diff options
| author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
| commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
| tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /src/files.php | |
| parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
| download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.gz AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.bz2 AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip | |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'src/files.php')
| -rw-r--r-- | src/files.php | 82 |
1 files changed, 48 insertions, 34 deletions
diff --git a/src/files.php b/src/files.php index 0bda901..ad20ee0 100644 --- a/src/files.php +++ b/src/files.php | |||
| @@ -5,53 +5,58 @@ | |||
| 5 | 5 | ||
| 6 | function makeFile($path, $file_name, $data) | 6 | function makeFile($path, $file_name, $data) |
| 7 | { | 7 | { |
| 8 | //~ if(is_writable('../' . $path)) | 8 | //~ if(is_writable('../' . $path)) |
| 9 | //~ { | 9 | //~ { |
| 10 | file_put_contents($path. $file_name, $data); | 10 | file_put_contents($path. $file_name, $data); |
| 11 | chmod($path . $file_name, 0644); // droits en octal | 11 | chmod($path . $file_name, 0644); // droits en octal |
| 12 | //~ } | 12 | //~ } |
| 13 | 13 | ||
| 14 | //~ protected function createFile(string $latex, string $file_name, string $latexPath) | 14 | //~ protected function createFile(string $latex, string $file_name, string $latexPath) |
| 15 | //~ { | 15 | //~ { |
| 16 | //~ // nom du fichier créé = nom.tex | 16 | //~ // nom du fichier créé = nom.tex |
| 17 | //~ // pour les devis, factures et enveloppes, le nom est le code la prestation | 17 | //~ // pour les devis, factures et enveloppes, le nom est le code la prestation |
| 18 | //~ // pour les livre de recettes et registres des achats mensuels: | 18 | //~ // pour les livre de recettes et registres des achats mensuels: |
| 19 | //~ // le nom du fichier suit cet exemple: "Recettes-2022-06-Juin.tex" | 19 | //~ // le nom du fichier suit cet exemple: "Recettes-2022-06-Juin.tex" |
| 20 | //~ // pour le livre de recette ou le registre des achats annuel, même principe: "Achats-2022.tex" | 20 | //~ // pour le livre de recette ou le registre des achats annuel, même principe: "Achats-2022.tex" |
| 21 | //~ // pour le bilan comptable annuel, ça donne: "Bilan-2022.tex" | 21 | //~ // pour le bilan comptable annuel, ça donne: "Bilan-2022.tex" |
| 22 | //~ $fichier = fopen($latexPath . $file_name, "w+"); | 22 | //~ $fichier = fopen($latexPath . $file_name, "w+"); |
| 23 | //~ fputs($fichier, $latex); | 23 | //~ fputs($fichier, $latex); |
| 24 | //~ fclose($fichier); | 24 | //~ fclose($fichier); |
| 25 | //~ } | 25 | //~ } |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | //~ function deleteFile($path, $file_name) | ||
| 29 | //~ { | ||
| 30 | //~ unlink() | ||
| 31 | //~ } | ||
| 32 | |||
| 28 | function makeFolder(string $path) | 33 | function makeFolder(string $path) |
| 29 | { | 34 | { |
| 30 | $rights = 0755; // droits en octal | 35 | $rights = 0755; // droits en octal |
| 31 | 36 | ||
| 32 | if(!file_exists($path)) | 37 | if(!file_exists($path)) |
| 33 | { | 38 | { |
| 34 | //~ if(is_writable('../' . $path)) | 39 | //~ if(is_writable('../' . $path)) |
| 35 | //~ { | 40 | //~ { |
| 36 | mkdir($path); | 41 | mkdir($path); |
| 37 | chmod($path, $rights); | 42 | chmod($path, $rights); |
| 38 | //~ } | 43 | //~ } |
| 39 | //~ else | 44 | //~ else |
| 40 | //~ { | 45 | //~ { |
| 41 | //~ echo "debug: la création du dossier " . $path . " est impossible\n"; | 46 | //~ echo "debug: la création du dossier " . $path . " est impossible\n"; |
| 42 | //~ } | 47 | //~ } |
| 43 | } | 48 | } |
| 44 | else | 49 | else |
| 45 | { | 50 | { |
| 46 | //~ if(is_writable($path)) | 51 | //~ if(is_writable($path)) |
| 47 | //~ { | 52 | //~ { |
| 48 | chmod($path, $rights); | 53 | chmod($path, $rights); |
| 49 | //~ } | 54 | //~ } |
| 50 | //~ else | 55 | //~ else |
| 51 | //~ { | 56 | //~ { |
| 52 | //~ echo "debug: la modification des droits du dossier " . $path . " est impossible\n"; | 57 | //~ echo "debug: la modification des droits du dossier " . $path . " est impossible\n"; |
| 53 | //~ } | 58 | //~ } |
| 54 | } | 59 | } |
| 55 | } | 60 | } |
| 56 | 61 | ||
| 57 | // commande système pdflatex | 62 | // commande système pdflatex |
| @@ -75,6 +80,15 @@ function latexToPdf(string $latex_path, string $file_name, string $pdf_path) | |||
| 75 | unlink($pdf_path . $basename . '.log'); | 80 | unlink($pdf_path . $basename . '.log'); |
| 76 | } | 81 | } |
| 77 | 82 | ||
| 83 | // équivalent de la commande mv | ||
| 84 | function renameFiles(Object $Object, string $old_code, string $new_code) | ||
| 85 | { | ||
| 86 | rename($Object->getLatexPath() . $old_code . '.tex', | ||
| 87 | $Object->getLatexPath() . $new_code . '.tex'); | ||
| 88 | rename($Object->getPdfPath() . $old_code . '.pdf', | ||
| 89 | $Object->getPdfPath() . $new_code . '.pdf'); | ||
| 90 | } | ||
| 91 | |||
| 78 | function makeTexAndPdf(Object $Object) // paramètre = enfant de Latex | 92 | function makeTexAndPdf(Object $Object) // paramètre = enfant de Latex |
| 79 | { | 93 | { |
| 80 | if(get_class($Object) !== 'EnveloppeVersoLatex') | 94 | if(get_class($Object) !== 'EnveloppeVersoLatex') |
