@@ -76,7 +76,10 @@ discard block |
||
76 | 76 | |
77 | 77 | // Recupere emmetteur |
78 | 78 | $this->emetteur=$mysoc; |
79 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
79 | + if (! $this->emetteur->country_code) { |
|
80 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
81 | + } |
|
82 | + // By default if not defined |
|
80 | 83 | |
81 | 84 | // Defini position des colonnes |
82 | 85 | $this->posxref=$this->marge_gauche+1; |
@@ -85,9 +88,11 @@ discard block |
||
85 | 88 | //$this->posxprogress=$this->marge_gauche+140; |
86 | 89 | $this->posxdatestart=$this->marge_gauche+152; |
87 | 90 | $this->posxdateend=$this->marge_gauche+170; |
88 | - if ($this->page_largeur < 210) // To work with US executive format |
|
91 | + if ($this->page_largeur < 210) { |
|
92 | + // To work with US executive format |
|
89 | 93 | { |
90 | 94 | $this->posxref-=20; |
95 | + } |
|
91 | 96 | $this->posxlabel-=20; |
92 | 97 | $this->posxtimespent-=20; |
93 | 98 | //$this->posxprogress-=20; |
@@ -110,9 +115,13 @@ discard block |
||
110 | 115 | // phpcs:enable |
111 | 116 | global $conf, $hookmanager, $langs, $user; |
112 | 117 | |
113 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
118 | + if (! is_object($outputlangs)) { |
|
119 | + $outputlangs=$langs; |
|
120 | + } |
|
114 | 121 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
115 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
122 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
123 | + $outputlangs->charset_output='ISO-8859-1'; |
|
124 | + } |
|
116 | 125 | |
117 | 126 | // Load traductions files requiredby by page |
118 | 127 | $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); |
@@ -123,7 +132,9 @@ discard block |
||
123 | 132 | |
124 | 133 | $objectref = dol_sanitizeFileName($object->ref); |
125 | 134 | $dir = $conf->projet->dir_output; |
126 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
135 | + if (! preg_match('/specimen/i',$objectref)) { |
|
136 | + $dir.= "/" . $objectref; |
|
137 | + } |
|
127 | 138 | $file = $dir . "/" . $objectref . ".pdf"; |
128 | 139 | |
129 | 140 | if (! file_exists($dir)) |
@@ -174,10 +185,12 @@ discard block |
||
174 | 185 | $task = new Task($this->db); |
175 | 186 | $tasksarray = $task->getTasksArray(0,0,$object->id); |
176 | 187 | |
177 | - if (! $object->id > 0) // Special case when used with object = specimen, we may return all lines |
|
188 | + if (! $object->id > 0) { |
|
189 | + // Special case when used with object = specimen, we may return all lines |
|
178 | 190 | { |
179 | 191 | $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray))); |
180 | 192 | } |
193 | + } |
|
181 | 194 | |
182 | 195 | $object->lines=$tasksarray; |
183 | 196 | $nblignes=count($object->lines); |
@@ -191,13 +204,17 @@ discard block |
||
191 | 204 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
192 | 205 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
193 | 206 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project")); |
194 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
207 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
208 | + $pdf->SetCompression(false); |
|
209 | + } |
|
195 | 210 | |
196 | 211 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
197 | 212 | |
198 | 213 | // New page |
199 | 214 | $pdf->AddPage(); |
200 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
215 | + if (! empty($tplidx)) { |
|
216 | + $pdf->useTemplate($tplidx); |
|
217 | + } |
|
201 | 218 | $pagenb++; |
202 | 219 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
203 | 220 | $pdf->SetFont('','', $default_font_size - 1); |
@@ -230,8 +247,7 @@ discard block |
||
230 | 247 | |
231 | 248 | $tab_height = $tab_height - $height_note; |
232 | 249 | $tab_top = $nexY+6; |
233 | - } |
|
234 | - else |
|
250 | + } else |
|
235 | 251 | { |
236 | 252 | $height_note=0; |
237 | 253 | } |
@@ -267,9 +283,11 @@ discard block |
||
267 | 283 | $pdf->SetXY($this->posxlabel, $curY); |
268 | 284 | $pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); |
269 | 285 | $pageposafter=$pdf->getPage(); |
270 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
286 | + if ($pageposafter > $pageposbefore) { |
|
287 | + // There is a pagebreak |
|
271 | 288 | { |
272 | 289 | $pdf->rollbackTransaction(true); |
290 | + } |
|
273 | 291 | $pageposafter=$pageposbefore; |
274 | 292 | //print $pageposafter.'-'.$pageposbefore;exit; |
275 | 293 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
@@ -279,17 +297,22 @@ discard block |
||
279 | 297 | $pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); |
280 | 298 | $pageposafter=$pdf->getPage(); |
281 | 299 | $posyafter=$pdf->GetY(); |
282 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
300 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
301 | + // There is no space left for total+free text |
|
283 | 302 | { |
284 | 303 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
285 | 304 | { |
286 | 305 | $pdf->AddPage('','',true); |
287 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
288 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
306 | + } |
|
307 | + if (! empty($tplidx)) { |
|
308 | + $pdf->useTemplate($tplidx); |
|
309 | + } |
|
310 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
311 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
312 | + } |
|
289 | 313 | $pdf->setPage($pageposafter+1); |
290 | 314 | } |
291 | - } |
|
292 | - else |
|
315 | + } else |
|
293 | 316 | { |
294 | 317 | // We found a page break |
295 | 318 | $showpricebeforepagebreak=0; |
@@ -301,8 +324,12 @@ discard block |
||
301 | 324 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
302 | 325 | |
303 | 326 | $pdf->AddPage('','',true); |
304 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
305 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
327 | + if (! empty($tplidx)) { |
|
328 | + $pdf->useTemplate($tplidx); |
|
329 | + } |
|
330 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
331 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
332 | + } |
|
306 | 333 | $pdf->setPage($pageposafter+1); |
307 | 334 | $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
308 | 335 | $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
@@ -320,8 +347,7 @@ discard block |
||
320 | 347 | } |
321 | 348 | } |
322 | 349 | //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak); |
323 | - } |
|
324 | - else // No pagebreak |
|
350 | + } else // No pagebreak |
|
325 | 351 | { |
326 | 352 | $pdf->commitTransaction(); |
327 | 353 | } |
@@ -375,8 +401,7 @@ discard block |
||
375 | 401 | if ($pagenb == 1) |
376 | 402 | { |
377 | 403 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
378 | - } |
|
379 | - else |
|
404 | + } else |
|
380 | 405 | { |
381 | 406 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
382 | 407 | } |
@@ -384,37 +409,45 @@ discard block |
||
384 | 409 | $pagenb++; |
385 | 410 | $pdf->setPage($pagenb); |
386 | 411 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
387 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
412 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
413 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
414 | + } |
|
388 | 415 | } |
389 | 416 | if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
390 | 417 | { |
391 | 418 | if ($pagenb == 1) |
392 | 419 | { |
393 | 420 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
394 | - } |
|
395 | - else |
|
421 | + } else |
|
396 | 422 | { |
397 | 423 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
398 | 424 | } |
399 | 425 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
400 | 426 | // New page |
401 | 427 | $pdf->AddPage(); |
402 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
428 | + if (! empty($tplidx)) { |
|
429 | + $pdf->useTemplate($tplidx); |
|
430 | + } |
|
403 | 431 | $pagenb++; |
404 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
432 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
433 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
434 | + } |
|
405 | 435 | } |
406 | 436 | } |
407 | 437 | |
408 | 438 | // Show square |
409 | - if ($pagenb == 1) |
|
410 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
411 | - else |
|
412 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
439 | + if ($pagenb == 1) { |
|
440 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
441 | + } else { |
|
442 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
443 | + } |
|
413 | 444 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
414 | 445 | |
415 | 446 | // Pied de page |
416 | 447 | $this->_pagefoot($pdf, $object, $outputlangs); |
417 | - if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
448 | + if (method_exists($pdf, 'AliasNbPages')) { |
|
449 | + $pdf->AliasNbPages(); |
|
450 | + } |
|
418 | 451 | |
419 | 452 | $pdf->Close(); |
420 | 453 | |
@@ -426,20 +459,19 @@ discard block |
||
426 | 459 | global $action; |
427 | 460 | $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
428 | 461 | |
429 | - if (! empty($conf->global->MAIN_UMASK)) |
|
430 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
462 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
463 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
464 | + } |
|
431 | 465 | |
432 | 466 | $this->result = array('fullpath'=>$file); |
433 | 467 | |
434 | 468 | return 1; // Pas d'erreur |
435 | - } |
|
436 | - else |
|
469 | + } else |
|
437 | 470 | { |
438 | 471 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
439 | 472 | return 0; |
440 | 473 | } |
441 | - } |
|
442 | - else |
|
474 | + } else |
|
443 | 475 | { |
444 | 476 | $this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR"); |
445 | 477 | return 0; |
@@ -530,16 +562,16 @@ discard block |
||
530 | 562 | { |
531 | 563 | $height=pdf_getHeightForLogo($logo); |
532 | 564 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
533 | - } |
|
534 | - else |
|
565 | + } else |
|
535 | 566 | { |
536 | 567 | $pdf->SetTextColor(200,0,0); |
537 | 568 | $pdf->SetFont('','B', $default_font_size - 2); |
538 | 569 | $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
539 | 570 | $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
540 | 571 | } |
572 | + } else { |
|
573 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
541 | 574 | } |
542 | - else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
543 | 575 | |
544 | 576 | $pdf->SetFont('','B', $default_font_size + 3); |
545 | 577 | $pdf->SetXY($posx,$posy); |
@@ -37,16 +37,36 @@ discard block |
||
37 | 37 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
38 | 38 | require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; |
39 | 39 | require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
40 | -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
41 | -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
42 | -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; |
|
43 | -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
44 | -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
|
45 | -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; |
|
46 | -if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
|
47 | -if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; |
|
48 | -if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; |
|
49 | -if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
|
40 | +if (! empty($conf->propal->enabled)) { |
|
41 | + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
42 | +} |
|
43 | +if (! empty($conf->facture->enabled)) { |
|
44 | + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
45 | +} |
|
46 | +if (! empty($conf->facture->enabled)) { |
|
47 | + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; |
|
48 | +} |
|
49 | +if (! empty($conf->commande->enabled)) { |
|
50 | + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
51 | +} |
|
52 | +if (! empty($conf->fournisseur->enabled)) { |
|
53 | + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
|
54 | +} |
|
55 | +if (! empty($conf->fournisseur->enabled)) { |
|
56 | + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; |
|
57 | +} |
|
58 | +if (! empty($conf->contrat->enabled)) { |
|
59 | + require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
|
60 | +} |
|
61 | +if (! empty($conf->ficheinter->enabled)) { |
|
62 | + require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; |
|
63 | +} |
|
64 | +if (! empty($conf->deplacement->enabled)) { |
|
65 | + require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; |
|
66 | +} |
|
67 | +if (! empty($conf->agenda->enabled)) { |
|
68 | + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
|
69 | +} |
|
50 | 70 | |
51 | 71 | |
52 | 72 | /** |
@@ -113,7 +133,10 @@ discard block |
||
113 | 133 | |
114 | 134 | // Recupere emetteur |
115 | 135 | $this->emetteur=$mysoc; |
116 | - if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'etait pas defini |
|
136 | + if (! $this->emetteur->pays_code) { |
|
137 | + $this->emetteur->pays_code=substr($langs->defaultlang,-2); |
|
138 | + } |
|
139 | + // Par defaut, si n'etait pas defini |
|
117 | 140 | } |
118 | 141 | |
119 | 142 | |
@@ -407,11 +430,14 @@ discard block |
||
407 | 430 | if (! $tmpdir) { |
408 | 431 | unset($listofdir[$key]); continue; |
409 | 432 | } |
410 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
411 | - else |
|
433 | + if (! is_dir($tmpdir)) { |
|
434 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
435 | + } else |
|
412 | 436 | { |
413 | 437 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
414 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
438 | + if (count($tmpfiles)) { |
|
439 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
440 | + } |
|
415 | 441 | } |
416 | 442 | } |
417 | 443 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -491,7 +517,9 @@ discard block |
||
491 | 517 | $hookmanager->initHooks(array('odtgeneration')); |
492 | 518 | global $action; |
493 | 519 | |
494 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
520 | + if (! is_object($outputlangs)) { |
|
521 | + $outputlangs=$langs; |
|
522 | + } |
|
495 | 523 | $sav_charset_output=$outputlangs->charset_output; |
496 | 524 | $outputlangs->charset_output='UTF-8'; |
497 | 525 | |
@@ -515,7 +543,9 @@ discard block |
||
515 | 543 | |
516 | 544 | $dir = $conf->projet->dir_output; |
517 | 545 | $objectref = dol_sanitizeFileName($object->ref); |
518 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
546 | + if (! preg_match('/specimen/i',$objectref)) { |
|
547 | + $dir.= "/" . $objectref; |
|
548 | + } |
|
519 | 549 | $file = $dir . "/" . $objectref . ".odt"; |
520 | 550 | |
521 | 551 | if (! file_exists($dir)) |
@@ -541,10 +571,11 @@ discard block |
||
541 | 571 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
542 | 572 | { |
543 | 573 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
544 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
574 | + if ($format == '1') { |
|
575 | + $format='%Y%m%d%H%M%S'; |
|
576 | + } |
|
545 | 577 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
546 | - } |
|
547 | - else |
|
578 | + } else |
|
548 | 579 | { |
549 | 580 | $filename=$newfiletmp.'.'.$newfileformat; |
550 | 581 | } |
@@ -619,7 +650,9 @@ discard block |
||
619 | 650 | $array_other=$this->get_substitutionarray_other($outputlangs); |
620 | 651 | // retrieve contact information for use in object as contact_xxx tags |
621 | 652 | $array_project_contact = array(); |
622 | - if ($usecontact && is_object($contactobject)) $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
653 | + if ($usecontact && is_object($contactobject)) { |
|
654 | + $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
655 | + } |
|
623 | 656 | |
624 | 657 | $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact); |
625 | 658 | complete_substitutions_array($tmparray, $outputlangs, $object); |
@@ -631,17 +664,18 @@ discard block |
||
631 | 664 | foreach($tmparray as $key=>$value) |
632 | 665 | { |
633 | 666 | try { |
634 | - if (preg_match('/logo$/',$key)) // Image |
|
667 | + if (preg_match('/logo$/',$key)) { |
|
668 | + // Image |
|
635 | 669 | { |
636 | 670 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
637 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
638 | - } |
|
639 | - else // Text |
|
671 | + } else { |
|
672 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
673 | + } |
|
674 | + } else // Text |
|
640 | 675 | { |
641 | 676 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
642 | 677 | } |
643 | - } |
|
644 | - catch (OdfException $e) |
|
678 | + } catch (OdfException $e) |
|
645 | 679 | { |
646 | 680 | dol_syslog($e->getMessage(), LOG_INFO); |
647 | 681 | } |
@@ -656,7 +690,9 @@ discard block |
||
656 | 690 | |
657 | 691 | // Security check |
658 | 692 | $socid=0; |
659 | - if (!empty($object->fk_soc)) $socid = $object->fk_soc; |
|
693 | + if (!empty($object->fk_soc)) { |
|
694 | + $socid = $object->fk_soc; |
|
695 | + } |
|
660 | 696 | |
661 | 697 | $tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0); |
662 | 698 | |
@@ -670,12 +706,10 @@ discard block |
||
670 | 706 | try |
671 | 707 | { |
672 | 708 | $listlines->setVars($key, $val, true, 'UTF-8'); |
673 | - } |
|
674 | - catch(OdfException $e) |
|
709 | + } catch(OdfException $e) |
|
675 | 710 | { |
676 | 711 | dol_syslog($e->getMessage(), LOG_INFO); |
677 | - } |
|
678 | - catch(SegmentException $e) |
|
712 | + } catch(SegmentException $e) |
|
679 | 713 | { |
680 | 714 | dol_syslog($e->getMessage(), LOG_INFO); |
681 | 715 | } |
@@ -721,12 +755,10 @@ discard block |
||
721 | 755 | try |
722 | 756 | { |
723 | 757 | $listlinestaskres->setVars($key, $val, true, 'UTF-8'); |
724 | - } |
|
725 | - catch(OdfException $e) |
|
758 | + } catch(OdfException $e) |
|
726 | 759 | { |
727 | 760 | dol_syslog($e->getMessage(), LOG_INFO); |
728 | - } |
|
729 | - catch(SegmentException $e) |
|
761 | + } catch(SegmentException $e) |
|
730 | 762 | { |
731 | 763 | dol_syslog($e->getMessage(), LOG_INFO); |
732 | 764 | } |
@@ -771,12 +803,10 @@ discard block |
||
771 | 803 | try |
772 | 804 | { |
773 | 805 | $listlinestasktime->setVars($key, $val, true, 'UTF-8'); |
774 | - } |
|
775 | - catch(OdfException $e) |
|
806 | + } catch(OdfException $e) |
|
776 | 807 | { |
777 | 808 | dol_syslog($e->getMessage(), LOG_INFO); |
778 | - } |
|
779 | - catch(SegmentException $e) |
|
809 | + } catch(SegmentException $e) |
|
780 | 810 | { |
781 | 811 | dol_syslog($e->getMessage(), LOG_INFO); |
782 | 812 | } |
@@ -811,12 +841,10 @@ discard block |
||
811 | 841 | try |
812 | 842 | { |
813 | 843 | $listlinestasktime->setVars($key, $val, true, 'UTF-8'); |
814 | - } |
|
815 | - catch(OdfException $e) |
|
844 | + } catch(OdfException $e) |
|
816 | 845 | { |
817 | 846 | dol_syslog($e->getMessage(), LOG_INFO); |
818 | - } |
|
819 | - catch(SegmentException $e) |
|
847 | + } catch(SegmentException $e) |
|
820 | 848 | { |
821 | 849 | dol_syslog($e->getMessage(), LOG_INFO); |
822 | 850 | } |
@@ -844,12 +872,10 @@ discard block |
||
844 | 872 | try |
845 | 873 | { |
846 | 874 | $listtasksfiles->setVars($key, $val, true, 'UTF-8'); |
847 | - } |
|
848 | - catch (OdfException $e) |
|
875 | + } catch (OdfException $e) |
|
849 | 876 | { |
850 | 877 | dol_syslog($e->getMessage(), LOG_INFO); |
851 | - } |
|
852 | - catch (SegmentException $e) |
|
878 | + } catch (SegmentException $e) |
|
853 | 879 | { |
854 | 880 | dol_syslog($e->getMessage(), LOG_INFO); |
855 | 881 | } |
@@ -859,8 +885,7 @@ discard block |
||
859 | 885 | $listlines->merge(); |
860 | 886 | } |
861 | 887 | $odfHandler->mergeSegment($listlines); |
862 | - } |
|
863 | - catch(OdfException $e) |
|
888 | + } catch(OdfException $e) |
|
864 | 889 | { |
865 | 890 | $ExceptionTrace=$e->getTrace(); |
866 | 891 | // no segment defined on ODT is not an error |
@@ -890,12 +915,10 @@ discard block |
||
890 | 915 | try |
891 | 916 | { |
892 | 917 | $listlines->setVars($key, $val, true, 'UTF-8'); |
893 | - } |
|
894 | - catch(OdfException $e) |
|
918 | + } catch(OdfException $e) |
|
895 | 919 | { |
896 | 920 | dol_syslog($e->getMessage(), LOG_INFO); |
897 | - } |
|
898 | - catch(SegmentException $e) |
|
921 | + } catch(SegmentException $e) |
|
899 | 922 | { |
900 | 923 | dol_syslog($e->getMessage(), LOG_INFO); |
901 | 924 | } |
@@ -903,8 +926,7 @@ discard block |
||
903 | 926 | $listlines->merge(); |
904 | 927 | } |
905 | 928 | $odfHandler->mergeSegment($listlines); |
906 | - } |
|
907 | - catch(OdfException $e) |
|
929 | + } catch(OdfException $e) |
|
908 | 930 | { |
909 | 931 | $this->error=$e->getMessage(); |
910 | 932 | dol_syslog($this->error, LOG_WARNING); |
@@ -949,12 +971,10 @@ discard block |
||
949 | 971 | try |
950 | 972 | { |
951 | 973 | $listlines->setVars($key, $val, true, 'UTF-8'); |
952 | - } |
|
953 | - catch(OdfException $e) |
|
974 | + } catch(OdfException $e) |
|
954 | 975 | { |
955 | 976 | dol_syslog($e->getMessage(), LOG_INFO); |
956 | - } |
|
957 | - catch(SegmentException $e) |
|
977 | + } catch(SegmentException $e) |
|
958 | 978 | { |
959 | 979 | dol_syslog($e->getMessage(), LOG_INFO); |
960 | 980 | } |
@@ -962,8 +982,7 @@ discard block |
||
962 | 982 | $listlines->merge(); |
963 | 983 | } |
964 | 984 | $odfHandler->mergeSegment($listlines); |
965 | - } |
|
966 | - catch(OdfException $e) |
|
985 | + } catch(OdfException $e) |
|
967 | 986 | { |
968 | 987 | $this->error=$e->getMessage(); |
969 | 988 | dol_syslog($this->error, LOG_WARNING); |
@@ -1116,8 +1135,12 @@ discard block |
||
1116 | 1135 | |
1117 | 1136 | //Date object |
1118 | 1137 | $dateref=$element->date; |
1119 | - if (empty($dateref)) $dateref=$element->datep; |
|
1120 | - if (empty($dateref)) $dateref=$element->date_contrat; |
|
1138 | + if (empty($dateref)) { |
|
1139 | + $dateref=$element->datep; |
|
1140 | + } |
|
1141 | + if (empty($dateref)) { |
|
1142 | + $dateref=$element->date_contrat; |
|
1143 | + } |
|
1121 | 1144 | $ref_array['date']=$dateref; |
1122 | 1145 | |
1123 | 1146 | //Soc object |
@@ -1150,12 +1173,10 @@ discard block |
||
1150 | 1173 | try |
1151 | 1174 | { |
1152 | 1175 | $listlines->setVars($key, $val, true, 'UTF-8'); |
1153 | - } |
|
1154 | - catch(OdfException $e) |
|
1176 | + } catch(OdfException $e) |
|
1155 | 1177 | { |
1156 | 1178 | dol_syslog($e->getMessage(), LOG_INFO); |
1157 | - } |
|
1158 | - catch(SegmentException $e) |
|
1179 | + } catch(SegmentException $e) |
|
1159 | 1180 | { |
1160 | 1181 | dol_syslog($e->getMessage(), LOG_INFO); |
1161 | 1182 | } |
@@ -1208,16 +1229,16 @@ discard block |
||
1208 | 1229 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
1209 | 1230 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
1210 | 1231 | |
1211 | - if (! empty($conf->global->MAIN_UMASK)) |
|
1212 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
1232 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
1233 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
1234 | + } |
|
1213 | 1235 | |
1214 | 1236 | $odfHandler=null; // Destroy object |
1215 | 1237 | |
1216 | 1238 | $this->result = array('fullpath'=>$file); |
1217 | 1239 | |
1218 | 1240 | return 1; // Success |
1219 | - } |
|
1220 | - else |
|
1241 | + } else |
|
1221 | 1242 | { |
1222 | 1243 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
1223 | 1244 | return -1; |
@@ -105,8 +105,7 @@ discard block |
||
105 | 105 | if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
106 | 106 | { |
107 | 107 | return true; |
108 | - } |
|
109 | - else |
|
108 | + } else |
|
110 | 109 | { |
111 | 110 | $langs->load("errors"); |
112 | 111 | $this->error=$langs->trans('ErrorNumRefModel',$max); |
@@ -137,10 +136,12 @@ discard block |
||
137 | 136 | if ($resql) |
138 | 137 | { |
139 | 138 | $obj = $db->fetch_object($resql); |
140 | - if ($obj) $max = intval($obj->max); |
|
141 | - else $max=0; |
|
142 | - } |
|
143 | - else |
|
139 | + if ($obj) { |
|
140 | + $max = intval($obj->max); |
|
141 | + } else { |
|
142 | + $max=0; |
|
143 | + } |
|
144 | + } else |
|
144 | 145 | { |
145 | 146 | dol_syslog("mod_project_simple::getNextValue", LOG_DEBUG); |
146 | 147 | return -1; |
@@ -151,8 +152,13 @@ discard block |
||
151 | 152 | //$yymm = strftime("%y%m",time()); |
152 | 153 | $yymm = strftime("%y%m",$date); |
153 | 154 | |
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); |
|
155 | + if ($max >= (pow(10, 4) - 1)) { |
|
156 | + $num=$max+1; |
|
157 | + } |
|
158 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
159 | + else { |
|
160 | + $num = sprintf("%04s",$max+1); |
|
161 | + } |
|
156 | 162 | |
157 | 163 | dol_syslog("mod_project_simple::getNextValue return ".$this->prefix.$yymm."-".$num); |
158 | 164 | return $this->prefix.$yymm."-".$num; |
@@ -38,16 +38,36 @@ 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)) { |
|
42 | + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
43 | +} |
|
44 | +if (! empty($conf->facture->enabled)) { |
|
45 | + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
46 | +} |
|
47 | +if (! empty($conf->facture->enabled)) { |
|
48 | + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; |
|
49 | +} |
|
50 | +if (! empty($conf->commande->enabled)) { |
|
51 | + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
52 | +} |
|
53 | +if (! empty($conf->fournisseur->enabled)) { |
|
54 | + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
|
55 | +} |
|
56 | +if (! empty($conf->fournisseur->enabled)) { |
|
57 | + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; |
|
58 | +} |
|
59 | +if (! empty($conf->contrat->enabled)) { |
|
60 | + require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
|
61 | +} |
|
62 | +if (! empty($conf->ficheinter->enabled)) { |
|
63 | + require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; |
|
64 | +} |
|
65 | +if (! empty($conf->deplacement->enabled)) { |
|
66 | + require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; |
|
67 | +} |
|
68 | +if (! empty($conf->agenda->enabled)) { |
|
69 | + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
|
70 | +} |
|
51 | 71 | |
52 | 72 | |
53 | 73 | /** |
@@ -114,7 +134,10 @@ discard block |
||
114 | 134 | |
115 | 135 | // Recupere emetteur |
116 | 136 | $this->emetteur=$mysoc; |
117 | - if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'etait pas defini |
|
137 | + if (! $this->emetteur->pays_code) { |
|
138 | + $this->emetteur->pays_code=substr($langs->defaultlang,-2); |
|
139 | + } |
|
140 | + // Par defaut, si n'etait pas defini |
|
118 | 141 | } |
119 | 142 | |
120 | 143 | |
@@ -367,11 +390,14 @@ discard block |
||
367 | 390 | if (! $tmpdir) { |
368 | 391 | unset($listofdir[$key]); continue; |
369 | 392 | } |
370 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
371 | - else |
|
393 | + if (! is_dir($tmpdir)) { |
|
394 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
395 | + } else |
|
372 | 396 | { |
373 | 397 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
374 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
398 | + if (count($tmpfiles)) { |
|
399 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
400 | + } |
|
375 | 401 | } |
376 | 402 | } |
377 | 403 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -442,7 +468,9 @@ discard block |
||
442 | 468 | return -1; |
443 | 469 | } |
444 | 470 | |
445 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
471 | + if (! is_object($outputlangs)) { |
|
472 | + $outputlangs=$langs; |
|
473 | + } |
|
446 | 474 | $sav_charset_output=$outputlangs->charset_output; |
447 | 475 | $outputlangs->charset_output='UTF-8'; |
448 | 476 | |
@@ -469,7 +497,9 @@ discard block |
||
469 | 497 | |
470 | 498 | $dir = $conf->projet->dir_output. "/" . $project->ref. "/"; |
471 | 499 | $objectref = dol_sanitizeFileName($object->ref); |
472 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
500 | + if (! preg_match('/specimen/i',$objectref)) { |
|
501 | + $dir.= "/" . $objectref; |
|
502 | + } |
|
473 | 503 | $file = $dir . "/" . $objectref . ".odt"; |
474 | 504 | |
475 | 505 | if (! file_exists($dir)) |
@@ -524,8 +554,7 @@ discard block |
||
524 | 554 | 'DELIMITER_RIGHT' => '}' |
525 | 555 | ) |
526 | 556 | ); |
527 | - } |
|
528 | - catch(Exception $e) |
|
557 | + } catch(Exception $e) |
|
529 | 558 | { |
530 | 559 | $this->error=$e->getMessage(); |
531 | 560 | return -1; |
@@ -552,12 +581,14 @@ discard block |
||
552 | 581 | foreach($tmparray as $key=>$value) |
553 | 582 | { |
554 | 583 | try { |
555 | - if (preg_match('/logo$/',$key)) // Image |
|
584 | + if (preg_match('/logo$/',$key)) { |
|
585 | + // Image |
|
556 | 586 | { |
557 | 587 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
558 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
559 | - } |
|
560 | - else // Text |
|
588 | + } else { |
|
589 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
590 | + } |
|
591 | + } else // Text |
|
561 | 592 | { |
562 | 593 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
563 | 594 | } |
@@ -571,7 +602,9 @@ discard block |
||
571 | 602 | { |
572 | 603 | // Security check |
573 | 604 | $socid=0; |
574 | - if (!empty($project->fk_soc)) $socid = $project->fk_soc; |
|
605 | + if (!empty($project->fk_soc)) { |
|
606 | + $socid = $project->fk_soc; |
|
607 | + } |
|
575 | 608 | |
576 | 609 | $tmparray=$this->get_substitutionarray_tasks($object,$outputlangs); |
577 | 610 | complete_substitutions_array($tmparray, $outputlangs, $object); |
@@ -624,8 +657,7 @@ discard block |
||
624 | 657 | $listlinestaskres->setVars($key, $val, true, 'UTF-8'); |
625 | 658 | } catch (OdfException $e) { |
626 | 659 | dol_syslog($e->getMessage(), LOG_INFO); |
627 | - } |
|
628 | - catch (SegmentException $e) { |
|
660 | + } catch (SegmentException $e) { |
|
629 | 661 | dol_syslog($e->getMessage(), LOG_INFO); |
630 | 662 | } |
631 | 663 | } |
@@ -669,12 +701,10 @@ discard block |
||
669 | 701 | try |
670 | 702 | { |
671 | 703 | $listlinestasktime->setVars($key, $val, true, 'UTF-8'); |
672 | - } |
|
673 | - catch(OdfException $e) |
|
704 | + } catch(OdfException $e) |
|
674 | 705 | { |
675 | 706 | dol_syslog($e->getMessage(), LOG_INFO); |
676 | - } |
|
677 | - catch(SegmentException $e) |
|
707 | + } catch(SegmentException $e) |
|
678 | 708 | { |
679 | 709 | dol_syslog($e->getMessage(), LOG_INFO); |
680 | 710 | } |
@@ -704,12 +734,10 @@ discard block |
||
704 | 734 | try |
705 | 735 | { |
706 | 736 | $listtasksfiles->setVars($key, $val, true, 'UTF-8'); |
707 | - } |
|
708 | - catch(OdfException $e) |
|
737 | + } catch(OdfException $e) |
|
709 | 738 | { |
710 | 739 | dol_syslog($e->getMessage(), LOG_INFO); |
711 | - } |
|
712 | - catch(SegmentException $e) |
|
740 | + } catch(SegmentException $e) |
|
713 | 741 | { |
714 | 742 | dol_syslog($e->getMessage(), LOG_INFO); |
715 | 743 | } |
@@ -719,8 +747,7 @@ discard block |
||
719 | 747 | //$listlines->merge(); |
720 | 748 | |
721 | 749 | $odfHandler->mergeSegment($listtasksfiles); |
722 | - } |
|
723 | - catch(OdfException $e) |
|
750 | + } catch(OdfException $e) |
|
724 | 751 | { |
725 | 752 | $this->error=$e->getMessage(); |
726 | 753 | dol_syslog($this->error, LOG_WARNING); |
@@ -748,12 +775,10 @@ discard block |
||
748 | 775 | try |
749 | 776 | { |
750 | 777 | $listlines->setVars($key, $val, true, 'UTF-8'); |
751 | - } |
|
752 | - catch(OdfException $e) |
|
778 | + } catch(OdfException $e) |
|
753 | 779 | { |
754 | 780 | dol_syslog($e->getMessage(), LOG_INFO); |
755 | - } |
|
756 | - catch(SegmentException $e) |
|
781 | + } catch(SegmentException $e) |
|
757 | 782 | { |
758 | 783 | dol_syslog($e->getMessage(), LOG_INFO); |
759 | 784 | } |
@@ -761,8 +786,7 @@ discard block |
||
761 | 786 | $listlines->merge(); |
762 | 787 | } |
763 | 788 | $odfHandler->mergeSegment($listlines); |
764 | - } |
|
765 | - catch(OdfException $e) |
|
789 | + } catch(OdfException $e) |
|
766 | 790 | { |
767 | 791 | $this->error=$e->getMessage(); |
768 | 792 | dol_syslog($this->error, LOG_WARNING); |
@@ -808,12 +832,10 @@ discard block |
||
808 | 832 | try |
809 | 833 | { |
810 | 834 | $listlines->setVars($key, $val, true, 'UTF-8'); |
811 | - } |
|
812 | - catch(OdfException $e) |
|
835 | + } catch(OdfException $e) |
|
813 | 836 | { |
814 | 837 | dol_syslog($e->getMessage(), LOG_INFO); |
815 | - } |
|
816 | - catch(SegmentException $e) |
|
838 | + } catch(SegmentException $e) |
|
817 | 839 | { |
818 | 840 | dol_syslog($e->getMessage(), LOG_INFO); |
819 | 841 | } |
@@ -821,8 +843,7 @@ discard block |
||
821 | 843 | $listlines->merge(); |
822 | 844 | } |
823 | 845 | $odfHandler->mergeSegment($listlines); |
824 | - } |
|
825 | - catch(OdfException $e) |
|
846 | + } catch(OdfException $e) |
|
826 | 847 | { |
827 | 848 | $this->error=$e->getMessage(); |
828 | 849 | dol_syslog($this->error, LOG_WARNING); |
@@ -845,8 +866,7 @@ discard block |
||
845 | 866 | dol_syslog($e->getMessage(), LOG_INFO); |
846 | 867 | return -1; |
847 | 868 | } |
848 | - } |
|
849 | - else { |
|
869 | + } else { |
|
850 | 870 | try { |
851 | 871 | $odfHandler->saveToDisk($file); |
852 | 872 | } catch (Exception $e) { |
@@ -858,16 +878,16 @@ discard block |
||
858 | 878 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
859 | 879 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
860 | 880 | |
861 | - if (! empty($conf->global->MAIN_UMASK)) |
|
862 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
881 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
882 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
883 | + } |
|
863 | 884 | |
864 | 885 | $odfHandler=null; // Destroy object |
865 | 886 | |
866 | 887 | $this->result = array('fullpath'=>$file); |
867 | 888 | |
868 | 889 | return 1; // Success |
869 | - } |
|
870 | - else |
|
890 | + } else |
|
871 | 891 | { |
872 | 892 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
873 | 893 | return -1; |
@@ -106,8 +106,7 @@ discard block |
||
106 | 106 | if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
107 | 107 | { |
108 | 108 | return true; |
109 | - } |
|
110 | - else |
|
109 | + } else |
|
111 | 110 | { |
112 | 111 | $langs->load("errors"); |
113 | 112 | $this->error=$langs->trans('ErrorNumRefModel',$max); |
@@ -137,10 +136,12 @@ discard block |
||
137 | 136 | if ($resql) |
138 | 137 | { |
139 | 138 | $obj = $db->fetch_object($resql); |
140 | - if ($obj) $max = intval($obj->max); |
|
141 | - else $max=0; |
|
142 | - } |
|
143 | - else |
|
139 | + if ($obj) { |
|
140 | + $max = intval($obj->max); |
|
141 | + } else { |
|
142 | + $max=0; |
|
143 | + } |
|
144 | + } else |
|
144 | 145 | { |
145 | 146 | dol_syslog("mod_task_simple::getNextValue", LOG_DEBUG); |
146 | 147 | return -1; |
@@ -151,8 +152,13 @@ discard block |
||
151 | 152 | //$yymm = strftime("%y%m",time()); |
152 | 153 | $yymm = strftime("%y%m",$date); |
153 | 154 | |
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); |
|
155 | + if ($max >= (pow(10, 4) - 1)) { |
|
156 | + $num=$max+1; |
|
157 | + } |
|
158 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
159 | + else { |
|
160 | + $num = sprintf("%04s",$max+1); |
|
161 | + } |
|
156 | 162 | |
157 | 163 | dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num); |
158 | 164 | return $this->prefix.$yymm."-".$num; |
@@ -141,9 +141,15 @@ |
||
141 | 141 | global $langs; |
142 | 142 | $langs->load("admin"); |
143 | 143 | |
144 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
145 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
146 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
144 | + if ($this->version == 'development') { |
|
145 | + return $langs->trans("VersionDevelopment"); |
|
146 | + } |
|
147 | + if ($this->version == 'experimental') { |
|
148 | + return $langs->trans("VersionExperimental"); |
|
149 | + } |
|
150 | + if ($this->version == 'dolibarr') { |
|
151 | + return DOL_VERSION; |
|
152 | + } |
|
147 | 153 | return $langs->trans("NotAvailable"); |
148 | 154 | } |
149 | 155 | } |
@@ -88,8 +88,7 @@ discard block |
||
88 | 88 | if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
89 | 89 | { |
90 | 90 | $logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
91 | - } |
|
92 | - elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
91 | + } elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
93 | 92 | { |
94 | 93 | $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
95 | 94 | } |
@@ -105,7 +104,9 @@ discard block |
||
105 | 104 | { |
106 | 105 | $file=get_exdir(0,0,0,0,$member,'member').'photos/'.$photo; |
107 | 106 | $photo=$dir.'/'.$file; |
108 | - if (! is_readable($photo)) $photo=''; |
|
107 | + if (! is_readable($photo)) { |
|
108 | + $photo=''; |
|
109 | + } |
|
109 | 110 | } |
110 | 111 | |
111 | 112 | // Define background image |
@@ -155,53 +156,58 @@ discard block |
||
155 | 156 | if ($tmp['height']) |
156 | 157 | { |
157 | 158 | $imgratio=$tmp['width']/$tmp['height']; |
158 | - if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } |
|
159 | - else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); } |
|
159 | + if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } 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=='') { |
|
165 | + // Only a left part |
|
165 | 166 | { |
166 | 167 | // Output left area |
167 | 168 | 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 | - else |
|
169 | + } else if ($textleft == '__PHOTO__' && $photo) { |
|
170 | + $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
171 | + } else |
|
170 | 172 | { |
171 | 173 | $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
172 | 174 | $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
173 | 175 | } |
174 | - } |
|
175 | - else if ($textleft!='' && $textright!='') // |
|
176 | + } else if ($textleft!='' && $textright!='') { |
|
177 | + // |
|
176 | 178 | { |
177 | 179 | if ($textleft == '__LOGO__' || $textleft == '__PHOTO__') |
178 | 180 | { |
179 | 181 | 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); |
|
182 | + } else if ($textleft == '__PHOTO__' && $photo) { |
|
183 | + $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
184 | + } |
|
181 | 185 | $pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop); |
182 | 186 | $pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
183 | - } |
|
184 | - else if ($textright == '__LOGO__' || $textright == '__PHOTO__') |
|
187 | + } else if ($textright == '__LOGO__' || $textright == '__PHOTO__') |
|
185 | 188 | { |
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); |
|
189 | + if ($textright == '__LOGO__' && $logo) { |
|
190 | + $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
191 | + } else if ($textright == '__PHOTO__' && $photo) { |
|
192 | + $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
193 | + } |
|
188 | 194 | $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
189 | 195 | $pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
190 | - } |
|
191 | - else // text on halft left and text on half right |
|
196 | + } else // text on halft left and text on half right |
|
192 | 197 | { |
193 | 198 | $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
194 | 199 | $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); |
195 | 200 | $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop); |
196 | 201 | $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
197 | 202 | } |
198 | - } |
|
199 | - else // Only a right part |
|
203 | + } else // Only a right part |
|
200 | 204 | { |
201 | 205 | // 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); |
|
204 | - else |
|
206 | + if ($textright == '__LOGO__' && $logo) { |
|
207 | + $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
208 | + } else if ($textright == '__PHOTO__' && $photo) { |
|
209 | + $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); |
|
210 | + } else |
|
205 | 211 | { |
206 | 212 | $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); |
207 | 213 | $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); |
@@ -257,7 +263,9 @@ discard block |
||
257 | 263 | |
258 | 264 | if (is_object($object)) |
259 | 265 | { |
260 | - if ($object->country == '-') $object->country=''; |
|
266 | + if ($object->country == '-') { |
|
267 | + $object->country=''; |
|
268 | + } |
|
261 | 269 | |
262 | 270 | // List of values to scan for a replacement |
263 | 271 | $substitutionarray = array ( |
@@ -290,7 +298,10 @@ discard block |
||
290 | 298 | $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); |
291 | 299 | |
292 | 300 | $nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY']; |
293 | - if ($nb <= 0) $nb=1; // Protection to avoid empty page |
|
301 | + if ($nb <= 0) { |
|
302 | + $nb=1; |
|
303 | + } |
|
304 | + // Protection to avoid empty page |
|
294 | 305 | |
295 | 306 | for($j=0;$j<$nb;$j++) |
296 | 307 | { |
@@ -305,8 +316,7 @@ discard block |
||
305 | 316 | } |
306 | 317 | |
307 | 318 | $arrayofrecords = $arrayofmembers; |
308 | - } |
|
309 | - else |
|
319 | + } else |
|
310 | 320 | { |
311 | 321 | $arrayofrecords = $object; |
312 | 322 | } |
@@ -325,9 +335,13 @@ discard block |
||
325 | 335 | $this->format = $resolution; |
326 | 336 | } |
327 | 337 | |
328 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
338 | + if (! is_object($outputlangs)) { |
|
339 | + $outputlangs=$langs; |
|
340 | + } |
|
329 | 341 | // 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'; |
|
342 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
343 | + $outputlangs->charset_output='ISO-8859-1'; |
|
344 | + } |
|
331 | 345 | |
332 | 346 | // Load traductions files requiredby by page |
333 | 347 | $outputlangs->loadLangs(array("main", "dict", "companies", "admin", "members")); |
@@ -336,8 +350,7 @@ discard block |
||
336 | 350 | { |
337 | 351 | $title=$outputlangs->transnoentities('MembersCards'); |
338 | 352 | $keywords=$outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name); |
339 | - } |
|
340 | - else |
|
353 | + } else |
|
341 | 354 | { |
342 | 355 | dol_print_error('','Bad value for $mode'); |
343 | 356 | return -1; |
@@ -349,8 +362,7 @@ discard block |
||
349 | 362 | $outputdir = $conf->adherent->dir_output; |
350 | 363 | $dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member'); |
351 | 364 | $file = $dir.'/'.$filename; |
352 | - } |
|
353 | - else |
|
365 | + } else |
|
354 | 366 | { |
355 | 367 | $outputdir = $conf->adherent->dir_temp; |
356 | 368 | $dir = $outputdir; |
@@ -382,7 +394,9 @@ discard block |
||
382 | 394 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
383 | 395 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
384 | 396 | $pdf->SetKeyWords($keywords); |
385 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
397 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
398 | + $pdf->SetCompression(false); |
|
399 | + } |
|
386 | 400 | |
387 | 401 | $pdf->SetMargins(0,0); |
388 | 402 | $pdf->SetAutoPageBreak(false); |
@@ -391,8 +405,16 @@ discard block |
||
391 | 405 | // Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie |
392 | 406 | $posX=1; |
393 | 407 | $posY=1; |
394 | - if ($posX > 0) $posX--; else $posX=0; |
|
395 | - if ($posY > 0) $posY--; else $posY=0; |
|
408 | + if ($posX > 0) { |
|
409 | + $posX--; |
|
410 | + } else { |
|
411 | + $posX=0; |
|
412 | + } |
|
413 | + if ($posY > 0) { |
|
414 | + $posY--; |
|
415 | + } else { |
|
416 | + $posY=0; |
|
417 | + } |
|
396 | 418 | $this->_COUNTX = $posX; |
397 | 419 | $this->_COUNTY = $posY; |
398 | 420 | $this->_Set_Format($pdf, $this->Tformat); |
@@ -416,8 +438,9 @@ discard block |
||
416 | 438 | // Output to file |
417 | 439 | $pdf->Output($file,'F'); |
418 | 440 | |
419 | - if (! empty($conf->global->MAIN_UMASK)) |
|
420 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
441 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
442 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
443 | + } |
|
421 | 444 | |
422 | 445 | |
423 | 446 | $this->result = array('fullpath'=>$file); |
@@ -428,13 +451,20 @@ discard block |
||
428 | 451 | clearstatcache(); |
429 | 452 | |
430 | 453 | $attachment=true; |
431 | - if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; |
|
454 | + if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) { |
|
455 | + $attachment=false; |
|
456 | + } |
|
432 | 457 | $type=dol_mimetype($filename); |
433 | 458 | |
434 | 459 | //if ($encoding) header('Content-Encoding: '.$encoding); |
435 | - if ($type) header('Content-Type: '.$type); |
|
436 | - if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
437 | - else header('Content-Disposition: inline; filename="'.$filename.'"'); |
|
460 | + if ($type) { |
|
461 | + header('Content-Type: '.$type); |
|
462 | + } |
|
463 | + if ($attachment) { |
|
464 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
465 | + } else { |
|
466 | + header('Content-Disposition: inline; filename="'.$filename.'"'); |
|
467 | + } |
|
438 | 468 | |
439 | 469 | // Ajout directives pour resoudre bug IE |
440 | 470 | header('Cache-Control: Public, must-revalidate'); |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | if (! empty($conf->global->ADHERENT_CARDS_ADDON_PDF)) |
100 | 100 | { |
101 | 101 | $code = $conf->global->ADHERENT_CARDS_ADDON_PDF; |
102 | - } |
|
103 | - else |
|
102 | + } else |
|
104 | 103 | { |
105 | 104 | $code = $modele; |
106 | 105 | } |
106 | + } else { |
|
107 | + $code=$modele; |
|
107 | 108 | } |
108 | - else $code=$modele; |
|
109 | 109 | |
110 | 110 | // If selected modele is a filename template (then $modele="modelname:filename") |
111 | 111 | $tmp=explode(':',$template,2); |
@@ -113,13 +113,16 @@ discard block |
||
113 | 113 | { |
114 | 114 | $template=$tmp[0]; |
115 | 115 | $srctemplatepath=$tmp[1]; |
116 | + } else { |
|
117 | + $srctemplatepath=$code; |
|
116 | 118 | } |
117 | - else $srctemplatepath=$code; |
|
118 | 119 | |
119 | 120 | // Search template files |
120 | 121 | $file=''; $classname=''; $filefound=0; |
121 | 122 | $dirmodels=array('/'); |
122 | - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); |
|
123 | + if (is_array($conf->modules_parts['models'])) { |
|
124 | + $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); |
|
125 | + } |
|
123 | 126 | foreach($dirmodels as $reldir) |
124 | 127 | { |
125 | 128 | foreach(array('doc','pdf') as $prefix) |
@@ -135,7 +138,9 @@ discard block |
||
135 | 138 | break; |
136 | 139 | } |
137 | 140 | } |
138 | - if ($filefound) break; |
|
141 | + if ($filefound) { |
|
142 | + break; |
|
143 | + } |
|
139 | 144 | } |
140 | 145 | |
141 | 146 | |
@@ -153,16 +158,13 @@ discard block |
||
153 | 158 | { |
154 | 159 | $outputlangs->charset_output=$sav_charset_output; |
155 | 160 | return 1; |
156 | - } |
|
157 | - else |
|
161 | + } else |
|
158 | 162 | { |
159 | 163 | $outputlangs->charset_output=$sav_charset_output; |
160 | 164 | dol_print_error($db,"members_card_pdf_create Error: ".$obj->error); |
161 | 165 | return -1; |
162 | 166 | } |
163 | - } |
|
164 | - |
|
165 | - else |
|
167 | + } else |
|
166 | 168 | { |
167 | 169 | dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file)); |
168 | 170 | return -1; |
@@ -250,7 +250,9 @@ discard block |
||
250 | 250 | 'ed.rowid'=>'LineId','cd.description'=>'Description','ed.qty'=>"Qty",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel', |
251 | 251 | 'p.weight'=>'ProductWeight','p.weight_units'=>'WeightUnits','p.volume'=>'ProductVolume','p.volume_units'=>'VolumeUnits' |
252 | 252 | ); |
253 | - if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r]+=array('sp.rowid'=>'IdContact','sp.lastname'=>'Lastname','sp.firstname'=>'Firstname','sp.note_public'=>'NotePublic'); |
|
253 | + if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) { |
|
254 | + $this->export_fields_array[$r]+=array('sp.rowid'=>'IdContact','sp.lastname'=>'Lastname','sp.firstname'=>'Firstname','sp.note_public'=>'NotePublic'); |
|
255 | + } |
|
254 | 256 | //$this->export_TypeFields_array[$r]=array( |
255 | 257 | // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label', |
256 | 258 | // 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text", |
@@ -272,7 +274,9 @@ discard block |
||
272 | 274 | 'ed.rowid'=>'shipment_line','cd.description'=>'shipment_line','ed.qty'=>"shipment_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product', |
273 | 275 | 'p.weight'=>'product','p.weight_units'=>'product','p.volume'=>'product','p.volume_units'=>'product' |
274 | 276 | ); |
275 | - if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r]+=array('sp.rowid'=>'contact','sp.lastname'=>'contact','sp.firstname'=>'contact','sp.note_public'=>'contact'); |
|
277 | + if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) { |
|
278 | + $this->export_entities_array[$r]+=array('sp.rowid'=>'contact','sp.lastname'=>'contact','sp.firstname'=>'contact','sp.note_public'=>'contact'); |
|
279 | + } |
|
276 | 280 | $this->export_dependencies_array[$r]=array('shipment_line'=>'ed.rowid','product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
277 | 281 | if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) |
278 | 282 | { |
@@ -288,7 +292,9 @@ discard block |
||
288 | 292 | $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'expedition as c'; |
289 | 293 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expedition_extrafields as extra ON c.rowid = extra.fk_object,'; |
290 | 294 | $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s'; |
291 | - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
295 | + if(!$user->rights->societe->client->voir) { |
|
296 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
297 | + } |
|
292 | 298 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; |
293 | 299 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; |
294 | 300 | $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expeditiondet as ed'; |
@@ -303,7 +309,9 @@ discard block |
||
303 | 309 | } |
304 | 310 | $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid'; |
305 | 311 | $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('expedition').')'; |
306 | - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
312 | + if(!$user->rights->societe->client->voir) { |
|
313 | + $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
314 | + } |
|
307 | 315 | } |
308 | 316 | |
309 | 317 |