@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
39 | 39 | require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; |
40 | 40 | require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
41 | -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
42 | -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
43 | -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; |
|
44 | -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
45 | -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
|
46 | -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; |
|
47 | -if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
|
48 | -if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; |
|
49 | -if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; |
|
50 | -if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
|
41 | +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
42 | +if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
43 | +if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; |
|
44 | +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
45 | +if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
|
46 | +if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; |
|
47 | +if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
|
48 | +if (!empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; |
|
49 | +if (!empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; |
|
50 | +if (!empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
|
51 | 51 | |
52 | 52 | |
53 | 53 | /** |
@@ -84,37 +84,37 @@ discard block |
||
84 | 84 | global $conf, $langs, $mysoc; |
85 | 85 | |
86 | 86 | // Load translation files required by the page |
87 | - $langs->loadLangs(array("main","companies")); |
|
87 | + $langs->loadLangs(array("main", "companies")); |
|
88 | 88 | |
89 | 89 | $this->db = $db; |
90 | 90 | $this->name = "ODT templates"; |
91 | 91 | $this->description = $langs->trans("DocumentModelOdt"); |
92 | - $this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
92 | + $this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
93 | 93 | |
94 | 94 | // Dimension page pour format A4 |
95 | 95 | $this->type = 'odt'; |
96 | 96 | $this->page_largeur = 0; |
97 | 97 | $this->page_hauteur = 0; |
98 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
99 | - $this->marge_gauche=0; |
|
100 | - $this->marge_droite=0; |
|
101 | - $this->marge_haute=0; |
|
102 | - $this->marge_basse=0; |
|
103 | - |
|
104 | - $this->option_logo = 1; // Affiche logo |
|
105 | - $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION |
|
106 | - $this->option_modereg = 0; // Affiche mode reglement |
|
107 | - $this->option_condreg = 0; // Affiche conditions reglement |
|
108 | - $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
109 | - $this->option_multilang = 0; // Dispo en plusieurs langues |
|
110 | - $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
111 | - $this->option_credit_note = 0; // Support credit notes |
|
112 | - $this->option_freetext = 1; // Support add of a personalised text |
|
113 | - $this->option_draft_watermark = 0; // Support add of a watermark on drafts |
|
98 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
99 | + $this->marge_gauche = 0; |
|
100 | + $this->marge_droite = 0; |
|
101 | + $this->marge_haute = 0; |
|
102 | + $this->marge_basse = 0; |
|
103 | + |
|
104 | + $this->option_logo = 1; // Affiche logo |
|
105 | + $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION |
|
106 | + $this->option_modereg = 0; // Affiche mode reglement |
|
107 | + $this->option_condreg = 0; // Affiche conditions reglement |
|
108 | + $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
109 | + $this->option_multilang = 0; // Dispo en plusieurs langues |
|
110 | + $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
111 | + $this->option_credit_note = 0; // Support credit notes |
|
112 | + $this->option_freetext = 1; // Support add of a personalised text |
|
113 | + $this->option_draft_watermark = 0; // Support add of a watermark on drafts |
|
114 | 114 | |
115 | 115 | // Recupere emetteur |
116 | - $this->emetteur=$mysoc; |
|
117 | - if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'etait pas defini |
|
116 | + $this->emetteur = $mysoc; |
|
117 | + if (!$this->emetteur->pays_code) $this->emetteur->pays_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | |
@@ -127,20 +127,20 @@ discard block |
||
127 | 127 | * @param string $array_key Name of the key for return array |
128 | 128 | * @return array Array of substitution |
129 | 129 | */ |
130 | - function get_substitutionarray_object($object,$outputlangs,$array_key='object') |
|
130 | + function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') |
|
131 | 131 | { |
132 | 132 | // phpcs:enable |
133 | 133 | global $conf; |
134 | 134 | |
135 | - $resarray=array( |
|
135 | + $resarray = array( |
|
136 | 136 | $array_key.'_id'=>$object->id, |
137 | 137 | $array_key.'_ref'=>$object->ref, |
138 | 138 | $array_key.'_title'=>$object->title, |
139 | 139 | $array_key.'_description'=>$object->description, |
140 | - $array_key.'_date_creation'=>dol_print_date($object->date_c,'day'), |
|
141 | - $array_key.'_date_modification'=>dol_print_date($object->date_m,'day'), |
|
142 | - $array_key.'_date_start'=>dol_print_date($object->date_start,'day'), |
|
143 | - $array_key.'_date_end'=>dol_print_date($object->date_end,'day'), |
|
140 | + $array_key.'_date_creation'=>dol_print_date($object->date_c, 'day'), |
|
141 | + $array_key.'_date_modification'=>dol_print_date($object->date_m, 'day'), |
|
142 | + $array_key.'_date_start'=>dol_print_date($object->date_start, 'day'), |
|
143 | + $array_key.'_date_end'=>dol_print_date($object->date_end, 'day'), |
|
144 | 144 | $array_key.'_note_private'=>$object->note_private, |
145 | 145 | $array_key.'_note_public'=>$object->note_public, |
146 | 146 | $array_key.'_public'=>$object->public, |
@@ -150,14 +150,14 @@ discard block |
||
150 | 150 | // Retrieve extrafields |
151 | 151 | if (is_array($object->array_options) && count($object->array_options)) |
152 | 152 | { |
153 | - $extrafieldkey=$object->element; |
|
153 | + $extrafieldkey = $object->element; |
|
154 | 154 | |
155 | 155 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
156 | 156 | $extrafields = new ExtraFields($this->db); |
157 | - $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); |
|
157 | + $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey, true); |
|
158 | 158 | $object->fetch_optionals(); |
159 | 159 | |
160 | - $resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs); |
|
160 | + $resarray = $this->fill_substitutionarray_with_extrafields($object, $resarray, $extrafields, $array_key, $outputlangs); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | return $resarray; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @param Translate $outputlangs Lang object to use for output |
172 | 172 | * @return array Return a substitution array |
173 | 173 | */ |
174 | - function get_substitutionarray_tasks($task,$outputlangs) |
|
174 | + function get_substitutionarray_tasks($task, $outputlangs) |
|
175 | 175 | { |
176 | 176 | // phpcs:enable |
177 | 177 | global $conf; |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | 'task_duration'=>$task->duration, |
188 | 188 | 'task_progress'=>$task->progress, |
189 | 189 | 'task_public'=>$task->public, |
190 | - 'task_date_start'=>dol_print_date($task->date_start,'day'), |
|
191 | - 'task_date_end'=>dol_print_date($task->date_end,'day'), |
|
190 | + 'task_date_start'=>dol_print_date($task->date_start, 'day'), |
|
191 | + 'task_date_end'=>dol_print_date($task->date_end, 'day'), |
|
192 | 192 | 'task_note_private'=>$task->note_private, |
193 | 193 | 'task_note_public'=>$task->note_public |
194 | 194 | ); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @param Translate $outputlangs Lang object to use for output |
203 | 203 | * @return array Return a substitution array |
204 | 204 | */ |
205 | - function get_substitutionarray_project_contacts($contact,$outputlangs) |
|
205 | + function get_substitutionarray_project_contacts($contact, $outputlangs) |
|
206 | 206 | { |
207 | 207 | // phpcs:enable |
208 | 208 | global $conf; |
@@ -227,14 +227,14 @@ discard block |
||
227 | 227 | * @param Translate $outputlangs Lang object to use for output |
228 | 228 | * @return array Return a substitution array |
229 | 229 | */ |
230 | - function get_substitutionarray_project_file($file,$outputlangs) |
|
230 | + function get_substitutionarray_project_file($file, $outputlangs) |
|
231 | 231 | { |
232 | 232 | // phpcs:enable |
233 | 233 | global $conf; |
234 | 234 | |
235 | 235 | return array( |
236 | 236 | 'projfile_name'=>$file['name'], |
237 | - 'projfile_date'=>dol_print_date($file['date'],'day'), |
|
237 | + 'projfile_date'=>dol_print_date($file['date'], 'day'), |
|
238 | 238 | 'projfile_size'=>$file['size'] |
239 | 239 | ); |
240 | 240 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @param Translate $outputlangs Lang object to use for output |
248 | 248 | * @return array Return a substitution array |
249 | 249 | */ |
250 | - function get_substitutionarray_project_reference($refdetail,$outputlangs) |
|
250 | + function get_substitutionarray_project_reference($refdetail, $outputlangs) |
|
251 | 251 | { |
252 | 252 | // phpcs:enable |
253 | 253 | global $conf; |
@@ -255,10 +255,10 @@ discard block |
||
255 | 255 | return array( |
256 | 256 | 'projref_type'=>$refdetail['type'], |
257 | 257 | 'projref_ref'=>$refdetail['ref'], |
258 | - 'projref_date'=>dol_print_date($refdetail['date'],'day'), |
|
258 | + 'projref_date'=>dol_print_date($refdetail['date'], 'day'), |
|
259 | 259 | 'projref_socname'=>$refdetail['socname'], |
260 | - 'projref_amountht'=>price($refdetail['amountht'],0,$outputlangs), |
|
261 | - 'projref_amountttc'=>price($refdetail['amountttc'],0,$outputlangs), |
|
260 | + 'projref_amountht'=>price($refdetail['amountht'], 0, $outputlangs), |
|
261 | + 'projref_amountttc'=>price($refdetail['amountttc'], 0, $outputlangs), |
|
262 | 262 | 'projref_status'=>$refdetail['status'] |
263 | 263 | ); |
264 | 264 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @param Translate $outputlangs Lang object to use for output |
272 | 272 | * @return array Return a substitution array |
273 | 273 | */ |
274 | - function get_substitutionarray_tasksressource($taskressource,$outputlangs) |
|
274 | + function get_substitutionarray_tasksressource($taskressource, $outputlangs) |
|
275 | 275 | { |
276 | 276 | // phpcs:enable |
277 | 277 | global $conf; |
@@ -295,15 +295,15 @@ discard block |
||
295 | 295 | * @param Translate $outputlangs Lang object to use for output |
296 | 296 | * @return array Return a substitution array |
297 | 297 | */ |
298 | - function get_substitutionarray_taskstime($tasktime,$outputlangs) |
|
298 | + function get_substitutionarray_taskstime($tasktime, $outputlangs) |
|
299 | 299 | { |
300 | 300 | // phpcs:enable |
301 | 301 | global $conf; |
302 | 302 | |
303 | 303 | return array( |
304 | 304 | 'tasktime_rowid'=>$tasktime['rowid'], |
305 | - 'tasktime_task_date'=>dol_print_date($tasktime['task_date'],'day'), |
|
306 | - 'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'],'all'), |
|
305 | + 'tasktime_task_date'=>dol_print_date($tasktime['task_date'], 'day'), |
|
306 | + 'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'], 'all'), |
|
307 | 307 | 'tasktime_note'=>$tasktime['note'], |
308 | 308 | 'tasktime_fk_user'=>$tasktime['fk_user'], |
309 | 309 | 'tasktime_user_name'=>$tasktime['name'], |
@@ -320,14 +320,14 @@ discard block |
||
320 | 320 | * @param Translate $outputlangs Lang object to use for output |
321 | 321 | * @return array Return a substitution array |
322 | 322 | */ |
323 | - function get_substitutionarray_task_file($file,$outputlangs) |
|
323 | + function get_substitutionarray_task_file($file, $outputlangs) |
|
324 | 324 | { |
325 | 325 | // phpcs:enable |
326 | 326 | global $conf; |
327 | 327 | |
328 | 328 | return array( |
329 | 329 | 'tasksfile_name'=>$file['name'], |
330 | - 'tasksfile_date'=>dol_print_date($file['date'],'day'), |
|
330 | + 'tasksfile_date'=>dol_print_date($file['date'], 'day'), |
|
331 | 331 | 'tasksfile_size'=>$file['size'] |
332 | 332 | ); |
333 | 333 | } |
@@ -341,83 +341,83 @@ discard block |
||
341 | 341 | */ |
342 | 342 | function info($langs) |
343 | 343 | { |
344 | - global $conf,$langs; |
|
344 | + global $conf, $langs; |
|
345 | 345 | |
346 | 346 | // Load translation files required by the page |
347 | - $langs->loadLangs(array("errors","companies")); |
|
347 | + $langs->loadLangs(array("errors", "companies")); |
|
348 | 348 | |
349 | 349 | $form = new Form($this->db); |
350 | 350 | |
351 | 351 | $texte = $this->description.".<br>\n"; |
352 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
353 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
354 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
355 | - $texte.= '<input type="hidden" name="param1" value="PROJECT_TASK_ADDON_PDF_ODT_PATH">'; |
|
356 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
352 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
353 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
354 | + $texte .= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
355 | + $texte .= '<input type="hidden" name="param1" value="PROJECT_TASK_ADDON_PDF_ODT_PATH">'; |
|
356 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
357 | 357 | |
358 | 358 | // List of directories area |
359 | - $texte.= '<tr><td>'; |
|
360 | - $texttitle=$langs->trans("ListOfDirectories"); |
|
361 | - $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH))); |
|
362 | - $listoffiles=array(); |
|
363 | - foreach($listofdir as $key=>$tmpdir) |
|
359 | + $texte .= '<tr><td>'; |
|
360 | + $texttitle = $langs->trans("ListOfDirectories"); |
|
361 | + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH))); |
|
362 | + $listoffiles = array(); |
|
363 | + foreach ($listofdir as $key=>$tmpdir) |
|
364 | 364 | { |
365 | - $tmpdir=trim($tmpdir); |
|
366 | - $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
|
367 | - if (! $tmpdir) { |
|
365 | + $tmpdir = trim($tmpdir); |
|
366 | + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); |
|
367 | + if (!$tmpdir) { |
|
368 | 368 | unset($listofdir[$key]); continue; |
369 | 369 | } |
370 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
370 | + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); |
|
371 | 371 | else |
372 | 372 | { |
373 | - $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
|
374 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
373 | + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); |
|
374 | + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); |
|
375 | 375 | } |
376 | 376 | } |
377 | - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
|
377 | + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); |
|
378 | 378 | // Add list of substitution keys |
379 | - $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
380 | - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
381 | - |
|
382 | - $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); |
|
383 | - $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">'; |
|
384 | - $texte.= '<textarea class="flat" cols="60" name="value1">'; |
|
385 | - $texte.=$conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH; |
|
386 | - $texte.= '</textarea>'; |
|
387 | - $texte.= '</div><div style="display: inline-block; vertical-align: middle;">'; |
|
388 | - $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">'; |
|
389 | - $texte.= '<br></div></div>'; |
|
379 | + $texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
380 | + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
381 | + |
|
382 | + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); |
|
383 | + $texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">'; |
|
384 | + $texte .= '<textarea class="flat" cols="60" name="value1">'; |
|
385 | + $texte .= $conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH; |
|
386 | + $texte .= '</textarea>'; |
|
387 | + $texte .= '</div><div style="display: inline-block; vertical-align: middle;">'; |
|
388 | + $texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">'; |
|
389 | + $texte .= '<br></div></div>'; |
|
390 | 390 | |
391 | 391 | // Scan directories |
392 | - $nbofiles=count($listoffiles); |
|
393 | - if (! empty($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)) |
|
392 | + $nbofiles = count($listoffiles); |
|
393 | + if (!empty($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)) |
|
394 | 394 | { |
395 | - $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'; |
|
395 | + $texte .= $langs->trans("NumberOfModelFilesFound").': <b>'; |
|
396 | 396 | //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':''; |
397 | - $texte.=$nbofiles; |
|
397 | + $texte .= $nbofiles; |
|
398 | 398 | //$texte.=$nbofiles?'</a>':''; |
399 | - $texte.='</b>'; |
|
399 | + $texte .= '</b>'; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | if ($nbofiles) |
403 | 403 | { |
404 | - $texte.='<div id="div_'.get_class($this).'" class="hidden">'; |
|
405 | - foreach($listoffiles as $file) |
|
404 | + $texte .= '<div id="div_'.get_class($this).'" class="hidden">'; |
|
405 | + foreach ($listoffiles as $file) |
|
406 | 406 | { |
407 | - $texte.=$file['name'].'<br>'; |
|
407 | + $texte .= $file['name'].'<br>'; |
|
408 | 408 | } |
409 | - $texte.='<div id="div_'.get_class($this).'">'; |
|
409 | + $texte .= '<div id="div_'.get_class($this).'">'; |
|
410 | 410 | } |
411 | 411 | |
412 | - $texte.= '</td>'; |
|
412 | + $texte .= '</td>'; |
|
413 | 413 | |
414 | - $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
415 | - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
416 | - $texte.= '</td>'; |
|
417 | - $texte.= '</tr>'; |
|
414 | + $texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
415 | + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
416 | + $texte .= '</td>'; |
|
417 | + $texte .= '</tr>'; |
|
418 | 418 | |
419 | - $texte.= '</table>'; |
|
420 | - $texte.= '</form>'; |
|
419 | + $texte .= '</table>'; |
|
420 | + $texte .= '</form>'; |
|
421 | 421 | |
422 | 422 | return $texte; |
423 | 423 | } |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | * @param string $srctemplatepath Full path of source filename for generator using a template file |
432 | 432 | * @return int 1 if OK, <=0 if KO |
433 | 433 | */ |
434 | - function write_file($object,$outputlangs,$srctemplatepath) |
|
434 | + function write_file($object, $outputlangs, $srctemplatepath) |
|
435 | 435 | { |
436 | 436 | // phpcs:enable |
437 | - global $user,$langs,$conf,$mysoc,$hookmanager; |
|
437 | + global $user, $langs, $conf, $mysoc, $hookmanager; |
|
438 | 438 | |
439 | 439 | if (empty($srctemplatepath)) |
440 | 440 | { |
@@ -442,9 +442,9 @@ discard block |
||
442 | 442 | return -1; |
443 | 443 | } |
444 | 444 | |
445 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
446 | - $sav_charset_output=$outputlangs->charset_output; |
|
447 | - $outputlangs->charset_output='UTF-8'; |
|
445 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
446 | + $sav_charset_output = $outputlangs->charset_output; |
|
447 | + $outputlangs->charset_output = 'UTF-8'; |
|
448 | 448 | |
449 | 449 | // Load translation files required by the page |
450 | 450 | $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); |
@@ -452,32 +452,32 @@ discard block |
||
452 | 452 | if ($conf->projet->dir_output) |
453 | 453 | { |
454 | 454 | // If $object is id instead of object |
455 | - if (! is_object($object)) |
|
455 | + if (!is_object($object)) |
|
456 | 456 | { |
457 | 457 | $id = $object; |
458 | 458 | $object = new Task($this->db); |
459 | - $result=$object->fetch($id); |
|
459 | + $result = $object->fetch($id); |
|
460 | 460 | if ($result < 0) |
461 | 461 | { |
462 | - dol_print_error($this->db,$object->error); |
|
462 | + dol_print_error($this->db, $object->error); |
|
463 | 463 | return -1; |
464 | 464 | } |
465 | 465 | } |
466 | - $project= new Project($this->db); |
|
466 | + $project = new Project($this->db); |
|
467 | 467 | $project->fetch($object->fk_project); |
468 | 468 | $project->fetch_thirdparty(); |
469 | 469 | |
470 | - $dir = $conf->projet->dir_output. "/" . $project->ref. "/"; |
|
470 | + $dir = $conf->projet->dir_output."/".$project->ref."/"; |
|
471 | 471 | $objectref = dol_sanitizeFileName($object->ref); |
472 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
473 | - $file = $dir . "/" . $objectref . ".odt"; |
|
472 | + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; |
|
473 | + $file = $dir."/".$objectref.".odt"; |
|
474 | 474 | |
475 | - if (! file_exists($dir)) |
|
475 | + if (!file_exists($dir)) |
|
476 | 476 | { |
477 | 477 | print '$dir'.$dir; |
478 | 478 | if (dol_mkdir($dir) < 0) |
479 | 479 | { |
480 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
480 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
481 | 481 | return -1; |
482 | 482 | } |
483 | 483 | } |
@@ -486,13 +486,13 @@ discard block |
||
486 | 486 | if (file_exists($dir)) |
487 | 487 | { |
488 | 488 | //print "srctemplatepath=".$srctemplatepath; // Src filename |
489 | - $newfile=basename($srctemplatepath); |
|
490 | - $newfiletmp=preg_replace('/\.(ods|odt)/i','',$newfile); |
|
491 | - $newfiletmp=preg_replace('/template_/i','',$newfiletmp); |
|
492 | - $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); |
|
493 | - $newfiletmp=$objectref.'_'.$newfiletmp; |
|
489 | + $newfile = basename($srctemplatepath); |
|
490 | + $newfiletmp = preg_replace('/\.(ods|odt)/i', '', $newfile); |
|
491 | + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); |
|
492 | + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); |
|
493 | + $newfiletmp = $objectref.'_'.$newfiletmp; |
|
494 | 494 | //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; |
495 | - $file=$dir.'/'.$newfiletmp.'.odt'; |
|
495 | + $file = $dir.'/'.$newfiletmp.'.odt'; |
|
496 | 496 | //print "newdir=".$dir; |
497 | 497 | //print "newfile=".$newfile; |
498 | 498 | //print "file=".$file; |
@@ -500,17 +500,17 @@ discard block |
||
500 | 500 | |
501 | 501 | dol_mkdir($conf->projet->dir_temp); |
502 | 502 | |
503 | - $socobject=$project->thirdparty; |
|
503 | + $socobject = $project->thirdparty; |
|
504 | 504 | |
505 | 505 | // Make substitution |
506 | - $substitutionarray=array( |
|
506 | + $substitutionarray = array( |
|
507 | 507 | '__FROM_NAME__' => $this->emetteur->name, |
508 | 508 | '__FROM_EMAIL__' => $this->emetteur->email, |
509 | 509 | ); |
510 | 510 | complete_substitutions_array($substitutionarray, $langs, $object); |
511 | 511 | // Call the ODTSubstitution hook |
512 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
513 | - $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
512 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); |
|
513 | + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
514 | 514 | |
515 | 515 | // Open and load template |
516 | 516 | require_once ODTPHP_PATH.'odf.php'; |
@@ -519,15 +519,15 @@ discard block |
||
519 | 519 | $srctemplatepath, |
520 | 520 | array( |
521 | 521 | 'PATH_TO_TMP' => $conf->projet->dir_temp, |
522 | - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
522 | + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
523 | 523 | 'DELIMITER_LEFT' => '{', |
524 | 524 | 'DELIMITER_RIGHT' => '}' |
525 | 525 | ) |
526 | 526 | ); |
527 | 527 | } |
528 | - catch(Exception $e) |
|
528 | + catch (Exception $e) |
|
529 | 529 | { |
530 | - $this->error=$e->getMessage(); |
|
530 | + $this->error = $e->getMessage(); |
|
531 | 531 | return -1; |
532 | 532 | } |
533 | 533 | // After construction $odfHandler->contentXml contains content and |
@@ -540,19 +540,19 @@ discard block |
||
540 | 540 | // Define substitution array |
541 | 541 | $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); |
542 | 542 | $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); |
543 | - $array_objet=$this->get_substitutionarray_object($project,$outputlangs); |
|
544 | - $array_user=$this->get_substitutionarray_user($user,$outputlangs); |
|
545 | - $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); |
|
546 | - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); |
|
547 | - $array_other=$this->get_substitutionarray_other($outputlangs); |
|
543 | + $array_objet = $this->get_substitutionarray_object($project, $outputlangs); |
|
544 | + $array_user = $this->get_substitutionarray_user($user, $outputlangs); |
|
545 | + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); |
|
546 | + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); |
|
547 | + $array_other = $this->get_substitutionarray_other($outputlangs); |
|
548 | 548 | |
549 | - $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other); |
|
549 | + $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other); |
|
550 | 550 | complete_substitutions_array($tmparray, $outputlangs, $object); |
551 | 551 | |
552 | - foreach($tmparray as $key=>$value) |
|
552 | + foreach ($tmparray as $key=>$value) |
|
553 | 553 | { |
554 | 554 | try { |
555 | - if (preg_match('/logo$/',$key)) // Image |
|
555 | + if (preg_match('/logo$/', $key)) // Image |
|
556 | 556 | { |
557 | 557 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
558 | 558 | else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
@@ -570,30 +570,30 @@ discard block |
||
570 | 570 | try |
571 | 571 | { |
572 | 572 | // Security check |
573 | - $socid=0; |
|
573 | + $socid = 0; |
|
574 | 574 | if (!empty($project->fk_soc)) $socid = $project->fk_soc; |
575 | 575 | |
576 | - $tmparray=$this->get_substitutionarray_tasks($object,$outputlangs); |
|
576 | + $tmparray = $this->get_substitutionarray_tasks($object, $outputlangs); |
|
577 | 577 | complete_substitutions_array($tmparray, $outputlangs, $object); |
578 | - foreach($tmparray as $key => $val) |
|
578 | + foreach ($tmparray as $key => $val) |
|
579 | 579 | { |
580 | 580 | try { |
581 | 581 | $odfHandler->setVars($key, $val, true, 'UTF-8'); |
582 | 582 | } catch (OdfException $e) { |
583 | 583 | dol_syslog($e->getMessage(), LOG_INFO); |
584 | - } catch(SegmentException $e) { |
|
584 | + } catch (SegmentException $e) { |
|
585 | 585 | dol_syslog($e->getMessage(), LOG_INFO); |
586 | 586 | } |
587 | 587 | } |
588 | 588 | |
589 | 589 | // Replace tags of lines for contacts task |
590 | - $sourcearray=array('internal','external'); |
|
591 | - $contact_arrray=array(); |
|
590 | + $sourcearray = array('internal', 'external'); |
|
591 | + $contact_arrray = array(); |
|
592 | 592 | foreach ($sourcearray as $source) { |
593 | - $contact_temp=$object->liste_contact(-1,$source); |
|
593 | + $contact_temp = $object->liste_contact(-1, $source); |
|
594 | 594 | if ((is_array($contact_temp) && count($contact_temp) > 0)) |
595 | 595 | { |
596 | - $contact_arrray=array_merge($contact_arrray,$contact_temp); |
|
596 | + $contact_arrray = array_merge($contact_arrray, $contact_temp); |
|
597 | 597 | } |
598 | 598 | } |
599 | 599 | if ((is_array($contact_arrray) && count($contact_arrray) > 0)) |
@@ -602,23 +602,23 @@ discard block |
||
602 | 602 | |
603 | 603 | foreach ($contact_arrray as $contact) |
604 | 604 | { |
605 | - if ($contact['source']=='internal') { |
|
606 | - $objectdetail=new User($this->db); |
|
605 | + if ($contact['source'] == 'internal') { |
|
606 | + $objectdetail = new User($this->db); |
|
607 | 607 | $objectdetail->fetch($contact['id']); |
608 | - $contact['socname']=$mysoc->name; |
|
609 | - } elseif ($contact['source']=='external') { |
|
610 | - $objectdetail=new Contact($this->db); |
|
608 | + $contact['socname'] = $mysoc->name; |
|
609 | + } elseif ($contact['source'] == 'external') { |
|
610 | + $objectdetail = new Contact($this->db); |
|
611 | 611 | $objectdetail->fetch($contact['id']); |
612 | 612 | |
613 | - $soc=new Societe($this->db); |
|
613 | + $soc = new Societe($this->db); |
|
614 | 614 | $soc->fetch($contact['socid']); |
615 | - $contact['socname']=$soc->name; |
|
615 | + $contact['socname'] = $soc->name; |
|
616 | 616 | } |
617 | - $contact['fullname']=$objectdetail->getFullName($outputlangs,1); |
|
617 | + $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1); |
|
618 | 618 | |
619 | - $tmparray=$this->get_substitutionarray_tasksressource($contact,$outputlangs); |
|
619 | + $tmparray = $this->get_substitutionarray_tasksressource($contact, $outputlangs); |
|
620 | 620 | |
621 | - foreach($tmparray as $key => $val) |
|
621 | + foreach ($tmparray as $key => $val) |
|
622 | 622 | { |
623 | 623 | try { |
624 | 624 | $listlinestaskres->setVars($key, $val, true, 'UTF-8'); |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | |
637 | 637 | // Time ressources |
638 | 638 | $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note"; |
639 | - $sql.= ", u.lastname, u.firstname"; |
|
639 | + $sql .= ", u.lastname, u.firstname"; |
|
640 | 640 | $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; |
641 | 641 | $sql .= " , ".MAIN_DB_PREFIX."user as u"; |
642 | 642 | $sql .= " WHERE t.fk_task =".$object->id; |
@@ -654,27 +654,27 @@ discard block |
||
654 | 654 | { |
655 | 655 | $row = $this->db->fetch_array($resql); |
656 | 656 | if (!empty($row['fk_user'])) { |
657 | - $objectdetail=new User($this->db); |
|
657 | + $objectdetail = new User($this->db); |
|
658 | 658 | $objectdetail->fetch($row['fk_user']); |
659 | 659 | // TODO Use a cache to aoid fetch for same user |
660 | - $row['fullcivname']=$objectdetail->getFullName($outputlangs,1); |
|
660 | + $row['fullcivname'] = $objectdetail->getFullName($outputlangs, 1); |
|
661 | 661 | } else { |
662 | - $row['fullcivname']=''; |
|
662 | + $row['fullcivname'] = ''; |
|
663 | 663 | } |
664 | 664 | |
665 | - $tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs); |
|
665 | + $tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs); |
|
666 | 666 | |
667 | - foreach($tmparray as $key => $val) |
|
667 | + foreach ($tmparray as $key => $val) |
|
668 | 668 | { |
669 | 669 | try |
670 | 670 | { |
671 | 671 | $listlinestasktime->setVars($key, $val, true, 'UTF-8'); |
672 | 672 | } |
673 | - catch(OdfException $e) |
|
673 | + catch (OdfException $e) |
|
674 | 674 | { |
675 | 675 | dol_syslog($e->getMessage(), LOG_INFO); |
676 | 676 | } |
677 | - catch(SegmentException $e) |
|
677 | + catch (SegmentException $e) |
|
678 | 678 | { |
679 | 679 | dol_syslog($e->getMessage(), LOG_INFO); |
680 | 680 | } |
@@ -692,24 +692,24 @@ discard block |
||
692 | 692 | $listtasksfiles = $odfHandler->setSegment('tasksfiles'); |
693 | 693 | |
694 | 694 | $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($object->ref); |
695 | - $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1); |
|
695 | + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); |
|
696 | 696 | |
697 | 697 | |
698 | 698 | foreach ($filearray as $filedetail) |
699 | 699 | { |
700 | - $tmparray=$this->get_substitutionarray_task_file($filedetail,$outputlangs); |
|
700 | + $tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs); |
|
701 | 701 | //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true)); |
702 | - foreach($tmparray as $key => $val) |
|
702 | + foreach ($tmparray as $key => $val) |
|
703 | 703 | { |
704 | 704 | try |
705 | 705 | { |
706 | 706 | $listtasksfiles->setVars($key, $val, true, 'UTF-8'); |
707 | 707 | } |
708 | - catch(OdfException $e) |
|
708 | + catch (OdfException $e) |
|
709 | 709 | { |
710 | 710 | dol_syslog($e->getMessage(), LOG_INFO); |
711 | 711 | } |
712 | - catch(SegmentException $e) |
|
712 | + catch (SegmentException $e) |
|
713 | 713 | { |
714 | 714 | dol_syslog($e->getMessage(), LOG_INFO); |
715 | 715 | } |
@@ -720,9 +720,9 @@ discard block |
||
720 | 720 | |
721 | 721 | $odfHandler->mergeSegment($listtasksfiles); |
722 | 722 | } |
723 | - catch(OdfException $e) |
|
723 | + catch (OdfException $e) |
|
724 | 724 | { |
725 | - $this->error=$e->getMessage(); |
|
725 | + $this->error = $e->getMessage(); |
|
726 | 726 | dol_syslog($this->error, LOG_WARNING); |
727 | 727 | return -1; |
728 | 728 | } |
@@ -735,25 +735,25 @@ discard block |
||
735 | 735 | $listlines = $odfHandler->setSegment('projectfiles'); |
736 | 736 | |
737 | 737 | $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref); |
738 | - $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1); |
|
738 | + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); |
|
739 | 739 | |
740 | 740 | |
741 | 741 | foreach ($filearray as $filedetail) |
742 | 742 | { |
743 | 743 | //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true)); |
744 | - $tmparray=$this->get_substitutionarray_project_file($filedetail,$outputlangs); |
|
744 | + $tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs); |
|
745 | 745 | |
746 | - foreach($tmparray as $key => $val) |
|
746 | + foreach ($tmparray as $key => $val) |
|
747 | 747 | { |
748 | 748 | try |
749 | 749 | { |
750 | 750 | $listlines->setVars($key, $val, true, 'UTF-8'); |
751 | 751 | } |
752 | - catch(OdfException $e) |
|
752 | + catch (OdfException $e) |
|
753 | 753 | { |
754 | 754 | dol_syslog($e->getMessage(), LOG_INFO); |
755 | 755 | } |
756 | - catch(SegmentException $e) |
|
756 | + catch (SegmentException $e) |
|
757 | 757 | { |
758 | 758 | dol_syslog($e->getMessage(), LOG_INFO); |
759 | 759 | } |
@@ -762,21 +762,21 @@ discard block |
||
762 | 762 | } |
763 | 763 | $odfHandler->mergeSegment($listlines); |
764 | 764 | } |
765 | - catch(OdfException $e) |
|
765 | + catch (OdfException $e) |
|
766 | 766 | { |
767 | - $this->error=$e->getMessage(); |
|
767 | + $this->error = $e->getMessage(); |
|
768 | 768 | dol_syslog($this->error, LOG_WARNING); |
769 | 769 | return -1; |
770 | 770 | } |
771 | 771 | |
772 | 772 | // Replace tags of lines for contacts |
773 | - $sourcearray=array('internal','external'); |
|
774 | - $contact_arrray=array(); |
|
773 | + $sourcearray = array('internal', 'external'); |
|
774 | + $contact_arrray = array(); |
|
775 | 775 | foreach ($sourcearray as $source) { |
776 | - $contact_temp=$project->liste_contact(-1,$source); |
|
776 | + $contact_temp = $project->liste_contact(-1, $source); |
|
777 | 777 | if ((is_array($contact_temp) && count($contact_temp) > 0)) |
778 | 778 | { |
779 | - $contact_arrray=array_merge($contact_arrray,$contact_temp); |
|
779 | + $contact_arrray = array_merge($contact_arrray, $contact_temp); |
|
780 | 780 | } |
781 | 781 | } |
782 | 782 | if ((is_array($contact_arrray) && count($contact_arrray) > 0)) |
@@ -787,33 +787,33 @@ discard block |
||
787 | 787 | |
788 | 788 | foreach ($contact_arrray as $contact) |
789 | 789 | { |
790 | - if ($contact['source']=='internal') { |
|
791 | - $objectdetail=new User($this->db); |
|
790 | + if ($contact['source'] == 'internal') { |
|
791 | + $objectdetail = new User($this->db); |
|
792 | 792 | $objectdetail->fetch($contact['id']); |
793 | - $contact['socname']=$mysoc->name; |
|
794 | - } elseif ($contact['source']=='external') { |
|
795 | - $objectdetail=new Contact($this->db); |
|
793 | + $contact['socname'] = $mysoc->name; |
|
794 | + } elseif ($contact['source'] == 'external') { |
|
795 | + $objectdetail = new Contact($this->db); |
|
796 | 796 | $objectdetail->fetch($contact['id']); |
797 | 797 | |
798 | - $soc=new Societe($this->db); |
|
798 | + $soc = new Societe($this->db); |
|
799 | 799 | $soc->fetch($contact['socid']); |
800 | - $contact['socname']=$soc->name; |
|
800 | + $contact['socname'] = $soc->name; |
|
801 | 801 | } |
802 | - $contact['fullname']=$objectdetail->getFullName($outputlangs,1); |
|
802 | + $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1); |
|
803 | 803 | |
804 | - $tmparray=$this->get_substitutionarray_project_contacts($contact,$outputlangs); |
|
804 | + $tmparray = $this->get_substitutionarray_project_contacts($contact, $outputlangs); |
|
805 | 805 | |
806 | - foreach($tmparray as $key => $val) |
|
806 | + foreach ($tmparray as $key => $val) |
|
807 | 807 | { |
808 | 808 | try |
809 | 809 | { |
810 | 810 | $listlines->setVars($key, $val, true, 'UTF-8'); |
811 | 811 | } |
812 | - catch(OdfException $e) |
|
812 | + catch (OdfException $e) |
|
813 | 813 | { |
814 | 814 | dol_syslog($e->getMessage(), LOG_INFO); |
815 | 815 | } |
816 | - catch(SegmentException $e) |
|
816 | + catch (SegmentException $e) |
|
817 | 817 | { |
818 | 818 | dol_syslog($e->getMessage(), LOG_INFO); |
819 | 819 | } |
@@ -822,9 +822,9 @@ discard block |
||
822 | 822 | } |
823 | 823 | $odfHandler->mergeSegment($listlines); |
824 | 824 | } |
825 | - catch(OdfException $e) |
|
825 | + catch (OdfException $e) |
|
826 | 826 | { |
827 | - $this->error=$e->getMessage(); |
|
827 | + $this->error = $e->getMessage(); |
|
828 | 828 | dol_syslog($this->error, LOG_WARNING); |
829 | 829 | return -1; |
830 | 830 | } |
@@ -832,8 +832,8 @@ discard block |
||
832 | 832 | |
833 | 833 | |
834 | 834 | // Call the beforeODTSave hook |
835 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
836 | - $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
835 | + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); |
|
836 | + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
837 | 837 | |
838 | 838 | |
839 | 839 | // Write new file |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | try { |
842 | 842 | $odfHandler->exportAsAttachedPDF($file); |
843 | 843 | } catch (Exception $e) { |
844 | - $this->error=$e->getMessage(); |
|
844 | + $this->error = $e->getMessage(); |
|
845 | 845 | dol_syslog($e->getMessage(), LOG_INFO); |
846 | 846 | return -1; |
847 | 847 | } |
@@ -850,26 +850,26 @@ discard block |
||
850 | 850 | try { |
851 | 851 | $odfHandler->saveToDisk($file); |
852 | 852 | } catch (Exception $e) { |
853 | - $this->error=$e->getMessage(); |
|
853 | + $this->error = $e->getMessage(); |
|
854 | 854 | dol_syslog($e->getMessage(), LOG_INFO); |
855 | 855 | return -1; |
856 | 856 | } |
857 | 857 | } |
858 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
859 | - $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
858 | + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); |
|
859 | + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
860 | 860 | |
861 | - if (! empty($conf->global->MAIN_UMASK)) |
|
861 | + if (!empty($conf->global->MAIN_UMASK)) |
|
862 | 862 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
863 | 863 | |
864 | - $odfHandler=null; // Destroy object |
|
864 | + $odfHandler = null; // Destroy object |
|
865 | 865 | |
866 | 866 | $this->result = array('fullpath'=>$file); |
867 | 867 | |
868 | - return 1; // Success |
|
868 | + return 1; // Success |
|
869 | 869 | } |
870 | 870 | else |
871 | 871 | { |
872 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
872 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
873 | 873 | return -1; |
874 | 874 | } |
875 | 875 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \brief File with class to manage the numbering module Simple for project references |
24 | 24 | */ |
25 | 25 | |
26 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php'; |
|
26 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php'; |
|
27 | 27 | |
28 | 28 | |
29 | 29 | /** |
@@ -35,26 +35,26 @@ discard block |
||
35 | 35 | * Dolibarr version of the loaded document |
36 | 36 | * @public string |
37 | 37 | */ |
38 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
39 | 39 | |
40 | - public $prefix='TK'; |
|
40 | + public $prefix = 'TK'; |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @var string Error code (or message) |
44 | 44 | */ |
45 | - public $error=''; |
|
45 | + public $error = ''; |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * @var string |
49 | 49 | * @deprecated |
50 | 50 | * @see name |
51 | 51 | */ |
52 | - public $nom='Simple'; |
|
52 | + public $nom = 'Simple'; |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @var string name |
56 | 56 | */ |
57 | - public $name='Simple'; |
|
57 | + public $name = 'Simple'; |
|
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,30 +87,30 @@ 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; |
|
95 | - $sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM " . $posindice . ") AS SIGNED)) as max"; |
|
96 | - $sql .= " FROM " . MAIN_DB_PREFIX . "projet_task AS task, "; |
|
97 | - $sql .= MAIN_DB_PREFIX . "projet AS project WHERE task.fk_projet=project.rowid"; |
|
98 | - $sql .= " AND task.ref LIKE '" . $db->escape($this->prefix) . "____-%'"; |
|
99 | - $sql .= " AND project.entity = " . $conf->entity; |
|
100 | - $resql=$db->query($sql); |
|
94 | + $posindice = 8; |
|
95 | + $sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
96 | + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task AS task, "; |
|
97 | + $sql .= MAIN_DB_PREFIX."projet AS project WHERE task.fk_projet=project.rowid"; |
|
98 | + $sql .= " AND task.ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
99 | + $sql .= " AND project.entity = ".$conf->entity; |
|
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 | return true; |
109 | 109 | } |
110 | 110 | else |
111 | 111 | { |
112 | 112 | $langs->load("errors"); |
113 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
113 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
114 | 114 | return false; |
115 | 115 | } |
116 | 116 | } |
@@ -123,22 +123,22 @@ discard block |
||
123 | 123 | * @param Task $object Object Task |
124 | 124 | * @return string Value if OK, 0 if KO |
125 | 125 | */ |
126 | - function getNextValue($objsoc,$object) |
|
126 | + function getNextValue($objsoc, $object) |
|
127 | 127 | { |
128 | - global $db,$conf; |
|
128 | + global $db, $conf; |
|
129 | 129 | |
130 | 130 | // D'abord on recupere la valeur max |
131 | - $posindice=8; |
|
131 | + $posindice = 8; |
|
132 | 132 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
133 | - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task"; |
|
134 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
133 | + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task"; |
|
134 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
135 | 135 | |
136 | - $resql=$db->query($sql); |
|
136 | + $resql = $db->query($sql); |
|
137 | 137 | if ($resql) |
138 | 138 | { |
139 | 139 | $obj = $db->fetch_object($resql); |
140 | 140 | if ($obj) $max = intval($obj->max); |
141 | - else $max=0; |
|
141 | + else $max = 0; |
|
142 | 142 | } |
143 | 143 | else |
144 | 144 | { |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | return -1; |
147 | 147 | } |
148 | 148 | |
149 | - $date=empty($object->date_c)?dol_now():$object->date_c; |
|
149 | + $date = empty($object->date_c) ?dol_now() : $object->date_c; |
|
150 | 150 | |
151 | 151 | //$yymm = strftime("%y%m",time()); |
152 | - $yymm = strftime("%y%m",$date); |
|
152 | + $yymm = strftime("%y%m", $date); |
|
153 | 153 | |
154 | - 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 |
|
155 | - else $num = sprintf("%04s",$max+1); |
|
154 | + 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 |
|
155 | + else $num = sprintf("%04s", $max + 1); |
|
156 | 156 | |
157 | 157 | dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num); |
158 | 158 | return $this->prefix.$yymm."-".$num; |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param Task $object Object task |
168 | 168 | * @return string Next not used reference |
169 | 169 | */ |
170 | - function task_get_num($objsoc=0,$object='') |
|
170 | + function task_get_num($objsoc = 0, $object = '') |
|
171 | 171 | { |
172 | - return $this->getNextValue($objsoc,$object); |
|
172 | + return $this->getNextValue($objsoc, $object); |
|
173 | 173 | } |
174 | 174 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief Fichier contenant la classe du modele de numerotation de reference de projet Universal |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php'; |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * Dolibarr version of the loaded document |
35 | 35 | * @public string |
36 | 36 | */ |
37 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @var string Error code (or message) |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * @deprecated |
47 | 47 | * @see name |
48 | 48 | */ |
49 | - public $nom='Universal'; |
|
49 | + public $nom = 'Universal'; |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @var string name |
53 | 53 | */ |
54 | - public $name='Universal'; |
|
54 | + public $name = 'Universal'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
@@ -61,36 +61,36 @@ discard block |
||
61 | 61 | */ |
62 | 62 | function info() |
63 | 63 | { |
64 | - global $conf,$langs; |
|
64 | + global $conf, $langs; |
|
65 | 65 | |
66 | 66 | // Load translation files required by the page |
67 | - $langs->loadLangs(array("projects","admin")); |
|
67 | + $langs->loadLangs(array("projects", "admin")); |
|
68 | 68 | |
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="updateMaskTask">'; |
|
75 | - $texte.= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">'; |
|
76 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
77 | - |
|
78 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Task"),$langs->transnoentities("Task")); |
|
79 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
80 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Task"),$langs->transnoentities("Task")); |
|
82 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
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="updateMaskTask">'; |
|
75 | + $texte .= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">'; |
|
76 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
77 | + |
|
78 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Task"), $langs->transnoentities("Task")); |
|
79 | + $tooltip .= $langs->trans("GenericMaskCodes2"); |
|
80 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
81 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Task"), $langs->transnoentities("Task")); |
|
82 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
83 | 83 | |
84 | 84 | // Parametrage du prefix |
85 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
86 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>'; |
|
85 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
86 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
87 | 87 | |
88 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
88 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
89 | 89 | |
90 | - $texte.= '</tr>'; |
|
90 | + $texte .= '</tr>'; |
|
91 | 91 | |
92 | - $texte.= '</table>'; |
|
93 | - $texte.= '</form>'; |
|
92 | + $texte .= '</table>'; |
|
93 | + $texte .= '</form>'; |
|
94 | 94 | |
95 | 95 | return $texte; |
96 | 96 | } |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | */ |
103 | 103 | function getExample() |
104 | 104 | { |
105 | - global $conf,$langs,$mysoc; |
|
105 | + global $conf, $langs, $mysoc; |
|
106 | 106 | |
107 | - $old_code_client=$mysoc->code_client; |
|
108 | - $mysoc->code_client='CCCCCCCCCC'; |
|
109 | - $numExample = $this->getNextValue($mysoc,''); |
|
110 | - $mysoc->code_client=$old_code_client; |
|
107 | + $old_code_client = $mysoc->code_client; |
|
108 | + $mysoc->code_client = 'CCCCCCCCCC'; |
|
109 | + $numExample = $this->getNextValue($mysoc, ''); |
|
110 | + $mysoc->code_client = $old_code_client; |
|
111 | 111 | |
112 | - if (! $numExample) |
|
112 | + if (!$numExample) |
|
113 | 113 | { |
114 | 114 | $numExample = $langs->trans('NotConfigured'); |
115 | 115 | } |
@@ -123,23 +123,23 @@ discard block |
||
123 | 123 | * @param Task $object Object task |
124 | 124 | * @return string Value if OK, 0 if KO |
125 | 125 | */ |
126 | - function getNextValue($objsoc,$object) |
|
126 | + function getNextValue($objsoc, $object) |
|
127 | 127 | { |
128 | - global $db,$conf; |
|
128 | + global $db, $conf; |
|
129 | 129 | |
130 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
130 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
131 | 131 | |
132 | 132 | // On defini critere recherche compteur |
133 | - $mask=$conf->global->PROJECT_TASK_UNIVERSAL_MASK; |
|
133 | + $mask = $conf->global->PROJECT_TASK_UNIVERSAL_MASK; |
|
134 | 134 | |
135 | - if (! $mask) |
|
135 | + if (!$mask) |
|
136 | 136 | { |
137 | - $this->error='NotConfigured'; |
|
137 | + $this->error = 'NotConfigured'; |
|
138 | 138 | return 0; |
139 | 139 | } |
140 | 140 | |
141 | - $date=empty($object->date_c)?dol_now():$object->date_c; |
|
142 | - $numFinal=get_next_value($db,$mask,'projet_task','ref','',(is_object($objsoc)?$objsoc->code_client:''),$date); |
|
141 | + $date = empty($object->date_c) ?dol_now() : $object->date_c; |
|
142 | + $numFinal = get_next_value($db, $mask, 'projet_task', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date); |
|
143 | 143 | |
144 | 144 | return $numFinal; |
145 | 145 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param Task $object Object task |
154 | 154 | * @return string Next not used reference |
155 | 155 | */ |
156 | - function project_get_num($objsoc=0,$object='') |
|
156 | + function project_get_num($objsoc = 0, $object = '') |
|
157 | 157 | { |
158 | 158 | // phpcs:enable |
159 | 159 | return $this->getNextValue($objsoc, $object); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @var string Error code (or message) |
37 | 37 | */ |
38 | - public $error=''; |
|
38 | + public $error = ''; |
|
39 | 39 | |
40 | 40 | |
41 | 41 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -46,16 +46,16 @@ discard block |
||
46 | 46 | * @param integer $maxfilenamelength Max length of value to show |
47 | 47 | * @return array List of templates |
48 | 48 | */ |
49 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
49 | + static function liste_modeles($db, $maxfilenamelength = 0) |
|
50 | 50 | { |
51 | 51 | // phpcs:enable |
52 | 52 | global $conf; |
53 | 53 | |
54 | - $type='project_task'; |
|
55 | - $liste=array(); |
|
54 | + $type = 'project_task'; |
|
55 | + $liste = array(); |
|
56 | 56 | |
57 | 57 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
58 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
58 | + $liste = getListOfModels($db, $type, $maxfilenamelength); |
|
59 | 59 | |
60 | 60 | return $liste; |
61 | 61 | } |
@@ -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 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief Fichier contenant la classe du modele de numerotation de reference de projet Universal |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/project/modules_project.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * Dolibarr version of the loaded document |
35 | 35 | * @public string |
36 | 36 | */ |
37 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @var string Error code (or message) |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * @deprecated |
47 | 47 | * @see name |
48 | 48 | */ |
49 | - public $nom='Universal'; |
|
49 | + public $nom = 'Universal'; |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @var string model name |
53 | 53 | */ |
54 | - public $name='Universal'; |
|
54 | + public $name = 'Universal'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
@@ -64,33 +64,33 @@ discard block |
||
64 | 64 | global $conf, $langs; |
65 | 65 | |
66 | 66 | // Load translation files required by the page |
67 | - $langs->loadLangs(array("projects","admin")); |
|
67 | + $langs->loadLangs(array("projects", "admin")); |
|
68 | 68 | |
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="maskconstproject" value="PROJECT_UNIVERSAL_MASK">'; |
|
76 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
77 | - |
|
78 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Project"),$langs->transnoentities("Project")); |
|
79 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
80 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Project"),$langs->transnoentities("Project")); |
|
82 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
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="maskconstproject" value="PROJECT_UNIVERSAL_MASK">'; |
|
76 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
77 | + |
|
78 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Project"), $langs->transnoentities("Project")); |
|
79 | + $tooltip .= $langs->trans("GenericMaskCodes2"); |
|
80 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
81 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Project"), $langs->transnoentities("Project")); |
|
82 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
83 | 83 | |
84 | 84 | // Parametrage du prefix |
85 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
86 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskproject" value="'.$conf->global->PROJECT_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>'; |
|
85 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
86 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskproject" value="'.$conf->global->PROJECT_UNIVERSAL_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
87 | 87 | |
88 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
88 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
89 | 89 | |
90 | - $texte.= '</tr>'; |
|
90 | + $texte .= '</tr>'; |
|
91 | 91 | |
92 | - $texte.= '</table>'; |
|
93 | - $texte.= '</form>'; |
|
92 | + $texte .= '</table>'; |
|
93 | + $texte .= '</form>'; |
|
94 | 94 | |
95 | 95 | return $texte; |
96 | 96 | } |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | */ |
103 | 103 | function getExample() |
104 | 104 | { |
105 | - global $conf,$langs,$mysoc; |
|
105 | + global $conf, $langs, $mysoc; |
|
106 | 106 | |
107 | - $old_code_client=$mysoc->code_client; |
|
108 | - $mysoc->code_client='CCCCCCCCCC'; |
|
109 | - $numExample = $this->getNextValue($mysoc,''); |
|
110 | - $mysoc->code_client=$old_code_client; |
|
107 | + $old_code_client = $mysoc->code_client; |
|
108 | + $mysoc->code_client = 'CCCCCCCCCC'; |
|
109 | + $numExample = $this->getNextValue($mysoc, ''); |
|
110 | + $mysoc->code_client = $old_code_client; |
|
111 | 111 | |
112 | - if (! $numExample) |
|
112 | + if (!$numExample) |
|
113 | 113 | { |
114 | 114 | $numExample = $langs->trans('NotConfigured'); |
115 | 115 | } |
@@ -125,21 +125,21 @@ discard block |
||
125 | 125 | */ |
126 | 126 | function getNextValue($objsoc, $project) |
127 | 127 | { |
128 | - global $db,$conf; |
|
128 | + global $db, $conf; |
|
129 | 129 | |
130 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
130 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
131 | 131 | |
132 | 132 | // On defini critere recherche compteur |
133 | - $mask=$conf->global->PROJECT_UNIVERSAL_MASK; |
|
133 | + $mask = $conf->global->PROJECT_UNIVERSAL_MASK; |
|
134 | 134 | |
135 | - if (! $mask) |
|
135 | + if (!$mask) |
|
136 | 136 | { |
137 | - $this->error='NotConfigured'; |
|
137 | + $this->error = 'NotConfigured'; |
|
138 | 138 | return 0; |
139 | 139 | } |
140 | 140 | |
141 | - $date=empty($project->date_c)?dol_now():$project->date_c; |
|
142 | - $numFinal=get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date); |
|
141 | + $date = empty($project->date_c) ?dol_now() : $project->date_c; |
|
142 | + $numFinal = get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date); |
|
143 | 143 | |
144 | 144 | return $numFinal; |
145 | 145 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param Project $project Object project |
154 | 154 | * @return string Next not used reference |
155 | 155 | */ |
156 | - function project_get_num($objsoc=0, $project='') |
|
156 | + function project_get_num($objsoc = 0, $project = '') |
|
157 | 157 | { |
158 | 158 | // phpcs:enable |
159 | 159 | return $this->getNextValue($objsoc, $project); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \brief Fichier de description et activation du module externalrss |
25 | 25 | */ |
26 | 26 | |
27 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
27 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
28 | 28 | |
29 | 29 | |
30 | 30 | /** |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | |
48 | 48 | $this->family = "technic"; |
49 | 49 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
50 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
50 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
51 | 51 | $this->description = "Ajout de files d'informations RSS dans les ecrans Dolibarr"; |
52 | 52 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
53 | 53 | $this->version = 'dolibarr'; |
54 | 54 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
55 | - $this->picto='rss'; |
|
55 | + $this->picto = 'rss'; |
|
56 | 56 | |
57 | 57 | // Data directories to create when module is enabled |
58 | 58 | $this->dirs = array("/externalrss/temp"); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | // Dependencies |
64 | 64 | $this->depends = array(); |
65 | 65 | $this->requiredby = array(); |
66 | - $this->phpmin = array(4,2,0); |
|
66 | + $this->phpmin = array(4, 2, 0); |
|
67 | 67 | $this->phpmax = array(); |
68 | 68 | |
69 | 69 | // Constants |
@@ -86,23 +86,23 @@ discard block |
||
86 | 86 | * @param string $options Options when enabling module ('', 'noboxes') |
87 | 87 | * @return int 1 if OK, 0 if KO |
88 | 88 | */ |
89 | - function init($options='') |
|
89 | + function init($options = '') |
|
90 | 90 | { |
91 | 91 | global $conf; |
92 | 92 | |
93 | 93 | $sql = array(); |
94 | 94 | |
95 | 95 | // Recherche configuration de boites |
96 | - $this->boxes=array(); |
|
97 | - $sql="select name, value from ".MAIN_DB_PREFIX."const"; |
|
98 | - $sql.= " WHERE name like 'EXTERNAL_RSS_TITLE_%'"; |
|
99 | - $sql.= " AND entity = ".$conf->entity; |
|
100 | - $result=$this->db->query($sql); |
|
96 | + $this->boxes = array(); |
|
97 | + $sql = "select name, value from ".MAIN_DB_PREFIX."const"; |
|
98 | + $sql .= " WHERE name like 'EXTERNAL_RSS_TITLE_%'"; |
|
99 | + $sql .= " AND entity = ".$conf->entity; |
|
100 | + $result = $this->db->query($sql); |
|
101 | 101 | if ($result) |
102 | 102 | { |
103 | 103 | while ($obj = $this->db->fetch_object($result)) |
104 | 104 | { |
105 | - if (preg_match('/EXTERNAL_RSS_TITLE_([0-9]+)/i',$obj->name,$reg)) |
|
105 | + if (preg_match('/EXTERNAL_RSS_TITLE_([0-9]+)/i', $obj->name, $reg)) |
|
106 | 106 | { |
107 | 107 | // Definie la boite si on a trouvee une ancienne configuration |
108 | 108 | //$this->boxes[$reg[1]][0] = "(ExternalRSSInformations)"; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | $sql = array(); |
117 | 117 | |
118 | - return $this->_init($sql,$options); |
|
118 | + return $this->_init($sql, $options); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | * @param string $options Options when enabling module ('', 'noboxes') |
127 | 127 | * @return int 1 if OK, 0 if KO |
128 | 128 | */ |
129 | - function remove($options='') |
|
129 | + function remove($options = '') |
|
130 | 130 | { |
131 | 131 | $sql = array(); |
132 | 132 | |
133 | 133 | // Delete old declarations of RSS box |
134 | 134 | $this->boxes[0]['file'] = "box_external_rss.php"; |
135 | 135 | |
136 | - return $this->_remove($sql,$options); |
|
136 | + return $this->_remove($sql, $options); |
|
137 | 137 | } |
138 | 138 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \ingroup socialnetworks |
24 | 24 | * \brief Description and activation file for module SocialNetworks |
25 | 25 | */ |
26 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
26 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Class to describe a SocialNetworks module |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function __construct($db) |
40 | 40 | { |
41 | - global $langs,$conf; |
|
41 | + global $langs, $conf; |
|
42 | 42 | |
43 | 43 | $this->db = $db; |
44 | 44 | $this->numero = 3400; |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | // Module position in the family on 2 digits ('01', '10', '20', ...) |
50 | 50 | $this->module_position = '20'; |
51 | 51 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
52 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
52 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
53 | 53 | $this->description = "Enable Social Networks fields into third parties and addresses (skype, twitter, facebook, ...)"; |
54 | 54 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
55 | 55 | $this->version = 'dolibarr'; |
56 | 56 | // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) |
57 | 57 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
58 | 58 | // Name of image file used for this module. |
59 | - $this->picto='generic'; |
|
59 | + $this->picto = 'generic'; |
|
60 | 60 | |
61 | 61 | // Data directories to create when module is enabled |
62 | 62 | $this->dirs = array(); |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | $this->config_page_url = array("socialnetworks.php"); |
66 | 66 | |
67 | 67 | // Dependencies |
68 | - $this->hidden = ! empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module |
|
69 | - $this->depends = array('modSociete'); // List of module class names as string that must be enabled if this module is enabled |
|
70 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
71 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
72 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
68 | + $this->hidden = !empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module |
|
69 | + $this->depends = array('modSociete'); // List of module class names as string that must be enabled if this module is enabled |
|
70 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
71 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
72 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module |
|
73 | 73 | $this->langfiles = array(); |
74 | 74 | |
75 | 75 | // Constants |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param array $param Associative array containing label content and optional parameters |
43 | 43 | * @return void |
44 | 44 | */ |
45 | - function addSticker(&$pdf,$outputlangs,$param) |
|
45 | + function addSticker(&$pdf, $outputlangs, $param) |
|
46 | 46 | { |
47 | 47 | // use this method in future refactoring |
48 | 48 | } |
@@ -63,162 +63,162 @@ discard block |
||
63 | 63 | * @param string $photo Photo (full path to image file used as replacement for key __PHOTOS__ into left, right, header or footer text) |
64 | 64 | * @return void |
65 | 65 | */ |
66 | - function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$idmember=0,$photo='') |
|
66 | + function Add_PDF_card(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $idmember = 0, $photo = '') |
|
67 | 67 | { |
68 | 68 | // phpcs:enable |
69 | - global $db,$mysoc,$conf,$langs; |
|
70 | - global $forceimgscalewidth,$forceimgscaleheight; |
|
69 | + global $db, $mysoc, $conf, $langs; |
|
70 | + global $forceimgscalewidth, $forceimgscaleheight; |
|
71 | 71 | |
72 | - $imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth); // Scale of image for width (1=Full width of sticker) |
|
73 | - $imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth); // Scale of image for height (1=Full height of sticker) |
|
72 | + $imgscalewidth = (empty($forceimgscalewidth) ? 0.3 : $forceimgscalewidth); // Scale of image for width (1=Full width of sticker) |
|
73 | + $imgscaleheight = (empty($forceimgscalewidth) ? 0.5 : $forceimgscalewidth); // Scale of image for height (1=Full height of sticker) |
|
74 | 74 | |
75 | 75 | // We are in a new page, then we must add a page |
76 | - if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) { |
|
76 | + if (($this->_COUNTX == 0) && ($this->_COUNTY == 0) and (!$this->_First == 1)) { |
|
77 | 77 | $pdf->AddPage(); |
78 | 78 | } |
79 | - $this->_First=0; |
|
80 | - $_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space)); |
|
81 | - $_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space)); |
|
79 | + $this->_First = 0; |
|
80 | + $_PosX = $this->_Margin_Left + ($this->_COUNTX * ($this->_Width + $this->_X_Space)); |
|
81 | + $_PosY = $this->_Margin_Top + ($this->_COUNTY * ($this->_Height + $this->_Y_Space)); |
|
82 | 82 | |
83 | 83 | // Define logo |
84 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
85 | - if (! is_readable($logo)) |
|
84 | + $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
85 | + if (!is_readable($logo)) |
|
86 | 86 | { |
87 | - $logo=''; |
|
88 | - if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
|
87 | + $logo = ''; |
|
88 | + if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
|
89 | 89 | { |
90 | - $logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
90 | + $logo = $conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
91 | 91 | } |
92 | - elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
92 | + elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
93 | 93 | { |
94 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
94 | + $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - $member=new Adherent($db); |
|
98 | + $member = new Adherent($db); |
|
99 | 99 | $member->id = $idmember; |
100 | 100 | $member->ref = $idmember; |
101 | 101 | |
102 | 102 | // Define photo |
103 | - $dir=$conf->adherent->dir_output; |
|
104 | - if (! empty($photo)) |
|
103 | + $dir = $conf->adherent->dir_output; |
|
104 | + if (!empty($photo)) |
|
105 | 105 | { |
106 | - $file=get_exdir(0,0,0,0,$member,'member').'photos/'.$photo; |
|
107 | - $photo=$dir.'/'.$file; |
|
108 | - if (! is_readable($photo)) $photo=''; |
|
106 | + $file = get_exdir(0, 0, 0, 0, $member, 'member').'photos/'.$photo; |
|
107 | + $photo = $dir.'/'.$file; |
|
108 | + if (!is_readable($photo)) $photo = ''; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // Define background image |
112 | - $backgroundimage=''; |
|
113 | - if(! empty($conf->global->ADHERENT_CARD_BACKGROUND) && file_exists($conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND)) |
|
112 | + $backgroundimage = ''; |
|
113 | + if (!empty($conf->global->ADHERENT_CARD_BACKGROUND) && file_exists($conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND)) |
|
114 | 114 | { |
115 | - $backgroundimage=$conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND; |
|
115 | + $backgroundimage = $conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | // Print lines |
119 | 119 | if ($this->code == "CARD") |
120 | 120 | { |
121 | - $this->Tformat=$this->_Avery_Labels["CARD"]; |
|
121 | + $this->Tformat = $this->_Avery_Labels["CARD"]; |
|
122 | 122 | //$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25); |
123 | - $this->_Croix($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.1,10); |
|
123 | + $this->_Croix($pdf, $_PosX, $_PosY, $_PosX + $this->_Width, $_PosY + $this->_Height, 0.1, 10); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // Background |
127 | 127 | if ($backgroundimage) |
128 | 128 | { |
129 | - $pdf->image($backgroundimage,$_PosX,$_PosY,$this->_Width,$this->_Height); |
|
129 | + $pdf->image($backgroundimage, $_PosX, $_PosY, $this->_Width, $this->_Height); |
|
130 | 130 | } |
131 | 131 | |
132 | - $xleft=2; $ytop=2; |
|
132 | + $xleft = 2; $ytop = 2; |
|
133 | 133 | |
134 | 134 | // Top |
135 | - if ($header!='') |
|
135 | + if ($header != '') |
|
136 | 136 | { |
137 | 137 | if ($this->code == "CARD") |
138 | 138 | { |
139 | - $pdf->SetDrawColor(128,128,128); |
|
140 | - $pdf->Line($_PosX, $_PosY+$this->_Line_Height+1, $_PosX+$this->_Width, $_PosY+$this->_Line_Height+1); // Only 1 mm and not ytop for top text |
|
141 | - $pdf->SetDrawColor(0,0,0); |
|
139 | + $pdf->SetDrawColor(128, 128, 128); |
|
140 | + $pdf->Line($_PosX, $_PosY + $this->_Line_Height + 1, $_PosX + $this->_Width, $_PosY + $this->_Line_Height + 1); // Only 1 mm and not ytop for top text |
|
141 | + $pdf->SetDrawColor(0, 0, 0); |
|
142 | 142 | } |
143 | - $pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text |
|
144 | - $pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C'); |
|
143 | + $pdf->SetXY($_PosX + $xleft, $_PosY + 1); // Only 1 mm and not ytop for top text |
|
144 | + $pdf->Cell($this->_Width - 2 * $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header), 0, 1, 'C'); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | |
148 | - $ytop+=(empty($header)?0:(1+$this->_Line_Height)); |
|
148 | + $ytop += (empty($header) ? 0 : (1 + $this->_Line_Height)); |
|
149 | 149 | |
150 | 150 | // Define widthtouse and heighttouse |
151 | - $maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight); |
|
152 | - $defaultratio=($maxwidthtouse/$maxheighttouse); |
|
153 | - $widthtouse=$maxwidthtouse; $heighttouse=0; // old value for image |
|
154 | - $tmp=dol_getImageSize($photo, false); |
|
151 | + $maxwidthtouse = round(($this->_Width - 2 * $xleft) * $imgscalewidth); $maxheighttouse = round(($this->_Height - 2 * $ytop) * $imgscaleheight); |
|
152 | + $defaultratio = ($maxwidthtouse / $maxheighttouse); |
|
153 | + $widthtouse = $maxwidthtouse; $heighttouse = 0; // old value for image |
|
154 | + $tmp = dol_getImageSize($photo, false); |
|
155 | 155 | if ($tmp['height']) |
156 | 156 | { |
157 | - $imgratio=$tmp['width']/$tmp['height']; |
|
157 | + $imgratio = $tmp['width'] / $tmp['height']; |
|
158 | 158 | if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } |
159 | 159 | else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); } |
160 | 160 | } |
161 | 161 | //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit; |
162 | 162 | |
163 | 163 | // Center |
164 | - if ($textright=='') // Only a left part |
|
164 | + if ($textright == '') // Only a left part |
|
165 | 165 | { |
166 | 166 | // Output left area |
167 | - if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
168 | - else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
167 | + if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
168 | + else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
169 | 169 | else |
170 | 170 | { |
171 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
172 | - $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
171 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
172 | + $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); |
|
173 | 173 | } |
174 | 174 | } |
175 | - else if ($textleft!='' && $textright!='') // |
|
175 | + else if ($textleft != '' && $textright != '') // |
|
176 | 176 | { |
177 | 177 | if ($textleft == '__LOGO__' || $textleft == '__PHOTO__') |
178 | 178 | { |
179 | - if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
180 | - else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
181 | - $pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop); |
|
182 | - $pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
179 | + if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
180 | + else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
181 | + $pdf->SetXY($_PosX + $xleft + $widthtouse + 1, $_PosY + $ytop); |
|
182 | + $pdf->MultiCell($this->_Width - $xleft - $xleft - $widthtouse - 1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R'); |
|
183 | 183 | } |
184 | 184 | else if ($textright == '__LOGO__' || $textright == '__PHOTO__') |
185 | 185 | { |
186 | - if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
187 | - else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
188 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
189 | - $pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
186 | + if ($textright == '__LOGO__' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
187 | + else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
188 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
189 | + $pdf->MultiCell($this->_Width - $widthtouse - $xleft - $xleft - 1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); |
|
190 | 190 | } |
191 | 191 | else // text on halft left and text on half right |
192 | 192 | { |
193 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
194 | - $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
|
195 | - $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop); |
|
196 | - $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
193 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
194 | + $pdf->MultiCell(round($this->_Width / 2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); |
|
195 | + $pdf->SetXY($_PosX + round($this->_Width / 2), $_PosY + $ytop); |
|
196 | + $pdf->MultiCell(round($this->_Width / 2) - 2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R'); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | else // Only a right part |
200 | 200 | { |
201 | 201 | // Output right area |
202 | - if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
203 | - else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
202 | + if ($textright == '__LOGO__' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
203 | + else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); |
|
204 | 204 | else |
205 | 205 | { |
206 | - $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
|
207 | - $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
|
206 | + $pdf->SetXY($_PosX + $xleft, $_PosY + $ytop); |
|
207 | + $pdf->MultiCell($this->_Width - $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R'); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | 211 | // Bottom |
212 | - if ($footer!='') |
|
212 | + if ($footer != '') |
|
213 | 213 | { |
214 | 214 | if ($this->code == "CARD") |
215 | 215 | { |
216 | - $pdf->SetDrawColor(128,128,128); |
|
217 | - $pdf->Line($_PosX, $_PosY+$this->_Height-$this->_Line_Height-2, $_PosX+$this->_Width, $_PosY+$this->_Height-$this->_Line_Height-2); |
|
218 | - $pdf->SetDrawColor(0,0,0); |
|
216 | + $pdf->SetDrawColor(128, 128, 128); |
|
217 | + $pdf->Line($_PosX, $_PosY + $this->_Height - $this->_Line_Height - 2, $_PosX + $this->_Width, $_PosY + $this->_Height - $this->_Line_Height - 2); |
|
218 | + $pdf->SetDrawColor(0, 0, 0); |
|
219 | 219 | } |
220 | - $pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1); |
|
221 | - $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C'); |
|
220 | + $pdf->SetXY($_PosX, $_PosY + $this->_Height - $this->_Line_Height - 1); |
|
221 | + $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer), 0, 1, 'C'); |
|
222 | 222 | } |
223 | 223 | //print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n"; |
224 | 224 | |
@@ -227,13 +227,13 @@ discard block |
||
227 | 227 | if ($this->_COUNTY == $this->_Y_Number) { |
228 | 228 | // Si on est en bas de page, on remonte le 'curseur' de position |
229 | 229 | $this->_COUNTX++; |
230 | - $this->_COUNTY=0; |
|
230 | + $this->_COUNTY = 0; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | if ($this->_COUNTX == $this->_X_Number) { |
234 | 234 | // Si on est en bout de page, alors on repart sur une nouvelle page |
235 | - $this->_COUNTX=0; |
|
236 | - $this->_COUNTY=0; |
|
235 | + $this->_COUNTX = 0; |
|
236 | + $this->_COUNTY = 0; |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
@@ -248,19 +248,19 @@ discard block |
||
248 | 248 | * @param int $nooutput 1=Generate only file on disk and do not return it on response |
249 | 249 | * @return int 1=OK, 0=KO |
250 | 250 | */ |
251 | - function write_file($object, $outputlangs, $srctemplatepath, $mode='member', $nooutput=0) |
|
251 | + function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = 0) |
|
252 | 252 | { |
253 | 253 | // phpcs:enable |
254 | - global $user,$conf,$langs,$mysoc,$_Avery_Labels; |
|
254 | + global $user, $conf, $langs, $mysoc, $_Avery_Labels; |
|
255 | 255 | |
256 | - $this->code=$srctemplatepath; |
|
256 | + $this->code = $srctemplatepath; |
|
257 | 257 | |
258 | 258 | if (is_object($object)) |
259 | 259 | { |
260 | - if ($object->country == '-') $object->country=''; |
|
260 | + if ($object->country == '-') $object->country = ''; |
|
261 | 261 | |
262 | 262 | // List of values to scan for a replacement |
263 | - $substitutionarray = array ( |
|
263 | + $substitutionarray = array( |
|
264 | 264 | '__ID__'=>$object->rowid, |
265 | 265 | '__LOGIN__'=>$object->login, |
266 | 266 | '__FIRSTNAME__'=>$object->firstname, |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | '__COUNTRY__'=>$object->country, |
274 | 274 | '__COUNTRY_CODE__'=>$object->country_code, |
275 | 275 | '__EMAIL__'=>$object->email, |
276 | - '__BIRTH__'=>dol_print_date($object->birth,'day'), |
|
276 | + '__BIRTH__'=>dol_print_date($object->birth, 'day'), |
|
277 | 277 | '__TYPE__'=>$object->type, |
278 | 278 | '__YEAR__'=>$year, |
279 | 279 | '__MONTH__'=>$month, |
@@ -284,17 +284,17 @@ discard block |
||
284 | 284 | complete_substitutions_array($substitutionarray, $langs); |
285 | 285 | |
286 | 286 | // For business cards |
287 | - $textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); |
|
288 | - $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); |
|
289 | - $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); |
|
290 | - $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); |
|
287 | + $textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); |
|
288 | + $textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); |
|
289 | + $textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); |
|
290 | + $textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); |
|
291 | 291 | |
292 | 292 | $nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY']; |
293 | - if ($nb <= 0) $nb=1; // Protection to avoid empty page |
|
293 | + if ($nb <= 0) $nb = 1; // Protection to avoid empty page |
|
294 | 294 | |
295 | - for($j=0;$j<$nb;$j++) |
|
295 | + for ($j = 0; $j < $nb; $j++) |
|
296 | 296 | { |
297 | - $arrayofmembers[]=array( |
|
297 | + $arrayofmembers[] = array( |
|
298 | 298 | 'textleft'=>$textleft, |
299 | 299 | 'textheader'=>$textheader, |
300 | 300 | 'textfooter'=>$textfooter, |
@@ -314,32 +314,32 @@ discard block |
||
314 | 314 | //var_dump($arrayofrecords);exit; |
315 | 315 | |
316 | 316 | $this->Tformat = $_Avery_Labels[$this->code]; |
317 | - if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; } |
|
317 | + if (empty($this->Tformat)) { dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; } |
|
318 | 318 | $this->type = 'pdf'; |
319 | 319 | // standard format or custom |
320 | - if ($this->Tformat['paper-size']!='custom') { |
|
320 | + if ($this->Tformat['paper-size'] != 'custom') { |
|
321 | 321 | $this->format = $this->Tformat['paper-size']; |
322 | 322 | } else { |
323 | 323 | //custom |
324 | - $resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']); |
|
324 | + $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']); |
|
325 | 325 | $this->format = $resolution; |
326 | 326 | } |
327 | 327 | |
328 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
328 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
329 | 329 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
330 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
330 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
331 | 331 | |
332 | 332 | // Load traductions files requiredby by page |
333 | 333 | $outputlangs->loadLangs(array("main", "dict", "companies", "admin", "members")); |
334 | 334 | |
335 | 335 | if (empty($mode) || $mode == 'member') |
336 | 336 | { |
337 | - $title=$outputlangs->transnoentities('MembersCards'); |
|
338 | - $keywords=$outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name); |
|
337 | + $title = $outputlangs->transnoentities('MembersCards'); |
|
338 | + $keywords = $outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name); |
|
339 | 339 | } |
340 | 340 | else |
341 | 341 | { |
342 | - dol_print_error('','Bad value for $mode'); |
|
342 | + dol_print_error('', 'Bad value for $mode'); |
|
343 | 343 | return -1; |
344 | 344 | } |
345 | 345 | |
@@ -359,16 +359,16 @@ discard block |
||
359 | 359 | |
360 | 360 | //var_dump($file);exit; |
361 | 361 | |
362 | - if (! file_exists($dir)) |
|
362 | + if (!file_exists($dir)) |
|
363 | 363 | { |
364 | 364 | if (dol_mkdir($dir) < 0) |
365 | 365 | { |
366 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
366 | + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); |
|
367 | 367 | return 0; |
368 | 368 | } |
369 | 369 | } |
370 | 370 | |
371 | - $pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']); |
|
371 | + $pdf = pdf_getInstance($this->format, $this->Tformat['metric'], $this->Tformat['orientation']); |
|
372 | 372 | |
373 | 373 | if (class_exists('TCPDF')) |
374 | 374 | { |
@@ -382,17 +382,17 @@ discard block |
||
382 | 382 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
383 | 383 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
384 | 384 | $pdf->SetKeyWords($keywords); |
385 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
385 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
386 | 386 | |
387 | - $pdf->SetMargins(0,0); |
|
387 | + $pdf->SetMargins(0, 0); |
|
388 | 388 | $pdf->SetAutoPageBreak(false); |
389 | 389 | |
390 | 390 | $this->_Metric_Doc = $this->Tformat['metric']; |
391 | 391 | // Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie |
392 | - $posX=1; |
|
393 | - $posY=1; |
|
394 | - if ($posX > 0) $posX--; else $posX=0; |
|
395 | - if ($posY > 0) $posY--; else $posY=0; |
|
392 | + $posX = 1; |
|
393 | + $posY = 1; |
|
394 | + if ($posX > 0) $posX--; else $posX = 0; |
|
395 | + if ($posY > 0) $posY--; else $posY = 0; |
|
396 | 396 | $this->_COUNTX = $posX; |
397 | 397 | $this->_COUNTY = $posY; |
398 | 398 | $this->_Set_Format($pdf, $this->Tformat); |
@@ -403,10 +403,10 @@ discard block |
||
403 | 403 | |
404 | 404 | |
405 | 405 | // Add each record |
406 | - foreach($arrayofrecords as $val) |
|
406 | + foreach ($arrayofrecords as $val) |
|
407 | 407 | { |
408 | 408 | // imprime le texte specifique sur la carte |
409 | - $this->Add_PDF_card($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['id'],$val['photo']); |
|
409 | + $this->Add_PDF_card($pdf, $val['textleft'], $val['textheader'], $val['textfooter'], $langs, $val['textright'], $val['id'], $val['photo']); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | //$pdf->SetXY(10, 295); |
@@ -414,9 +414,9 @@ discard block |
||
414 | 414 | |
415 | 415 | |
416 | 416 | // Output to file |
417 | - $pdf->Output($file,'F'); |
|
417 | + $pdf->Output($file, 'F'); |
|
418 | 418 | |
419 | - if (! empty($conf->global->MAIN_UMASK)) |
|
419 | + if (!empty($conf->global->MAIN_UMASK)) |
|
420 | 420 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
421 | 421 | |
422 | 422 | |
@@ -427,9 +427,9 @@ discard block |
||
427 | 427 | { |
428 | 428 | clearstatcache(); |
429 | 429 | |
430 | - $attachment=true; |
|
431 | - if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; |
|
432 | - $type=dol_mimetype($filename); |
|
430 | + $attachment = true; |
|
431 | + if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false; |
|
432 | + $type = dol_mimetype($filename); |
|
433 | 433 | |
434 | 434 | //if ($encoding) header('Content-Encoding: '.$encoding); |
435 | 435 | if ($type) header('Content-Type: '.$type); |
@@ -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 | |
43 | 43 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -48,16 +48,16 @@ discard block |
||
48 | 48 | * @param integer $maxfilenamelength Max length of value to show |
49 | 49 | * @return array List of templates |
50 | 50 | */ |
51 | - function liste_modeles($db,$maxfilenamelength=0) |
|
51 | + function liste_modeles($db, $maxfilenamelength = 0) |
|
52 | 52 | { |
53 | 53 | // phpcs:enable |
54 | 54 | global $conf; |
55 | 55 | |
56 | - $type='member'; |
|
57 | - $liste=array(); |
|
56 | + $type = 'member'; |
|
57 | + $liste = array(); |
|
58 | 58 | |
59 | 59 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
60 | - $liste=getListOfModels($db,$type,$maxfilenamelength); |
|
60 | + $liste = getListOfModels($db, $type, $maxfilenamelength); |
|
61 | 61 | |
62 | 62 | return $liste; |
63 | 63 | } |
@@ -76,27 +76,27 @@ discard block |
||
76 | 76 | * @param string $template pdf generenate document class to use default 'standard' |
77 | 77 | * @return int <0 if KO, >0 if OK |
78 | 78 | */ |
79 | -function members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $outputdir='', $template='standard') |
|
79 | +function members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $outputdir = '', $template = 'standard') |
|
80 | 80 | { |
81 | 81 | // phpcs:enable |
82 | - global $conf,$langs; |
|
82 | + global $conf, $langs; |
|
83 | 83 | $langs->load("members"); |
84 | 84 | |
85 | - $error=0; |
|
85 | + $error = 0; |
|
86 | 86 | |
87 | 87 | // Increase limit for PDF build |
88 | - $err=error_reporting(); |
|
88 | + $err = error_reporting(); |
|
89 | 89 | error_reporting(0); |
90 | 90 | @set_time_limit(120); |
91 | 91 | error_reporting($err); |
92 | 92 | |
93 | - $code=''; |
|
94 | - $srctemplatepath=''; |
|
93 | + $code = ''; |
|
94 | + $srctemplatepath = ''; |
|
95 | 95 | |
96 | 96 | // Positionne le modele sur le nom du modele a utiliser |
97 | - if (! dol_strlen($modele)) |
|
97 | + if (!dol_strlen($modele)) |
|
98 | 98 | { |
99 | - if (! empty($conf->global->ADHERENT_CARDS_ADDON_PDF)) |
|
99 | + if (!empty($conf->global->ADHERENT_CARDS_ADDON_PDF)) |
|
100 | 100 | { |
101 | 101 | $code = $conf->global->ADHERENT_CARDS_ADDON_PDF; |
102 | 102 | } |
@@ -105,33 +105,33 @@ discard block |
||
105 | 105 | $code = $modele; |
106 | 106 | } |
107 | 107 | } |
108 | - else $code=$modele; |
|
108 | + else $code = $modele; |
|
109 | 109 | |
110 | 110 | // If selected modele is a filename template (then $modele="modelname:filename") |
111 | - $tmp=explode(':',$template,2); |
|
112 | - if (! empty($tmp[1])) |
|
111 | + $tmp = explode(':', $template, 2); |
|
112 | + if (!empty($tmp[1])) |
|
113 | 113 | { |
114 | - $template=$tmp[0]; |
|
115 | - $srctemplatepath=$tmp[1]; |
|
114 | + $template = $tmp[0]; |
|
115 | + $srctemplatepath = $tmp[1]; |
|
116 | 116 | } |
117 | - else $srctemplatepath=$code; |
|
117 | + else $srctemplatepath = $code; |
|
118 | 118 | |
119 | 119 | // Search template files |
120 | - $file=''; $classname=''; $filefound=0; |
|
121 | - $dirmodels=array('/'); |
|
122 | - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); |
|
123 | - foreach($dirmodels as $reldir) |
|
120 | + $file = ''; $classname = ''; $filefound = 0; |
|
121 | + $dirmodels = array('/'); |
|
122 | + if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); |
|
123 | + foreach ($dirmodels as $reldir) |
|
124 | 124 | { |
125 | - foreach(array('doc','pdf') as $prefix) |
|
125 | + foreach (array('doc', 'pdf') as $prefix) |
|
126 | 126 | { |
127 | 127 | $file = $prefix."_".$template.".class.php"; |
128 | 128 | |
129 | 129 | // On verifie l'emplacement du modele |
130 | - $file=dol_buildpath($reldir."core/modules/member/doc/".$file,0); |
|
130 | + $file = dol_buildpath($reldir."core/modules/member/doc/".$file, 0); |
|
131 | 131 | if (file_exists($file)) |
132 | 132 | { |
133 | - $filefound=1; |
|
134 | - $classname=$prefix.'_'.$template; |
|
133 | + $filefound = 1; |
|
134 | + $classname = $prefix.'_'.$template; |
|
135 | 135 | break; |
136 | 136 | } |
137 | 137 | } |
@@ -148,23 +148,23 @@ discard block |
||
148 | 148 | |
149 | 149 | // We save charset_output to restore it because write_file can change it if needed for |
150 | 150 | // output format that does not support UTF8. |
151 | - $sav_charset_output=$outputlangs->charset_output; |
|
151 | + $sav_charset_output = $outputlangs->charset_output; |
|
152 | 152 | if ($obj->write_file($arrayofmembers, $outputlangs, $srctemplatepath) > 0) |
153 | 153 | { |
154 | - $outputlangs->charset_output=$sav_charset_output; |
|
154 | + $outputlangs->charset_output = $sav_charset_output; |
|
155 | 155 | return 1; |
156 | 156 | } |
157 | 157 | else |
158 | 158 | { |
159 | - $outputlangs->charset_output=$sav_charset_output; |
|
160 | - dol_print_error($db,"members_card_pdf_create Error: ".$obj->error); |
|
159 | + $outputlangs->charset_output = $sav_charset_output; |
|
160 | + dol_print_error($db, "members_card_pdf_create Error: ".$obj->error); |
|
161 | 161 | return -1; |
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | 165 | else |
166 | 166 | { |
167 | - dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file)); |
|
167 | + dol_print_error('', $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file)); |
|
168 | 168 | return -1; |
169 | 169 | } |
170 | 170 | } |