diff options
| author | polo <ordipolo@gmx.fr> | 2026-07-17 23:04:59 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2026-07-17 23:04:59 +0200 |
| commit | 9ca2e7f3b212ca7434bb169f7c1b9ac0f8b2b22e (patch) | |
| tree | 754f601c6010fa428425178b36f102e2c732908f /src | |
| parent | e30f1b6f6bc6df56aa7ed2dff4169ab7d7f93fc4 (diff) | |
| download | AppliGestionPHP-9ca2e7f3b212ca7434bb169f7c1b9ac0f8b2b22e.tar.gz AppliGestionPHP-9ca2e7f3b212ca7434bb169f7c1b9ac0f8b2b22e.tar.bz2 AppliGestionPHP-9ca2e7f3b212ca7434bb169f7c1b9ac0f8b2b22e.zip | |
param ?Client dans newService() et modifyData(), gitignore, config-template
Diffstat (limited to 'src')
| -rw-r--r-- | src/model/entities/Client.php | 12 | ||||
| -rw-r--r-- | src/sections/2_service.php | 10 | ||||
| -rw-r--r-- | src/sections/3_modify_data.php | 11 |
3 files changed, 14 insertions, 19 deletions
diff --git a/src/model/entities/Client.php b/src/model/entities/Client.php index 7dd3be6..a81519a 100644 --- a/src/model/entities/Client.php +++ b/src/model/entities/Client.php | |||
| @@ -216,7 +216,7 @@ class Client | |||
| 216 | return true; | 216 | return true; |
| 217 | } | 217 | } |
| 218 | 218 | ||
| 219 | public static function getObject(ZenityEntry $SearchCustomerForm, ZenityList $SearchCustomerResults) // renvoie un Client ou 0 | 219 | public static function find(ZenityEntry $SearchCustomerForm, ZenityList $SearchCustomerResults): ?Client |
| 220 | { | 220 | { |
| 221 | // fenêtres | 221 | // fenêtres |
| 222 | /*$SearchCustomerForm = new ZenityEntry(ZenitySetup::$recherche_client_text); | 222 | /*$SearchCustomerForm = new ZenityEntry(ZenitySetup::$recherche_client_text); |
| @@ -228,11 +228,11 @@ class Client | |||
| 228 | if($input == '') // commenter ce if pour qu'une saisie vide permette d'obtenir tous les clients | 228 | if($input == '') // commenter ce if pour qu'une saisie vide permette d'obtenir tous les clients |
| 229 | { | 229 | { |
| 230 | echo "debug: recherche annulée ou saisie vide\n"; | 230 | echo "debug: recherche annulée ou saisie vide\n"; |
| 231 | return 0; | 231 | return null; |
| 232 | } | 232 | } |
| 233 | echo "debug: recherche effectuée\n"; | 233 | echo "debug: recherche effectuée\n"; |
| 234 | 234 | ||
| 235 | $MatchedObjects = self::searchCustomer($input, $Customer); | 235 | $MatchedObjects = self::search($input, $Customer); |
| 236 | if(count($MatchedObjects) === 0) // si aucun client ne correspond, les prendre tous! | 236 | if(count($MatchedObjects) === 0) // si aucun client ne correspond, les prendre tous! |
| 237 | { | 237 | { |
| 238 | $repository = self::$entityManager->getRepository('Client'); | 238 | $repository = self::$entityManager->getRepository('Client'); |
| @@ -241,7 +241,7 @@ class Client | |||
| 241 | if(count($MatchedObjects) === 0) // toujours rien | 241 | if(count($MatchedObjects) === 0) // toujours rien |
| 242 | { | 242 | { |
| 243 | echo "debug: aucun client dans la base de données\n"; | 243 | echo "debug: aucun client dans la base de données\n"; |
| 244 | return 0; | 244 | return null; |
| 245 | } | 245 | } |
| 246 | } | 246 | } |
| 247 | 247 | ||
| @@ -261,7 +261,7 @@ class Client | |||
| 261 | if($input == '') | 261 | if($input == '') |
| 262 | { | 262 | { |
| 263 | echo "debug: client pas trouvé ou pas sélectionné\n"; | 263 | echo "debug: client pas trouvé ou pas sélectionné\n"; |
| 264 | return 0; | 264 | return null; |
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | echo "debug: client sélectionné\n"; | 267 | echo "debug: client sélectionné\n"; |
| @@ -273,7 +273,7 @@ class Client | |||
| 273 | return $Customer; | 273 | return $Customer; |
| 274 | } | 274 | } |
| 275 | 275 | ||
| 276 | private static function searchCustomer(string $input, Client $Customer): array | 276 | private static function search(string $input, Client $Customer): array |
| 277 | { | 277 | { |
| 278 | $input_array = explode(' ', $input); // si plusieurs mot, on les recherche tous l'un après l'autre | 278 | $input_array = explode(' ', $input); // si plusieurs mot, on les recherche tous l'un après l'autre |
| 279 | return $Customer->findByKeywords($input_array, 'prenom_nom'); // on obtient un tableau à deux dimensions avec les entrées trouvées | 279 | return $Customer->findByKeywords($input_array, 'prenom_nom'); // on obtient un tableau à deux dimensions avec les entrées trouvées |
diff --git a/src/sections/2_service.php b/src/sections/2_service.php index e25d677..9ebf303 100644 --- a/src/sections/2_service.php +++ b/src/sections/2_service.php | |||
| @@ -3,9 +3,7 @@ | |||
| 3 | // | 3 | // |
| 4 | // -- SECTION 2: Prestation et devis -- | 4 | // -- SECTION 2: Prestation et devis -- |
| 5 | 5 | ||
| 6 | use Doctrine\ORM\EntityManager; | 6 | function newService(?Client $Client = null): array |
| 7 | |||
| 8 | function newService($Client): array // $Client est un Client ou null | ||
| 9 | { | 7 | { |
| 10 | // fenêtres recherche d'un client | 8 | // fenêtres recherche d'un client |
| 11 | $RechercheClient = new zenityEntry(ZenitySetup::$recherche_client['text']); | 9 | $RechercheClient = new zenityEntry(ZenitySetup::$recherche_client['text']); |
| @@ -25,11 +23,11 @@ function newService($Client): array // $Client est un Client ou null | |||
| 25 | 23 | ||
| 26 | 24 | ||
| 27 | // -- partie 1: le client -- | 25 | // -- partie 1: le client -- |
| 28 | if($Client == null || get_class($Client) !== 'Client') | 26 | if(!$Client) |
| 29 | { | 27 | { |
| 30 | $Client = Client::getObject($RechercheClient, $ResultatsRechercheClient); // retourne un Client ou 0 | 28 | $Client = Client::find($RechercheClient, $ResultatsRechercheClient); // retourne un Client ou 0 |
| 31 | //$ResultatsRechercheClient->cleanCommand(); // inutile parce qu'on ne boucle pas dans cette fonction | 29 | //$ResultatsRechercheClient->cleanCommand(); // inutile parce qu'on ne boucle pas dans cette fonction |
| 32 | if($Client === 0) | 30 | if(!$Client) |
| 33 | { | 31 | { |
| 34 | echo "debug: annulation sélection client\n"; | 32 | echo "debug: annulation sélection client\n"; |
| 35 | return [0, null]; // menu principal | 33 | return [0, null]; // menu principal |
diff --git a/src/sections/3_modify_data.php b/src/sections/3_modify_data.php index 00fe220..607638b 100644 --- a/src/sections/3_modify_data.php +++ b/src/sections/3_modify_data.php | |||
| @@ -5,9 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | require('3-1_windows.php'); | 6 | require('3-1_windows.php'); |
| 7 | 7 | ||
| 8 | use Doctrine\ORM\EntityManager; | 8 | function modifyData(?Client $Client = null): array |
| 9 | |||
| 10 | function modifyData($Client): array | ||
| 11 | { | 9 | { |
| 12 | // -- partie 1: rechercher un client -- | 10 | // -- partie 1: rechercher un client -- |
| 13 | 11 | ||
| @@ -19,12 +17,11 @@ function modifyData($Client): array | |||
| 19 | $TypeDeClient = new ZenityList(ZenitySetup::$type_client['text'], ZenitySetup::$type_client['entrees']); | 17 | $TypeDeClient = new ZenityList(ZenitySetup::$type_client['text'], ZenitySetup::$type_client['entrees']); |
| 20 | $Calendrier = new ZenityCalendar(ZenitySetup::$calendar['section3']); | 18 | $Calendrier = new ZenityCalendar(ZenitySetup::$calendar['section3']); |
| 21 | 19 | ||
| 22 | if($Client == null || get_class($Client) !== 'Client') // étape sautable | 20 | if(!$Client) |
| 23 | { | 21 | { |
| 24 | $Client = Client::getObject($RechercheClient, $ResultatsRechercheClient); // = 0 ou type "Client" | 22 | $Client = Client::find($RechercheClient, $ResultatsRechercheClient); |
| 25 | //$ResultatsRechercheClient->cleanCommand(); // inutile parce qu'on ne boucle pas dans cette fonction | 23 | //$ResultatsRechercheClient->cleanCommand(); // inutile parce qu'on ne boucle pas dans cette fonction |
| 26 | //if(!is_object($Client) || !get_class($Client) == 'Client') | 24 | if(!$Client) |
| 27 | if($Client === 0) | ||
| 28 | { | 25 | { |
| 29 | echo "debug: annulation sélection client\n"; | 26 | echo "debug: annulation sélection client\n"; |
| 30 | return [0, null]; // menu principal | 27 | return [0, null]; // menu principal |
