1 | <?php |
---|
2 | |
---|
3 | /* * *************************************************************************\ |
---|
4 | * Associaspip, extension de SPIP pour gestion d'associations * |
---|
5 | * * |
---|
6 | * Copyright (c) 2007 Bernard Blazin & François de Montlivault (V1) * |
---|
7 | * Copyright (c) 2010-2011 Emmanuel Saint-James & Jeannot Lapin (V2) * |
---|
8 | * Ecrit par Marcel BOLLA en 01/2012 * |
---|
9 | * * |
---|
10 | * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * |
---|
11 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
---|
12 | \************************************************************************** */ |
---|
13 | |
---|
14 | if (!defined('_ECRIRE_INC_VERSION')) |
---|
15 | return; |
---|
16 | |
---|
17 | include_spip('exec/compte_resultat'); // c'est pour la definition de classe ExportCompteResultats |
---|
18 | |
---|
19 | // Export du Compte de Resultat au format LaTeX |
---|
20 | // http://fr.wikipedia.org/wiki/LaTeX |
---|
21 | function exec_export_compteresultats_tex() { |
---|
22 | if (!autoriser('associer', 'export_compteresultats')) { |
---|
23 | include_spip('inc/minipres'); |
---|
24 | echo minipres(); |
---|
25 | } else { |
---|
26 | $var = _request('var'); |
---|
27 | $latex = new LaTeX(_request('var')); |
---|
28 | $latex->EnTete(); |
---|
29 | foreach (array('charges', 'produits', 'contributions_volontaires') as $key) { |
---|
30 | $latex->LesEcritures($key); |
---|
31 | } |
---|
32 | $latex->Pied(); |
---|
33 | $latex->leFichier('tex'); |
---|
34 | } |
---|
35 | } |
---|
36 | |
---|
37 | /** |
---|
38 | * Utilisation d'une classe tres tres tres simple !!! |
---|
39 | */ |
---|
40 | class LaTeX extends ExportCompteResultats { |
---|
41 | |
---|
42 | function EnTete() { |
---|
43 | $this->out .= '\\documentclass[a4paper]{article}'."\n"; |
---|
44 | $this->out .= '\\usepackage['.$GLOBALS['meta']['charset'].']{inputenc}'."\n"; |
---|
45 | $this->out .= '\\usepackage[french]{babel}'."\n"; |
---|
46 | $this->out .= '\\usepackage[table]{xcolor}'."\n"; |
---|
47 | $this->out .= '%generator: Associaspip'."\n"; |
---|
48 | $this->out .= '\\title{'. html_entity_decode(_T('asso:cpte_resultat_titre_general')) .'\\\\ '. _T('Exercice') .' : '. sql_asso1champ('exercice', $this->exercice, 'intitule') .'}'."\n"; |
---|
49 | $this->out .= '\\author{'. $GLOBALS['association_metas']['nom'] .'}'."\n"; |
---|
50 | $this->out .= '\\date{\\today}'."\n"; |
---|
51 | $this->out .= '\\begin{document}'."\n"; |
---|
52 | $this->out .= '\\maketitle{}'."\n"; |
---|
53 | } |
---|
54 | |
---|
55 | function LesEcritures($key) { |
---|
56 | switch ($key) { |
---|
57 | case 'charges' : |
---|
58 | $quoi = "SUM(depense) AS valeurs"; |
---|
59 | break; |
---|
60 | case 'produits' : |
---|
61 | $quoi = "SUM(recette) AS valeurs"; |
---|
62 | break; |
---|
63 | case 'contributions_volontaires' : |
---|
64 | $quoi = "SUM(depense) AS charge_evaluee, SUM(recette) AS produit_evalue"; |
---|
65 | break; |
---|
66 | } |
---|
67 | $this->out .= '\\section*{'. ucfirst($key) .'}'."\n"; |
---|
68 | $this->out .= '\\begin{tabular}{|l p{.7562\\textwidth} r|}'."\n"; // 20/210=9.52381/100 30/210=14.8571/100 (210-20-30)/100=75.61909 |
---|
69 | $query = sql_select( |
---|
70 | "imputation, $quoi, DATE_FORMAT(date, '%Y') AS annee ".$this->sel, // select |
---|
71 | 'spip_asso_comptes'.$this->join, // from |
---|
72 | $this->where, // where |
---|
73 | $this->order, // group by |
---|
74 | $this->order, // order by |
---|
75 | '', // limit |
---|
76 | $this->having .$GLOBALS['association_metas']['classe_'.$key] // having |
---|
77 | ); |
---|
78 | $chapitre = ''; |
---|
79 | $i = 0; |
---|
80 | while ($data = sql_fetch($query)) { |
---|
81 | if ($key==='contributions_volontaires') { |
---|
82 | if ($data['charge_evaluee']>0) { |
---|
83 | $valeurs = $data['charge_evaluee']; |
---|
84 | } else { |
---|
85 | $valeurs = $data['produit_evalue']; |
---|
86 | } |
---|
87 | } else { |
---|
88 | $valeurs = $data['valeurs']; |
---|
89 | } |
---|
90 | $new_chapitre = substr($data['code'], 0, 2); |
---|
91 | if ($chapitre!=$new_chapitre) { |
---|
92 | $this->out .= str_replace(array('\\','&'), array('\\backslash{}','\\&'), $new_chapitre) .' & '; |
---|
93 | $this->out .= '\multicolumn{2}{l|}{'. str_replace(array('\\','&'), array('\\backslash{}','\\&'), ($GLOBALS['association_metas']['plan_comptable_prerenseigne']?association_plan_comptable_complet($new_chapitre):sql_getfetsel('intitule','spip_asso_plan',"code='$new_chapitre'"))) .'}\\\\'."\n"; |
---|
94 | $chapitre = $new_chapitre; |
---|
95 | } |
---|
96 | $this->out .= str_replace(array('\\','&'), array('\\backslash{}','\\&'), $data['code']) .' & '; |
---|
97 | $this->out .= str_replace(array('\\','&'), array('\\backslash{}','\\&'), $data['intitule']) .' & '; |
---|
98 | $this->out .= $valeurs.'\\\\'."\n"; |
---|
99 | } |
---|
100 | $this->out .= '\\end{tabular}'."\n"; |
---|
101 | } |
---|
102 | |
---|
103 | function Pied() { |
---|
104 | $this->out .= '\end{document}'."\n"; |
---|
105 | } |
---|
106 | |
---|
107 | } |
---|
108 | |
---|
109 | ?> |
---|