diff options
| author | polo <ordipolo@gmx.fr> | 2023-07-22 12:29:47 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2023-07-22 12:29:47 +0200 |
| commit | 747674b450d6840ce9bd9aecd765cf31445ef8d3 (patch) | |
| tree | 46e47fd65c751e1951d9aa8438aea1b8c2d8aece | |
| parent | 9bdfb5196a2ee1cbfc403702e8d2ef88076d366f (diff) | |
| download | AppliGestionPHP-747674b450d6840ce9bd9aecd765cf31445ef8d3.tar.gz AppliGestionPHP-747674b450d6840ce9bd9aecd765cf31445ef8d3.tar.bz2 AppliGestionPHP-747674b450d6840ce9bd9aecd765cf31445ef8d3.zip | |
navigation entre sections, boucle principale, client ou prospect
| -rw-r--r-- | data/dev.sqlite | bin | 36864 -> 36864 bytes | |||
| -rw-r--r-- | src/Dates.php | 10 | ||||
| -rw-r--r-- | src/Latex.php | 94 | ||||
| -rw-r--r-- | src/functions.php | 118 | ||||
| -rwxr-xr-x | src/main.php | 130 | ||||
| -rw-r--r-- | src/model/Clients.php | 6 | ||||
| -rw-r--r-- | src/model/Model.php | 13 | ||||
| -rw-r--r-- | src/model/StructTablesDB.php | 2 | ||||
| -rw-r--r-- | src/model/traits.php | 2 | ||||
| -rw-r--r-- | src/sections/1_customer.php | 48 | ||||
| -rw-r--r-- | src/sections/2_quotations.php | 9 | ||||
| -rw-r--r-- | src/sections/2_service.php (renamed from src/sections/1_new_service.php) | 118 | ||||
| -rw-r--r-- | src/sections/3_modify_data.php | 9 | ||||
| -rw-r--r-- | src/sections/3_modify_service.php | 9 | ||||
| -rw-r--r-- | src/sections/4_get_document.php | 55 | ||||
| -rw-r--r-- | src/sections/main_loop.php | 106 | ||||
| -rw-r--r-- | src/view/ZenitySetup.php | 15 |
17 files changed, 454 insertions, 290 deletions
diff --git a/data/dev.sqlite b/data/dev.sqlite index 841d187..857931f 100644 --- a/data/dev.sqlite +++ b/data/dev.sqlite | |||
| Binary files differ | |||
diff --git a/src/Dates.php b/src/Dates.php index eb57ca8..2fe93cb 100644 --- a/src/Dates.php +++ b/src/Dates.php | |||
| @@ -32,24 +32,24 @@ class Dates | |||
| 32 | // getters | 32 | // getters |
| 33 | public function getDate(): string | 33 | public function getDate(): string |
| 34 | { | 34 | { |
| 35 | return($this->date); | 35 | return $this->date; |
| 36 | } | 36 | } |
| 37 | public function getDay(): string | 37 | public function getDay(): string |
| 38 | { | 38 | { |
| 39 | return($this->day); | 39 | return $this->day; |
| 40 | } | 40 | } |
| 41 | public function getMonth(): string | 41 | public function getMonth(): string |
| 42 | { | 42 | { |
| 43 | return($this->month); | 43 | return $this->month; |
| 44 | } | 44 | } |
| 45 | public function getYear(): string | 45 | public function getYear(): string |
| 46 | { | 46 | { |
| 47 | return($this->year); | 47 | return $this->year; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | public function getTimestamp(): int | 50 | public function getTimestamp(): int |
| 51 | { | 51 | { |
| 52 | return($this->timestamp); | 52 | return $this->timestamp; |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | 55 | ||
diff --git a/src/Latex.php b/src/Latex.php index 051c48b..547c130 100644 --- a/src/Latex.php +++ b/src/Latex.php | |||
| @@ -12,7 +12,7 @@ abstract class Latex | |||
| 12 | protected $data = []; // données à insérer dans le template | 12 | protected $data = []; // données à insérer dans le template |
| 13 | protected $latex = ''; // latex pur | 13 | protected $latex = ''; // latex pur |
| 14 | 14 | ||
| 15 | static function makeLatexSubClass(string $type): Object | 15 | static function makeLatexSubClass(string $type) |
| 16 | { | 16 | { |
| 17 | switch($type) | 17 | switch($type) |
| 18 | { | 18 | { |
| @@ -27,16 +27,20 @@ abstract class Latex | |||
| 27 | return new EnveloppeRectoLatex($type); | 27 | return new EnveloppeRectoLatex($type); |
| 28 | case 'enveloppe_verso': | 28 | case 'enveloppe_verso': |
| 29 | return new EnveloppeVersoLatex($type); | 29 | return new EnveloppeVersoLatex($type); |
| 30 | // pas de document | ||
| 31 | case 'cesu': | ||
| 32 | return null; | ||
| 33 | case 'non_vendue': | ||
| 34 | return null; | ||
| 30 | 35 | ||
| 31 | // documents pour la compta | 36 | // documents pour la compta |
| 32 | 37 | ||
| 33 | // erreur | 38 | // erreur |
| 34 | default: | 39 | default: |
| 35 | echo 'erreur, la sous-classe latex à initialiser n\'existe pas'; | 40 | echo "erreur, la sous-classe latex à initialiser n'existe pas\n"; |
| 36 | } | 41 | } |
| 37 | } | 42 | } |
| 38 | 43 | ||
| 39 | // tester en private? | ||
| 40 | public function __construct(string $type) | 44 | public function __construct(string $type) |
| 41 | { | 45 | { |
| 42 | $this->type = $type; | 46 | $this->type = $type; |
| @@ -70,30 +74,28 @@ abstract class Latex | |||
| 70 | { | 74 | { |
| 71 | return $this->pdf_path; | 75 | return $this->pdf_path; |
| 72 | } | 76 | } |
| 73 | |||
| 74 | public function getLatex(): string | 77 | public function getLatex(): string |
| 75 | { | 78 | { |
| 76 | return $this->latex; | 79 | return $this->latex; |
| 77 | } | 80 | } |
| 78 | 81 | ||
| 79 | // setters | 82 | // setters |
| 80 | public function setFileName(string $file_name) | 83 | //~ public function setFileName(string $file_name) |
| 81 | { | 84 | //~ { |
| 82 | $this->file_name = $file_name; | 85 | //~ $this->file_name = $file_name; |
| 83 | } | 86 | //~ } |
| 84 | public function setLatexPath(string $latex_path) | 87 | //~ public function setLatexPath(string $latex_path) |
| 85 | { | 88 | //~ { |
| 86 | $this->latex_path = $latex_path; | 89 | //~ $this->latex_path = $latex_path; |
| 87 | } | 90 | //~ } |
| 88 | public function setPdfPath(string $pdf_path) | 91 | //~ public function setPdfPath(string $pdf_path) |
| 89 | { | 92 | //~ { |
| 90 | $this->pdf_path = $pdf_path; | 93 | //~ $this->pdf_path = $pdf_path; |
| 91 | } | 94 | //~ } |
| 92 | 95 | ||
| 93 | public function setData(Object $Object) | 96 | public function setData(Object $Object) |
| 94 | { | 97 | { |
| 95 | $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs | 98 | $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs |
| 96 | //return $Object; // pour chainer les méthodes | ||
| 97 | } | 99 | } |
| 98 | } | 100 | } |
| 99 | 101 | ||
| @@ -101,24 +103,36 @@ abstract class Latex | |||
| 101 | abstract class PrestaLatex extends Latex | 103 | abstract class PrestaLatex extends Latex |
| 102 | { | 104 | { |
| 103 | protected $Date; // sera un type "Dates" | 105 | protected $Date; // sera un type "Dates" |
| 104 | protected $year = ''; | ||
| 105 | 106 | ||
| 106 | //~ public function __construct(string $type) // surcharge Latex::__construct() | 107 | //~ public function __construct(string $type) |
| 107 | //~ { | 108 | //~ { |
| 108 | //~ $this->type = $type; | 109 | //~ $this->type = $type; |
| 109 | //~ $this->Date = new Dates(); | ||
| 110 | //~ $this->year = $this->Date->getYear(); | ||
| 111 | //~ } | 110 | //~ } |
| 112 | 111 | ||
| 113 | public function getYear(): string // parce que Dates::getDate() retourne une chaine | 112 | public function setData(Object $Object): self |
| 114 | { | 113 | { |
| 115 | return $this->year; | 114 | $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs |
| 115 | |||
| 116 | if(get_class($Object) === 'Prestations') | ||
| 117 | { | ||
| 118 | $this->file_name = $Object->getCodePresta() . '.tex'; | ||
| 119 | $this->makeDateInstance($Object->getDate()); // paramètre = int | ||
| 120 | |||
| 121 | $this->latex_path = Config::$latex_path . $this->Date->getYear() . '/'; | ||
| 122 | $this->pdf_path = Config::$pdf_path . $this->Date->getYear() . '/'; | ||
| 123 | } | ||
| 124 | |||
| 125 | return $this; // pour chainer les méthodes | ||
| 116 | } | 126 | } |
| 117 | 127 | ||
| 118 | public function makeDateInstance(int $date) | 128 | //~ public function getYear(): string // parce que Dates::getDate() retourne une chaine |
| 129 | //~ { | ||
| 130 | //~ return $this->year; | ||
| 131 | //~ } | ||
| 132 | |||
| 133 | protected function makeDateInstance(int $timestamp) | ||
| 119 | { | 134 | { |
| 120 | $this->Date = new Dates($date); | 135 | $this->Date = new Dates($timestamp); |
| 121 | $this->year = $this->Date->getYear(); | ||
| 122 | } | 136 | } |
| 123 | 137 | ||
| 124 | // forme = code-presta.tex | 138 | // forme = code-presta.tex |
| @@ -143,23 +157,45 @@ abstract class PrestaLatex extends Latex | |||
| 143 | //return($latex); | 157 | //return($latex); |
| 144 | } | 158 | } |
| 145 | } | 159 | } |
| 146 | |||
| 147 | class DevisLatex extends PrestaLatex // extends Latex | 160 | class DevisLatex extends PrestaLatex // extends Latex |
| 148 | {} | 161 | {} |
| 149 | class FactureLatex extends PrestaLatex // extends Latex | 162 | class FactureLatex extends PrestaLatex // extends Latex |
| 150 | {} | 163 | {} |
| 151 | class LocationLatex extends PrestaLatex // extends Latex | 164 | class LocationLatex extends PrestaLatex // extends Latex |
| 152 | {} | 165 | {} |
| 166 | |||
| 153 | class EnveloppeRectoLatex extends Latex | 167 | class EnveloppeRectoLatex extends Latex |
| 154 | { | 168 | { |
| 169 | public function __construct(string $type) | ||
| 170 | { | ||
| 171 | $this->type = $type; | ||
| 172 | $this->latex_path = Config::$latex_path . 'enveloppes_recto/'; | ||
| 173 | $this->pdf_path = Config::$pdf_path . 'enveloppes_recto/'; | ||
| 174 | } | ||
| 175 | |||
| 176 | public function setData(Object $Client) // ici de type Clients | ||
| 177 | { | ||
| 178 | $this->file_name = $Client->getCodeClient() . '.tex'; | ||
| 179 | $this->data = array_merge($this->data, $Client->getAll()); // nécessite des tableaux associatifs | ||
| 180 | $this->spacesInPostCode(); // nécessite $this->data | ||
| 181 | } | ||
| 182 | |||
| 155 | // code postal avec 2 espaces entre chaque chiffre: 2 \ 9 \ 0 \ 0 \ 0 | 183 | // code postal avec 2 espaces entre chaque chiffre: 2 \ 9 \ 0 \ 0 \ 0 |
| 156 | public function spacesInPostCode() | 184 | protected function spacesInPostCode() |
| 157 | { | 185 | { |
| 158 | $this->data['code_postal_espaces'] = implode(' \ ', str_split($this->data['code_postal'])); | 186 | $this->data['code_postal_espaces'] = implode(' \ ', str_split($this->data['code_postal'])); |
| 159 | } | 187 | } |
| 160 | } | 188 | } |
| 161 | class EnveloppeVersoLatex extends Latex | 189 | class EnveloppeVersoLatex extends Latex |
| 162 | {} | 190 | { |
| 191 | public function __construct(string $type) | ||
| 192 | { | ||
| 193 | $this->type = $type; | ||
| 194 | $this->file_name = 'enveloppe_verso.tex'; | ||
| 195 | $this->latex_path = Config::$latex_path; | ||
| 196 | $this->pdf_path = Config::$pdf_path; | ||
| 197 | } | ||
| 198 | } | ||
| 163 | 199 | ||
| 164 | 200 | ||
| 165 | 201 | ||
diff --git a/src/functions.php b/src/functions.php index aaacb36..f78b23d 100644 --- a/src/functions.php +++ b/src/functions.php | |||
| @@ -22,21 +22,45 @@ function windowAppCommand(string $app, string $path = ''): string | |||
| 22 | return $command; | 22 | return $command; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | function makeObjectCLient() | 25 | function enterCustomer($Client): bool |
| 26 | { | ||
| 27 | // fenêtre | ||
| 28 | $NouveauClient = new ZenityForms(ZenitySetup::$nouveau_client_text, ZenitySetup::$nouveau_client_entrees); | ||
| 29 | |||
| 30 | $input = exec($NouveauClient->get()); | ||
| 31 | if($input == '') | ||
| 32 | { | ||
| 33 | echo "debug: annulation lors de l'enregistrement d'un nouveau client\n"; | ||
| 34 | return false; | ||
| 35 | } | ||
| 36 | if(!$Client->hydrateFromForm($input)) | ||
| 37 | { | ||
| 38 | // messages d'erreur dans hydrateFromForm() | ||
| 39 | return false; | ||
| 40 | } | ||
| 41 | unset($input); | ||
| 42 | |||
| 43 | $Client->create(); // écrire dans la base | ||
| 44 | $Client->setID(); // sans paramètre, exécute un $this->db->lastInsertId() | ||
| 45 | |||
| 46 | return true; | ||
| 47 | } | ||
| 48 | |||
| 49 | function makeObjectClient() | ||
| 26 | { | 50 | { |
| 27 | // fenêtres | 51 | // fenêtres |
| 28 | $QuestionNouveauClient = new ZenityQuestion(ZenitySetup::$question_nouveau_client_text); | 52 | //~ $QuestionNouveauClient = new ZenityQuestion(ZenitySetup::$question_nouveau_client_text); |
| 29 | $RechercheClient = new zenityEntry(ZenitySetup::$recherche_client_text); | 53 | $RechercheClient = new zenityEntry(ZenitySetup::$recherche_client_text); |
| 30 | $ResultatsRechercheClient = new ZenityList(ZenitySetup::$resultats_recherche_client_text, []); | 54 | $ResultatsRechercheClient = new ZenityList(ZenitySetup::$resultats_recherche_client_text, []); |
| 31 | $NouveauClient = new ZenityForms(ZenitySetup::$nouveau_client_text, ZenitySetup::$nouveau_client_entrees); | 55 | //~ $NouveauClient = new ZenityForms(ZenitySetup::$nouveau_client_text, ZenitySetup::$nouveau_client_entrees); |
| 32 | 56 | ||
| 33 | $Client = new Clients; | 57 | $Client = new Clients; |
| 34 | 58 | ||
| 35 | // est ce que le client est déjà dans la base? | 59 | // est ce que le client est déjà dans la base? |
| 36 | $client_inconnu = true; | 60 | //~ $client_inconnu = true; |
| 37 | if(exec($QuestionNouveauClient->get()) == '0') // $? = 0 signifie oui, double égal == pour le transtypage | 61 | //~ if(exec($QuestionNouveauClient->get()) == '0') // $? = 0 signifie oui, double égal == pour le transtypage |
| 38 | { | 62 | //~ { |
| 39 | echo "choix: recherche d'une client\n"; | 63 | //~ echo "choix: recherche d'une client\n"; |
| 40 | $input = exec($RechercheClient->get()); | 64 | $input = exec($RechercheClient->get()); |
| 41 | if($input == '') | 65 | if($input == '') |
| 42 | { | 66 | { |
| @@ -45,7 +69,7 @@ function makeObjectCLient() | |||
| 45 | } | 69 | } |
| 46 | 70 | ||
| 47 | echo "debug: recherche effectuée\n"; | 71 | echo "debug: recherche effectuée\n"; |
| 48 | $ResultatsRechercheClient->setListRows(rechercheClient($input, $Client), $Client->getTable()); // recherche silencieuse | 72 | $ResultatsRechercheClient->setListRows(searchCustomer($input, $Client), $Client->getTable()); // recherche silencieuse |
| 49 | 73 | ||
| 50 | // sélection parmi les résultats | 74 | // sélection parmi les résultats |
| 51 | $input = exec($ResultatsRechercheClient->get()); // renvoie l'ID de la table 'clients' | 75 | $input = exec($ResultatsRechercheClient->get()); // renvoie l'ID de la table 'clients' |
| @@ -59,31 +83,31 @@ function makeObjectCLient() | |||
| 59 | 83 | ||
| 60 | echo "debug: client sélectionné\n"; | 84 | echo "debug: client sélectionné\n"; |
| 61 | $Client->hydrate($Client->findById($input)); | 85 | $Client->hydrate($Client->findById($input)); |
| 62 | $client_inconnu = false; | 86 | //~ $client_inconnu = false; |
| 63 | } | 87 | //~ } |
| 64 | else | 88 | //~ else |
| 65 | { | 89 | //~ { |
| 66 | echo "choix: nouveau client\n"; | 90 | //~ echo "choix: nouveau client\n"; |
| 67 | } | 91 | //~ } |
| 68 | 92 | ||
| 69 | // on n'a pas cherché OU on n'a pas trouvé | 93 | // on n'a pas cherché OU on n'a pas trouvé |
| 70 | if($client_inconnu) | 94 | //~ if($client_inconnu) |
| 71 | { | 95 | //~ { |
| 72 | $input = exec($NouveauClient->get()); | 96 | //~ $input = exec($NouveauClient->get()); |
| 73 | if($input == '') | 97 | //~ if($input == '') |
| 74 | { | 98 | //~ { |
| 75 | echo "debug: annulation lors de l'enregistrement d'un nouveau client\n"; | 99 | //~ echo "debug: annulation lors de l'enregistrement d'un nouveau client\n"; |
| 76 | return 0; | 100 | //~ return 0; |
| 77 | } | 101 | //~ } |
| 78 | if(!$Client->hydrateFromForm($input)) | 102 | //~ if(!$Client->hydrateFromForm($input)) |
| 79 | { | 103 | //~ { |
| 80 | // messages d'erreur dans hydrateFromForm() | 104 | //~ // messages d'erreur dans hydrateFromForm() |
| 81 | return 0; | 105 | //~ return 0; |
| 82 | } | 106 | //~ } |
| 83 | unset($input); | 107 | //~ unset($input); |
| 84 | $Client->create(); | 108 | //~ $Client->create(); |
| 85 | $Client->setID(); // sans paramètre, exécute un $this->db->lastInsertId() | 109 | //~ $Client->setID(); // sans paramètre, exécute un $this->db->lastInsertId() |
| 86 | } | 110 | //~ } |
| 87 | 111 | ||
| 88 | return $Client; | 112 | return $Client; |
| 89 | } | 113 | } |
| @@ -93,7 +117,7 @@ function makeObjectCLient() | |||
| 93 | // NOTE 3: la variable créée lors d'un "new" est elle-même une référence contenant un identifiant (= le pointeur?) | 117 | // NOTE 3: la variable créée lors d'un "new" est elle-même une référence contenant un identifiant (= le pointeur?) |
| 94 | // NOTE 4: l'objet est détruit lorsque la dernière référence est supprimée | 118 | // NOTE 4: l'objet est détruit lorsque la dernière référence est supprimée |
| 95 | 119 | ||
| 96 | function rechercheClient(string $input, Clients $Client): array | 120 | function searchCustomer(string $input, Clients $Client): array |
| 97 | { | 121 | { |
| 98 | $input_array = explode(' ', $input); // si plusieurs mot, on les recherche tous l'un après l'autre | 122 | $input_array = explode(' ', $input); // si plusieurs mot, on les recherche tous l'un après l'autre |
| 99 | $result = $Client->findByKeywords($input_array, 'prenom_nom'); // on obtient un tableau à deux dimensions avec les entrées trouvées | 123 | $result = $Client->findByKeywords($input_array, 'prenom_nom'); // on obtient un tableau à deux dimensions avec les entrées trouvées |
| @@ -101,6 +125,17 @@ function rechercheClient(string $input, Clients $Client): array | |||
| 101 | } | 125 | } |
| 102 | 126 | ||
| 103 | 127 | ||
| 128 | function makeTexAndPdf(Object $Object) | ||
| 129 | { | ||
| 130 | if(get_class($Object) !== 'EnveloppeVersoLatex') | ||
| 131 | { | ||
| 132 | makeFolder($Object->getLatexPath()); | ||
| 133 | makeFolder($Object->getPdfPath()); | ||
| 134 | } | ||
| 135 | makeFile($Object->getLatexPath(), $Object->getFileName(), $Object->getLatex()); | ||
| 136 | latexToPdf($Object->getLatexPath(), $Object->getFileName(), $Object->getPdfPath()); | ||
| 137 | } | ||
| 138 | |||
| 104 | //~ function makeLatexAndPdfDocuments(Clients $Client = null, Prestations $Presta = null, $PrestaDetails = null) | 139 | //~ function makeLatexAndPdfDocuments(Clients $Client = null, Prestations $Presta = null, $PrestaDetails = null) |
| 105 | //~ { | 140 | //~ { |
| 106 | //~ $latex = ''; | 141 | //~ $latex = ''; |
| @@ -166,22 +201,3 @@ function rechercheClient(string $input, Clients $Client): array | |||
| 166 | //~ } | 201 | //~ } |
| 167 | //~ } | 202 | //~ } |
| 168 | //~ } | 203 | //~ } |
| 169 | |||
| 170 | //~ function makeLatex(string $type, array $data = [], Dates $Date = null) | ||
| 171 | //~ { | ||
| 172 | //~ $date = ''; | ||
| 173 | //~ if($Date != null) | ||
| 174 | //~ { | ||
| 175 | //~ $date = $Date->getDate(); | ||
| 176 | //~ $date = preg_replace('#\D#', '/', $date); // date avec des slashs / parce que j'aime bien | ||
| 177 | //~ } | ||
| 178 | |||
| 179 | //~ // on obtient la variable $latex avec ob_get_clean() | ||
| 180 | //~ // le include() ici, c'est du génie ou c'est moche ou les deux? | ||
| 181 | //~ // un nouveau fichier php est inséré à chaque itération | ||
| 182 | //~ include('latex_templates/' . $type . '.php'); | ||
| 183 | |||
| 184 | //~ // on retourne le buffer | ||
| 185 | //~ // normallement le code PHP inséré avec include est nettoyé en quittant la fonction | ||
| 186 | //~ return($latex); | ||
| 187 | //~ } | ||
diff --git a/src/main.php b/src/main.php index 7bf8470..a0b973b 100755 --- a/src/main.php +++ b/src/main.php | |||
| @@ -49,132 +49,6 @@ require('view/ZenitySetup.php'); // texte dans les fenêtres ET instanciation (u | |||
| 49 | 49 | ||
| 50 | require('Latex.php'); // générer le code LaTeX | 50 | require('Latex.php'); // générer le code LaTeX |
| 51 | 51 | ||
| 52 | require('sections/1_new_service.php'); | ||
| 53 | require('sections/2_quotations.php'); | ||
| 54 | require('sections/3_modify_service.php'); | ||
| 55 | 52 | ||
| 56 | // boucle principale | 53 | // action !! |
| 57 | $boucle = true; | 54 | require('sections/main_loop.php'); |
| 58 | $code_retour = 0; // 0 dirige vers le menu principal, 1 vers la section 1, etc | ||
| 59 | while($boucle) | ||
| 60 | { | ||
| 61 | // niveau 1: menu principal | ||
| 62 | if($code_retour === 0) | ||
| 63 | { | ||
| 64 | $MenuPrincipal = new ZenityList(ZenitySetup::$menu_principal_text, ZenitySetup::$menu_principal_entrees); | ||
| 65 | $choix_niv1 = exec($MenuPrincipal->get()); | ||
| 66 | } | ||
| 67 | else | ||
| 68 | { | ||
| 69 | $choix_niv1 = ''; | ||
| 70 | } | ||
| 71 | |||
| 72 | |||
| 73 | // -- SECTION 1: Nouvelle prestation -- | ||
| 74 | if($choix_niv1 === ZenitySetup::$menu_principal_entrees[0] || $code_retour === 1) | ||
| 75 | { | ||
| 76 | echo("choix: $choix_niv1\n"); | ||
| 77 | $code_retour = newService(); | ||
| 78 | echo "debug: main.php: hello, code retour " . $code_retour . "\n"; | ||
| 79 | } | ||
| 80 | |||
| 81 | // -- SECTION 2: Devis -- | ||
| 82 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[1] || $code_retour === 2) | ||
| 83 | { | ||
| 84 | echo("choix: $choix_niv1\n"); | ||
| 85 | $code_retour = modifyService(); | ||
| 86 | } | ||
| 87 | // -- SECTION 3: Modifier un enregistrement -- | ||
| 88 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[2] || $code_retour === 3) | ||
| 89 | { | ||
| 90 | echo("choix: $choix_niv1\n"); | ||
| 91 | $code_retour = modifyService(); | ||
| 92 | } | ||
| 93 | |||
| 94 | // -- SECTION 4: Consulter/analyser les données -- | ||
| 95 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[3] || $code_retour === 4) | ||
| 96 | { | ||
| 97 | echo("choix: $choix_niv1\n"); | ||
| 98 | // quel affichage? des tableaux avec zenity? LaTeX? une page web? un autre outil servant à faire des tableaux et graphiques | ||
| 99 | } | ||
| 100 | |||
| 101 | // -- SECTION 5: Imprimer -- | ||
| 102 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[4] || $code_retour === 5) // = Imprimer un document | ||
| 103 | { | ||
| 104 | echo("choix: $choix_niv1\n"); | ||
| 105 | $MenuDocuments = new ZenityList(ZenitySetup::$menu_documents_text, ZenitySetup::$menu_documents_entrees); | ||
| 106 | $choix_niv2 = exec($MenuDocuments->get()); | ||
| 107 | if($choix_niv2 === ZenitySetup::$menu_documents_entrees[0]) | ||
| 108 | { | ||
| 109 | |||
| 110 | } | ||
| 111 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[1]) // = Facture | ||
| 112 | { | ||
| 113 | |||
| 114 | } | ||
| 115 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[2]) // = Lettre avec adresse | ||
| 116 | { | ||
| 117 | |||
| 118 | } | ||
| 119 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[3]) // = Livre des recettes | ||
| 120 | { | ||
| 121 | |||
| 122 | } | ||
| 123 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[4]) // = Registre des achats | ||
| 124 | { | ||
| 125 | |||
| 126 | } | ||
| 127 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[5]) // = Bilan annuel | ||
| 128 | { | ||
| 129 | |||
| 130 | } | ||
| 131 | else | ||
| 132 | { | ||
| 133 | // retour menu principal | ||
| 134 | } | ||
| 135 | } | ||
| 136 | |||
| 137 | // -- SECTION 6: Supports de communication -- | ||
| 138 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[5] || $code_retour === 6) // = Communication | ||
| 139 | { | ||
| 140 | echo("choix: $choix_niv1\n"); | ||
| 141 | $MenuCommunication = new ZenityList(ZenitySetup::$menu_communication_text, ZenitySetup::$menu_communication_entrees); | ||
| 142 | $choix_niv2 = exec($MenuCommunication->get()); | ||
| 143 | if($choix_niv2 === ZenitySetup::$menu_communication_entrees[0]) // = Flyer (nécessite gimp) | ||
| 144 | { | ||
| 145 | exec(windowAppCommand($image_editor, $flyer)); | ||
| 146 | } | ||
| 147 | elseif($choix_niv2 === ZenitySetup::$menu_communication_entrees[1]) // = Carte de visite (nécessite scribus) | ||
| 148 | { | ||
| 149 | exec(windowAppCommand($publishing, $business_card)); | ||
| 150 | } | ||
| 151 | elseif($choix_niv2 === ZenitySetup::$menu_communication_entrees[2]) // = Explorateur de fichiers | ||
| 152 | { | ||
| 153 | exec(windowAppCommand($file_explorer, $pub)); | ||
| 154 | } | ||
| 155 | else | ||
| 156 | { | ||
| 157 | // retour menu principal | ||
| 158 | } | ||
| 159 | } | ||
| 160 | |||
| 161 | // -- SECTION 7: BDD -- | ||
| 162 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[6] || $code_retour === 7) // = Base de données | ||
| 163 | { | ||
| 164 | echo("choix: $choix_niv1\n"); | ||
| 165 | if($sqlitebrowser_enable) | ||
| 166 | { | ||
| 167 | exec(windowAppCommand(Config::$sqlite_gui, Config::$db_path)); | ||
| 168 | } | ||
| 169 | else | ||
| 170 | { | ||
| 171 | exec($x_term_command . ' ' . $sqlite_cli . ' ' . Config::$db_path); // correpond à priori à: xterm -e sqlite3 ~/ORDIPOLO/Appli_PHP/ordipolo.sqlite | ||
| 172 | } | ||
| 173 | } | ||
| 174 | |||
| 175 | // arrêt | ||
| 176 | else | ||
| 177 | { | ||
| 178 | $boucle = false; | ||
| 179 | } | ||
| 180 | } | ||
diff --git a/src/model/Clients.php b/src/model/Clients.php index d9dd28d..f36acc1 100644 --- a/src/model/Clients.php +++ b/src/model/Clients.php | |||
| @@ -13,6 +13,7 @@ class Clients extends Model | |||
| 13 | protected $telephone; | 13 | protected $telephone; |
| 14 | protected $courriel; | 14 | protected $courriel; |
| 15 | protected $apropos; | 15 | protected $apropos; |
| 16 | protected $type = 'prospect'; | ||
| 16 | 17 | ||
| 17 | //~ use ModelChildren; | 18 | //~ use ModelChildren; |
| 18 | 19 | ||
| @@ -81,6 +82,11 @@ class Clients extends Model | |||
| 81 | $this->apropos = (string) $value; | 82 | $this->apropos = (string) $value; |
| 82 | return $this; | 83 | return $this; |
| 83 | } | 84 | } |
| 85 | public function setType($value) | ||
| 86 | { | ||
| 87 | $this->type = (string) $value; | ||
| 88 | return $this; | ||
| 89 | } | ||
| 84 | 90 | ||
| 85 | 91 | ||
| 86 | public function findByKeywords(array $keywords, string $field): array // n'hydrate pas les variables, on doit choisir un client et hydrater ensuite | 92 | public function findByKeywords(array $keywords, string $field): array // n'hydrate pas les variables, on doit choisir un client et hydrater ensuite |
diff --git a/src/model/Model.php b/src/model/Model.php index 17d1292..3fb3bdf 100644 --- a/src/model/Model.php +++ b/src/model/Model.php | |||
| @@ -43,7 +43,7 @@ abstract class Model extends DB | |||
| 43 | foreach($data as $key => $value) | 43 | foreach($data as $key => $value) |
| 44 | { | 44 | { |
| 45 | // nom du setter | 45 | // nom du setter |
| 46 | // nom_du_champ devient setNomDuChamp | 46 | // nom_propriete => setPropriete |
| 47 | // on sépare les mots par des espaces, ucwords met la première lettre de chaque mot en majuscule, puis on supprime les espaces | 47 | // on sépare les mots par des espaces, ucwords met la première lettre de chaque mot en majuscule, puis on supprime les espaces |
| 48 | $setter_name = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))); // ucwords: première lettre de chaque mot en majuscule | 48 | $setter_name = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))); // ucwords: première lettre de chaque mot en majuscule |
| 49 | if(method_exists($this, $setter_name)) | 49 | if(method_exists($this, $setter_name)) |
| @@ -207,7 +207,7 @@ abstract class Model extends DB | |||
| 207 | 207 | ||
| 208 | 208 | ||
| 209 | // update UPDATE | 209 | // update UPDATE |
| 210 | public function update(int $id) | 210 | public function update(int $id) // utiliser plutôt $this->ID ? |
| 211 | { | 211 | { |
| 212 | $fields = []; | 212 | $fields = []; |
| 213 | $values = []; | 213 | $values = []; |
| @@ -219,13 +219,18 @@ abstract class Model extends DB | |||
| 219 | $values[] = $value; | 219 | $values[] = $value; |
| 220 | } | 220 | } |
| 221 | } | 221 | } |
| 222 | $values[] = $id; | 222 | $values[] = $id; // cette syntaxe ajoute une valeur au tableau |
| 223 | $field_list = implode(', ', $fields); | 223 | $field_list = implode(', ', $fields); |
| 224 | 224 | ||
| 225 | // UPDATE annonces SET titre = ?, description = ?, actif = ? WHERE id= ? | 225 | // UPDATE annonces SET titre = ?, description = ?, actif = ? WHERE id = ? |
| 226 | return($this->execQuery('UPDATE ' . $this->table . ' SET ' . $field_list . ' WHERE id = ?', $values)); | 226 | return($this->execQuery('UPDATE ' . $this->table . ' SET ' . $field_list . ' WHERE id = ?', $values)); |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | public function updateOneValue(string $field, $value) | ||
| 230 | { | ||
| 231 | return($this->execQuery('UPDATE ' . $this->table . ' SET ' . $field . ' = ? WHERE id = ?', [$value, $this->ID])); | ||
| 232 | } | ||
| 233 | |||
| 229 | 234 | ||
| 230 | // delete DELETE | 235 | // delete DELETE |
| 231 | protected function delete(int $id) | 236 | protected function delete(int $id) |
diff --git a/src/model/StructTablesDB.php b/src/model/StructTablesDB.php index 75a4383..769d502 100644 --- a/src/model/StructTablesDB.php +++ b/src/model/StructTablesDB.php | |||
| @@ -9,7 +9,7 @@ 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', 'code_client' => 'TEXT', 'adresse' => 'TEXT', 'code_postal' => 'TEXT', 'ville' => 'TEXT', 'telephone' => 'TEXT', 'courriel' => 'TEXT', 'apropos' => 'TEXT'], | 12 | 'clients' => ['ID' => 'INTEGER', 'prenom_nom' => 'TEXT', 'code_client' => 'TEXT', 'adresse' => 'TEXT', 'code_postal' => 'TEXT', 'ville' => 'TEXT', 'telephone' => 'TEXT', 'courriel' => 'TEXT', 'apropos' => 'TEXT', 'type' => 'TEXT DEFAULT prospect'], |
| 13 | 'prestations' => ['ID' => 'INTEGER', 'ID_client' => '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 | 'devis' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL', 'delai_livraison' => 'TEXT', 'validite_devis' => 'TEXT', 'signature_devis' => 'TEXT'], | 14 | 'devis' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL', 'delai_livraison' => 'TEXT', 'validite_devis' => 'TEXT', 'signature_devis' => 'TEXT'], |
| 15 | 'factures' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', '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 | 'factures' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', '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'], |
diff --git a/src/model/traits.php b/src/model/traits.php index 03121be..88451d9 100644 --- a/src/model/traits.php +++ b/src/model/traits.php | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/traits.php | 2 | // src/model/traits.php |
| 3 | // | 3 | // |
| 4 | // fonctions à utiliser par les enfants de Model | 4 | // fonctions "partagées" par les enfants de Model |
| 5 | 5 | ||
| 6 | trait ModelChildren | 6 | trait ModelChildren |
| 7 | { | 7 | { |
diff --git a/src/sections/1_customer.php b/src/sections/1_customer.php new file mode 100644 index 0000000..cdec448 --- /dev/null +++ b/src/sections/1_customer.php | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | <?php | ||
| 2 | // src/sections/1_customer.php | ||
| 3 | // | ||
| 4 | // -- SECTION 1: Fichier clients et propects -- | ||
| 5 | |||
| 6 | function newCustomer(): array | ||
| 7 | { | ||
| 8 | // fenêtres | ||
| 9 | $TypeDeClient = new ZenityList(ZenitySetup::$type_client_text, ZenitySetup::$type_client_entrees); | ||
| 10 | //~ $NouveauClient = new ZenityForms(ZenitySetup::$nouveau_client_text, ZenitySetup::$nouveau_client_entrees); | ||
| 11 | $FinSection1 = new ZenityList(ZenitySetup::$fin_section_1_text, ZenitySetup::$fin_section_1_entrees); | ||
| 12 | |||
| 13 | // -- partie 1: client ou prospect? -- | ||
| 14 | $Client = new Clients; | ||
| 15 | if(exec($TypeDeClient->get()) === 'Client') | ||
| 16 | { | ||
| 17 | $Client->setType('client'); | ||
| 18 | } | ||
| 19 | //~ else // | ||
| 20 | //~ { | ||
| 21 | //~ $Client->setType('prospect'); | ||
| 22 | //~ } | ||
| 23 | |||
| 24 | // -- partie 2: saisie des infos -- | ||
| 25 | if(enterCustomer($Client)) | ||
| 26 | { | ||
| 27 | // -- partie 3: on fait quoi maintenant -- | ||
| 28 | $choix_niv2 = exec($FinSection1->get()); | ||
| 29 | if($choix_niv2 === ZenitySetup::$fin_section_1_entrees[0]) | ||
| 30 | { | ||
| 31 | return [2, $Client]; // section 2: newService() | ||
| 32 | } | ||
| 33 | elseif($choix_niv2 === ZenitySetup::$fin_section_1_entrees[1]) | ||
| 34 | { | ||
| 35 | return [3, $Client]; // section 3: modifyData() | ||
| 36 | } | ||
| 37 | elseif($choix_niv2 === ZenitySetup::$fin_section_1_entrees[2]) | ||
| 38 | { | ||
| 39 | return [1, null]; // relancer section 1: newCustomer() | ||
| 40 | } | ||
| 41 | else | ||
| 42 | { | ||
| 43 | return [0, null]; // menu principal | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | return [0, null]; // menu principal | ||
| 48 | } | ||
diff --git a/src/sections/2_quotations.php b/src/sections/2_quotations.php deleted file mode 100644 index 76b66fd..0000000 --- a/src/sections/2_quotations.php +++ /dev/null | |||
| @@ -1,9 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | // src/sections/2_quotations.php | ||
| 3 | // | ||
| 4 | // -- SECTION 2: Devis -- | ||
| 5 | |||
| 6 | function quotation(): int // code de retour, si 2 aller à la section 2, etc | ||
| 7 | { | ||
| 8 | return(0); // menu principal | ||
| 9 | } | ||
diff --git a/src/sections/1_new_service.php b/src/sections/2_service.php index 6f5a72c..8109b31 100644 --- a/src/sections/1_new_service.php +++ b/src/sections/2_service.php | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/sections/1_new_service.php | 2 | // src/sections/2_service.php |
| 3 | // | 3 | // |
| 4 | // -- SECTION 1: Nouvelle prestation -- | 4 | // -- SECTION 2: Prestation et devis -- |
| 5 | 5 | ||
| 6 | function newService(): int // code de retour, si 0 retour menu principal, si 2 aller à la section 2, etc | 6 | function newService($Client): array // $Client est un Client ou null |
| 7 | { | 7 | { |
| 8 | // fenêtres | 8 | // fenêtres |
| 9 | $MenuEnregistrement = new ZenityList(ZenitySetup::$menu_enregistrement_text, ZenitySetup::$menu_enregistrement_entrees); | 9 | $MenuEnregistrement = new ZenityList(ZenitySetup::$menu_enregistrement_text, ZenitySetup::$menu_enregistrement_entrees); |
| @@ -14,14 +14,19 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
| 14 | $FormulaireLocation = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_location_entrees); | 14 | $FormulaireLocation = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_location_entrees); |
| 15 | $CommentairePrestation = new ZenityEntry(ZenitySetup::$commentaire_prestation_text); | 15 | $CommentairePrestation = new ZenityEntry(ZenitySetup::$commentaire_prestation_text); |
| 16 | $Recapitulatif = new ZenityList(ZenitySetup::$recapitulatif_text, ZenitySetup::$recapitulatif_entrees); // tableau à multiples colonnes | 16 | $Recapitulatif = new ZenityList(ZenitySetup::$recapitulatif_text, ZenitySetup::$recapitulatif_entrees); // tableau à multiples colonnes |
| 17 | $QuestionModifierPrestation = new ZenityQuestion(ZenitySetup::$question_modification_text); | 17 | //$QuestionModifierPrestation = new ZenityQuestion(ZenitySetup::$question_modification_text); |
| 18 | $FinSection2 = new ZenityList(ZenitySetup::$fin_section_2_text, ZenitySetup::$fin_section_2_entrees); | ||
| 18 | 19 | ||
| 19 | 20 | ||
| 20 | // -- partie 1: le client -- | 21 | // -- partie 1: le client -- |
| 21 | $Client = makeObjectCLient(); | 22 | if($Client == null || get_class($Client) !== 'Clients') |
| 22 | if($Client === 0) | ||
| 23 | { | 23 | { |
| 24 | return 0; // menu principal | 24 | $Client = makeObjectClient(); // retourne 0 ou un objet "Clients" |
| 25 | if($Client == 0) | ||
| 26 | { | ||
| 27 | echo "debug: annulation sélection client\n"; | ||
| 28 | return [0, null]; // menu principal | ||
| 29 | } | ||
| 25 | } | 30 | } |
| 26 | 31 | ||
| 27 | 32 | ||
| @@ -32,7 +37,7 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
| 32 | if($choix_niv2 === '') | 37 | if($choix_niv2 === '') |
| 33 | { | 38 | { |
| 34 | echo "debug: annulation menu enregistrement\n"; | 39 | echo "debug: annulation menu enregistrement\n"; |
| 35 | return 0; // menu principal | 40 | return [0, null]; // menu principal |
| 36 | } | 41 | } |
| 37 | 42 | ||
| 38 | $Presta = new Prestations($Client->getID()); | 43 | $Presta = new Prestations($Client->getID()); |
| @@ -43,7 +48,7 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
| 43 | if($Date->getDate() == '') // on n'a pas cliqué sur "annuler" | 48 | if($Date->getDate() == '') // on n'a pas cliqué sur "annuler" |
| 44 | { | 49 | { |
| 45 | echo "debug: annulation à la saisie d'une date\n"; | 50 | echo "debug: annulation à la saisie d'une date\n"; |
| 46 | return 0; // menu principal | 51 | return [0, null]; // menu principal |
| 47 | } | 52 | } |
| 48 | 53 | ||
| 49 | $Presta->setDate($Date->getTimestamp()); // un entier pour la BDD | 54 | $Presta->setDate($Date->getTimestamp()); // un entier pour la BDD |
| @@ -76,7 +81,7 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
| 76 | break; | 81 | break; |
| 77 | default: // inutile normallement, cas déjà géré avant | 82 | default: // inutile normallement, cas déjà géré avant |
| 78 | echo "debug: sortie du menu enregistrement incorrect\n"; | 83 | echo "debug: sortie du menu enregistrement incorrect\n"; |
| 79 | return 0; | 84 | return [0, null]; |
| 80 | } | 85 | } |
| 81 | 86 | ||
| 82 | $Presta->makeCodePresta($Date, $Client->getCodeClient()); // d'un objet à l'autre | 87 | $Presta->makeCodePresta($Date, $Client->getCodeClient()); // d'un objet à l'autre |
| @@ -86,12 +91,12 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
| 86 | if($input == '') // annulation | 91 | if($input == '') // annulation |
| 87 | { | 92 | { |
| 88 | echo "debug: annulation lors de l'enregistrement des détails de la prestation\n"; | 93 | echo "debug: annulation lors de l'enregistrement des détails de la prestation\n"; |
| 89 | return 0; | 94 | return [0, null]; |
| 90 | } | 95 | } |
| 91 | elseif(isset($PrestaDetails) && !$PrestaDetails->hydrateFromForm($input, $Presta)) // echec de l'hydratation | 96 | elseif(isset($PrestaDetails) && !$PrestaDetails->hydrateFromForm($input, $Presta)) // echec de l'hydratation |
| 92 | { | 97 | { |
| 93 | echo "debug: erreur de hydrateFromForm()\n"; // messages d'erreur à mettre ici ou dans hydrateFromForm()? | 98 | echo "debug: erreur de hydrateFromForm()\n"; // messages d'erreur à mettre ici ou dans hydrateFromForm()? |
| 94 | return 0; | 99 | return [0, null]; |
| 95 | } | 100 | } |
| 96 | unset($input); | 101 | unset($input); |
| 97 | } | 102 | } |
| @@ -127,6 +132,10 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
| 127 | $PrestaDetails->setID(); // sans paramètre, exécute un $this->db->lastInsertId() | 132 | $PrestaDetails->setID(); // sans paramètre, exécute un $this->db->lastInsertId() |
| 128 | } | 133 | } |
| 129 | 134 | ||
| 135 | // si encore de type prospect, devient un type client | ||
| 136 | //$Client->setType('client'); // inutile? | ||
| 137 | $Client->updateOneValue('type', 'client'); // modifier le type prospect en client | ||
| 138 | |||
| 130 | 139 | ||
| 131 | // -- partie 3: LaTeX -- | 140 | // -- partie 3: LaTeX -- |
| 132 | 141 | ||
| @@ -141,6 +150,9 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
| 141 | */ | 150 | */ |
| 142 | // et pour bien faire ajouter aussi une interface | 151 | // et pour bien faire ajouter aussi une interface |
| 143 | 152 | ||
| 153 | //~ function makeLatexSubClass(string $type) | ||
| 154 | //~ {} | ||
| 155 | |||
| 144 | // fabrique d'objets (sans connaître les noms des classes) | 156 | // fabrique d'objets (sans connaître les noms des classes) |
| 145 | $EnveloppeRecto = Latex::makeLatexSubClass('enveloppe_recto'); | 157 | $EnveloppeRecto = Latex::makeLatexSubClass('enveloppe_recto'); |
| 146 | $EnveloppeVerso = Latex::makeLatexSubClass('enveloppe_verso'); | 158 | $EnveloppeVerso = Latex::makeLatexSubClass('enveloppe_verso'); |
| @@ -148,39 +160,40 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
| 148 | 160 | ||
| 149 | // génération du latex | 161 | // génération du latex |
| 150 | $EnveloppeRecto->setData($Client); | 162 | $EnveloppeRecto->setData($Client); |
| 151 | $EnveloppeRecto->setFileName($Client->getCodeClient() . '.tex'); | 163 | //~ $EnveloppeRecto->setFileName($Client->getCodeClient() . '.tex'); |
| 152 | $EnveloppeRecto->setLatexPath(Config::$latex_path . 'enveloppes_recto/'); | 164 | //~ $EnveloppeRecto->setLatexPath(Config::$latex_path . 'enveloppes_recto/'); |
| 153 | $EnveloppeRecto->setPdfPath(Config::$pdf_path . 'enveloppes_recto/'); | 165 | //~ $EnveloppeRecto->setPdfPath(Config::$pdf_path . 'enveloppes_recto/'); |
| 154 | $EnveloppeRecto->spacesInPostCode(); | 166 | //~ $EnveloppeRecto->spacesInPostCode(); |
| 155 | $EnveloppeRecto->makeLatex(); | 167 | $EnveloppeRecto->makeLatex(); |
| 156 | 168 | ||
| 157 | $EnveloppeVerso->setFileName('enveloppe_verso.tex'); | 169 | //~ $EnveloppeVerso->setFileName('enveloppe_verso.tex'); |
| 158 | $EnveloppeVerso->setLatexPath(Config::$latex_path); | 170 | //~ $EnveloppeVerso->setLatexPath(Config::$latex_path); |
| 159 | $EnveloppeVerso->setPdfPath(Config::$pdf_path); | 171 | //~ $EnveloppeVerso->setPdfPath(Config::$pdf_path); |
| 160 | $EnveloppeVerso->makeLatex(); | 172 | $EnveloppeVerso->makeLatex(); |
| 161 | 173 | ||
| 162 | $DocumentPresta->setData($Client); | 174 | if($DocumentPresta !== null) |
| 163 | $DocumentPresta->setData($Presta); | 175 | { |
| 164 | $DocumentPresta->setData($PrestaDetails); | 176 | $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); |
| 165 | $DocumentPresta->makeDateInstance($Presta->getDate()); // paramètre = int | 177 | //~ $DocumentPresta->setData($Client); |
| 166 | $DocumentPresta->setFileName($Presta->getCodePresta() . '.tex'); | 178 | //~ $DocumentPresta->setData($Presta); |
| 167 | $DocumentPresta->setLatexPath(Config::$latex_path . $DocumentPresta->getYear() . '/'); | 179 | //~ $DocumentPresta->makeDateInstance($Presta->getDate()); // paramètre = int |
| 168 | $DocumentPresta->setPdfPath(Config::$pdf_path . $DocumentPresta->getYear() . '/'); | 180 | //~ $DocumentPresta->setFileName($Presta->getCodePresta() . '.tex'); |
| 169 | $DocumentPresta->makeLatex(); | 181 | //~ $DocumentPresta->setLatexPath(Config::$latex_path . $DocumentPresta->getYear() . '/'); |
| 182 | //~ $DocumentPresta->setPdfPath(Config::$pdf_path . $DocumentPresta->getYear() . '/'); | ||
| 183 | //~ $DocumentPresta->setData($PrestaDetails); | ||
| 184 | $DocumentPresta->makeLatex(); | ||
| 185 | } | ||
| 170 | 186 | ||
| 171 | // création des fichiers | ||
| 172 | makeFolder($EnveloppeRecto->getLatexPath()); | ||
| 173 | makeFolder($EnveloppeRecto->getPdfPath()); | ||
| 174 | makeFile($EnveloppeRecto->getLatexPath(), $EnveloppeRecto->getFileName(), $EnveloppeRecto->getLatex()); | ||
| 175 | latexToPdf($EnveloppeRecto->getLatexPath(), $EnveloppeRecto->getFileName(), $EnveloppeRecto->getPdfPath()); | ||
| 176 | 187 | ||
| 177 | makeFile($EnveloppeVerso->getLatexPath(), $EnveloppeVerso->getFileName(), $EnveloppeVerso->getLatex()); | 188 | // création des fichiers |
| 178 | latexToPdf($EnveloppeVerso->getLatexPath(), $EnveloppeVerso->getFileName(), $EnveloppeVerso->getPdfPath()); | 189 | // paramètre = Objet enfant de Latex |
| 190 | makeTexAndPdf($EnveloppeRecto); | ||
| 191 | makeTexAndPdf($EnveloppeVerso); | ||
| 179 | 192 | ||
| 180 | makeFolder($DocumentPresta->getLatexPath()); | 193 | if($DocumentPresta !== null) |
| 181 | makeFolder($DocumentPresta->getPdfPath()); | 194 | { |
| 182 | makeFile($DocumentPresta->getLatexPath(), $DocumentPresta->getFileName(), $DocumentPresta->getLatex()); | 195 | makeTexAndPdf($DocumentPresta); |
| 183 | latexToPdf($DocumentPresta->getLatexPath(), $DocumentPresta->getFileName(), $DocumentPresta->getPdfPath()); | 196 | } |
| 184 | 197 | ||
| 185 | 198 | ||
| 186 | // -- partie 4: récapitulatif -- | 199 | // -- partie 4: récapitulatif -- |
| @@ -194,16 +207,23 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
| 194 | 207 | ||
| 195 | 208 | ||
| 196 | // -- partie 5: on fait quoi maintenant -- | 209 | // -- partie 5: on fait quoi maintenant -- |
| 210 | $choix_niv2 = exec($FinSection2->get()); | ||
| 211 | if($choix_niv2 === ZenitySetup::$fin_section_2_entrees[0]) | ||
| 212 | { | ||
| 213 | return [4, null]; // section 4: getDocument() | ||
| 214 | } | ||
| 215 | elseif($choix_niv2 === ZenitySetup::$fin_section_2_entrees[1]) | ||
| 216 | { | ||
| 217 | return [3, null]; // section 3: modifyData() | ||
| 218 | } | ||
| 219 | elseif($choix_niv2 === ZenitySetup::$fin_section_2_entrees[2]) | ||
| 220 | { | ||
| 221 | return [2, null]; // relancer section 2: newService() | ||
| 222 | } | ||
| 223 | else | ||
| 224 | { | ||
| 225 | return [0, null]; // menu principal | ||
| 226 | } | ||
| 197 | 227 | ||
| 198 | // possibilité de modification | 228 | return [0, null]; // menu principal |
| 199 | // zenityQuestion | ||
| 200 | //~ if(exec($QuestionModifierPrestation->get()) == '0') | ||
| 201 | //~ { | ||
| 202 | //~ return 3; // section "Modifier un enregistrement" | ||
| 203 | //~ } | ||
| 204 | //~ else | ||
| 205 | //~ { | ||
| 206 | //~ return 0; // menu principal | ||
| 207 | //~ } | ||
| 208 | return 0; // menu principal | ||
| 209 | } | 229 | } |
diff --git a/src/sections/3_modify_data.php b/src/sections/3_modify_data.php new file mode 100644 index 0000000..cc95468 --- /dev/null +++ b/src/sections/3_modify_data.php | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | <?php | ||
| 2 | // src/sections/3_modify_data.php | ||
| 3 | // | ||
| 4 | // -- SECTION 3: Modifier un client, un prospect, une prestation, un devis -- | ||
| 5 | |||
| 6 | function modifyData($Objet): array | ||
| 7 | { | ||
| 8 | return [0, null]; // menu principal | ||
| 9 | } | ||
diff --git a/src/sections/3_modify_service.php b/src/sections/3_modify_service.php deleted file mode 100644 index 3147969..0000000 --- a/src/sections/3_modify_service.php +++ /dev/null | |||
| @@ -1,9 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | // src/sections/3_modify_service.php | ||
| 3 | // | ||
| 4 | // -- SECTION 3: Modifier une prestation -- | ||
| 5 | |||
| 6 | function modifyService(): int // code de retour, si 2 aller à la section 2, etc | ||
| 7 | { | ||
| 8 | return(0); // menu principal | ||
| 9 | } | ||
diff --git a/src/sections/4_get_document.php b/src/sections/4_get_document.php new file mode 100644 index 0000000..e28e526 --- /dev/null +++ b/src/sections/4_get_document.php | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | <?php | ||
| 2 | // src/sections/4_get_document.php | ||
| 3 | // | ||
| 4 | // -- SECTION 4: Afficher, imprimer un document -- | ||
| 5 | |||
| 6 | function getDocument($Objet): array | ||
| 7 | { | ||
| 8 | $MenuDocuments = new ZenityList(ZenitySetup::$menu_documents_text, ZenitySetup::$menu_documents_entrees); | ||
| 9 | |||
| 10 | // -- partie 1: type de document -- | ||
| 11 | |||
| 12 | $choix_niv2 = exec($MenuDocuments->get()); | ||
| 13 | if($choix_niv2 === ZenitySetup::$menu_documents_entrees[0]) | ||
| 14 | { | ||
| 15 | |||
| 16 | } | ||
| 17 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[1]) // = Facture | ||
| 18 | { | ||
| 19 | |||
| 20 | } | ||
| 21 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[2]) // = Lettre avec adresse | ||
| 22 | { | ||
| 23 | |||
| 24 | } | ||
| 25 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[3]) // = Livre des recettes | ||
| 26 | { | ||
| 27 | |||
| 28 | } | ||
| 29 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[4]) // = Registre des achats | ||
| 30 | { | ||
| 31 | |||
| 32 | } | ||
| 33 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[5]) // = Bilan annuel | ||
| 34 | { | ||
| 35 | |||
| 36 | } | ||
| 37 | else | ||
| 38 | { | ||
| 39 | return [0, null]; // menu principal | ||
| 40 | } | ||
| 41 | |||
| 42 | |||
| 43 | // -- partie 2: régénérer les documents latex et pdf -- | ||
| 44 | |||
| 45 | |||
| 46 | // -- partie 3: afficher -- | ||
| 47 | |||
| 48 | |||
| 49 | // -- partie 4: imprimer -- | ||
| 50 | |||
| 51 | |||
| 52 | // -- partie 5: on fait quoi maintenant -- | ||
| 53 | |||
| 54 | return [0, null]; // menu principal | ||
| 55 | } | ||
diff --git a/src/sections/main_loop.php b/src/sections/main_loop.php new file mode 100644 index 0000000..7dd1af0 --- /dev/null +++ b/src/sections/main_loop.php | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | <?php | ||
| 2 | // src/sections/main_loop.php | ||
| 3 | // | ||
| 4 | // -- BOUCLE PRINCIPALE -- | ||
| 5 | |||
| 6 | require('sections/1_customer.php'); | ||
| 7 | require('sections/2_service.php'); | ||
| 8 | require('sections/3_modify_data.php'); | ||
| 9 | |||
| 10 | $main_loop = true; | ||
| 11 | $returned = [0, null]; // [code de retour, éventuelles données] | ||
| 12 | |||
| 13 | while($main_loop) | ||
| 14 | { | ||
| 15 | // -- MENU PRINCIPAL (niveau 1) -- | ||
| 16 | if($returned[0] === 0) | ||
| 17 | { | ||
| 18 | echo("Menu principal\n"); | ||
| 19 | $MenuPrincipal = new ZenityList(ZenitySetup::$menu_principal_text, ZenitySetup::$menu_principal_entrees); | ||
| 20 | $choix_niv1 = exec($MenuPrincipal->get()); | ||
| 21 | } | ||
| 22 | else | ||
| 23 | { | ||
| 24 | $choix_niv1 = ''; | ||
| 25 | } | ||
| 26 | |||
| 27 | |||
| 28 | // -- SECTION 1: Clients et prospects -- | ||
| 29 | if($choix_niv1 === ZenitySetup::$menu_principal_entrees[0] || $returned[0] === 1) | ||
| 30 | { | ||
| 31 | echo("choix: ". ZenitySetup::$menu_principal_entrees[0] . "\n"); | ||
| 32 | $returned = newCustomer(); | ||
| 33 | } | ||
| 34 | |||
| 35 | // -- SECTION 2: Prestations et devis -- | ||
| 36 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[1] || $returned[0] === 2) | ||
| 37 | { | ||
| 38 | echo("choix: ". ZenitySetup::$menu_principal_entrees[1] . "\n"); | ||
| 39 | $returned = newService($returned[1]); // $returned[1] vaut un type Clients ou null | ||
| 40 | } | ||
| 41 | |||
| 42 | // -- SECTION 3: Modifier un enregistrement -- | ||
| 43 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[2] || $returned[0] === 3) | ||
| 44 | { | ||
| 45 | echo("choix: " . ZenitySetup::$menu_principal_entrees[2] . "\n"); | ||
| 46 | $returned = modifyData(); | ||
| 47 | } | ||
| 48 | |||
| 49 | // -- SECTION 4: Consulter, Imprimer un document -- | ||
| 50 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[3] || $returned[0] === 4) // = Imprimer un document | ||
| 51 | { | ||
| 52 | echo("choix: ". ZenitySetup::$menu_principal_entrees[3] . "\n"); | ||
| 53 | $returned = getDocument(); | ||
| 54 | } | ||
| 55 | |||
| 56 | // -- SECTION 5: Consulter/analyser les données -- | ||
| 57 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[4] || $returned[0] === 5) | ||
| 58 | { | ||
| 59 | echo("choix: ". ZenitySetup::$menu_principal_entrees[4] . "\n"); | ||
| 60 | // quel affichage? des tableaux avec zenity? LaTeX? une page web? un autre outil servant à faire des tableaux et graphiques | ||
| 61 | } | ||
| 62 | |||
| 63 | // -- SECTION 6: Supports de communication -- | ||
| 64 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[5] || $returned[0] === 6) // = Communication | ||
| 65 | { | ||
| 66 | echo("choix: ". ZenitySetup::$menu_principal_entrees[5] . "\n"); | ||
| 67 | $MenuCommunication = new ZenityList(ZenitySetup::$menu_communication_text, ZenitySetup::$menu_communication_entrees); | ||
| 68 | $choix_niv2 = exec($MenuCommunication->get()); | ||
| 69 | if($choix_niv2 === ZenitySetup::$menu_communication_entrees[0]) // = Flyer (nécessite gimp) | ||
| 70 | { | ||
| 71 | exec(windowAppCommand($image_editor, $flyer)); | ||
| 72 | } | ||
| 73 | elseif($choix_niv2 === ZenitySetup::$menu_communication_entrees[1]) // = Carte de visite (nécessite scribus) | ||
| 74 | { | ||
| 75 | exec(windowAppCommand($publishing, $business_card)); | ||
| 76 | } | ||
| 77 | elseif($choix_niv2 === ZenitySetup::$menu_communication_entrees[2]) // = Explorateur de fichiers | ||
| 78 | { | ||
| 79 | exec(windowAppCommand($file_explorer, $pub)); | ||
| 80 | } | ||
| 81 | else | ||
| 82 | { | ||
| 83 | // retour menu principal | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | // -- SECTION 7: BDD -- | ||
| 88 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[6] || $returned[0] === 7) // = Base de données | ||
| 89 | { | ||
| 90 | echo("choix: ". ZenitySetup::$menu_principal_entrees[6] . "\n"); | ||
| 91 | if($sqlitebrowser_enable) | ||
| 92 | { | ||
| 93 | exec(windowAppCommand(Config::$sqlite_gui, Config::$db_path)); | ||
| 94 | } | ||
| 95 | else | ||
| 96 | { | ||
| 97 | exec($x_term_command . ' ' . $sqlite_cli . ' ' . Config::$db_path); // correpond à priori à: xterm -e sqlite3 ~/ORDIPOLO/Appli_PHP/ordipolo.sqlite | ||
| 98 | } | ||
| 99 | } | ||
| 100 | |||
| 101 | // arrêt | ||
| 102 | else | ||
| 103 | { | ||
| 104 | $main_loop = false; | ||
| 105 | } | ||
| 106 | } | ||
diff --git a/src/view/ZenitySetup.php b/src/view/ZenitySetup.php index b6d83f6..d0b785c 100644 --- a/src/view/ZenitySetup.php +++ b/src/view/ZenitySetup.php | |||
| @@ -8,12 +8,14 @@ | |||
| 8 | class ZenitySetup | 8 | class ZenitySetup |
| 9 | { | 9 | { |
| 10 | static public $menu_principal_text = "Gestion d'une micro-entreprise"; | 10 | static public $menu_principal_text = "Gestion d'une micro-entreprise"; |
| 11 | static public $menu_principal_entrees = ["Nouvelle prestation", "Devis", "Modifier un enregistrement", "Consulter/analyser les données", "Imprimer un document", "Communication", "Base de données"]; | 11 | static public $menu_principal_entrees = ["Clients et prospects", "Prestations et devis", "Modifier un enregistrement", "Consulter, imprimer un document", "Consulter/analyser les données", "Communication", "Base de données"]; |
| 12 | static public $question_nouveau_client_text = "Ce client figure t\'il déjà dans le fichier clients?"; | 12 | //~ static public $question_nouveau_client_text = "Ce client figure t\'il déjà dans le fichier clients?"; |
| 13 | static public $type_client_text = "Client ou prospect?"; | ||
| 14 | static public $type_client_entrees = ["Client", "Prospect"]; | ||
| 13 | static public $menu_enregistrement_text = "Type d\'enregistrement?"; | 15 | static public $menu_enregistrement_text = "Type d\'enregistrement?"; |
| 14 | //static public $menu_enregistrement_entrees = ["Devis", "Facture", "CESU", "Location", "Prestation non vendue"]; | 16 | //static public $menu_enregistrement_entrees = ["Devis", "Facture", "CESU", "Location", "Prestation non vendue"]; |
| 15 | static public $menu_enregistrement_entrees = ["Facture", "CESU", "Location", "Prestation non vendue"]; | 17 | static public $menu_enregistrement_entrees = ["Facture", "CESU", "Location", "Prestation non vendue"]; |
| 16 | static public $menu_documents_text = "Imprimer un document LaTeX"; | 18 | static public $menu_documents_text = "Consulter, imprimer un document LaTeX"; |
| 17 | static public $menu_documents_entrees = ["Devis", "Facture", "Lettre avec adresse", "Livre des recettes", "Registre des achats", "Bilan annuel"]; | 19 | static public $menu_documents_entrees = ["Devis", "Facture", "Lettre avec adresse", "Livre des recettes", "Registre des achats", "Bilan annuel"]; |
| 18 | static public $menu_communication_text = "Imprimer un support de communication"; | 20 | static public $menu_communication_text = "Imprimer un support de communication"; |
| 19 | static public $menu_communication_entrees = ["Flyer (nécessite gimp)", "Carte de visite (nécessite scribus)", "Explorateur de fichiers"]; | 21 | static public $menu_communication_entrees = ["Flyer (nécessite gimp)", "Carte de visite (nécessite scribus)", "Explorateur de fichiers"]; |
| @@ -30,5 +32,10 @@ class ZenitySetup | |||
| 30 | static public $commentaire_prestation_text = 'Nouvelle prestation 3/3 - Commentaires'; | 32 | static public $commentaire_prestation_text = 'Nouvelle prestation 3/3 - Commentaires'; |
| 31 | static public $recapitulatif_text = "voici toutes les informations enregistrées"; | 33 | static public $recapitulatif_text = "voici toutes les informations enregistrées"; |
| 32 | static public $recapitulatif_entrees = []; | 34 | static public $recapitulatif_entrees = []; |
| 33 | static public $question_modification_text = "Prestation enregistrée. Modifier les informations?"; | 35 | //static public $question_modification_text = "Prestation enregistrée. Modifier les informations?"; |
| 36 | |||
| 37 | static public $fin_section_1_text = "Client enregistré"; | ||
| 38 | static public $fin_section_1_entrees = ["Ajouter une prestation pour ce client", "Modifier les informations", "Enregistrer un autre client", "Menu principal"]; | ||
| 39 | static public $fin_section_2_text = "Prestation/devis enregistré(e)"; | ||
| 40 | static public $fin_section_2_entrees = ["Afficher le document", "Modifier les informations", "Enregistrer une autre prestation/devis", "Menu principal"]; | ||
| 34 | } | 41 | } |
