diff options
| -rw-r--r-- | config.php | 8 | ||||
| -rw-r--r-- | data/ordipolo.sqlite | bin | 0 -> 32768 bytes | |||
| -rw-r--r-- | src/Dates.php | 78 | ||||
| -rw-r--r-- | src/functions.php | 18 | ||||
| -rwxr-xr-x | src/main.php | 160 | ||||
| -rw-r--r-- | src/model/CESU.php | 23 | ||||
| -rw-r--r-- | src/model/Clients.php | 56 | ||||
| -rw-r--r-- | src/model/DevisFactures.php | 32 | ||||
| -rw-r--r-- | src/model/Locations.php | 21 | ||||
| -rw-r--r-- | src/model/Model.php | 12 | ||||
| -rw-r--r-- | src/model/Prestations.php | 81 | ||||
| -rw-r--r-- | src/model/StructTablesDB.php | 6 | ||||
| -rw-r--r-- | src/model/traits.php | 18 | ||||
| -rw-r--r-- | src/sections/1_new_service.php | 241 | ||||
| -rw-r--r-- | src/view/Zenity.php | 29 | ||||
| -rw-r--r-- | src/view/ZenitySetup.php | 30 | ||||
| -rw-r--r-- | src/view/zenity_setup.php | 37 |
17 files changed, 572 insertions, 278 deletions
| @@ -55,15 +55,15 @@ $publishing = 'scribus'; | |||
| 55 | // $sqliteGUI = 'sqlitebrowser'; | 55 | // $sqliteGUI = 'sqlitebrowser'; |
| 56 | $sqlite_gui = 'sqlitebrowser'; | 56 | $sqlite_gui = 'sqlitebrowser'; |
| 57 | 57 | ||
| 58 | // format des dates: EU exemple européenne 28-11-2022, US exemple américaine 11/28/2022 | 58 | // format des dates: 'euro' exemple 28-11-2022, 'usa' exemple 11/28/2022 |
| 59 | // $date_format = 'EU'; | 59 | // $date_format = 'euro'; |
| 60 | $date_format = 'EU'; | 60 | $date_format = 'euro'; |
| 61 | 61 | ||
| 62 | 62 | ||
| 63 | // $x_terminal = 'xterm'; | 63 | // $x_terminal = 'xterm'; |
| 64 | // -- état actuel du programme -- | 64 | // -- état actuel du programme -- |
| 65 | // les terminaux gérés sont: xterm, urxvt, lxterminal, xfce4-terminal, gnome-terminal, konsole, Terminal (MAC, désactivé tant que non testé) | 65 | // les terminaux gérés sont: xterm, urxvt, lxterminal, xfce4-terminal, gnome-terminal, konsole, Terminal (MAC, désactivé tant que non testé) |
| 66 | // ajouter à l'accaz: i3-sensible-terminal (pour i3), lxterminal-qt (pour LXQT, et donc lubuntu) | 66 | // ajouter à l'accaz: i3-sensible-terminal (pour i3), lxterminal-qt (pour lubuntu) |
| 67 | // le choix est automatique en prenant le 1er terminal disponible, ceux-ci sont testés un par un dans l'ordre de la liste ci-dessus | 67 | // le choix est automatique en prenant le 1er terminal disponible, ceux-ci sont testés un par un dans l'ordre de la liste ci-dessus |
| 68 | 68 | ||
| 69 | 69 | ||
diff --git a/data/ordipolo.sqlite b/data/ordipolo.sqlite new file mode 100644 index 0000000..2c76848 --- /dev/null +++ b/data/ordipolo.sqlite | |||
| Binary files differ | |||
diff --git a/src/Dates.php b/src/Dates.php index de71b08..36b19a8 100644 --- a/src/Dates.php +++ b/src/Dates.php | |||
| @@ -3,56 +3,66 @@ | |||
| 3 | 3 | ||
| 4 | class Dates | 4 | class Dates |
| 5 | { | 5 | { |
| 6 | private $date; | 6 | private $date = ''; |
| 7 | private $timestamp; // valeurs négatives autorisées => dates avant 1970 | 7 | static public $date_format = 'euro'; // dates européennes jj-mm-aaaa (EU) ou américaines mm/dd/yyyy (US) |
| 8 | static public $date_format = 'EU'; // dates européennes jj-mm-aaaa (EU) ou américaines mm/dd/yyyy (US) | ||
| 9 | 8 | ||
| 9 | private $day = ''; | ||
| 10 | private $month = ''; | ||
| 11 | private $year = ''; | ||
| 10 | 12 | ||
| 11 | public function __construct($entry = NULL) | 13 | private $timestamp = 0; // valeurs négatives autorisées => dates avant 1970 |
| 14 | |||
| 15 | public function __construct($input = NULL) | ||
| 12 | { | 16 | { |
| 13 | if(gettype($entry) === 'string') // une date est attendue | 17 | if(gettype($input) === 'string' && $input !== '') // une date est attendue |
| 14 | { | 18 | { |
| 15 | $this->setDate($entry); | 19 | $this->setDate($input); |
| 16 | } | 20 | } |
| 17 | elseif(gettype($entry) === 'integer') | 21 | elseif(gettype($input) === 'integer' && $input !== 0) |
| 18 | { | 22 | { |
| 19 | $this->setTimestamp($entry); | 23 | $this->setTimestamp($input); |
| 20 | } | 24 | } |
| 21 | } | 25 | } |
| 22 | 26 | ||
| 23 | 27 | ||
| 24 | public function setDate(string $entry) | 28 | public function setDate(string $input) |
| 25 | { | 29 | { |
| 26 | $entry = $this->dashOrSlash($entry); // pour strtotime() | 30 | $input = $this->dashOrSlash($input); // pour strtotime() |
| 27 | 31 | ||
| 28 | $splitedDate = preg_split('#\D#', $entry); // \D = tout sauf chiffre | 32 | $splitedDate = preg_split('#\D#', $input); // \D = tout sauf chiffre |
| 33 | $this->year = $splitedDate[2]; | ||
| 29 | 34 | ||
| 30 | if(self::$date_format === 'EU') | 35 | if(self::$date_format === 'euro') |
| 31 | { | 36 | { |
| 32 | $tmp = $splitedDate[0]; | 37 | $this->day = $splitedDate[1]; |
| 33 | $splitedDate[0] = $splitedDate[1]; | 38 | $this->month = $splitedDate[0]; |
| 34 | $splitedDate[1] = $tmp; | 39 | } |
| 40 | else | ||
| 41 | { | ||
| 42 | $this->day = $splitedDate[0]; | ||
| 43 | $this->month = $splitedDate[1]; | ||
| 35 | } | 44 | } |
| 36 | 45 | ||
| 37 | if(checkdate($splitedDate[0], $splitedDate[1], $splitedDate[2])) | 46 | //~ if(checkdate($splitedDate[0], $splitedDate[1], $splitedDate[2])) |
| 47 | if(checkdate($this->day, $this->month, $this->year)) | ||
| 38 | { | 48 | { |
| 39 | $this->date = $entry; | 49 | $this->date = $input; |
| 40 | $this->timestamp = strtotime($entry); // date (string) -> timestamp (int) | 50 | $this->timestamp = strtotime($input); // date (string) -> timestamp (int) |
| 41 | // strtotime() devine le format en analysant la chaîne en entrée, on l'aide un peu | 51 | // strtotime() devine le format en analysant la chaîne en entrée, on l'aide un peu |
| 42 | // avec des /, php considère que la date est américaine | 52 | // avec des /, php considère que la date est américaine |
| 43 | // avec des - ou des ., php considère que la date est européenne | 53 | // avec des - ou des ., php considère que la date est européenne |
| 44 | } | 54 | } |
| 45 | else | 55 | else |
| 46 | { | 56 | { |
| 47 | echo("Date incorrecte, le format de la date dans le fichier config.php est " . self::$date_format . ".\nLes choix possibles sont EU pour Europe et US pour États-Unis."); | 57 | echo("Date incorrecte, le format de la date dans le fichier config.php est " . self::$date_format . ".\nLes choix possibles sont 'euro' pour Europe et 'usa' pour États-Unis."); |
| 48 | die(); | 58 | die(); |
| 49 | } | 59 | } |
| 50 | } | 60 | } |
| 51 | 61 | ||
| 52 | public function setTimestamp(int $entry) | 62 | public function setTimestamp(int $input) |
| 53 | { | 63 | { |
| 54 | $this->timestamp = $entry; | 64 | $this->timestamp = $input; |
| 55 | $this->date = $this->timestamp_to_date($entry); // timestamp (int) -> date (string) | 65 | $this->date = $this->timestamp_to_date($input); // timestamp (int) -> date (string) |
| 56 | } | 66 | } |
| 57 | 67 | ||
| 58 | 68 | ||
| @@ -60,6 +70,18 @@ class Dates | |||
| 60 | { | 70 | { |
| 61 | return($this->date); | 71 | return($this->date); |
| 62 | } | 72 | } |
| 73 | public function getDay(): string | ||
| 74 | { | ||
| 75 | return($this->day); | ||
| 76 | } | ||
| 77 | public function getMonth(): string | ||
| 78 | { | ||
| 79 | return($this->month); | ||
| 80 | } | ||
| 81 | public function getYear(): string | ||
| 82 | { | ||
| 83 | return($this->year); | ||
| 84 | } | ||
| 63 | 85 | ||
| 64 | public function getTimestamp(): int | 86 | public function getTimestamp(): int |
| 65 | { | 87 | { |
| @@ -69,36 +91,36 @@ class Dates | |||
| 69 | 91 | ||
| 70 | private function dashOrSlash(string $date): string | 92 | private function dashOrSlash(string $date): string |
| 71 | { | 93 | { |
| 72 | if(self::$date_format === 'EU') | 94 | if(self::$date_format === 'euro') |
| 73 | { | 95 | { |
| 74 | // change jj/mm/aaaa en jj-mm-aaaa | 96 | // change jj/mm/aaaa en jj-mm-aaaa |
| 75 | return(preg_replace('#\D#', '-', $date)); // \D = tout sauf chiffre | 97 | return(preg_replace('#\D#', '-', $date)); // \D = tout sauf chiffre |
| 76 | } | 98 | } |
| 77 | elseif(self::$date_format === 'US') | 99 | elseif(self::$date_format === 'usa') |
| 78 | { | 100 | { |
| 79 | // change mm-dd.yyyy en mm/dd/yyyy | 101 | // change mm-dd.yyyy en mm/dd/yyyy |
| 80 | return(preg_replace('#\D#', '/', $date)); | 102 | return(preg_replace('#\D#', '/', $date)); |
| 81 | } | 103 | } |
| 82 | else | 104 | else |
| 83 | { | 105 | { |
| 84 | echo('Le fichier config.php comporte une erreur. La variable $date_format doit avoir pour valeur "EU" ou "US"'); | 106 | echo("Le fichier config.php comporte une erreur. La variable $date_format doit avoir pour valeur 'euro' ou 'usa'"); |
| 85 | die(); // brutal | 107 | die(); // brutal |
| 86 | } | 108 | } |
| 87 | } | 109 | } |
| 88 | 110 | ||
| 89 | private function timestamp_to_date(int $timestamp): string | 111 | private function timestamp_to_date(int $timestamp): string |
| 90 | { | 112 | { |
| 91 | if(self::$date_format === 'EU') | 113 | if(self::$date_format === 'euro') |
| 92 | { | 114 | { |
| 93 | return(date("j-m-Y", $timestamp)); | 115 | return(date("j-m-Y", $timestamp)); |
| 94 | } | 116 | } |
| 95 | elseif(self::$date_format === 'US') | 117 | elseif(self::$date_format === 'usa') |
| 96 | { | 118 | { |
| 97 | return(date("m/d/Y", $timestamp)); | 119 | return(date("m/d/Y", $timestamp)); |
| 98 | } | 120 | } |
| 99 | else | 121 | else |
| 100 | { | 122 | { |
| 101 | echo('Le fichier config.php comporte une erreur. La variable $date_format doit avoir pour valeur "EU" ou "US"'); | 123 | echo("Le fichier config.php comporte une erreur. La variable $date_format doit avoir pour valeur 'euro' ou 'usa'"); |
| 102 | die(); // brutal | 124 | die(); // brutal |
| 103 | } | 125 | } |
| 104 | } | 126 | } |
diff --git a/src/functions.php b/src/functions.php index 82263bb..bdcd594 100644 --- a/src/functions.php +++ b/src/functions.php | |||
| @@ -30,24 +30,26 @@ function rechercheClient(string $input, Clients $Client): array | |||
| 30 | return($result); | 30 | return($result); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | // NOTE 1: les objets sont passés aux fonctions par référence par défaut, toutefois ce n'est pas entièrement vrai | 33 | // NOTE 1: en PHP les objets sont passés aux fonctions par référence par défaut, toutefois ce n'est pas entièrement vrai |
| 34 | // NOTE 2: PHP n'a pas de pointeur mais des références, une référence est un alias qui ne contient pas l'objet lui-même | 34 | // NOTE 2: PHP n'a pas de pointeur mais des références, une référence est un alias qui ne contient pas l'objet lui-même |
| 35 | // NOTE 3: la variable créée lors d'un "new" est elle-même une référence contenant un identifiant (= le pointeur?) | 35 | // NOTE 3: la variable créée lors d'un "new" est elle-même une référence contenant un identifiant (= le pointeur?) |
| 36 | // NOTE 4: l'objet est détruit lorsque la dernière référence est supprimée | 36 | // NOTE 4: l'objet est détruit lorsque la dernière référence est supprimée |
| 37 | 37 | ||
| 38 | function enregistrementNouveauClient(string $name, Clients $Client): bool | 38 | function controlFormInput(array $data): bool |
| 39 | { | 39 | { |
| 40 | if($name !== '') | 40 | $tableSize = count(StructTablesDB::$structureOfTables[$table]); // int |
| 41 | if($data !== '') | ||
| 41 | { | 42 | { |
| 42 | $tableau = explode('|', $name); | 43 | $dataArray = explode('|', $data); |
| 43 | if(count($tableau) === 4) | 44 | |
| 45 | if(count($dataArray) === $tableSize - 1) // nombre de champs sauf ID qui est auto-incrémenté automatiquement | ||
| 44 | { | 46 | { |
| 45 | $Client->newRow($tableau); // écriture dans la BDD | 47 | |
| 46 | return true; | 48 | |
| 47 | } | 49 | } |
| 48 | else | 50 | else |
| 49 | { | 51 | { |
| 50 | echo "debug: mauvais tableau, il doit avoir 4 cases\n"; | 52 | echo "debug: mauvais tableau, il doit avoir " . $tableSize - 1 . " cases\n"; |
| 51 | return false; | 53 | return false; |
| 52 | } | 54 | } |
| 53 | } | 55 | } |
diff --git a/src/main.php b/src/main.php index 3c9c4aa..12715f3 100755 --- a/src/main.php +++ b/src/main.php | |||
| @@ -39,162 +39,67 @@ require('model/CESU.php'); | |||
| 39 | require('model/Locations.php'); | 39 | require('model/Locations.php'); |
| 40 | 40 | ||
| 41 | require('view/Zenity.php'); // commande système zenity | 41 | require('view/Zenity.php'); // commande système zenity |
| 42 | require('view/zenity_setup.php'); // texte dans les fenêtres ET instanciation (un objet = une commande) | 42 | require('view/ZenitySetup.php'); // texte dans les fenêtres ET instanciation (un objet = une commande) |
| 43 | require('Latex.php'); // générer le code LaTeX | 43 | require('Latex.php'); // générer le code LaTeX |
| 44 | 44 | ||
| 45 | require('sections/1_new_service.php'); | ||
| 46 | |||
| 45 | 47 | ||
| 46 | // boucle principale | 48 | // boucle principale |
| 47 | $boucle = true; | 49 | $boucle = true; |
| 48 | while($boucle) | 50 | while($boucle) |
| 49 | { | 51 | { |
| 50 | // niveau 1: menu principal | 52 | // niveau 1: menu principal |
| 53 | $MenuPrincipal = new ZenityList(ZenitySetup::$menu_principal_text, ZenitySetup::$menu_principal_entrees); | ||
| 51 | $choix_niv1 = exec($MenuPrincipal->get()); | 54 | $choix_niv1 = exec($MenuPrincipal->get()); |
| 52 | 55 | ||
| 53 | // Nouvelle prestation | 56 | // -- SECTION 1: Nouvelle prestation -- |
| 54 | if($choix_niv1 === $menu_principal_entrees[0]) | 57 | if($choix_niv1 === ZenitySetup::$menu_principal_entrees[0]) |
| 55 | { | 58 | { |
| 56 | $Client = new Clients; | 59 | echo("choix: $choix_niv1\n"); |
| 57 | $id_client_connu = false; | 60 | newService(); |
| 58 | |||
| 59 | // niveau 2: est ce que le client est déjà dans la base? | ||
| 60 | if(exec($QuestionNouveauClient->get()) == '0') // $? = 0 signifie oui, double égal == pour le transtypage | ||
| 61 | { | ||
| 62 | echo "debug: recherche souhaitée\n"; | ||
| 63 | |||
| 64 | // niveau 3: saisie du nom du client | ||
| 65 | $nom_client = exec($RechercheClient->get()); | ||
| 66 | if($nom_client !== '') | ||
| 67 | { | ||
| 68 | echo "debug: recherche effectuée\n"; | ||
| 69 | $ResultatsRechercheClient->setListRows(rechercheClient($nom_client, $Client), $Client->getTable()); // recherche silencieuse | ||
| 70 | //~ var_dump($ResultatsRechercheClient->get()); die(); | ||
| 71 | unset($nom_client); | ||
| 72 | |||
| 73 | // niveau 4: sélection parmi les résultats | ||
| 74 | $choix_niv4 = exec($ResultatsRechercheClient->get()); | ||
| 75 | $ResultatsRechercheClient->cleanCommand(); | ||
| 76 | |||
| 77 | if($choix_niv4 !== '') | ||
| 78 | { | ||
| 79 | echo "debug: client sélectionné\n"; | ||
| 80 | $id_client_connu = true; | ||
| 81 | } | ||
| 82 | else | ||
| 83 | { | ||
| 84 | echo "debug: client pas trouvé ou pas sélectionné\n"; | ||
| 85 | } | ||
| 86 | } | ||
| 87 | else | ||
| 88 | { | ||
| 89 | echo "debug: recherche annulée ou saisie vide\n"; | ||
| 90 | } | ||
| 91 | } | ||
| 92 | else | ||
| 93 | { | ||
| 94 | echo "debug: nouveau client\n"; | ||
| 95 | } | ||
| 96 | |||
| 97 | // niveau 2: on n'a pas cherché OU on n'a pas trouvé | ||
| 98 | if(!$id_client_connu) | ||
| 99 | { | ||
| 100 | $id_client_connu = enregistrementNouveauClient(exec($NouveauClient->get()), $Client); // fenêtre + écriture BDD | ||
| 101 | } | ||
| 102 | |||
| 103 | // niveau 2: type comptable d'enregistrement: devis, facture, cesu ou pas de prestation | ||
| 104 | if($id_client_connu) | ||
| 105 | { | ||
| 106 | $choix_niv2 = exec($MenuEnregistrement->get()); | ||
| 107 | $continuer = true; | ||
| 108 | if($choix_niv2 === $menu_enregistrement_entrees[0]) | ||
| 109 | { | ||
| 110 | // | ||
| 111 | } | ||
| 112 | elseif($choix_niv2 === $menu_enregistrement_entrees[1]) | ||
| 113 | { | ||
| 114 | // | ||
| 115 | } | ||
| 116 | elseif($choix_niv2 === $menu_enregistrement_entrees[2]) | ||
| 117 | { | ||
| 118 | // | ||
| 119 | } | ||
| 120 | elseif($choix_niv2 === $menu_enregistrement_entrees[3]) | ||
| 121 | { | ||
| 122 | // | ||
| 123 | } | ||
| 124 | else | ||
| 125 | { | ||
| 126 | $continuer = false; // retour menu principal | ||
| 127 | } | ||
| 128 | |||
| 129 | if($continuer) | ||
| 130 | { | ||
| 131 | //niveau 3: détail de la prestation | ||
| 132 | $Date = new Dates(exec($Calendrier->get())); | ||
| 133 | $Objet->setDate($Date->getTimestamp()); // enregistrement du timestamp en BDD | ||
| 134 | |||
| 135 | exec($FormulairePrestation->get()); | ||
| 136 | // enregistrement date et prestation en BDD | ||
| 137 | |||
| 138 | exec($CommentairePrestation->get()); | ||
| 139 | // enregistrement commentaire en BDD | ||
| 140 | // vérification? | ||
| 141 | |||
| 142 | // tableau récaptilatif et demande de confirmation des informations | ||
| 143 | |||
| 144 | // création fichiers LaTeX et PDF | ||
| 145 | //~ $latex_path = '../data/latex/'; // noms de variables dans le config.php | ||
| 146 | //~ $file_name = 'devis.tex'; | ||
| 147 | //~ $template = 'devis'; // vaut 'devis' ou 'enveloppe_recto' ou 'enveloppe_verso' ou 'facture' ou 'location' | ||
| 148 | //~ $latex = getLatexFromTemplate($template); | ||
| 149 | //~ file_put_contents($latex_path . $file_name, $latex); // injection des variables & écriture du fichier | ||
| 150 | //~ $pdf_path = '../data/pdf/'; | ||
| 151 | //~ latexToPdf($latex_path, $file_name, $pdf_path); | ||
| 152 | |||
| 153 | // imprimer? | ||
| 154 | //~ $imprimer_facture = exec('zenity --question --width=250 --title="Base de données mise à jour" --text="Imprimer la facture?"'); | ||
| 155 | //~ $imprimer_enveloppe = exec('zenity --question --width=250 --title="Base de données mise à jour" --text="Imprimer l\'adresse sur une enveloppe? (insérer une enveloppe DL sans fenêtre dans l\'imprimante"'); | ||
| 156 | } | ||
| 157 | } | ||
| 158 | unset($Client); // suppression de la dernière référence (normallement) | ||
| 159 | } | 61 | } |
| 160 | 62 | ||
| 161 | // Modifier un enregistrement | 63 | // -- SECTION 2: Modifier un enregistrement -- |
| 162 | elseif($choix_niv1 === $menu_principal_entrees[1]) | 64 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[1]) |
| 163 | { | 65 | { |
| 164 | // niveau 2: | 66 | echo("choix: $choix_niv1\n"); |
| 165 | } | 67 | } |
| 166 | 68 | ||
| 167 | // Fichier clients | 69 | // -- SECTION 3: Fichier clients -- |
| 168 | elseif($choix_niv1 === $menu_principal_entrees[2]) | 70 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[2]) |
| 169 | { | 71 | { |
| 72 | echo("choix: $choix_niv1\n"); | ||
| 170 | // quel affichage? un grand tableau avec zenity? une page web? un document LaTeX? | 73 | // quel affichage? un grand tableau avec zenity? une page web? un document LaTeX? |
| 171 | } | 74 | } |
| 172 | 75 | ||
| 173 | // documents à imprimer | 76 | // -- SECTION 4: documents à imprimer -- |
| 174 | elseif($choix_niv1 === $menu_principal_entrees[3]) // = Créer/imprimer un document | 77 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[3]) // = Créer/imprimer un document |
| 175 | { | 78 | { |
| 79 | echo("choix: $choix_niv1\n"); | ||
| 80 | $MenuDocuments = new ZenityList(ZenitySetup::$menu_documents_text, ZenitySetup::$menu_documents_entrees); | ||
| 176 | $choix_niv2 = exec($MenuDocuments->get()); | 81 | $choix_niv2 = exec($MenuDocuments->get()); |
| 177 | if($choix_niv2 === $menu_documents_entrees[0]) | 82 | if($choix_niv2 === ZenitySetup::$menu_documents_entrees[0]) |
| 178 | { | 83 | { |
| 179 | 84 | ||
| 180 | } | 85 | } |
| 181 | elseif($choix_niv2 === $menu_documents_entrees[1]) // = Facture | 86 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[1]) // = Facture |
| 182 | { | 87 | { |
| 183 | 88 | ||
| 184 | } | 89 | } |
| 185 | elseif($choix_niv2 === $menu_documents_entrees[2]) // = Lettre avec adresse | 90 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[2]) // = Lettre avec adresse |
| 186 | { | 91 | { |
| 187 | 92 | ||
| 188 | } | 93 | } |
| 189 | elseif($choix_niv2 === $menu_documents_entrees[3]) // = Livre des recettes | 94 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[3]) // = Livre des recettes |
| 190 | { | 95 | { |
| 191 | 96 | ||
| 192 | } | 97 | } |
| 193 | elseif($choix_niv2 === $menu_documents_entrees[4]) // = Registre des achats | 98 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[4]) // = Registre des achats |
| 194 | { | 99 | { |
| 195 | 100 | ||
| 196 | } | 101 | } |
| 197 | elseif($choix_niv2 === $menu_documents_entrees[5]) // = Bilan annuel | 102 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[5]) // = Bilan annuel |
| 198 | { | 103 | { |
| 199 | 104 | ||
| 200 | } | 105 | } |
| @@ -204,19 +109,21 @@ while($boucle) | |||
| 204 | } | 109 | } |
| 205 | } | 110 | } |
| 206 | 111 | ||
| 207 | // Supports de communication | 112 | // -- SECTION 5: Supports de communication -- |
| 208 | elseif($choix_niv1 === $menu_principal_entrees[4]) // = Communication | 113 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[4]) // = Communication |
| 209 | { | 114 | { |
| 115 | echo("choix: $choix_niv1\n"); | ||
| 116 | $MenuCommunication = new ZenityList(ZenitySetup::$menu_communication_text, ZenitySetup::$menu_communication_entrees); | ||
| 210 | $choix_niv2 = exec($MenuCommunication->get()); | 117 | $choix_niv2 = exec($MenuCommunication->get()); |
| 211 | if($choix_niv2 === $menu_communication_entrees[0]) // = Flyer (nécessite gimp) | 118 | if($choix_niv2 === ZenitySetup::$menu_communication_entrees[0]) // = Flyer (nécessite gimp) |
| 212 | { | 119 | { |
| 213 | exec(windowAppCommand($image_editor, $flyer)); | 120 | exec(windowAppCommand($image_editor, $flyer)); |
| 214 | } | 121 | } |
| 215 | elseif($choix_niv2 === $menu_communication_entrees[1]) // = Carte de visite (nécessite scribus) | 122 | elseif($choix_niv2 === ZenitySetup::$menu_communication_entrees[1]) // = Carte de visite (nécessite scribus) |
| 216 | { | 123 | { |
| 217 | exec(windowAppCommand($publishing, $business_card)); | 124 | exec(windowAppCommand($publishing, $business_card)); |
| 218 | } | 125 | } |
| 219 | elseif($choix_niv2 === $menu_communication_entrees[2]) // = Explorateur de fichiers | 126 | elseif($choix_niv2 === ZenitySetup::$menu_communication_entrees[2]) // = Explorateur de fichiers |
| 220 | { | 127 | { |
| 221 | exec(windowAppCommand($file_explorer, $pub)); | 128 | exec(windowAppCommand($file_explorer, $pub)); |
| 222 | } | 129 | } |
| @@ -226,9 +133,10 @@ while($boucle) | |||
| 226 | } | 133 | } |
| 227 | } | 134 | } |
| 228 | 135 | ||
| 229 | // BDD | 136 | // -- SECTION 6: BDD -- |
| 230 | elseif($choix_niv1 === $menu_principal_entrees[5]) // = Base de données | 137 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[5]) // = Base de données |
| 231 | { | 138 | { |
| 139 | echo("choix: $choix_niv1\n"); | ||
| 232 | if($sqlitebrowser_enable) | 140 | if($sqlitebrowser_enable) |
| 233 | { | 141 | { |
| 234 | exec(windowAppCommand($sqlite_gui, $db_place)); | 142 | exec(windowAppCommand($sqlite_gui, $db_place)); |
diff --git a/src/model/CESU.php b/src/model/CESU.php index 28a54a8..2be89c0 100644 --- a/src/model/CESU.php +++ b/src/model/CESU.php | |||
| @@ -3,28 +3,33 @@ | |||
| 3 | 3 | ||
| 4 | class CESU extends Model | 4 | class CESU extends Model |
| 5 | { | 5 | { |
| 6 | const TABLE = 'cesu'; | 6 | //~ const TABLE = 'cesu'; |
| 7 | 7 | ||
| 8 | // lecture des données ou hydratation | 8 | // lecture des données ou hydratation |
| 9 | private $ID; | 9 | private $ID_cesu; |
| 10 | private $ID_presta; | ||
| 11 | private $taches; | 10 | private $taches; |
| 12 | private $duree_travail; | 11 | private $duree_travail; |
| 13 | private $salaire; | 12 | private $salaire; |
| 14 | 13 | ||
| 15 | use ModelChildren; | 14 | use ModelChildren; |
| 16 | 15 | ||
| 17 | // setters | 16 | public function __construct(int $client_ID) |
| 18 | public function setID(int $value) | ||
| 19 | { | 17 | { |
| 20 | $this->ID = $value; | 18 | parent::__construct($client_ID); |
| 21 | return($this); | 19 | $this->type == 'cesu'; |
| 22 | } | 20 | } |
| 23 | public function setIDPresta(int $value) | 21 | |
| 22 | // setters | ||
| 23 | public function setIDCesu(int $value) | ||
| 24 | { | 24 | { |
| 25 | $this->ID_presta = $value; | 25 | $this->ID_cesu = $value; |
| 26 | return($this); | 26 | return($this); |
| 27 | } | 27 | } |
| 28 | //~ public function setIDPresta(int $value) | ||
| 29 | //~ { | ||
| 30 | //~ $this->ID_presta = $value; | ||
| 31 | //~ return($this); | ||
| 32 | //~ } | ||
| 28 | public function setTaches(string $value) | 33 | public function setTaches(string $value) |
| 29 | { | 34 | { |
| 30 | $this->taches = $value; | 35 | $this->taches = $value; |
diff --git a/src/model/Clients.php b/src/model/Clients.php index 92a4b31..aeb39c1 100644 --- a/src/model/Clients.php +++ b/src/model/Clients.php | |||
| @@ -4,20 +4,37 @@ | |||
| 4 | class Clients extends Model | 4 | class Clients extends Model |
| 5 | { | 5 | { |
| 6 | // lecture des données ou hydratation | 6 | // lecture des données ou hydratation |
| 7 | public $ID; | 7 | protected $ID; // auto-incrémentée |
| 8 | public $prenom_nom; | 8 | protected $prenom_nom = ''; |
| 9 | public $adresse; | 9 | protected $code_client = ''; |
| 10 | public $code_client; | 10 | protected $adresse = ''; |
| 11 | public $commentaires; | 11 | protected $telephone = ''; |
| 12 | protected $courriel = ''; | ||
| 13 | protected $commentaires = ''; | ||
| 12 | 14 | ||
| 13 | use ModelChildren; // renseigne parent::table | 15 | use ModelChildren; // renseigne parent::table |
| 14 | 16 | ||
| 17 | public function __construct() | ||
| 18 | { | ||
| 19 | $this->table = 'clients'; | ||
| 20 | } | ||
| 21 | |||
| 15 | //~ public function set(string $variable, $value) | 22 | //~ public function set(string $variable, $value) |
| 16 | //~ { | 23 | //~ { |
| 17 | //~ $this->$variable = $value; | 24 | //~ $this->$variable = $value; |
| 18 | //~ return($this); | 25 | //~ return($this); |
| 19 | //~ } | 26 | //~ } |
| 20 | 27 | ||
| 28 | // getters | ||
| 29 | public function getID(): int | ||
| 30 | { | ||
| 31 | return $this->ID; | ||
| 32 | } | ||
| 33 | public function getCodeClient(): string | ||
| 34 | { | ||
| 35 | return $this->code_client; | ||
| 36 | } | ||
| 37 | |||
| 21 | // setters | 38 | // setters |
| 22 | public function setID(int $value) // inutile? il s'autoincrémente | 39 | public function setID(int $value) // inutile? il s'autoincrémente |
| 23 | { | 40 | { |
| @@ -29,14 +46,27 @@ class Clients extends Model | |||
| 29 | $this->prenom_nom = $value; | 46 | $this->prenom_nom = $value; |
| 30 | return($this); | 47 | return($this); |
| 31 | } | 48 | } |
| 49 | public function setCode_client(string $value) | ||
| 50 | { | ||
| 51 | $this->code_client = $value; | ||
| 52 | return($this); | ||
| 53 | } | ||
| 32 | public function setAdresse(string $value) | 54 | public function setAdresse(string $value) |
| 33 | { | 55 | { |
| 34 | $this->adresse = $value; | 56 | $this->adresse = $value; |
| 35 | return($this); | 57 | return($this); |
| 36 | } | 58 | } |
| 37 | public function setCode_client(string $value) | 59 | public function setTelephone(string $value) // chaine parce que zenity renvoie une chaine et parce qu'on garde le 0 au début |
| 38 | { | 60 | { |
| 39 | $this->code_client = $value; | 61 | if(is_numeric($value)) |
| 62 | { | ||
| 63 | $this->telephone = $value; | ||
| 64 | } | ||
| 65 | return($this); | ||
| 66 | } | ||
| 67 | public function setCourriel(string $value) | ||
| 68 | { | ||
| 69 | $this->courriel = $value; | ||
| 40 | return($this); | 70 | return($this); |
| 41 | } | 71 | } |
| 42 | public function setCommentaires(string $value) | 72 | public function setCommentaires(string $value) |
| @@ -48,12 +78,18 @@ class Clients extends Model | |||
| 48 | 78 | ||
| 49 | public function newRow(array $input) | 79 | public function newRow(array $input) |
| 50 | { | 80 | { |
| 51 | $this->hydrate(['prenom_nom' => $input[0], 'adresse' => $input[1], 'code_client' => $input[2], 'commentaires' => $input[3]]); | 81 | $this->hydrate(['prenom_nom' => $input[0], 'code_client' => $input[1], 'adresse' => $input[2], 'telephone' => $input[3], 'courriel' => $input[4], 'commentaires' => $input[5]]); |
| 52 | $this->create(); | 82 | $this->create(); |
| 53 | $this->setIdFromLastInsertID(); // dans ModelChildren, n'utilise pas Model::execQuery() | 83 | // ID obtenu par auto-incrémentation |
| 84 | $this->ID = $this->db->lastInsertId(); // méthode de PDO | ||
| 54 | } | 85 | } |
| 86 | //~ public function setIdFromLastInsertID() // à faire juste après l'écriture d'une nouvelle entrée | ||
| 87 | //~ { | ||
| 88 | //~ $this->db = parent::getInstance(); // $db est créée dans Model::execQuery() | ||
| 89 | //~ $this->ID = $this->db->lastInsertId(); // méthode de PDO | ||
| 90 | //~ } | ||
| 55 | 91 | ||
| 56 | public function findByKeywords(array $keywords, string $field): array | 92 | public function findByKeywords(array $keywords, string $field): array // n'hydrate pas les variables, on doit choisir un client et hydrater ensuite |
| 57 | { | 93 | { |
| 58 | $result = []; | 94 | $result = []; |
| 59 | for($i = 0; $i < count($keywords); $i++) | 95 | for($i = 0; $i < count($keywords); $i++) |
diff --git a/src/model/DevisFactures.php b/src/model/DevisFactures.php index 218ebfe..1ed3a5c 100644 --- a/src/model/DevisFactures.php +++ b/src/model/DevisFactures.php | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | class DevisFactures extends Model | 4 | class DevisFactures extends Model |
| 5 | { | 5 | { |
| 6 | // lecture des données ou hydratation | 6 | // lecture des données ou hydratation |
| 7 | private $ID; | 7 | private $ID_devis_facture; // auto-incrémentée |
| 8 | private $ID_presta; | 8 | private $ID_presta = 0; |
| 9 | private $validite_devis; | 9 | private $validite_devis; |
| 10 | private $signature_devis; | 10 | private $signature_devis; |
| 11 | private $taches; | 11 | private $taches; |
| @@ -19,12 +19,25 @@ class DevisFactures extends Model | |||
| 19 | private $deplacement; | 19 | private $deplacement; |
| 20 | private $total_HT; | 20 | private $total_HT; |
| 21 | 21 | ||
| 22 | use ModelChildren; | 22 | //~ use ModelChildren; |
| 23 | |||
| 24 | public function __construct(int $ID_presta) | ||
| 25 | { | ||
| 26 | $this->table = 'devisfactures'; | ||
| 27 | $this->ID_presta = $ID_presta; | ||
| 28 | } | ||
| 23 | 29 | ||
| 24 | // setters | 30 | // setters |
| 25 | public function setID(int $value) | 31 | public function setIDDevisFacture(int $value = 0) |
| 26 | { | 32 | { |
| 27 | $this->ID = $value; | 33 | if($value === 0) |
| 34 | { | ||
| 35 | $this->ID_devis_facture = $this->db->lastInsertId(); // méthode de PDO | ||
| 36 | } | ||
| 37 | else | ||
| 38 | { | ||
| 39 | $this->ID_devis_facture = $value; | ||
| 40 | } | ||
| 28 | return($this); | 41 | return($this); |
| 29 | } | 42 | } |
| 30 | public function setIDPresta(int $value) | 43 | public function setIDPresta(int $value) |
| @@ -92,4 +105,13 @@ class DevisFactures extends Model | |||
| 92 | $this->total_HT = $value; | 105 | $this->total_HT = $value; |
| 93 | return($this); | 106 | return($this); |
| 94 | } | 107 | } |
| 108 | |||
| 109 | public function newRow(array $input, array $quotations_input = []) | ||
| 110 | { | ||
| 111 | if(!empty($quotations_input)) // cas d'un devis | ||
| 112 | { | ||
| 113 | $this->hydrate(['validite_devis' => $quotations_input[0], 'signature_devis' => $quotations_input[1]]); | ||
| 114 | } | ||
| 115 | $this->hydrate([]); | ||
| 116 | } | ||
| 95 | } | 117 | } |
diff --git a/src/model/Locations.php b/src/model/Locations.php index b788d43..21e9b09 100644 --- a/src/model/Locations.php +++ b/src/model/Locations.php | |||
| @@ -4,8 +4,7 @@ | |||
| 4 | class Locations extends Model | 4 | class Locations extends Model |
| 5 | { | 5 | { |
| 6 | // lecture des données ou hydratation | 6 | // lecture des données ou hydratation |
| 7 | private $ID; | 7 | private $ID_location; |
| 8 | private $ID_presta; | ||
| 9 | private $nature_bien; | 8 | private $nature_bien; |
| 10 | private $modele; | 9 | private $modele; |
| 11 | private $valeur; | 10 | private $valeur; |
| @@ -17,17 +16,23 @@ class Locations extends Model | |||
| 17 | 16 | ||
| 18 | use ModelChildren; | 17 | use ModelChildren; |
| 19 | 18 | ||
| 20 | // setters | 19 | public function __construct(int $client_ID) |
| 21 | public function setID(int $value) | ||
| 22 | { | 20 | { |
| 23 | $this->ID = $value; | 21 | parent::__construct($client_ID); |
| 24 | return($this); | 22 | $this->type == 'location'; |
| 25 | } | 23 | } |
| 26 | public function setIDPresta(int $value) | 24 | |
| 25 | // setters | ||
| 26 | public function setIDLocation(int $value) | ||
| 27 | { | 27 | { |
| 28 | $this->ID_presta = $value; | 28 | $this->ID_location = $value; |
| 29 | return($this); | 29 | return($this); |
| 30 | } | 30 | } |
| 31 | //~ public function setIDPresta(int $value) | ||
| 32 | //~ { | ||
| 33 | //~ $this->ID_presta = $value; | ||
| 34 | //~ return($this); | ||
| 35 | //~ } | ||
| 31 | public function setNatureBien(string $value) | 36 | public function setNatureBien(string $value) |
| 32 | { | 37 | { |
| 33 | $this->nature_bien = $value; | 38 | $this->nature_bien = $value; |
diff --git a/src/model/Model.php b/src/model/Model.php index 8cbf056..938e3dd 100644 --- a/src/model/Model.php +++ b/src/model/Model.php | |||
| @@ -9,7 +9,8 @@ class Model extends DB | |||
| 9 | 9 | ||
| 10 | public function __construct() | 10 | public function __construct() |
| 11 | { | 11 | { |
| 12 | $this->db = parent::getInstance(); // connexion | 12 | //~ $this->db = parent::getInstance(); // connexion |
| 13 | //~ $this->table = strtolower(__CLASS__); | ||
| 13 | } | 14 | } |
| 14 | 15 | ||
| 15 | // getters | 16 | // getters |
| @@ -26,8 +27,9 @@ class Model extends DB | |||
| 26 | // nom d'un setter, forme "setMachin()" | 27 | // nom d'un setter, forme "setMachin()" |
| 27 | $setterName = 'set' . ucfirst($key); // ucfirst met la première lettre en majuscule | 28 | $setterName = 'set' . ucfirst($key); // ucfirst met la première lettre en majuscule |
| 28 | // détection | 29 | // détection |
| 29 | if(method_exists($this, $setterName)) // on trouve aussi la méthode is_callable() | 30 | if(method_exists($this, $setterName) && $value != NULL) // on trouve aussi la méthode is_callable() |
| 30 | { | 31 | { |
| 32 | //~ var_dump($value); | ||
| 31 | // on renseigne les propriétés des l'instance | 33 | // on renseigne les propriétés des l'instance |
| 32 | $this->$setterName($value); // nom d'une méthode dans une variable | 34 | $this->$setterName($value); // nom d'une méthode dans une variable |
| 33 | } | 35 | } |
| @@ -84,7 +86,7 @@ class Model extends DB | |||
| 84 | 86 | ||
| 85 | 87 | ||
| 86 | // read SELECT | 88 | // read SELECT |
| 87 | public function readAll(): array // obtenir une table | 89 | protected function readAll(): array // obtenir une table |
| 88 | { | 90 | { |
| 89 | return($this->execQuery('SELECT * FROM ' . $this->table)->fetchAll()); // fonctionne aussi sans le point virgule dans le SQL!! | 91 | return($this->execQuery('SELECT * FROM ' . $this->table)->fetchAll()); // fonctionne aussi sans le point virgule dans le SQL!! |
| 90 | } | 92 | } |
| @@ -94,7 +96,7 @@ class Model extends DB | |||
| 94 | return($this->execQuery('SELECT * FROM ' . $this->table . ' WHERE id = ' . $id)->fetch()); | 96 | return($this->execQuery('SELECT * FROM ' . $this->table . ' WHERE id = ' . $id)->fetch()); |
| 95 | } | 97 | } |
| 96 | 98 | ||
| 97 | public function find(array $criteria): array // obtenir une entrée avec un tableau associatif 'champ' => 'valeur' | 99 | protected function find(array $criteria): array // obtenir une entrée avec un tableau associatif 'champ' => 'valeur' |
| 98 | { | 100 | { |
| 99 | $fields = []; | 101 | $fields = []; |
| 100 | $values = []; | 102 | $values = []; |
| @@ -134,7 +136,7 @@ class Model extends DB | |||
| 134 | 136 | ||
| 135 | 137 | ||
| 136 | // delete DELETE | 138 | // delete DELETE |
| 137 | public function delete(int $id) | 139 | protected function delete(int $id) |
| 138 | { | 140 | { |
| 139 | return($this->execQuery("DELETE FROM {$this->table} WHERE id = ?", [$id])); // double quotes "" pour insertion de variable, paramètre [$id] parce qu'on veut un tableau | 141 | return($this->execQuery("DELETE FROM {$this->table} WHERE id = ?", [$id])); // double quotes "" pour insertion de variable, paramètre [$id] parce qu'on veut un tableau |
| 140 | } | 142 | } |
diff --git a/src/model/Prestations.php b/src/model/Prestations.php index 32f9768..cbe8e6c 100644 --- a/src/model/Prestations.php +++ b/src/model/Prestations.php | |||
| @@ -4,23 +4,56 @@ | |||
| 4 | class Prestations extends Model | 4 | class Prestations extends Model |
| 5 | { | 5 | { |
| 6 | // lecture des données ou hydratation | 6 | // lecture des données ou hydratation |
| 7 | private $ID; | 7 | protected $ID_presta; // auto-incrémentée |
| 8 | private $IDClient; | 8 | protected $ID_client = 0; |
| 9 | private $combientieme_fois; | 9 | protected $combientieme_fois = 0; |
| 10 | private $code_presta; | 10 | protected $code_presta = ''; |
| 11 | private $date; | 11 | protected $date = 0; // timestamp unix |
| 12 | private $type; | 12 | protected $type_presta = ''; |
| 13 | private $mode_paiement; | 13 | protected $mode_paiement = ''; |
| 14 | private $commentaires; | 14 | protected $commentaires = ''; |
| 15 | 15 | ||
| 16 | use ModelChildren; | 16 | //~ use ModelChildren; |
| 17 | |||
| 18 | public function __construct(int $ID_client) | ||
| 19 | { | ||
| 20 | $this->table = 'prestations'; | ||
| 21 | $this->ID_client = $ID_client; | ||
| 22 | $this->combientiemeFois(); | ||
| 23 | } | ||
| 24 | |||
| 25 | // getters | ||
| 26 | public function getIDPresta(): int | ||
| 27 | { | ||
| 28 | return $this->ID_presta; | ||
| 29 | } | ||
| 30 | public function getIDClient(): int | ||
| 31 | { | ||
| 32 | return $this->ID_client; | ||
| 33 | } | ||
| 34 | public function getCombientiemeFois(): int | ||
| 35 | { | ||
| 36 | return $this->combientieme_fois; | ||
| 37 | } | ||
| 38 | public function getDate(): int | ||
| 39 | { | ||
| 40 | return $this->date; | ||
| 41 | } | ||
| 17 | 42 | ||
| 18 | // setters | 43 | // setters |
| 19 | public function setID(int $value) | 44 | public function setIDPresta(int $value = 0) |
| 20 | { | 45 | { |
| 21 | $this->ID = $value; | 46 | if($value === 0) |
| 47 | { | ||
| 48 | $this->ID_presta = $this->db->lastInsertId(); // méthode de PDO | ||
| 49 | } | ||
| 50 | else | ||
| 51 | { | ||
| 52 | $this->ID_presta = $value; | ||
| 53 | } | ||
| 22 | return($this); | 54 | return($this); |
| 23 | } | 55 | } |
| 56 | |||
| 24 | public function setIDClient(int $value) | 57 | public function setIDClient(int $value) |
| 25 | { | 58 | { |
| 26 | $this->ID_client = $value; | 59 | $this->ID_client = $value; |
| @@ -41,9 +74,9 @@ class Prestations extends Model | |||
| 41 | $this->date = $value; | 74 | $this->date = $value; |
| 42 | return($this); | 75 | return($this); |
| 43 | } | 76 | } |
| 44 | public function setType(string $value) | 77 | public function setTypePresta(string $value) |
| 45 | { | 78 | { |
| 46 | $this->type = $value; | 79 | $this->type_presta = $value; |
| 47 | return($this); | 80 | return($this); |
| 48 | } | 81 | } |
| 49 | public function setModePaiement(string $value) | 82 | public function setModePaiement(string $value) |
| @@ -56,4 +89,26 @@ class Prestations extends Model | |||
| 56 | $this->commentaires = $value; | 89 | $this->commentaires = $value; |
| 57 | return($this); | 90 | return($this); |
| 58 | } | 91 | } |
| 92 | |||
| 93 | protected function combientiemeFois() | ||
| 94 | { | ||
| 95 | // on récupère un tableau contenant toutes les prestations d'un client tous types confondus (devis, facture, cesu, location, enregistrement sans vente) | ||
| 96 | $array = $this->find(['ID_client' => $this->ID_client]); | ||
| 97 | $this->combientieme_fois = count($array) + 1; | ||
| 98 | } | ||
| 99 | |||
| 100 | // code client = année-mois-jour-codeclient-combientièmefois | ||
| 101 | public function makeCodePresta(Dates $Date, string $code_client) | ||
| 102 | { | ||
| 103 | $array_code = [$Date->getYear(), $Date->getMonth(), $Date->getDay(), $code_client, $this->combientieme_fois]; | ||
| 104 | $this->code_presta = implode('-', $array_code); | ||
| 105 | } | ||
| 106 | |||
| 107 | //~ public function newRow(array $input) | ||
| 108 | //~ { | ||
| 109 | //~ $this->hydrate(['ID_client' => $input[0], 'code_presta' => $input[1], 'date' => $input[2], 'type_presta' => $input[3], 'mode_paiement' => $input[4], 'commentaires' => $input[5]]); | ||
| 110 | //~ $this->create(); | ||
| 111 | //~ // ID obtenu par auto-incrémentation | ||
| 112 | //~ $this->ID_presta = $this->db->lastInsertId(); // méthode de PDO | ||
| 113 | //~ } | ||
| 59 | } | 114 | } |
diff --git a/src/model/StructTablesDB.php b/src/model/StructTablesDB.php index ee4baf1..0f13b80 100644 --- a/src/model/StructTablesDB.php +++ b/src/model/StructTablesDB.php | |||
| @@ -9,11 +9,11 @@ class StructTablesDB | |||
| 9 | static public $structureOfTables = [ | 9 | static public $structureOfTables = [ |
| 10 | // la table prestations est liée à la table clients | 10 | // la table prestations est liée à la table clients |
| 11 | // les tables devis_factures, cesu et locations sont liées à la table prestations | 11 | // les tables devis_factures, cesu et locations sont liées à la table prestations |
| 12 | 'clients' => ['ID' => 'INTEGER', 'prenom_nom' => 'TEXT', 'adresse' => 'TEXT', 'code_client' => 'TEXT', 'commentaires' => 'TEXT'], | 12 | 'clients' => ['ID' => 'INTEGER', 'prenom_nom' => 'TEXT', 'code_client' => 'TEXT', 'adresse' => 'TEXT', 'telephone' => 'TEXT', 'courriel' => 'TEXT', 'commentaires' => 'TEXT'], |
| 13 | 'prestations' => ['ID' => 'INTEGER', 'ID_client' => 'INTEGER', 'combientieme_fois' => 'INTEGER', 'code_presta' => 'TEXT', 'date' => 'INTEGER', 'type_presta' => 'TEXT', 'mode_paiement' => 'TEXT', 'commentaires' => 'TEXT'], | 13 | 'prestations' => ['ID' => 'INTEGER', 'ID_client' => 'INTEGER', 'code_presta' => 'TEXT', 'date' => 'INTEGER', 'type_presta' => 'TEXT', 'mode_paiement' => 'TEXT', 'commentaires' => 'TEXT'], |
| 14 | 'devisfactures' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'validite_devis' => 'TEXT', 'signature_devis' => 'TEXT', 'taches' => 'TEXT', 'machine' => 'TEXT', 'OS' => 'TEXT', 'donnees' => 'TEXT', 'cles_licences' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL'], | 14 | 'devisfactures' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'validite_devis' => 'TEXT', 'signature_devis' => 'TEXT', 'taches' => 'TEXT', 'machine' => 'TEXT', 'OS' => 'TEXT', 'donnees' => 'TEXT', 'cles_licences' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL'], |
| 15 | 'cesu' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'duree_travail' => 'TEXT', 'salaire' => 'REAL'], | 15 | 'cesu' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'duree_travail' => 'TEXT', 'salaire' => 'REAL'], |
| 16 | 'locations' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'designation' => 'TEXT', 'modele_description' => 'TEXT', 'valeur' => 'REAL', 'etat_des_lieux_debut' => 'TEXT', 'etat_des_lieux_fin' => 'TEXT', 'duree_location' => 'INTEGER', 'loyer_mensuel' => 'REAL', 'loyers_encaisse' => 'INTEGER', 'caution' => 'INTEGER'] | 16 | 'locations' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'designation' => 'TEXT', 'modele_description' => 'TEXT', 'valeur' => 'REAL', 'etat_des_lieux_debut' => 'TEXT', 'etat_des_lieux_fin' => 'TEXT', 'duree_location' => 'INTEGER', 'loyer_mensuel' => 'REAL', 'loyers_payes' => 'INTEGER', 'caution' => 'INTEGER'] |
| 17 | ]; | 17 | ]; |
| 18 | 18 | ||
| 19 | // les types de variables de sqlite sont peu nombreux et autorisent un typage automatique | 19 | // les types de variables de sqlite sont peu nombreux et autorisent un typage automatique |
diff --git a/src/model/traits.php b/src/model/traits.php index 43d9b7f..3d446c1 100644 --- a/src/model/traits.php +++ b/src/model/traits.php | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | 3 | ||
| 4 | trait ModelChildren // pour ne pas toucher au constructeur de la classe Model | 4 | trait ModelChildren // pour ne pas toucher au constructeur de la classe Model |
| 5 | { | 5 | { |
| 6 | public function __construct() | 6 | //~ public function __construct() |
| 7 | { | 7 | //~ { |
| 8 | $this->table = strtolower(__CLASS__); | 8 | //~ $this->table = strtolower(__CLASS__); |
| 9 | } | 9 | //~ } |
| 10 | 10 | ||
| 11 | public function setIdFromLastInsertID() // à faire juste après l'écriture d'une nouvelle entrée | 11 | //~ public function setIdFromLastInsertID() // à faire juste après l'écriture d'une nouvelle entrée |
| 12 | { | 12 | //~ { |
| 13 | $this->db = parent::getInstance(); | 13 | //~ $this->db = parent::getInstance(); |
| 14 | $this->ID = $this->db->lastInsertId(); // méthode de PDO | 14 | //~ $this->ID = $this->db->lastInsertId(); // méthode de PDO |
| 15 | } | 15 | //~ } |
| 16 | } | 16 | } |
diff --git a/src/sections/1_new_service.php b/src/sections/1_new_service.php new file mode 100644 index 0000000..172402a --- /dev/null +++ b/src/sections/1_new_service.php | |||
| @@ -0,0 +1,241 @@ | |||
| 1 | <?php | ||
| 2 | // sections/1_new_service.php | ||
| 3 | // | ||
| 4 | // -- SECTION 1: Nouvelle prestation -- | ||
| 5 | |||
| 6 | function newService() | ||
| 7 | { | ||
| 8 | // fenêtres | ||
| 9 | $QuestionNouveauClient = new ZenityQuestion(ZenitySetup::$question_nouveau_client_text); | ||
| 10 | $RechercheClient = new zenityEntry(ZenitySetup::$recherche_client_text); | ||
| 11 | $ResultatsRechercheClient = new ZenityList(ZenitySetup::$resultats_recherche_client_text, []); | ||
| 12 | $NouveauClient = new ZenityForms(ZenitySetup::$nouveau_client_text, ZenitySetup::$nouveau_client_entrees); | ||
| 13 | $MenuEnregistrement = new ZenityList(ZenitySetup::$menu_enregistrement_text, ZenitySetup::$menu_enregistrement_entrees); | ||
| 14 | $Calendrier = new ZenityCalendar(ZenitySetup::$calendar_text); | ||
| 15 | $FormulaireDevis = new ZenityForms(ZenitySetup::$formulaire_text, array_merge(ZenitySetup::$formulaire_devis_entrees, ZenitySetup::$formulaire_facture_entrees)); | ||
| 16 | $FormulaireFacture = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_facture_entrees); | ||
| 17 | $FormulaireCesu = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_cesu_entrees); | ||
| 18 | $FormulaireLocation = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_location_entrees); | ||
| 19 | $CommentairePrestation = new ZenityEntry(ZenitySetup::$commentaire_prestation_text); | ||
| 20 | |||
| 21 | $Client = new Clients; // modèle de la table 'clients' | ||
| 22 | |||
| 23 | $continuer = false; | ||
| 24 | // niveau 2: est ce que le client est déjà dans la base? | ||
| 25 | if(exec($QuestionNouveauClient->get()) == '0') // $? = 0 signifie oui, double égal == pour le transtypage | ||
| 26 | { | ||
| 27 | echo "debug: recherche souhaitée\n"; | ||
| 28 | |||
| 29 | // niveau 3: saisie du nom du client | ||
| 30 | $nom_client = exec($RechercheClient->get()); | ||
| 31 | if($nom_client !== '') | ||
| 32 | { | ||
| 33 | echo "debug: recherche effectuée\n"; | ||
| 34 | $ResultatsRechercheClient->setListRows(rechercheClient($nom_client, $Client), $Client->getTable()); // recherche silencieuse | ||
| 35 | unset($nom_client); | ||
| 36 | |||
| 37 | // niveau 4: sélection parmi les résultats | ||
| 38 | $choix_niv4 = exec($ResultatsRechercheClient->get()); // renvoie l'ID de la table 'clients' | ||
| 39 | $ResultatsRechercheClient->cleanCommand(); | ||
| 40 | |||
| 41 | if($choix_niv4 !== '') | ||
| 42 | { | ||
| 43 | echo "debug: client sélectionné\n"; | ||
| 44 | $Client->hydrate($Client->findById($choix_niv4)); | ||
| 45 | $continuer = true; | ||
| 46 | } | ||
| 47 | else | ||
| 48 | { | ||
| 49 | echo "debug: client pas trouvé ou pas sélectionné\n"; | ||
| 50 | } | ||
| 51 | } | ||
| 52 | else | ||
| 53 | { | ||
| 54 | echo "debug: recherche annulée ou saisie vide\n"; | ||
| 55 | } | ||
| 56 | } | ||
| 57 | else | ||
| 58 | { | ||
| 59 | echo "debug: nouveau client\n"; | ||
| 60 | } | ||
| 61 | |||
| 62 | // niveau 2: on n'a pas cherché OU on n'a pas trouvé | ||
| 63 | if(!$continuer) | ||
| 64 | { | ||
| 65 | $data_string = exec($NouveauClient->get()); | ||
| 66 | //~ $data_array = explode('|', $data_string); | ||
| 67 | //~ if(controlFormInput($data_array)) | ||
| 68 | //~ { | ||
| 69 | //~ $Client->newRow($data_array); // écriture dans la BDD | ||
| 70 | //~ $continuer = true; | ||
| 71 | //~ } | ||
| 72 | |||
| 73 | if($data_string !== '') | ||
| 74 | { | ||
| 75 | $data_array = explode('|', $data_string); | ||
| 76 | $data_string = ''; // nettoyage | ||
| 77 | |||
| 78 | if(count($data_array) === count(StructTablesDB::$structureOfTables[$Client->getTable()]) - 1) | ||
| 79 | { | ||
| 80 | if($data_array[0] != "") // le champ "prenom_nom" ne doit pas être vide | ||
| 81 | { | ||
| 82 | $Client->newRow($data_array); // écriture dans la BDD | ||
| 83 | $continuer = true; | ||
| 84 | } | ||
| 85 | else | ||
| 86 | { | ||
| 87 | echo "debug: données insuffisantes, le nom du client doit au minimum être renseigné\n"; | ||
| 88 | $continuer = false; | ||
| 89 | } | ||
| 90 | } | ||
| 91 | else | ||
| 92 | { | ||
| 93 | echo "debug: le nombre d'informations à enregistrer du nombre de champs à renseigner dans la table\n"; | ||
| 94 | $continuer = false; | ||
| 95 | } | ||
| 96 | } | ||
| 97 | else | ||
| 98 | { | ||
| 99 | echo "debug: annulation lors du formulaire\n"; | ||
| 100 | $continuer = false; | ||
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 104 | // niveau 2: type comptable d'enregistrement: devis, facture, cesu, location ou pas de prestation | ||
| 105 | if($continuer) | ||
| 106 | { | ||
| 107 | $choix_niv2 = exec($MenuEnregistrement->get()); | ||
| 108 | $continuer = false; | ||
| 109 | $Presta = new Prestations($Client->getID()); | ||
| 110 | |||
| 111 | switch($choix_niv2) | ||
| 112 | { | ||
| 113 | case ZenitySetup::$menu_enregistrement_entrees[0]: // "Devis" | ||
| 114 | $DetailsPresta = new DevisFactures($Client->getID()); | ||
| 115 | $Presta->setTypePresta('devis'); | ||
| 116 | $continuer = true; | ||
| 117 | break; | ||
| 118 | case ZenitySetup::$menu_enregistrement_entrees[1]: // "Facture" | ||
| 119 | $DetailsPresta = new DevisFactures($Client->getID()); | ||
| 120 | $Presta->setTypePresta('facture'); | ||
| 121 | $continuer = true; | ||
| 122 | break; | ||
| 123 | case ZenitySetup::$menu_enregistrement_entrees[2]: // "CESU" | ||
| 124 | $DetailsPresta = new CESU($Client->getID()); | ||
| 125 | $Presta->setTypePresta('cesu'); | ||
| 126 | $continuer = true; | ||
| 127 | break; | ||
| 128 | case ZenitySetup::$menu_enregistrement_entrees[3]: // "Location" | ||
| 129 | $DetailsPresta = new Locations($Client->getID()); | ||
| 130 | $Presta->setTypePresta('location'); | ||
| 131 | $continuer = true; | ||
| 132 | break; | ||
| 133 | case ZenitySetup::$menu_enregistrement_entrees[4]: // "non_vendue" | ||
| 134 | // objet $Presta uniquement | ||
| 135 | $Presta->setTypePresta('non_vendue'); | ||
| 136 | $continuer = true; | ||
| 137 | break; | ||
| 138 | default: | ||
| 139 | $continuer = false; // annulation, retour menu principal | ||
| 140 | } | ||
| 141 | |||
| 142 | if($continuer) | ||
| 143 | { | ||
| 144 | // niveau 3: détail de la prestation | ||
| 145 | // noter que exec() renvoie toujours une chaîne, sauf en cas d'erreur où il renvoie un "false" | ||
| 146 | $Date = new Dates(exec($Calendrier->get())); | ||
| 147 | if($Date->getDate() !== '') // on n'a pas cliqué sur "annuler" | ||
| 148 | { | ||
| 149 | $Presta->setDate($Date->getTimestamp()); // un entier pour la BDD | ||
| 150 | $Presta->makeCodePresta($Date, $Client->getCodeClient()); // d'un objet à l'autre | ||
| 151 | |||
| 152 | // on continue si le formulaire précédent a été rempli | ||
| 153 | switch($choix_niv2) | ||
| 154 | { | ||
| 155 | case $Presta->getType = 'devis'; | ||
| 156 | $data_string = exec($FormulaireDevis->get()); | ||
| 157 | break; | ||
| 158 | case $Presta->getType = 'facture'; | ||
| 159 | $data_string = exec($FormulaireFacture->get()); // tester si c'est vide ou clic sur 'Annuler' | ||
| 160 | break; | ||
| 161 | case $Presta->getType = 'cesu'; | ||
| 162 | $data_string = exec($FormulaireCesu->get()); | ||
| 163 | break; | ||
| 164 | case $Presta->getType = 'location'; | ||
| 165 | $data_string = exec($FormulaireLocation->get()); | ||
| 166 | break; | ||
| 167 | case $data_string->getType = 'non_vendue'; | ||
| 168 | // ne rien faire | ||
| 169 | break; | ||
| 170 | default: | ||
| 171 | $continuer = false; // annulation, retour menu principal | ||
| 172 | } | ||
| 173 | |||
| 174 | if($continuer) | ||
| 175 | { | ||
| 176 | // dans $Presta | ||
| 177 | $comment = exec($CommentairePrestation->get()); | ||
| 178 | if(!empty($comment)) | ||
| 179 | { | ||
| 180 | $Presta->setCommentaires($comment); | ||
| 181 | } | ||
| 182 | else | ||
| 183 | { | ||
| 184 | $continuer = false; // annulation, retour menu principal | ||
| 185 | } | ||
| 186 | } | ||
| 187 | } | ||
| 188 | $Presta->create(); | ||
| 189 | $Presta->setIDPresta(); // sans paramètre pour récupérer le dernier ID inséré | ||
| 190 | |||
| 191 | if($data_string !== '') | ||
| 192 | { | ||
| 193 | $data_array = explode('|', $data_string); | ||
| 194 | |||
| 195 | if(count($data_array) === count(StructTablesDB::$structureOfTables[$DetailsPresta->getTable()]) - 1) | ||
| 196 | { | ||
| 197 | if($data_array[0] != "") // le champ "prenom_nom" ne doit pas être vide | ||
| 198 | { | ||
| 199 | $DetailsPresta->newRow($data_array); // INSUFFISANT | ||
| 200 | $continuer = true; | ||
| 201 | } | ||
| 202 | else | ||
| 203 | { | ||
| 204 | echo "debug: données insuffisantes, le nom du client doit au minimum être renseigné\n"; | ||
| 205 | $continuer = false; | ||
| 206 | } | ||
| 207 | } | ||
| 208 | else | ||
| 209 | { | ||
| 210 | echo "debug: le nombre d'informations à enregistrer du nombre de champs à renseigner dans la table\n"; | ||
| 211 | $continuer = false; | ||
| 212 | } | ||
| 213 | } | ||
| 214 | else | ||
| 215 | { | ||
| 216 | echo "debug: annulation lors du formulaire\n"; | ||
| 217 | $continuer = false; | ||
| 218 | } | ||
| 219 | $DetailsPresta->setIDPresta($Presta->getIDPresta()); // d'un objet à l'autre | ||
| 220 | $DetailsPresta->create(); | ||
| 221 | |||
| 222 | |||
| 223 | // tableau récaptilatif, possibilité de modification | ||
| 224 | //ZenityList | ||
| 225 | |||
| 226 | |||
| 227 | // création fichiers LaTeX et PDF | ||
| 228 | //~ $latex_path = '../data/latex/'; // noms de variables dans le config.php | ||
| 229 | //~ $file_name = 'devis.tex'; | ||
| 230 | //~ $template = 'devis'; // vaut 'devis' ou 'enveloppe_recto' ou 'enveloppe_verso' ou 'facture' ou 'location' | ||
| 231 | //~ $latex = getLatexFromTemplate($template); | ||
| 232 | //~ file_put_contents($latex_path . $file_name, $latex); // injection des variables & écriture du fichier | ||
| 233 | //~ $pdf_path = '../data/pdf/'; | ||
| 234 | //~ latexToPdf($latex_path, $file_name, $pdf_path); | ||
| 235 | |||
| 236 | // imprimer? | ||
| 237 | //~ $imprimer_facture = exec('zenity --question --width=250 --title="Base de données mise à jour" --text="Imprimer la facture?"'); | ||
| 238 | //~ $imprimer_enveloppe = exec('zenity --question --width=250 --title="Base de données mise à jour" --text="Imprimer l\'adresse sur une enveloppe? (insérer une enveloppe DL sans fenêtre dans l\'imprimante"'); | ||
| 239 | } | ||
| 240 | } | ||
| 241 | } | ||
diff --git a/src/view/Zenity.php b/src/view/Zenity.php index 1299d1c..72d5eed 100644 --- a/src/view/Zenity.php +++ b/src/view/Zenity.php | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // php/Zenity.php | 2 | // php/Zenity.php |
| 3 | // | 3 | // |
| 4 | // commande système zenity | 4 | // générer les commandes qui ouvrent les fenêtres zenity, un objet = une commande |
| 5 | // s'utilisent comme ceci: exec($Objet->get()); | ||
| 5 | 6 | ||
| 6 | abstract class ZenityCmd | 7 | abstract class ZenityCmd |
| 7 | { | 8 | { |
| @@ -33,17 +34,17 @@ class ZenityList extends ZenityCmd | |||
| 33 | { | 34 | { |
| 34 | private $columns = 1; // tableau simple ou multidimensionnel? | 35 | private $columns = 1; // tableau simple ou multidimensionnel? |
| 35 | 36 | ||
| 36 | public function __construct(string $text, array $rows = [], int $columns = 1) | 37 | public function __construct(string $text, array $rows = []) |
| 37 | { | 38 | { |
| 38 | $this->command_type = ' --list'; | 39 | $this->command_type = ' --list'; |
| 39 | parent::__construct($text, $rows); | 40 | parent::__construct($text, $rows); |
| 40 | $this->columns = $columns; | 41 | $this->columns = 1; |
| 41 | $this->height = 80 + count($this->rows) * 25; | ||
| 42 | $this->command .= ' --height=' . $this->height; | ||
| 43 | $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text | 42 | $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text |
| 44 | if($this->rows !== []) | 43 | if($this->rows !== []) |
| 45 | { | 44 | { |
| 46 | $this->command .= ' --width=' . $this->width; | 45 | $this->command .= ' --width=' . $this->width; |
| 46 | $this->height = 80 + count($this->rows) * 25; | ||
| 47 | $this->command .= ' --height=' . $this->height; | ||
| 47 | $this->fillZenityList(); | 48 | $this->fillZenityList(); |
| 48 | } | 49 | } |
| 49 | } | 50 | } |
| @@ -54,8 +55,10 @@ class ZenityList extends ZenityCmd | |||
| 54 | { | 55 | { |
| 55 | $this->rows = $rows; | 56 | $this->rows = $rows; |
| 56 | $this->columns = count(StructTablesDB::$structureOfTables[$table]); | 57 | $this->columns = count(StructTablesDB::$structureOfTables[$table]); |
| 57 | $this->width = 600; | 58 | $this->width = 800; |
| 58 | $this->command .= ' --width=' . $this->width; | 59 | $this->command .= ' --width=' . $this->width; |
| 60 | $this->height = 80 + count($this->rows) * 25; | ||
| 61 | $this->command .= ' --height=' . $this->height; | ||
| 59 | $this->fillZenityList(); | 62 | $this->fillZenityList(); |
| 60 | } | 63 | } |
| 61 | 64 | ||
| @@ -100,7 +103,7 @@ class ZenityList extends ZenityCmd | |||
| 100 | 103 | ||
| 101 | class ZenityQuestion extends ZenityCmd | 104 | class ZenityQuestion extends ZenityCmd |
| 102 | { | 105 | { |
| 103 | public function __construct($text) | 106 | public function __construct(string $text) |
| 104 | { | 107 | { |
| 105 | $this->command_type = ' --question'; | 108 | $this->command_type = ' --question'; |
| 106 | parent::__construct($text); | 109 | parent::__construct($text); |
| @@ -114,7 +117,7 @@ class ZenityQuestion extends ZenityCmd | |||
| 114 | // si on clique sur 'Annuler', renvoie une chaine vide | 117 | // si on clique sur 'Annuler', renvoie une chaine vide |
| 115 | class ZenityForms extends ZenityCmd | 118 | class ZenityForms extends ZenityCmd |
| 116 | { | 119 | { |
| 117 | public function __construct($text, array $rows) | 120 | public function __construct(string $text, array $rows) |
| 118 | { | 121 | { |
| 119 | $this->command_type = ' --forms'; | 122 | $this->command_type = ' --forms'; |
| 120 | parent::__construct($text, $rows); | 123 | parent::__construct($text, $rows); |
| @@ -122,12 +125,12 @@ class ZenityForms extends ZenityCmd | |||
| 122 | self::entriesZenityForms($this->rows); | 125 | self::entriesZenityForms($this->rows); |
| 123 | } | 126 | } |
| 124 | 127 | ||
| 125 | private function entriesZenityForms($entries) | 128 | private function entriesZenityForms(array $input) |
| 126 | { | 129 | { |
| 127 | $output = ''; | 130 | $output = ''; |
| 128 | foreach($entries as $one_entry) | 131 | foreach($input as $one_question) |
| 129 | { | 132 | { |
| 130 | $output .= ' --add-entry="' . $one_entry . '"'; // forme: ' "choix 1" "choix 2"' | 133 | $output .= ' --add-entry="' . $one_question . '"'; // forme: ' "choix 1" "choix 2"' |
| 131 | } | 134 | } |
| 132 | $this->command .= $output; | 135 | $this->command .= $output; |
| 133 | } | 136 | } |
| @@ -135,7 +138,7 @@ class ZenityForms extends ZenityCmd | |||
| 135 | 138 | ||
| 136 | class ZenityCalendar extends ZenityCmd | 139 | class ZenityCalendar extends ZenityCmd |
| 137 | { | 140 | { |
| 138 | public function __construct($text) | 141 | public function __construct(string $text) |
| 139 | { | 142 | { |
| 140 | $this->command_type = ' --calendar'; | 143 | $this->command_type = ' --calendar'; |
| 141 | parent::__construct($text); | 144 | parent::__construct($text); |
| @@ -144,7 +147,7 @@ class ZenityCalendar extends ZenityCmd | |||
| 144 | 147 | ||
| 145 | class ZenityEntry extends ZenityCmd | 148 | class ZenityEntry extends ZenityCmd |
| 146 | { | 149 | { |
| 147 | public function __construct($text) | 150 | public function __construct(string $text) |
| 148 | { | 151 | { |
| 149 | $this->command_type = ' --entry'; | 152 | $this->command_type = ' --entry'; |
| 150 | parent::__construct($text); | 153 | parent::__construct($text); |
diff --git a/src/view/ZenitySetup.php b/src/view/ZenitySetup.php new file mode 100644 index 0000000..e8a3ddb --- /dev/null +++ b/src/view/ZenitySetup.php | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | <?php | ||
| 2 | // view/ZenitySetup.php | ||
| 3 | // | ||
| 4 | // ces variables sont des paramètres de la commande zenity (--text, --add-entry, --column) | ||
| 5 | // les utiliser à l'instanciation des objets Zenity à la manière de l'exemple suivant: | ||
| 6 | // $MenuPrincipal = new ZenityList(ZenitySetup::$menu_principal_text, ZenitySetup::$menu_principal_entrees); | ||
| 7 | |||
| 8 | class ZenitySetup | ||
| 9 | { | ||
| 10 | static public $menu_principal_text = "Gestion d'une micro-entreprise"; | ||
| 11 | static public $menu_principal_entrees = ["Nouvelle prestation", "Modifier enregistrement", "Fichier clients", "Créer/imprimer un document", "Communication", "Base de données"]; | ||
| 12 | static public $question_nouveau_client_text = "Ce client figure t\'il déjà dans le fichier clients?"; | ||
| 13 | static public $menu_enregistrement_text = "Type d\'enregistrement?"; | ||
| 14 | static public $menu_enregistrement_entrees = ["Devis", "Facture", "CESU", "Location", "Prestation non vendue"]; | ||
| 15 | static public $menu_documents_text = "Création de documents LaTeX"; | ||
| 16 | static public $menu_documents_entrees = ["Devis", "Facture", "Lettre avec adresse", "Livre des recettes", "Registre des achats", "Bilan annuel"]; | ||
| 17 | static public $menu_communication_text = "Imprimer un support de communication"; | ||
| 18 | static public $menu_communication_entrees = ["Flyer (nécessite gimp)", "Carte de visite (nécessite scribus)", "Explorateur de fichiers"]; | ||
| 19 | static public $recherche_client_text = "Recherche d'un client avec son nom ou son code client"; | ||
| 20 | static public $resultats_recherche_client_text = "Résultats de la recherche, sélectionner un client"; | ||
| 21 | static public $nouveau_client_text = "Nouveau client"; | ||
| 22 | static public $nouveau_client_entrees = ["Prénom Nom:", "Code client, exemple: J.P.Duchmol", "Adresse::", "Telephone:", "Courriel:", "Commentaires:"]; | ||
| 23 | static public $calendar_text = 'Nouvelle prestation étape 1/3 - Choisir une date'; | ||
| 24 | static public $formulaire_text = 'Nouvelle prestation 2/3 - Détail des travaux'; | ||
| 25 | static public $formulaire_facture_entrees = ["Tâches effectuées:", "Modèle du PC:", "OS:", "Données sauvegardées:", "Clés d\'activation:", "Temps main d\'oeuvre (heures):", "Total main d\'oeuvre (euros):", "Total pièces (euros):", "Déplacement (euros)", "Total HT (euros):", "Mode de paiement", "Commentaires"]; | ||
| 26 | static public $formulaire_devis_entrees = ["Validite du devis:", "Devis signé?:"]; | ||
| 27 | static public $formulaire_cesu_entrees = ["Tâches effectuées:", "Duree de travail:", "Salaire net"]; | ||
| 28 | static public $formulaire_location_entrees = ["Désignation du bien", "Modèle, numéro de série, description:", "Valeur", "État des lieux du début:", "État des lieux de fin:", "Durée de la location en mois:", "Loyer mensuel:", "Nombre de loyers déjà payés:", "Montant du chèque de caution:"]; | ||
| 29 | static public $commentaire_prestation_text = 'Nouvelle prestation 3/3 - Commentaires'; | ||
| 30 | } | ||
diff --git a/src/view/zenity_setup.php b/src/view/zenity_setup.php deleted file mode 100644 index 042d1ab..0000000 --- a/src/view/zenity_setup.php +++ /dev/null | |||
| @@ -1,37 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | // php/zenity_setup.php | ||
| 3 | |||
| 4 | |||
| 5 | // contenu des fenêtres zenity | ||
| 6 | $menu_principal_text = "Gestion d'une micro-entreprise"; | ||
| 7 | $menu_principal_entrees = ["Nouvelle prestation", "Modifier enregistrement", "Fichier clients", "Créer/imprimer un document", "Communication", "Base de données"]; | ||
| 8 | $question_nouveau_client_text = "Ce client figure t\'il déjà dans le fichier clients?"; | ||
| 9 | $menu_enregistrement_text = "Type d\'enregistrement?"; | ||
| 10 | $menu_enregistrement_entrees = ["Devis", "Facture", "CESU", "Prestation non vendue"]; | ||
| 11 | $menu_documents_text = "Création de documents LaTeX"; | ||
| 12 | $menu_documents_entrees = ["Devis", "Facture", "Lettre avec adresse", "Livre des recettes", "Registre des achats", "Bilan annuel"]; | ||
| 13 | $menu_communication_text = "Imprimer un support de communication"; | ||
| 14 | $menu_communication_entrees = ["Flyer (nécessite gimp)", "Carte de visite (nécessite scribus)", "Explorateur de fichiers"]; | ||
| 15 | $recherche_client_text = "Recherche d'un client avec son nom ou son code client"; | ||
| 16 | $resultats_recherche_client_text = "Résultats de la recherche, sélectionner un client"; | ||
| 17 | $nouveau_client_text = "Nouveau client"; | ||
| 18 | $nouveau_client_entrees = ["Prénom Nom:", "Adresse:", "Code client, exemple: J.P.Duchmol", "Commentaires"]; | ||
| 19 | $calendar_text = 'Nouvelle prestation étape 1/3 - Choisir une date'; | ||
| 20 | $formulaire_text = 'Nouvelle prestation 2/3 - Détail des travaux'; | ||
| 21 | $formulaire_entrees = ["Tâches effectuées:", "Modèle du PC:", "OS:", "Données sauvegardées:", "Clés d\'activation:", "Temps main d\'oeuvre (heures):", "Total main d\'oeuvre (euros):", "Total pièces (euros):", "Déplacement (euros)", "Total HT (euros):",]; | ||
| 22 | $commentaire_prestation_text = 'Nouvelle prestation 3/3 - Commentaires'; | ||
| 23 | |||
| 24 | |||
| 25 | // commandes système qui ouvrent les fenêtres zenity, un objet = une commande | ||
| 26 | // s'utilisent comme ceci: exec($Objet->get()); | ||
| 27 | $MenuPrincipal = new ZenityList($menu_principal_text, $menu_principal_entrees); | ||
| 28 | $QuestionNouveauClient = new ZenityQuestion($question_nouveau_client_text); | ||
| 29 | $MenuEnregistrement = new ZenityList($menu_enregistrement_text, $menu_enregistrement_entrees); | ||
| 30 | $MenuDocuments = new ZenityList($menu_documents_text, $menu_documents_entrees); | ||
| 31 | $MenuCommunication = new ZenityList($menu_communication_text, $menu_communication_entrees); | ||
| 32 | $RechercheClient = new zenityEntry($recherche_client_text); | ||
| 33 | $ResultatsRechercheClient = new ZenityList($resultats_recherche_client_text, [], 2); | ||
| 34 | $NouveauClient = new ZenityForms($nouveau_client_text, $nouveau_client_entrees); | ||
| 35 | $Calendrier = new ZenityCalendar($calendar_text); | ||
| 36 | $FormulairePrestation = new ZenityForms($formulaire_text, $formulaire_entrees); | ||
| 37 | $CommentairePrestation = new ZenityEntry($commentaire_prestation_text); | ||
