summaryrefslogtreecommitdiff
path: root/src/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/functions.php')
-rw-r--r--src/functions.php52
1 files changed, 47 insertions, 5 deletions
diff --git a/src/functions.php b/src/functions.php
index d67a05e..6ddbae0 100644
--- a/src/functions.php
+++ b/src/functions.php
@@ -1,11 +1,11 @@
1<?php 1<?php
2// php/functions.php 2// src/functions.php
3// 3//
4// gros fourre-tout, il faudra le ranger plus tard 4// gros fourre-tout, à ranger plus tard
5 5
6 6
7// commande pour lancer une application graphique en ouvrant un fichier 7// commande pour lancer une application graphique en ouvrant un fichier
8function window_app_command(string $app, string $path = ''): string 8function windowAppCommand(string $app, string $path = ''): string
9{ 9{
10 // attention, la syntaxe utilisée est la plus simple: "app fichier" 10 // attention, la syntaxe utilisée est la plus simple: "app fichier"
11 // ça fonctionne avec les logiciels choisis: gimp, scribus 11 // ça fonctionne avec les logiciels choisis: gimp, scribus
@@ -22,7 +22,7 @@ function window_app_command(string $app, string $path = ''): string
22 return $command; 22 return $command;
23} 23}
24 24
25function recherche_client(string $saisie): array 25function rechercheClient(string $saisie): array
26{ 26{
27 $resultats = []; 27 $resultats = [];
28 28
@@ -32,8 +32,50 @@ function recherche_client(string $saisie): array
32 return($resultats); 32 return($resultats);
33} 33}
34 34
35// NOTE 1: les objets sont passés aux fonctions par référence par défaut, toutefois ce n'est pas entièrement vrai
36// 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
37// NOTE 3: la variable créée lors d'un "new" est elle-même une référence contenant un identifiant (= le pointeur?)
38// NOTE 4: l'objet est détruit lorsque la dernière référence est supprimée
39
40function enregistrementNouveauClient(Clients $Client, ZenityForms $NouveauClient)
41{
42 $entry = exec($NouveauClient->get());
43 if($entry !== '')
44 {
45 $tableau = explode('|', $entry);
46 if(count($tableau) === 4)
47 {
48 $Client->newRow($tableau);
49 return true;
50 }
51 else
52 {
53 echo "debug: mauvais tableau, il doit avoir 4 cases\n";
54 return false;
55 }
56 }
57 else
58 {
59 echo "debug: pas de données saisies\n";
60 return false;
61 }
62}
63
64function getLatexFromTemplate(string $template)
65{
66 // variables à injecter
67 $nom_client = "M. Duchmol";
68
69 // on obtient la variable $latex avec ob_get_clean()
70 include('latex_templates/' . $template . '.php');
71
72 // on retourne le buffer
73 // normallement le code PHP inséré avec include est nettoyé en quittant la fonction
74 return($latex);
75}
76
35// compilation à partir d'un fichier .tex 77// compilation à partir d'un fichier .tex
36function latexToPdf(string $fileName, string $latexPath, string $pdfPath) 78function latexToPdf(string $latexPath, string $fileName, string $pdfPath)
37{ 79{
38 $outputDir = ''; 80 $outputDir = '';
39 if($pdfPath !== '') 81 if($pdfPath !== '')