@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | abstract class ModeleDon extends CommonDocGenerator |
36 | 36 | { |
37 | 37 | /** |
38 | - * @var string Error code (or message) |
|
39 | - */ |
|
40 | - public $error=''; |
|
38 | + * @var string Error code (or message) |
|
39 | + */ |
|
40 | + public $error=''; |
|
41 | 41 | |
42 | 42 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
43 | 43 | /** |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | abstract class ModeleNumRefDons |
70 | 70 | { |
71 | 71 | /** |
72 | - * @var string Error code (or message) |
|
73 | - */ |
|
74 | - public $error=''; |
|
72 | + * @var string Error code (or message) |
|
73 | + */ |
|
74 | + public $error=''; |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Return if a module can be used or not |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | /** |
38 | 38 | * @var string Error code (or message) |
39 | 39 | */ |
40 | - public $error=''; |
|
40 | + public $error = ''; |
|
41 | 41 | |
42 | 42 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
43 | 43 | /** |
@@ -47,16 +47,16 @@ discard block |
||
47 | 47 | * @param integer $maxfilenamelength Max length of value to show |
48 | 48 | * @return array List of templates |
49 | 49 | */ |
50 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
50 | + static function liste_modeles($db, $maxfilenamelength = 0) |
|
51 | 51 | { |
52 | 52 | // phpcs:enable |
53 | 53 | global $conf; |
54 | 54 | |
55 | - $type='donation'; |
|
56 | - $liste=array(); |
|
55 | + $type = 'donation'; |
|
56 | + $liste = array(); |
|
57 | 57 | |
58 | 58 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
59 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
59 | + $liste = getListOfModels($db, $type, $maxfilenamelength); |
|
60 | 60 | |
61 | 61 | return $liste; |
62 | 62 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | /** |
72 | 72 | * @var string Error code (or message) |
73 | 73 | */ |
74 | - public $error=''; |
|
74 | + public $error = ''; |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Return if a module can be used or not |
@@ -139,10 +139,18 @@ |
||
139 | 139 | global $langs; |
140 | 140 | $langs->load("admin"); |
141 | 141 | |
142 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
143 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
144 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
145 | - if ($this->version) return $this->version; |
|
142 | + if ($this->version == 'development') { |
|
143 | + return $langs->trans("VersionDevelopment"); |
|
144 | + } |
|
145 | + if ($this->version == 'experimental') { |
|
146 | + return $langs->trans("VersionExperimental"); |
|
147 | + } |
|
148 | + if ($this->version == 'dolibarr') { |
|
149 | + return DOL_VERSION; |
|
150 | + } |
|
151 | + if ($this->version) { |
|
152 | + return $this->version; |
|
153 | + } |
|
146 | 154 | return $langs->trans("NotAvailable"); |
147 | 155 | } |
148 | 156 | } |
@@ -35,119 +35,119 @@ discard block |
||
35 | 35 | */ |
36 | 36 | class html_cerfafr extends ModeleDon |
37 | 37 | { |
38 | - /** |
|
39 | - * Constructor |
|
40 | - * |
|
41 | - * @param DoliDb $db Database handler |
|
42 | - */ |
|
43 | - function __construct($db) |
|
44 | - { |
|
45 | - global $conf,$langs; |
|
46 | - |
|
47 | - $this->db = $db; |
|
48 | - $this->name = "cerfafr"; |
|
49 | - $this->description = $langs->trans('DonationsReceiptModel').' - fr_FR - Cerfa 11580*03'; |
|
50 | - |
|
51 | - // Dimension page for size A4 |
|
52 | - $this->type = 'html'; |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * Return if a module can be used or not |
|
58 | - * |
|
59 | - * @return boolean true if module can be used |
|
60 | - */ |
|
61 | - function isEnabled() |
|
62 | - { |
|
63 | - return true; |
|
64 | - } |
|
38 | + /** |
|
39 | + * Constructor |
|
40 | + * |
|
41 | + * @param DoliDb $db Database handler |
|
42 | + */ |
|
43 | + function __construct($db) |
|
44 | + { |
|
45 | + global $conf,$langs; |
|
46 | + |
|
47 | + $this->db = $db; |
|
48 | + $this->name = "cerfafr"; |
|
49 | + $this->description = $langs->trans('DonationsReceiptModel').' - fr_FR - Cerfa 11580*03'; |
|
50 | + |
|
51 | + // Dimension page for size A4 |
|
52 | + $this->type = 'html'; |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * Return if a module can be used or not |
|
58 | + * |
|
59 | + * @return boolean true if module can be used |
|
60 | + */ |
|
61 | + function isEnabled() |
|
62 | + { |
|
63 | + return true; |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | 67 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
68 | - /** |
|
69 | - * Write the object to document file to disk |
|
70 | - * |
|
71 | - * @param Don $don Donation object |
|
72 | - * @param Translate $outputlangs Lang object for output language |
|
73 | - * @param string $currency Currency code |
|
74 | - * @return int >0 if OK, <0 if KO |
|
75 | - */ |
|
76 | - function write_file($don,$outputlangs,$currency='') |
|
77 | - { |
|
68 | + /** |
|
69 | + * Write the object to document file to disk |
|
70 | + * |
|
71 | + * @param Don $don Donation object |
|
72 | + * @param Translate $outputlangs Lang object for output language |
|
73 | + * @param string $currency Currency code |
|
74 | + * @return int >0 if OK, <0 if KO |
|
75 | + */ |
|
76 | + function write_file($don,$outputlangs,$currency='') |
|
77 | + { |
|
78 | 78 | // phpcs:enable |
79 | - global $user,$conf,$langs,$mysoc; |
|
80 | - |
|
81 | - $now=dol_now(); |
|
82 | - $id = (! is_object($don)?$don:''); |
|
83 | - |
|
84 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
85 | - |
|
86 | - // Load traductions files requiredby by page |
|
87 | - $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "donations")); |
|
88 | - |
|
89 | - $currency = !empty($currency) ? $currency : $conf->currency; |
|
90 | - |
|
91 | - if (! empty($conf->don->dir_output)) |
|
92 | - { |
|
93 | - // Definition of the object don (for upward compatibility) |
|
94 | - if (! is_object($don)) |
|
95 | - { |
|
96 | - $don = new Don($this->db); |
|
97 | - $ret=$don->fetch($id); |
|
98 | - $id=$don->id; |
|
99 | - } |
|
100 | - |
|
101 | - // Definition of $dir and $file |
|
102 | - if (! empty($don->specimen)) |
|
103 | - { |
|
104 | - $dir = $conf->don->dir_output; |
|
105 | - $file = $dir . "/SPECIMEN.html"; |
|
106 | - } |
|
107 | - else |
|
108 | - { |
|
109 | - $donref = dol_sanitizeFileName($don->ref); |
|
110 | - $dir = $conf->don->dir_output . "/" . $donref; |
|
111 | - $file = $dir . "/" . $donref . ".html"; |
|
112 | - } |
|
113 | - |
|
114 | - if (! file_exists($dir)) |
|
115 | - { |
|
116 | - if (dol_mkdir($dir) < 0) |
|
117 | - { |
|
118 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
119 | - return -1; |
|
120 | - } |
|
121 | - } |
|
122 | - |
|
123 | - if (file_exists($dir)) |
|
124 | - { |
|
125 | - $formclass = new Form($this->db); |
|
126 | - |
|
127 | - // This is not the proper way to do it but $formclass->form_modes_reglement |
|
128 | - // prints the translation instead of returning it |
|
129 | - if ($don->modepaiementid) |
|
130 | - { |
|
131 | - $formclass->load_cache_types_paiements(); |
|
132 | - $paymentmode = $formclass->cache_types_paiements[$don->modepaiementid]['label']; |
|
133 | - } |
|
134 | - else $paymentmode = ''; |
|
135 | - |
|
136 | - if ($don->modepaymentcode=='CHQ'){ |
|
137 | - $ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox" disabled="true" checked="checked"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>'; |
|
138 | - } |
|
139 | - else if ($don->modepaymentcode=='LIQ'){ |
|
140 | - $ModePaiement = '<td width="25%"><input type="checkbox" checked="checked"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>'; |
|
141 | - } |
|
142 | - else if ($don->modepaymentcode=='VIR' || $don->modepaymentcode=='PRE' || $don->modepaymentcode=='CB'){ |
|
143 | - $ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox" checked="checked"> Virement, prélèvement, carte bancaire</td>'; |
|
144 | - } |
|
145 | - else |
|
146 | - { |
|
147 | - $ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>'; |
|
148 | - } |
|
149 | - |
|
150 | - /* |
|
79 | + global $user,$conf,$langs,$mysoc; |
|
80 | + |
|
81 | + $now=dol_now(); |
|
82 | + $id = (! is_object($don)?$don:''); |
|
83 | + |
|
84 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
85 | + |
|
86 | + // Load traductions files requiredby by page |
|
87 | + $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "donations")); |
|
88 | + |
|
89 | + $currency = !empty($currency) ? $currency : $conf->currency; |
|
90 | + |
|
91 | + if (! empty($conf->don->dir_output)) |
|
92 | + { |
|
93 | + // Definition of the object don (for upward compatibility) |
|
94 | + if (! is_object($don)) |
|
95 | + { |
|
96 | + $don = new Don($this->db); |
|
97 | + $ret=$don->fetch($id); |
|
98 | + $id=$don->id; |
|
99 | + } |
|
100 | + |
|
101 | + // Definition of $dir and $file |
|
102 | + if (! empty($don->specimen)) |
|
103 | + { |
|
104 | + $dir = $conf->don->dir_output; |
|
105 | + $file = $dir . "/SPECIMEN.html"; |
|
106 | + } |
|
107 | + else |
|
108 | + { |
|
109 | + $donref = dol_sanitizeFileName($don->ref); |
|
110 | + $dir = $conf->don->dir_output . "/" . $donref; |
|
111 | + $file = $dir . "/" . $donref . ".html"; |
|
112 | + } |
|
113 | + |
|
114 | + if (! file_exists($dir)) |
|
115 | + { |
|
116 | + if (dol_mkdir($dir) < 0) |
|
117 | + { |
|
118 | + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
119 | + return -1; |
|
120 | + } |
|
121 | + } |
|
122 | + |
|
123 | + if (file_exists($dir)) |
|
124 | + { |
|
125 | + $formclass = new Form($this->db); |
|
126 | + |
|
127 | + // This is not the proper way to do it but $formclass->form_modes_reglement |
|
128 | + // prints the translation instead of returning it |
|
129 | + if ($don->modepaiementid) |
|
130 | + { |
|
131 | + $formclass->load_cache_types_paiements(); |
|
132 | + $paymentmode = $formclass->cache_types_paiements[$don->modepaiementid]['label']; |
|
133 | + } |
|
134 | + else $paymentmode = ''; |
|
135 | + |
|
136 | + if ($don->modepaymentcode=='CHQ'){ |
|
137 | + $ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox" disabled="true" checked="checked"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>'; |
|
138 | + } |
|
139 | + else if ($don->modepaymentcode=='LIQ'){ |
|
140 | + $ModePaiement = '<td width="25%"><input type="checkbox" checked="checked"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>'; |
|
141 | + } |
|
142 | + else if ($don->modepaymentcode=='VIR' || $don->modepaymentcode=='PRE' || $don->modepaymentcode=='CB'){ |
|
143 | + $ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox" checked="checked"> Virement, prélèvement, carte bancaire</td>'; |
|
144 | + } |
|
145 | + else |
|
146 | + { |
|
147 | + $ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>'; |
|
148 | + } |
|
149 | + |
|
150 | + /* |
|
151 | 151 | if (empty($don->societe)) |
152 | 152 | { |
153 | 153 | $CodeDon = '<td width="33%"><input type="checkbox" disabled="true" checked="checked" > 200 du CGI</td><td width="33%"><input type="checkbox" disabled="true" > 238 bis du CGI</td><td width="33%"><input type="checkbox" disabled="true" > 885-0 V bis A du CGI</td>'; |
@@ -158,279 +158,279 @@ discard block |
||
158 | 158 | } |
159 | 159 | */ |
160 | 160 | |
161 | - // Define contents |
|
162 | - $donmodel=DOL_DOCUMENT_ROOT ."/core/modules/dons/html_cerfafr.html"; |
|
163 | - $form = implode('', file($donmodel)); |
|
164 | - $form = str_replace('__REF__',$don->id,$form); |
|
165 | - $form = str_replace('__DATE__',dol_print_date($don->date,'day',false,$outputlangs),$form); |
|
166 | - //$form = str_replace('__IP__',$user->ip,$form); // TODO $user->ip not exist |
|
167 | - $form = str_replace('__AMOUNT__', price($don->amount), $form); |
|
168 | - $form = str_replace('__AMOUNTLETTERS__', $this->amountToLetters($don->amount),$form); |
|
169 | - $form = str_replace('__CURRENCY__',$outputlangs->transnoentitiesnoconv("Currency".$currency),$form); |
|
170 | - $form = str_replace('__CURRENCYCODE__',$conf->currency,$form); |
|
171 | - $form = str_replace('__MAIN_INFO_SOCIETE_NOM__',$mysoc->name,$form); |
|
172 | - $form = str_replace('__MAIN_INFO_SOCIETE_ADDRESS__',$mysoc->address,$form); |
|
173 | - $form = str_replace('__MAIN_INFO_SOCIETE_ZIP__',$mysoc->zip,$form); |
|
174 | - $form = str_replace('__MAIN_INFO_SOCIETE_TOWN__',$mysoc->town,$form); |
|
175 | - $form = str_replace('__MAIN_INFO_SOCIETE_OBJECT__',$mysoc->object,$form); |
|
176 | - $form = str_replace('__DONATOR_FIRSTNAME__',$don->firstname,$form); |
|
177 | - $form = str_replace('__DONATOR_LASTNAME__',$don->lastname,$form); |
|
178 | - $form = str_replace('__DONATOR_SOCIETE__',$don->societe,$form); |
|
179 | - $form = str_replace('__DONATOR_STATUT__',$don->statut,$form); |
|
180 | - $form = str_replace('__DONATOR_ADDRESS__',$don->address,$form); |
|
181 | - $form = str_replace('__DONATOR_ZIP__',$don->zip,$form); |
|
182 | - $form = str_replace('__DONATOR_TOWN__',$don->town,$form); |
|
183 | - $form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode,$form); |
|
184 | - $form = str_replace('__NOW__',dol_print_date($now,'day',false,$outputlangs),$form); |
|
185 | - $form = str_replace('__DonationRef__',$outputlangs->trans("DonationRef"),$form); |
|
186 | - $form = str_replace('__DonationTitle__',$outputlangs->trans("DonationTitle"),$form); |
|
187 | - $form = str_replace('__DonationReceipt__',$outputlangs->trans("DonationReceipt"),$form); |
|
188 | - $form = str_replace('__DonationRecipient__',$outputlangs->trans("DonationRecipient"),$form); |
|
189 | - $form = str_replace('__DonationDatePayment__',$outputlangs->trans("DonationDatePayment"),$form); |
|
190 | - $form = str_replace('__PaymentMode__',$outputlangs->trans("PaymentMode"),$form); |
|
191 | - // $form = str_replace('__CodeDon__',$CodeDon,$form); |
|
192 | - $form = str_replace('__Name__',$outputlangs->trans("Name"),$form); |
|
193 | - $form = str_replace('__Address__',$outputlangs->trans("Address"),$form); |
|
194 | - $form = str_replace('__Zip__',$outputlangs->trans("Zip"),$form); |
|
195 | - $form = str_replace('__Town__',$outputlangs->trans("Town"),$form); |
|
196 | - $form = str_replace('__Object__',$outputlangs->trans("Object"),$form); |
|
197 | - $form = str_replace('__Donor__',$outputlangs->trans("Donor"),$form); |
|
198 | - $form = str_replace('__Date__',$outputlangs->trans("Date"),$form); |
|
199 | - $form = str_replace('__Signature__',$outputlangs->trans("Signature"),$form); |
|
200 | - $form = str_replace('__Message__',$outputlangs->trans("Message"),$form); |
|
201 | - $form = str_replace('__IConfirmDonationReception__',$outputlangs->trans("IConfirmDonationReception"),$form); |
|
202 | - $form = str_replace('__DonationMessage__',$conf->global->DONATION_MESSAGE,$form); |
|
203 | - |
|
204 | - $form = str_replace('__ModePaiement__', $ModePaiement,$form); |
|
205 | - |
|
206 | - $frencharticle=''; |
|
207 | - if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencharticle='<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>'; |
|
208 | - $form = str_replace('__FrenchArticle__',$frencharticle,$form); |
|
209 | - |
|
210 | - $frencheligibility=''; |
|
211 | - if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencheligibility='Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :'; |
|
212 | - $form = str_replace('__FrenchEligibility__',$frencheligibility,$form); |
|
213 | - |
|
214 | - $art200=''; |
|
215 | - if (preg_match('/fr/i',$outputlangs->defaultlang)) { |
|
216 | - if ($conf->global->DONATION_ART200 >= 1) |
|
217 | - { |
|
218 | - $art200='<input type="checkbox" disabled="true" checked="checked" >200 du CGI'; |
|
219 | - } |
|
220 | - else |
|
221 | - { |
|
222 | - $art200='<input type="checkbox" disabled="true">200 du CGI'; |
|
223 | - } |
|
224 | - } |
|
225 | - $form = str_replace('__ARTICLE200__',$art200,$form); |
|
226 | - |
|
227 | - $art238=''; |
|
228 | - if (preg_match('/fr/i',$outputlangs->defaultlang)) { |
|
229 | - if ($conf->global->DONATION_ART238 >= 1) |
|
230 | - { |
|
231 | - $art238='<input type="checkbox" disabled="true" checked="checked" >238 bis du CGI'; |
|
232 | - } |
|
233 | - else |
|
234 | - { |
|
235 | - $art238='<input type="checkbox" disabled="true">238 bis du CGI'; |
|
236 | - } |
|
237 | - } |
|
238 | - $form = str_replace('__ARTICLE238__',$art238,$form); |
|
239 | - |
|
240 | - $art885=''; |
|
241 | - if (preg_match('/fr/i',$outputlangs->defaultlang)) { |
|
242 | - if ($conf->global->DONATION_ART885 >= 1) |
|
243 | - { |
|
244 | - $art885='<input type="checkbox" disabled="true" checked="checked" >885-0 V bis du CGI'; |
|
245 | - } |
|
246 | - else |
|
247 | - { |
|
248 | - $art885='<input type="checkbox" disabled="true">885-0 V bis du CGI'; |
|
249 | - } |
|
250 | - } |
|
251 | - $form = str_replace('__ARTICLE885__',$art885,$form); |
|
252 | - |
|
253 | - // Save file on disk |
|
254 | - dol_syslog("html_cerfafr::write_file $file"); |
|
255 | - $handle=fopen($file,"w"); |
|
256 | - fwrite($handle,$form); |
|
257 | - fclose($handle); |
|
258 | - if (! empty($conf->global->MAIN_UMASK)) |
|
259 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
260 | - |
|
261 | - $this->result = array('fullpath'=>$file); |
|
262 | - |
|
263 | - return 1; |
|
264 | - } |
|
265 | - else |
|
266 | - { |
|
267 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
268 | - return 0; |
|
269 | - } |
|
270 | - } |
|
271 | - else |
|
272 | - { |
|
273 | - $this->error=$langs->trans("ErrorConstantNotDefined","DON_OUTPUTDIR"); |
|
274 | - return 0; |
|
275 | - } |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * numbers to letters |
|
280 | - * |
|
281 | - * @param mixed $montant amount |
|
282 | - * @param mixed $devise1 devise 1 ex: euro |
|
283 | - * @param mixed $devise2 devise 2 ex: centimes |
|
284 | - * @return string amount in letters |
|
285 | - */ |
|
286 | - private function amountToLetters($montant, $devise1='', $devise2='') |
|
287 | - { |
|
288 | - $unite = array(); |
|
289 | - $dix = array(); |
|
290 | - $cent = array(); |
|
291 | - if(empty($devise1)) $dev1='euros'; |
|
292 | - else $dev1=$devise1; |
|
293 | - if(empty($devise2)) $dev2='centimes'; |
|
294 | - else $dev2=$devise2; |
|
295 | - $valeur_entiere=intval($montant); |
|
296 | - $valeur_decimal=intval(round($montant-intval($montant), 2)*100); |
|
297 | - $dix_c=intval($valeur_decimal%100/10); |
|
298 | - $cent_c=intval($valeur_decimal%1000/100); |
|
299 | - $unite[1]=$valeur_entiere%10; |
|
300 | - $dix[1]=intval($valeur_entiere%100/10); |
|
301 | - $cent[1]=intval($valeur_entiere%1000/100); |
|
302 | - $unite[2]=intval($valeur_entiere%10000/1000); |
|
303 | - $dix[2]=intval($valeur_entiere%100000/10000); |
|
304 | - $cent[2]=intval($valeur_entiere%1000000/100000); |
|
305 | - $unite[3]=intval($valeur_entiere%10000000/1000000); |
|
306 | - $dix[3]=intval($valeur_entiere%100000000/10000000); |
|
307 | - $cent[3]=intval($valeur_entiere%1000000000/100000000); |
|
308 | - $chif=array('', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix sept', 'dix huit', 'dix neuf'); |
|
309 | - $secon_c=''; |
|
310 | - $trio_c=''; |
|
311 | - for($i=1; $i<=3; $i++){ |
|
312 | - $prim[$i]=''; |
|
313 | - $secon[$i]=''; |
|
314 | - $trio[$i]=''; |
|
315 | - if($dix[$i]==0){ |
|
316 | - $secon[$i]=''; |
|
317 | - $prim[$i]=$chif[$unite[$i]]; |
|
318 | - } |
|
319 | - else if($dix[$i]==1){ |
|
320 | - $secon[$i]=''; |
|
321 | - $prim[$i]=$chif[($unite[$i]+10)]; |
|
322 | - } |
|
323 | - else if($dix[$i]==2){ |
|
324 | - if($unite[$i]==1){ |
|
325 | - $secon[$i]='vingt et'; |
|
326 | - $prim[$i]=$chif[$unite[$i]]; |
|
327 | - } |
|
328 | - else { |
|
329 | - $secon[$i]='vingt'; |
|
330 | - $prim[$i]=$chif[$unite[$i]]; |
|
331 | - } |
|
332 | - } |
|
333 | - else if($dix[$i]==3){ |
|
334 | - if($unite[$i]==1){ |
|
335 | - $secon[$i]='trente et'; |
|
336 | - $prim[$i]=$chif[$unite[$i]]; |
|
337 | - } |
|
338 | - else { |
|
339 | - $secon[$i]='trente'; |
|
340 | - $prim[$i]=$chif[$unite[$i]]; |
|
341 | - } |
|
342 | - } |
|
343 | - else if($dix[$i]==4){ |
|
344 | - if($unite[$i]==1){ |
|
345 | - $secon[$i]='quarante et'; |
|
346 | - $prim[$i]=$chif[$unite[$i]]; |
|
347 | - } |
|
348 | - else { |
|
349 | - $secon[$i]='quarante'; |
|
350 | - $prim[$i]=$chif[$unite[$i]]; |
|
351 | - } |
|
352 | - } |
|
353 | - else if($dix[$i]==5){ |
|
354 | - if($unite[$i]==1){ |
|
355 | - $secon[$i]='cinquante et'; |
|
356 | - $prim[$i]=$chif[$unite[$i]]; |
|
357 | - } |
|
358 | - else { |
|
359 | - $secon[$i]='cinquante'; |
|
360 | - $prim[$i]=$chif[$unite[$i]]; |
|
361 | - } |
|
362 | - } |
|
363 | - else if($dix[$i]==6){ |
|
364 | - if($unite[$i]==1){ |
|
365 | - $secon[$i]='soixante et'; |
|
366 | - $prim[$i]=$chif[$unite[$i]]; |
|
367 | - } |
|
368 | - else { |
|
369 | - $secon[$i]='soixante'; |
|
370 | - $prim[$i]=$chif[$unite[$i]]; |
|
371 | - } |
|
372 | - } |
|
373 | - else if($dix[$i]==7){ |
|
374 | - if($unite[$i]==1){ |
|
375 | - $secon[$i]='soixante et'; |
|
376 | - $prim[$i]=$chif[$unite[$i]+10]; |
|
377 | - } |
|
378 | - else { |
|
379 | - $secon[$i]='soixante'; |
|
380 | - $prim[$i]=$chif[$unite[$i]+10]; |
|
381 | - } |
|
382 | - } |
|
383 | - else if($dix[$i]==8){ |
|
384 | - if($unite[$i]==1){ |
|
385 | - $secon[$i]='quatre-vingts et'; |
|
386 | - $prim[$i]=$chif[$unite[$i]]; |
|
387 | - } |
|
388 | - else { |
|
389 | - $secon[$i]='quatre-vingt'; |
|
390 | - $prim[$i]=$chif[$unite[$i]]; |
|
391 | - } |
|
392 | - } |
|
393 | - else if($dix[$i]==9){ |
|
394 | - if($unite[$i]==1){ |
|
395 | - $secon[$i]='quatre-vingts et'; |
|
396 | - $prim[$i]=$chif[$unite[$i]+10]; |
|
397 | - } |
|
398 | - else { |
|
399 | - $secon[$i]='quatre-vingts'; |
|
400 | - $prim[$i]=$chif[$unite[$i]+10]; |
|
401 | - } |
|
402 | - } |
|
403 | - if($cent[$i]==1) $trio[$i]='cent'; |
|
404 | - else if($cent[$i]!=0 || $cent[$i]!='') $trio[$i]=$chif[$cent[$i]] .' cents'; |
|
405 | - } |
|
406 | - |
|
407 | - |
|
408 | - $chif2=array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix'); |
|
409 | - $secon_c=$chif2[$dix_c]; |
|
410 | - if($cent_c==1) $trio_c='cent'; |
|
411 | - else if($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents'; |
|
412 | - |
|
413 | - if(($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1)) |
|
414 | - $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' million '; |
|
415 | - else if(($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!='')) |
|
416 | - $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions '; |
|
417 | - else |
|
418 | - $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]; |
|
419 | - |
|
420 | - if(($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1)) |
|
421 | - $somme = $somme.' mille '; |
|
422 | - else if(($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!='')) |
|
423 | - $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles '; |
|
424 | - else |
|
425 | - $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]; |
|
426 | - |
|
427 | - $somme = $somme. $trio[1]. ' ' .$secon[1]. ' ' . $prim[1]; |
|
428 | - |
|
429 | - $somme = $somme. ' '. $dev1 .' ' ; |
|
430 | - |
|
431 | - if(($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c=='')) |
|
432 | - return $somme. ' et zéro '. $dev2; |
|
433 | - else |
|
434 | - return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2; |
|
435 | - } |
|
161 | + // Define contents |
|
162 | + $donmodel=DOL_DOCUMENT_ROOT ."/core/modules/dons/html_cerfafr.html"; |
|
163 | + $form = implode('', file($donmodel)); |
|
164 | + $form = str_replace('__REF__',$don->id,$form); |
|
165 | + $form = str_replace('__DATE__',dol_print_date($don->date,'day',false,$outputlangs),$form); |
|
166 | + //$form = str_replace('__IP__',$user->ip,$form); // TODO $user->ip not exist |
|
167 | + $form = str_replace('__AMOUNT__', price($don->amount), $form); |
|
168 | + $form = str_replace('__AMOUNTLETTERS__', $this->amountToLetters($don->amount),$form); |
|
169 | + $form = str_replace('__CURRENCY__',$outputlangs->transnoentitiesnoconv("Currency".$currency),$form); |
|
170 | + $form = str_replace('__CURRENCYCODE__',$conf->currency,$form); |
|
171 | + $form = str_replace('__MAIN_INFO_SOCIETE_NOM__',$mysoc->name,$form); |
|
172 | + $form = str_replace('__MAIN_INFO_SOCIETE_ADDRESS__',$mysoc->address,$form); |
|
173 | + $form = str_replace('__MAIN_INFO_SOCIETE_ZIP__',$mysoc->zip,$form); |
|
174 | + $form = str_replace('__MAIN_INFO_SOCIETE_TOWN__',$mysoc->town,$form); |
|
175 | + $form = str_replace('__MAIN_INFO_SOCIETE_OBJECT__',$mysoc->object,$form); |
|
176 | + $form = str_replace('__DONATOR_FIRSTNAME__',$don->firstname,$form); |
|
177 | + $form = str_replace('__DONATOR_LASTNAME__',$don->lastname,$form); |
|
178 | + $form = str_replace('__DONATOR_SOCIETE__',$don->societe,$form); |
|
179 | + $form = str_replace('__DONATOR_STATUT__',$don->statut,$form); |
|
180 | + $form = str_replace('__DONATOR_ADDRESS__',$don->address,$form); |
|
181 | + $form = str_replace('__DONATOR_ZIP__',$don->zip,$form); |
|
182 | + $form = str_replace('__DONATOR_TOWN__',$don->town,$form); |
|
183 | + $form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode,$form); |
|
184 | + $form = str_replace('__NOW__',dol_print_date($now,'day',false,$outputlangs),$form); |
|
185 | + $form = str_replace('__DonationRef__',$outputlangs->trans("DonationRef"),$form); |
|
186 | + $form = str_replace('__DonationTitle__',$outputlangs->trans("DonationTitle"),$form); |
|
187 | + $form = str_replace('__DonationReceipt__',$outputlangs->trans("DonationReceipt"),$form); |
|
188 | + $form = str_replace('__DonationRecipient__',$outputlangs->trans("DonationRecipient"),$form); |
|
189 | + $form = str_replace('__DonationDatePayment__',$outputlangs->trans("DonationDatePayment"),$form); |
|
190 | + $form = str_replace('__PaymentMode__',$outputlangs->trans("PaymentMode"),$form); |
|
191 | + // $form = str_replace('__CodeDon__',$CodeDon,$form); |
|
192 | + $form = str_replace('__Name__',$outputlangs->trans("Name"),$form); |
|
193 | + $form = str_replace('__Address__',$outputlangs->trans("Address"),$form); |
|
194 | + $form = str_replace('__Zip__',$outputlangs->trans("Zip"),$form); |
|
195 | + $form = str_replace('__Town__',$outputlangs->trans("Town"),$form); |
|
196 | + $form = str_replace('__Object__',$outputlangs->trans("Object"),$form); |
|
197 | + $form = str_replace('__Donor__',$outputlangs->trans("Donor"),$form); |
|
198 | + $form = str_replace('__Date__',$outputlangs->trans("Date"),$form); |
|
199 | + $form = str_replace('__Signature__',$outputlangs->trans("Signature"),$form); |
|
200 | + $form = str_replace('__Message__',$outputlangs->trans("Message"),$form); |
|
201 | + $form = str_replace('__IConfirmDonationReception__',$outputlangs->trans("IConfirmDonationReception"),$form); |
|
202 | + $form = str_replace('__DonationMessage__',$conf->global->DONATION_MESSAGE,$form); |
|
203 | + |
|
204 | + $form = str_replace('__ModePaiement__', $ModePaiement,$form); |
|
205 | + |
|
206 | + $frencharticle=''; |
|
207 | + if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencharticle='<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>'; |
|
208 | + $form = str_replace('__FrenchArticle__',$frencharticle,$form); |
|
209 | + |
|
210 | + $frencheligibility=''; |
|
211 | + if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencheligibility='Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :'; |
|
212 | + $form = str_replace('__FrenchEligibility__',$frencheligibility,$form); |
|
213 | + |
|
214 | + $art200=''; |
|
215 | + if (preg_match('/fr/i',$outputlangs->defaultlang)) { |
|
216 | + if ($conf->global->DONATION_ART200 >= 1) |
|
217 | + { |
|
218 | + $art200='<input type="checkbox" disabled="true" checked="checked" >200 du CGI'; |
|
219 | + } |
|
220 | + else |
|
221 | + { |
|
222 | + $art200='<input type="checkbox" disabled="true">200 du CGI'; |
|
223 | + } |
|
224 | + } |
|
225 | + $form = str_replace('__ARTICLE200__',$art200,$form); |
|
226 | + |
|
227 | + $art238=''; |
|
228 | + if (preg_match('/fr/i',$outputlangs->defaultlang)) { |
|
229 | + if ($conf->global->DONATION_ART238 >= 1) |
|
230 | + { |
|
231 | + $art238='<input type="checkbox" disabled="true" checked="checked" >238 bis du CGI'; |
|
232 | + } |
|
233 | + else |
|
234 | + { |
|
235 | + $art238='<input type="checkbox" disabled="true">238 bis du CGI'; |
|
236 | + } |
|
237 | + } |
|
238 | + $form = str_replace('__ARTICLE238__',$art238,$form); |
|
239 | + |
|
240 | + $art885=''; |
|
241 | + if (preg_match('/fr/i',$outputlangs->defaultlang)) { |
|
242 | + if ($conf->global->DONATION_ART885 >= 1) |
|
243 | + { |
|
244 | + $art885='<input type="checkbox" disabled="true" checked="checked" >885-0 V bis du CGI'; |
|
245 | + } |
|
246 | + else |
|
247 | + { |
|
248 | + $art885='<input type="checkbox" disabled="true">885-0 V bis du CGI'; |
|
249 | + } |
|
250 | + } |
|
251 | + $form = str_replace('__ARTICLE885__',$art885,$form); |
|
252 | + |
|
253 | + // Save file on disk |
|
254 | + dol_syslog("html_cerfafr::write_file $file"); |
|
255 | + $handle=fopen($file,"w"); |
|
256 | + fwrite($handle,$form); |
|
257 | + fclose($handle); |
|
258 | + if (! empty($conf->global->MAIN_UMASK)) |
|
259 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
260 | + |
|
261 | + $this->result = array('fullpath'=>$file); |
|
262 | + |
|
263 | + return 1; |
|
264 | + } |
|
265 | + else |
|
266 | + { |
|
267 | + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
268 | + return 0; |
|
269 | + } |
|
270 | + } |
|
271 | + else |
|
272 | + { |
|
273 | + $this->error=$langs->trans("ErrorConstantNotDefined","DON_OUTPUTDIR"); |
|
274 | + return 0; |
|
275 | + } |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * numbers to letters |
|
280 | + * |
|
281 | + * @param mixed $montant amount |
|
282 | + * @param mixed $devise1 devise 1 ex: euro |
|
283 | + * @param mixed $devise2 devise 2 ex: centimes |
|
284 | + * @return string amount in letters |
|
285 | + */ |
|
286 | + private function amountToLetters($montant, $devise1='', $devise2='') |
|
287 | + { |
|
288 | + $unite = array(); |
|
289 | + $dix = array(); |
|
290 | + $cent = array(); |
|
291 | + if(empty($devise1)) $dev1='euros'; |
|
292 | + else $dev1=$devise1; |
|
293 | + if(empty($devise2)) $dev2='centimes'; |
|
294 | + else $dev2=$devise2; |
|
295 | + $valeur_entiere=intval($montant); |
|
296 | + $valeur_decimal=intval(round($montant-intval($montant), 2)*100); |
|
297 | + $dix_c=intval($valeur_decimal%100/10); |
|
298 | + $cent_c=intval($valeur_decimal%1000/100); |
|
299 | + $unite[1]=$valeur_entiere%10; |
|
300 | + $dix[1]=intval($valeur_entiere%100/10); |
|
301 | + $cent[1]=intval($valeur_entiere%1000/100); |
|
302 | + $unite[2]=intval($valeur_entiere%10000/1000); |
|
303 | + $dix[2]=intval($valeur_entiere%100000/10000); |
|
304 | + $cent[2]=intval($valeur_entiere%1000000/100000); |
|
305 | + $unite[3]=intval($valeur_entiere%10000000/1000000); |
|
306 | + $dix[3]=intval($valeur_entiere%100000000/10000000); |
|
307 | + $cent[3]=intval($valeur_entiere%1000000000/100000000); |
|
308 | + $chif=array('', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix sept', 'dix huit', 'dix neuf'); |
|
309 | + $secon_c=''; |
|
310 | + $trio_c=''; |
|
311 | + for($i=1; $i<=3; $i++){ |
|
312 | + $prim[$i]=''; |
|
313 | + $secon[$i]=''; |
|
314 | + $trio[$i]=''; |
|
315 | + if($dix[$i]==0){ |
|
316 | + $secon[$i]=''; |
|
317 | + $prim[$i]=$chif[$unite[$i]]; |
|
318 | + } |
|
319 | + else if($dix[$i]==1){ |
|
320 | + $secon[$i]=''; |
|
321 | + $prim[$i]=$chif[($unite[$i]+10)]; |
|
322 | + } |
|
323 | + else if($dix[$i]==2){ |
|
324 | + if($unite[$i]==1){ |
|
325 | + $secon[$i]='vingt et'; |
|
326 | + $prim[$i]=$chif[$unite[$i]]; |
|
327 | + } |
|
328 | + else { |
|
329 | + $secon[$i]='vingt'; |
|
330 | + $prim[$i]=$chif[$unite[$i]]; |
|
331 | + } |
|
332 | + } |
|
333 | + else if($dix[$i]==3){ |
|
334 | + if($unite[$i]==1){ |
|
335 | + $secon[$i]='trente et'; |
|
336 | + $prim[$i]=$chif[$unite[$i]]; |
|
337 | + } |
|
338 | + else { |
|
339 | + $secon[$i]='trente'; |
|
340 | + $prim[$i]=$chif[$unite[$i]]; |
|
341 | + } |
|
342 | + } |
|
343 | + else if($dix[$i]==4){ |
|
344 | + if($unite[$i]==1){ |
|
345 | + $secon[$i]='quarante et'; |
|
346 | + $prim[$i]=$chif[$unite[$i]]; |
|
347 | + } |
|
348 | + else { |
|
349 | + $secon[$i]='quarante'; |
|
350 | + $prim[$i]=$chif[$unite[$i]]; |
|
351 | + } |
|
352 | + } |
|
353 | + else if($dix[$i]==5){ |
|
354 | + if($unite[$i]==1){ |
|
355 | + $secon[$i]='cinquante et'; |
|
356 | + $prim[$i]=$chif[$unite[$i]]; |
|
357 | + } |
|
358 | + else { |
|
359 | + $secon[$i]='cinquante'; |
|
360 | + $prim[$i]=$chif[$unite[$i]]; |
|
361 | + } |
|
362 | + } |
|
363 | + else if($dix[$i]==6){ |
|
364 | + if($unite[$i]==1){ |
|
365 | + $secon[$i]='soixante et'; |
|
366 | + $prim[$i]=$chif[$unite[$i]]; |
|
367 | + } |
|
368 | + else { |
|
369 | + $secon[$i]='soixante'; |
|
370 | + $prim[$i]=$chif[$unite[$i]]; |
|
371 | + } |
|
372 | + } |
|
373 | + else if($dix[$i]==7){ |
|
374 | + if($unite[$i]==1){ |
|
375 | + $secon[$i]='soixante et'; |
|
376 | + $prim[$i]=$chif[$unite[$i]+10]; |
|
377 | + } |
|
378 | + else { |
|
379 | + $secon[$i]='soixante'; |
|
380 | + $prim[$i]=$chif[$unite[$i]+10]; |
|
381 | + } |
|
382 | + } |
|
383 | + else if($dix[$i]==8){ |
|
384 | + if($unite[$i]==1){ |
|
385 | + $secon[$i]='quatre-vingts et'; |
|
386 | + $prim[$i]=$chif[$unite[$i]]; |
|
387 | + } |
|
388 | + else { |
|
389 | + $secon[$i]='quatre-vingt'; |
|
390 | + $prim[$i]=$chif[$unite[$i]]; |
|
391 | + } |
|
392 | + } |
|
393 | + else if($dix[$i]==9){ |
|
394 | + if($unite[$i]==1){ |
|
395 | + $secon[$i]='quatre-vingts et'; |
|
396 | + $prim[$i]=$chif[$unite[$i]+10]; |
|
397 | + } |
|
398 | + else { |
|
399 | + $secon[$i]='quatre-vingts'; |
|
400 | + $prim[$i]=$chif[$unite[$i]+10]; |
|
401 | + } |
|
402 | + } |
|
403 | + if($cent[$i]==1) $trio[$i]='cent'; |
|
404 | + else if($cent[$i]!=0 || $cent[$i]!='') $trio[$i]=$chif[$cent[$i]] .' cents'; |
|
405 | + } |
|
406 | + |
|
407 | + |
|
408 | + $chif2=array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix'); |
|
409 | + $secon_c=$chif2[$dix_c]; |
|
410 | + if($cent_c==1) $trio_c='cent'; |
|
411 | + else if($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents'; |
|
412 | + |
|
413 | + if(($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1)) |
|
414 | + $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' million '; |
|
415 | + else if(($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!='')) |
|
416 | + $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions '; |
|
417 | + else |
|
418 | + $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]; |
|
419 | + |
|
420 | + if(($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1)) |
|
421 | + $somme = $somme.' mille '; |
|
422 | + else if(($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!='')) |
|
423 | + $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles '; |
|
424 | + else |
|
425 | + $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]; |
|
426 | + |
|
427 | + $somme = $somme. $trio[1]. ' ' .$secon[1]. ' ' . $prim[1]; |
|
428 | + |
|
429 | + $somme = $somme. ' '. $dev1 .' ' ; |
|
430 | + |
|
431 | + if(($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c=='')) |
|
432 | + return $somme. ' et zéro '. $dev2; |
|
433 | + else |
|
434 | + return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2; |
|
435 | + } |
|
436 | 436 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | function __construct($db) |
44 | 44 | { |
45 | - global $conf,$langs; |
|
45 | + global $conf, $langs; |
|
46 | 46 | |
47 | 47 | $this->db = $db; |
48 | 48 | $this->name = "cerfafr"; |
@@ -73,49 +73,49 @@ discard block |
||
73 | 73 | * @param string $currency Currency code |
74 | 74 | * @return int >0 if OK, <0 if KO |
75 | 75 | */ |
76 | - function write_file($don,$outputlangs,$currency='') |
|
76 | + function write_file($don, $outputlangs, $currency = '') |
|
77 | 77 | { |
78 | 78 | // phpcs:enable |
79 | - global $user,$conf,$langs,$mysoc; |
|
79 | + global $user, $conf, $langs, $mysoc; |
|
80 | 80 | |
81 | - $now=dol_now(); |
|
82 | - $id = (! is_object($don)?$don:''); |
|
81 | + $now = dol_now(); |
|
82 | + $id = (!is_object($don) ? $don : ''); |
|
83 | 83 | |
84 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
84 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
85 | 85 | |
86 | 86 | // Load traductions files requiredby by page |
87 | 87 | $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "donations")); |
88 | 88 | |
89 | 89 | $currency = !empty($currency) ? $currency : $conf->currency; |
90 | 90 | |
91 | - if (! empty($conf->don->dir_output)) |
|
91 | + if (!empty($conf->don->dir_output)) |
|
92 | 92 | { |
93 | 93 | // Definition of the object don (for upward compatibility) |
94 | - if (! is_object($don)) |
|
94 | + if (!is_object($don)) |
|
95 | 95 | { |
96 | 96 | $don = new Don($this->db); |
97 | - $ret=$don->fetch($id); |
|
98 | - $id=$don->id; |
|
97 | + $ret = $don->fetch($id); |
|
98 | + $id = $don->id; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | // Definition of $dir and $file |
102 | - if (! empty($don->specimen)) |
|
102 | + if (!empty($don->specimen)) |
|
103 | 103 | { |
104 | 104 | $dir = $conf->don->dir_output; |
105 | - $file = $dir . "/SPECIMEN.html"; |
|
105 | + $file = $dir."/SPECIMEN.html"; |
|
106 | 106 | } |
107 | 107 | else |
108 | 108 | { |
109 | 109 | $donref = dol_sanitizeFileName($don->ref); |
110 | - $dir = $conf->don->dir_output . "/" . $donref; |
|
111 | - $file = $dir . "/" . $donref . ".html"; |
|
110 | + $dir = $conf->don->dir_output."/".$donref; |
|
111 | + $file = $dir."/".$donref.".html"; |
|
112 | 112 | } |
113 | 113 | |
114 | - if (! file_exists($dir)) |
|
114 | + if (!file_exists($dir)) |
|
115 | 115 | { |
116 | 116 | if (dol_mkdir($dir) < 0) |
117 | 117 | { |
118 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
118 | + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); |
|
119 | 119 | return -1; |
120 | 120 | } |
121 | 121 | } |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | } |
134 | 134 | else $paymentmode = ''; |
135 | 135 | |
136 | - if ($don->modepaymentcode=='CHQ'){ |
|
136 | + if ($don->modepaymentcode == 'CHQ') { |
|
137 | 137 | $ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox" disabled="true" checked="checked"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>'; |
138 | 138 | } |
139 | - else if ($don->modepaymentcode=='LIQ'){ |
|
139 | + else if ($don->modepaymentcode == 'LIQ') { |
|
140 | 140 | $ModePaiement = '<td width="25%"><input type="checkbox" checked="checked"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>'; |
141 | 141 | } |
142 | - else if ($don->modepaymentcode=='VIR' || $don->modepaymentcode=='PRE' || $don->modepaymentcode=='CB'){ |
|
142 | + else if ($don->modepaymentcode == 'VIR' || $don->modepaymentcode == 'PRE' || $don->modepaymentcode == 'CB') { |
|
143 | 143 | $ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox" checked="checked"> Virement, prélèvement, carte bancaire</td>'; |
144 | 144 | } |
145 | 145 | else |
@@ -159,103 +159,103 @@ discard block |
||
159 | 159 | */ |
160 | 160 | |
161 | 161 | // Define contents |
162 | - $donmodel=DOL_DOCUMENT_ROOT ."/core/modules/dons/html_cerfafr.html"; |
|
162 | + $donmodel = DOL_DOCUMENT_ROOT."/core/modules/dons/html_cerfafr.html"; |
|
163 | 163 | $form = implode('', file($donmodel)); |
164 | - $form = str_replace('__REF__',$don->id,$form); |
|
165 | - $form = str_replace('__DATE__',dol_print_date($don->date,'day',false,$outputlangs),$form); |
|
164 | + $form = str_replace('__REF__', $don->id, $form); |
|
165 | + $form = str_replace('__DATE__', dol_print_date($don->date, 'day', false, $outputlangs), $form); |
|
166 | 166 | //$form = str_replace('__IP__',$user->ip,$form); // TODO $user->ip not exist |
167 | 167 | $form = str_replace('__AMOUNT__', price($don->amount), $form); |
168 | - $form = str_replace('__AMOUNTLETTERS__', $this->amountToLetters($don->amount),$form); |
|
169 | - $form = str_replace('__CURRENCY__',$outputlangs->transnoentitiesnoconv("Currency".$currency),$form); |
|
170 | - $form = str_replace('__CURRENCYCODE__',$conf->currency,$form); |
|
171 | - $form = str_replace('__MAIN_INFO_SOCIETE_NOM__',$mysoc->name,$form); |
|
172 | - $form = str_replace('__MAIN_INFO_SOCIETE_ADDRESS__',$mysoc->address,$form); |
|
173 | - $form = str_replace('__MAIN_INFO_SOCIETE_ZIP__',$mysoc->zip,$form); |
|
174 | - $form = str_replace('__MAIN_INFO_SOCIETE_TOWN__',$mysoc->town,$form); |
|
175 | - $form = str_replace('__MAIN_INFO_SOCIETE_OBJECT__',$mysoc->object,$form); |
|
176 | - $form = str_replace('__DONATOR_FIRSTNAME__',$don->firstname,$form); |
|
177 | - $form = str_replace('__DONATOR_LASTNAME__',$don->lastname,$form); |
|
178 | - $form = str_replace('__DONATOR_SOCIETE__',$don->societe,$form); |
|
179 | - $form = str_replace('__DONATOR_STATUT__',$don->statut,$form); |
|
180 | - $form = str_replace('__DONATOR_ADDRESS__',$don->address,$form); |
|
181 | - $form = str_replace('__DONATOR_ZIP__',$don->zip,$form); |
|
182 | - $form = str_replace('__DONATOR_TOWN__',$don->town,$form); |
|
183 | - $form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode,$form); |
|
184 | - $form = str_replace('__NOW__',dol_print_date($now,'day',false,$outputlangs),$form); |
|
185 | - $form = str_replace('__DonationRef__',$outputlangs->trans("DonationRef"),$form); |
|
186 | - $form = str_replace('__DonationTitle__',$outputlangs->trans("DonationTitle"),$form); |
|
187 | - $form = str_replace('__DonationReceipt__',$outputlangs->trans("DonationReceipt"),$form); |
|
188 | - $form = str_replace('__DonationRecipient__',$outputlangs->trans("DonationRecipient"),$form); |
|
189 | - $form = str_replace('__DonationDatePayment__',$outputlangs->trans("DonationDatePayment"),$form); |
|
190 | - $form = str_replace('__PaymentMode__',$outputlangs->trans("PaymentMode"),$form); |
|
168 | + $form = str_replace('__AMOUNTLETTERS__', $this->amountToLetters($don->amount), $form); |
|
169 | + $form = str_replace('__CURRENCY__', $outputlangs->transnoentitiesnoconv("Currency".$currency), $form); |
|
170 | + $form = str_replace('__CURRENCYCODE__', $conf->currency, $form); |
|
171 | + $form = str_replace('__MAIN_INFO_SOCIETE_NOM__', $mysoc->name, $form); |
|
172 | + $form = str_replace('__MAIN_INFO_SOCIETE_ADDRESS__', $mysoc->address, $form); |
|
173 | + $form = str_replace('__MAIN_INFO_SOCIETE_ZIP__', $mysoc->zip, $form); |
|
174 | + $form = str_replace('__MAIN_INFO_SOCIETE_TOWN__', $mysoc->town, $form); |
|
175 | + $form = str_replace('__MAIN_INFO_SOCIETE_OBJECT__', $mysoc->object, $form); |
|
176 | + $form = str_replace('__DONATOR_FIRSTNAME__', $don->firstname, $form); |
|
177 | + $form = str_replace('__DONATOR_LASTNAME__', $don->lastname, $form); |
|
178 | + $form = str_replace('__DONATOR_SOCIETE__', $don->societe, $form); |
|
179 | + $form = str_replace('__DONATOR_STATUT__', $don->statut, $form); |
|
180 | + $form = str_replace('__DONATOR_ADDRESS__', $don->address, $form); |
|
181 | + $form = str_replace('__DONATOR_ZIP__', $don->zip, $form); |
|
182 | + $form = str_replace('__DONATOR_TOWN__', $don->town, $form); |
|
183 | + $form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode, $form); |
|
184 | + $form = str_replace('__NOW__', dol_print_date($now, 'day', false, $outputlangs), $form); |
|
185 | + $form = str_replace('__DonationRef__', $outputlangs->trans("DonationRef"), $form); |
|
186 | + $form = str_replace('__DonationTitle__', $outputlangs->trans("DonationTitle"), $form); |
|
187 | + $form = str_replace('__DonationReceipt__', $outputlangs->trans("DonationReceipt"), $form); |
|
188 | + $form = str_replace('__DonationRecipient__', $outputlangs->trans("DonationRecipient"), $form); |
|
189 | + $form = str_replace('__DonationDatePayment__', $outputlangs->trans("DonationDatePayment"), $form); |
|
190 | + $form = str_replace('__PaymentMode__', $outputlangs->trans("PaymentMode"), $form); |
|
191 | 191 | // $form = str_replace('__CodeDon__',$CodeDon,$form); |
192 | - $form = str_replace('__Name__',$outputlangs->trans("Name"),$form); |
|
193 | - $form = str_replace('__Address__',$outputlangs->trans("Address"),$form); |
|
194 | - $form = str_replace('__Zip__',$outputlangs->trans("Zip"),$form); |
|
195 | - $form = str_replace('__Town__',$outputlangs->trans("Town"),$form); |
|
196 | - $form = str_replace('__Object__',$outputlangs->trans("Object"),$form); |
|
197 | - $form = str_replace('__Donor__',$outputlangs->trans("Donor"),$form); |
|
198 | - $form = str_replace('__Date__',$outputlangs->trans("Date"),$form); |
|
199 | - $form = str_replace('__Signature__',$outputlangs->trans("Signature"),$form); |
|
200 | - $form = str_replace('__Message__',$outputlangs->trans("Message"),$form); |
|
201 | - $form = str_replace('__IConfirmDonationReception__',$outputlangs->trans("IConfirmDonationReception"),$form); |
|
202 | - $form = str_replace('__DonationMessage__',$conf->global->DONATION_MESSAGE,$form); |
|
203 | - |
|
204 | - $form = str_replace('__ModePaiement__', $ModePaiement,$form); |
|
205 | - |
|
206 | - $frencharticle=''; |
|
207 | - if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencharticle='<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>'; |
|
208 | - $form = str_replace('__FrenchArticle__',$frencharticle,$form); |
|
209 | - |
|
210 | - $frencheligibility=''; |
|
211 | - if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencheligibility='Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :'; |
|
212 | - $form = str_replace('__FrenchEligibility__',$frencheligibility,$form); |
|
213 | - |
|
214 | - $art200=''; |
|
215 | - if (preg_match('/fr/i',$outputlangs->defaultlang)) { |
|
192 | + $form = str_replace('__Name__', $outputlangs->trans("Name"), $form); |
|
193 | + $form = str_replace('__Address__', $outputlangs->trans("Address"), $form); |
|
194 | + $form = str_replace('__Zip__', $outputlangs->trans("Zip"), $form); |
|
195 | + $form = str_replace('__Town__', $outputlangs->trans("Town"), $form); |
|
196 | + $form = str_replace('__Object__', $outputlangs->trans("Object"), $form); |
|
197 | + $form = str_replace('__Donor__', $outputlangs->trans("Donor"), $form); |
|
198 | + $form = str_replace('__Date__', $outputlangs->trans("Date"), $form); |
|
199 | + $form = str_replace('__Signature__', $outputlangs->trans("Signature"), $form); |
|
200 | + $form = str_replace('__Message__', $outputlangs->trans("Message"), $form); |
|
201 | + $form = str_replace('__IConfirmDonationReception__', $outputlangs->trans("IConfirmDonationReception"), $form); |
|
202 | + $form = str_replace('__DonationMessage__', $conf->global->DONATION_MESSAGE, $form); |
|
203 | + |
|
204 | + $form = str_replace('__ModePaiement__', $ModePaiement, $form); |
|
205 | + |
|
206 | + $frencharticle = ''; |
|
207 | + if (preg_match('/fr/i', $outputlangs->defaultlang)) $frencharticle = '<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>'; |
|
208 | + $form = str_replace('__FrenchArticle__', $frencharticle, $form); |
|
209 | + |
|
210 | + $frencheligibility = ''; |
|
211 | + if (preg_match('/fr/i', $outputlangs->defaultlang)) $frencheligibility = 'Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :'; |
|
212 | + $form = str_replace('__FrenchEligibility__', $frencheligibility, $form); |
|
213 | + |
|
214 | + $art200 = ''; |
|
215 | + if (preg_match('/fr/i', $outputlangs->defaultlang)) { |
|
216 | 216 | if ($conf->global->DONATION_ART200 >= 1) |
217 | 217 | { |
218 | - $art200='<input type="checkbox" disabled="true" checked="checked" >200 du CGI'; |
|
218 | + $art200 = '<input type="checkbox" disabled="true" checked="checked" >200 du CGI'; |
|
219 | 219 | } |
220 | 220 | else |
221 | 221 | { |
222 | - $art200='<input type="checkbox" disabled="true">200 du CGI'; |
|
222 | + $art200 = '<input type="checkbox" disabled="true">200 du CGI'; |
|
223 | 223 | } |
224 | 224 | } |
225 | - $form = str_replace('__ARTICLE200__',$art200,$form); |
|
225 | + $form = str_replace('__ARTICLE200__', $art200, $form); |
|
226 | 226 | |
227 | - $art238=''; |
|
228 | - if (preg_match('/fr/i',$outputlangs->defaultlang)) { |
|
227 | + $art238 = ''; |
|
228 | + if (preg_match('/fr/i', $outputlangs->defaultlang)) { |
|
229 | 229 | if ($conf->global->DONATION_ART238 >= 1) |
230 | 230 | { |
231 | - $art238='<input type="checkbox" disabled="true" checked="checked" >238 bis du CGI'; |
|
231 | + $art238 = '<input type="checkbox" disabled="true" checked="checked" >238 bis du CGI'; |
|
232 | 232 | } |
233 | 233 | else |
234 | 234 | { |
235 | - $art238='<input type="checkbox" disabled="true">238 bis du CGI'; |
|
235 | + $art238 = '<input type="checkbox" disabled="true">238 bis du CGI'; |
|
236 | 236 | } |
237 | 237 | } |
238 | - $form = str_replace('__ARTICLE238__',$art238,$form); |
|
238 | + $form = str_replace('__ARTICLE238__', $art238, $form); |
|
239 | 239 | |
240 | - $art885=''; |
|
241 | - if (preg_match('/fr/i',$outputlangs->defaultlang)) { |
|
240 | + $art885 = ''; |
|
241 | + if (preg_match('/fr/i', $outputlangs->defaultlang)) { |
|
242 | 242 | if ($conf->global->DONATION_ART885 >= 1) |
243 | 243 | { |
244 | - $art885='<input type="checkbox" disabled="true" checked="checked" >885-0 V bis du CGI'; |
|
244 | + $art885 = '<input type="checkbox" disabled="true" checked="checked" >885-0 V bis du CGI'; |
|
245 | 245 | } |
246 | 246 | else |
247 | 247 | { |
248 | - $art885='<input type="checkbox" disabled="true">885-0 V bis du CGI'; |
|
248 | + $art885 = '<input type="checkbox" disabled="true">885-0 V bis du CGI'; |
|
249 | 249 | } |
250 | 250 | } |
251 | - $form = str_replace('__ARTICLE885__',$art885,$form); |
|
251 | + $form = str_replace('__ARTICLE885__', $art885, $form); |
|
252 | 252 | |
253 | 253 | // Save file on disk |
254 | 254 | dol_syslog("html_cerfafr::write_file $file"); |
255 | - $handle=fopen($file,"w"); |
|
256 | - fwrite($handle,$form); |
|
255 | + $handle = fopen($file, "w"); |
|
256 | + fwrite($handle, $form); |
|
257 | 257 | fclose($handle); |
258 | - if (! empty($conf->global->MAIN_UMASK)) |
|
258 | + if (!empty($conf->global->MAIN_UMASK)) |
|
259 | 259 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
260 | 260 | |
261 | 261 | $this->result = array('fullpath'=>$file); |
@@ -264,13 +264,13 @@ discard block |
||
264 | 264 | } |
265 | 265 | else |
266 | 266 | { |
267 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
267 | + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); |
|
268 | 268 | return 0; |
269 | 269 | } |
270 | 270 | } |
271 | 271 | else |
272 | 272 | { |
273 | - $this->error=$langs->trans("ErrorConstantNotDefined","DON_OUTPUTDIR"); |
|
273 | + $this->error = $langs->trans("ErrorConstantNotDefined", "DON_OUTPUTDIR"); |
|
274 | 274 | return 0; |
275 | 275 | } |
276 | 276 | } |
@@ -283,154 +283,154 @@ discard block |
||
283 | 283 | * @param mixed $devise2 devise 2 ex: centimes |
284 | 284 | * @return string amount in letters |
285 | 285 | */ |
286 | - private function amountToLetters($montant, $devise1='', $devise2='') |
|
286 | + private function amountToLetters($montant, $devise1 = '', $devise2 = '') |
|
287 | 287 | { |
288 | 288 | $unite = array(); |
289 | 289 | $dix = array(); |
290 | 290 | $cent = array(); |
291 | - if(empty($devise1)) $dev1='euros'; |
|
292 | - else $dev1=$devise1; |
|
293 | - if(empty($devise2)) $dev2='centimes'; |
|
294 | - else $dev2=$devise2; |
|
295 | - $valeur_entiere=intval($montant); |
|
296 | - $valeur_decimal=intval(round($montant-intval($montant), 2)*100); |
|
297 | - $dix_c=intval($valeur_decimal%100/10); |
|
298 | - $cent_c=intval($valeur_decimal%1000/100); |
|
299 | - $unite[1]=$valeur_entiere%10; |
|
300 | - $dix[1]=intval($valeur_entiere%100/10); |
|
301 | - $cent[1]=intval($valeur_entiere%1000/100); |
|
302 | - $unite[2]=intval($valeur_entiere%10000/1000); |
|
303 | - $dix[2]=intval($valeur_entiere%100000/10000); |
|
304 | - $cent[2]=intval($valeur_entiere%1000000/100000); |
|
305 | - $unite[3]=intval($valeur_entiere%10000000/1000000); |
|
306 | - $dix[3]=intval($valeur_entiere%100000000/10000000); |
|
307 | - $cent[3]=intval($valeur_entiere%1000000000/100000000); |
|
308 | - $chif=array('', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix sept', 'dix huit', 'dix neuf'); |
|
309 | - $secon_c=''; |
|
310 | - $trio_c=''; |
|
311 | - for($i=1; $i<=3; $i++){ |
|
312 | - $prim[$i]=''; |
|
313 | - $secon[$i]=''; |
|
314 | - $trio[$i]=''; |
|
315 | - if($dix[$i]==0){ |
|
316 | - $secon[$i]=''; |
|
317 | - $prim[$i]=$chif[$unite[$i]]; |
|
291 | + if (empty($devise1)) $dev1 = 'euros'; |
|
292 | + else $dev1 = $devise1; |
|
293 | + if (empty($devise2)) $dev2 = 'centimes'; |
|
294 | + else $dev2 = $devise2; |
|
295 | + $valeur_entiere = intval($montant); |
|
296 | + $valeur_decimal = intval(round($montant - intval($montant), 2) * 100); |
|
297 | + $dix_c = intval($valeur_decimal % 100 / 10); |
|
298 | + $cent_c = intval($valeur_decimal % 1000 / 100); |
|
299 | + $unite[1] = $valeur_entiere % 10; |
|
300 | + $dix[1] = intval($valeur_entiere % 100 / 10); |
|
301 | + $cent[1] = intval($valeur_entiere % 1000 / 100); |
|
302 | + $unite[2] = intval($valeur_entiere % 10000 / 1000); |
|
303 | + $dix[2] = intval($valeur_entiere % 100000 / 10000); |
|
304 | + $cent[2] = intval($valeur_entiere % 1000000 / 100000); |
|
305 | + $unite[3] = intval($valeur_entiere % 10000000 / 1000000); |
|
306 | + $dix[3] = intval($valeur_entiere % 100000000 / 10000000); |
|
307 | + $cent[3] = intval($valeur_entiere % 1000000000 / 100000000); |
|
308 | + $chif = array('', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix sept', 'dix huit', 'dix neuf'); |
|
309 | + $secon_c = ''; |
|
310 | + $trio_c = ''; |
|
311 | + for ($i = 1; $i <= 3; $i++) { |
|
312 | + $prim[$i] = ''; |
|
313 | + $secon[$i] = ''; |
|
314 | + $trio[$i] = ''; |
|
315 | + if ($dix[$i] == 0) { |
|
316 | + $secon[$i] = ''; |
|
317 | + $prim[$i] = $chif[$unite[$i]]; |
|
318 | 318 | } |
319 | - else if($dix[$i]==1){ |
|
320 | - $secon[$i]=''; |
|
321 | - $prim[$i]=$chif[($unite[$i]+10)]; |
|
319 | + else if ($dix[$i] == 1) { |
|
320 | + $secon[$i] = ''; |
|
321 | + $prim[$i] = $chif[($unite[$i] + 10)]; |
|
322 | 322 | } |
323 | - else if($dix[$i]==2){ |
|
324 | - if($unite[$i]==1){ |
|
325 | - $secon[$i]='vingt et'; |
|
326 | - $prim[$i]=$chif[$unite[$i]]; |
|
323 | + else if ($dix[$i] == 2) { |
|
324 | + if ($unite[$i] == 1) { |
|
325 | + $secon[$i] = 'vingt et'; |
|
326 | + $prim[$i] = $chif[$unite[$i]]; |
|
327 | 327 | } |
328 | 328 | else { |
329 | - $secon[$i]='vingt'; |
|
330 | - $prim[$i]=$chif[$unite[$i]]; |
|
329 | + $secon[$i] = 'vingt'; |
|
330 | + $prim[$i] = $chif[$unite[$i]]; |
|
331 | 331 | } |
332 | 332 | } |
333 | - else if($dix[$i]==3){ |
|
334 | - if($unite[$i]==1){ |
|
335 | - $secon[$i]='trente et'; |
|
336 | - $prim[$i]=$chif[$unite[$i]]; |
|
333 | + else if ($dix[$i] == 3) { |
|
334 | + if ($unite[$i] == 1) { |
|
335 | + $secon[$i] = 'trente et'; |
|
336 | + $prim[$i] = $chif[$unite[$i]]; |
|
337 | 337 | } |
338 | 338 | else { |
339 | - $secon[$i]='trente'; |
|
340 | - $prim[$i]=$chif[$unite[$i]]; |
|
339 | + $secon[$i] = 'trente'; |
|
340 | + $prim[$i] = $chif[$unite[$i]]; |
|
341 | 341 | } |
342 | 342 | } |
343 | - else if($dix[$i]==4){ |
|
344 | - if($unite[$i]==1){ |
|
345 | - $secon[$i]='quarante et'; |
|
346 | - $prim[$i]=$chif[$unite[$i]]; |
|
343 | + else if ($dix[$i] == 4) { |
|
344 | + if ($unite[$i] == 1) { |
|
345 | + $secon[$i] = 'quarante et'; |
|
346 | + $prim[$i] = $chif[$unite[$i]]; |
|
347 | 347 | } |
348 | 348 | else { |
349 | - $secon[$i]='quarante'; |
|
350 | - $prim[$i]=$chif[$unite[$i]]; |
|
349 | + $secon[$i] = 'quarante'; |
|
350 | + $prim[$i] = $chif[$unite[$i]]; |
|
351 | 351 | } |
352 | 352 | } |
353 | - else if($dix[$i]==5){ |
|
354 | - if($unite[$i]==1){ |
|
355 | - $secon[$i]='cinquante et'; |
|
356 | - $prim[$i]=$chif[$unite[$i]]; |
|
353 | + else if ($dix[$i] == 5) { |
|
354 | + if ($unite[$i] == 1) { |
|
355 | + $secon[$i] = 'cinquante et'; |
|
356 | + $prim[$i] = $chif[$unite[$i]]; |
|
357 | 357 | } |
358 | 358 | else { |
359 | - $secon[$i]='cinquante'; |
|
360 | - $prim[$i]=$chif[$unite[$i]]; |
|
359 | + $secon[$i] = 'cinquante'; |
|
360 | + $prim[$i] = $chif[$unite[$i]]; |
|
361 | 361 | } |
362 | 362 | } |
363 | - else if($dix[$i]==6){ |
|
364 | - if($unite[$i]==1){ |
|
365 | - $secon[$i]='soixante et'; |
|
366 | - $prim[$i]=$chif[$unite[$i]]; |
|
363 | + else if ($dix[$i] == 6) { |
|
364 | + if ($unite[$i] == 1) { |
|
365 | + $secon[$i] = 'soixante et'; |
|
366 | + $prim[$i] = $chif[$unite[$i]]; |
|
367 | 367 | } |
368 | 368 | else { |
369 | - $secon[$i]='soixante'; |
|
370 | - $prim[$i]=$chif[$unite[$i]]; |
|
369 | + $secon[$i] = 'soixante'; |
|
370 | + $prim[$i] = $chif[$unite[$i]]; |
|
371 | 371 | } |
372 | 372 | } |
373 | - else if($dix[$i]==7){ |
|
374 | - if($unite[$i]==1){ |
|
375 | - $secon[$i]='soixante et'; |
|
376 | - $prim[$i]=$chif[$unite[$i]+10]; |
|
373 | + else if ($dix[$i] == 7) { |
|
374 | + if ($unite[$i] == 1) { |
|
375 | + $secon[$i] = 'soixante et'; |
|
376 | + $prim[$i] = $chif[$unite[$i] + 10]; |
|
377 | 377 | } |
378 | 378 | else { |
379 | - $secon[$i]='soixante'; |
|
380 | - $prim[$i]=$chif[$unite[$i]+10]; |
|
379 | + $secon[$i] = 'soixante'; |
|
380 | + $prim[$i] = $chif[$unite[$i] + 10]; |
|
381 | 381 | } |
382 | 382 | } |
383 | - else if($dix[$i]==8){ |
|
384 | - if($unite[$i]==1){ |
|
385 | - $secon[$i]='quatre-vingts et'; |
|
386 | - $prim[$i]=$chif[$unite[$i]]; |
|
383 | + else if ($dix[$i] == 8) { |
|
384 | + if ($unite[$i] == 1) { |
|
385 | + $secon[$i] = 'quatre-vingts et'; |
|
386 | + $prim[$i] = $chif[$unite[$i]]; |
|
387 | 387 | } |
388 | 388 | else { |
389 | - $secon[$i]='quatre-vingt'; |
|
390 | - $prim[$i]=$chif[$unite[$i]]; |
|
389 | + $secon[$i] = 'quatre-vingt'; |
|
390 | + $prim[$i] = $chif[$unite[$i]]; |
|
391 | 391 | } |
392 | 392 | } |
393 | - else if($dix[$i]==9){ |
|
394 | - if($unite[$i]==1){ |
|
395 | - $secon[$i]='quatre-vingts et'; |
|
396 | - $prim[$i]=$chif[$unite[$i]+10]; |
|
393 | + else if ($dix[$i] == 9) { |
|
394 | + if ($unite[$i] == 1) { |
|
395 | + $secon[$i] = 'quatre-vingts et'; |
|
396 | + $prim[$i] = $chif[$unite[$i] + 10]; |
|
397 | 397 | } |
398 | 398 | else { |
399 | - $secon[$i]='quatre-vingts'; |
|
400 | - $prim[$i]=$chif[$unite[$i]+10]; |
|
399 | + $secon[$i] = 'quatre-vingts'; |
|
400 | + $prim[$i] = $chif[$unite[$i] + 10]; |
|
401 | 401 | } |
402 | 402 | } |
403 | - if($cent[$i]==1) $trio[$i]='cent'; |
|
404 | - else if($cent[$i]!=0 || $cent[$i]!='') $trio[$i]=$chif[$cent[$i]] .' cents'; |
|
403 | + if ($cent[$i] == 1) $trio[$i] = 'cent'; |
|
404 | + else if ($cent[$i] != 0 || $cent[$i] != '') $trio[$i] = $chif[$cent[$i]].' cents'; |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
408 | - $chif2=array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix'); |
|
409 | - $secon_c=$chif2[$dix_c]; |
|
410 | - if($cent_c==1) $trio_c='cent'; |
|
411 | - else if($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents'; |
|
408 | + $chif2 = array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix'); |
|
409 | + $secon_c = $chif2[$dix_c]; |
|
410 | + if ($cent_c == 1) $trio_c = 'cent'; |
|
411 | + else if ($cent_c != 0 || $cent_c != '') $trio_c = $chif[$cent_c].' cents'; |
|
412 | 412 | |
413 | - if(($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1)) |
|
414 | - $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' million '; |
|
415 | - else if(($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!='')) |
|
416 | - $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions '; |
|
413 | + if (($cent[3] == 0 || $cent[3] == '') && ($dix[3] == 0 || $dix[3] == '') && ($unite[3] == 1)) |
|
414 | + $somme = $trio[3].' '.$secon[3].' '.$prim[3].' million '; |
|
415 | + else if (($cent[3] != 0 && $cent[3] != '') || ($dix[3] != 0 && $dix[3] != '') || ($unite[3] != 0 && $unite[3] != '')) |
|
416 | + $somme = $trio[3].' '.$secon[3].' '.$prim[3].' millions '; |
|
417 | 417 | else |
418 | - $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]; |
|
418 | + $somme = $trio[3].' '.$secon[3].' '.$prim[3]; |
|
419 | 419 | |
420 | - if(($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1)) |
|
420 | + if (($cent[2] == 0 || $cent[2] == '') && ($dix[2] == 0 || $dix[2] == '') && ($unite[2] == 1)) |
|
421 | 421 | $somme = $somme.' mille '; |
422 | - else if(($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!='')) |
|
423 | - $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles '; |
|
422 | + else if (($cent[2] != 0 && $cent[2] != '') || ($dix[2] != 0 && $dix[2] != '') || ($unite[2] != 0 && $unite[2] != '')) |
|
423 | + $somme = $somme.$trio[2].' '.$secon[2].' '.$prim[2].' milles '; |
|
424 | 424 | else |
425 | - $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]; |
|
425 | + $somme = $somme.$trio[2].' '.$secon[2].' '.$prim[2]; |
|
426 | 426 | |
427 | - $somme = $somme. $trio[1]. ' ' .$secon[1]. ' ' . $prim[1]; |
|
427 | + $somme = $somme.$trio[1].' '.$secon[1].' '.$prim[1]; |
|
428 | 428 | |
429 | - $somme = $somme. ' '. $dev1 .' ' ; |
|
429 | + $somme = $somme.' '.$dev1.' '; |
|
430 | 430 | |
431 | - if(($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c=='')) |
|
432 | - return $somme. ' et zéro '. $dev2; |
|
431 | + if (($cent_c == '0' || $cent_c == '') && ($dix_c == '0' || $dix_c == '')) |
|
432 | + return $somme.' et zéro '.$dev2; |
|
433 | 433 | else |
434 | - return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2; |
|
434 | + return $somme.$trio_c.' '.$secon_c.' '.$dev2; |
|
435 | 435 | } |
436 | 436 | } |
@@ -81,7 +81,9 @@ discard block |
||
81 | 81 | $now=dol_now(); |
82 | 82 | $id = (! is_object($don)?$don:''); |
83 | 83 | |
84 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
84 | + if (! is_object($outputlangs)) { |
|
85 | + $outputlangs=$langs; |
|
86 | + } |
|
85 | 87 | |
86 | 88 | // Load traductions files requiredby by page |
87 | 89 | $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "donations")); |
@@ -103,8 +105,7 @@ discard block |
||
103 | 105 | { |
104 | 106 | $dir = $conf->don->dir_output; |
105 | 107 | $file = $dir . "/SPECIMEN.html"; |
106 | - } |
|
107 | - else |
|
108 | + } else |
|
108 | 109 | { |
109 | 110 | $donref = dol_sanitizeFileName($don->ref); |
110 | 111 | $dir = $conf->don->dir_output . "/" . $donref; |
@@ -130,19 +131,17 @@ discard block |
||
130 | 131 | { |
131 | 132 | $formclass->load_cache_types_paiements(); |
132 | 133 | $paymentmode = $formclass->cache_types_paiements[$don->modepaiementid]['label']; |
134 | + } else { |
|
135 | + $paymentmode = ''; |
|
133 | 136 | } |
134 | - else $paymentmode = ''; |
|
135 | 137 | |
136 | 138 | if ($don->modepaymentcode=='CHQ'){ |
137 | 139 | $ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox" disabled="true" checked="checked"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>'; |
138 | - } |
|
139 | - else if ($don->modepaymentcode=='LIQ'){ |
|
140 | + } else if ($don->modepaymentcode=='LIQ'){ |
|
140 | 141 | $ModePaiement = '<td width="25%"><input type="checkbox" checked="checked"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>'; |
141 | - } |
|
142 | - else if ($don->modepaymentcode=='VIR' || $don->modepaymentcode=='PRE' || $don->modepaymentcode=='CB'){ |
|
142 | + } else if ($don->modepaymentcode=='VIR' || $don->modepaymentcode=='PRE' || $don->modepaymentcode=='CB'){ |
|
143 | 143 | $ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox" checked="checked"> Virement, prélèvement, carte bancaire</td>'; |
144 | - } |
|
145 | - else |
|
144 | + } else |
|
146 | 145 | { |
147 | 146 | $ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>'; |
148 | 147 | } |
@@ -204,11 +203,15 @@ discard block |
||
204 | 203 | $form = str_replace('__ModePaiement__', $ModePaiement,$form); |
205 | 204 | |
206 | 205 | $frencharticle=''; |
207 | - if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencharticle='<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>'; |
|
206 | + if (preg_match('/fr/i',$outputlangs->defaultlang)) { |
|
207 | + $frencharticle='<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>'; |
|
208 | + } |
|
208 | 209 | $form = str_replace('__FrenchArticle__',$frencharticle,$form); |
209 | 210 | |
210 | 211 | $frencheligibility=''; |
211 | - if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencheligibility='Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :'; |
|
212 | + if (preg_match('/fr/i',$outputlangs->defaultlang)) { |
|
213 | + $frencheligibility='Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :'; |
|
214 | + } |
|
212 | 215 | $form = str_replace('__FrenchEligibility__',$frencheligibility,$form); |
213 | 216 | |
214 | 217 | $art200=''; |
@@ -216,8 +219,7 @@ discard block |
||
216 | 219 | if ($conf->global->DONATION_ART200 >= 1) |
217 | 220 | { |
218 | 221 | $art200='<input type="checkbox" disabled="true" checked="checked" >200 du CGI'; |
219 | - } |
|
220 | - else |
|
222 | + } else |
|
221 | 223 | { |
222 | 224 | $art200='<input type="checkbox" disabled="true">200 du CGI'; |
223 | 225 | } |
@@ -229,8 +231,7 @@ discard block |
||
229 | 231 | if ($conf->global->DONATION_ART238 >= 1) |
230 | 232 | { |
231 | 233 | $art238='<input type="checkbox" disabled="true" checked="checked" >238 bis du CGI'; |
232 | - } |
|
233 | - else |
|
234 | + } else |
|
234 | 235 | { |
235 | 236 | $art238='<input type="checkbox" disabled="true">238 bis du CGI'; |
236 | 237 | } |
@@ -242,8 +243,7 @@ discard block |
||
242 | 243 | if ($conf->global->DONATION_ART885 >= 1) |
243 | 244 | { |
244 | 245 | $art885='<input type="checkbox" disabled="true" checked="checked" >885-0 V bis du CGI'; |
245 | - } |
|
246 | - else |
|
246 | + } else |
|
247 | 247 | { |
248 | 248 | $art885='<input type="checkbox" disabled="true">885-0 V bis du CGI'; |
249 | 249 | } |
@@ -255,20 +255,19 @@ discard block |
||
255 | 255 | $handle=fopen($file,"w"); |
256 | 256 | fwrite($handle,$form); |
257 | 257 | fclose($handle); |
258 | - if (! empty($conf->global->MAIN_UMASK)) |
|
259 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
258 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
259 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
260 | + } |
|
260 | 261 | |
261 | 262 | $this->result = array('fullpath'=>$file); |
262 | 263 | |
263 | 264 | return 1; |
264 | - } |
|
265 | - else |
|
265 | + } else |
|
266 | 266 | { |
267 | 267 | $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
268 | 268 | return 0; |
269 | 269 | } |
270 | - } |
|
271 | - else |
|
270 | + } else |
|
272 | 271 | { |
273 | 272 | $this->error=$langs->trans("ErrorConstantNotDefined","DON_OUTPUTDIR"); |
274 | 273 | return 0; |
@@ -288,10 +287,16 @@ discard block |
||
288 | 287 | $unite = array(); |
289 | 288 | $dix = array(); |
290 | 289 | $cent = array(); |
291 | - if(empty($devise1)) $dev1='euros'; |
|
292 | - else $dev1=$devise1; |
|
293 | - if(empty($devise2)) $dev2='centimes'; |
|
294 | - else $dev2=$devise2; |
|
290 | + if(empty($devise1)) { |
|
291 | + $dev1='euros'; |
|
292 | + } else { |
|
293 | + $dev1=$devise1; |
|
294 | + } |
|
295 | + if(empty($devise2)) { |
|
296 | + $dev2='centimes'; |
|
297 | + } else { |
|
298 | + $dev2=$devise2; |
|
299 | + } |
|
295 | 300 | $valeur_entiere=intval($montant); |
296 | 301 | $valeur_decimal=intval(round($montant-intval($montant), 2)*100); |
297 | 302 | $dix_c=intval($valeur_decimal%100/10); |
@@ -315,122 +320,114 @@ discard block |
||
315 | 320 | if($dix[$i]==0){ |
316 | 321 | $secon[$i]=''; |
317 | 322 | $prim[$i]=$chif[$unite[$i]]; |
318 | - } |
|
319 | - else if($dix[$i]==1){ |
|
323 | + } else if($dix[$i]==1){ |
|
320 | 324 | $secon[$i]=''; |
321 | 325 | $prim[$i]=$chif[($unite[$i]+10)]; |
322 | - } |
|
323 | - else if($dix[$i]==2){ |
|
326 | + } else if($dix[$i]==2){ |
|
324 | 327 | if($unite[$i]==1){ |
325 | 328 | $secon[$i]='vingt et'; |
326 | 329 | $prim[$i]=$chif[$unite[$i]]; |
327 | - } |
|
328 | - else { |
|
330 | + } else { |
|
329 | 331 | $secon[$i]='vingt'; |
330 | 332 | $prim[$i]=$chif[$unite[$i]]; |
331 | 333 | } |
332 | - } |
|
333 | - else if($dix[$i]==3){ |
|
334 | + } else if($dix[$i]==3){ |
|
334 | 335 | if($unite[$i]==1){ |
335 | 336 | $secon[$i]='trente et'; |
336 | 337 | $prim[$i]=$chif[$unite[$i]]; |
337 | - } |
|
338 | - else { |
|
338 | + } else { |
|
339 | 339 | $secon[$i]='trente'; |
340 | 340 | $prim[$i]=$chif[$unite[$i]]; |
341 | 341 | } |
342 | - } |
|
343 | - else if($dix[$i]==4){ |
|
342 | + } else if($dix[$i]==4){ |
|
344 | 343 | if($unite[$i]==1){ |
345 | 344 | $secon[$i]='quarante et'; |
346 | 345 | $prim[$i]=$chif[$unite[$i]]; |
347 | - } |
|
348 | - else { |
|
346 | + } else { |
|
349 | 347 | $secon[$i]='quarante'; |
350 | 348 | $prim[$i]=$chif[$unite[$i]]; |
351 | 349 | } |
352 | - } |
|
353 | - else if($dix[$i]==5){ |
|
350 | + } else if($dix[$i]==5){ |
|
354 | 351 | if($unite[$i]==1){ |
355 | 352 | $secon[$i]='cinquante et'; |
356 | 353 | $prim[$i]=$chif[$unite[$i]]; |
357 | - } |
|
358 | - else { |
|
354 | + } else { |
|
359 | 355 | $secon[$i]='cinquante'; |
360 | 356 | $prim[$i]=$chif[$unite[$i]]; |
361 | 357 | } |
362 | - } |
|
363 | - else if($dix[$i]==6){ |
|
358 | + } else if($dix[$i]==6){ |
|
364 | 359 | if($unite[$i]==1){ |
365 | 360 | $secon[$i]='soixante et'; |
366 | 361 | $prim[$i]=$chif[$unite[$i]]; |
367 | - } |
|
368 | - else { |
|
362 | + } else { |
|
369 | 363 | $secon[$i]='soixante'; |
370 | 364 | $prim[$i]=$chif[$unite[$i]]; |
371 | 365 | } |
372 | - } |
|
373 | - else if($dix[$i]==7){ |
|
366 | + } else if($dix[$i]==7){ |
|
374 | 367 | if($unite[$i]==1){ |
375 | 368 | $secon[$i]='soixante et'; |
376 | 369 | $prim[$i]=$chif[$unite[$i]+10]; |
377 | - } |
|
378 | - else { |
|
370 | + } else { |
|
379 | 371 | $secon[$i]='soixante'; |
380 | 372 | $prim[$i]=$chif[$unite[$i]+10]; |
381 | 373 | } |
382 | - } |
|
383 | - else if($dix[$i]==8){ |
|
374 | + } else if($dix[$i]==8){ |
|
384 | 375 | if($unite[$i]==1){ |
385 | 376 | $secon[$i]='quatre-vingts et'; |
386 | 377 | $prim[$i]=$chif[$unite[$i]]; |
387 | - } |
|
388 | - else { |
|
378 | + } else { |
|
389 | 379 | $secon[$i]='quatre-vingt'; |
390 | 380 | $prim[$i]=$chif[$unite[$i]]; |
391 | 381 | } |
392 | - } |
|
393 | - else if($dix[$i]==9){ |
|
382 | + } else if($dix[$i]==9){ |
|
394 | 383 | if($unite[$i]==1){ |
395 | 384 | $secon[$i]='quatre-vingts et'; |
396 | 385 | $prim[$i]=$chif[$unite[$i]+10]; |
397 | - } |
|
398 | - else { |
|
386 | + } else { |
|
399 | 387 | $secon[$i]='quatre-vingts'; |
400 | 388 | $prim[$i]=$chif[$unite[$i]+10]; |
401 | 389 | } |
402 | 390 | } |
403 | - if($cent[$i]==1) $trio[$i]='cent'; |
|
404 | - else if($cent[$i]!=0 || $cent[$i]!='') $trio[$i]=$chif[$cent[$i]] .' cents'; |
|
391 | + if($cent[$i]==1) { |
|
392 | + $trio[$i]='cent'; |
|
393 | + } else if($cent[$i]!=0 || $cent[$i]!='') { |
|
394 | + $trio[$i]=$chif[$cent[$i]] .' cents'; |
|
395 | + } |
|
405 | 396 | } |
406 | 397 | |
407 | 398 | |
408 | 399 | $chif2=array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix'); |
409 | 400 | $secon_c=$chif2[$dix_c]; |
410 | - if($cent_c==1) $trio_c='cent'; |
|
411 | - else if($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents'; |
|
412 | - |
|
413 | - if(($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1)) |
|
414 | - $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' million '; |
|
415 | - else if(($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!='')) |
|
416 | - $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions '; |
|
417 | - else |
|
418 | - $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]; |
|
419 | - |
|
420 | - if(($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1)) |
|
421 | - $somme = $somme.' mille '; |
|
422 | - else if(($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!='')) |
|
423 | - $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles '; |
|
424 | - else |
|
425 | - $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]; |
|
401 | + if($cent_c==1) { |
|
402 | + $trio_c='cent'; |
|
403 | + } else if($cent_c!=0 || $cent_c!='') { |
|
404 | + $trio_c=$chif[$cent_c] .' cents'; |
|
405 | + } |
|
406 | + |
|
407 | + if(($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1)) { |
|
408 | + $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' million '; |
|
409 | + } else if(($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!='')) { |
|
410 | + $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions '; |
|
411 | + } else { |
|
412 | + $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]; |
|
413 | + } |
|
414 | + |
|
415 | + if(($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1)) { |
|
416 | + $somme = $somme.' mille '; |
|
417 | + } else if(($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!='')) { |
|
418 | + $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles '; |
|
419 | + } else { |
|
420 | + $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]; |
|
421 | + } |
|
426 | 422 | |
427 | 423 | $somme = $somme. $trio[1]. ' ' .$secon[1]. ' ' . $prim[1]; |
428 | 424 | |
429 | 425 | $somme = $somme. ' '. $dev1 .' ' ; |
430 | 426 | |
431 | - if(($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c=='')) |
|
432 | - return $somme. ' et zéro '. $dev2; |
|
433 | - else |
|
434 | - return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2; |
|
427 | + if(($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c=='')) { |
|
428 | + return $somme. ' et zéro '. $dev2; |
|
429 | + } else { |
|
430 | + return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2; |
|
431 | + } |
|
435 | 432 | } |
436 | 433 | } |
@@ -35,135 +35,135 @@ discard block |
||
35 | 35 | |
36 | 36 | class pdf_sepamandate extends ModeleBankAccountDoc |
37 | 37 | { |
38 | - /** |
|
39 | - * Issuer |
|
40 | - * @var Societe |
|
41 | - */ |
|
42 | - public $emetteur; |
|
38 | + /** |
|
39 | + * Issuer |
|
40 | + * @var Societe |
|
41 | + */ |
|
42 | + public $emetteur; |
|
43 | 43 | |
44 | - /** |
|
44 | + /** |
|
45 | 45 | * Dolibarr version of the loaded document |
46 | 46 | * @public string |
47 | 47 | */ |
48 | - public $version = 'dolibarr'; |
|
49 | - |
|
50 | - /** |
|
51 | - * Constructor |
|
52 | - * |
|
53 | - * @param DoliDB $db Database handler |
|
54 | - */ |
|
55 | - function __construct($db) |
|
56 | - { |
|
57 | - global $conf, $langs, $mysoc; |
|
58 | - |
|
59 | - // Translations |
|
60 | - $langs->loadLangs(array("main", "bank", "withdrawals", "companies")); |
|
61 | - |
|
62 | - $this->db = $db; |
|
63 | - $this->name = "sepamandate"; |
|
64 | - $this->description = $langs->transnoentitiesnoconv("DocumentModelSepaMandate"); |
|
65 | - |
|
66 | - // Dimension page pour format A4 |
|
67 | - $this->type = 'pdf'; |
|
68 | - $formatarray=pdf_getFormat(); |
|
69 | - $this->page_largeur = $formatarray['width']; |
|
70 | - $this->page_hauteur = $formatarray['height']; |
|
71 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
72 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
73 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
74 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
75 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
76 | - |
|
77 | - $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO |
|
78 | - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
79 | - $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
80 | - |
|
81 | - // Recupere emmetteur |
|
82 | - $this->emetteur=$mysoc; |
|
83 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
84 | - |
|
85 | - // Defini position des colonnes |
|
86 | - $this->posxref=$this->marge_gauche+1; |
|
87 | - $this->posxlabel=$this->marge_gauche+25; |
|
88 | - $this->posxworkload=$this->marge_gauche+100; |
|
89 | - $this->posxprogress=$this->marge_gauche+130; |
|
90 | - $this->posxdatestart=$this->marge_gauche+150; |
|
91 | - $this->posxdateend=$this->marge_gauche+170; |
|
92 | - } |
|
48 | + public $version = 'dolibarr'; |
|
49 | + |
|
50 | + /** |
|
51 | + * Constructor |
|
52 | + * |
|
53 | + * @param DoliDB $db Database handler |
|
54 | + */ |
|
55 | + function __construct($db) |
|
56 | + { |
|
57 | + global $conf, $langs, $mysoc; |
|
58 | + |
|
59 | + // Translations |
|
60 | + $langs->loadLangs(array("main", "bank", "withdrawals", "companies")); |
|
61 | + |
|
62 | + $this->db = $db; |
|
63 | + $this->name = "sepamandate"; |
|
64 | + $this->description = $langs->transnoentitiesnoconv("DocumentModelSepaMandate"); |
|
65 | + |
|
66 | + // Dimension page pour format A4 |
|
67 | + $this->type = 'pdf'; |
|
68 | + $formatarray=pdf_getFormat(); |
|
69 | + $this->page_largeur = $formatarray['width']; |
|
70 | + $this->page_hauteur = $formatarray['height']; |
|
71 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
72 | + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
73 | + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
74 | + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
75 | + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
76 | + |
|
77 | + $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO |
|
78 | + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
79 | + $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
80 | + |
|
81 | + // Recupere emmetteur |
|
82 | + $this->emetteur=$mysoc; |
|
83 | + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
84 | + |
|
85 | + // Defini position des colonnes |
|
86 | + $this->posxref=$this->marge_gauche+1; |
|
87 | + $this->posxlabel=$this->marge_gauche+25; |
|
88 | + $this->posxworkload=$this->marge_gauche+100; |
|
89 | + $this->posxprogress=$this->marge_gauche+130; |
|
90 | + $this->posxdatestart=$this->marge_gauche+150; |
|
91 | + $this->posxdateend=$this->marge_gauche+170; |
|
92 | + } |
|
93 | 93 | |
94 | 94 | |
95 | 95 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
96 | 96 | /** |
97 | - * Fonction generant le projet sur le disque |
|
98 | - * |
|
99 | - * @param Project $object Object project a generer |
|
100 | - * @param Translate $outputlangs Lang output object |
|
97 | + * Fonction generant le projet sur le disque |
|
98 | + * |
|
99 | + * @param Project $object Object project a generer |
|
100 | + * @param Translate $outputlangs Lang output object |
|
101 | 101 | * @param string $srctemplatepath Full path of source filename for generator using a template file |
102 | 102 | * @param int $hidedetails Do not show line details (not used for this template) |
103 | 103 | * @param int $hidedesc Do not show desc (not used for this template) |
104 | 104 | * @param int $hideref Do not show ref (not used for this template) |
105 | 105 | * @param null|array $moreparams More parameters |
106 | - * @return int 1 if OK, <=0 if KO |
|
107 | - */ |
|
108 | - function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null) |
|
109 | - { |
|
106 | + * @return int 1 if OK, <=0 if KO |
|
107 | + */ |
|
108 | + function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null) |
|
109 | + { |
|
110 | 110 | // phpcs:enable |
111 | - global $conf, $hookmanager, $langs, $user, $mysoc; |
|
112 | - |
|
113 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
114 | - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
115 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
116 | - |
|
117 | - // Load traductions files requiredby by page |
|
118 | - $outputlangs->loadLangs(array("main", "dict", "withdrawals", "companies", "projects", "bills")); |
|
119 | - |
|
120 | - if (! empty($conf->bank->dir_output)) |
|
121 | - { |
|
122 | - //$nblignes = count($object->lines); // This is set later with array of tasks |
|
123 | - |
|
124 | - // Definition of $dir and $file |
|
125 | - if ($object->specimen) |
|
126 | - { |
|
127 | - if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
128 | - else $dir = $conf->bank->dir_output; |
|
129 | - $file = $dir . "/SPECIMEN.pdf"; |
|
130 | - } |
|
131 | - else |
|
132 | - { |
|
133 | - $objectref = dol_sanitizeFileName($object->ref); |
|
134 | - if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
135 | - else $dir = $conf->bank->dir_output . "/" . $objectref; |
|
136 | - $file = $dir . "/" . $langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref . "-".dol_sanitizeFileName($object->rum).".pdf"; |
|
137 | - } |
|
138 | - |
|
139 | - if (! file_exists($dir)) |
|
140 | - { |
|
141 | - if (dol_mkdir($dir) < 0) |
|
142 | - { |
|
143 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
144 | - return 0; |
|
145 | - } |
|
146 | - } |
|
147 | - |
|
148 | - if (file_exists($dir)) |
|
149 | - { |
|
150 | - // Add pdfgeneration hook |
|
151 | - if (! is_object($hookmanager)) |
|
152 | - { |
|
153 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
154 | - $hookmanager=new HookManager($this->db); |
|
155 | - } |
|
156 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
157 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
158 | - global $action; |
|
159 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
111 | + global $conf, $hookmanager, $langs, $user, $mysoc; |
|
112 | + |
|
113 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
114 | + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
115 | + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
116 | + |
|
117 | + // Load traductions files requiredby by page |
|
118 | + $outputlangs->loadLangs(array("main", "dict", "withdrawals", "companies", "projects", "bills")); |
|
119 | + |
|
120 | + if (! empty($conf->bank->dir_output)) |
|
121 | + { |
|
122 | + //$nblignes = count($object->lines); // This is set later with array of tasks |
|
123 | + |
|
124 | + // Definition of $dir and $file |
|
125 | + if ($object->specimen) |
|
126 | + { |
|
127 | + if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
128 | + else $dir = $conf->bank->dir_output; |
|
129 | + $file = $dir . "/SPECIMEN.pdf"; |
|
130 | + } |
|
131 | + else |
|
132 | + { |
|
133 | + $objectref = dol_sanitizeFileName($object->ref); |
|
134 | + if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
135 | + else $dir = $conf->bank->dir_output . "/" . $objectref; |
|
136 | + $file = $dir . "/" . $langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref . "-".dol_sanitizeFileName($object->rum).".pdf"; |
|
137 | + } |
|
138 | + |
|
139 | + if (! file_exists($dir)) |
|
140 | + { |
|
141 | + if (dol_mkdir($dir) < 0) |
|
142 | + { |
|
143 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
144 | + return 0; |
|
145 | + } |
|
146 | + } |
|
147 | + |
|
148 | + if (file_exists($dir)) |
|
149 | + { |
|
150 | + // Add pdfgeneration hook |
|
151 | + if (! is_object($hookmanager)) |
|
152 | + { |
|
153 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
154 | + $hookmanager=new HookManager($this->db); |
|
155 | + } |
|
156 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
157 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
158 | + global $action; |
|
159 | + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
160 | 160 | |
161 | 161 | $pdf=pdf_getInstance($this->format); |
162 | 162 | $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
163 | 163 | $heightforinfotot = 50; // Height reserved to output the info and total part |
164 | - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
165 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
166 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
164 | + $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
165 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
166 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
167 | 167 | $pdf->SetAutoPageBreak(1,0); |
168 | 168 | |
169 | 169 | if (class_exists('TCPDF')) |
@@ -173,419 +173,419 @@ discard block |
||
173 | 173 | } |
174 | 174 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
175 | 175 | |
176 | - $pdf->Open(); |
|
177 | - $pagenb=0; |
|
178 | - $pdf->SetDrawColor(128,128,128); |
|
179 | - |
|
180 | - $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
181 | - $pdf->SetSubject($outputlangs->transnoentities("SepaMandate")); |
|
182 | - $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
183 | - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
184 | - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("SepaMandate")); |
|
185 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
186 | - |
|
187 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
188 | - |
|
189 | - // New page |
|
190 | - $pdf->AddPage(); |
|
191 | - $pagenb++; |
|
192 | - $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
193 | - $pdf->SetFont('','', $default_font_size - 1); |
|
194 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
195 | - $pdf->SetTextColor(0,0,0); |
|
196 | - |
|
197 | - $tab_top = 50; |
|
198 | - $tab_height = 200; |
|
199 | - $tab_top_newpage = 40; |
|
176 | + $pdf->Open(); |
|
177 | + $pagenb=0; |
|
178 | + $pdf->SetDrawColor(128,128,128); |
|
179 | + |
|
180 | + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
181 | + $pdf->SetSubject($outputlangs->transnoentities("SepaMandate")); |
|
182 | + $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
183 | + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
184 | + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("SepaMandate")); |
|
185 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
186 | + |
|
187 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
188 | + |
|
189 | + // New page |
|
190 | + $pdf->AddPage(); |
|
191 | + $pagenb++; |
|
192 | + $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
193 | + $pdf->SetFont('','', $default_font_size - 1); |
|
194 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
195 | + $pdf->SetTextColor(0,0,0); |
|
196 | + |
|
197 | + $tab_top = 50; |
|
198 | + $tab_height = 200; |
|
199 | + $tab_top_newpage = 40; |
|
200 | 200 | $tab_height_newpage = 210; |
201 | 201 | |
202 | - // Affiche notes |
|
203 | - if (! empty($object->note_public)) |
|
204 | - { |
|
205 | - $pdf->SetFont('','', $default_font_size - 1); |
|
206 | - $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
207 | - $nexY = $pdf->GetY(); |
|
208 | - $height_note=$nexY-($tab_top-2); |
|
209 | - |
|
210 | - // Rect prend une longueur en 3eme param |
|
211 | - $pdf->SetDrawColor(192,192,192); |
|
212 | - $pdf->Rect($this->marge_gauche, $tab_top-3, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
213 | - |
|
214 | - $tab_height = $tab_height - $height_note; |
|
215 | - $tab_top = $nexY+6; |
|
216 | - } |
|
217 | - else |
|
218 | - { |
|
219 | - $height_note=0; |
|
220 | - } |
|
221 | - |
|
222 | - $iniY = $tab_top + 7; |
|
223 | - $curY = $tab_top + 7; |
|
224 | - $nexY = $tab_top + 7; |
|
225 | - |
|
226 | - $posY = $curY; |
|
227 | - |
|
228 | - $pdf->SetFont('','', $default_font_size); |
|
229 | - |
|
230 | - $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); |
|
231 | - $posY+=2; |
|
232 | - |
|
233 | - $pdf->SetXY($this->marge_gauche, $posY); |
|
234 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("RUMLong").' ('.$outputlangs->transnoentitiesnoconv("RUM").')'.' : '.$object->rum, 0, 'L'); |
|
235 | - |
|
236 | - $posY=$pdf->GetY(); |
|
237 | - $posY+=2; |
|
238 | - $pdf->SetXY($this->marge_gauche, $posY); |
|
239 | - $ics=''; |
|
240 | - if (! empty($conf->global->PRELEVEMENT_ICS)) $ics=$conf->global->PRELEVEMENT_ICS; |
|
241 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorIdentifier").' ('.$outputlangs->transnoentitiesnoconv("ICS").')'.' : '.$ics, 0, 'L'); |
|
242 | - |
|
243 | - $posY=$pdf->GetY(); |
|
244 | - $posY+=1; |
|
245 | - $pdf->SetXY($this->marge_gauche, $posY); |
|
246 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorName").' : '.$mysoc->name, 0, 'L'); |
|
247 | - |
|
248 | - $posY=$pdf->GetY(); |
|
249 | - $posY+=1; |
|
250 | - $pdf->SetXY($this->marge_gauche, $posY); |
|
251 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L'); |
|
252 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $mysoc->getFullAddress(), 0, 'L'); |
|
253 | - |
|
254 | - $posY=$pdf->GetY(); |
|
255 | - $posY+=3; |
|
256 | - |
|
257 | - $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); |
|
258 | - |
|
259 | - $pdf->SetFont('','', $default_font_size - 1); |
|
260 | - |
|
261 | - $posY+=8; |
|
262 | - $pdf->SetXY($this->marge_gauche, $posY); |
|
263 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 8, $outputlangs->transnoentitiesnoconv("SEPALegalText", $mysoc->name, $mysoc->name), 0, 'L'); |
|
264 | - |
|
265 | - // Your data form |
|
266 | - $posY=$pdf->GetY(); |
|
267 | - $posY+=8; |
|
268 | - $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); |
|
269 | - $posY+=2; |
|
270 | - |
|
271 | - $pdf->SetFont('','', $default_font_size); |
|
272 | - |
|
273 | - $pdf->SetXY($this->marge_gauche, $posY); |
|
274 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFillForm"), 0, 'C'); |
|
275 | - |
|
276 | - $thirdparty=new Societe($this->db); |
|
277 | - if ($object->socid > 0) $thirdparty->fetch($object->socid); |
|
278 | - |
|
279 | - $sepaname = '______________________________________________'; |
|
280 | - if ($thirdparty->id > 0) |
|
281 | - { |
|
282 | - $sepaname = $thirdparty->name.($object->account_owner?' ('.$object->account_owner.')':''); |
|
283 | - } |
|
284 | - $posY=$pdf->GetY(); |
|
285 | - $posY+=3; |
|
286 | - $pdf->SetXY($this->marge_gauche, $posY); |
|
287 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourName").' * : ', 0, 'L'); |
|
288 | - $pdf->SetXY(80, $posY); |
|
289 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepaname, 0, 'L'); |
|
290 | - |
|
291 | - $address = '______________________________________________'; |
|
292 | - if ($thirdparty->id > 0) |
|
293 | - { |
|
294 | - $address = $thirdparty->getFullAddress(); |
|
295 | - } |
|
296 | - $posY=$pdf->GetY(); |
|
297 | - $posY+=1; |
|
298 | - $pdf->SetXY($this->marge_gauche, $posY); |
|
299 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L'); |
|
300 | - $pdf->SetXY(80, $posY); |
|
301 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L'); |
|
302 | - if (preg_match('/_____/', $address)) |
|
303 | - { |
|
304 | - $posY+=6; |
|
305 | - $pdf->SetXY(80, $posY); |
|
306 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L'); |
|
307 | - } |
|
308 | - |
|
309 | - $ban = '__________________________________________________'; |
|
310 | - if (! empty($object->iban)) $ban = $object->iban; |
|
311 | - $posY=$pdf->GetY(); |
|
312 | - $posY+=1; |
|
313 | - $pdf->SetXY($this->marge_gauche, $posY); |
|
314 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBAN").' * : ', 0, 'L'); |
|
315 | - $pdf->SetXY(80, $posY); |
|
316 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0, 'L'); |
|
317 | - |
|
318 | - $bic = '__________________________________________________'; |
|
319 | - if (! empty($object->bic)) $bic = $object->bic; |
|
320 | - $posY=$pdf->GetY(); |
|
321 | - $posY+=1; |
|
322 | - $pdf->SetXY($this->marge_gauche, $posY); |
|
323 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBIC").' * : ', 0, 'L'); |
|
324 | - $pdf->SetXY(80, $posY); |
|
325 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $bic, 0, 'L'); |
|
326 | - |
|
327 | - |
|
328 | - $posY=$pdf->GetY(); |
|
329 | - $posY+=1; |
|
330 | - $pdf->SetXY($this->marge_gauche, $posY); |
|
331 | - $txt = $outputlangs->transnoentitiesnoconv("SEPAFrstOrRecur").' * : '; |
|
332 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
|
333 | - $pdf->Rect(80, $posY, 5, 5); |
|
334 | - $pdf->SetXY(80, $posY); |
|
335 | - if ($object->frstrecur == 'RECUR') $pdf->MultiCell(5, 3, 'X', 0, 'L'); |
|
336 | - $pdf->SetXY(86, $posY); |
|
337 | - $txt = $langs->transnoentitiesnoconv("ModeRECUR").' '.$langs->transnoentitiesnoconv("or"); |
|
338 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
|
339 | - $posY+=6; |
|
340 | - $pdf->Rect(80, $posY, 5, 5); |
|
341 | - $pdf->SetXY(80, $posY); |
|
342 | - if ($object->frstrecur == 'FRST') $pdf->MultiCell(5, 3, 'X', 0, 'L'); |
|
343 | - $pdf->SetXY(86, $posY); |
|
344 | - $txt = $langs->transnoentitiesnoconv("ModeFRST"); |
|
345 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
|
346 | - if (empty($object->frstrecur)) |
|
347 | - { |
|
348 | - $posY+=6; |
|
349 | - $pdf->SetXY(80, $posY); |
|
350 | - $txt = '('.$langs->transnoentitiesnoconv("PleaseCheckOne").')'; |
|
351 | - $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
|
352 | - } |
|
353 | - |
|
354 | - $posY=$pdf->GetY(); |
|
355 | - $posY+=3; |
|
356 | - $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); |
|
357 | - $posY+=3; |
|
358 | - |
|
359 | - |
|
360 | - // Show square |
|
361 | - if ($pagenb == 1) |
|
362 | - { |
|
363 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
364 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
365 | - } |
|
366 | - else |
|
367 | - { |
|
368 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
369 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
370 | - } |
|
371 | - |
|
372 | - /*var_dump($tab_top); |
|
202 | + // Affiche notes |
|
203 | + if (! empty($object->note_public)) |
|
204 | + { |
|
205 | + $pdf->SetFont('','', $default_font_size - 1); |
|
206 | + $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
207 | + $nexY = $pdf->GetY(); |
|
208 | + $height_note=$nexY-($tab_top-2); |
|
209 | + |
|
210 | + // Rect prend une longueur en 3eme param |
|
211 | + $pdf->SetDrawColor(192,192,192); |
|
212 | + $pdf->Rect($this->marge_gauche, $tab_top-3, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
213 | + |
|
214 | + $tab_height = $tab_height - $height_note; |
|
215 | + $tab_top = $nexY+6; |
|
216 | + } |
|
217 | + else |
|
218 | + { |
|
219 | + $height_note=0; |
|
220 | + } |
|
221 | + |
|
222 | + $iniY = $tab_top + 7; |
|
223 | + $curY = $tab_top + 7; |
|
224 | + $nexY = $tab_top + 7; |
|
225 | + |
|
226 | + $posY = $curY; |
|
227 | + |
|
228 | + $pdf->SetFont('','', $default_font_size); |
|
229 | + |
|
230 | + $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); |
|
231 | + $posY+=2; |
|
232 | + |
|
233 | + $pdf->SetXY($this->marge_gauche, $posY); |
|
234 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("RUMLong").' ('.$outputlangs->transnoentitiesnoconv("RUM").')'.' : '.$object->rum, 0, 'L'); |
|
235 | + |
|
236 | + $posY=$pdf->GetY(); |
|
237 | + $posY+=2; |
|
238 | + $pdf->SetXY($this->marge_gauche, $posY); |
|
239 | + $ics=''; |
|
240 | + if (! empty($conf->global->PRELEVEMENT_ICS)) $ics=$conf->global->PRELEVEMENT_ICS; |
|
241 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorIdentifier").' ('.$outputlangs->transnoentitiesnoconv("ICS").')'.' : '.$ics, 0, 'L'); |
|
242 | + |
|
243 | + $posY=$pdf->GetY(); |
|
244 | + $posY+=1; |
|
245 | + $pdf->SetXY($this->marge_gauche, $posY); |
|
246 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorName").' : '.$mysoc->name, 0, 'L'); |
|
247 | + |
|
248 | + $posY=$pdf->GetY(); |
|
249 | + $posY+=1; |
|
250 | + $pdf->SetXY($this->marge_gauche, $posY); |
|
251 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L'); |
|
252 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $mysoc->getFullAddress(), 0, 'L'); |
|
253 | + |
|
254 | + $posY=$pdf->GetY(); |
|
255 | + $posY+=3; |
|
256 | + |
|
257 | + $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); |
|
258 | + |
|
259 | + $pdf->SetFont('','', $default_font_size - 1); |
|
260 | + |
|
261 | + $posY+=8; |
|
262 | + $pdf->SetXY($this->marge_gauche, $posY); |
|
263 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 8, $outputlangs->transnoentitiesnoconv("SEPALegalText", $mysoc->name, $mysoc->name), 0, 'L'); |
|
264 | + |
|
265 | + // Your data form |
|
266 | + $posY=$pdf->GetY(); |
|
267 | + $posY+=8; |
|
268 | + $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); |
|
269 | + $posY+=2; |
|
270 | + |
|
271 | + $pdf->SetFont('','', $default_font_size); |
|
272 | + |
|
273 | + $pdf->SetXY($this->marge_gauche, $posY); |
|
274 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFillForm"), 0, 'C'); |
|
275 | + |
|
276 | + $thirdparty=new Societe($this->db); |
|
277 | + if ($object->socid > 0) $thirdparty->fetch($object->socid); |
|
278 | + |
|
279 | + $sepaname = '______________________________________________'; |
|
280 | + if ($thirdparty->id > 0) |
|
281 | + { |
|
282 | + $sepaname = $thirdparty->name.($object->account_owner?' ('.$object->account_owner.')':''); |
|
283 | + } |
|
284 | + $posY=$pdf->GetY(); |
|
285 | + $posY+=3; |
|
286 | + $pdf->SetXY($this->marge_gauche, $posY); |
|
287 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourName").' * : ', 0, 'L'); |
|
288 | + $pdf->SetXY(80, $posY); |
|
289 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepaname, 0, 'L'); |
|
290 | + |
|
291 | + $address = '______________________________________________'; |
|
292 | + if ($thirdparty->id > 0) |
|
293 | + { |
|
294 | + $address = $thirdparty->getFullAddress(); |
|
295 | + } |
|
296 | + $posY=$pdf->GetY(); |
|
297 | + $posY+=1; |
|
298 | + $pdf->SetXY($this->marge_gauche, $posY); |
|
299 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L'); |
|
300 | + $pdf->SetXY(80, $posY); |
|
301 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L'); |
|
302 | + if (preg_match('/_____/', $address)) |
|
303 | + { |
|
304 | + $posY+=6; |
|
305 | + $pdf->SetXY(80, $posY); |
|
306 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L'); |
|
307 | + } |
|
308 | + |
|
309 | + $ban = '__________________________________________________'; |
|
310 | + if (! empty($object->iban)) $ban = $object->iban; |
|
311 | + $posY=$pdf->GetY(); |
|
312 | + $posY+=1; |
|
313 | + $pdf->SetXY($this->marge_gauche, $posY); |
|
314 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBAN").' * : ', 0, 'L'); |
|
315 | + $pdf->SetXY(80, $posY); |
|
316 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0, 'L'); |
|
317 | + |
|
318 | + $bic = '__________________________________________________'; |
|
319 | + if (! empty($object->bic)) $bic = $object->bic; |
|
320 | + $posY=$pdf->GetY(); |
|
321 | + $posY+=1; |
|
322 | + $pdf->SetXY($this->marge_gauche, $posY); |
|
323 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBIC").' * : ', 0, 'L'); |
|
324 | + $pdf->SetXY(80, $posY); |
|
325 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $bic, 0, 'L'); |
|
326 | + |
|
327 | + |
|
328 | + $posY=$pdf->GetY(); |
|
329 | + $posY+=1; |
|
330 | + $pdf->SetXY($this->marge_gauche, $posY); |
|
331 | + $txt = $outputlangs->transnoentitiesnoconv("SEPAFrstOrRecur").' * : '; |
|
332 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
|
333 | + $pdf->Rect(80, $posY, 5, 5); |
|
334 | + $pdf->SetXY(80, $posY); |
|
335 | + if ($object->frstrecur == 'RECUR') $pdf->MultiCell(5, 3, 'X', 0, 'L'); |
|
336 | + $pdf->SetXY(86, $posY); |
|
337 | + $txt = $langs->transnoentitiesnoconv("ModeRECUR").' '.$langs->transnoentitiesnoconv("or"); |
|
338 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
|
339 | + $posY+=6; |
|
340 | + $pdf->Rect(80, $posY, 5, 5); |
|
341 | + $pdf->SetXY(80, $posY); |
|
342 | + if ($object->frstrecur == 'FRST') $pdf->MultiCell(5, 3, 'X', 0, 'L'); |
|
343 | + $pdf->SetXY(86, $posY); |
|
344 | + $txt = $langs->transnoentitiesnoconv("ModeFRST"); |
|
345 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
|
346 | + if (empty($object->frstrecur)) |
|
347 | + { |
|
348 | + $posY+=6; |
|
349 | + $pdf->SetXY(80, $posY); |
|
350 | + $txt = '('.$langs->transnoentitiesnoconv("PleaseCheckOne").')'; |
|
351 | + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
|
352 | + } |
|
353 | + |
|
354 | + $posY=$pdf->GetY(); |
|
355 | + $posY+=3; |
|
356 | + $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); |
|
357 | + $posY+=3; |
|
358 | + |
|
359 | + |
|
360 | + // Show square |
|
361 | + if ($pagenb == 1) |
|
362 | + { |
|
363 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
364 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
365 | + } |
|
366 | + else |
|
367 | + { |
|
368 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
369 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
370 | + } |
|
371 | + |
|
372 | + /*var_dump($tab_top); |
|
373 | 373 | var_dump($heightforinfotot); |
374 | 374 | var_dump($heightforfreetext); |
375 | 375 | var_dump($heightforfooter); |
376 | 376 | var_dump($bottomlasttab);*/ |
377 | 377 | |
378 | - // Affiche zone infos |
|
379 | - $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); |
|
378 | + // Affiche zone infos |
|
379 | + $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); |
|
380 | 380 | |
381 | - /* |
|
381 | + /* |
|
382 | 382 | * Pied de page |
383 | 383 | */ |
384 | - $this->_pagefoot($pdf,$object,$outputlangs); |
|
385 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
386 | - |
|
387 | - $pdf->Close(); |
|
388 | - |
|
389 | - $pdf->Output($file,'F'); |
|
390 | - |
|
391 | - // Add pdfgeneration hook |
|
392 | - if (! is_object($hookmanager)) |
|
393 | - { |
|
394 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
395 | - $hookmanager=new HookManager($this->db); |
|
396 | - } |
|
397 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
398 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
399 | - global $action; |
|
400 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
401 | - |
|
402 | - if (! empty($conf->global->MAIN_UMASK)) |
|
403 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
404 | - |
|
405 | - $this->result = array('fullpath'=>$file); |
|
406 | - |
|
407 | - return 1; // Pas d'erreur |
|
408 | - } |
|
409 | - else |
|
410 | - { |
|
411 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
412 | - return 0; |
|
413 | - } |
|
414 | - } |
|
415 | - |
|
416 | - $this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR"); |
|
417 | - return 0; |
|
418 | - } |
|
419 | - |
|
420 | - |
|
421 | - /** |
|
422 | - * Show table for lines |
|
423 | - * |
|
424 | - * @param PDF $pdf Object PDF |
|
425 | - * @param string $tab_top Top position of table |
|
426 | - * @param string $tab_height Height of table (rectangle) |
|
427 | - * @param int $nexY Y |
|
428 | - * @param Translate $outputlangs Langs object |
|
429 | - * @param int $hidetop Hide top bar of array |
|
430 | - * @param int $hidebottom Hide bottom bar of array |
|
431 | - * @return void |
|
432 | - */ |
|
433 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
434 | - { |
|
435 | - global $conf,$mysoc; |
|
384 | + $this->_pagefoot($pdf,$object,$outputlangs); |
|
385 | + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
386 | + |
|
387 | + $pdf->Close(); |
|
388 | + |
|
389 | + $pdf->Output($file,'F'); |
|
390 | + |
|
391 | + // Add pdfgeneration hook |
|
392 | + if (! is_object($hookmanager)) |
|
393 | + { |
|
394 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
395 | + $hookmanager=new HookManager($this->db); |
|
396 | + } |
|
397 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
398 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
399 | + global $action; |
|
400 | + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
401 | + |
|
402 | + if (! empty($conf->global->MAIN_UMASK)) |
|
403 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
404 | + |
|
405 | + $this->result = array('fullpath'=>$file); |
|
406 | + |
|
407 | + return 1; // Pas d'erreur |
|
408 | + } |
|
409 | + else |
|
410 | + { |
|
411 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
412 | + return 0; |
|
413 | + } |
|
414 | + } |
|
415 | + |
|
416 | + $this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR"); |
|
417 | + return 0; |
|
418 | + } |
|
419 | + |
|
420 | + |
|
421 | + /** |
|
422 | + * Show table for lines |
|
423 | + * |
|
424 | + * @param PDF $pdf Object PDF |
|
425 | + * @param string $tab_top Top position of table |
|
426 | + * @param string $tab_height Height of table (rectangle) |
|
427 | + * @param int $nexY Y |
|
428 | + * @param Translate $outputlangs Langs object |
|
429 | + * @param int $hidetop Hide top bar of array |
|
430 | + * @param int $hidebottom Hide bottom bar of array |
|
431 | + * @return void |
|
432 | + */ |
|
433 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
434 | + { |
|
435 | + global $conf,$mysoc; |
|
436 | 436 | |
437 | 437 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
438 | - } |
|
438 | + } |
|
439 | 439 | |
440 | 440 | |
441 | 441 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
442 | - /** |
|
443 | - * Show miscellaneous information (payment mode, payment term, ...) |
|
444 | - * |
|
445 | - * @param PDF $pdf Object PDF |
|
446 | - * @param Object $object Object to show |
|
447 | - * @param int $posy Y |
|
448 | - * @param Translate $outputlangs Langs object |
|
449 | - * @return void |
|
450 | - */ |
|
451 | - function _tableau_info(&$pdf, $object, $posy, $outputlangs) |
|
452 | - { |
|
442 | + /** |
|
443 | + * Show miscellaneous information (payment mode, payment term, ...) |
|
444 | + * |
|
445 | + * @param PDF $pdf Object PDF |
|
446 | + * @param Object $object Object to show |
|
447 | + * @param int $posy Y |
|
448 | + * @param Translate $outputlangs Langs object |
|
449 | + * @return void |
|
450 | + */ |
|
451 | + function _tableau_info(&$pdf, $object, $posy, $outputlangs) |
|
452 | + { |
|
453 | 453 | // phpcs:enable |
454 | 454 | global $conf, $mysoc; |
455 | 455 | |
456 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
456 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
457 | 457 | |
458 | - $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?1:$conf->global->PDF_DIFFSIZE_TITLE); |
|
458 | + $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?1:$conf->global->PDF_DIFFSIZE_TITLE); |
|
459 | 459 | |
460 | - $posy+=$this->_signature_area($pdf, $object, $posy, $outputlangs); |
|
460 | + $posy+=$this->_signature_area($pdf, $object, $posy, $outputlangs); |
|
461 | 461 | |
462 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
463 | - $pdf->SetFont('','', $default_font_size); |
|
464 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("PleaseReturnMandate", $mysoc->email).':', 0, 'L', 0); |
|
465 | - $posy=$pdf->GetY()+2; |
|
462 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
463 | + $pdf->SetFont('','', $default_font_size); |
|
464 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("PleaseReturnMandate", $mysoc->email).':', 0, 'L', 0); |
|
465 | + $posy=$pdf->GetY()+2; |
|
466 | 466 | |
467 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
468 | - $pdf->SetFont('','', $default_font_size - $diffsizetitle); |
|
469 | - $pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0); |
|
470 | - $pdf->MultiCell(100, 6, $outputlangs->convToOutputCharset($mysoc->getFullAddress()), 0, 'L', 0); |
|
471 | - $posy=$pdf->GetY()+2; |
|
467 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
468 | + $pdf->SetFont('','', $default_font_size - $diffsizetitle); |
|
469 | + $pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0); |
|
470 | + $pdf->MultiCell(100, 6, $outputlangs->convToOutputCharset($mysoc->getFullAddress()), 0, 'L', 0); |
|
471 | + $posy=$pdf->GetY()+2; |
|
472 | 472 | |
473 | - return $posy; |
|
474 | - } |
|
473 | + return $posy; |
|
474 | + } |
|
475 | 475 | |
476 | 476 | |
477 | 477 | |
478 | 478 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
479 | - /** |
|
480 | - * Show area for the customer to sign |
|
481 | - * |
|
482 | - * @param PDF $pdf Object PDF |
|
483 | - * @param Facture $object Object invoice |
|
484 | - * @param int $posy Position depart |
|
485 | - * @param Translate $outputlangs Objet langs |
|
486 | - * @return int Position pour suite |
|
487 | - */ |
|
488 | - function _signature_area(&$pdf, $object, $posy, $outputlangs) |
|
489 | - { |
|
479 | + /** |
|
480 | + * Show area for the customer to sign |
|
481 | + * |
|
482 | + * @param PDF $pdf Object PDF |
|
483 | + * @param Facture $object Object invoice |
|
484 | + * @param int $posy Position depart |
|
485 | + * @param Translate $outputlangs Objet langs |
|
486 | + * @return int Position pour suite |
|
487 | + */ |
|
488 | + function _signature_area(&$pdf, $object, $posy, $outputlangs) |
|
489 | + { |
|
490 | 490 | // phpcs:enable |
491 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
492 | - $tab_top = $posy + 4; |
|
493 | - $tab_hl = 4; |
|
491 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
492 | + $tab_top = $posy + 4; |
|
493 | + $tab_hl = 4; |
|
494 | 494 | |
495 | - $posx = $this->marge_gauche; |
|
496 | - $pdf->SetXY($posx, $tab_top + 0); |
|
495 | + $posx = $this->marge_gauche; |
|
496 | + $pdf->SetXY($posx, $tab_top + 0); |
|
497 | 497 | |
498 | - $pdf->SetFont('','', $default_font_size - 2); |
|
498 | + $pdf->SetFont('','', $default_font_size - 2); |
|
499 | 499 | |
500 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("DateOfSignature"), 0, 'L', 0); |
|
501 | - $pdf->MultiCell(100, 3, ' '); |
|
502 | - $pdf->MultiCell(100, 3, '______________________', 0, 'L', 0); |
|
500 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("DateOfSignature"), 0, 'L', 0); |
|
501 | + $pdf->MultiCell(100, 3, ' '); |
|
502 | + $pdf->MultiCell(100, 3, '______________________', 0, 'L', 0); |
|
503 | 503 | |
504 | - $posx = 120; |
|
505 | - $largcol = ($this->page_largeur - $this->marge_droite - $posx); |
|
506 | - $useborder=0; |
|
507 | - $index = 0; |
|
508 | - // Total HT |
|
509 | - $pdf->SetFillColor(255,255,255); |
|
510 | - $pdf->SetXY($posx, $tab_top + 0); |
|
511 | - $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1); |
|
504 | + $posx = 120; |
|
505 | + $largcol = ($this->page_largeur - $this->marge_droite - $posx); |
|
506 | + $useborder=0; |
|
507 | + $index = 0; |
|
508 | + // Total HT |
|
509 | + $pdf->SetFillColor(255,255,255); |
|
510 | + $pdf->SetXY($posx, $tab_top + 0); |
|
511 | + $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1); |
|
512 | 512 | |
513 | - $pdf->SetXY($posx, $tab_top + $tab_hl); |
|
514 | - $pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R'); |
|
513 | + $pdf->SetXY($posx, $tab_top + $tab_hl); |
|
514 | + $pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R'); |
|
515 | 515 | |
516 | - return ($tab_hl*7); |
|
517 | - } |
|
516 | + return ($tab_hl*7); |
|
517 | + } |
|
518 | 518 | |
519 | 519 | |
520 | - /** |
|
521 | - * Show top header of page. |
|
522 | - * |
|
523 | - * @param PDF $pdf Object PDF |
|
524 | - * @param Project $object Object to show |
|
525 | - * @param int $showaddress 0=no, 1=yes |
|
526 | - * @param Translate $outputlangs Object lang for output |
|
527 | - * @return void |
|
528 | - */ |
|
529 | - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
530 | - { |
|
531 | - global $langs,$conf,$mysoc; |
|
520 | + /** |
|
521 | + * Show top header of page. |
|
522 | + * |
|
523 | + * @param PDF $pdf Object PDF |
|
524 | + * @param Project $object Object to show |
|
525 | + * @param int $showaddress 0=no, 1=yes |
|
526 | + * @param Translate $outputlangs Object lang for output |
|
527 | + * @return void |
|
528 | + */ |
|
529 | + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
530 | + { |
|
531 | + global $langs,$conf,$mysoc; |
|
532 | 532 | |
533 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
533 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
534 | 534 | |
535 | - pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
535 | + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
536 | 536 | |
537 | - $pdf->SetTextColor(0,0,60); |
|
538 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
537 | + $pdf->SetTextColor(0,0,60); |
|
538 | + $pdf->SetFont('','B', $default_font_size + 3); |
|
539 | 539 | |
540 | 540 | $posx=$this->page_largeur-$this->marge_droite-100; |
541 | - $posy=$this->marge_haute; |
|
542 | - |
|
543 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
544 | - |
|
545 | - // Logo |
|
546 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
547 | - if ($mysoc->logo) |
|
548 | - { |
|
549 | - if (is_readable($logo)) |
|
550 | - { |
|
551 | - $height=pdf_getHeightForLogo($logo); |
|
552 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
553 | - } |
|
554 | - else |
|
555 | - { |
|
556 | - $pdf->SetTextColor(200,0,0); |
|
557 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
558 | - $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
559 | - $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
|
560 | - } |
|
561 | - } |
|
562 | - else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
563 | - |
|
564 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
565 | - $pdf->SetXY($posx,$posy); |
|
566 | - $pdf->SetTextColor(0,0,60); |
|
567 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("SepaMandate"), '', 'R'); |
|
568 | - $pdf->SetFont('','', $default_font_size + 2); |
|
569 | - |
|
570 | - $posy+=6; |
|
571 | - $pdf->SetXY($posx,$posy); |
|
572 | - $pdf->SetTextColor(0,0,60); |
|
573 | - $daterum = '__________________'; |
|
574 | - if (! empty($object->date_rum)) |
|
575 | - { |
|
541 | + $posy=$this->marge_haute; |
|
542 | + |
|
543 | + $pdf->SetXY($this->marge_gauche,$posy); |
|
544 | + |
|
545 | + // Logo |
|
546 | + $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
547 | + if ($mysoc->logo) |
|
548 | + { |
|
549 | + if (is_readable($logo)) |
|
550 | + { |
|
551 | + $height=pdf_getHeightForLogo($logo); |
|
552 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
553 | + } |
|
554 | + else |
|
555 | + { |
|
556 | + $pdf->SetTextColor(200,0,0); |
|
557 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
558 | + $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
559 | + $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
|
560 | + } |
|
561 | + } |
|
562 | + else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
563 | + |
|
564 | + $pdf->SetFont('','B', $default_font_size + 3); |
|
565 | + $pdf->SetXY($posx,$posy); |
|
566 | + $pdf->SetTextColor(0,0,60); |
|
567 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("SepaMandate"), '', 'R'); |
|
568 | + $pdf->SetFont('','', $default_font_size + 2); |
|
569 | + |
|
570 | + $posy+=6; |
|
571 | + $pdf->SetXY($posx,$posy); |
|
572 | + $pdf->SetTextColor(0,0,60); |
|
573 | + $daterum = '__________________'; |
|
574 | + if (! empty($object->date_rum)) |
|
575 | + { |
|
576 | 576 | $daterum = dol_print_date($object->date_rum,'day',false,$outputlangs,true); |
577 | - } |
|
578 | - else $daterum = dol_print_date($object->datec,'day',false,$outputlangs,true); // For old record, the date_rum was not saved. |
|
579 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . $daterum, '', 'R'); |
|
580 | - /*$posy+=6; |
|
577 | + } |
|
578 | + else $daterum = dol_print_date($object->datec,'day',false,$outputlangs,true); // For old record, the date_rum was not saved. |
|
579 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . $daterum, '', 'R'); |
|
580 | + /*$posy+=6; |
|
581 | 581 | $pdf->SetXY($posx,$posy); |
582 | 582 | $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R'); |
583 | 583 | */ |
584 | 584 | |
585 | - $pdf->SetTextColor(0,0,60); |
|
585 | + $pdf->SetTextColor(0,0,60); |
|
586 | 586 | |
587 | - // Add list of linked objects |
|
588 | - /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc.... |
|
587 | + // Add list of linked objects |
|
588 | + /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc.... |
|
589 | 589 | $object->fetchObjectLinked(); |
590 | 590 | |
591 | 591 | foreach($object->linkedObjects as $objecttype => $objects) |
@@ -607,21 +607,21 @@ discard block |
||
607 | 607 | } |
608 | 608 | } |
609 | 609 | */ |
610 | - } |
|
610 | + } |
|
611 | 611 | |
612 | - /** |
|
613 | - * Show footer of page. Need this->emetteur object |
|
612 | + /** |
|
613 | + * Show footer of page. Need this->emetteur object |
|
614 | 614 | * |
615 | - * @param PDF $pdf PDF |
|
616 | - * @param Project $object Object to show |
|
617 | - * @param Translate $outputlangs Object lang for output |
|
618 | - * @param int $hidefreetext 1=Hide free text |
|
619 | - * @return integer |
|
620 | - */ |
|
621 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
622 | - { |
|
623 | - global $conf; |
|
624 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
625 | - return pdf_pagefoot($pdf,$outputlangs,'PAYMENTORDER_FREE_TEXT',null,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
626 | - } |
|
615 | + * @param PDF $pdf PDF |
|
616 | + * @param Project $object Object to show |
|
617 | + * @param Translate $outputlangs Object lang for output |
|
618 | + * @param int $hidefreetext 1=Hide free text |
|
619 | + * @return integer |
|
620 | + */ |
|
621 | + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
622 | + { |
|
623 | + global $conf; |
|
624 | + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
625 | + return pdf_pagefoot($pdf,$outputlangs,'PAYMENTORDER_FREE_TEXT',null,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
626 | + } |
|
627 | 627 | } |
@@ -65,30 +65,30 @@ discard block |
||
65 | 65 | |
66 | 66 | // Dimension page pour format A4 |
67 | 67 | $this->type = 'pdf'; |
68 | - $formatarray=pdf_getFormat(); |
|
68 | + $formatarray = pdf_getFormat(); |
|
69 | 69 | $this->page_largeur = $formatarray['width']; |
70 | 70 | $this->page_hauteur = $formatarray['height']; |
71 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
72 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
73 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
74 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
75 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
71 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
72 | + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; |
|
73 | + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; |
|
74 | + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; |
|
75 | + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; |
|
76 | 76 | |
77 | - $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO |
|
78 | - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
79 | - $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
77 | + $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO |
|
78 | + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
79 | + $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
80 | 80 | |
81 | 81 | // Recupere emmetteur |
82 | - $this->emetteur=$mysoc; |
|
83 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
82 | + $this->emetteur = $mysoc; |
|
83 | + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined |
|
84 | 84 | |
85 | 85 | // Defini position des colonnes |
86 | - $this->posxref=$this->marge_gauche+1; |
|
87 | - $this->posxlabel=$this->marge_gauche+25; |
|
88 | - $this->posxworkload=$this->marge_gauche+100; |
|
89 | - $this->posxprogress=$this->marge_gauche+130; |
|
90 | - $this->posxdatestart=$this->marge_gauche+150; |
|
91 | - $this->posxdateend=$this->marge_gauche+170; |
|
86 | + $this->posxref = $this->marge_gauche + 1; |
|
87 | + $this->posxlabel = $this->marge_gauche + 25; |
|
88 | + $this->posxworkload = $this->marge_gauche + 100; |
|
89 | + $this->posxprogress = $this->marge_gauche + 130; |
|
90 | + $this->posxdatestart = $this->marge_gauche + 150; |
|
91 | + $this->posxdateend = $this->marge_gauche + 170; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -105,42 +105,42 @@ discard block |
||
105 | 105 | * @param null|array $moreparams More parameters |
106 | 106 | * @return int 1 if OK, <=0 if KO |
107 | 107 | */ |
108 | - function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null) |
|
108 | + function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) |
|
109 | 109 | { |
110 | 110 | // phpcs:enable |
111 | 111 | global $conf, $hookmanager, $langs, $user, $mysoc; |
112 | 112 | |
113 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
113 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
114 | 114 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
115 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
115 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
116 | 116 | |
117 | 117 | // Load traductions files requiredby by page |
118 | 118 | $outputlangs->loadLangs(array("main", "dict", "withdrawals", "companies", "projects", "bills")); |
119 | 119 | |
120 | - if (! empty($conf->bank->dir_output)) |
|
120 | + if (!empty($conf->bank->dir_output)) |
|
121 | 121 | { |
122 | 122 | //$nblignes = count($object->lines); // This is set later with array of tasks |
123 | 123 | |
124 | 124 | // Definition of $dir and $file |
125 | 125 | if ($object->specimen) |
126 | 126 | { |
127 | - if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
127 | + if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
128 | 128 | else $dir = $conf->bank->dir_output; |
129 | - $file = $dir . "/SPECIMEN.pdf"; |
|
129 | + $file = $dir."/SPECIMEN.pdf"; |
|
130 | 130 | } |
131 | 131 | else |
132 | 132 | { |
133 | 133 | $objectref = dol_sanitizeFileName($object->ref); |
134 | - if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
135 | - else $dir = $conf->bank->dir_output . "/" . $objectref; |
|
136 | - $file = $dir . "/" . $langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref . "-".dol_sanitizeFileName($object->rum).".pdf"; |
|
134 | + if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
135 | + else $dir = $conf->bank->dir_output."/".$objectref; |
|
136 | + $file = $dir."/".$langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref."-".dol_sanitizeFileName($object->rum).".pdf"; |
|
137 | 137 | } |
138 | 138 | |
139 | - if (! file_exists($dir)) |
|
139 | + if (!file_exists($dir)) |
|
140 | 140 | { |
141 | 141 | if (dol_mkdir($dir) < 0) |
142 | 142 | { |
143 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
143 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
144 | 144 | return 0; |
145 | 145 | } |
146 | 146 | } |
@@ -148,23 +148,23 @@ discard block |
||
148 | 148 | if (file_exists($dir)) |
149 | 149 | { |
150 | 150 | // Add pdfgeneration hook |
151 | - if (! is_object($hookmanager)) |
|
151 | + if (!is_object($hookmanager)) |
|
152 | 152 | { |
153 | 153 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
154 | - $hookmanager=new HookManager($this->db); |
|
154 | + $hookmanager = new HookManager($this->db); |
|
155 | 155 | } |
156 | 156 | $hookmanager->initHooks(array('pdfgeneration')); |
157 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
157 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
158 | 158 | global $action; |
159 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
159 | + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
160 | 160 | |
161 | - $pdf=pdf_getInstance($this->format); |
|
162 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
163 | - $heightforinfotot = 50; // Height reserved to output the info and total part |
|
164 | - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
165 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
166 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
167 | - $pdf->SetAutoPageBreak(1,0); |
|
161 | + $pdf = pdf_getInstance($this->format); |
|
162 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
163 | + $heightforinfotot = 50; // Height reserved to output the info and total part |
|
164 | + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page |
|
165 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
166 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; |
|
167 | + $pdf->SetAutoPageBreak(1, 0); |
|
168 | 168 | |
169 | 169 | if (class_exists('TCPDF')) |
170 | 170 | { |
@@ -174,25 +174,25 @@ discard block |
||
174 | 174 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
175 | 175 | |
176 | 176 | $pdf->Open(); |
177 | - $pagenb=0; |
|
178 | - $pdf->SetDrawColor(128,128,128); |
|
177 | + $pagenb = 0; |
|
178 | + $pdf->SetDrawColor(128, 128, 128); |
|
179 | 179 | |
180 | 180 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
181 | 181 | $pdf->SetSubject($outputlangs->transnoentities("SepaMandate")); |
182 | 182 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
183 | 183 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
184 | 184 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("SepaMandate")); |
185 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
185 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
186 | 186 | |
187 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
187 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
188 | 188 | |
189 | 189 | // New page |
190 | 190 | $pdf->AddPage(); |
191 | 191 | $pagenb++; |
192 | 192 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
193 | - $pdf->SetFont('','', $default_font_size - 1); |
|
194 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
195 | - $pdf->SetTextColor(0,0,0); |
|
193 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
194 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
195 | + $pdf->SetTextColor(0, 0, 0); |
|
196 | 196 | |
197 | 197 | $tab_top = 50; |
198 | 198 | $tab_height = 200; |
@@ -200,23 +200,23 @@ discard block |
||
200 | 200 | $tab_height_newpage = 210; |
201 | 201 | |
202 | 202 | // Affiche notes |
203 | - if (! empty($object->note_public)) |
|
203 | + if (!empty($object->note_public)) |
|
204 | 204 | { |
205 | - $pdf->SetFont('','', $default_font_size - 1); |
|
206 | - $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
205 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
206 | + $pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
207 | 207 | $nexY = $pdf->GetY(); |
208 | - $height_note=$nexY-($tab_top-2); |
|
208 | + $height_note = $nexY - ($tab_top - 2); |
|
209 | 209 | |
210 | 210 | // Rect prend une longueur en 3eme param |
211 | - $pdf->SetDrawColor(192,192,192); |
|
212 | - $pdf->Rect($this->marge_gauche, $tab_top-3, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
211 | + $pdf->SetDrawColor(192, 192, 192); |
|
212 | + $pdf->Rect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); |
|
213 | 213 | |
214 | 214 | $tab_height = $tab_height - $height_note; |
215 | - $tab_top = $nexY+6; |
|
215 | + $tab_top = $nexY + 6; |
|
216 | 216 | } |
217 | 217 | else |
218 | 218 | { |
219 | - $height_note=0; |
|
219 | + $height_note = 0; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | $iniY = $tab_top + 7; |
@@ -225,64 +225,64 @@ discard block |
||
225 | 225 | |
226 | 226 | $posY = $curY; |
227 | 227 | |
228 | - $pdf->SetFont('','', $default_font_size); |
|
228 | + $pdf->SetFont('', '', $default_font_size); |
|
229 | 229 | |
230 | 230 | $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); |
231 | - $posY+=2; |
|
231 | + $posY += 2; |
|
232 | 232 | |
233 | 233 | $pdf->SetXY($this->marge_gauche, $posY); |
234 | 234 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("RUMLong").' ('.$outputlangs->transnoentitiesnoconv("RUM").')'.' : '.$object->rum, 0, 'L'); |
235 | 235 | |
236 | - $posY=$pdf->GetY(); |
|
237 | - $posY+=2; |
|
236 | + $posY = $pdf->GetY(); |
|
237 | + $posY += 2; |
|
238 | 238 | $pdf->SetXY($this->marge_gauche, $posY); |
239 | - $ics=''; |
|
240 | - if (! empty($conf->global->PRELEVEMENT_ICS)) $ics=$conf->global->PRELEVEMENT_ICS; |
|
239 | + $ics = ''; |
|
240 | + if (!empty($conf->global->PRELEVEMENT_ICS)) $ics = $conf->global->PRELEVEMENT_ICS; |
|
241 | 241 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorIdentifier").' ('.$outputlangs->transnoentitiesnoconv("ICS").')'.' : '.$ics, 0, 'L'); |
242 | 242 | |
243 | - $posY=$pdf->GetY(); |
|
244 | - $posY+=1; |
|
243 | + $posY = $pdf->GetY(); |
|
244 | + $posY += 1; |
|
245 | 245 | $pdf->SetXY($this->marge_gauche, $posY); |
246 | 246 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorName").' : '.$mysoc->name, 0, 'L'); |
247 | 247 | |
248 | - $posY=$pdf->GetY(); |
|
249 | - $posY+=1; |
|
248 | + $posY = $pdf->GetY(); |
|
249 | + $posY += 1; |
|
250 | 250 | $pdf->SetXY($this->marge_gauche, $posY); |
251 | 251 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L'); |
252 | 252 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $mysoc->getFullAddress(), 0, 'L'); |
253 | 253 | |
254 | - $posY=$pdf->GetY(); |
|
255 | - $posY+=3; |
|
254 | + $posY = $pdf->GetY(); |
|
255 | + $posY += 3; |
|
256 | 256 | |
257 | 257 | $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); |
258 | 258 | |
259 | - $pdf->SetFont('','', $default_font_size - 1); |
|
259 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
260 | 260 | |
261 | - $posY+=8; |
|
261 | + $posY += 8; |
|
262 | 262 | $pdf->SetXY($this->marge_gauche, $posY); |
263 | 263 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 8, $outputlangs->transnoentitiesnoconv("SEPALegalText", $mysoc->name, $mysoc->name), 0, 'L'); |
264 | 264 | |
265 | 265 | // Your data form |
266 | - $posY=$pdf->GetY(); |
|
267 | - $posY+=8; |
|
266 | + $posY = $pdf->GetY(); |
|
267 | + $posY += 8; |
|
268 | 268 | $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); |
269 | - $posY+=2; |
|
269 | + $posY += 2; |
|
270 | 270 | |
271 | - $pdf->SetFont('','', $default_font_size); |
|
271 | + $pdf->SetFont('', '', $default_font_size); |
|
272 | 272 | |
273 | 273 | $pdf->SetXY($this->marge_gauche, $posY); |
274 | 274 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFillForm"), 0, 'C'); |
275 | 275 | |
276 | - $thirdparty=new Societe($this->db); |
|
276 | + $thirdparty = new Societe($this->db); |
|
277 | 277 | if ($object->socid > 0) $thirdparty->fetch($object->socid); |
278 | 278 | |
279 | 279 | $sepaname = '______________________________________________'; |
280 | 280 | if ($thirdparty->id > 0) |
281 | 281 | { |
282 | - $sepaname = $thirdparty->name.($object->account_owner?' ('.$object->account_owner.')':''); |
|
282 | + $sepaname = $thirdparty->name.($object->account_owner ? ' ('.$object->account_owner.')' : ''); |
|
283 | 283 | } |
284 | - $posY=$pdf->GetY(); |
|
285 | - $posY+=3; |
|
284 | + $posY = $pdf->GetY(); |
|
285 | + $posY += 3; |
|
286 | 286 | $pdf->SetXY($this->marge_gauche, $posY); |
287 | 287 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourName").' * : ', 0, 'L'); |
288 | 288 | $pdf->SetXY(80, $posY); |
@@ -293,40 +293,40 @@ discard block |
||
293 | 293 | { |
294 | 294 | $address = $thirdparty->getFullAddress(); |
295 | 295 | } |
296 | - $posY=$pdf->GetY(); |
|
297 | - $posY+=1; |
|
296 | + $posY = $pdf->GetY(); |
|
297 | + $posY += 1; |
|
298 | 298 | $pdf->SetXY($this->marge_gauche, $posY); |
299 | 299 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L'); |
300 | 300 | $pdf->SetXY(80, $posY); |
301 | 301 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L'); |
302 | 302 | if (preg_match('/_____/', $address)) |
303 | 303 | { |
304 | - $posY+=6; |
|
304 | + $posY += 6; |
|
305 | 305 | $pdf->SetXY(80, $posY); |
306 | 306 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L'); |
307 | 307 | } |
308 | 308 | |
309 | 309 | $ban = '__________________________________________________'; |
310 | - if (! empty($object->iban)) $ban = $object->iban; |
|
311 | - $posY=$pdf->GetY(); |
|
312 | - $posY+=1; |
|
310 | + if (!empty($object->iban)) $ban = $object->iban; |
|
311 | + $posY = $pdf->GetY(); |
|
312 | + $posY += 1; |
|
313 | 313 | $pdf->SetXY($this->marge_gauche, $posY); |
314 | 314 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBAN").' * : ', 0, 'L'); |
315 | 315 | $pdf->SetXY(80, $posY); |
316 | 316 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0, 'L'); |
317 | 317 | |
318 | 318 | $bic = '__________________________________________________'; |
319 | - if (! empty($object->bic)) $bic = $object->bic; |
|
320 | - $posY=$pdf->GetY(); |
|
321 | - $posY+=1; |
|
319 | + if (!empty($object->bic)) $bic = $object->bic; |
|
320 | + $posY = $pdf->GetY(); |
|
321 | + $posY += 1; |
|
322 | 322 | $pdf->SetXY($this->marge_gauche, $posY); |
323 | 323 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBIC").' * : ', 0, 'L'); |
324 | 324 | $pdf->SetXY(80, $posY); |
325 | 325 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $bic, 0, 'L'); |
326 | 326 | |
327 | 327 | |
328 | - $posY=$pdf->GetY(); |
|
329 | - $posY+=1; |
|
328 | + $posY = $pdf->GetY(); |
|
329 | + $posY += 1; |
|
330 | 330 | $pdf->SetXY($this->marge_gauche, $posY); |
331 | 331 | $txt = $outputlangs->transnoentitiesnoconv("SEPAFrstOrRecur").' * : '; |
332 | 332 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | $pdf->SetXY(86, $posY); |
337 | 337 | $txt = $langs->transnoentitiesnoconv("ModeRECUR").' '.$langs->transnoentitiesnoconv("or"); |
338 | 338 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
339 | - $posY+=6; |
|
339 | + $posY += 6; |
|
340 | 340 | $pdf->Rect(80, $posY, 5, 5); |
341 | 341 | $pdf->SetXY(80, $posY); |
342 | 342 | if ($object->frstrecur == 'FRST') $pdf->MultiCell(5, 3, 'X', 0, 'L'); |
@@ -345,28 +345,28 @@ discard block |
||
345 | 345 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
346 | 346 | if (empty($object->frstrecur)) |
347 | 347 | { |
348 | - $posY+=6; |
|
348 | + $posY += 6; |
|
349 | 349 | $pdf->SetXY(80, $posY); |
350 | 350 | $txt = '('.$langs->transnoentitiesnoconv("PleaseCheckOne").')'; |
351 | 351 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
352 | 352 | } |
353 | 353 | |
354 | - $posY=$pdf->GetY(); |
|
355 | - $posY+=3; |
|
354 | + $posY = $pdf->GetY(); |
|
355 | + $posY += 3; |
|
356 | 356 | $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); |
357 | - $posY+=3; |
|
357 | + $posY += 3; |
|
358 | 358 | |
359 | 359 | |
360 | 360 | // Show square |
361 | 361 | if ($pagenb == 1) |
362 | 362 | { |
363 | 363 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
364 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
364 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
365 | 365 | } |
366 | 366 | else |
367 | 367 | { |
368 | 368 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
369 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
369 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /*var_dump($tab_top); |
@@ -376,44 +376,44 @@ discard block |
||
376 | 376 | var_dump($bottomlasttab);*/ |
377 | 377 | |
378 | 378 | // Affiche zone infos |
379 | - $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); |
|
379 | + $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); |
|
380 | 380 | |
381 | 381 | /* |
382 | 382 | * Pied de page |
383 | 383 | */ |
384 | - $this->_pagefoot($pdf,$object,$outputlangs); |
|
385 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
384 | + $this->_pagefoot($pdf, $object, $outputlangs); |
|
385 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
386 | 386 | |
387 | 387 | $pdf->Close(); |
388 | 388 | |
389 | - $pdf->Output($file,'F'); |
|
389 | + $pdf->Output($file, 'F'); |
|
390 | 390 | |
391 | 391 | // Add pdfgeneration hook |
392 | - if (! is_object($hookmanager)) |
|
392 | + if (!is_object($hookmanager)) |
|
393 | 393 | { |
394 | 394 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
395 | - $hookmanager=new HookManager($this->db); |
|
395 | + $hookmanager = new HookManager($this->db); |
|
396 | 396 | } |
397 | 397 | $hookmanager->initHooks(array('pdfgeneration')); |
398 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
398 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
399 | 399 | global $action; |
400 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
400 | + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
401 | 401 | |
402 | - if (! empty($conf->global->MAIN_UMASK)) |
|
402 | + if (!empty($conf->global->MAIN_UMASK)) |
|
403 | 403 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
404 | 404 | |
405 | 405 | $this->result = array('fullpath'=>$file); |
406 | 406 | |
407 | - return 1; // Pas d'erreur |
|
407 | + return 1; // Pas d'erreur |
|
408 | 408 | } |
409 | 409 | else |
410 | 410 | { |
411 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
411 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
412 | 412 | return 0; |
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
416 | - $this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR"); |
|
416 | + $this->error = $langs->transnoentities("ErrorConstantNotDefined", "LIVRAISON_OUTPUTDIR"); |
|
417 | 417 | return 0; |
418 | 418 | } |
419 | 419 | |
@@ -430,9 +430,9 @@ discard block |
||
430 | 430 | * @param int $hidebottom Hide bottom bar of array |
431 | 431 | * @return void |
432 | 432 | */ |
433 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
433 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) |
|
434 | 434 | { |
435 | - global $conf,$mysoc; |
|
435 | + global $conf, $mysoc; |
|
436 | 436 | |
437 | 437 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
438 | 438 | } |
@@ -455,20 +455,20 @@ discard block |
||
455 | 455 | |
456 | 456 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
457 | 457 | |
458 | - $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?1:$conf->global->PDF_DIFFSIZE_TITLE); |
|
458 | + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 1 : $conf->global->PDF_DIFFSIZE_TITLE); |
|
459 | 459 | |
460 | - $posy+=$this->_signature_area($pdf, $object, $posy, $outputlangs); |
|
460 | + $posy += $this->_signature_area($pdf, $object, $posy, $outputlangs); |
|
461 | 461 | |
462 | 462 | $pdf->SetXY($this->marge_gauche, $posy); |
463 | - $pdf->SetFont('','', $default_font_size); |
|
463 | + $pdf->SetFont('', '', $default_font_size); |
|
464 | 464 | $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("PleaseReturnMandate", $mysoc->email).':', 0, 'L', 0); |
465 | - $posy=$pdf->GetY()+2; |
|
465 | + $posy = $pdf->GetY() + 2; |
|
466 | 466 | |
467 | 467 | $pdf->SetXY($this->marge_gauche, $posy); |
468 | - $pdf->SetFont('','', $default_font_size - $diffsizetitle); |
|
468 | + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); |
|
469 | 469 | $pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0); |
470 | 470 | $pdf->MultiCell(100, 6, $outputlangs->convToOutputCharset($mysoc->getFullAddress()), 0, 'L', 0); |
471 | - $posy=$pdf->GetY()+2; |
|
471 | + $posy = $pdf->GetY() + 2; |
|
472 | 472 | |
473 | 473 | return $posy; |
474 | 474 | } |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | $posx = $this->marge_gauche; |
496 | 496 | $pdf->SetXY($posx, $tab_top + 0); |
497 | 497 | |
498 | - $pdf->SetFont('','', $default_font_size - 2); |
|
498 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
499 | 499 | |
500 | 500 | $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("DateOfSignature"), 0, 'L', 0); |
501 | 501 | $pdf->MultiCell(100, 3, ' '); |
@@ -503,17 +503,17 @@ discard block |
||
503 | 503 | |
504 | 504 | $posx = 120; |
505 | 505 | $largcol = ($this->page_largeur - $this->marge_droite - $posx); |
506 | - $useborder=0; |
|
506 | + $useborder = 0; |
|
507 | 507 | $index = 0; |
508 | 508 | // Total HT |
509 | - $pdf->SetFillColor(255,255,255); |
|
509 | + $pdf->SetFillColor(255, 255, 255); |
|
510 | 510 | $pdf->SetXY($posx, $tab_top + 0); |
511 | 511 | $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1); |
512 | 512 | |
513 | 513 | $pdf->SetXY($posx, $tab_top + $tab_hl); |
514 | - $pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R'); |
|
514 | + $pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R'); |
|
515 | 515 | |
516 | - return ($tab_hl*7); |
|
516 | + return ($tab_hl * 7); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | |
@@ -528,61 +528,61 @@ discard block |
||
528 | 528 | */ |
529 | 529 | function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
530 | 530 | { |
531 | - global $langs,$conf,$mysoc; |
|
531 | + global $langs, $conf, $mysoc; |
|
532 | 532 | |
533 | 533 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
534 | 534 | |
535 | - pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
535 | + pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); |
|
536 | 536 | |
537 | - $pdf->SetTextColor(0,0,60); |
|
538 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
537 | + $pdf->SetTextColor(0, 0, 60); |
|
538 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
539 | 539 | |
540 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
541 | - $posy=$this->marge_haute; |
|
540 | + $posx = $this->page_largeur - $this->marge_droite - 100; |
|
541 | + $posy = $this->marge_haute; |
|
542 | 542 | |
543 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
543 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
544 | 544 | |
545 | 545 | // Logo |
546 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
546 | + $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
547 | 547 | if ($mysoc->logo) |
548 | 548 | { |
549 | 549 | if (is_readable($logo)) |
550 | 550 | { |
551 | - $height=pdf_getHeightForLogo($logo); |
|
552 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
551 | + $height = pdf_getHeightForLogo($logo); |
|
552 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
553 | 553 | } |
554 | 554 | else |
555 | 555 | { |
556 | - $pdf->SetTextColor(200,0,0); |
|
557 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
558 | - $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
556 | + $pdf->SetTextColor(200, 0, 0); |
|
557 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
558 | + $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); |
|
559 | 559 | $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
560 | 560 | } |
561 | 561 | } |
562 | 562 | else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
563 | 563 | |
564 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
565 | - $pdf->SetXY($posx,$posy); |
|
566 | - $pdf->SetTextColor(0,0,60); |
|
564 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
565 | + $pdf->SetXY($posx, $posy); |
|
566 | + $pdf->SetTextColor(0, 0, 60); |
|
567 | 567 | $pdf->MultiCell(100, 4, $outputlangs->transnoentities("SepaMandate"), '', 'R'); |
568 | - $pdf->SetFont('','', $default_font_size + 2); |
|
568 | + $pdf->SetFont('', '', $default_font_size + 2); |
|
569 | 569 | |
570 | - $posy+=6; |
|
571 | - $pdf->SetXY($posx,$posy); |
|
572 | - $pdf->SetTextColor(0,0,60); |
|
570 | + $posy += 6; |
|
571 | + $pdf->SetXY($posx, $posy); |
|
572 | + $pdf->SetTextColor(0, 0, 60); |
|
573 | 573 | $daterum = '__________________'; |
574 | - if (! empty($object->date_rum)) |
|
574 | + if (!empty($object->date_rum)) |
|
575 | 575 | { |
576 | - $daterum = dol_print_date($object->date_rum,'day',false,$outputlangs,true); |
|
576 | + $daterum = dol_print_date($object->date_rum, 'day', false, $outputlangs, true); |
|
577 | 577 | } |
578 | - else $daterum = dol_print_date($object->datec,'day',false,$outputlangs,true); // For old record, the date_rum was not saved. |
|
579 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . $daterum, '', 'R'); |
|
578 | + else $daterum = dol_print_date($object->datec, 'day', false, $outputlangs, true); // For old record, the date_rum was not saved. |
|
579 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".$daterum, '', 'R'); |
|
580 | 580 | /*$posy+=6; |
581 | 581 | $pdf->SetXY($posx,$posy); |
582 | 582 | $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R'); |
583 | 583 | */ |
584 | 584 | |
585 | - $pdf->SetTextColor(0,0,60); |
|
585 | + $pdf->SetTextColor(0, 0, 60); |
|
586 | 586 | |
587 | 587 | // Add list of linked objects |
588 | 588 | /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc.... |
@@ -618,10 +618,10 @@ discard block |
||
618 | 618 | * @param int $hidefreetext 1=Hide free text |
619 | 619 | * @return integer |
620 | 620 | */ |
621 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
621 | + function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) |
|
622 | 622 | { |
623 | 623 | global $conf; |
624 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
625 | - return pdf_pagefoot($pdf,$outputlangs,'PAYMENTORDER_FREE_TEXT',null,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
624 | + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
625 | + return pdf_pagefoot($pdf, $outputlangs, 'PAYMENTORDER_FREE_TEXT', null, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); |
|
626 | 626 | } |
627 | 627 | } |
@@ -80,7 +80,10 @@ discard block |
||
80 | 80 | |
81 | 81 | // Recupere emmetteur |
82 | 82 | $this->emetteur=$mysoc; |
83 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
83 | + if (! $this->emetteur->country_code) { |
|
84 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
85 | + } |
|
86 | + // By default if not defined |
|
84 | 87 | |
85 | 88 | // Defini position des colonnes |
86 | 89 | $this->posxref=$this->marge_gauche+1; |
@@ -110,9 +113,13 @@ discard block |
||
110 | 113 | // phpcs:enable |
111 | 114 | global $conf, $hookmanager, $langs, $user, $mysoc; |
112 | 115 | |
113 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
116 | + if (! is_object($outputlangs)) { |
|
117 | + $outputlangs=$langs; |
|
118 | + } |
|
114 | 119 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
115 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
120 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
121 | + $outputlangs->charset_output='ISO-8859-1'; |
|
122 | + } |
|
116 | 123 | |
117 | 124 | // Load traductions files requiredby by page |
118 | 125 | $outputlangs->loadLangs(array("main", "dict", "withdrawals", "companies", "projects", "bills")); |
@@ -124,15 +131,20 @@ discard block |
||
124 | 131 | // Definition of $dir and $file |
125 | 132 | if ($object->specimen) |
126 | 133 | { |
127 | - if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
128 | - else $dir = $conf->bank->dir_output; |
|
134 | + if (! empty($moreparams['force_dir_output'])) { |
|
135 | + $dir = $moreparams['force_dir_output']; |
|
136 | + } else { |
|
137 | + $dir = $conf->bank->dir_output; |
|
138 | + } |
|
129 | 139 | $file = $dir . "/SPECIMEN.pdf"; |
130 | - } |
|
131 | - else |
|
140 | + } else |
|
132 | 141 | { |
133 | 142 | $objectref = dol_sanitizeFileName($object->ref); |
134 | - if (! empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output']; |
|
135 | - else $dir = $conf->bank->dir_output . "/" . $objectref; |
|
143 | + if (! empty($moreparams['force_dir_output'])) { |
|
144 | + $dir = $moreparams['force_dir_output']; |
|
145 | + } else { |
|
146 | + $dir = $conf->bank->dir_output . "/" . $objectref; |
|
147 | + } |
|
136 | 148 | $file = $dir . "/" . $langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref . "-".dol_sanitizeFileName($object->rum).".pdf"; |
137 | 149 | } |
138 | 150 | |
@@ -163,7 +175,9 @@ discard block |
||
163 | 175 | $heightforinfotot = 50; // Height reserved to output the info and total part |
164 | 176 | $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
165 | 177 | $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
166 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
178 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) { |
|
179 | + $heightforfooter+= 6; |
|
180 | + } |
|
167 | 181 | $pdf->SetAutoPageBreak(1,0); |
168 | 182 | |
169 | 183 | if (class_exists('TCPDF')) |
@@ -182,7 +196,9 @@ discard block |
||
182 | 196 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
183 | 197 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
184 | 198 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("SepaMandate")); |
185 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
199 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
200 | + $pdf->SetCompression(false); |
|
201 | + } |
|
186 | 202 | |
187 | 203 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
188 | 204 | |
@@ -213,8 +229,7 @@ discard block |
||
213 | 229 | |
214 | 230 | $tab_height = $tab_height - $height_note; |
215 | 231 | $tab_top = $nexY+6; |
216 | - } |
|
217 | - else |
|
232 | + } else |
|
218 | 233 | { |
219 | 234 | $height_note=0; |
220 | 235 | } |
@@ -237,7 +252,9 @@ discard block |
||
237 | 252 | $posY+=2; |
238 | 253 | $pdf->SetXY($this->marge_gauche, $posY); |
239 | 254 | $ics=''; |
240 | - if (! empty($conf->global->PRELEVEMENT_ICS)) $ics=$conf->global->PRELEVEMENT_ICS; |
|
255 | + if (! empty($conf->global->PRELEVEMENT_ICS)) { |
|
256 | + $ics=$conf->global->PRELEVEMENT_ICS; |
|
257 | + } |
|
241 | 258 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorIdentifier").' ('.$outputlangs->transnoentitiesnoconv("ICS").')'.' : '.$ics, 0, 'L'); |
242 | 259 | |
243 | 260 | $posY=$pdf->GetY(); |
@@ -274,7 +291,9 @@ discard block |
||
274 | 291 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFillForm"), 0, 'C'); |
275 | 292 | |
276 | 293 | $thirdparty=new Societe($this->db); |
277 | - if ($object->socid > 0) $thirdparty->fetch($object->socid); |
|
294 | + if ($object->socid > 0) { |
|
295 | + $thirdparty->fetch($object->socid); |
|
296 | + } |
|
278 | 297 | |
279 | 298 | $sepaname = '______________________________________________'; |
280 | 299 | if ($thirdparty->id > 0) |
@@ -307,7 +326,9 @@ discard block |
||
307 | 326 | } |
308 | 327 | |
309 | 328 | $ban = '__________________________________________________'; |
310 | - if (! empty($object->iban)) $ban = $object->iban; |
|
329 | + if (! empty($object->iban)) { |
|
330 | + $ban = $object->iban; |
|
331 | + } |
|
311 | 332 | $posY=$pdf->GetY(); |
312 | 333 | $posY+=1; |
313 | 334 | $pdf->SetXY($this->marge_gauche, $posY); |
@@ -316,7 +337,9 @@ discard block |
||
316 | 337 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0, 'L'); |
317 | 338 | |
318 | 339 | $bic = '__________________________________________________'; |
319 | - if (! empty($object->bic)) $bic = $object->bic; |
|
340 | + if (! empty($object->bic)) { |
|
341 | + $bic = $object->bic; |
|
342 | + } |
|
320 | 343 | $posY=$pdf->GetY(); |
321 | 344 | $posY+=1; |
322 | 345 | $pdf->SetXY($this->marge_gauche, $posY); |
@@ -332,14 +355,18 @@ discard block |
||
332 | 355 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
333 | 356 | $pdf->Rect(80, $posY, 5, 5); |
334 | 357 | $pdf->SetXY(80, $posY); |
335 | - if ($object->frstrecur == 'RECUR') $pdf->MultiCell(5, 3, 'X', 0, 'L'); |
|
358 | + if ($object->frstrecur == 'RECUR') { |
|
359 | + $pdf->MultiCell(5, 3, 'X', 0, 'L'); |
|
360 | + } |
|
336 | 361 | $pdf->SetXY(86, $posY); |
337 | 362 | $txt = $langs->transnoentitiesnoconv("ModeRECUR").' '.$langs->transnoentitiesnoconv("or"); |
338 | 363 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
339 | 364 | $posY+=6; |
340 | 365 | $pdf->Rect(80, $posY, 5, 5); |
341 | 366 | $pdf->SetXY(80, $posY); |
342 | - if ($object->frstrecur == 'FRST') $pdf->MultiCell(5, 3, 'X', 0, 'L'); |
|
367 | + if ($object->frstrecur == 'FRST') { |
|
368 | + $pdf->MultiCell(5, 3, 'X', 0, 'L'); |
|
369 | + } |
|
343 | 370 | $pdf->SetXY(86, $posY); |
344 | 371 | $txt = $langs->transnoentitiesnoconv("ModeFRST"); |
345 | 372 | $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); |
@@ -362,8 +389,7 @@ discard block |
||
362 | 389 | { |
363 | 390 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
364 | 391 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
365 | - } |
|
366 | - else |
|
392 | + } else |
|
367 | 393 | { |
368 | 394 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
369 | 395 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
@@ -382,7 +408,9 @@ discard block |
||
382 | 408 | * Pied de page |
383 | 409 | */ |
384 | 410 | $this->_pagefoot($pdf,$object,$outputlangs); |
385 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
411 | + if (method_exists($pdf,'AliasNbPages')) { |
|
412 | + $pdf->AliasNbPages(); |
|
413 | + } |
|
386 | 414 | |
387 | 415 | $pdf->Close(); |
388 | 416 | |
@@ -399,14 +427,14 @@ discard block |
||
399 | 427 | global $action; |
400 | 428 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
401 | 429 | |
402 | - if (! empty($conf->global->MAIN_UMASK)) |
|
403 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
430 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
431 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
432 | + } |
|
404 | 433 | |
405 | 434 | $this->result = array('fullpath'=>$file); |
406 | 435 | |
407 | 436 | return 1; // Pas d'erreur |
408 | - } |
|
409 | - else |
|
437 | + } else |
|
410 | 438 | { |
411 | 439 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
412 | 440 | return 0; |
@@ -550,16 +578,16 @@ discard block |
||
550 | 578 | { |
551 | 579 | $height=pdf_getHeightForLogo($logo); |
552 | 580 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
553 | - } |
|
554 | - else |
|
581 | + } else |
|
555 | 582 | { |
556 | 583 | $pdf->SetTextColor(200,0,0); |
557 | 584 | $pdf->SetFont('','B', $default_font_size - 2); |
558 | 585 | $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
559 | 586 | $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
560 | 587 | } |
588 | + } else { |
|
589 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
561 | 590 | } |
562 | - else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
563 | 591 | |
564 | 592 | $pdf->SetFont('','B', $default_font_size + 3); |
565 | 593 | $pdf->SetXY($posx,$posy); |
@@ -574,8 +602,10 @@ discard block |
||
574 | 602 | if (! empty($object->date_rum)) |
575 | 603 | { |
576 | 604 | $daterum = dol_print_date($object->date_rum,'day',false,$outputlangs,true); |
605 | + } else { |
|
606 | + $daterum = dol_print_date($object->datec,'day',false,$outputlangs,true); |
|
577 | 607 | } |
578 | - else $daterum = dol_print_date($object->datec,'day',false,$outputlangs,true); // For old record, the date_rum was not saved. |
|
608 | + // For old record, the date_rum was not saved. |
|
579 | 609 | $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . $daterum, '', 'R'); |
580 | 610 | /*$posy+=6; |
581 | 611 | $pdf->SetXY($posx,$posy); |
@@ -35,128 +35,128 @@ discard block |
||
35 | 35 | |
36 | 36 | class pdf_ban extends ModeleBankAccountDoc |
37 | 37 | { |
38 | - /** |
|
39 | - * Issuer |
|
40 | - * @var Societe |
|
41 | - */ |
|
42 | - public $emetteur; |
|
38 | + /** |
|
39 | + * Issuer |
|
40 | + * @var Societe |
|
41 | + */ |
|
42 | + public $emetteur; |
|
43 | 43 | |
44 | - /** |
|
44 | + /** |
|
45 | 45 | * Dolibarr version of the loaded document |
46 | 46 | * @public string |
47 | 47 | */ |
48 | - public $version = 'development'; |
|
49 | - |
|
50 | - /** |
|
51 | - * Constructor |
|
52 | - * |
|
53 | - * @param DoliDB $db Database handler |
|
54 | - */ |
|
55 | - function __construct($db) |
|
56 | - { |
|
57 | - global $conf,$langs,$mysoc; |
|
58 | - |
|
59 | - // Load translation files required by the page |
|
48 | + public $version = 'development'; |
|
49 | + |
|
50 | + /** |
|
51 | + * Constructor |
|
52 | + * |
|
53 | + * @param DoliDB $db Database handler |
|
54 | + */ |
|
55 | + function __construct($db) |
|
56 | + { |
|
57 | + global $conf,$langs,$mysoc; |
|
58 | + |
|
59 | + // Load translation files required by the page |
|
60 | 60 | $langs->loadLangs(array("main","bank","withdrawals","companies")); |
61 | 61 | |
62 | - $this->db = $db; |
|
63 | - $this->name = "ban"; |
|
64 | - $this->description = $langs->trans("DocumentModelBan").' (Volunteer wanted to finish)'; |
|
65 | - |
|
66 | - // Dimension page pour format A4 |
|
67 | - $this->type = 'pdf'; |
|
68 | - $formatarray=pdf_getFormat(); |
|
69 | - $this->page_largeur = $formatarray['width']; |
|
70 | - $this->page_hauteur = $formatarray['height']; |
|
71 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
72 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
73 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
74 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
75 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
76 | - |
|
77 | - $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO |
|
78 | - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
79 | - $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
80 | - |
|
81 | - // Recupere emmetteur |
|
82 | - $this->emetteur=$mysoc; |
|
83 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
84 | - |
|
85 | - // Defini position des colonnes |
|
86 | - $this->posxref=$this->marge_gauche+1; |
|
87 | - $this->posxlabel=$this->marge_gauche+25; |
|
88 | - $this->posxworkload=$this->marge_gauche+100; |
|
89 | - $this->posxprogress=$this->marge_gauche+130; |
|
90 | - $this->posxdatestart=$this->marge_gauche+150; |
|
91 | - $this->posxdateend=$this->marge_gauche+170; |
|
92 | - } |
|
62 | + $this->db = $db; |
|
63 | + $this->name = "ban"; |
|
64 | + $this->description = $langs->trans("DocumentModelBan").' (Volunteer wanted to finish)'; |
|
65 | + |
|
66 | + // Dimension page pour format A4 |
|
67 | + $this->type = 'pdf'; |
|
68 | + $formatarray=pdf_getFormat(); |
|
69 | + $this->page_largeur = $formatarray['width']; |
|
70 | + $this->page_hauteur = $formatarray['height']; |
|
71 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
72 | + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
73 | + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
74 | + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
75 | + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
76 | + |
|
77 | + $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO |
|
78 | + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
79 | + $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
80 | + |
|
81 | + // Recupere emmetteur |
|
82 | + $this->emetteur=$mysoc; |
|
83 | + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
84 | + |
|
85 | + // Defini position des colonnes |
|
86 | + $this->posxref=$this->marge_gauche+1; |
|
87 | + $this->posxlabel=$this->marge_gauche+25; |
|
88 | + $this->posxworkload=$this->marge_gauche+100; |
|
89 | + $this->posxprogress=$this->marge_gauche+130; |
|
90 | + $this->posxdatestart=$this->marge_gauche+150; |
|
91 | + $this->posxdateend=$this->marge_gauche+170; |
|
92 | + } |
|
93 | 93 | |
94 | 94 | |
95 | 95 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
96 | - /** |
|
97 | - * Fonction generant le projet sur le disque |
|
98 | - * |
|
99 | - * @param Project $object Object project a generer |
|
100 | - * @param Translate $outputlangs Lang output object |
|
101 | - * @return int 1 if OK, <=0 if KO |
|
102 | - */ |
|
103 | - function write_file($object,$outputlangs) |
|
104 | - { |
|
96 | + /** |
|
97 | + * Fonction generant le projet sur le disque |
|
98 | + * |
|
99 | + * @param Project $object Object project a generer |
|
100 | + * @param Translate $outputlangs Lang output object |
|
101 | + * @return int 1 if OK, <=0 if KO |
|
102 | + */ |
|
103 | + function write_file($object,$outputlangs) |
|
104 | + { |
|
105 | 105 | // phpcs:enable |
106 | - global $conf, $hookmanager, $langs, $user; |
|
107 | - |
|
108 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
109 | - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
110 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
111 | - |
|
112 | - // Load traductions files requiredby by page |
|
113 | - $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); |
|
114 | - |
|
115 | - if ($conf->bank->dir_output) |
|
116 | - { |
|
117 | - //$nblignes = count($object->lines); // This is set later with array of tasks |
|
118 | - |
|
119 | - // Definition of $dir and $file |
|
120 | - if ($object->specimen) |
|
121 | - { |
|
122 | - $dir = $conf->bank->dir_output; |
|
123 | - $file = $dir . "/SPECIMEN.pdf"; |
|
124 | - } |
|
125 | - else |
|
126 | - { |
|
127 | - $objectref = dol_sanitizeFileName($object->ref); |
|
128 | - $dir = $conf->bank->dir_output . "/" . $objectref; |
|
129 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
130 | - } |
|
131 | - |
|
132 | - if (! file_exists($dir)) |
|
133 | - { |
|
134 | - if (dol_mkdir($dir) < 0) |
|
135 | - { |
|
136 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
137 | - return 0; |
|
138 | - } |
|
139 | - } |
|
140 | - |
|
141 | - if (file_exists($dir)) |
|
142 | - { |
|
143 | - // Add pdfgeneration hook |
|
144 | - if (! is_object($hookmanager)) |
|
145 | - { |
|
146 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
147 | - $hookmanager=new HookManager($this->db); |
|
148 | - } |
|
149 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
150 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
151 | - global $action; |
|
152 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
106 | + global $conf, $hookmanager, $langs, $user; |
|
107 | + |
|
108 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
109 | + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
110 | + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
111 | + |
|
112 | + // Load traductions files requiredby by page |
|
113 | + $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); |
|
114 | + |
|
115 | + if ($conf->bank->dir_output) |
|
116 | + { |
|
117 | + //$nblignes = count($object->lines); // This is set later with array of tasks |
|
118 | + |
|
119 | + // Definition of $dir and $file |
|
120 | + if ($object->specimen) |
|
121 | + { |
|
122 | + $dir = $conf->bank->dir_output; |
|
123 | + $file = $dir . "/SPECIMEN.pdf"; |
|
124 | + } |
|
125 | + else |
|
126 | + { |
|
127 | + $objectref = dol_sanitizeFileName($object->ref); |
|
128 | + $dir = $conf->bank->dir_output . "/" . $objectref; |
|
129 | + $file = $dir . "/" . $objectref . ".pdf"; |
|
130 | + } |
|
131 | + |
|
132 | + if (! file_exists($dir)) |
|
133 | + { |
|
134 | + if (dol_mkdir($dir) < 0) |
|
135 | + { |
|
136 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
137 | + return 0; |
|
138 | + } |
|
139 | + } |
|
140 | + |
|
141 | + if (file_exists($dir)) |
|
142 | + { |
|
143 | + // Add pdfgeneration hook |
|
144 | + if (! is_object($hookmanager)) |
|
145 | + { |
|
146 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
147 | + $hookmanager=new HookManager($this->db); |
|
148 | + } |
|
149 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
150 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
151 | + global $action; |
|
152 | + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
153 | 153 | |
154 | 154 | $pdf=pdf_getInstance($this->format); |
155 | 155 | $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
156 | 156 | $heightforinfotot = 50; // Height reserved to output the info and total part |
157 | - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
158 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
159 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
157 | + $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
158 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
159 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
160 | 160 | $pdf->SetAutoPageBreak(1,0); |
161 | 161 | |
162 | 162 | if (class_exists('TCPDF')) |
@@ -166,195 +166,195 @@ discard block |
||
166 | 166 | } |
167 | 167 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
168 | 168 | |
169 | - $pdf->Open(); |
|
170 | - $pagenb=0; |
|
171 | - $pdf->SetDrawColor(128,128,128); |
|
172 | - |
|
173 | - $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
174 | - $pdf->SetSubject($outputlangs->transnoentities("BAN")); |
|
175 | - $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
176 | - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
177 | - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("BAN")); |
|
178 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
179 | - |
|
180 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
181 | - |
|
182 | - // New page |
|
183 | - $pdf->AddPage(); |
|
184 | - $pagenb++; |
|
185 | - $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
186 | - $pdf->SetFont('','', $default_font_size - 1); |
|
187 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
188 | - $pdf->SetTextColor(0,0,0); |
|
189 | - |
|
190 | - $tab_top = 50; |
|
191 | - $tab_height = 200; |
|
192 | - $tab_top_newpage = 40; |
|
169 | + $pdf->Open(); |
|
170 | + $pagenb=0; |
|
171 | + $pdf->SetDrawColor(128,128,128); |
|
172 | + |
|
173 | + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
174 | + $pdf->SetSubject($outputlangs->transnoentities("BAN")); |
|
175 | + $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
176 | + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
177 | + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("BAN")); |
|
178 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
179 | + |
|
180 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
181 | + |
|
182 | + // New page |
|
183 | + $pdf->AddPage(); |
|
184 | + $pagenb++; |
|
185 | + $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
186 | + $pdf->SetFont('','', $default_font_size - 1); |
|
187 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
188 | + $pdf->SetTextColor(0,0,0); |
|
189 | + |
|
190 | + $tab_top = 50; |
|
191 | + $tab_height = 200; |
|
192 | + $tab_top_newpage = 40; |
|
193 | 193 | $tab_height_newpage = 210; |
194 | 194 | |
195 | - // Affiche notes |
|
196 | - if (! empty($object->note_public)) |
|
197 | - { |
|
198 | - $pdf->SetFont('','', $default_font_size - 1); |
|
199 | - $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
200 | - $nexY = $pdf->GetY(); |
|
201 | - $height_note=$nexY-($tab_top-2); |
|
202 | - |
|
203 | - // Rect prend une longueur en 3eme param |
|
204 | - $pdf->SetDrawColor(192,192,192); |
|
205 | - $pdf->Rect($this->marge_gauche, $tab_top-3, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
206 | - |
|
207 | - $tab_height = $tab_height - $height_note; |
|
208 | - $tab_top = $nexY+6; |
|
209 | - } |
|
210 | - else |
|
211 | - { |
|
212 | - $height_note=0; |
|
213 | - } |
|
214 | - |
|
215 | - $iniY = $tab_top + 7; |
|
216 | - $curY = $tab_top + 7; |
|
217 | - $nexY = $tab_top + 7; |
|
218 | - |
|
219 | - $pdf->SetXY($this->marge_gauche, $curY); |
|
220 | - $pdf->MultiCell(200, 3, $outputlangs->trans("BAN").' : '.$object->account_number, 0, 'L'); |
|
221 | - |
|
222 | - |
|
223 | - |
|
224 | - // Show square |
|
225 | - if ($pagenb == 1) |
|
226 | - { |
|
227 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
228 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
229 | - } |
|
230 | - else |
|
231 | - { |
|
232 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
233 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
234 | - } |
|
235 | - |
|
236 | - /* |
|
195 | + // Affiche notes |
|
196 | + if (! empty($object->note_public)) |
|
197 | + { |
|
198 | + $pdf->SetFont('','', $default_font_size - 1); |
|
199 | + $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
200 | + $nexY = $pdf->GetY(); |
|
201 | + $height_note=$nexY-($tab_top-2); |
|
202 | + |
|
203 | + // Rect prend une longueur en 3eme param |
|
204 | + $pdf->SetDrawColor(192,192,192); |
|
205 | + $pdf->Rect($this->marge_gauche, $tab_top-3, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
206 | + |
|
207 | + $tab_height = $tab_height - $height_note; |
|
208 | + $tab_top = $nexY+6; |
|
209 | + } |
|
210 | + else |
|
211 | + { |
|
212 | + $height_note=0; |
|
213 | + } |
|
214 | + |
|
215 | + $iniY = $tab_top + 7; |
|
216 | + $curY = $tab_top + 7; |
|
217 | + $nexY = $tab_top + 7; |
|
218 | + |
|
219 | + $pdf->SetXY($this->marge_gauche, $curY); |
|
220 | + $pdf->MultiCell(200, 3, $outputlangs->trans("BAN").' : '.$object->account_number, 0, 'L'); |
|
221 | + |
|
222 | + |
|
223 | + |
|
224 | + // Show square |
|
225 | + if ($pagenb == 1) |
|
226 | + { |
|
227 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
228 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
229 | + } |
|
230 | + else |
|
231 | + { |
|
232 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
233 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
234 | + } |
|
235 | + |
|
236 | + /* |
|
237 | 237 | * Pied de page |
238 | 238 | */ |
239 | - $this->_pagefoot($pdf,$object,$outputlangs); |
|
240 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
241 | - |
|
242 | - $pdf->Close(); |
|
243 | - |
|
244 | - $pdf->Output($file,'F'); |
|
245 | - |
|
246 | - // Add pdfgeneration hook |
|
247 | - if (! is_object($hookmanager)) |
|
248 | - { |
|
249 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
250 | - $hookmanager=new HookManager($this->db); |
|
251 | - } |
|
252 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
253 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
254 | - global $action; |
|
255 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
256 | - |
|
257 | - if (! empty($conf->global->MAIN_UMASK)) |
|
258 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
259 | - |
|
260 | - $this->result = array('fullpath'=>$file); |
|
261 | - |
|
262 | - return 1; // Pas d'erreur |
|
263 | - } |
|
264 | - else |
|
265 | - { |
|
266 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
267 | - return 0; |
|
268 | - } |
|
269 | - } |
|
270 | - |
|
271 | - $this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR"); |
|
272 | - return 0; |
|
273 | - } |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * Show table for lines |
|
278 | - * |
|
279 | - * @param PDF $pdf Object PDF |
|
280 | - * @param string $tab_top Top position of table |
|
281 | - * @param string $tab_height Height of table (rectangle) |
|
282 | - * @param int $nexY Y |
|
283 | - * @param Translate $outputlangs Langs object |
|
284 | - * @param int $hidetop Hide top bar of array |
|
285 | - * @param int $hidebottom Hide bottom bar of array |
|
286 | - * @return void |
|
287 | - */ |
|
288 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
289 | - { |
|
290 | - global $conf,$mysoc; |
|
239 | + $this->_pagefoot($pdf,$object,$outputlangs); |
|
240 | + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
241 | + |
|
242 | + $pdf->Close(); |
|
243 | + |
|
244 | + $pdf->Output($file,'F'); |
|
245 | + |
|
246 | + // Add pdfgeneration hook |
|
247 | + if (! is_object($hookmanager)) |
|
248 | + { |
|
249 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
250 | + $hookmanager=new HookManager($this->db); |
|
251 | + } |
|
252 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
253 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
254 | + global $action; |
|
255 | + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
256 | + |
|
257 | + if (! empty($conf->global->MAIN_UMASK)) |
|
258 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
259 | + |
|
260 | + $this->result = array('fullpath'=>$file); |
|
261 | + |
|
262 | + return 1; // Pas d'erreur |
|
263 | + } |
|
264 | + else |
|
265 | + { |
|
266 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
267 | + return 0; |
|
268 | + } |
|
269 | + } |
|
270 | + |
|
271 | + $this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR"); |
|
272 | + return 0; |
|
273 | + } |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * Show table for lines |
|
278 | + * |
|
279 | + * @param PDF $pdf Object PDF |
|
280 | + * @param string $tab_top Top position of table |
|
281 | + * @param string $tab_height Height of table (rectangle) |
|
282 | + * @param int $nexY Y |
|
283 | + * @param Translate $outputlangs Langs object |
|
284 | + * @param int $hidetop Hide top bar of array |
|
285 | + * @param int $hidebottom Hide bottom bar of array |
|
286 | + * @return void |
|
287 | + */ |
|
288 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
289 | + { |
|
290 | + global $conf,$mysoc; |
|
291 | 291 | |
292 | 292 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
293 | - } |
|
293 | + } |
|
294 | 294 | |
295 | - /** |
|
296 | - * Show top header of page. |
|
297 | - * |
|
298 | - * @param PDF $pdf Object PDF |
|
299 | - * @param Project $object Object to show |
|
300 | - * @param int $showaddress 0=no, 1=yes |
|
301 | - * @param Translate $outputlangs Object lang for output |
|
302 | - * @return void |
|
303 | - */ |
|
304 | - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
305 | - { |
|
306 | - global $langs,$conf,$mysoc; |
|
295 | + /** |
|
296 | + * Show top header of page. |
|
297 | + * |
|
298 | + * @param PDF $pdf Object PDF |
|
299 | + * @param Project $object Object to show |
|
300 | + * @param int $showaddress 0=no, 1=yes |
|
301 | + * @param Translate $outputlangs Object lang for output |
|
302 | + * @return void |
|
303 | + */ |
|
304 | + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
305 | + { |
|
306 | + global $langs,$conf,$mysoc; |
|
307 | 307 | |
308 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
308 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
309 | 309 | |
310 | - pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
310 | + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
311 | 311 | |
312 | - $pdf->SetTextColor(0,0,60); |
|
313 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
312 | + $pdf->SetTextColor(0,0,60); |
|
313 | + $pdf->SetFont('','B', $default_font_size + 3); |
|
314 | 314 | |
315 | 315 | $posx=$this->page_largeur-$this->marge_droite-100; |
316 | - $posy=$this->marge_haute; |
|
317 | - |
|
318 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
319 | - |
|
320 | - // Logo |
|
321 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
322 | - if ($mysoc->logo) |
|
323 | - { |
|
324 | - if (is_readable($logo)) |
|
325 | - { |
|
326 | - $height=pdf_getHeightForLogo($logo); |
|
327 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
328 | - } |
|
329 | - else |
|
330 | - { |
|
331 | - $pdf->SetTextColor(200,0,0); |
|
332 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
333 | - $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
334 | - $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
|
335 | - } |
|
336 | - } |
|
337 | - else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
338 | - |
|
339 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
340 | - $pdf->SetXY($posx,$posy); |
|
341 | - $pdf->SetTextColor(0,0,60); |
|
342 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("BAN")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); |
|
343 | - $pdf->SetFont('','', $default_font_size + 2); |
|
344 | - |
|
345 | - $posy+=6; |
|
346 | - $pdf->SetXY($posx,$posy); |
|
347 | - $pdf->SetTextColor(0,0,60); |
|
348 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date(dol_now(),'day',false,$outputlangs,true), '', 'R'); |
|
349 | - /*$posy+=6; |
|
316 | + $posy=$this->marge_haute; |
|
317 | + |
|
318 | + $pdf->SetXY($this->marge_gauche,$posy); |
|
319 | + |
|
320 | + // Logo |
|
321 | + $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
322 | + if ($mysoc->logo) |
|
323 | + { |
|
324 | + if (is_readable($logo)) |
|
325 | + { |
|
326 | + $height=pdf_getHeightForLogo($logo); |
|
327 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
328 | + } |
|
329 | + else |
|
330 | + { |
|
331 | + $pdf->SetTextColor(200,0,0); |
|
332 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
333 | + $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
334 | + $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
|
335 | + } |
|
336 | + } |
|
337 | + else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
338 | + |
|
339 | + $pdf->SetFont('','B', $default_font_size + 3); |
|
340 | + $pdf->SetXY($posx,$posy); |
|
341 | + $pdf->SetTextColor(0,0,60); |
|
342 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("BAN")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); |
|
343 | + $pdf->SetFont('','', $default_font_size + 2); |
|
344 | + |
|
345 | + $posy+=6; |
|
346 | + $pdf->SetXY($posx,$posy); |
|
347 | + $pdf->SetTextColor(0,0,60); |
|
348 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date(dol_now(),'day',false,$outputlangs,true), '', 'R'); |
|
349 | + /*$posy+=6; |
|
350 | 350 | $pdf->SetXY($posx,$posy); |
351 | 351 | $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R'); |
352 | 352 | */ |
353 | 353 | |
354 | - $pdf->SetTextColor(0,0,60); |
|
354 | + $pdf->SetTextColor(0,0,60); |
|
355 | 355 | |
356 | - // Add list of linked objects |
|
357 | - /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc.... |
|
356 | + // Add list of linked objects |
|
357 | + /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc.... |
|
358 | 358 | $object->fetchObjectLinked(); |
359 | 359 | |
360 | 360 | foreach($object->linkedObjects as $objecttype => $objects) |
@@ -376,21 +376,21 @@ discard block |
||
376 | 376 | } |
377 | 377 | } |
378 | 378 | */ |
379 | - } |
|
379 | + } |
|
380 | 380 | |
381 | - /** |
|
382 | - * Show footer of page. Need this->emetteur object |
|
381 | + /** |
|
382 | + * Show footer of page. Need this->emetteur object |
|
383 | 383 | * |
384 | - * @param PDF $pdf PDF |
|
385 | - * @param Project $object Object to show |
|
386 | - * @param Translate $outputlangs Object lang for output |
|
387 | - * @param int $hidefreetext 1=Hide free text |
|
388 | - * @return integer |
|
389 | - */ |
|
390 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
391 | - { |
|
392 | - global $conf; |
|
393 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
394 | - //return pdf_pagefoot($pdf,$outputlangs,'BANK_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
395 | - } |
|
384 | + * @param PDF $pdf PDF |
|
385 | + * @param Project $object Object to show |
|
386 | + * @param Translate $outputlangs Object lang for output |
|
387 | + * @param int $hidefreetext 1=Hide free text |
|
388 | + * @return integer |
|
389 | + */ |
|
390 | + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
391 | + { |
|
392 | + global $conf; |
|
393 | + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
394 | + //return pdf_pagefoot($pdf,$outputlangs,'BANK_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
395 | + } |
|
396 | 396 | } |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | */ |
55 | 55 | function __construct($db) |
56 | 56 | { |
57 | - global $conf,$langs,$mysoc; |
|
57 | + global $conf, $langs, $mysoc; |
|
58 | 58 | |
59 | 59 | // Load translation files required by the page |
60 | - $langs->loadLangs(array("main","bank","withdrawals","companies")); |
|
60 | + $langs->loadLangs(array("main", "bank", "withdrawals", "companies")); |
|
61 | 61 | |
62 | 62 | $this->db = $db; |
63 | 63 | $this->name = "ban"; |
@@ -65,30 +65,30 @@ discard block |
||
65 | 65 | |
66 | 66 | // Dimension page pour format A4 |
67 | 67 | $this->type = 'pdf'; |
68 | - $formatarray=pdf_getFormat(); |
|
68 | + $formatarray = pdf_getFormat(); |
|
69 | 69 | $this->page_largeur = $formatarray['width']; |
70 | 70 | $this->page_hauteur = $formatarray['height']; |
71 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
72 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
73 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
74 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
75 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
71 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
72 | + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; |
|
73 | + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; |
|
74 | + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; |
|
75 | + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; |
|
76 | 76 | |
77 | - $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO |
|
78 | - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
79 | - $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
77 | + $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO |
|
78 | + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
79 | + $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
80 | 80 | |
81 | 81 | // Recupere emmetteur |
82 | - $this->emetteur=$mysoc; |
|
83 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
82 | + $this->emetteur = $mysoc; |
|
83 | + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined |
|
84 | 84 | |
85 | 85 | // Defini position des colonnes |
86 | - $this->posxref=$this->marge_gauche+1; |
|
87 | - $this->posxlabel=$this->marge_gauche+25; |
|
88 | - $this->posxworkload=$this->marge_gauche+100; |
|
89 | - $this->posxprogress=$this->marge_gauche+130; |
|
90 | - $this->posxdatestart=$this->marge_gauche+150; |
|
91 | - $this->posxdateend=$this->marge_gauche+170; |
|
86 | + $this->posxref = $this->marge_gauche + 1; |
|
87 | + $this->posxlabel = $this->marge_gauche + 25; |
|
88 | + $this->posxworkload = $this->marge_gauche + 100; |
|
89 | + $this->posxprogress = $this->marge_gauche + 130; |
|
90 | + $this->posxdatestart = $this->marge_gauche + 150; |
|
91 | + $this->posxdateend = $this->marge_gauche + 170; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | * @param Translate $outputlangs Lang output object |
101 | 101 | * @return int 1 if OK, <=0 if KO |
102 | 102 | */ |
103 | - function write_file($object,$outputlangs) |
|
103 | + function write_file($object, $outputlangs) |
|
104 | 104 | { |
105 | 105 | // phpcs:enable |
106 | 106 | global $conf, $hookmanager, $langs, $user; |
107 | 107 | |
108 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
108 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
109 | 109 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
110 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
110 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
111 | 111 | |
112 | 112 | // Load traductions files requiredby by page |
113 | 113 | $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); |
@@ -120,20 +120,20 @@ discard block |
||
120 | 120 | if ($object->specimen) |
121 | 121 | { |
122 | 122 | $dir = $conf->bank->dir_output; |
123 | - $file = $dir . "/SPECIMEN.pdf"; |
|
123 | + $file = $dir."/SPECIMEN.pdf"; |
|
124 | 124 | } |
125 | 125 | else |
126 | 126 | { |
127 | 127 | $objectref = dol_sanitizeFileName($object->ref); |
128 | - $dir = $conf->bank->dir_output . "/" . $objectref; |
|
129 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
128 | + $dir = $conf->bank->dir_output."/".$objectref; |
|
129 | + $file = $dir."/".$objectref.".pdf"; |
|
130 | 130 | } |
131 | 131 | |
132 | - if (! file_exists($dir)) |
|
132 | + if (!file_exists($dir)) |
|
133 | 133 | { |
134 | 134 | if (dol_mkdir($dir) < 0) |
135 | 135 | { |
136 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
136 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
137 | 137 | return 0; |
138 | 138 | } |
139 | 139 | } |
@@ -141,23 +141,23 @@ discard block |
||
141 | 141 | if (file_exists($dir)) |
142 | 142 | { |
143 | 143 | // Add pdfgeneration hook |
144 | - if (! is_object($hookmanager)) |
|
144 | + if (!is_object($hookmanager)) |
|
145 | 145 | { |
146 | 146 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
147 | - $hookmanager=new HookManager($this->db); |
|
147 | + $hookmanager = new HookManager($this->db); |
|
148 | 148 | } |
149 | 149 | $hookmanager->initHooks(array('pdfgeneration')); |
150 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
150 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
151 | 151 | global $action; |
152 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
152 | + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
153 | 153 | |
154 | - $pdf=pdf_getInstance($this->format); |
|
155 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
156 | - $heightforinfotot = 50; // Height reserved to output the info and total part |
|
157 | - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
158 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
159 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
160 | - $pdf->SetAutoPageBreak(1,0); |
|
154 | + $pdf = pdf_getInstance($this->format); |
|
155 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
156 | + $heightforinfotot = 50; // Height reserved to output the info and total part |
|
157 | + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page |
|
158 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
159 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; |
|
160 | + $pdf->SetAutoPageBreak(1, 0); |
|
161 | 161 | |
162 | 162 | if (class_exists('TCPDF')) |
163 | 163 | { |
@@ -167,25 +167,25 @@ discard block |
||
167 | 167 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
168 | 168 | |
169 | 169 | $pdf->Open(); |
170 | - $pagenb=0; |
|
171 | - $pdf->SetDrawColor(128,128,128); |
|
170 | + $pagenb = 0; |
|
171 | + $pdf->SetDrawColor(128, 128, 128); |
|
172 | 172 | |
173 | 173 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
174 | 174 | $pdf->SetSubject($outputlangs->transnoentities("BAN")); |
175 | 175 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
176 | 176 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
177 | 177 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("BAN")); |
178 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
178 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
179 | 179 | |
180 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
180 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
181 | 181 | |
182 | 182 | // New page |
183 | 183 | $pdf->AddPage(); |
184 | 184 | $pagenb++; |
185 | 185 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
186 | - $pdf->SetFont('','', $default_font_size - 1); |
|
187 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
188 | - $pdf->SetTextColor(0,0,0); |
|
186 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
187 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
188 | + $pdf->SetTextColor(0, 0, 0); |
|
189 | 189 | |
190 | 190 | $tab_top = 50; |
191 | 191 | $tab_height = 200; |
@@ -193,23 +193,23 @@ discard block |
||
193 | 193 | $tab_height_newpage = 210; |
194 | 194 | |
195 | 195 | // Affiche notes |
196 | - if (! empty($object->note_public)) |
|
196 | + if (!empty($object->note_public)) |
|
197 | 197 | { |
198 | - $pdf->SetFont('','', $default_font_size - 1); |
|
199 | - $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
198 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
199 | + $pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
200 | 200 | $nexY = $pdf->GetY(); |
201 | - $height_note=$nexY-($tab_top-2); |
|
201 | + $height_note = $nexY - ($tab_top - 2); |
|
202 | 202 | |
203 | 203 | // Rect prend une longueur en 3eme param |
204 | - $pdf->SetDrawColor(192,192,192); |
|
205 | - $pdf->Rect($this->marge_gauche, $tab_top-3, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
204 | + $pdf->SetDrawColor(192, 192, 192); |
|
205 | + $pdf->Rect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); |
|
206 | 206 | |
207 | 207 | $tab_height = $tab_height - $height_note; |
208 | - $tab_top = $nexY+6; |
|
208 | + $tab_top = $nexY + 6; |
|
209 | 209 | } |
210 | 210 | else |
211 | 211 | { |
212 | - $height_note=0; |
|
212 | + $height_note = 0; |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | $iniY = $tab_top + 7; |
@@ -225,50 +225,50 @@ discard block |
||
225 | 225 | if ($pagenb == 1) |
226 | 226 | { |
227 | 227 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
228 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
228 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
229 | 229 | } |
230 | 230 | else |
231 | 231 | { |
232 | 232 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
233 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
233 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /* |
237 | 237 | * Pied de page |
238 | 238 | */ |
239 | - $this->_pagefoot($pdf,$object,$outputlangs); |
|
240 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
239 | + $this->_pagefoot($pdf, $object, $outputlangs); |
|
240 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
241 | 241 | |
242 | 242 | $pdf->Close(); |
243 | 243 | |
244 | - $pdf->Output($file,'F'); |
|
244 | + $pdf->Output($file, 'F'); |
|
245 | 245 | |
246 | 246 | // Add pdfgeneration hook |
247 | - if (! is_object($hookmanager)) |
|
247 | + if (!is_object($hookmanager)) |
|
248 | 248 | { |
249 | 249 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
250 | - $hookmanager=new HookManager($this->db); |
|
250 | + $hookmanager = new HookManager($this->db); |
|
251 | 251 | } |
252 | 252 | $hookmanager->initHooks(array('pdfgeneration')); |
253 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
253 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
254 | 254 | global $action; |
255 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
255 | + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
256 | 256 | |
257 | - if (! empty($conf->global->MAIN_UMASK)) |
|
257 | + if (!empty($conf->global->MAIN_UMASK)) |
|
258 | 258 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
259 | 259 | |
260 | 260 | $this->result = array('fullpath'=>$file); |
261 | 261 | |
262 | - return 1; // Pas d'erreur |
|
262 | + return 1; // Pas d'erreur |
|
263 | 263 | } |
264 | 264 | else |
265 | 265 | { |
266 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
266 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
267 | 267 | return 0; |
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
271 | - $this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR"); |
|
271 | + $this->error = $langs->transnoentities("ErrorConstantNotDefined", "LIVRAISON_OUTPUTDIR"); |
|
272 | 272 | return 0; |
273 | 273 | } |
274 | 274 | |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | * @param int $hidebottom Hide bottom bar of array |
286 | 286 | * @return void |
287 | 287 | */ |
288 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
288 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) |
|
289 | 289 | { |
290 | - global $conf,$mysoc; |
|
290 | + global $conf, $mysoc; |
|
291 | 291 | |
292 | 292 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
293 | 293 | } |
@@ -303,55 +303,55 @@ discard block |
||
303 | 303 | */ |
304 | 304 | function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
305 | 305 | { |
306 | - global $langs,$conf,$mysoc; |
|
306 | + global $langs, $conf, $mysoc; |
|
307 | 307 | |
308 | 308 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
309 | 309 | |
310 | - pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
310 | + pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); |
|
311 | 311 | |
312 | - $pdf->SetTextColor(0,0,60); |
|
313 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
312 | + $pdf->SetTextColor(0, 0, 60); |
|
313 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
314 | 314 | |
315 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
316 | - $posy=$this->marge_haute; |
|
315 | + $posx = $this->page_largeur - $this->marge_droite - 100; |
|
316 | + $posy = $this->marge_haute; |
|
317 | 317 | |
318 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
318 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
319 | 319 | |
320 | 320 | // Logo |
321 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
321 | + $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
322 | 322 | if ($mysoc->logo) |
323 | 323 | { |
324 | 324 | if (is_readable($logo)) |
325 | 325 | { |
326 | - $height=pdf_getHeightForLogo($logo); |
|
327 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
326 | + $height = pdf_getHeightForLogo($logo); |
|
327 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
328 | 328 | } |
329 | 329 | else |
330 | 330 | { |
331 | - $pdf->SetTextColor(200,0,0); |
|
332 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
333 | - $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
331 | + $pdf->SetTextColor(200, 0, 0); |
|
332 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
333 | + $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); |
|
334 | 334 | $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
335 | 335 | } |
336 | 336 | } |
337 | 337 | else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
338 | 338 | |
339 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
340 | - $pdf->SetXY($posx,$posy); |
|
341 | - $pdf->SetTextColor(0,0,60); |
|
339 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
340 | + $pdf->SetXY($posx, $posy); |
|
341 | + $pdf->SetTextColor(0, 0, 60); |
|
342 | 342 | $pdf->MultiCell(100, 4, $outputlangs->transnoentities("BAN")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); |
343 | - $pdf->SetFont('','', $default_font_size + 2); |
|
343 | + $pdf->SetFont('', '', $default_font_size + 2); |
|
344 | 344 | |
345 | - $posy+=6; |
|
346 | - $pdf->SetXY($posx,$posy); |
|
347 | - $pdf->SetTextColor(0,0,60); |
|
348 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date(dol_now(),'day',false,$outputlangs,true), '', 'R'); |
|
345 | + $posy += 6; |
|
346 | + $pdf->SetXY($posx, $posy); |
|
347 | + $pdf->SetTextColor(0, 0, 60); |
|
348 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".dol_print_date(dol_now(), 'day', false, $outputlangs, true), '', 'R'); |
|
349 | 349 | /*$posy+=6; |
350 | 350 | $pdf->SetXY($posx,$posy); |
351 | 351 | $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R'); |
352 | 352 | */ |
353 | 353 | |
354 | - $pdf->SetTextColor(0,0,60); |
|
354 | + $pdf->SetTextColor(0, 0, 60); |
|
355 | 355 | |
356 | 356 | // Add list of linked objects |
357 | 357 | /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc.... |
@@ -387,10 +387,10 @@ discard block |
||
387 | 387 | * @param int $hidefreetext 1=Hide free text |
388 | 388 | * @return integer |
389 | 389 | */ |
390 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
390 | + function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) |
|
391 | 391 | { |
392 | 392 | global $conf; |
393 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
393 | + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
394 | 394 | //return pdf_pagefoot($pdf,$outputlangs,'BANK_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
395 | 395 | } |
396 | 396 | } |
@@ -80,7 +80,10 @@ discard block |
||
80 | 80 | |
81 | 81 | // Recupere emmetteur |
82 | 82 | $this->emetteur=$mysoc; |
83 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
83 | + if (! $this->emetteur->country_code) { |
|
84 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
85 | + } |
|
86 | + // By default if not defined |
|
84 | 87 | |
85 | 88 | // Defini position des colonnes |
86 | 89 | $this->posxref=$this->marge_gauche+1; |
@@ -105,9 +108,13 @@ discard block |
||
105 | 108 | // phpcs:enable |
106 | 109 | global $conf, $hookmanager, $langs, $user; |
107 | 110 | |
108 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
111 | + if (! is_object($outputlangs)) { |
|
112 | + $outputlangs=$langs; |
|
113 | + } |
|
109 | 114 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
110 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
115 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
116 | + $outputlangs->charset_output='ISO-8859-1'; |
|
117 | + } |
|
111 | 118 | |
112 | 119 | // Load traductions files requiredby by page |
113 | 120 | $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); |
@@ -121,8 +128,7 @@ discard block |
||
121 | 128 | { |
122 | 129 | $dir = $conf->bank->dir_output; |
123 | 130 | $file = $dir . "/SPECIMEN.pdf"; |
124 | - } |
|
125 | - else |
|
131 | + } else |
|
126 | 132 | { |
127 | 133 | $objectref = dol_sanitizeFileName($object->ref); |
128 | 134 | $dir = $conf->bank->dir_output . "/" . $objectref; |
@@ -156,7 +162,9 @@ discard block |
||
156 | 162 | $heightforinfotot = 50; // Height reserved to output the info and total part |
157 | 163 | $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
158 | 164 | $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
159 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
165 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) { |
|
166 | + $heightforfooter+= 6; |
|
167 | + } |
|
160 | 168 | $pdf->SetAutoPageBreak(1,0); |
161 | 169 | |
162 | 170 | if (class_exists('TCPDF')) |
@@ -175,7 +183,9 @@ discard block |
||
175 | 183 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
176 | 184 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
177 | 185 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("BAN")); |
178 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
186 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
187 | + $pdf->SetCompression(false); |
|
188 | + } |
|
179 | 189 | |
180 | 190 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
181 | 191 | |
@@ -206,8 +216,7 @@ discard block |
||
206 | 216 | |
207 | 217 | $tab_height = $tab_height - $height_note; |
208 | 218 | $tab_top = $nexY+6; |
209 | - } |
|
210 | - else |
|
219 | + } else |
|
211 | 220 | { |
212 | 221 | $height_note=0; |
213 | 222 | } |
@@ -226,8 +235,7 @@ discard block |
||
226 | 235 | { |
227 | 236 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
228 | 237 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
229 | - } |
|
230 | - else |
|
238 | + } else |
|
231 | 239 | { |
232 | 240 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
233 | 241 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
@@ -237,7 +245,9 @@ discard block |
||
237 | 245 | * Pied de page |
238 | 246 | */ |
239 | 247 | $this->_pagefoot($pdf,$object,$outputlangs); |
240 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
248 | + if (method_exists($pdf,'AliasNbPages')) { |
|
249 | + $pdf->AliasNbPages(); |
|
250 | + } |
|
241 | 251 | |
242 | 252 | $pdf->Close(); |
243 | 253 | |
@@ -254,14 +264,14 @@ discard block |
||
254 | 264 | global $action; |
255 | 265 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
256 | 266 | |
257 | - if (! empty($conf->global->MAIN_UMASK)) |
|
258 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
267 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
268 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
269 | + } |
|
259 | 270 | |
260 | 271 | $this->result = array('fullpath'=>$file); |
261 | 272 | |
262 | 273 | return 1; // Pas d'erreur |
263 | - } |
|
264 | - else |
|
274 | + } else |
|
265 | 275 | { |
266 | 276 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
267 | 277 | return 0; |
@@ -325,16 +335,16 @@ discard block |
||
325 | 335 | { |
326 | 336 | $height=pdf_getHeightForLogo($logo); |
327 | 337 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
328 | - } |
|
329 | - else |
|
338 | + } else |
|
330 | 339 | { |
331 | 340 | $pdf->SetTextColor(200,0,0); |
332 | 341 | $pdf->SetFont('','B', $default_font_size - 2); |
333 | 342 | $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
334 | 343 | $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
335 | 344 | } |
345 | + } else { |
|
346 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
336 | 347 | } |
337 | - else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
338 | 348 | |
339 | 349 | $pdf->SetFont('','B', $default_font_size + 3); |
340 | 350 | $pdf->SetXY($posx,$posy); |
@@ -31,31 +31,31 @@ |
||
31 | 31 | */ |
32 | 32 | abstract class ModeleBankAccountDoc extends CommonDocGenerator |
33 | 33 | { |
34 | - /** |
|
35 | - * @var string Error code (or message) |
|
36 | - */ |
|
37 | - public $error=''; |
|
34 | + /** |
|
35 | + * @var string Error code (or message) |
|
36 | + */ |
|
37 | + public $error=''; |
|
38 | 38 | |
39 | 39 | |
40 | 40 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
41 | - /** |
|
42 | - * Return list of active generation modules |
|
43 | - * |
|
41 | + /** |
|
42 | + * Return list of active generation modules |
|
43 | + * |
|
44 | 44 | * @param DoliDB $db Database handler |
45 | 45 | * @param integer $maxfilenamelength Max length of value to show |
46 | 46 | * @return array List of templates |
47 | 47 | */ |
48 | - static function liste_modeles($db, $maxfilenamelength=0) |
|
49 | - { |
|
48 | + static function liste_modeles($db, $maxfilenamelength=0) |
|
49 | + { |
|
50 | 50 | // phpcs:enable |
51 | - global $conf; |
|
51 | + global $conf; |
|
52 | 52 | |
53 | - $type = 'bankaccount'; |
|
54 | - $list = array(); |
|
53 | + $type = 'bankaccount'; |
|
54 | + $list = array(); |
|
55 | 55 | |
56 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
57 | - $list = getListOfModels($db, $type, $maxfilenamelength); |
|
56 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
57 | + $list = getListOfModels($db, $type, $maxfilenamelength); |
|
58 | 58 | |
59 | - return $list; |
|
60 | - } |
|
59 | + return $list; |
|
60 | + } |
|
61 | 61 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * @var string Error code (or message) |
36 | 36 | */ |
37 | - public $error=''; |
|
37 | + public $error = ''; |
|
38 | 38 | |
39 | 39 | |
40 | 40 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param integer $maxfilenamelength Max length of value to show |
46 | 46 | * @return array List of templates |
47 | 47 | */ |
48 | - static function liste_modeles($db, $maxfilenamelength=0) |
|
48 | + static function liste_modeles($db, $maxfilenamelength = 0) |
|
49 | 49 | { |
50 | 50 | // phpcs:enable |
51 | 51 | global $conf; |
@@ -36,257 +36,257 @@ |
||
36 | 36 | class modPropale extends DolibarrModules |
37 | 37 | { |
38 | 38 | |
39 | - /** |
|
40 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
41 | - * |
|
42 | - * @param DoliDB $db Database handler |
|
43 | - */ |
|
44 | - function __construct($db) |
|
45 | - { |
|
46 | - global $conf, $user; |
|
47 | - |
|
48 | - $this->db = $db; |
|
49 | - $this->numero = 20; |
|
50 | - |
|
51 | - $this->family = "crm"; |
|
52 | - $this->module_position = '20'; |
|
53 | - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
54 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
55 | - $this->description = "Gestion des propositions commerciales"; |
|
56 | - |
|
57 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
58 | - $this->version = 'dolibarr'; |
|
59 | - |
|
60 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
61 | - $this->picto='propal'; |
|
62 | - |
|
63 | - // Data directories to create when module is enabled |
|
64 | - $this->dirs = array("/propale/temp"); |
|
65 | - |
|
66 | - // Dependencies |
|
67 | - $this->hidden = false; // A condition to hide module |
|
68 | - $this->depends = array("modSociete"); // List of module class names as string that must be enabled if this module is enabled |
|
69 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
70 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
71 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
72 | - $this->config_page_url = array("propal.php"); |
|
73 | - $this->langfiles = array("propal","bills","companies","deliveries","products"); |
|
74 | - |
|
75 | - // Constants |
|
76 | - $this->const = array(); |
|
77 | - $r=0; |
|
78 | - |
|
79 | - $this->const[$r][0] = "PROPALE_ADDON_PDF"; |
|
80 | - $this->const[$r][1] = "chaine"; |
|
81 | - $this->const[$r][2] = "azur"; |
|
82 | - $this->const[$r][3] = 'Name of the proposal generation manager in PDF format'; |
|
83 | - $this->const[$r][4] = 0; |
|
84 | - $r++; |
|
85 | - |
|
86 | - $this->const[$r][0] = "PROPALE_ADDON"; |
|
87 | - $this->const[$r][1] = "chaine"; |
|
88 | - $this->const[$r][2] = "mod_propale_marbre"; |
|
89 | - $this->const[$r][3] = 'Name of proposal numbering manager'; |
|
90 | - $this->const[$r][4] = 0; |
|
91 | - $r++; |
|
92 | - |
|
93 | - $this->const[$r][0] = "PROPALE_VALIDITY_DURATION"; |
|
94 | - $this->const[$r][1] = "chaine"; |
|
95 | - $this->const[$r][2] = "15"; |
|
96 | - $this->const[$r][3] = 'Duration of validity of business proposals'; |
|
97 | - $this->const[$r][4] = 0; |
|
98 | - $r++; |
|
99 | - |
|
100 | - $this->const[$r][0] = "PROPALE_ADDON_PDF_ODT_PATH"; |
|
101 | - $this->const[$r][1] = "chaine"; |
|
102 | - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/proposals"; |
|
103 | - $this->const[$r][3] = ""; |
|
104 | - $this->const[$r][4] = 0; |
|
105 | - $r++; |
|
106 | - |
|
107 | - /*$this->const[$r][0] = "PROPALE_DRAFT_WATERMARK"; |
|
39 | + /** |
|
40 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
41 | + * |
|
42 | + * @param DoliDB $db Database handler |
|
43 | + */ |
|
44 | + function __construct($db) |
|
45 | + { |
|
46 | + global $conf, $user; |
|
47 | + |
|
48 | + $this->db = $db; |
|
49 | + $this->numero = 20; |
|
50 | + |
|
51 | + $this->family = "crm"; |
|
52 | + $this->module_position = '20'; |
|
53 | + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
54 | + $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
55 | + $this->description = "Gestion des propositions commerciales"; |
|
56 | + |
|
57 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
58 | + $this->version = 'dolibarr'; |
|
59 | + |
|
60 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
61 | + $this->picto='propal'; |
|
62 | + |
|
63 | + // Data directories to create when module is enabled |
|
64 | + $this->dirs = array("/propale/temp"); |
|
65 | + |
|
66 | + // Dependencies |
|
67 | + $this->hidden = false; // A condition to hide module |
|
68 | + $this->depends = array("modSociete"); // List of module class names as string that must be enabled if this module is enabled |
|
69 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
70 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
71 | + $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
72 | + $this->config_page_url = array("propal.php"); |
|
73 | + $this->langfiles = array("propal","bills","companies","deliveries","products"); |
|
74 | + |
|
75 | + // Constants |
|
76 | + $this->const = array(); |
|
77 | + $r=0; |
|
78 | + |
|
79 | + $this->const[$r][0] = "PROPALE_ADDON_PDF"; |
|
80 | + $this->const[$r][1] = "chaine"; |
|
81 | + $this->const[$r][2] = "azur"; |
|
82 | + $this->const[$r][3] = 'Name of the proposal generation manager in PDF format'; |
|
83 | + $this->const[$r][4] = 0; |
|
84 | + $r++; |
|
85 | + |
|
86 | + $this->const[$r][0] = "PROPALE_ADDON"; |
|
87 | + $this->const[$r][1] = "chaine"; |
|
88 | + $this->const[$r][2] = "mod_propale_marbre"; |
|
89 | + $this->const[$r][3] = 'Name of proposal numbering manager'; |
|
90 | + $this->const[$r][4] = 0; |
|
91 | + $r++; |
|
92 | + |
|
93 | + $this->const[$r][0] = "PROPALE_VALIDITY_DURATION"; |
|
94 | + $this->const[$r][1] = "chaine"; |
|
95 | + $this->const[$r][2] = "15"; |
|
96 | + $this->const[$r][3] = 'Duration of validity of business proposals'; |
|
97 | + $this->const[$r][4] = 0; |
|
98 | + $r++; |
|
99 | + |
|
100 | + $this->const[$r][0] = "PROPALE_ADDON_PDF_ODT_PATH"; |
|
101 | + $this->const[$r][1] = "chaine"; |
|
102 | + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/proposals"; |
|
103 | + $this->const[$r][3] = ""; |
|
104 | + $this->const[$r][4] = 0; |
|
105 | + $r++; |
|
106 | + |
|
107 | + /*$this->const[$r][0] = "PROPALE_DRAFT_WATERMARK"; |
|
108 | 108 | $this->const[$r][2] = "__(Draft)__"; |
109 | 109 | $this->const[$r][3] = 'Watermark to show on draft proposals'; |
110 | 110 | $this->const[$r][4] = 0; |
111 | 111 | $r++;*/ |
112 | 112 | |
113 | - // Boxes |
|
114 | - $this->boxes = array( |
|
115 | - 0=>array('file'=>'box_graph_propales_permonth.php','enabledbydefaulton'=>'Home'), |
|
116 | - 1=>array('file'=>'box_propales.php','enabledbydefaulton'=>'Home'), |
|
117 | - ); |
|
118 | - |
|
119 | - // Permissions |
|
120 | - $this->rights = array(); |
|
121 | - $this->rights_class = 'propale'; |
|
122 | - $r=0; |
|
123 | - |
|
124 | - $r++; |
|
125 | - $this->rights[$r][0] = 21; // id de la permission |
|
126 | - $this->rights[$r][1] = 'Read commercial proposals'; // libelle de la permission |
|
127 | - $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
128 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
129 | - $this->rights[$r][4] = 'lire'; |
|
130 | - |
|
131 | - $r++; |
|
132 | - $this->rights[$r][0] = 22; // id de la permission |
|
133 | - $this->rights[$r][1] = 'Create and update commercial proposals'; // libelle de la permission |
|
134 | - $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) |
|
135 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
136 | - $this->rights[$r][4] = 'creer'; |
|
137 | - |
|
138 | - $r++; |
|
139 | - $this->rights[$r][0] = 24; // id de la permission |
|
140 | - $this->rights[$r][1] = 'Validate commercial proposals'; // libelle de la permission |
|
141 | - $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) |
|
142 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
143 | - $this->rights[$r][4] = 'propal_advance'; |
|
144 | - $this->rights[$r][5] = 'validate'; |
|
145 | - |
|
146 | - $r++; |
|
147 | - $this->rights[$r][0] = 25; // id de la permission |
|
148 | - $this->rights[$r][1] = 'Send commercial proposals to customers'; // libelle de la permission |
|
149 | - $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) |
|
150 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
151 | - $this->rights[$r][4] = 'propal_advance'; |
|
113 | + // Boxes |
|
114 | + $this->boxes = array( |
|
115 | + 0=>array('file'=>'box_graph_propales_permonth.php','enabledbydefaulton'=>'Home'), |
|
116 | + 1=>array('file'=>'box_propales.php','enabledbydefaulton'=>'Home'), |
|
117 | + ); |
|
118 | + |
|
119 | + // Permissions |
|
120 | + $this->rights = array(); |
|
121 | + $this->rights_class = 'propale'; |
|
122 | + $r=0; |
|
123 | + |
|
124 | + $r++; |
|
125 | + $this->rights[$r][0] = 21; // id de la permission |
|
126 | + $this->rights[$r][1] = 'Read commercial proposals'; // libelle de la permission |
|
127 | + $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
128 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
129 | + $this->rights[$r][4] = 'lire'; |
|
130 | + |
|
131 | + $r++; |
|
132 | + $this->rights[$r][0] = 22; // id de la permission |
|
133 | + $this->rights[$r][1] = 'Create and update commercial proposals'; // libelle de la permission |
|
134 | + $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) |
|
135 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
136 | + $this->rights[$r][4] = 'creer'; |
|
137 | + |
|
138 | + $r++; |
|
139 | + $this->rights[$r][0] = 24; // id de la permission |
|
140 | + $this->rights[$r][1] = 'Validate commercial proposals'; // libelle de la permission |
|
141 | + $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) |
|
142 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
143 | + $this->rights[$r][4] = 'propal_advance'; |
|
144 | + $this->rights[$r][5] = 'validate'; |
|
145 | + |
|
146 | + $r++; |
|
147 | + $this->rights[$r][0] = 25; // id de la permission |
|
148 | + $this->rights[$r][1] = 'Send commercial proposals to customers'; // libelle de la permission |
|
149 | + $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) |
|
150 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
151 | + $this->rights[$r][4] = 'propal_advance'; |
|
152 | 152 | $this->rights[$r][5] = 'send'; |
153 | 153 | |
154 | - $r++; |
|
155 | - $this->rights[$r][0] = 26; // id de la permission |
|
156 | - $this->rights[$r][1] = 'Close commercial proposals'; // libelle de la permission |
|
157 | - $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) |
|
158 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
159 | - $this->rights[$r][4] = 'cloturer'; |
|
160 | - |
|
161 | - $r++; |
|
162 | - $this->rights[$r][0] = 27; // id de la permission |
|
163 | - $this->rights[$r][1] = 'Delete commercial proposals'; // libelle de la permission |
|
164 | - $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) |
|
165 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
166 | - $this->rights[$r][4] = 'supprimer'; |
|
167 | - |
|
168 | - $r++; |
|
169 | - $this->rights[$r][0] = 28; // id de la permission |
|
170 | - $this->rights[$r][1] = 'Exporting commercial proposals and attributes'; // libelle de la permission |
|
171 | - $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
172 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
173 | - $this->rights[$r][4] = 'export'; |
|
174 | - |
|
175 | - |
|
176 | - // Menus |
|
177 | - //------- |
|
178 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
179 | - |
|
180 | - |
|
181 | - // Exports |
|
182 | - //-------- |
|
183 | - $r=0; |
|
184 | - |
|
185 | - $r++; |
|
186 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
187 | - $this->export_label[$r]='ProposalsAndProposalsLines'; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
188 | - $this->export_permission[$r]=array(array("propale","export")); |
|
189 | - $this->export_fields_array[$r]=array( |
|
190 | - 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','co.code'=>'CountryCode','s.phone'=>'Phone', |
|
191 | - 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer", |
|
192 | - 'c.fk_soc'=>"IdCompany",'c.datec'=>"DateCreation",'c.datep'=>"DatePropal",'c.fin_validite'=>"DateEndPropal",'c.remise_percent'=>"GlobalDiscount", |
|
193 | - 'c.total_ht'=>"TotalHT",'c.total'=>"TotalTTC",'c.fk_statut'=>'Status','c.note_public'=>"Note",'c.date_livraison'=>'DeliveryDate', |
|
194 | - 'c.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','c.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin', |
|
195 | - 'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct', |
|
196 | - 'cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC", |
|
197 | - 'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel' |
|
198 | - ); |
|
199 | - //$this->export_TypeFields_array[$r]=array( |
|
200 | - // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text', |
|
201 | - // 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date", |
|
202 | - // 'c.fin_validite'=>"Date",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text", |
|
203 | - // 'c.date_livraison'=>'Date','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric", |
|
204 | - // 'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text' |
|
205 | - //); |
|
206 | - $this->export_TypeFields_array[$r]=array( |
|
207 | - 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text', |
|
208 | - 's.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date",'c.fin_validite'=>"Date", |
|
209 | - 'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date', |
|
210 | - 'pj.ref'=>'Text', 'cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric", |
|
211 | - 'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.ref'=>'Text','p.label'=>'Text' |
|
212 | - ); |
|
213 | - $this->export_entities_array[$r]=array( |
|
214 | - 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','co.code'=>'company','s.phone'=>'company', |
|
215 | - 's.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"propal",'c.ref'=>"propal",'c.ref_client'=>"propal", |
|
216 | - 'c.fk_soc'=>"propal",'c.datec'=>"propal",'c.datep'=>"propal",'c.fin_validite'=>"propal",'c.remise_percent'=>"propal",'c.total_ht'=>"propal", |
|
217 | - 'c.total'=>"propal",'c.fk_statut'=>"propal",'c.note_public'=>"propal",'c.date_livraison'=>"propal", 'pj.ref'=>'project', 'cd.rowid'=>'propal_line', |
|
218 | - 'cd.label'=>"propal_line",'cd.description'=>"propal_line",'cd.product_type'=>'propal_line','cd.tva_tx'=>"propal_line",'cd.qty'=>"propal_line", |
|
219 | - 'cd.total_ht'=>"propal_line",'cd.total_tva'=>"propal_line",'cd.total_ttc'=>"propal_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product' |
|
220 | - ); |
|
221 | - $this->export_dependencies_array[$r]=array('propal_line'=>'cd.rowid','product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
222 | - $keyforselect='propal'; $keyforelement='propal'; $keyforaliasextra='extra'; |
|
223 | - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
224 | - $keyforselect='propaldet'; $keyforelement='propal_line'; $keyforaliasextra='extra2'; |
|
225 | - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
226 | - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra3'; |
|
227 | - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
228 | - $keyforselect='societe'; $keyforelement='societe'; $keyforaliasextra='extra4'; |
|
229 | - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
230 | - |
|
231 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
232 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s '; |
|
233 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra4 ON s.rowid = extra4.fk_object'; |
|
234 | - |
|
235 | - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
236 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; |
|
237 | - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'propal as c'; |
|
238 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid'; |
|
239 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON c.fk_user_author = uc.rowid'; |
|
240 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON c.fk_user_valid = uv.rowid'; |
|
241 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'propal_extrafields as extra ON c.rowid = extra.fk_object'; |
|
242 | - $this->export_sql_end[$r] .=', '.MAIN_DB_PREFIX.'propaldet as cd'; |
|
243 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet_extrafields as extra2 on cd.rowid = extra2.fk_object'; |
|
244 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (cd.fk_product = p.rowid)'; |
|
245 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; |
|
246 | - $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_propal'; |
|
247 | - $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('propal').')'; |
|
248 | - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * Function called when module is enabled. |
|
254 | - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
255 | - * It also creates data directories |
|
256 | - * |
|
154 | + $r++; |
|
155 | + $this->rights[$r][0] = 26; // id de la permission |
|
156 | + $this->rights[$r][1] = 'Close commercial proposals'; // libelle de la permission |
|
157 | + $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) |
|
158 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
159 | + $this->rights[$r][4] = 'cloturer'; |
|
160 | + |
|
161 | + $r++; |
|
162 | + $this->rights[$r][0] = 27; // id de la permission |
|
163 | + $this->rights[$r][1] = 'Delete commercial proposals'; // libelle de la permission |
|
164 | + $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) |
|
165 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
166 | + $this->rights[$r][4] = 'supprimer'; |
|
167 | + |
|
168 | + $r++; |
|
169 | + $this->rights[$r][0] = 28; // id de la permission |
|
170 | + $this->rights[$r][1] = 'Exporting commercial proposals and attributes'; // libelle de la permission |
|
171 | + $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
172 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
173 | + $this->rights[$r][4] = 'export'; |
|
174 | + |
|
175 | + |
|
176 | + // Menus |
|
177 | + //------- |
|
178 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
179 | + |
|
180 | + |
|
181 | + // Exports |
|
182 | + //-------- |
|
183 | + $r=0; |
|
184 | + |
|
185 | + $r++; |
|
186 | + $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
187 | + $this->export_label[$r]='ProposalsAndProposalsLines'; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
188 | + $this->export_permission[$r]=array(array("propale","export")); |
|
189 | + $this->export_fields_array[$r]=array( |
|
190 | + 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','co.code'=>'CountryCode','s.phone'=>'Phone', |
|
191 | + 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer", |
|
192 | + 'c.fk_soc'=>"IdCompany",'c.datec'=>"DateCreation",'c.datep'=>"DatePropal",'c.fin_validite'=>"DateEndPropal",'c.remise_percent'=>"GlobalDiscount", |
|
193 | + 'c.total_ht'=>"TotalHT",'c.total'=>"TotalTTC",'c.fk_statut'=>'Status','c.note_public'=>"Note",'c.date_livraison'=>'DeliveryDate', |
|
194 | + 'c.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','c.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin', |
|
195 | + 'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct', |
|
196 | + 'cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC", |
|
197 | + 'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel' |
|
198 | + ); |
|
199 | + //$this->export_TypeFields_array[$r]=array( |
|
200 | + // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text', |
|
201 | + // 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date", |
|
202 | + // 'c.fin_validite'=>"Date",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text", |
|
203 | + // 'c.date_livraison'=>'Date','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric", |
|
204 | + // 'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text' |
|
205 | + //); |
|
206 | + $this->export_TypeFields_array[$r]=array( |
|
207 | + 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text', |
|
208 | + 's.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date",'c.fin_validite'=>"Date", |
|
209 | + 'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date', |
|
210 | + 'pj.ref'=>'Text', 'cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric", |
|
211 | + 'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.ref'=>'Text','p.label'=>'Text' |
|
212 | + ); |
|
213 | + $this->export_entities_array[$r]=array( |
|
214 | + 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','co.code'=>'company','s.phone'=>'company', |
|
215 | + 's.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"propal",'c.ref'=>"propal",'c.ref_client'=>"propal", |
|
216 | + 'c.fk_soc'=>"propal",'c.datec'=>"propal",'c.datep'=>"propal",'c.fin_validite'=>"propal",'c.remise_percent'=>"propal",'c.total_ht'=>"propal", |
|
217 | + 'c.total'=>"propal",'c.fk_statut'=>"propal",'c.note_public'=>"propal",'c.date_livraison'=>"propal", 'pj.ref'=>'project', 'cd.rowid'=>'propal_line', |
|
218 | + 'cd.label'=>"propal_line",'cd.description'=>"propal_line",'cd.product_type'=>'propal_line','cd.tva_tx'=>"propal_line",'cd.qty'=>"propal_line", |
|
219 | + 'cd.total_ht'=>"propal_line",'cd.total_tva'=>"propal_line",'cd.total_ttc'=>"propal_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product' |
|
220 | + ); |
|
221 | + $this->export_dependencies_array[$r]=array('propal_line'=>'cd.rowid','product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
222 | + $keyforselect='propal'; $keyforelement='propal'; $keyforaliasextra='extra'; |
|
223 | + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
224 | + $keyforselect='propaldet'; $keyforelement='propal_line'; $keyforaliasextra='extra2'; |
|
225 | + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
226 | + $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra3'; |
|
227 | + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
228 | + $keyforselect='societe'; $keyforelement='societe'; $keyforaliasextra='extra4'; |
|
229 | + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
230 | + |
|
231 | + $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
232 | + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s '; |
|
233 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra4 ON s.rowid = extra4.fk_object'; |
|
234 | + |
|
235 | + if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
236 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; |
|
237 | + $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'propal as c'; |
|
238 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid'; |
|
239 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON c.fk_user_author = uc.rowid'; |
|
240 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON c.fk_user_valid = uv.rowid'; |
|
241 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'propal_extrafields as extra ON c.rowid = extra.fk_object'; |
|
242 | + $this->export_sql_end[$r] .=', '.MAIN_DB_PREFIX.'propaldet as cd'; |
|
243 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet_extrafields as extra2 on cd.rowid = extra2.fk_object'; |
|
244 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (cd.fk_product = p.rowid)'; |
|
245 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; |
|
246 | + $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_propal'; |
|
247 | + $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('propal').')'; |
|
248 | + if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * Function called when module is enabled. |
|
254 | + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
255 | + * It also creates data directories |
|
256 | + * |
|
257 | 257 | * @param string $options Options when enabling module ('', 'noboxes') |
258 | - * @return int 1 if OK, 0 if KO |
|
259 | - */ |
|
260 | - function init($options='') |
|
261 | - { |
|
262 | - global $conf,$langs; |
|
263 | - |
|
264 | - // Remove permissions and default values |
|
265 | - $this->remove($options); |
|
266 | - |
|
267 | - //ODT template |
|
268 | - $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/proposals/template_proposal.odt'; |
|
269 | - $dirodt=DOL_DATA_ROOT.'/doctemplates/proposals'; |
|
270 | - $dest=$dirodt.'/template_proposal.odt'; |
|
271 | - |
|
272 | - if (file_exists($src) && ! file_exists($dest)) |
|
273 | - { |
|
274 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
275 | - dol_mkdir($dirodt); |
|
276 | - $result=dol_copy($src,$dest,0,0); |
|
277 | - if ($result < 0) |
|
278 | - { |
|
279 | - $langs->load("errors"); |
|
280 | - $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); |
|
281 | - return 0; |
|
282 | - } |
|
283 | - } |
|
284 | - |
|
285 | - $sql = array( |
|
286 | - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'propal' AND entity = ".$conf->entity, |
|
287 | - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','propal',".$conf->entity.")", |
|
288 | - ); |
|
289 | - |
|
290 | - return $this->_init($sql,$options); |
|
291 | - } |
|
258 | + * @return int 1 if OK, 0 if KO |
|
259 | + */ |
|
260 | + function init($options='') |
|
261 | + { |
|
262 | + global $conf,$langs; |
|
263 | + |
|
264 | + // Remove permissions and default values |
|
265 | + $this->remove($options); |
|
266 | + |
|
267 | + //ODT template |
|
268 | + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/proposals/template_proposal.odt'; |
|
269 | + $dirodt=DOL_DATA_ROOT.'/doctemplates/proposals'; |
|
270 | + $dest=$dirodt.'/template_proposal.odt'; |
|
271 | + |
|
272 | + if (file_exists($src) && ! file_exists($dest)) |
|
273 | + { |
|
274 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
275 | + dol_mkdir($dirodt); |
|
276 | + $result=dol_copy($src,$dest,0,0); |
|
277 | + if ($result < 0) |
|
278 | + { |
|
279 | + $langs->load("errors"); |
|
280 | + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); |
|
281 | + return 0; |
|
282 | + } |
|
283 | + } |
|
284 | + |
|
285 | + $sql = array( |
|
286 | + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'propal' AND entity = ".$conf->entity, |
|
287 | + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','propal',".$conf->entity.")", |
|
288 | + ); |
|
289 | + |
|
290 | + return $this->_init($sql,$options); |
|
291 | + } |
|
292 | 292 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * \ingroup propale |
28 | 28 | * \brief Fichier de description et activation du module Propale |
29 | 29 | */ |
30 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
30 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
31 | 31 | |
32 | 32 | |
33 | 33 | /** |
@@ -51,30 +51,30 @@ discard block |
||
51 | 51 | $this->family = "crm"; |
52 | 52 | $this->module_position = '20'; |
53 | 53 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
54 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
54 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
55 | 55 | $this->description = "Gestion des propositions commerciales"; |
56 | 56 | |
57 | 57 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
58 | 58 | $this->version = 'dolibarr'; |
59 | 59 | |
60 | 60 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
61 | - $this->picto='propal'; |
|
61 | + $this->picto = 'propal'; |
|
62 | 62 | |
63 | 63 | // Data directories to create when module is enabled |
64 | 64 | $this->dirs = array("/propale/temp"); |
65 | 65 | |
66 | 66 | // Dependencies |
67 | - $this->hidden = false; // A condition to hide module |
|
68 | - $this->depends = array("modSociete"); // List of module class names as string that must be enabled if this module is enabled |
|
69 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
70 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
71 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
67 | + $this->hidden = false; // A condition to hide module |
|
68 | + $this->depends = array("modSociete"); // List of module class names as string that must be enabled if this module is enabled |
|
69 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
70 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
71 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module |
|
72 | 72 | $this->config_page_url = array("propal.php"); |
73 | - $this->langfiles = array("propal","bills","companies","deliveries","products"); |
|
73 | + $this->langfiles = array("propal", "bills", "companies", "deliveries", "products"); |
|
74 | 74 | |
75 | 75 | // Constants |
76 | 76 | $this->const = array(); |
77 | - $r=0; |
|
77 | + $r = 0; |
|
78 | 78 | |
79 | 79 | $this->const[$r][0] = "PROPALE_ADDON_PDF"; |
80 | 80 | $this->const[$r][1] = "chaine"; |
@@ -112,14 +112,14 @@ discard block |
||
112 | 112 | |
113 | 113 | // Boxes |
114 | 114 | $this->boxes = array( |
115 | - 0=>array('file'=>'box_graph_propales_permonth.php','enabledbydefaulton'=>'Home'), |
|
116 | - 1=>array('file'=>'box_propales.php','enabledbydefaulton'=>'Home'), |
|
115 | + 0=>array('file'=>'box_graph_propales_permonth.php', 'enabledbydefaulton'=>'Home'), |
|
116 | + 1=>array('file'=>'box_propales.php', 'enabledbydefaulton'=>'Home'), |
|
117 | 117 | ); |
118 | 118 | |
119 | 119 | // Permissions |
120 | 120 | $this->rights = array(); |
121 | 121 | $this->rights_class = 'propale'; |
122 | - $r=0; |
|
122 | + $r = 0; |
|
123 | 123 | |
124 | 124 | $r++; |
125 | 125 | $this->rights[$r][0] = 21; // id de la permission |
@@ -175,26 +175,26 @@ discard block |
||
175 | 175 | |
176 | 176 | // Menus |
177 | 177 | //------- |
178 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
178 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
179 | 179 | |
180 | 180 | |
181 | 181 | // Exports |
182 | 182 | //-------- |
183 | - $r=0; |
|
183 | + $r = 0; |
|
184 | 184 | |
185 | 185 | $r++; |
186 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
187 | - $this->export_label[$r]='ProposalsAndProposalsLines'; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
188 | - $this->export_permission[$r]=array(array("propale","export")); |
|
189 | - $this->export_fields_array[$r]=array( |
|
190 | - 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','co.code'=>'CountryCode','s.phone'=>'Phone', |
|
191 | - 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer", |
|
192 | - 'c.fk_soc'=>"IdCompany",'c.datec'=>"DateCreation",'c.datep'=>"DatePropal",'c.fin_validite'=>"DateEndPropal",'c.remise_percent'=>"GlobalDiscount", |
|
193 | - 'c.total_ht'=>"TotalHT",'c.total'=>"TotalTTC",'c.fk_statut'=>'Status','c.note_public'=>"Note",'c.date_livraison'=>'DeliveryDate', |
|
194 | - 'c.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','c.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin', |
|
195 | - 'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct', |
|
196 | - 'cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC", |
|
197 | - 'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel' |
|
186 | + $this->export_code[$r] = $this->rights_class.'_'.$r; |
|
187 | + $this->export_label[$r] = 'ProposalsAndProposalsLines'; // Translation key (used only if key ExportDataset_xxx_z not found) |
|
188 | + $this->export_permission[$r] = array(array("propale", "export")); |
|
189 | + $this->export_fields_array[$r] = array( |
|
190 | + 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'co.code'=>'CountryCode', 's.phone'=>'Phone', |
|
191 | + 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 'c.rowid'=>"Id", 'c.ref'=>"Ref", 'c.ref_client'=>"RefCustomer", |
|
192 | + 'c.fk_soc'=>"IdCompany", 'c.datec'=>"DateCreation", 'c.datep'=>"DatePropal", 'c.fin_validite'=>"DateEndPropal", 'c.remise_percent'=>"GlobalDiscount", |
|
193 | + 'c.total_ht'=>"TotalHT", 'c.total'=>"TotalTTC", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'c.date_livraison'=>'DeliveryDate', |
|
194 | + 'c.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', 'c.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', |
|
195 | + 'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.label'=>"Label", 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct', |
|
196 | + 'cd.tva_tx'=>"LineVATRate", 'cd.qty'=>"LineQty", 'cd.total_ht'=>"LineTotalHT", 'cd.total_tva'=>"LineTotalVAT", 'cd.total_ttc'=>"LineTotalTTC", |
|
197 | + 'p.rowid'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel' |
|
198 | 198 | ); |
199 | 199 | //$this->export_TypeFields_array[$r]=array( |
200 | 200 | // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text', |
@@ -203,49 +203,49 @@ discard block |
||
203 | 203 | // 'c.date_livraison'=>'Date','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric", |
204 | 204 | // 'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text' |
205 | 205 | //); |
206 | - $this->export_TypeFields_array[$r]=array( |
|
207 | - 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text', |
|
208 | - 's.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date",'c.fin_validite'=>"Date", |
|
209 | - 'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date', |
|
210 | - 'pj.ref'=>'Text', 'cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric", |
|
211 | - 'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.ref'=>'Text','p.label'=>'Text' |
|
206 | + $this->export_TypeFields_array[$r] = array( |
|
207 | + 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', |
|
208 | + 's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_client'=>"Text", 'c.datec'=>"Date", 'c.datep'=>"Date", 'c.fin_validite'=>"Date", |
|
209 | + 'c.remise_percent'=>"Numeric", 'c.total_ht'=>"Numeric", 'c.total'=>"Numeric", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date', |
|
210 | + 'pj.ref'=>'Text', 'cd.description'=>"Text", 'cd.product_type'=>'Boolean', 'cd.tva_tx'=>"Numeric", 'cd.qty'=>"Numeric", 'cd.total_ht'=>"Numeric", |
|
211 | + 'cd.total_tva'=>"Numeric", 'cd.total_ttc'=>"Numeric", 'p.ref'=>'Text', 'p.label'=>'Text' |
|
212 | 212 | ); |
213 | - $this->export_entities_array[$r]=array( |
|
214 | - 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','co.code'=>'company','s.phone'=>'company', |
|
215 | - 's.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"propal",'c.ref'=>"propal",'c.ref_client'=>"propal", |
|
216 | - 'c.fk_soc'=>"propal",'c.datec'=>"propal",'c.datep'=>"propal",'c.fin_validite'=>"propal",'c.remise_percent'=>"propal",'c.total_ht'=>"propal", |
|
217 | - 'c.total'=>"propal",'c.fk_statut'=>"propal",'c.note_public'=>"propal",'c.date_livraison'=>"propal", 'pj.ref'=>'project', 'cd.rowid'=>'propal_line', |
|
218 | - 'cd.label'=>"propal_line",'cd.description'=>"propal_line",'cd.product_type'=>'propal_line','cd.tva_tx'=>"propal_line",'cd.qty'=>"propal_line", |
|
219 | - 'cd.total_ht'=>"propal_line",'cd.total_tva'=>"propal_line",'cd.total_ttc'=>"propal_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product' |
|
213 | + $this->export_entities_array[$r] = array( |
|
214 | + 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'co.code'=>'company', 's.phone'=>'company', |
|
215 | + 's.siren'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.siret'=>'company', 'c.rowid'=>"propal", 'c.ref'=>"propal", 'c.ref_client'=>"propal", |
|
216 | + 'c.fk_soc'=>"propal", 'c.datec'=>"propal", 'c.datep'=>"propal", 'c.fin_validite'=>"propal", 'c.remise_percent'=>"propal", 'c.total_ht'=>"propal", |
|
217 | + 'c.total'=>"propal", 'c.fk_statut'=>"propal", 'c.note_public'=>"propal", 'c.date_livraison'=>"propal", 'pj.ref'=>'project', 'cd.rowid'=>'propal_line', |
|
218 | + 'cd.label'=>"propal_line", 'cd.description'=>"propal_line", 'cd.product_type'=>'propal_line', 'cd.tva_tx'=>"propal_line", 'cd.qty'=>"propal_line", |
|
219 | + 'cd.total_ht'=>"propal_line", 'cd.total_tva'=>"propal_line", 'cd.total_ttc'=>"propal_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product' |
|
220 | 220 | ); |
221 | - $this->export_dependencies_array[$r]=array('propal_line'=>'cd.rowid','product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
222 | - $keyforselect='propal'; $keyforelement='propal'; $keyforaliasextra='extra'; |
|
221 | + $this->export_dependencies_array[$r] = array('propal_line'=>'cd.rowid', 'product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
222 | + $keyforselect = 'propal'; $keyforelement = 'propal'; $keyforaliasextra = 'extra'; |
|
223 | 223 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
224 | - $keyforselect='propaldet'; $keyforelement='propal_line'; $keyforaliasextra='extra2'; |
|
224 | + $keyforselect = 'propaldet'; $keyforelement = 'propal_line'; $keyforaliasextra = 'extra2'; |
|
225 | 225 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
226 | - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra3'; |
|
226 | + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra3'; |
|
227 | 227 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
228 | - $keyforselect='societe'; $keyforelement='societe'; $keyforaliasextra='extra4'; |
|
228 | + $keyforselect = 'societe'; $keyforelement = 'societe'; $keyforaliasextra = 'extra4'; |
|
229 | 229 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
230 | 230 | |
231 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
232 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s '; |
|
233 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra4 ON s.rowid = extra4.fk_object'; |
|
234 | - |
|
235 | - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
236 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; |
|
237 | - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'propal as c'; |
|
238 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid'; |
|
239 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON c.fk_user_author = uc.rowid'; |
|
240 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON c.fk_user_valid = uv.rowid'; |
|
241 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'propal_extrafields as extra ON c.rowid = extra.fk_object'; |
|
242 | - $this->export_sql_end[$r] .=', '.MAIN_DB_PREFIX.'propaldet as cd'; |
|
243 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet_extrafields as extra2 on cd.rowid = extra2.fk_object'; |
|
244 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (cd.fk_product = p.rowid)'; |
|
245 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; |
|
246 | - $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_propal'; |
|
247 | - $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('propal').')'; |
|
248 | - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
231 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
232 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s '; |
|
233 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra4 ON s.rowid = extra4.fk_object'; |
|
234 | + |
|
235 | + if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
236 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; |
|
237 | + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'propal as c'; |
|
238 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid'; |
|
239 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON c.fk_user_author = uc.rowid'; |
|
240 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON c.fk_user_valid = uv.rowid'; |
|
241 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'propal_extrafields as extra ON c.rowid = extra.fk_object'; |
|
242 | + $this->export_sql_end[$r] .= ', '.MAIN_DB_PREFIX.'propaldet as cd'; |
|
243 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet_extrafields as extra2 on cd.rowid = extra2.fk_object'; |
|
244 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (cd.fk_product = p.rowid)'; |
|
245 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; |
|
246 | + $this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_propal'; |
|
247 | + $this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('propal').')'; |
|
248 | + if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | |
@@ -257,27 +257,27 @@ discard block |
||
257 | 257 | * @param string $options Options when enabling module ('', 'noboxes') |
258 | 258 | * @return int 1 if OK, 0 if KO |
259 | 259 | */ |
260 | - function init($options='') |
|
260 | + function init($options = '') |
|
261 | 261 | { |
262 | - global $conf,$langs; |
|
262 | + global $conf, $langs; |
|
263 | 263 | |
264 | 264 | // Remove permissions and default values |
265 | 265 | $this->remove($options); |
266 | 266 | |
267 | 267 | //ODT template |
268 | - $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/proposals/template_proposal.odt'; |
|
269 | - $dirodt=DOL_DATA_ROOT.'/doctemplates/proposals'; |
|
270 | - $dest=$dirodt.'/template_proposal.odt'; |
|
268 | + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/proposals/template_proposal.odt'; |
|
269 | + $dirodt = DOL_DATA_ROOT.'/doctemplates/proposals'; |
|
270 | + $dest = $dirodt.'/template_proposal.odt'; |
|
271 | 271 | |
272 | - if (file_exists($src) && ! file_exists($dest)) |
|
272 | + if (file_exists($src) && !file_exists($dest)) |
|
273 | 273 | { |
274 | 274 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
275 | 275 | dol_mkdir($dirodt); |
276 | - $result=dol_copy($src,$dest,0,0); |
|
276 | + $result = dol_copy($src, $dest, 0, 0); |
|
277 | 277 | if ($result < 0) |
278 | 278 | { |
279 | 279 | $langs->load("errors"); |
280 | - $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); |
|
280 | + $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); |
|
281 | 281 | return 0; |
282 | 282 | } |
283 | 283 | } |
@@ -287,6 +287,6 @@ discard block |
||
287 | 287 | "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','propal',".$conf->entity.")", |
288 | 288 | ); |
289 | 289 | |
290 | - return $this->_init($sql,$options); |
|
290 | + return $this->_init($sql, $options); |
|
291 | 291 | } |
292 | 292 | } |
@@ -232,7 +232,9 @@ discard block |
||
232 | 232 | $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s '; |
233 | 233 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra4 ON s.rowid = extra4.fk_object'; |
234 | 234 | |
235 | - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
235 | + if(!$user->rights->societe->client->voir) { |
|
236 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
237 | + } |
|
236 | 238 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; |
237 | 239 | $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'propal as c'; |
238 | 240 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid'; |
@@ -245,7 +247,9 @@ discard block |
||
245 | 247 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; |
246 | 248 | $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_propal'; |
247 | 249 | $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('propal').')'; |
248 | - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
250 | + if(!$user->rights->societe->client->voir) { |
|
251 | + $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
252 | + } |
|
249 | 253 | } |
250 | 254 | |
251 | 255 |
@@ -33,101 +33,101 @@ |
||
33 | 33 | */ |
34 | 34 | class modProductBatch extends DolibarrModules |
35 | 35 | { |
36 | - /** |
|
37 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
38 | - * |
|
39 | - * @param DoliDB $db Database handler |
|
40 | - */ |
|
41 | - function __construct($db) |
|
42 | - { |
|
36 | + /** |
|
37 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
38 | + * |
|
39 | + * @param DoliDB $db Database handler |
|
40 | + */ |
|
41 | + function __construct($db) |
|
42 | + { |
|
43 | 43 | global $langs,$conf; |
44 | 44 | |
45 | 45 | $this->db = $db; |
46 | - $this->numero = 39000; |
|
46 | + $this->numero = 39000; |
|
47 | 47 | |
48 | - $this->family = "products"; |
|
49 | - $this->module_position = '45'; |
|
48 | + $this->family = "products"; |
|
49 | + $this->module_position = '45'; |
|
50 | 50 | |
51 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
52 | - $this->description = "Batch number, eat-by and sell-by date management module"; |
|
51 | + $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
52 | + $this->description = "Batch number, eat-by and sell-by date management module"; |
|
53 | 53 | |
54 | - $this->rights_class = 'productbatch'; |
|
55 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
56 | - $this->version = 'dolibarr'; |
|
57 | - // Key used in llx_const table to save module status enabled/disabled (where dluo is value of property name of module in uppercase) |
|
58 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
54 | + $this->rights_class = 'productbatch'; |
|
55 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
56 | + $this->version = 'dolibarr'; |
|
57 | + // Key used in llx_const table to save module status enabled/disabled (where dluo is value of property name of module in uppercase) |
|
58 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
59 | 59 | |
60 | - $this->picto='stock'; |
|
60 | + $this->picto='stock'; |
|
61 | 61 | |
62 | - $this->module_parts = array(); |
|
62 | + $this->module_parts = array(); |
|
63 | 63 | |
64 | - // Data directories to create when module is enabled. |
|
65 | - $this->dirs = array(); |
|
64 | + // Data directories to create when module is enabled. |
|
65 | + $this->dirs = array(); |
|
66 | 66 | |
67 | - // Config pages. Put here list of php page, stored into productdluo/admin directory, to use to setup module. |
|
68 | - $this->config_page_url = array("product_lot_extrafields.php@product"); |
|
67 | + // Config pages. Put here list of php page, stored into productdluo/admin directory, to use to setup module. |
|
68 | + $this->config_page_url = array("product_lot_extrafields.php@product"); |
|
69 | 69 | |
70 | - // Dependencies |
|
71 | - $this->hidden = false; // A condition to hide module |
|
72 | - $this->depends = array("modProduct","modStock","modExpedition","modFournisseur"); // List of module class names as string that must be enabled if this module is enabled |
|
73 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
74 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
75 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
76 | - $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module |
|
77 | - $this->langfiles = array("productbatch"); |
|
70 | + // Dependencies |
|
71 | + $this->hidden = false; // A condition to hide module |
|
72 | + $this->depends = array("modProduct","modStock","modExpedition","modFournisseur"); // List of module class names as string that must be enabled if this module is enabled |
|
73 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
74 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
75 | + $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
76 | + $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module |
|
77 | + $this->langfiles = array("productbatch"); |
|
78 | 78 | |
79 | - // Constants |
|
80 | - $this->const = array(); |
|
79 | + // Constants |
|
80 | + $this->const = array(); |
|
81 | 81 | |
82 | 82 | $this->tabs = array(); |
83 | 83 | |
84 | 84 | // Dictionaries |
85 | - if (! isset($conf->productbatch->enabled)) |
|
85 | + if (! isset($conf->productbatch->enabled)) |
|
86 | 86 | { |
87 | - $conf->productbatch=new stdClass(); |
|
88 | - $conf->productbatch->enabled=0; |
|
87 | + $conf->productbatch=new stdClass(); |
|
88 | + $conf->productbatch->enabled=0; |
|
89 | 89 | } |
90 | - $this->dictionaries=array(); |
|
90 | + $this->dictionaries=array(); |
|
91 | 91 | |
92 | 92 | // Boxes |
93 | 93 | $this->boxes = array(); // List of boxes |
94 | 94 | |
95 | - // Permissions |
|
96 | - $this->rights = array(); // Permission array used by this module |
|
97 | - $r=0; |
|
95 | + // Permissions |
|
96 | + $this->rights = array(); // Permission array used by this module |
|
97 | + $r=0; |
|
98 | 98 | |
99 | 99 | |
100 | - // Menus |
|
101 | - //------- |
|
102 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
100 | + // Menus |
|
101 | + //------- |
|
102 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
103 | 103 | |
104 | 104 | |
105 | - // Exports |
|
106 | - $r=0; |
|
107 | - } |
|
105 | + // Exports |
|
106 | + $r=0; |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Function called when module is enabled. |
|
111 | - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
112 | - * It also creates data directories |
|
113 | - * |
|
109 | + /** |
|
110 | + * Function called when module is enabled. |
|
111 | + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
112 | + * It also creates data directories |
|
113 | + * |
|
114 | 114 | * @param string $options Options when enabling module ('', 'noboxes') |
115 | - * @return int 1 if OK, 0 if KO |
|
116 | - */ |
|
117 | - function init($options='') |
|
118 | - { |
|
119 | - global $db,$conf; |
|
120 | - |
|
121 | - $sql = array(); |
|
122 | - |
|
123 | - if (! empty($conf->cashdesk->enabled)) { |
|
124 | - if (empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) { |
|
125 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; |
|
126 | - $res = dolibarr_set_const($db,"CASHDESK_NO_DECREASE_STOCK",1,'chaine',0,'',$conf->entity); |
|
127 | - } |
|
128 | - } |
|
129 | - |
|
130 | - return $this->_init($sql, $options); |
|
131 | - } |
|
115 | + * @return int 1 if OK, 0 if KO |
|
116 | + */ |
|
117 | + function init($options='') |
|
118 | + { |
|
119 | + global $db,$conf; |
|
120 | + |
|
121 | + $sql = array(); |
|
122 | + |
|
123 | + if (! empty($conf->cashdesk->enabled)) { |
|
124 | + if (empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) { |
|
125 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; |
|
126 | + $res = dolibarr_set_const($db,"CASHDESK_NO_DECREASE_STOCK",1,'chaine',0,'',$conf->entity); |
|
127 | + } |
|
128 | + } |
|
129 | + |
|
130 | + return $this->_init($sql, $options); |
|
131 | + } |
|
132 | 132 | } |
133 | 133 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * \ingroup productbatch |
26 | 26 | * \brief Description and activation file for module productbatch |
27 | 27 | */ |
28 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
28 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
29 | 29 | |
30 | 30 | |
31 | 31 | /** |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | function __construct($db) |
42 | 42 | { |
43 | - global $langs,$conf; |
|
43 | + global $langs, $conf; |
|
44 | 44 | |
45 | 45 | $this->db = $db; |
46 | 46 | $this->numero = 39000; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $this->family = "products"; |
49 | 49 | $this->module_position = '45'; |
50 | 50 | |
51 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
51 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
52 | 52 | $this->description = "Batch number, eat-by and sell-by date management module"; |
53 | 53 | |
54 | 54 | $this->rights_class = 'productbatch'; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | // Key used in llx_const table to save module status enabled/disabled (where dluo is value of property name of module in uppercase) |
58 | 58 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
59 | 59 | |
60 | - $this->picto='stock'; |
|
60 | + $this->picto = 'stock'; |
|
61 | 61 | |
62 | 62 | $this->module_parts = array(); |
63 | 63 | |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | $this->config_page_url = array("product_lot_extrafields.php@product"); |
69 | 69 | |
70 | 70 | // Dependencies |
71 | - $this->hidden = false; // A condition to hide module |
|
72 | - $this->depends = array("modProduct","modStock","modExpedition","modFournisseur"); // List of module class names as string that must be enabled if this module is enabled |
|
73 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
74 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
75 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
76 | - $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module |
|
71 | + $this->hidden = false; // A condition to hide module |
|
72 | + $this->depends = array("modProduct", "modStock", "modExpedition", "modFournisseur"); // List of module class names as string that must be enabled if this module is enabled |
|
73 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
74 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
75 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module |
|
76 | + $this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module |
|
77 | 77 | $this->langfiles = array("productbatch"); |
78 | 78 | |
79 | 79 | // Constants |
@@ -82,28 +82,28 @@ discard block |
||
82 | 82 | $this->tabs = array(); |
83 | 83 | |
84 | 84 | // Dictionaries |
85 | - if (! isset($conf->productbatch->enabled)) |
|
85 | + if (!isset($conf->productbatch->enabled)) |
|
86 | 86 | { |
87 | - $conf->productbatch=new stdClass(); |
|
88 | - $conf->productbatch->enabled=0; |
|
87 | + $conf->productbatch = new stdClass(); |
|
88 | + $conf->productbatch->enabled = 0; |
|
89 | 89 | } |
90 | - $this->dictionaries=array(); |
|
90 | + $this->dictionaries = array(); |
|
91 | 91 | |
92 | 92 | // Boxes |
93 | - $this->boxes = array(); // List of boxes |
|
93 | + $this->boxes = array(); // List of boxes |
|
94 | 94 | |
95 | 95 | // Permissions |
96 | - $this->rights = array(); // Permission array used by this module |
|
97 | - $r=0; |
|
96 | + $this->rights = array(); // Permission array used by this module |
|
97 | + $r = 0; |
|
98 | 98 | |
99 | 99 | |
100 | 100 | // Menus |
101 | 101 | //------- |
102 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
102 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
103 | 103 | |
104 | 104 | |
105 | 105 | // Exports |
106 | - $r=0; |
|
106 | + $r = 0; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | * @param string $options Options when enabling module ('', 'noboxes') |
115 | 115 | * @return int 1 if OK, 0 if KO |
116 | 116 | */ |
117 | - function init($options='') |
|
117 | + function init($options = '') |
|
118 | 118 | { |
119 | - global $db,$conf; |
|
119 | + global $db, $conf; |
|
120 | 120 | |
121 | 121 | $sql = array(); |
122 | 122 | |
123 | - if (! empty($conf->cashdesk->enabled)) { |
|
123 | + if (!empty($conf->cashdesk->enabled)) { |
|
124 | 124 | if (empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) { |
125 | 125 | include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; |
126 | - $res = dolibarr_set_const($db,"CASHDESK_NO_DECREASE_STOCK",1,'chaine',0,'',$conf->entity); |
|
126 | + $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 |
@@ -30,122 +30,122 @@ |
||
30 | 30 | */ |
31 | 31 | class mod_holiday_immaculate extends ModelNumRefHolidays |
32 | 32 | { |
33 | - /** |
|
33 | + /** |
|
34 | 34 | * Dolibarr version of the loaded document |
35 | 35 | * @public string |
36 | 36 | */ |
37 | - public $version = 'dolibarr'; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var string Error message |
|
41 | - */ |
|
42 | - public $error = ''; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var string Nom du modele |
|
46 | - * @deprecated |
|
47 | - * @see $name |
|
48 | - */ |
|
49 | - public $nom='Immaculate'; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var string model name |
|
53 | - */ |
|
54 | - public $name='Immaculate'; |
|
55 | - |
|
56 | - public $code_auto=1; |
|
57 | - |
|
58 | - /** |
|
59 | - * Return default description of numbering model |
|
60 | - * |
|
61 | - * @return string text description |
|
62 | - */ |
|
63 | - function info() |
|
37 | + public $version = 'dolibarr'; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var string Error message |
|
41 | + */ |
|
42 | + public $error = ''; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var string Nom du modele |
|
46 | + * @deprecated |
|
47 | + * @see $name |
|
48 | + */ |
|
49 | + public $nom='Immaculate'; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var string model name |
|
53 | + */ |
|
54 | + public $name='Immaculate'; |
|
55 | + |
|
56 | + public $code_auto=1; |
|
57 | + |
|
58 | + /** |
|
59 | + * Return default description of numbering model |
|
60 | + * |
|
61 | + * @return string text description |
|
62 | + */ |
|
63 | + function info() |
|
64 | 64 | { |
65 | - global $conf, $langs; |
|
65 | + global $conf, $langs; |
|
66 | 66 | |
67 | - $langs->load("bills"); |
|
67 | + $langs->load("bills"); |
|
68 | 68 | |
69 | - $form = new Form($this->db); |
|
69 | + $form = new Form($this->db); |
|
70 | 70 | |
71 | - $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
72 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
73 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
74 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
75 | - $texte.= '<input type="hidden" name="maskconstcontract" value="HOLIDAY_IMMACULATE_MASK">'; |
|
76 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
71 | + $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
72 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
73 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
74 | + $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
75 | + $texte.= '<input type="hidden" name="maskconstcontract" value="HOLIDAY_IMMACULATE_MASK">'; |
|
76 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
77 | 77 | |
78 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Holiday"),$langs->transnoentities("Holiday")); |
|
79 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
80 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Holiday"),$langs->transnoentities("Holiday")); |
|
82 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
78 | + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Holiday"),$langs->transnoentities("Holiday")); |
|
79 | + $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
80 | + $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
81 | + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Holiday"),$langs->transnoentities("Holiday")); |
|
82 | + $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
83 | 83 | |
84 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskholiday" value="'.$conf->global->HOLIDAY_IMMACULATE_MASK.'">',$tooltip,1,1).'</td>'; |
|
86 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
87 | - $texte.= '</tr>'; |
|
88 | - $texte.= '</table>'; |
|
89 | - $texte.= '</form>'; |
|
84 | + $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskholiday" value="'.$conf->global->HOLIDAY_IMMACULATE_MASK.'">',$tooltip,1,1).'</td>'; |
|
86 | + $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
87 | + $texte.= '</tr>'; |
|
88 | + $texte.= '</table>'; |
|
89 | + $texte.= '</form>'; |
|
90 | 90 | |
91 | - return $texte; |
|
91 | + return $texte; |
|
92 | 92 | } |
93 | 93 | |
94 | - /** |
|
95 | - * Return numbering example |
|
96 | - * |
|
97 | - * @return string Example |
|
98 | - */ |
|
94 | + /** |
|
95 | + * Return numbering example |
|
96 | + * |
|
97 | + * @return string Example |
|
98 | + */ |
|
99 | 99 | function getExample() |
100 | 100 | { |
101 | - global $conf,$langs,$user; |
|
102 | - |
|
103 | - $old_login=$user->login; |
|
104 | - $user->login='UUUUUUU'; |
|
105 | - $numExample = $this->getNextValue($user, ''); |
|
106 | - $user->login=$old_login; |
|
107 | - |
|
108 | - if (! $numExample) |
|
109 | - { |
|
110 | - $numExample = $langs->trans('NotConfigured'); |
|
111 | - } |
|
112 | - return $numExample; |
|
101 | + global $conf,$langs,$user; |
|
102 | + |
|
103 | + $old_login=$user->login; |
|
104 | + $user->login='UUUUUUU'; |
|
105 | + $numExample = $this->getNextValue($user, ''); |
|
106 | + $user->login=$old_login; |
|
107 | + |
|
108 | + if (! $numExample) |
|
109 | + { |
|
110 | + $numExample = $langs->trans('NotConfigured'); |
|
111 | + } |
|
112 | + return $numExample; |
|
113 | 113 | } |
114 | 114 | |
115 | - /** |
|
116 | - * Return next value |
|
117 | - * |
|
118 | - * @param Societe $user user object |
|
119 | - * @param Object $holiday holiday object |
|
120 | - * @return string Value if OK, 0 if KO |
|
121 | - */ |
|
115 | + /** |
|
116 | + * Return next value |
|
117 | + * |
|
118 | + * @param Societe $user user object |
|
119 | + * @param Object $holiday holiday object |
|
120 | + * @return string Value if OK, 0 if KO |
|
121 | + */ |
|
122 | 122 | function getNextValue($user, $holiday) |
123 | 123 | { |
124 | - global $db,$conf; |
|
124 | + global $db,$conf; |
|
125 | 125 | |
126 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
126 | + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
127 | 127 | |
128 | - $mask=$conf->global->HOLIDAY_IMMACULATE_MASK; |
|
128 | + $mask=$conf->global->HOLIDAY_IMMACULATE_MASK; |
|
129 | 129 | |
130 | - if (! $mask) |
|
131 | - { |
|
132 | - $this->error='NotConfigured'; |
|
133 | - return 0; |
|
134 | - } |
|
130 | + if (! $mask) |
|
131 | + { |
|
132 | + $this->error='NotConfigured'; |
|
133 | + return 0; |
|
134 | + } |
|
135 | 135 | |
136 | - $numFinal=get_next_value($db,$mask,'holiday','ref','', $user, $holiday->date_create); |
|
136 | + $numFinal=get_next_value($db,$mask,'holiday','ref','', $user, $holiday->date_create); |
|
137 | 137 | |
138 | - return $numFinal; |
|
139 | - } |
|
138 | + return $numFinal; |
|
139 | + } |
|
140 | 140 | |
141 | 141 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
142 | - /** |
|
143 | - * Return next value |
|
144 | - * |
|
145 | - * @param User $fuser User object |
|
146 | - * @param Object $objforref Holiday object |
|
147 | - * @return string Value if OK, 0 if KO |
|
148 | - */ |
|
142 | + /** |
|
143 | + * Return next value |
|
144 | + * |
|
145 | + * @param User $fuser User object |
|
146 | + * @param Object $objforref Holiday object |
|
147 | + * @return string Value if OK, 0 if KO |
|
148 | + */ |
|
149 | 149 | function holiday_get_num($fuser, $objforref) |
150 | 150 | { |
151 | 151 | // phpcs:enable |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \brief File of class to manage contract numbering rules Magre |
24 | 24 | */ |
25 | 25 | |
26 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/holiday/modules_holiday.php'; |
|
26 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/holiday/modules_holiday.php'; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Class to manage contract numbering rules Magre |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | * @deprecated |
47 | 47 | * @see $name |
48 | 48 | */ |
49 | - public $nom='Immaculate'; |
|
49 | + public $nom = 'Immaculate'; |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @var string model name |
53 | 53 | */ |
54 | - public $name='Immaculate'; |
|
54 | + public $name = 'Immaculate'; |
|
55 | 55 | |
56 | - public $code_auto=1; |
|
56 | + public $code_auto = 1; |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * Return default description of numbering model |
@@ -69,24 +69,24 @@ discard block |
||
69 | 69 | $form = new Form($this->db); |
70 | 70 | |
71 | 71 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
72 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
73 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
74 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
75 | - $texte.= '<input type="hidden" name="maskconstcontract" value="HOLIDAY_IMMACULATE_MASK">'; |
|
76 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
77 | - |
|
78 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Holiday"),$langs->transnoentities("Holiday")); |
|
79 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
80 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Holiday"),$langs->transnoentities("Holiday")); |
|
82 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
83 | - |
|
84 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskholiday" value="'.$conf->global->HOLIDAY_IMMACULATE_MASK.'">',$tooltip,1,1).'</td>'; |
|
86 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
87 | - $texte.= '</tr>'; |
|
88 | - $texte.= '</table>'; |
|
89 | - $texte.= '</form>'; |
|
72 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
73 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
74 | + $texte .= '<input type="hidden" name="action" value="updateMask">'; |
|
75 | + $texte .= '<input type="hidden" name="maskconstcontract" value="HOLIDAY_IMMACULATE_MASK">'; |
|
76 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
77 | + |
|
78 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Holiday"), $langs->transnoentities("Holiday")); |
|
79 | + $tooltip .= $langs->trans("GenericMaskCodes2"); |
|
80 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
81 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Holiday"), $langs->transnoentities("Holiday")); |
|
82 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
83 | + |
|
84 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskholiday" value="'.$conf->global->HOLIDAY_IMMACULATE_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
86 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
87 | + $texte .= '</tr>'; |
|
88 | + $texte .= '</table>'; |
|
89 | + $texte .= '</form>'; |
|
90 | 90 | |
91 | 91 | return $texte; |
92 | 92 | } |
@@ -98,14 +98,14 @@ discard block |
||
98 | 98 | */ |
99 | 99 | function getExample() |
100 | 100 | { |
101 | - global $conf,$langs,$user; |
|
101 | + global $conf, $langs, $user; |
|
102 | 102 | |
103 | - $old_login=$user->login; |
|
104 | - $user->login='UUUUUUU'; |
|
103 | + $old_login = $user->login; |
|
104 | + $user->login = 'UUUUUUU'; |
|
105 | 105 | $numExample = $this->getNextValue($user, ''); |
106 | - $user->login=$old_login; |
|
106 | + $user->login = $old_login; |
|
107 | 107 | |
108 | - if (! $numExample) |
|
108 | + if (!$numExample) |
|
109 | 109 | { |
110 | 110 | $numExample = $langs->trans('NotConfigured'); |
111 | 111 | } |
@@ -121,19 +121,19 @@ discard block |
||
121 | 121 | */ |
122 | 122 | function getNextValue($user, $holiday) |
123 | 123 | { |
124 | - global $db,$conf; |
|
124 | + global $db, $conf; |
|
125 | 125 | |
126 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
126 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
127 | 127 | |
128 | - $mask=$conf->global->HOLIDAY_IMMACULATE_MASK; |
|
128 | + $mask = $conf->global->HOLIDAY_IMMACULATE_MASK; |
|
129 | 129 | |
130 | - if (! $mask) |
|
130 | + if (!$mask) |
|
131 | 131 | { |
132 | - $this->error='NotConfigured'; |
|
132 | + $this->error = 'NotConfigured'; |
|
133 | 133 | return 0; |
134 | 134 | } |
135 | 135 | |
136 | - $numFinal=get_next_value($db,$mask,'holiday','ref','', $user, $holiday->date_create); |
|
136 | + $numFinal = get_next_value($db, $mask, 'holiday', 'ref', '', $user, $holiday->date_create); |
|
137 | 137 | |
138 | 138 | return $numFinal; |
139 | 139 | } |
@@ -29,142 +29,142 @@ |
||
29 | 29 | */ |
30 | 30 | class mod_holiday_madonna extends ModelNumRefHolidays |
31 | 31 | { |
32 | - /** |
|
32 | + /** |
|
33 | 33 | * Dolibarr version of the loaded document |
34 | 34 | * @public string |
35 | 35 | */ |
36 | - public $version = 'dolibarr'; |
|
36 | + public $version = 'dolibarr'; |
|
37 | 37 | |
38 | - public $prefix='HL'; |
|
38 | + public $prefix='HL'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @var string Error code (or message) |
|
42 | - */ |
|
43 | - public $error=''; |
|
40 | + /** |
|
41 | + * @var string Error code (or message) |
|
42 | + */ |
|
43 | + public $error=''; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @var string Nom du modele |
|
47 | - * @deprecated |
|
48 | - * @see $name |
|
49 | - */ |
|
50 | - public $nom='Madonna'; |
|
45 | + /** |
|
46 | + * @var string Nom du modele |
|
47 | + * @deprecated |
|
48 | + * @see $name |
|
49 | + */ |
|
50 | + public $nom='Madonna'; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @var string model name |
|
54 | - */ |
|
55 | - public $name='Madonna'; |
|
52 | + /** |
|
53 | + * @var string model name |
|
54 | + */ |
|
55 | + public $name='Madonna'; |
|
56 | 56 | |
57 | - public $code_auto=1; |
|
57 | + public $code_auto=1; |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * Return default description of numbering model |
|
62 | - * |
|
63 | - * @return string text description |
|
64 | - */ |
|
60 | + /** |
|
61 | + * Return default description of numbering model |
|
62 | + * |
|
63 | + * @return string text description |
|
64 | + */ |
|
65 | 65 | function info() |
66 | 66 | { |
67 | - global $langs; |
|
68 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
67 | + global $langs; |
|
68 | + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * Return numbering example |
|
74 | - * |
|
75 | - * @return string Example |
|
76 | - */ |
|
77 | - function getExample() |
|
78 | - { |
|
79 | - return $this->prefix."0501-0001"; |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * Test if existing numbers make problems with numbering |
|
85 | - * |
|
86 | - * @return boolean false if conflit, true if ok |
|
87 | - */ |
|
88 | - function canBeActivated() |
|
89 | - { |
|
90 | - global $conf,$langs,$db; |
|
91 | - |
|
92 | - $coyymm=''; $max=''; |
|
93 | - |
|
94 | - $posindice=8; |
|
95 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
96 | - $sql.= " FROM ".MAIN_DB_PREFIX."holiday"; |
|
97 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
98 | - $sql.= " AND entity = ".$conf->entity; |
|
99 | - |
|
100 | - $resql=$db->query($sql); |
|
101 | - if ($resql) |
|
102 | - { |
|
103 | - $row = $db->fetch_row($resql); |
|
104 | - if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
105 | - } |
|
106 | - if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
107 | - { |
|
108 | - $langs->load("errors"); |
|
109 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
110 | - return false; |
|
111 | - } |
|
112 | - |
|
113 | - return true; |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Return next value |
|
118 | - * |
|
119 | - * @param Societe $objsoc third party object |
|
120 | - * @param Object $holiday Holiday object |
|
121 | - * @return string Value if OK, 0 if KO |
|
122 | - */ |
|
123 | - function getNextValue($objsoc, $holiday) |
|
124 | - { |
|
125 | - global $db,$conf; |
|
126 | - |
|
127 | - $posindice=8; |
|
128 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
129 | - $sql.= " FROM ".MAIN_DB_PREFIX."holiday"; |
|
130 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
131 | - $sql.= " AND entity = ".$conf->entity; |
|
132 | - |
|
133 | - $resql=$db->query($sql); |
|
134 | - if ($resql) |
|
135 | - { |
|
136 | - $obj = $db->fetch_object($resql); |
|
137 | - if ($obj) $max = intval($obj->max); |
|
138 | - else $max=0; |
|
139 | - } |
|
140 | - else |
|
141 | - { |
|
142 | - dol_syslog("mod_holiday_madonna::getNextValue", LOG_DEBUG); |
|
143 | - return -1; |
|
144 | - } |
|
145 | - |
|
146 | - $date=$holiday->date_debut; |
|
147 | - $yymm = strftime("%y%m",$date); |
|
148 | - |
|
149 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
150 | - else $num = sprintf("%04s",$max+1); |
|
151 | - |
|
152 | - dol_syslog("mod_holiday_madonna::getNextValue return ".$this->prefix.$yymm."-".$num); |
|
153 | - return $this->prefix.$yymm."-".$num; |
|
154 | - } |
|
72 | + /** |
|
73 | + * Return numbering example |
|
74 | + * |
|
75 | + * @return string Example |
|
76 | + */ |
|
77 | + function getExample() |
|
78 | + { |
|
79 | + return $this->prefix."0501-0001"; |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * Test if existing numbers make problems with numbering |
|
85 | + * |
|
86 | + * @return boolean false if conflit, true if ok |
|
87 | + */ |
|
88 | + function canBeActivated() |
|
89 | + { |
|
90 | + global $conf,$langs,$db; |
|
91 | + |
|
92 | + $coyymm=''; $max=''; |
|
93 | + |
|
94 | + $posindice=8; |
|
95 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
96 | + $sql.= " FROM ".MAIN_DB_PREFIX."holiday"; |
|
97 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
98 | + $sql.= " AND entity = ".$conf->entity; |
|
99 | + |
|
100 | + $resql=$db->query($sql); |
|
101 | + if ($resql) |
|
102 | + { |
|
103 | + $row = $db->fetch_row($resql); |
|
104 | + if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
105 | + } |
|
106 | + if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
107 | + { |
|
108 | + $langs->load("errors"); |
|
109 | + $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
110 | + return false; |
|
111 | + } |
|
112 | + |
|
113 | + return true; |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Return next value |
|
118 | + * |
|
119 | + * @param Societe $objsoc third party object |
|
120 | + * @param Object $holiday Holiday object |
|
121 | + * @return string Value if OK, 0 if KO |
|
122 | + */ |
|
123 | + function getNextValue($objsoc, $holiday) |
|
124 | + { |
|
125 | + global $db,$conf; |
|
126 | + |
|
127 | + $posindice=8; |
|
128 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
129 | + $sql.= " FROM ".MAIN_DB_PREFIX."holiday"; |
|
130 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
131 | + $sql.= " AND entity = ".$conf->entity; |
|
132 | + |
|
133 | + $resql=$db->query($sql); |
|
134 | + if ($resql) |
|
135 | + { |
|
136 | + $obj = $db->fetch_object($resql); |
|
137 | + if ($obj) $max = intval($obj->max); |
|
138 | + else $max=0; |
|
139 | + } |
|
140 | + else |
|
141 | + { |
|
142 | + dol_syslog("mod_holiday_madonna::getNextValue", LOG_DEBUG); |
|
143 | + return -1; |
|
144 | + } |
|
145 | + |
|
146 | + $date=$holiday->date_debut; |
|
147 | + $yymm = strftime("%y%m",$date); |
|
148 | + |
|
149 | + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
150 | + else $num = sprintf("%04s",$max+1); |
|
151 | + |
|
152 | + dol_syslog("mod_holiday_madonna::getNextValue return ".$this->prefix.$yymm."-".$num); |
|
153 | + return $this->prefix.$yymm."-".$num; |
|
154 | + } |
|
155 | 155 | |
156 | 156 | |
157 | 157 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
158 | - /** |
|
159 | - * Return next value |
|
160 | - * |
|
161 | - * @param User $fuser User object |
|
162 | - * @param Object $objforref Holiday object |
|
163 | - * @return string Value if OK, 0 if KO |
|
164 | - */ |
|
165 | - function holiday_get_num($fuser,$objforref) |
|
166 | - { |
|
158 | + /** |
|
159 | + * Return next value |
|
160 | + * |
|
161 | + * @param User $fuser User object |
|
162 | + * @param Object $objforref Holiday object |
|
163 | + * @return string Value if OK, 0 if KO |
|
164 | + */ |
|
165 | + function holiday_get_num($fuser,$objforref) |
|
166 | + { |
|
167 | 167 | // phpcs:enable |
168 | - return $this->getNextValue($fuser,$objforref); |
|
169 | - } |
|
168 | + return $this->getNextValue($fuser,$objforref); |
|
169 | + } |
|
170 | 170 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \ingroup contract |
23 | 23 | * \brief File of class to manage contract numbering rules Serpis |
24 | 24 | */ |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/holiday/modules_holiday.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/holiday/modules_holiday.php'; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Class to manage contract numbering rules madonna |
@@ -35,26 +35,26 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public $version = 'dolibarr'; |
37 | 37 | |
38 | - public $prefix='HL'; |
|
38 | + public $prefix = 'HL'; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @var string Error code (or message) |
42 | 42 | */ |
43 | - public $error=''; |
|
43 | + public $error = ''; |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @var string Nom du modele |
47 | 47 | * @deprecated |
48 | 48 | * @see $name |
49 | 49 | */ |
50 | - public $nom='Madonna'; |
|
50 | + public $nom = 'Madonna'; |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @var string model name |
54 | 54 | */ |
55 | - public $name='Madonna'; |
|
55 | + public $name = 'Madonna'; |
|
56 | 56 | |
57 | - public $code_auto=1; |
|
57 | + public $code_auto = 1; |
|
58 | 58 | |
59 | 59 | |
60 | 60 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | function info() |
66 | 66 | { |
67 | 67 | global $langs; |
68 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
68 | + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
@@ -87,26 +87,26 @@ discard block |
||
87 | 87 | */ |
88 | 88 | function canBeActivated() |
89 | 89 | { |
90 | - global $conf,$langs,$db; |
|
90 | + global $conf, $langs, $db; |
|
91 | 91 | |
92 | - $coyymm=''; $max=''; |
|
92 | + $coyymm = ''; $max = ''; |
|
93 | 93 | |
94 | - $posindice=8; |
|
94 | + $posindice = 8; |
|
95 | 95 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
96 | - $sql.= " FROM ".MAIN_DB_PREFIX."holiday"; |
|
97 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
98 | - $sql.= " AND entity = ".$conf->entity; |
|
96 | + $sql .= " FROM ".MAIN_DB_PREFIX."holiday"; |
|
97 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
98 | + $sql .= " AND entity = ".$conf->entity; |
|
99 | 99 | |
100 | - $resql=$db->query($sql); |
|
100 | + $resql = $db->query($sql); |
|
101 | 101 | if ($resql) |
102 | 102 | { |
103 | 103 | $row = $db->fetch_row($resql); |
104 | - if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
104 | + if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
105 | 105 | } |
106 | - if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
106 | + if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) |
|
107 | 107 | { |
108 | 108 | $langs->load("errors"); |
109 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
109 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | |
@@ -122,20 +122,20 @@ discard block |
||
122 | 122 | */ |
123 | 123 | function getNextValue($objsoc, $holiday) |
124 | 124 | { |
125 | - global $db,$conf; |
|
125 | + global $db, $conf; |
|
126 | 126 | |
127 | - $posindice=8; |
|
127 | + $posindice = 8; |
|
128 | 128 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
129 | - $sql.= " FROM ".MAIN_DB_PREFIX."holiday"; |
|
130 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
131 | - $sql.= " AND entity = ".$conf->entity; |
|
129 | + $sql .= " FROM ".MAIN_DB_PREFIX."holiday"; |
|
130 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
131 | + $sql .= " AND entity = ".$conf->entity; |
|
132 | 132 | |
133 | - $resql=$db->query($sql); |
|
133 | + $resql = $db->query($sql); |
|
134 | 134 | if ($resql) |
135 | 135 | { |
136 | 136 | $obj = $db->fetch_object($resql); |
137 | 137 | if ($obj) $max = intval($obj->max); |
138 | - else $max=0; |
|
138 | + else $max = 0; |
|
139 | 139 | } |
140 | 140 | else |
141 | 141 | { |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | return -1; |
144 | 144 | } |
145 | 145 | |
146 | - $date=$holiday->date_debut; |
|
147 | - $yymm = strftime("%y%m",$date); |
|
146 | + $date = $holiday->date_debut; |
|
147 | + $yymm = strftime("%y%m", $date); |
|
148 | 148 | |
149 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
150 | - else $num = sprintf("%04s",$max+1); |
|
149 | + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
150 | + else $num = sprintf("%04s", $max + 1); |
|
151 | 151 | |
152 | 152 | dol_syslog("mod_holiday_madonna::getNextValue return ".$this->prefix.$yymm."-".$num); |
153 | 153 | return $this->prefix.$yymm."-".$num; |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | * @param Object $objforref Holiday object |
163 | 163 | * @return string Value if OK, 0 if KO |
164 | 164 | */ |
165 | - function holiday_get_num($fuser,$objforref) |
|
165 | + function holiday_get_num($fuser, $objforref) |
|
166 | 166 | { |
167 | 167 | // phpcs:enable |
168 | - return $this->getNextValue($fuser,$objforref); |
|
168 | + return $this->getNextValue($fuser, $objforref); |
|
169 | 169 | } |
170 | 170 | } |
@@ -134,10 +134,12 @@ discard block |
||
134 | 134 | if ($resql) |
135 | 135 | { |
136 | 136 | $obj = $db->fetch_object($resql); |
137 | - if ($obj) $max = intval($obj->max); |
|
138 | - else $max=0; |
|
139 | - } |
|
140 | - else |
|
137 | + if ($obj) { |
|
138 | + $max = intval($obj->max); |
|
139 | + } else { |
|
140 | + $max=0; |
|
141 | + } |
|
142 | + } else |
|
141 | 143 | { |
142 | 144 | dol_syslog("mod_holiday_madonna::getNextValue", LOG_DEBUG); |
143 | 145 | return -1; |
@@ -146,8 +148,13 @@ discard block |
||
146 | 148 | $date=$holiday->date_debut; |
147 | 149 | $yymm = strftime("%y%m",$date); |
148 | 150 | |
149 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
150 | - else $num = sprintf("%04s",$max+1); |
|
151 | + if ($max >= (pow(10, 4) - 1)) { |
|
152 | + $num=$max+1; |
|
153 | + } |
|
154 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
155 | + else { |
|
156 | + $num = sprintf("%04s",$max+1); |
|
157 | + } |
|
151 | 158 | |
152 | 159 | dol_syslog("mod_holiday_madonna::getNextValue return ".$this->prefix.$yymm."-".$num); |
153 | 160 | return $this->prefix.$yymm."-".$num; |