diff options
| author | polo <ordipolo@gmx.fr> | 2022-12-20 03:31:33 +0100 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2022-12-20 03:31:33 +0100 |
| commit | 7d564efbccc4b361d2fa2db2902fb35882304aae (patch) | |
| tree | efc28d94a1387f918c84201318880d74a52adf84 /src/view | |
| parent | dedbe2f5cee33431c1299c7f0dbef4e247dc2447 (diff) | |
| download | AppliGestionPHP-7d564efbccc4b361d2fa2db2902fb35882304aae.tar.gz AppliGestionPHP-7d564efbccc4b361d2fa2db2902fb35882304aae.tar.bz2 AppliGestionPHP-7d564efbccc4b361d2fa2db2902fb35882304aae.zip | |
recherche de clients
Diffstat (limited to 'src/view')
| -rw-r--r-- | src/view/Zenity.php | 62 | ||||
| -rw-r--r-- | src/view/zenity_setup.php | 2 |
2 files changed, 50 insertions, 14 deletions
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 | |||
| 9 | protected $command_type = ''; | 9 | protected $command_type = ''; |
| 10 | protected $rows = []; | 10 | protected $rows = []; |
| 11 | private $title = 'ORDIPOLO'; | 11 | private $title = 'ORDIPOLO'; |
| 12 | private $text = ''; | 12 | protected $text = ''; |
| 13 | protected $width = 300; | 13 | protected $width = 300; |
| 14 | protected $height = 200; // recalculée en fonction du contenu, vaut au minimum 150 | 14 | protected $height = 200; // recalculée en fonction du contenu, vaut au minimum 150 |
| 15 | 15 | ||
| @@ -31,35 +31,71 @@ abstract class ZenityCmd | |||
| 31 | 31 | ||
| 32 | class ZenityList extends ZenityCmd | 32 | class ZenityList extends ZenityCmd |
| 33 | { | 33 | { |
| 34 | public function __construct(string $text, array $rows) | 34 | private $columns = 1; // tableau simple ou multidimensionnel? |
| 35 | |||
| 36 | public function __construct(string $text, array $rows = [], int $columns = 1) | ||
| 35 | { | 37 | { |
| 36 | $this->command_type = ' --list'; | 38 | $this->command_type = ' --list'; |
| 37 | parent::__construct($text, $rows); | 39 | parent::__construct($text, $rows); |
| 40 | $this->columns = $columns; | ||
| 38 | $this->height = 80 + count($this->rows) * 25; | 41 | $this->height = 80 + count($this->rows) * 25; |
| 39 | $this->command .= ' --width=' . $this->width; | ||
| 40 | $this->command .= ' --height=' . $this->height; | 42 | $this->command .= ' --height=' . $this->height; |
| 41 | $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text | 43 | $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text |
| 42 | self::oneColumnZenityList($this->rows); | 44 | if($this->rows !== []) |
| 45 | { | ||
| 46 | $this->command .= ' --width=' . $this->width; | ||
| 47 | $this->fillZenityList(); | ||
| 48 | } | ||
| 43 | } | 49 | } |
| 44 | 50 | ||
| 45 | // cas ou $this->rows est renseignée après | 51 | // cas ou $this->rows est renseignée après |
| 46 | public function setEntries(array $rows_set) | 52 | // la valeur de $columns n'est plus nécessairement celle apr défaut |
| 53 | public function setListRows(array $rows, string $table) | ||
| 47 | { | 54 | { |
| 48 | $this->rows = $rows_set; | 55 | $this->rows = $rows; |
| 56 | $this->columns = count(StructTablesDB::$structureOfTables[$table]); | ||
| 57 | $this->width = 600; | ||
| 58 | $this->command .= ' --width=' . $this->width; | ||
| 59 | $this->fillZenityList(); | ||
| 49 | } | 60 | } |
| 50 | 61 | ||
| 51 | // cas où on veut une seule colonne | 62 | // noter que la syntaxe de zentity --list est déroutante! |
| 52 | private function oneColumnZenityList(array $rows) | 63 | // le remplissage est horizontal et le nombre de colonne dépend du nombre d'occurence de --column="" |
| 64 | public function fillZenityList() | ||
| 53 | { | 65 | { |
| 54 | $output = ' --column=""'; | 66 | $output = ''; |
| 55 | foreach($rows as $entry) | 67 | if($this->columns === 1) |
| 56 | { | 68 | { |
| 57 | $output .= ' "' . $entry . '"'; // forme: ' "choix 1" "choix 2"' | 69 | $output .= ' --column=""'; |
| 70 | // remplissage vertical | ||
| 71 | foreach($this->rows as $one_row) | ||
| 72 | { | ||
| 73 | $output .= ' "' . $one_row . '"'; // forme: ' "choix 1" "choix 2"' | ||
| 74 | } | ||
| 75 | } | ||
| 76 | elseif($this->columns >= 2) // marche quelque soit le nombre de colonnes | ||
| 77 | { | ||
| 78 | for($i = 0; $i < $this->columns; $i++) | ||
| 79 | { | ||
| 80 | $output .= ' --column=""'; | ||
| 81 | } | ||
| 82 | // remplissage horizontal, un sous-tableau = une ligne | ||
| 83 | foreach($this->rows as $one_row) | ||
| 84 | { | ||
| 85 | foreach($one_row as $one_field) | ||
| 86 | { | ||
| 87 | $output .= ' "' . $one_field . '"'; | ||
| 88 | } | ||
| 89 | } | ||
| 58 | } | 90 | } |
| 59 | $this->command .= $output; | 91 | $this->command .= $output; |
| 60 | } | 92 | } |
| 61 | 93 | ||
| 62 | // cas où on veut plusieurs colonnes, le remplissage est horizontal, oui c'est tordu! | 94 | public function cleanCommand() |
| 95 | { | ||
| 96 | $this->command = 'zenity'; | ||
| 97 | $this->__construct($this->text); | ||
| 98 | } | ||
| 63 | } | 99 | } |
| 64 | 100 | ||
| 65 | class ZenityQuestion extends ZenityCmd | 101 | class ZenityQuestion extends ZenityCmd |
| @@ -74,7 +110,7 @@ class ZenityQuestion extends ZenityCmd | |||
| 74 | } | 110 | } |
| 75 | } | 111 | } |
| 76 | 112 | ||
| 77 | // note: le formulaire renvoie une chaine avecdes pipes | entre les zones de texte (qui peuvent être vides) | 113 | // note: le formulaire renvoie une chaine avec des pipes | entre les zones de texte (qui peuvent être vides) |
| 78 | // si on clique sur 'Annuler', renvoie une chaine vide | 114 | // si on clique sur 'Annuler', renvoie une chaine vide |
| 79 | class ZenityForms extends ZenityCmd | 115 | class ZenityForms extends ZenityCmd |
| 80 | { | 116 | { |
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 | |||
| 30 | $MenuDocuments = new ZenityList($menu_documents_text, $menu_documents_entrees); | 30 | $MenuDocuments = new ZenityList($menu_documents_text, $menu_documents_entrees); |
| 31 | $MenuCommunication = new ZenityList($menu_communication_text, $menu_communication_entrees); | 31 | $MenuCommunication = new ZenityList($menu_communication_text, $menu_communication_entrees); |
| 32 | $RechercheClient = new zenityEntry($recherche_client_text); | 32 | $RechercheClient = new zenityEntry($recherche_client_text); |
| 33 | $ResultatsRechercheClient = new zenityList($resultats_recherche_client_text, []); | 33 | $ResultatsRechercheClient = new ZenityList($resultats_recherche_client_text, [], 2); |
| 34 | $NouveauClient = new ZenityForms($nouveau_client_text, $nouveau_client_entrees); | 34 | $NouveauClient = new ZenityForms($nouveau_client_text, $nouveau_client_entrees); |
| 35 | $Calendrier = new ZenityCalendar($calendar_text); | 35 | $Calendrier = new ZenityCalendar($calendar_text); |
| 36 | $FormulairePrestation = new ZenityForms($formulaire_text, $formulaire_entrees); | 36 | $FormulairePrestation = new ZenityForms($formulaire_text, $formulaire_entrees); |
