@@ -138,7 +138,10 @@ discard block |
||
138 | 138 | |
139 | 139 | // Get source company |
140 | 140 | $this->emetteur=$mysoc; |
141 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
141 | + if (! $this->emetteur->country_code) { |
|
142 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
143 | + } |
|
144 | + // By default if not defined |
|
142 | 145 | } |
143 | 146 | |
144 | 147 | |
@@ -161,9 +164,13 @@ discard block |
||
161 | 164 | |
162 | 165 | $object->fetch_thirdparty(); |
163 | 166 | |
164 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
167 | + if (! is_object($outputlangs)) { |
|
168 | + $outputlangs=$langs; |
|
169 | + } |
|
165 | 170 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
166 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
171 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
172 | + $outputlangs->charset_output='ISO-8859-1'; |
|
173 | + } |
|
167 | 174 | |
168 | 175 | // Load traductions files requiredby by page |
169 | 176 | $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); |
@@ -180,20 +187,23 @@ discard block |
||
180 | 187 | //Creation du destinataire |
181 | 188 | $idcontact = $object->$origin->getIdContact('external','SHIPPING'); |
182 | 189 | $this->destinataire = new Contact($this->db); |
183 | - if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]); |
|
190 | + if (! empty($idcontact[0])) { |
|
191 | + $this->destinataire->fetch($idcontact[0]); |
|
192 | + } |
|
184 | 193 | |
185 | 194 | //Creation du livreur |
186 | 195 | $idcontact = $object->$origin->getIdContact('internal','LIVREUR'); |
187 | 196 | $this->livreur = new User($this->db); |
188 | - if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]); |
|
197 | + if (! empty($idcontact[0])) { |
|
198 | + $this->livreur->fetch($idcontact[0]); |
|
199 | + } |
|
189 | 200 | |
190 | 201 | // Definition de $dir et $file |
191 | 202 | if ($object->specimen) |
192 | 203 | { |
193 | 204 | $dir = $conf->expedition->dir_output."/sending"; |
194 | 205 | $file = $dir . "/SPECIMEN.pdf"; |
195 | - } |
|
196 | - else |
|
206 | + } else |
|
197 | 207 | { |
198 | 208 | $expref = dol_sanitizeFileName($object->ref); |
199 | 209 | $dir = $conf->expedition->dir_output . "/sending/" . $expref; |
@@ -229,7 +239,9 @@ discard block |
||
229 | 239 | $heightforinfotot = 0; // Height reserved to output the info and total part |
230 | 240 | $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
231 | 241 | $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
232 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
242 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) { |
|
243 | + $heightforfooter+= 6; |
|
244 | + } |
|
233 | 245 | $pdf->SetAutoPageBreak(1,0); |
234 | 246 | |
235 | 247 | if (class_exists('TCPDF')) |
@@ -249,14 +261,18 @@ discard block |
||
249 | 261 | $pagenb=0; |
250 | 262 | $pdf->SetDrawColor(128,128,128); |
251 | 263 | |
252 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
264 | + if (method_exists($pdf,'AliasNbPages')) { |
|
265 | + $pdf->AliasNbPages(); |
|
266 | + } |
|
253 | 267 | |
254 | 268 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
255 | 269 | $pdf->SetSubject($outputlangs->transnoentities("Shipment")); |
256 | 270 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
257 | 271 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
258 | 272 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment")); |
259 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
273 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
274 | + $pdf->SetCompression(false); |
|
275 | + } |
|
260 | 276 | |
261 | 277 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
262 | 278 | |
@@ -287,8 +303,7 @@ discard block |
||
287 | 303 | |
288 | 304 | $tab_height = $tab_height - $height_note; |
289 | 305 | $tab_top = $nexY+6; |
290 | - } |
|
291 | - else |
|
306 | + } else |
|
292 | 307 | { |
293 | 308 | $height_note=0; |
294 | 309 | } |
@@ -365,8 +380,7 @@ discard block |
||
365 | 380 | if ($pagenb == 1) |
366 | 381 | { |
367 | 382 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
368 | - } |
|
369 | - else |
|
383 | + } else |
|
370 | 384 | { |
371 | 385 | $this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
372 | 386 | } |
@@ -380,8 +394,7 @@ discard block |
||
380 | 394 | if ($pagenb == 1) |
381 | 395 | { |
382 | 396 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
383 | - } |
|
384 | - else |
|
397 | + } else |
|
385 | 398 | { |
386 | 399 | $this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
387 | 400 | } |
@@ -397,8 +410,7 @@ discard block |
||
397 | 410 | { |
398 | 411 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
399 | 412 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
400 | - } |
|
401 | - else |
|
413 | + } else |
|
402 | 414 | { |
403 | 415 | $this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
404 | 416 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
@@ -406,7 +418,9 @@ discard block |
||
406 | 418 | |
407 | 419 | // Pied de page |
408 | 420 | $this->_pagefoot($pdf, $object, $outputlangs); |
409 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
421 | + if (method_exists($pdf,'AliasNbPages')) { |
|
422 | + $pdf->AliasNbPages(); |
|
423 | + } |
|
410 | 424 | |
411 | 425 | $pdf->Close(); |
412 | 426 | |
@@ -423,20 +437,19 @@ discard block |
||
423 | 437 | global $action; |
424 | 438 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
425 | 439 | |
426 | - if (! empty($conf->global->MAIN_UMASK)) |
|
427 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
440 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
441 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
442 | + } |
|
428 | 443 | |
429 | 444 | $this->result = array('fullpath'=>$file); |
430 | 445 | |
431 | 446 | return 1; |
432 | - } |
|
433 | - else |
|
447 | + } else |
|
434 | 448 | { |
435 | 449 | $this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir); |
436 | 450 | return 0; |
437 | 451 | } |
438 | - } |
|
439 | - else |
|
452 | + } else |
|
440 | 453 | { |
441 | 454 | $this->error=$outputlangs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR"); |
442 | 455 | return 0; |
@@ -556,16 +569,14 @@ discard block |
||
556 | 569 | { |
557 | 570 | $height=pdf_getHeightForLogo($logo); |
558 | 571 | $pdf->Image($logo,10, 5, 0, $height); // width=0 (auto) |
559 | - } |
|
560 | - else |
|
572 | + } else |
|
561 | 573 | { |
562 | 574 | $pdf->SetTextColor(200,0,0); |
563 | 575 | $pdf->SetFont('','B', $default_font_size - 2); |
564 | 576 | $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
565 | 577 | $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
566 | 578 | } |
567 | - } |
|
568 | - else |
|
579 | + } else |
|
569 | 580 | { |
570 | 581 | $text=$this->emetteur->name; |
571 | 582 | $pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -665,8 +676,7 @@ discard block |
||
665 | 676 | $pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L'); |
666 | 677 | } |
667 | 678 | } |
668 | - } |
|
669 | - else |
|
679 | + } else |
|
670 | 680 | { |
671 | 681 | $pdf->MultiCell(50, 8, $outputlangs->transnoentities("Deliverer")." ".$outputlangs->convToOutputCharset($this->livreur->getFullName($outputlangs)), '', 'L'); |
672 | 682 | } |
@@ -99,7 +99,10 @@ discard block |
||
99 | 99 | |
100 | 100 | // Recupere emetteur |
101 | 101 | $this->emetteur=$mysoc; |
102 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
102 | + if (! $this->emetteur->country_code) { |
|
103 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
104 | + } |
|
105 | + // By default if not defined |
|
103 | 106 | } |
104 | 107 | |
105 | 108 | |
@@ -137,11 +140,14 @@ discard block |
||
137 | 140 | if (! $tmpdir) { |
138 | 141 | unset($listofdir[$key]); continue; |
139 | 142 | } |
140 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
141 | - else |
|
143 | + if (! is_dir($tmpdir)) { |
|
144 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
145 | + } else |
|
142 | 146 | { |
143 | 147 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
144 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
148 | + if (count($tmpfiles)) { |
|
149 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
150 | + } |
|
145 | 151 | } |
146 | 152 | } |
147 | 153 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -223,7 +229,9 @@ discard block |
||
223 | 229 | $hookmanager->initHooks(array('odtgeneration')); |
224 | 230 | global $action; |
225 | 231 | |
226 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
232 | + if (! is_object($outputlangs)) { |
|
233 | + $outputlangs=$langs; |
|
234 | + } |
|
227 | 235 | $sav_charset_output=$outputlangs->charset_output; |
228 | 236 | $outputlangs->charset_output='UTF-8'; |
229 | 237 | |
@@ -247,7 +255,9 @@ discard block |
||
247 | 255 | |
248 | 256 | $dir = $conf->expedition->dir_output."/sending"; |
249 | 257 | $objectref = dol_sanitizeFileName($object->ref); |
250 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
258 | + if (! preg_match('/specimen/i',$objectref)) { |
|
259 | + $dir.= "/" . $objectref; |
|
260 | + } |
|
251 | 261 | $file = $dir . "/" . $objectref . ".odt"; |
252 | 262 | |
253 | 263 | if (! file_exists($dir)) |
@@ -273,10 +283,11 @@ discard block |
||
273 | 283 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
274 | 284 | { |
275 | 285 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
276 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
286 | + if ($format == '1') { |
|
287 | + $format='%Y%m%d%H%M%S'; |
|
288 | + } |
|
277 | 289 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
278 | - } |
|
279 | - else |
|
290 | + } else |
|
280 | 291 | { |
281 | 292 | $filename=$newfiletmp.'.'.$newfileformat; |
282 | 293 | } |
@@ -302,9 +313,9 @@ discard block |
||
302 | 313 | $contactobject = null; |
303 | 314 | if (! empty($usecontact)) { |
304 | 315 | // On peut utiliser le nom de la societe du contact |
305 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) |
|
306 | - $socobject = $object->contact; |
|
307 | - else { |
|
316 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
317 | + $socobject = $object->contact; |
|
318 | + } else { |
|
308 | 319 | $socobject = $object->thirdparty; |
309 | 320 | // if we have a SHIIPPING contact and we dont use it as recipient we store the contact object for later use |
310 | 321 | $contactobject = $object->contact; |
@@ -346,8 +357,7 @@ discard block |
||
346 | 357 | 'DELIMITER_RIGHT' => '}' |
347 | 358 | ) |
348 | 359 | ); |
349 | - } |
|
350 | - catch(Exception $e) |
|
360 | + } catch(Exception $e) |
|
351 | 361 | { |
352 | 362 | $this->error=$e->getMessage(); |
353 | 363 | dol_syslog($e->getMessage(), LOG_INFO); |
@@ -363,8 +373,7 @@ discard block |
||
363 | 373 | // Make substitutions into odt of freetext |
364 | 374 | try { |
365 | 375 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
366 | - } |
|
367 | - catch(OdfException $e) |
|
376 | + } catch(OdfException $e) |
|
368 | 377 | { |
369 | 378 | dol_syslog($e->getMessage(), LOG_INFO); |
370 | 379 | } |
@@ -375,18 +384,19 @@ discard block |
||
375 | 384 | foreach($tmparray as $key=>$value) |
376 | 385 | { |
377 | 386 | try { |
378 | - if (preg_match('/logo$/',$key)) // Image |
|
387 | + if (preg_match('/logo$/',$key)) { |
|
388 | + // Image |
|
379 | 389 | { |
380 | 390 | //var_dump($value);exit; |
381 | 391 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
382 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
383 | - } |
|
384 | - else // Text |
|
392 | + } else { |
|
393 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
394 | + } |
|
395 | + } else // Text |
|
385 | 396 | { |
386 | 397 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
387 | 398 | } |
388 | - } |
|
389 | - catch (OdfException $e) |
|
399 | + } catch (OdfException $e) |
|
390 | 400 | { |
391 | 401 | dol_syslog($e->getMessage(), LOG_INFO); |
392 | 402 | } |
@@ -397,18 +407,19 @@ discard block |
||
397 | 407 | foreach($tmparray as $key=>$value) |
398 | 408 | { |
399 | 409 | try { |
400 | - if (preg_match('/logo$/',$key)) // Image |
|
410 | + if (preg_match('/logo$/',$key)) { |
|
411 | + // Image |
|
401 | 412 | { |
402 | 413 | //var_dump($value);exit; |
403 | 414 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
404 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
405 | - } |
|
406 | - else // Text |
|
415 | + } else { |
|
416 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
417 | + } |
|
418 | + } else // Text |
|
407 | 419 | { |
408 | 420 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
409 | 421 | } |
410 | - } |
|
411 | - catch (OdfException $e) |
|
422 | + } catch (OdfException $e) |
|
412 | 423 | { |
413 | 424 | dol_syslog($e->getMessage(), LOG_INFO); |
414 | 425 | } |
@@ -418,17 +429,18 @@ discard block |
||
418 | 429 | foreach($tmparray as $key=>$value) |
419 | 430 | { |
420 | 431 | try { |
421 | - if (preg_match('/logo$/',$key)) // Image |
|
432 | + if (preg_match('/logo$/',$key)) { |
|
433 | + // Image |
|
422 | 434 | { |
423 | 435 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
424 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
425 | - } |
|
426 | - else // Text |
|
436 | + } else { |
|
437 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
438 | + } |
|
439 | + } else // Text |
|
427 | 440 | { |
428 | 441 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
429 | 442 | } |
430 | - } |
|
431 | - catch (OdfException $e) |
|
443 | + } catch (OdfException $e) |
|
432 | 444 | { |
433 | 445 | dol_syslog($e->getMessage(), LOG_INFO); |
434 | 446 | } |
@@ -439,17 +451,18 @@ discard block |
||
439 | 451 | foreach($tmparray as $key=>$value) |
440 | 452 | { |
441 | 453 | try { |
442 | - if (preg_match('/logo$/',$key)) // Image |
|
454 | + if (preg_match('/logo$/',$key)) { |
|
455 | + // Image |
|
443 | 456 | { |
444 | 457 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
445 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
446 | - } |
|
447 | - else // Text |
|
458 | + } else { |
|
459 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
460 | + } |
|
461 | + } else // Text |
|
448 | 462 | { |
449 | 463 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
450 | 464 | } |
451 | - } |
|
452 | - catch(OdfException $e) |
|
465 | + } catch(OdfException $e) |
|
453 | 466 | { |
454 | 467 | dol_syslog($e->getMessage(), LOG_INFO); |
455 | 468 | } |
@@ -465,17 +478,18 @@ discard block |
||
465 | 478 | foreach($tmparray as $key=>$value) |
466 | 479 | { |
467 | 480 | try { |
468 | - if (preg_match('/logo$/',$key)) // Image |
|
481 | + if (preg_match('/logo$/',$key)) { |
|
482 | + // Image |
|
469 | 483 | { |
470 | 484 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
471 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
472 | - } |
|
473 | - else // Text |
|
485 | + } else { |
|
486 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
487 | + } |
|
488 | + } else // Text |
|
474 | 489 | { |
475 | 490 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
476 | 491 | } |
477 | - } |
|
478 | - catch(OdfException $e) |
|
492 | + } catch(OdfException $e) |
|
479 | 493 | { |
480 | 494 | dol_syslog($e->getMessage(), LOG_INFO); |
481 | 495 | } |
@@ -486,8 +500,7 @@ discard block |
||
486 | 500 | $foundtagforlines = 1; |
487 | 501 | try { |
488 | 502 | $listlines = $odfHandler->setSegment('lines'); |
489 | - } |
|
490 | - catch(OdfException $e) |
|
503 | + } catch(OdfException $e) |
|
491 | 504 | { |
492 | 505 | // We may arrive here if tags for lines not present into template |
493 | 506 | $foundtagforlines = 0; |
@@ -507,12 +520,10 @@ discard block |
||
507 | 520 | try |
508 | 521 | { |
509 | 522 | $listlines->setVars($key, $val, true, 'UTF-8'); |
510 | - } |
|
511 | - catch(OdfException $e) |
|
523 | + } catch(OdfException $e) |
|
512 | 524 | { |
513 | 525 | dol_syslog($e->getMessage(), LOG_INFO); |
514 | - } |
|
515 | - catch(SegmentException $e) |
|
526 | + } catch(SegmentException $e) |
|
516 | 527 | { |
517 | 528 | dol_syslog($e->getMessage(), LOG_INFO); |
518 | 529 | } |
@@ -521,8 +532,7 @@ discard block |
||
521 | 532 | } |
522 | 533 | $odfHandler->mergeSegment($listlines); |
523 | 534 | } |
524 | - } |
|
525 | - catch (OdfException $e) |
|
535 | + } catch (OdfException $e) |
|
526 | 536 | { |
527 | 537 | $this->error=$e->getMessage(); |
528 | 538 | dol_syslog($this->error, LOG_WARNING); |
@@ -535,8 +545,7 @@ discard block |
||
535 | 545 | { |
536 | 546 | try { |
537 | 547 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
538 | - } |
|
539 | - catch (OdfException $e) |
|
548 | + } catch (OdfException $e) |
|
540 | 549 | { |
541 | 550 | dol_syslog($e->getMessage(), LOG_INFO); |
542 | 551 | } |
@@ -555,8 +564,7 @@ discard block |
||
555 | 564 | dol_syslog($e->getMessage(), LOG_INFO); |
556 | 565 | return -1; |
557 | 566 | } |
558 | - } |
|
559 | - else { |
|
567 | + } else { |
|
560 | 568 | try { |
561 | 569 | $odfHandler->saveToDisk($file); |
562 | 570 | } catch (Exception $e) { |
@@ -568,16 +576,16 @@ discard block |
||
568 | 576 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
569 | 577 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
570 | 578 | |
571 | - if (! empty($conf->global->MAIN_UMASK)) |
|
572 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
579 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
580 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
581 | + } |
|
573 | 582 | |
574 | 583 | $odfHandler=null; // Destroy object |
575 | 584 | |
576 | 585 | $this->result = array('fullpath'=>$file); |
577 | 586 | |
578 | 587 | return 1; // Success |
579 | - } |
|
580 | - else |
|
588 | + } else |
|
581 | 589 | { |
582 | 590 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
583 | 591 | return -1; |
@@ -131,10 +131,12 @@ discard block |
||
131 | 131 | if ($resql) |
132 | 132 | { |
133 | 133 | $obj = $db->fetch_object($resql); |
134 | - if ($obj) $max = intval($obj->max); |
|
135 | - else $max=0; |
|
136 | - } |
|
137 | - else |
|
134 | + if ($obj) { |
|
135 | + $max = intval($obj->max); |
|
136 | + } else { |
|
137 | + $max=0; |
|
138 | + } |
|
139 | + } else |
|
138 | 140 | { |
139 | 141 | dol_syslog("mod_expedition_safor::getNextValue", LOG_DEBUG); |
140 | 142 | return -1; |
@@ -143,8 +145,13 @@ discard block |
||
143 | 145 | $date=time(); |
144 | 146 | $yymm = strftime("%y%m",$date); |
145 | 147 | |
146 | - 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 |
|
147 | - else $num = sprintf("%04s",$max+1); |
|
148 | + if ($max >= (pow(10, 4) - 1)) { |
|
149 | + $num=$max+1; |
|
150 | + } |
|
151 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
152 | + else { |
|
153 | + $num = sprintf("%04s",$max+1); |
|
154 | + } |
|
148 | 155 | |
149 | 156 | dol_syslog("mod_expedition_safor::getNextValue return ".$this->prefix.$yymm."-".$num); |
150 | 157 | return $this->prefix.$yymm."-".$num; |
@@ -142,10 +142,18 @@ |
||
142 | 142 | global $langs; |
143 | 143 | $langs->load("admin"); |
144 | 144 | |
145 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
146 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
147 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
148 | - if ($this->version) return $this->version; |
|
145 | + if ($this->version == 'development') { |
|
146 | + return $langs->trans("VersionDevelopment"); |
|
147 | + } |
|
148 | + if ($this->version == 'experimental') { |
|
149 | + return $langs->trans("VersionExperimental"); |
|
150 | + } |
|
151 | + if ($this->version == 'dolibarr') { |
|
152 | + return DOL_VERSION; |
|
153 | + } |
|
154 | + if ($this->version) { |
|
155 | + return $this->version; |
|
156 | + } |
|
149 | 157 | return $langs->trans("NotAvailable"); |
150 | 158 | } |
151 | 159 | } |
@@ -80,7 +80,10 @@ discard block |
||
80 | 80 | |
81 | 81 | // Recupere emmetteur |
82 | 82 | $this->emetteur=$mysoc; |
83 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // Par defaut, si n'etait pas defini |
|
83 | + if (! $this->emetteur->country_code) { |
|
84 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
85 | + } |
|
86 | + // Par defaut, si n'etait pas defini |
|
84 | 87 | } |
85 | 88 | |
86 | 89 | |
@@ -116,11 +119,14 @@ discard block |
||
116 | 119 | $tmpdir=trim($tmpdir); |
117 | 120 | $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
118 | 121 | if (! $tmpdir) { unset($listofdir[$key]); continue; } |
119 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
120 | - else |
|
122 | + if (! is_dir($tmpdir)) { |
|
123 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
124 | + } else |
|
121 | 125 | { |
122 | 126 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.od(s|t)$','','name',SORT_ASC,0,true); // Disable hook for the moment |
123 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
127 | + if (count($tmpfiles)) { |
|
128 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
129 | + } |
|
124 | 130 | } |
125 | 131 | } |
126 | 132 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -206,7 +212,9 @@ discard block |
||
206 | 212 | $hookmanager->initHooks(array('odtgeneration')); |
207 | 213 | global $action; |
208 | 214 | |
209 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
215 | + if (! is_object($outputlangs)) { |
|
216 | + $outputlangs=$langs; |
|
217 | + } |
|
210 | 218 | $sav_charset_output=$outputlangs->charset_output; |
211 | 219 | $outputlangs->charset_output='UTF-8'; |
212 | 220 | |
@@ -217,7 +225,9 @@ discard block |
||
217 | 225 | { |
218 | 226 | $dir = $conf->societe->multidir_output[$object->entity]; |
219 | 227 | $objectref = dol_sanitizeFileName($object->id); |
220 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
228 | + if (! preg_match('/specimen/i',$objectref)) { |
|
229 | + $dir.= "/" . $objectref; |
|
230 | + } |
|
221 | 231 | |
222 | 232 | if (! file_exists($dir)) |
223 | 233 | { |
@@ -244,10 +254,11 @@ discard block |
||
244 | 254 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
245 | 255 | { |
246 | 256 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
247 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
257 | + if ($format == '1') { |
|
258 | + $format='%Y%m%d%H%M%S'; |
|
259 | + } |
|
248 | 260 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
249 | - } |
|
250 | - else |
|
261 | + } else |
|
251 | 262 | { |
252 | 263 | $filename=$newfiletmp.'.'.$newfileformat; |
253 | 264 | } |
@@ -274,8 +285,7 @@ discard block |
||
274 | 285 | 'DELIMITER_RIGHT' => '}' |
275 | 286 | ) |
276 | 287 | ); |
277 | - } |
|
278 | - catch(Exception $e) |
|
288 | + } catch(Exception $e) |
|
279 | 289 | { |
280 | 290 | $this->error=$e->getMessage(); |
281 | 291 | dol_syslog($e->getMessage(), LOG_INFO); |
@@ -323,12 +333,10 @@ discard block |
||
323 | 333 | try |
324 | 334 | { |
325 | 335 | $listlines->setVars($key, $val, true, 'UTF-8'); |
326 | - } |
|
327 | - catch(OdfException $e) |
|
336 | + } catch(OdfException $e) |
|
328 | 337 | { |
329 | 338 | dol_syslog($e->getMessage(), LOG_INFO); |
330 | - } |
|
331 | - catch(SegmentException $e) |
|
339 | + } catch(SegmentException $e) |
|
332 | 340 | { |
333 | 341 | dol_syslog($e->getMessage(), LOG_INFO); |
334 | 342 | } |
@@ -336,8 +344,7 @@ discard block |
||
336 | 344 | $listlines->merge(); |
337 | 345 | } |
338 | 346 | $odfHandler->mergeSegment($listlines); |
339 | - } |
|
340 | - catch(OdfException $e) |
|
347 | + } catch(OdfException $e) |
|
341 | 348 | { |
342 | 349 | $this->error=$e->getMessage(); |
343 | 350 | dol_syslog($this->error, LOG_WARNING); |
@@ -362,17 +369,18 @@ discard block |
||
362 | 369 | foreach($tmparray as $key=>$value) |
363 | 370 | { |
364 | 371 | try { |
365 | - if (preg_match('/logo$/',$key)) // Image |
|
372 | + if (preg_match('/logo$/',$key)) { |
|
373 | + // Image |
|
366 | 374 | { |
367 | 375 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
368 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
369 | - } |
|
370 | - else // Text |
|
376 | + } else { |
|
377 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
378 | + } |
|
379 | + } else // Text |
|
371 | 380 | { |
372 | 381 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
373 | 382 | } |
374 | - } |
|
375 | - catch (OdfException $e) |
|
383 | + } catch (OdfException $e) |
|
376 | 384 | { |
377 | 385 | // setVars failed, probably because key not found |
378 | 386 | dol_syslog($e->getMessage(), LOG_INFO); |
@@ -385,8 +393,7 @@ discard block |
||
385 | 393 | { |
386 | 394 | try { |
387 | 395 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
388 | - } |
|
389 | - catch (OdfException $e) |
|
396 | + } catch (OdfException $e) |
|
390 | 397 | { |
391 | 398 | dol_syslog($e->getMessage(), LOG_INFO); |
392 | 399 | } |
@@ -405,8 +412,7 @@ discard block |
||
405 | 412 | dol_syslog($e->getMessage(), LOG_INFO); |
406 | 413 | return -1; |
407 | 414 | } |
408 | - } |
|
409 | - else { |
|
415 | + } else { |
|
410 | 416 | try { |
411 | 417 | $odfHandler->creator = $user->getFullName($outputlangs); |
412 | 418 | $odfHandler->title = $object->builddoc_filename; |
@@ -419,7 +425,7 @@ discard block |
||
419 | 425 | } |
420 | 426 | |
421 | 427 | $odfHandler->saveToDisk($file); |
422 | - }catch (Exception $e){ |
|
428 | + } catch (Exception $e){ |
|
423 | 429 | $this->error=$e->getMessage(); |
424 | 430 | dol_syslog($e->getMessage(), LOG_INFO); |
425 | 431 | return -1; |
@@ -428,16 +434,16 @@ discard block |
||
428 | 434 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
429 | 435 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
430 | 436 | |
431 | - if (! empty($conf->global->MAIN_UMASK)) |
|
432 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
437 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
438 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
439 | + } |
|
433 | 440 | |
434 | 441 | $odfHandler=null; // Destroy object |
435 | 442 | |
436 | 443 | $this->result = array('fullpath'=>$file); |
437 | 444 | |
438 | 445 | return 1; // Success |
439 | - } |
|
440 | - else |
|
446 | + } else |
|
441 | 447 | { |
442 | 448 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
443 | 449 | return -1; |
@@ -138,10 +138,18 @@ discard block |
||
138 | 138 | global $langs; |
139 | 139 | $langs->load("admin"); |
140 | 140 | |
141 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
142 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
143 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
144 | - if ($this->version) return $this->version; |
|
141 | + if ($this->version == 'development') { |
|
142 | + return $langs->trans("VersionDevelopment"); |
|
143 | + } |
|
144 | + if ($this->version == 'experimental') { |
|
145 | + return $langs->trans("VersionExperimental"); |
|
146 | + } |
|
147 | + if ($this->version == 'dolibarr') { |
|
148 | + return DOL_VERSION; |
|
149 | + } |
|
150 | + if ($this->version) { |
|
151 | + return $this->version; |
|
152 | + } |
|
145 | 153 | return $langs->trans("NotAvailable"); |
146 | 154 | } |
147 | 155 | |
@@ -170,8 +178,7 @@ discard block |
||
170 | 178 | $liste[$row[0]]=$row[1]; |
171 | 179 | $i++; |
172 | 180 | } |
173 | - } |
|
174 | - else |
|
181 | + } else |
|
175 | 182 | { |
176 | 183 | return -1; |
177 | 184 | } |
@@ -193,35 +200,57 @@ discard block |
||
193 | 200 | $langs->load("admin"); |
194 | 201 | |
195 | 202 | $s=''; |
196 | - if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>'; |
|
197 | - if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
198 | - if ($type == 0) $s.=$langs->trans("CustomerCodeDesc").'<br>'; |
|
199 | - if ($type == 1) $s.=$langs->trans("SupplierCodeDesc").'<br>'; |
|
200 | - if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
203 | + if ($type == -1) { |
|
204 | + $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>'; |
|
205 | + } |
|
206 | + if ($type == -1) { |
|
207 | + $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
208 | + } |
|
209 | + if ($type == 0) { |
|
210 | + $s.=$langs->trans("CustomerCodeDesc").'<br>'; |
|
211 | + } |
|
212 | + if ($type == 1) { |
|
213 | + $s.=$langs->trans("SupplierCodeDesc").'<br>'; |
|
214 | + } |
|
215 | + if ($type != -1) { |
|
216 | + $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
217 | + } |
|
201 | 218 | $s.='<br>'; |
202 | 219 | $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
203 | 220 | if ($type == 0) |
204 | 221 | { |
205 | 222 | $s.=$langs->trans("RequiredIfCustomer").': '; |
206 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
223 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
224 | + $s.='<strike>'; |
|
225 | + } |
|
207 | 226 | $s.=yn(!$this->code_null,1,2); |
208 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
227 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
228 | + $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
229 | + } |
|
209 | 230 | $s.='<br>'; |
210 | 231 | } |
211 | 232 | if ($type == 1) |
212 | 233 | { |
213 | 234 | $s.=$langs->trans("RequiredIfSupplier").': '; |
214 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
235 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
236 | + $s.='<strike>'; |
|
237 | + } |
|
215 | 238 | $s.=yn(!$this->code_null,1,2); |
216 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
239 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
240 | + $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
241 | + } |
|
217 | 242 | $s.='<br>'; |
218 | 243 | } |
219 | 244 | if ($type == -1) |
220 | 245 | { |
221 | 246 | $s.=$langs->trans("Required").': '; |
222 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
247 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
248 | + $s.='<strike>'; |
|
249 | + } |
|
223 | 250 | $s.=yn(!$this->code_null,1,2); |
224 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
251 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
252 | + $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
253 | + } |
|
225 | 254 | $s.='<br>'; |
226 | 255 | } |
227 | 256 | $s.=$langs->trans("CanBeModifiedIfOk").': '; |
@@ -233,13 +262,17 @@ discard block |
||
233 | 262 | if ($type == 0 || $type == -1) |
234 | 263 | { |
235 | 264 | $nextval=$this->getNextValue($soc,0); |
236 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
265 | + if (empty($nextval)) { |
|
266 | + $nextval=$langs->trans("Undefined"); |
|
267 | + } |
|
237 | 268 | $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>'; |
238 | 269 | } |
239 | 270 | if ($type == 1 || $type == -1) |
240 | 271 | { |
241 | 272 | $nextval=$this->getNextValue($soc,1); |
242 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
273 | + if (empty($nextval)) { |
|
274 | + $nextval=$langs->trans("Undefined"); |
|
275 | + } |
|
243 | 276 | $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>'; |
244 | 277 | } |
245 | 278 | return $s; |
@@ -314,10 +347,18 @@ discard block |
||
314 | 347 | global $langs; |
315 | 348 | $langs->load("admin"); |
316 | 349 | |
317 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
318 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
319 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
320 | - if ($this->version) return $this->version; |
|
350 | + if ($this->version == 'development') { |
|
351 | + return $langs->trans("VersionDevelopment"); |
|
352 | + } |
|
353 | + if ($this->version == 'experimental') { |
|
354 | + return $langs->trans("VersionExperimental"); |
|
355 | + } |
|
356 | + if ($this->version == 'dolibarr') { |
|
357 | + return DOL_VERSION; |
|
358 | + } |
|
359 | + if ($this->version) { |
|
360 | + return $this->version; |
|
361 | + } |
|
321 | 362 | return $langs->trans("NotAvailable"); |
322 | 363 | } |
323 | 364 | |
@@ -336,8 +377,12 @@ discard block |
||
336 | 377 | $langs->load("admin"); |
337 | 378 | |
338 | 379 | $s=''; |
339 | - if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->nom.'</b><br>'; |
|
340 | - if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
380 | + if ($type == -1) { |
|
381 | + $s.=$langs->trans("Name").': <b>'.$this->nom.'</b><br>'; |
|
382 | + } |
|
383 | + if ($type == -1) { |
|
384 | + $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
385 | + } |
|
341 | 386 | //$s.='<br>'; |
342 | 387 | //$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
343 | 388 | $s.='<br>'; |
@@ -345,14 +390,18 @@ discard block |
||
345 | 390 | { |
346 | 391 | $result=$this->get_code($db,$soc,'customer'); |
347 | 392 | $nextval=$this->code; |
348 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
393 | + if (empty($nextval)) { |
|
394 | + $nextval=$langs->trans("Undefined"); |
|
395 | + } |
|
349 | 396 | $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>'; |
350 | 397 | } |
351 | 398 | if ($type == 1 || $type == -1) |
352 | 399 | { |
353 | 400 | $result=$this->get_code($db,$soc,'supplier'); |
354 | 401 | $nextval=$this->code; |
355 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
402 | + if (empty($nextval)) { |
|
403 | + $nextval=$langs->trans("Undefined"); |
|
404 | + } |
|
356 | 405 | $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>'; |
357 | 406 | } |
358 | 407 | return $s; |
@@ -188,8 +188,12 @@ discard block |
||
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | - if ($type == 0) return $examplecust; |
|
192 | - if ($type == 1) return $examplesup; |
|
191 | + if ($type == 0) { |
|
192 | + return $examplecust; |
|
193 | + } |
|
194 | + if ($type == 1) { |
|
195 | + return $examplesup; |
|
196 | + } |
|
193 | 197 | return $examplecust.'<br>'.$examplesup; |
194 | 198 | } |
195 | 199 | |
@@ -208,8 +212,12 @@ discard block |
||
208 | 212 | |
209 | 213 | // Get Mask value |
210 | 214 | $mask = ''; |
211 | - if ($type==0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
212 | - if ($type==1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
215 | + if ($type==0) { |
|
216 | + $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
217 | + } |
|
218 | + if ($type==1) { |
|
219 | + $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
220 | + } |
|
213 | 221 | if (! $mask) |
214 | 222 | { |
215 | 223 | $this->error='NotConfigured'; |
@@ -221,13 +229,13 @@ discard block |
||
221 | 229 | { |
222 | 230 | $field = 'code_client'; |
223 | 231 | //$where = ' AND client in (1,2)'; |
224 | - } |
|
225 | - else if ($type == 1) |
|
232 | + } else if ($type == 1) |
|
226 | 233 | { |
227 | 234 | $field = 'code_fournisseur'; |
228 | 235 | //$where = ' AND fournisseur = 1'; |
236 | + } else { |
|
237 | + return -1; |
|
229 | 238 | } |
230 | - else return -1; |
|
231 | 239 | |
232 | 240 | $now=dol_now(); |
233 | 241 | |
@@ -249,10 +257,14 @@ discard block |
||
249 | 257 | global $conf; |
250 | 258 | |
251 | 259 | $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
252 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
260 | + if (preg_match('/\{pre\}/i',$mask)) { |
|
261 | + return 1; |
|
262 | + } |
|
253 | 263 | |
254 | 264 | $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
255 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
265 | + if (preg_match('/\{pre\}/i',$mask)) { |
|
266 | + return 1; |
|
267 | + } |
|
256 | 268 | |
257 | 269 | return 0; |
258 | 270 | } |
@@ -284,17 +296,19 @@ discard block |
||
284 | 296 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
285 | 297 | { |
286 | 298 | $result=0; |
287 | - } |
|
288 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
299 | + } else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
289 | 300 | { |
290 | 301 | $result=-2; |
291 | - } |
|
292 | - else |
|
302 | + } else |
|
293 | 303 | { |
294 | 304 | // Get Mask value |
295 | 305 | $mask = ''; |
296 | - if ($type==0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER)?'':$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
297 | - if ($type==1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER)?'':$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
306 | + if ($type==0) { |
|
307 | + $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER)?'':$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
308 | + } |
|
309 | + if ($type==1) { |
|
310 | + $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER)?'':$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
311 | + } |
|
298 | 312 | if (! $mask) |
299 | 313 | { |
300 | 314 | $this->error='NotConfigured'; |
@@ -328,9 +342,14 @@ discard block |
||
328 | 342 | { |
329 | 343 | // phpcs:enable |
330 | 344 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; |
331 | - if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'"; |
|
332 | - else $sql.= " WHERE code_client = '".$code."'"; |
|
333 | - if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; |
|
345 | + if ($type == 1) { |
|
346 | + $sql.= " WHERE code_fournisseur = '".$code."'"; |
|
347 | + } else { |
|
348 | + $sql.= " WHERE code_client = '".$code."'"; |
|
349 | + } |
|
350 | + if ($soc->id > 0) { |
|
351 | + $sql.= " AND rowid <> ".$soc->id; |
|
352 | + } |
|
334 | 353 | |
335 | 354 | $resql=$db->query($sql); |
336 | 355 | if ($resql) |
@@ -338,13 +357,11 @@ discard block |
||
338 | 357 | if ($db->num_rows($resql) == 0) |
339 | 358 | { |
340 | 359 | return 0; |
341 | - } |
|
342 | - else |
|
360 | + } else |
|
343 | 361 | { |
344 | 362 | return -1; |
345 | 363 | } |
346 | - } |
|
347 | - else |
|
364 | + } else |
|
348 | 365 | { |
349 | 366 | return -2; |
350 | 367 | } |
@@ -145,10 +145,12 @@ discard block |
||
145 | 145 | if ($resql) |
146 | 146 | { |
147 | 147 | $obj = $db->fetch_object($resql); |
148 | - if ($obj) $max = intval($obj->max); |
|
149 | - else $max=0; |
|
150 | - } |
|
151 | - else |
|
148 | + if ($obj) { |
|
149 | + $max = intval($obj->max); |
|
150 | + } else { |
|
151 | + $max=0; |
|
152 | + } |
|
153 | + } else |
|
152 | 154 | { |
153 | 155 | return -1; |
154 | 156 | } |
@@ -156,8 +158,13 @@ discard block |
||
156 | 158 | $date = dol_now(); |
157 | 159 | $yymm = strftime("%y%m",$date); |
158 | 160 | |
159 | - if ($max >= (pow(10, 5) - 1)) $num=$max+1; // If counter > 99999, we do not format on 5 chars, we take number as it is |
|
160 | - else $num = sprintf("%05s",$max+1); |
|
161 | + if ($max >= (pow(10, 5) - 1)) { |
|
162 | + $num=$max+1; |
|
163 | + } |
|
164 | + // If counter > 99999, we do not format on 5 chars, we take number as it is |
|
165 | + else { |
|
166 | + $num = sprintf("%05s",$max+1); |
|
167 | + } |
|
161 | 168 | |
162 | 169 | dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
163 | 170 | return $prefix.$yymm."-".$num; |
@@ -187,12 +194,10 @@ discard block |
||
187 | 194 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
188 | 195 | { |
189 | 196 | $result=0; |
190 | - } |
|
191 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
197 | + } else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
192 | 198 | { |
193 | 199 | $result=-2; |
194 | - } |
|
195 | - else |
|
200 | + } else |
|
196 | 201 | { |
197 | 202 | if ($this->verif_syntax($code) >= 0) |
198 | 203 | { |
@@ -200,19 +205,16 @@ discard block |
||
200 | 205 | if ($is_dispo <> 0) |
201 | 206 | { |
202 | 207 | $result=-3; |
203 | - } |
|
204 | - else |
|
208 | + } else |
|
205 | 209 | { |
206 | 210 | $result=0; |
207 | 211 | } |
208 | - } |
|
209 | - else |
|
212 | + } else |
|
210 | 213 | { |
211 | 214 | if (dol_strlen($code) == 0) |
212 | 215 | { |
213 | 216 | $result=-2; |
214 | - } |
|
215 | - else |
|
217 | + } else |
|
216 | 218 | { |
217 | 219 | $result=-1; |
218 | 220 | } |
@@ -240,10 +242,15 @@ discard block |
||
240 | 242 | global $conf, $mc; |
241 | 243 | |
242 | 244 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; |
243 | - if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'"; |
|
244 | - else $sql.= " WHERE code_client = '".$code."'"; |
|
245 | + if ($type == 1) { |
|
246 | + $sql.= " WHERE code_fournisseur = '".$code."'"; |
|
247 | + } else { |
|
248 | + $sql.= " WHERE code_client = '".$code."'"; |
|
249 | + } |
|
245 | 250 | $sql.= " AND entity IN (".getEntity('societe').")"; |
246 | - if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; |
|
251 | + if ($soc->id > 0) { |
|
252 | + $sql.= " AND rowid <> ".$soc->id; |
|
253 | + } |
|
247 | 254 | |
248 | 255 | dol_syslog(get_class($this)."::verif_dispo", LOG_DEBUG); |
249 | 256 | $resql=$db->query($sql); |
@@ -252,13 +259,11 @@ discard block |
||
252 | 259 | if ($db->num_rows($resql) == 0) |
253 | 260 | { |
254 | 261 | return 0; |
255 | - } |
|
256 | - else |
|
262 | + } else |
|
257 | 263 | { |
258 | 264 | return -1; |
259 | 265 | } |
260 | - } |
|
261 | - else |
|
266 | + } else |
|
262 | 267 | { |
263 | 268 | return -2; |
264 | 269 | } |
@@ -280,8 +285,7 @@ discard block |
||
280 | 285 | if (dol_strlen($code) < 11) |
281 | 286 | { |
282 | 287 | $res = -1; |
283 | - } |
|
284 | - else |
|
288 | + } else |
|
285 | 289 | { |
286 | 290 | $res = 0; |
287 | 291 | } |
@@ -96,8 +96,11 @@ |
||
96 | 96 | $this->code=''; |
97 | 97 | |
98 | 98 | if (is_object($societe)) { |
99 | - if ($type == 'supplier') $this->code = (! empty($societe->code_compta_fournisseur)?$societe->code_compta_fournisseur:''); |
|
100 | - else $this->code = (! empty($societe->code_compta)?$societe->code_compta:''); |
|
99 | + if ($type == 'supplier') { |
|
100 | + $this->code = (! empty($societe->code_compta_fournisseur)?$societe->code_compta_fournisseur:''); |
|
101 | + } else { |
|
102 | + $this->code = (! empty($societe->code_compta)?$societe->code_compta:''); |
|
103 | + } |
|
101 | 104 | } |
102 | 105 | |
103 | 106 | return 0; // return ok |