diff options
| -rw-r--r-- | config.ini | 65 | ||||
| -rw-r--r-- | config.php | 81 | ||||
| -rw-r--r-- | data/ordipolo.sqlite | bin | 32768 -> 32768 bytes | |||
| -rw-r--r-- | data/originaux pas toucher/devis.tex (renamed from data/originaux_latex/devis.tex) | 0 | ||||
| -rw-r--r-- | data/originaux pas toucher/enveloppe_recto.tex (renamed from data/originaux_latex/enveloppe_recto.tex) | 0 | ||||
| -rw-r--r-- | data/originaux pas toucher/enveloppe_verso.tex (renamed from data/originaux_latex/enveloppe_verso.tex) | 0 | ||||
| -rw-r--r-- | data/originaux pas toucher/facture.tex (renamed from data/originaux_latex/facture.tex) | 0 | ||||
| -rw-r--r-- | data/originaux pas toucher/location.tex (renamed from data/originaux_latex/location.tex) | 0 | ||||
| -rw-r--r-- | data/templates/devis.php (renamed from src/latex_templates/devis.php) | 0 | ||||
| -rw-r--r-- | data/templates/enveloppe_recto.php (renamed from src/latex_templates/enveloppe_recto.php) | 0 | ||||
| -rw-r--r-- | data/templates/enveloppe_verso.php (renamed from src/latex_templates/enveloppe_verso.php) | 0 | ||||
| -rw-r--r-- | data/templates/facture.php (renamed from src/latex_templates/facture.php) | 0 | ||||
| -rw-r--r-- | data/templates/location.php (renamed from src/latex_templates/location.php) | 0 | ||||
| -rw-r--r-- | src/Config.php | 131 | ||||
| -rw-r--r-- | src/functions.php | 19 | ||||
| -rwxr-xr-x | src/main.php | 23 | ||||
| -rw-r--r-- | src/sections/1_new_service.php | 53 |
17 files changed, 271 insertions, 101 deletions
diff --git a/config.ini b/config.ini new file mode 100644 index 0000000..89c6118 --- /dev/null +++ b/config.ini | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | ; fichier à modifier soi-même | ||
| 2 | ; les lignes commentées correspondent aux réglages par défaut | ||
| 3 | ; ils seront utilisés si une information manque ou est mal renseignée ici | ||
| 4 | |||
| 5 | ; ATTENTION aux chemins relatifs! | ||
| 6 | ; ils sont relatifs par rapport au dossier 'src' où s'exécute le programme | ||
| 7 | |||
| 8 | business_name = ORDIPOLO | ||
| 9 | |||
| 10 | db_name = ordipolo | ||
| 11 | |||
| 12 | ; défaut = racine de l'appli = dossier parent de celui du code source | ||
| 13 | db_path = '../data/' | ||
| 14 | |||
| 15 | ; le dossier latex par défaut est celui "inclu" dans ce programme | ||
| 16 | latex_path = '../data/latex/' | ||
| 17 | pdf_path = '../data/pdf/' | ||
| 18 | |||
| 19 | ;receipts_latex = '../data/latex/' | ||
| 20 | ;receipts_pdf = '../data/pdf/' | ||
| 21 | |||
| 22 | ;quotations_latex = '../data/latex/' | ||
| 23 | ;quotations_pdf = '../data/pdf/' | ||
| 24 | |||
| 25 | ;envelopes_latex = '../data/latex/' | ||
| 26 | ;envelopes_pdf = '../data/pdf/' | ||
| 27 | |||
| 28 | ;rental_latex = '../data/latex/' | ||
| 29 | ;rental_pdf = '../data/pdf/' | ||
| 30 | |||
| 31 | ;pub = '../pub/' | ||
| 32 | pub_path = '../pub/' ;dossier pub inclu dans l'appli | ||
| 33 | |||
| 34 | ;flyer = flyer.xcf | ||
| 35 | flyer = flyer.xcf | ||
| 36 | |||
| 37 | ;business_card = carte.sla | ||
| 38 | business_card = carte.sla | ||
| 39 | |||
| 40 | ;image_editor = gimp | ||
| 41 | image_editor = gimp | ||
| 42 | |||
| 43 | ;publishing = scribus | ||
| 44 | publishing = scribus | ||
| 45 | |||
| 46 | ;sqliteGUI = sqlitebrowser | ||
| 47 | sqlite_gui = sqlitebrowser | ||
| 48 | |||
| 49 | ; format des dates, choisir 'euro' exemple 28-11-2022 OU 'usa' exemple 11/28/2022 | ||
| 50 | ;date_format = 'euro' | ||
| 51 | date_format = 'euro' | ||
| 52 | |||
| 53 | |||
| 54 | ;x_terminal = xterm | ||
| 55 | ; -- état actuel du programme -- | ||
| 56 | ; les terminaux gérés sont: xterm, urxvt, lxterminal, xfce4-terminal, gnome-terminal, konsole, Terminal (MAC, désactivé tant que non testé) | ||
| 57 | ; ajouter à l'accaz: i3-sensible-terminal (pour i3), lxterminal-qt (pour lubuntu) | ||
| 58 | ; 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 | ||
| 59 | |||
| 60 | |||
| 61 | sgbd = 'sqlite' | ||
| 62 | ;dsn = ''; | ||
| 63 | |||
| 64 | ;sqliteBin = '../lib/sqlite_linux' | ||
| 65 | ;sqliteBin = '../lib/sqlite_win.exe' | ||
diff --git a/config.php b/config.php deleted file mode 100644 index c51e793..0000000 --- a/config.php +++ /dev/null | |||
| @@ -1,81 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | // config.php | ||
| 3 | |||
| 4 | // fichier à modifier soi-même | ||
| 5 | // les lignes commentées correspondent aux réglages par défaut | ||
| 6 | |||
| 7 | $business_name = 'ORDIPOLO'; | ||
| 8 | |||
| 9 | // $db_name = "ordipolo"; | ||
| 10 | $db_name = "ordipolo"; | ||
| 11 | |||
| 12 | // défaut = racine de l'appli = dossier parent de celui du code source | ||
| 13 | // $db_place = '../data/'; | ||
| 14 | $db_place = '../data/'; | ||
| 15 | |||
| 16 | |||
| 17 | // le dossier latex par défaut est celui "inclu" dans ce programme | ||
| 18 | // $receipts_latex = '../data/latex/'; | ||
| 19 | $receipts_latex = '../data/latex/'; | ||
| 20 | // $receipts_pdf = '../data/pdf/'; | ||
| 21 | $receipts_pdf = '../data/pdf/'; | ||
| 22 | |||
| 23 | // $quotations_latex = '../data/latex/'; | ||
| 24 | $quotations_latex = '../data/latex/'; | ||
| 25 | // $quotations_pdf = '../data/pdf/'; | ||
| 26 | $quotations_pdf = '../data/pdf/'; | ||
| 27 | |||
| 28 | // $envelopes_latex = '../data/latex/'; | ||
| 29 | $envelopes_latex = '../data/latex/'; | ||
| 30 | // $envelopes_pdf = '../data/pdf/'; | ||
| 31 | $envelopes_pdf = '../data/pdf/'; | ||
| 32 | |||
| 33 | // $rental_latex = '../data/latex/'; | ||
| 34 | $rental_latex = '../data/latex/'; | ||
| 35 | // $rental_pdf = '../data/pdf/'; | ||
| 36 | $rental_pdf = '../data/pdf/'; | ||
| 37 | |||
| 38 | |||
| 39 | // $pub = "~/ORDIPOLO/PUB/"; // dossier extérieur au choix | ||
| 40 | // $pub = "../pub/"; | ||
| 41 | $pub = "../pub/"; // dossier pub inclu dans l'appli | ||
| 42 | |||
| 43 | // $flyer = "flyer.xcf"; | ||
| 44 | $flyer = "flyer.xcf"; | ||
| 45 | |||
| 46 | // $business_card = "carte.sla"; | ||
| 47 | $business_card = "carte.sla"; | ||
| 48 | |||
| 49 | // $image_editor = 'gimp'; | ||
| 50 | $image_editor = 'gimp'; | ||
| 51 | |||
| 52 | // $publishing = 'scribus'; | ||
| 53 | $publishing = 'scribus'; | ||
| 54 | |||
| 55 | // $sqliteGUI = 'sqlitebrowser'; | ||
| 56 | $sqlite_gui = 'sqlitebrowser'; | ||
| 57 | |||
| 58 | // format des dates: 'euro' exemple 28-11-2022, 'usa' exemple 11/28/2022 | ||
| 59 | // $date_format = 'euro'; | ||
| 60 | $date_format = 'euro'; | ||
| 61 | |||
| 62 | |||
| 63 | // $x_terminal = 'xterm'; | ||
| 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é) | ||
| 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 | ||
| 68 | |||
| 69 | |||
| 70 | //~ $SGBD = 'sqlite'; | ||
| 71 | //~ $dsn = ''; | ||
| 72 | //~ if($SGBD == 'sqlite') | ||
| 73 | //~ { | ||
| 74 | //~ $dsn = 'sqlite:' . $db_name . '.sqlite'; | ||
| 75 | //~ } | ||
| 76 | //~ // pour la portabilité, ce serait pas mal de fournir le binaire de sqlite (dossier lib) | ||
| 77 | //~ $sqliteBin = '../lib/sqlite_linux'; | ||
| 78 | //~ $sqliteBin = '../lib/sqlite_win.exe'; | ||
| 79 | |||
| 80 | |||
| 81 | // vérification des variables dans ../php/config_check.php | ||
diff --git a/data/ordipolo.sqlite b/data/ordipolo.sqlite index 094294b..29474b5 100644 --- a/data/ordipolo.sqlite +++ b/data/ordipolo.sqlite | |||
| Binary files differ | |||
diff --git a/data/originaux_latex/devis.tex b/data/originaux pas toucher/devis.tex index c5ae6e8..c5ae6e8 100644 --- a/data/originaux_latex/devis.tex +++ b/data/originaux pas toucher/devis.tex | |||
diff --git a/data/originaux_latex/enveloppe_recto.tex b/data/originaux pas toucher/enveloppe_recto.tex index eab03f8..eab03f8 100644 --- a/data/originaux_latex/enveloppe_recto.tex +++ b/data/originaux pas toucher/enveloppe_recto.tex | |||
diff --git a/data/originaux_latex/enveloppe_verso.tex b/data/originaux pas toucher/enveloppe_verso.tex index 24baa8a..24baa8a 100644 --- a/data/originaux_latex/enveloppe_verso.tex +++ b/data/originaux pas toucher/enveloppe_verso.tex | |||
diff --git a/data/originaux_latex/facture.tex b/data/originaux pas toucher/facture.tex index 5c849f5..5c849f5 100644 --- a/data/originaux_latex/facture.tex +++ b/data/originaux pas toucher/facture.tex | |||
diff --git a/data/originaux_latex/location.tex b/data/originaux pas toucher/location.tex index 0d525fe..0d525fe 100644 --- a/data/originaux_latex/location.tex +++ b/data/originaux pas toucher/location.tex | |||
diff --git a/src/latex_templates/devis.php b/data/templates/devis.php index 8f5e640..8f5e640 100644 --- a/src/latex_templates/devis.php +++ b/data/templates/devis.php | |||
diff --git a/src/latex_templates/enveloppe_recto.php b/data/templates/enveloppe_recto.php index 99d65a1..99d65a1 100644 --- a/src/latex_templates/enveloppe_recto.php +++ b/data/templates/enveloppe_recto.php | |||
diff --git a/src/latex_templates/enveloppe_verso.php b/data/templates/enveloppe_verso.php index ae2e716..ae2e716 100644 --- a/src/latex_templates/enveloppe_verso.php +++ b/data/templates/enveloppe_verso.php | |||
diff --git a/src/latex_templates/facture.php b/data/templates/facture.php index 5d62b91..5d62b91 100644 --- a/src/latex_templates/facture.php +++ b/data/templates/facture.php | |||
diff --git a/src/latex_templates/location.php b/data/templates/location.php index dbffd0e..dbffd0e 100644 --- a/src/latex_templates/location.php +++ b/data/templates/location.php | |||
diff --git a/src/Config.php b/src/Config.php new file mode 100644 index 0000000..396b588 --- /dev/null +++ b/src/Config.php | |||
| @@ -0,0 +1,131 @@ | |||
| 1 | <?php | ||
| 2 | // src/Config.php | ||
| 3 | |||
| 4 | class Config | ||
| 5 | { | ||
| 6 | // valeurs par défaut au cas où | ||
| 7 | static public $business_name = 'ORDIPOLO'; | ||
| 8 | static public $db_name = "ordipolo"; | ||
| 9 | static public $db_path = '../data/'; | ||
| 10 | static public $latex_path = '../data/latex/'; | ||
| 11 | static public $pdf_path = '../data/pdf/'; | ||
| 12 | static public $pub_path = "../pub/"; | ||
| 13 | static public $flyer = "flyer.xcf"; | ||
| 14 | static public $business_card = "carte.sla"; | ||
| 15 | static public $image_editor = 'gimp'; | ||
| 16 | static public $publishing = 'scribus'; | ||
| 17 | static public $sgbd = 'sqlite'; | ||
| 18 | static public $sqlite_gui = 'sqlitebrowser'; // ne pas utiliser si le sgbd n'est pas sqlite | ||
| 19 | static public $date_format = 'euro'; | ||
| 20 | |||
| 21 | // pour que Config crée le dsn: Data Source Name (à mettre dans une autre classe!) | ||
| 22 | //~ static public $dsn = ''; | ||
| 23 | |||
| 24 | // ça pourrait être bien de founir sqlite avec l'application pour supprimer une dépendance | ||
| 25 | //~ static public $sqliteBin = '../lib/sqlite_linux'; | ||
| 26 | //~ static public $sqliteBin = '../lib/sqlite_win.exe'; | ||
| 27 | |||
| 28 | static private $raw_data; | ||
| 29 | |||
| 30 | static public function readFile($file_path) | ||
| 31 | { | ||
| 32 | self::$raw_data = parse_ini_file($file_path); | ||
| 33 | } | ||
| 34 | |||
| 35 | static private function fieldIsPath($field): bool | ||
| 36 | { | ||
| 37 | if($field === 'db_path' || $field === 'latex_path' || $field === 'pdf_path' || $field === 'pub_path') | ||
| 38 | { | ||
| 39 | return true; | ||
| 40 | } | ||
| 41 | else | ||
| 42 | { | ||
| 43 | return false; | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | static private function checkPath($field, $value): bool | ||
| 48 | { | ||
| 49 | if(!file_exists($value)) | ||
| 50 | { | ||
| 51 | echo "debug: le fichier config.ini comporte une erreur, le dossier " . $value . " renseigné pour le champ " . $field . " n'existe pas,\nla valeur par défaut: " . self::$$field . " sera utilisé\n"; | ||
| 52 | return false; | ||
| 53 | } | ||
| 54 | if(!is_writable($value)) | ||
| 55 | { | ||
| 56 | if($value == self::$$field) | ||
| 57 | { | ||
| 58 | echo "debug: le dossier " . $value . " n'est pas autorisé en écriture\n"; | ||
| 59 | } | ||
| 60 | else | ||
| 61 | { | ||
| 62 | echo "debug: le dossier " . $value . " renseigné pour le champ " . $field . " dans le fichier config.ini n'est pas autorisé en écriture,\nla valeur par défaut: " . self::$$field . " sera utilisée\n"; | ||
| 63 | } | ||
| 64 | return false; | ||
| 65 | } | ||
| 66 | return true; | ||
| 67 | } | ||
| 68 | |||
| 69 | static public function slashAtEndOfPath($path): string | ||
| 70 | { | ||
| 71 | if(!str_ends_with($path, '/')) | ||
| 72 | { | ||
| 73 | return($path . '/'); | ||
| 74 | } | ||
| 75 | else | ||
| 76 | { | ||
| 77 | return $path; | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | static public function hydrate() | ||
| 82 | { | ||
| 83 | foreach(self::$raw_data as $field => $value) | ||
| 84 | { | ||
| 85 | if(isset(self::$$field)) // vérification du nom du champ | ||
| 86 | { | ||
| 87 | // vérification du contenu | ||
| 88 | if(self::fieldIsPath($field)) // cas où le champ db_path, latex_path, pdf_path ou pub_path | ||
| 89 | { | ||
| 90 | if(self::checkPath($field, $value)) | ||
| 91 | { | ||
| 92 | $value = self::slashAtEndOfPath($value); | ||
| 93 | self::$$field = $value; | ||
| 94 | } | ||
| 95 | } | ||
| 96 | else // tester le reste? | ||
| 97 | { | ||
| 98 | self::$$field = $value; | ||
| 99 | } | ||
| 100 | // else: la valeur par défaut est conservée | ||
| 101 | } | ||
| 102 | else | ||
| 103 | { | ||
| 104 | echo "debug: le fichier config.ini comporte une erreur, le champ: " . $field . " est incorrect,\nl'information contenue sur cette ligne ne sera pas utilisée\n"; | ||
| 105 | } | ||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 | // à faire plus tard | ||
| 110 | // transformer les chemins pour qu'ils soient relatif au dossier 'src' où s'exécute le programme | ||
| 111 | static private function adjustRelativePath($input) | ||
| 112 | { | ||
| 113 | // chemin windows? | ||
| 114 | |||
| 115 | // chemin relatif ou absolu (par le 1er caractère) | ||
| 116 | |||
| 117 | // obtenir l'emplacement du dossier de l'utilisateur '~' | ||
| 118 | $userHomePlace = exec(''); | ||
| 119 | |||
| 120 | // obtenir l'emplacement du dossier 'src' | ||
| 121 | $appExecPlace = getcwd(); | ||
| 122 | } | ||
| 123 | |||
| 124 | //~ static public function makeDsn() | ||
| 125 | //~ { | ||
| 126 | //~ if($this->sgbd === 'sqlite') | ||
| 127 | //~ { | ||
| 128 | //~ $this->dsn = 'sqlite:' . $this->db_name . '.sqlite'; | ||
| 129 | //~ } | ||
| 130 | //~ } | ||
| 131 | } | ||
diff --git a/src/functions.php b/src/functions.php index 0ec280f..b8779e8 100644 --- a/src/functions.php +++ b/src/functions.php | |||
| @@ -35,7 +35,24 @@ function rechercheClient(string $input, Clients $Client): array | |||
| 35 | return($result); | 35 | return($result); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | function getLatexFromTemplate(string $template) | 38 | function makeFolder(string $path) |
| 39 | { | ||
| 40 | if(!file_exists($path)) | ||
| 41 | { | ||
| 42 | mkdir($path); | ||
| 43 | chmod($path, 0755); | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | function makeLatexAndPdfDocument($file_name, $template, Clients $Client, Prestations $Presta = null, $Details = null) // $Details peut être de type DevisFactures ou Locations | ||
| 48 | { | ||
| 49 | //~ $data = ; // tableau associatif avec des données des différents objets | ||
| 50 | $latex = getLatexFromTemplate($template, $data); | ||
| 51 | file_put_contents($latex_path . $file_name, $latex); // injection des variables & écriture du fichier | ||
| 52 | latexToPdf($latex_path, $file_name, $pdf_path); | ||
| 53 | } | ||
| 54 | |||
| 55 | function getLatexFromTemplate(string $template, $data) | ||
| 39 | { | 56 | { |
| 40 | // variables à injecter | 57 | // variables à injecter |
| 41 | $nom_client = "M. Duchmol"; | 58 | $nom_client = "M. Duchmol"; |
diff --git a/src/main.php b/src/main.php index 0a8ae09..ee0888e 100755 --- a/src/main.php +++ b/src/main.php | |||
| @@ -3,18 +3,20 @@ | |||
| 3 | // php/main.php | 3 | // php/main.php |
| 4 | 4 | ||
| 5 | // configuration du programme par l'utilisateur | 5 | // configuration du programme par l'utilisateur |
| 6 | require('../config.php'); // fichier de l'utilisateur: à déplacer peut-être dans un dossier config | 6 | //~ require('../config.php'); // fichier de l'utilisateur: à déplacer peut-être dans un dossier config |
| 7 | require('Config.php'); // classe structure de données, lit config.php et préviens les erreurs (par exemple les / aux chemins manquants) | ||
| 8 | Config::readFile('../config.ini'); | ||
| 9 | Config::hydrate(); | ||
| 7 | 10 | ||
| 8 | // à coder peut-être plus tard | 11 | // et à coder peut-être plus tard |
| 9 | //require('config_check.php'); // contrôle de config.php, on ajoutera des / aux chemins quand ils manquent | ||
| 10 | //require('config_window.php'); // configuration user-friendly et assistée avec des messages d'erreur et des indications | 12 | //require('config_window.php'); // configuration user-friendly et assistée avec des messages d'erreur et des indications |
| 11 | 13 | ||
| 12 | // variables diverses, certaines utilisent les variables de config.php | 14 | // variables diverses, certaines utilisent les variables de config.php |
| 13 | $exec_mode = 'gui'; // les versions pure console (CLI) et serveur web (CGI) de ce programme ne sont pas prévues pour l'instant | 15 | $exec_mode = 'gui'; // les versions pure console (CLI) et serveur web (CGI) de ce programme ne sont pas prévues pour l'instant |
| 14 | $file_explorer = 'xdg-open'; // ouvre l'explorateur de fichiers par défaut quand suivi d'un chemin en paramètre | 16 | $file_explorer = 'xdg-open'; // ouvre l'explorateur de fichiers par défaut quand suivi d'un chemin en paramètre |
| 15 | $flyer = $pub . $flyer; | 17 | $flyer = Config::$pub_path . Config::$flyer; |
| 16 | $business_card = $pub . $business_card; | 18 | $business_card = Config::$pub_path . Config::$business_card; |
| 17 | $db_place .= $db_name . '.sqlite'; | 19 | Config::$db_path .= Config::$db_name . '.' . Config::$sgbd; |
| 18 | $sqlitebrowser_enable = false; | 20 | $sqlitebrowser_enable = false; |
| 19 | $sqlite_cli = ''; // commande sqlite ou sqlite3 | 21 | $sqlite_cli = ''; // commande sqlite ou sqlite3 |
| 20 | $x_term_command = ''; // commande terminal en mode graphique | 22 | $x_term_command = ''; // commande terminal en mode graphique |
| @@ -22,10 +24,11 @@ $x_term_command = ''; // commande terminal en mode graphique | |||
| 22 | require('dependances.php'); // vérification des dépendances | 24 | require('dependances.php'); // vérification des dépendances |
| 23 | require('functions.php'); | 25 | require('functions.php'); |
| 24 | require('Dates.php'); // gère dates et timestamps | 26 | require('Dates.php'); // gère dates et timestamps |
| 25 | Dates::$date_format = $date_format; // dates européennes ou américaines | 27 | Dates::$date_format = Config::$date_format; // dates européennes ou américaines |
| 26 | 28 | ||
| 27 | require('model/DB.php'); // connexion en héritant de PDO | 29 | require('model/DB.php'); // connexion en héritant de PDO |
| 28 | DB::$dsn = 'sqlite:' . $db_place; // Data Source Name = 1er paramètre du constructeur de PDO: $bdd = new PDO($dsn); | 30 | // création du DSN à mettre ailleurs (dans Model?) |
| 31 | DB::$dsn = 'sqlite:' . Config::$db_path; // Data Source Name = 1er paramètre du constructeur de PDO: $bdd = new PDO($dsn); | ||
| 29 | 32 | ||
| 30 | require('model/Model.php'); // class Model extends DB, requêtes SQL | 33 | require('model/Model.php'); // class Model extends DB, requêtes SQL |
| 31 | require('model/StructTablesDB.php'); | 34 | require('model/StructTablesDB.php'); |
| @@ -150,11 +153,11 @@ while($boucle) | |||
| 150 | echo("choix: $choix_niv1\n"); | 153 | echo("choix: $choix_niv1\n"); |
| 151 | if($sqlitebrowser_enable) | 154 | if($sqlitebrowser_enable) |
| 152 | { | 155 | { |
| 153 | exec(windowAppCommand($sqlite_gui, $db_place)); | 156 | exec(windowAppCommand(Config::$sqlite_gui, Config::$db_path)); |
| 154 | } | 157 | } |
| 155 | else | 158 | else |
| 156 | { | 159 | { |
| 157 | exec($x_term_command . ' ' . $sqlite_cli . ' ' . $db_place); // correpond à priori à: xterm -e sqlite3 ~/ORDIPOLO/Appli_PHP/ordipolo.sqlite | 160 | exec($x_term_command . ' ' . $sqlite_cli . ' ' . Config::$db_path); // correpond à priori à: xterm -e sqlite3 ~/ORDIPOLO/Appli_PHP/ordipolo.sqlite |
| 158 | } | 161 | } |
| 159 | } | 162 | } |
| 160 | 163 | ||
diff --git a/src/sections/1_new_service.php b/src/sections/1_new_service.php index aaf441a..656b45f 100644 --- a/src/sections/1_new_service.php +++ b/src/sections/1_new_service.php | |||
| @@ -130,7 +130,7 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
| 130 | case ZenitySetup::$menu_enregistrement_entrees[4]: // "Prestation non vendue" | 130 | case ZenitySetup::$menu_enregistrement_entrees[4]: // "Prestation non vendue" |
| 131 | $Presta->setTypePresta('non_vendue'); | 131 | $Presta->setTypePresta('non_vendue'); |
| 132 | break; | 132 | break; |
| 133 | default: // inutile normallement, cas déjà géré plus haut | 133 | default: // inutile normallement, cas déjà géré avant |
| 134 | echo "debug: sortie du menu enregistrement incorrect\n"; | 134 | echo "debug: sortie du menu enregistrement incorrect\n"; |
| 135 | return(0); | 135 | return(0); |
| 136 | } | 136 | } |
| @@ -167,14 +167,49 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
| 167 | 167 | ||
| 168 | // -- partie 3: LaTeX -- | 168 | // -- partie 3: LaTeX -- |
| 169 | 169 | ||
| 170 | // création fichiers LaTeX et PDF | 170 | // créer le chemin et un sous-dossier avec l'année en cours |
| 171 | //~ $latex_path = '../data/latex/'; // noms de variables dans le config.php | 171 | $latex_year_folder = Config::$latex_path . date('Y') . '/'; |
| 172 | //~ $file_name = 'devis.tex'; | 172 | makeFolder($latex_year_folder); |
| 173 | //~ $template = 'devis'; // vaut 'devis' ou 'enveloppe_recto' ou 'enveloppe_verso' ou 'facture' ou 'location' | 173 | |
| 174 | //~ $latex = getLatexFromTemplate($template); | 174 | $pdf_year_folder = Config::$pdf_path . date('Y') . '/'; |
| 175 | //~ file_put_contents($latex_path . $file_name, $latex); // injection des variables & écriture du fichier | 175 | makeFolder($pdf_year_folder); |
| 176 | //~ $pdf_path = '../data/pdf/'; | 176 | |
| 177 | //~ latexToPdf($latex_path, $file_name, $pdf_path); | 177 | // document de la prestation |
| 178 | switch($choix_niv2) | ||
| 179 | { | ||
| 180 | case ZenitySetup::$menu_enregistrement_entrees[0]: // "Devis" | ||
| 181 | $file_name = 'devis.tex'; | ||
| 182 | $template = 'devis'; | ||
| 183 | makeLatexAndPdfDocument($file_name, $template, $Client, $Presta, $Details); | ||
| 184 | break; | ||
| 185 | case ZenitySetup::$menu_enregistrement_entrees[1]: // "Facture" | ||
| 186 | $file_name = 'facture.tex'; | ||
| 187 | $template = 'facture'; | ||
| 188 | makeLatexAndPdfDocument($file_name, $template, $Client, $Presta, $Details); | ||
| 189 | break; | ||
| 190 | case ZenitySetup::$menu_enregistrement_entrees[2]: // "CESU" | ||
| 191 | // pas de facture | ||
| 192 | break; | ||
| 193 | case ZenitySetup::$menu_enregistrement_entrees[3]: // "Location" | ||
| 194 | $file_name = 'location.tex'; | ||
| 195 | $template = 'location'; | ||
| 196 | makeLatexAndPdfDocument($file_name, $template, $Client, $Presta, $Details); | ||
| 197 | break; | ||
| 198 | case ZenitySetup::$menu_enregistrement_entrees[4]: // "Prestation non vendue" | ||
| 199 | // pas de facture | ||
| 200 | break; | ||
| 201 | default: // inutile normallement, cas déjà géré avant | ||
| 202 | echo "debug: sortie du menu enregistrement incorrect\n"; | ||
| 203 | return(0); | ||
| 204 | } | ||
| 205 | |||
| 206 | // enveloppe | ||
| 207 | $file_name = 'enveloppe_recto.tex'; | ||
| 208 | $template = 'enveloppe_recto'; | ||
| 209 | makeLatexAndPdfDocument($file_name, $template, $Client); | ||
| 210 | $file_name = 'enveloppe_verso.tex'; | ||
| 211 | $template = 'enveloppe_verso'; | ||
| 212 | makeLatexAndPdfDocument($file_name, $template, $Client); | ||
| 178 | 213 | ||
| 179 | 214 | ||
| 180 | // -- partie 4: récapitulatif -- | 215 | // -- partie 4: récapitulatif -- |
