From 7d564efbccc4b361d2fa2db2902fb35882304aae Mon Sep 17 00:00:00 2001 From: polo Date: Tue, 20 Dec 2022 03:31:33 +0100 Subject: recherche de clients --- src/view/Zenity.php | 62 +++++++++++++++++++++++++++++++++++++---------- src/view/zenity_setup.php | 2 +- 2 files changed, 50 insertions(+), 14 deletions(-) (limited to 'src/view') diff --git a/src/view/Zenity.php b/src/view/Zenity.php index 04c9221..1299d1c 100644 --- a/src/view/Zenity.php +++ b/src/view/Zenity.php @@ -9,7 +9,7 @@ abstract class ZenityCmd protected $command_type = ''; protected $rows = []; private $title = 'ORDIPOLO'; - private $text = ''; + protected $text = ''; protected $width = 300; protected $height = 200; // recalculée en fonction du contenu, vaut au minimum 150 @@ -31,35 +31,71 @@ abstract class ZenityCmd class ZenityList extends ZenityCmd { - public function __construct(string $text, array $rows) + private $columns = 1; // tableau simple ou multidimensionnel? + + public function __construct(string $text, array $rows = [], int $columns = 1) { $this->command_type = ' --list'; parent::__construct($text, $rows); + $this->columns = $columns; $this->height = 80 + count($this->rows) * 25; - $this->command .= ' --width=' . $this->width; $this->command .= ' --height=' . $this->height; $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text - self::oneColumnZenityList($this->rows); + if($this->rows !== []) + { + $this->command .= ' --width=' . $this->width; + $this->fillZenityList(); + } } // cas ou $this->rows est renseignée après - public function setEntries(array $rows_set) + // la valeur de $columns n'est plus nécessairement celle apr défaut + public function setListRows(array $rows, string $table) { - $this->rows = $rows_set; + $this->rows = $rows; + $this->columns = count(StructTablesDB::$structureOfTables[$table]); + $this->width = 600; + $this->command .= ' --width=' . $this->width; + $this->fillZenityList(); } - // cas où on veut une seule colonne - private function oneColumnZenityList(array $rows) + // noter que la syntaxe de zentity --list est déroutante! + // le remplissage est horizontal et le nombre de colonne dépend du nombre d'occurence de --column="" + public function fillZenityList() { - $output = ' --column=""'; - foreach($rows as $entry) + $output = ''; + if($this->columns === 1) { - $output .= ' "' . $entry . '"'; // forme: ' "choix 1" "choix 2"' + $output .= ' --column=""'; + // remplissage vertical + foreach($this->rows as $one_row) + { + $output .= ' "' . $one_row . '"'; // forme: ' "choix 1" "choix 2"' + } + } + elseif($this->columns >= 2) // marche quelque soit le nombre de colonnes + { + for($i = 0; $i < $this->columns; $i++) + { + $output .= ' --column=""'; + } + // remplissage horizontal, un sous-tableau = une ligne + foreach($this->rows as $one_row) + { + foreach($one_row as $one_field) + { + $output .= ' "' . $one_field . '"'; + } + } } $this->command .= $output; } - // cas où on veut plusieurs colonnes, le remplissage est horizontal, oui c'est tordu! + public function cleanCommand() + { + $this->command = 'zenity'; + $this->__construct($this->text); + } } class ZenityQuestion extends ZenityCmd @@ -74,7 +110,7 @@ class ZenityQuestion extends ZenityCmd } } -// note: le formulaire renvoie une chaine avecdes pipes | entre les zones de texte (qui peuvent être vides) +// note: le formulaire renvoie une chaine avec des pipes | entre les zones de texte (qui peuvent être vides) // si on clique sur 'Annuler', renvoie une chaine vide class ZenityForms extends ZenityCmd { diff --git a/src/view/zenity_setup.php b/src/view/zenity_setup.php index 503ae71..042d1ab 100644 --- a/src/view/zenity_setup.php +++ b/src/view/zenity_setup.php @@ -30,7 +30,7 @@ $MenuEnregistrement = new ZenityList($menu_enregistrement_text, $menu_enregistre $MenuDocuments = new ZenityList($menu_documents_text, $menu_documents_entrees); $MenuCommunication = new ZenityList($menu_communication_text, $menu_communication_entrees); $RechercheClient = new zenityEntry($recherche_client_text); -$ResultatsRechercheClient = new zenityList($resultats_recherche_client_text, []); +$ResultatsRechercheClient = new ZenityList($resultats_recherche_client_text, [], 2); $NouveauClient = new ZenityForms($nouveau_client_text, $nouveau_client_entrees); $Calendrier = new ZenityCalendar($calendar_text); $FormulairePrestation = new ZenityForms($formulaire_text, $formulaire_entrees); -- cgit v1.2.3