summaryrefslogtreecommitdiff
path: root/php/Latex.php
blob: c3d56af471a6474fc6335c8e18202135f0cd512c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
// php/Latex.php
//
// génération du code LaTeX

abstract class Latex
{
    protected $fileName = '';
    protected $latexPath = '';
    protected $pdfPath = '';
    
    protected function createFile(string $latex, string $fileName, string $latexPath)
    {
        // nom du fichier créé = nom.tex
        // pour les devis, factures et enveloppes, le nom est le code la prestation
        // pour les livre de recettes et registres des achats mensuels:
        // le nom du fichier suit cet exemple: "Recettes-2022-06-Juin.tex"
        // pour le livre de recette ou le registre des achats annuel, même principe: "Achats-2022.tex"
        // pour le bilan comptable annuel, ça donne: "Bilan-2022.tex"
        $fichier = fopen($latexPath . $fileName, "w+");
        fputs($fichier, $latex);
        fclose($fichier);
    }
}


abstract class PrestaLatex extends Latex
{
    public function __construct(string $quoi, string $codePresta)
    {
        nameTheFile($quoi, $codePresta);
    }
    
    // forme = code-presta.tex
    protected function nameTheFile(string $quoi, string $codePresta)
    {
        $this->fileName = $quoi . '-' . $codePresta . '.tex';
    }
}

class DevisLatex extends PrestaLatex
{}

class FactureLatex extends PrestaLatex
{}

class LocationLatex extends PrestaLatex
{}

class EnveloppeRectoLatex extends PrestaLatex
{}
class EnveloppeVersoLatex extends PrestaLatex
{}


abstract class ComptaLatex extends Latex
{
    public function __construct(string $quoi, string $annee, int $numeroMois = 0)
    {
        nameTheFile($quoi, $annee, $numeroMois);
    }
    
    // forme = Recettes-2022-06-Juin.tex ou Recettes-2022.tex
    // type de 'annee'?
    protected function nameTheFile(string $quoi, string $annee, int $numeroMois = 0)
    {
        $this->fileName = $quoi . '-' . $annee;
        $mois = ['', 'Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'];
        if($numeroMois > 0 && $numeroMois <= 12)
        {
            $this->fileName .= '-' . $numeroMois . '-' . $mois[$numeroMois];
        }
        $this->fileName .= '.tex';
    }
}

class LivreRecettesLatex extends ComptaLatex
{}

class RegistreAchatsLatex extends ComptaLatex
{}

class BilanLatex extends ComptaLatex
{}