@@ -210,8 +210,7 @@ discard block |
||
| 210 | 210 | if($extrafields->attribute_type[$key] == 'price') |
| 211 | 211 | { |
| 212 | 212 | $object->array_options['options_'.$key] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
| 213 | - } |
|
| 214 | - else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
| 213 | + } else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
| 215 | 214 | { |
| 216 | 215 | $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
| 217 | 216 | } |
@@ -281,8 +280,7 @@ discard block |
||
| 281 | 280 | if ($extrafields->attribute_type[$key] == 'price') |
| 282 | 281 | { |
| 283 | 282 | $object->array_options['options_' . $key] = price($object->array_options ['options_' . $key], 0, $outputlangs, 0, 0, - 1, $conf->currency); |
| 284 | - } |
|
| 285 | - elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
| 283 | + } elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
| 286 | 284 | { |
| 287 | 285 | $object->array_options['options_' . $key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_' . $key]]; |
| 288 | 286 | } |
@@ -319,8 +317,11 @@ discard block |
||
| 319 | 317 | |
| 320 | 318 | foreach($conf->global as $key => $val) |
| 321 | 319 | { |
| 322 | - if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****'; |
|
| 323 | - else $newval = $val; |
|
| 320 | + if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) { |
|
| 321 | + $newval = '*****forbidden*****'; |
|
| 322 | + } else { |
|
| 323 | + $newval = $val; |
|
| 324 | + } |
|
| 324 | 325 | $array_other['__['.$key.']__'] = $newval; |
| 325 | 326 | } |
| 326 | 327 | |
@@ -449,12 +450,16 @@ discard block |
||
| 449 | 450 | foreach ($object->lines as $line) |
| 450 | 451 | { |
| 451 | 452 | // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility |
| 452 | - if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
| 453 | + if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) { |
|
| 454 | + $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
| 455 | + } |
|
| 453 | 456 | $resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
| 454 | 457 | $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); |
| 455 | 458 | // $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example) |
| 456 | 459 | $vatformated=vatrate($line->tva_tx); |
| 457 | - if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; |
|
| 460 | + if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) { |
|
| 461 | + $resarray[$array_key.'_total_vat_'.$vatformated]=0; |
|
| 462 | + } |
|
| 458 | 463 | $resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; |
| 459 | 464 | $resarray[$array_key.'_total_vat_locale_'.$vatformated]=price($resarray[$array_key.'_total_vat_'.$vatformated]); |
| 460 | 465 | } |
@@ -543,8 +548,9 @@ discard block |
||
| 543 | 548 | { |
| 544 | 549 | $tmpproduct = new Product($this->db); |
| 545 | 550 | $result = $tmpproduct->fetch($line->fk_product); |
| 546 | - foreach($tmpproduct->array_options as $key=>$label) |
|
| 547 | - $resarray["line_".$key] = $label; |
|
| 551 | + foreach($tmpproduct->array_options as $key=>$label) { |
|
| 552 | + $resarray["line_".$key] = $label; |
|
| 553 | + } |
|
| 548 | 554 | } |
| 549 | 555 | |
| 550 | 556 | return $resarray; |
@@ -592,7 +598,9 @@ discard block |
||
| 592 | 598 | // Add vat by rates |
| 593 | 599 | foreach ($object->lines as $line) |
| 594 | 600 | { |
| 595 | - if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
| 601 | + if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) { |
|
| 602 | + $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
| 603 | + } |
|
| 596 | 604 | $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
| 597 | 605 | } |
| 598 | 606 | |
@@ -691,12 +699,10 @@ discard block |
||
| 691 | 699 | $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
| 692 | 700 | //Add value to store price with currency |
| 693 | 701 | $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); |
| 694 | - } |
|
| 695 | - else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
| 702 | + } else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
| 696 | 703 | { |
| 697 | 704 | $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
| 698 | - } |
|
| 699 | - else if($extrafields->attribute_type[$key] == 'date') |
|
| 705 | + } else if($extrafields->attribute_type[$key] == 'date') |
|
| 700 | 706 | { |
| 701 | 707 | if (strlen($object->array_options['options_'.$key])>0) |
| 702 | 708 | { |
@@ -704,8 +710,7 @@ discard block |
||
| 704 | 710 | $object->array_options['options_'.$key] = dol_print_date($date,'day'); // using company output language |
| 705 | 711 | $object->array_options['options_'.$key.'_locale'] = dol_print_date($date,'day','tzserver',$outputlangs); // using output language format |
| 706 | 712 | $object->array_options['options_'.$key.'_rfc'] = dol_print_date($date,'dayrfc'); // international format |
| 707 | - } |
|
| 708 | - else |
|
| 713 | + } else |
|
| 709 | 714 | { |
| 710 | 715 | $object->array_options['options_'.$key] = ''; |
| 711 | 716 | $object->array_options['options_'.$key.'_locale'] = ''; |
@@ -713,8 +718,7 @@ discard block |
||
| 713 | 718 | } |
| 714 | 719 | $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); |
| 715 | 720 | $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); |
| 716 | - } |
|
| 717 | - else if($extrafields->attribute_type[$key] == 'datetime') |
|
| 721 | + } else if($extrafields->attribute_type[$key] == 'datetime') |
|
| 718 | 722 | { |
| 719 | 723 | $datetime = $object->array_options['options_'.$key]; |
| 720 | 724 | $object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhour'):''); // using company output language |
@@ -745,9 +749,13 @@ discard block |
||
| 745 | 749 | */ |
| 746 | 750 | function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
| 747 | 751 | { |
| 748 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
| 752 | + if (empty($hidetop) || $hidetop==-1) { |
|
| 753 | + $pdf->line($x, $y, $x+$l, $y); |
|
| 754 | + } |
|
| 749 | 755 | $pdf->line($x+$l, $y, $x+$l, $y+$h); |
| 750 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
| 756 | + if (empty($hidebottom)) { |
|
| 757 | + $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
| 758 | + } |
|
| 751 | 759 | $pdf->line($x, $y+$h, $x, $y); |
| 752 | 760 | } |
| 753 | 761 | } |
@@ -84,7 +84,10 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | // Recupere emetteur |
| 86 | 86 | $this->emetteur=$mysoc; |
| 87 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // Par defaut, si n'etait pas defini |
|
| 87 | + if (! $this->emetteur->country_code) { |
|
| 88 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
| 89 | + } |
|
| 90 | + // Par defaut, si n'etait pas defini |
|
| 88 | 91 | } |
| 89 | 92 | |
| 90 | 93 | |
@@ -122,11 +125,14 @@ discard block |
||
| 122 | 125 | if (! $tmpdir) { |
| 123 | 126 | unset($listofdir[$key]); continue; |
| 124 | 127 | } |
| 125 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 126 | - else |
|
| 128 | + if (! is_dir($tmpdir)) { |
|
| 129 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 130 | + } else |
|
| 127 | 131 | { |
| 128 | 132 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
| 129 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 133 | + if (count($tmpfiles)) { |
|
| 134 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 135 | + } |
|
| 130 | 136 | } |
| 131 | 137 | } |
| 132 | 138 | $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 | |
@@ -232,7 +240,9 @@ discard block |
||
| 232 | 240 | |
| 233 | 241 | $dir = $conf->facture->dir_output; |
| 234 | 242 | $objectref = dol_sanitizeFileName($object->ref); |
| 235 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
| 243 | + if (! preg_match('/specimen/i',$objectref)) { |
|
| 244 | + $dir.= "/" . $objectref; |
|
| 245 | + } |
|
| 236 | 246 | $file = $dir . "/" . $objectref . ".odt"; |
| 237 | 247 | |
| 238 | 248 | if (! file_exists($dir)) |
@@ -259,10 +269,11 @@ discard block |
||
| 259 | 269 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 260 | 270 | { |
| 261 | 271 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
| 262 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 272 | + if ($format == '1') { |
|
| 273 | + $format='%Y%m%d%H%M%S'; |
|
| 274 | + } |
|
| 263 | 275 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 264 | - } |
|
| 265 | - else |
|
| 276 | + } else |
|
| 266 | 277 | { |
| 267 | 278 | $filename=$newfiletmp.'.'.$newfileformat; |
| 268 | 279 | } |
@@ -289,14 +300,14 @@ discard block |
||
| 289 | 300 | if (! empty($usecontact)) |
| 290 | 301 | { |
| 291 | 302 | // On peut utiliser le nom de la societe du contact |
| 292 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
| 293 | - else { |
|
| 303 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
| 304 | + $socobject = $object->contact; |
|
| 305 | + } else { |
|
| 294 | 306 | $socobject = $object->thirdparty; |
| 295 | 307 | // if we have a BILLING contact and we dont use it as recipient we store the contact object for later use |
| 296 | 308 | $contactobject = $object->contact; |
| 297 | 309 | } |
| 298 | - } |
|
| 299 | - else |
|
| 310 | + } else |
|
| 300 | 311 | { |
| 301 | 312 | $socobject=$object->thirdparty; |
| 302 | 313 | } |
@@ -340,8 +351,7 @@ discard block |
||
| 340 | 351 | 'DELIMITER_RIGHT' => '}' |
| 341 | 352 | ) |
| 342 | 353 | ); |
| 343 | - } |
|
| 344 | - catch(Exception $e) |
|
| 354 | + } catch(Exception $e) |
|
| 345 | 355 | { |
| 346 | 356 | $this->error=$e->getMessage(); |
| 347 | 357 | return -1; |
@@ -356,8 +366,7 @@ discard block |
||
| 356 | 366 | // Make substitutions into odt of freetext |
| 357 | 367 | try { |
| 358 | 368 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
| 359 | - } |
|
| 360 | - catch(OdfException $e) |
|
| 369 | + } catch(OdfException $e) |
|
| 361 | 370 | { |
| 362 | 371 | } |
| 363 | 372 | |
@@ -372,7 +381,9 @@ discard block |
||
| 372 | 381 | $array_other=$this->get_substitutionarray_other($outputlangs); |
| 373 | 382 | // retrieve contact information for use in invoice as contact_xxx tags |
| 374 | 383 | $array_thirdparty_contact = array(); |
| 375 | - if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 384 | + if ($usecontact) { |
|
| 385 | + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 386 | + } |
|
| 376 | 387 | |
| 377 | 388 | $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal,$array_other,$array_thirdparty_contact); |
| 378 | 389 | complete_substitutions_array($tmparray, $outputlangs, $object); |
@@ -385,18 +396,19 @@ discard block |
||
| 385 | 396 | foreach($tmparray as $key=>$value) |
| 386 | 397 | { |
| 387 | 398 | try { |
| 388 | - if (preg_match('/logo$/',$key)) // Image |
|
| 399 | + if (preg_match('/logo$/',$key)) { |
|
| 400 | + // Image |
|
| 389 | 401 | { |
| 390 | 402 | //var_dump($value);exit; |
| 391 | 403 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
| 392 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 393 | - } |
|
| 394 | - else // Text |
|
| 404 | + } else { |
|
| 405 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 406 | + } |
|
| 407 | + } else // Text |
|
| 395 | 408 | { |
| 396 | 409 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 397 | 410 | } |
| 398 | - } |
|
| 399 | - catch(OdfException $e) |
|
| 411 | + } catch(OdfException $e) |
|
| 400 | 412 | { |
| 401 | 413 | } |
| 402 | 414 | } |
@@ -406,8 +418,7 @@ discard block |
||
| 406 | 418 | $foundtagforlines = 1; |
| 407 | 419 | try { |
| 408 | 420 | $listlines = $odfHandler->setSegment('lines'); |
| 409 | - } |
|
| 410 | - catch(OdfException $e) |
|
| 421 | + } catch(OdfException $e) |
|
| 411 | 422 | { |
| 412 | 423 | // We may arrive here if tags for lines not present into template |
| 413 | 424 | $foundtagforlines = 0; |
@@ -427,11 +438,9 @@ discard block |
||
| 427 | 438 | try |
| 428 | 439 | { |
| 429 | 440 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 430 | - } |
|
| 431 | - catch(OdfException $e) |
|
| 441 | + } catch(OdfException $e) |
|
| 432 | 442 | { |
| 433 | - } |
|
| 434 | - catch(SegmentException $e) |
|
| 443 | + } catch(SegmentException $e) |
|
| 435 | 444 | { |
| 436 | 445 | } |
| 437 | 446 | } |
@@ -439,8 +448,7 @@ discard block |
||
| 439 | 448 | } |
| 440 | 449 | $odfHandler->mergeSegment($listlines); |
| 441 | 450 | } |
| 442 | - } |
|
| 443 | - catch(OdfException $e) |
|
| 451 | + } catch(OdfException $e) |
|
| 444 | 452 | { |
| 445 | 453 | $this->error=$e->getMessage(); |
| 446 | 454 | dol_syslog($this->error, LOG_WARNING); |
@@ -453,8 +461,7 @@ discard block |
||
| 453 | 461 | { |
| 454 | 462 | try { |
| 455 | 463 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 456 | - } |
|
| 457 | - catch(OdfException $e) |
|
| 464 | + } catch(OdfException $e) |
|
| 458 | 465 | { |
| 459 | 466 | } |
| 460 | 467 | } |
@@ -467,15 +474,14 @@ discard block |
||
| 467 | 474 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
| 468 | 475 | try { |
| 469 | 476 | $odfHandler->exportAsAttachedPDF($file); |
| 470 | - }catch (Exception $e){ |
|
| 477 | + } catch (Exception $e){ |
|
| 471 | 478 | $this->error=$e->getMessage(); |
| 472 | 479 | return -1; |
| 473 | 480 | } |
| 474 | - } |
|
| 475 | - else { |
|
| 481 | + } else { |
|
| 476 | 482 | try { |
| 477 | 483 | $odfHandler->saveToDisk($file); |
| 478 | - }catch (Exception $e){ |
|
| 484 | + } catch (Exception $e){ |
|
| 479 | 485 | $this->error=$e->getMessage(); |
| 480 | 486 | return -1; |
| 481 | 487 | } |
@@ -483,16 +489,16 @@ discard block |
||
| 483 | 489 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
| 484 | 490 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 485 | 491 | |
| 486 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 487 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 492 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 493 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 494 | + } |
|
| 488 | 495 | |
| 489 | 496 | $odfHandler=null; // Destroy object |
| 490 | 497 | |
| 491 | 498 | $this->result = array('fullpath'=>$file); |
| 492 | 499 | |
| 493 | 500 | return 1; // Success |
| 494 | - } |
|
| 495 | - else |
|
| 501 | + } else |
|
| 496 | 502 | { |
| 497 | 503 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 498 | 504 | return -1; |
@@ -36,16 +36,36 @@ discard block |
||
| 36 | 36 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 37 | 37 | require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; |
| 38 | 38 | require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
| 39 | -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 40 | -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
| 41 | -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; |
|
| 42 | -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 43 | -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
|
| 44 | -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; |
|
| 45 | -if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
|
| 46 | -if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; |
|
| 47 | -if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; |
|
| 48 | -if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
|
| 39 | +if (! empty($conf->propal->enabled)) { |
|
| 40 | + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 41 | +} |
|
| 42 | +if (! empty($conf->facture->enabled)) { |
|
| 43 | + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
| 44 | +} |
|
| 45 | +if (! empty($conf->facture->enabled)) { |
|
| 46 | + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; |
|
| 47 | +} |
|
| 48 | +if (! empty($conf->commande->enabled)) { |
|
| 49 | + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 50 | +} |
|
| 51 | +if (! empty($conf->fournisseur->enabled)) { |
|
| 52 | + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
|
| 53 | +} |
|
| 54 | +if (! empty($conf->fournisseur->enabled)) { |
|
| 55 | + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; |
|
| 56 | +} |
|
| 57 | +if (! empty($conf->contrat->enabled)) { |
|
| 58 | + require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
|
| 59 | +} |
|
| 60 | +if (! empty($conf->ficheinter->enabled)) { |
|
| 61 | + require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; |
|
| 62 | +} |
|
| 63 | +if (! empty($conf->deplacement->enabled)) { |
|
| 64 | + require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; |
|
| 65 | +} |
|
| 66 | +if (! empty($conf->agenda->enabled)) { |
|
| 67 | + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
|
| 68 | +} |
|
| 49 | 69 | |
| 50 | 70 | |
| 51 | 71 | /** |
@@ -99,7 +119,10 @@ discard block |
||
| 99 | 119 | |
| 100 | 120 | // Recupere emetteur |
| 101 | 121 | $this->emetteur=$mysoc; |
| 102 | - if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'etait pas defini |
|
| 122 | + if (! $this->emetteur->pays_code) { |
|
| 123 | + $this->emetteur->pays_code=substr($langs->defaultlang,-2); |
|
| 124 | + } |
|
| 125 | + // Par defaut, si n'etait pas defini |
|
| 103 | 126 | } |
| 104 | 127 | |
| 105 | 128 | |
@@ -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"); |
@@ -449,7 +475,9 @@ discard block |
||
| 449 | 475 | $hookmanager->initHooks(array('odtgeneration')); |
| 450 | 476 | global $action; |
| 451 | 477 | |
| 452 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 478 | + if (! is_object($outputlangs)) { |
|
| 479 | + $outputlangs=$langs; |
|
| 480 | + } |
|
| 453 | 481 | $sav_charset_output=$outputlangs->charset_output; |
| 454 | 482 | $outputlangs->charset_output='UTF-8'; |
| 455 | 483 | |
@@ -475,7 +503,9 @@ discard block |
||
| 475 | 503 | |
| 476 | 504 | $dir = $conf->projet->dir_output; |
| 477 | 505 | $objectref = dol_sanitizeFileName($object->ref); |
| 478 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
| 506 | + if (! preg_match('/specimen/i',$objectref)) { |
|
| 507 | + $dir.= "/" . $objectref; |
|
| 508 | + } |
|
| 479 | 509 | $file = $dir . "/" . $objectref . ".odt"; |
| 480 | 510 | |
| 481 | 511 | if (! file_exists($dir)) |
@@ -501,10 +531,11 @@ discard block |
||
| 501 | 531 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 502 | 532 | { |
| 503 | 533 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
| 504 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 534 | + if ($format == '1') { |
|
| 535 | + $format='%Y%m%d%H%M%S'; |
|
| 536 | + } |
|
| 505 | 537 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 506 | - } |
|
| 507 | - else |
|
| 538 | + } else |
|
| 508 | 539 | { |
| 509 | 540 | $filename=$newfiletmp.'.'.$newfileformat; |
| 510 | 541 | } |
@@ -556,8 +587,7 @@ discard block |
||
| 556 | 587 | 'DELIMITER_RIGHT' => '}' |
| 557 | 588 | ) |
| 558 | 589 | ); |
| 559 | - } |
|
| 560 | - catch(Exception $e) |
|
| 590 | + } catch(Exception $e) |
|
| 561 | 591 | { |
| 562 | 592 | $this->error=$e->getMessage(); |
| 563 | 593 | return -1; |
@@ -579,7 +609,9 @@ discard block |
||
| 579 | 609 | $array_other=$this->get_substitutionarray_other($outputlangs); |
| 580 | 610 | // retrieve contact information for use in project as contact_xxx tags |
| 581 | 611 | $array_project_contact = array(); |
| 582 | - if ($usecontact) $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 612 | + if ($usecontact) { |
|
| 613 | + $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 614 | + } |
|
| 583 | 615 | |
| 584 | 616 | $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact); |
| 585 | 617 | complete_substitutions_array($tmparray, $outputlangs, $object); |
@@ -591,17 +623,18 @@ discard block |
||
| 591 | 623 | foreach($tmparray as $key=>$value) |
| 592 | 624 | { |
| 593 | 625 | try { |
| 594 | - if (preg_match('/logo$/',$key)) // Image |
|
| 626 | + if (preg_match('/logo$/',$key)) { |
|
| 627 | + // Image |
|
| 595 | 628 | { |
| 596 | 629 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
| 597 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 598 | - } |
|
| 599 | - else // Text |
|
| 630 | + } else { |
|
| 631 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 632 | + } |
|
| 633 | + } else // Text |
|
| 600 | 634 | { |
| 601 | 635 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 602 | 636 | } |
| 603 | - } |
|
| 604 | - catch(OdfException $e) |
|
| 637 | + } catch(OdfException $e) |
|
| 605 | 638 | { |
| 606 | 639 | } |
| 607 | 640 | } |
@@ -615,7 +648,9 @@ discard block |
||
| 615 | 648 | |
| 616 | 649 | // Security check |
| 617 | 650 | $socid=0; |
| 618 | - if (!empty($object->fk_soc)) $socid = $object->fk_soc; |
|
| 651 | + if (!empty($object->fk_soc)) { |
|
| 652 | + $socid = $object->fk_soc; |
|
| 653 | + } |
|
| 619 | 654 | |
| 620 | 655 | $tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0); |
| 621 | 656 | |
@@ -629,11 +664,9 @@ discard block |
||
| 629 | 664 | try |
| 630 | 665 | { |
| 631 | 666 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 632 | - } |
|
| 633 | - catch(OdfException $e) |
|
| 667 | + } catch(OdfException $e) |
|
| 634 | 668 | { |
| 635 | - } |
|
| 636 | - catch(SegmentException $e) |
|
| 669 | + } catch(SegmentException $e) |
|
| 637 | 670 | { |
| 638 | 671 | } |
| 639 | 672 | } |
@@ -678,11 +711,9 @@ discard block |
||
| 678 | 711 | try |
| 679 | 712 | { |
| 680 | 713 | $listlinestaskres->setVars($key, $val, true, 'UTF-8'); |
| 681 | - } |
|
| 682 | - catch(OdfException $e) |
|
| 714 | + } catch(OdfException $e) |
|
| 683 | 715 | { |
| 684 | - } |
|
| 685 | - catch(SegmentException $e) |
|
| 716 | + } catch(SegmentException $e) |
|
| 686 | 717 | { |
| 687 | 718 | } |
| 688 | 719 | } |
@@ -724,11 +755,9 @@ discard block |
||
| 724 | 755 | try |
| 725 | 756 | { |
| 726 | 757 | $listlinestasktime->setVars($key, $val, true, 'UTF-8'); |
| 727 | - } |
|
| 728 | - catch(OdfException $e) |
|
| 758 | + } catch(OdfException $e) |
|
| 729 | 759 | { |
| 730 | - } |
|
| 731 | - catch(SegmentException $e) |
|
| 760 | + } catch(SegmentException $e) |
|
| 732 | 761 | { |
| 733 | 762 | } |
| 734 | 763 | } |
@@ -755,11 +784,9 @@ discard block |
||
| 755 | 784 | try |
| 756 | 785 | { |
| 757 | 786 | $listtasksfiles->setVars($key, $val, true, 'UTF-8'); |
| 758 | - } |
|
| 759 | - catch(OdfException $e) |
|
| 787 | + } catch(OdfException $e) |
|
| 760 | 788 | { |
| 761 | - } |
|
| 762 | - catch(SegmentException $e) |
|
| 789 | + } catch(SegmentException $e) |
|
| 763 | 790 | { |
| 764 | 791 | } |
| 765 | 792 | } |
@@ -768,8 +795,7 @@ discard block |
||
| 768 | 795 | $listlines->merge(); |
| 769 | 796 | } |
| 770 | 797 | $odfHandler->mergeSegment($listlines); |
| 771 | - } |
|
| 772 | - catch(OdfException $e) |
|
| 798 | + } catch(OdfException $e) |
|
| 773 | 799 | { |
| 774 | 800 | $ExceptionTrace=$e->getTrace(); |
| 775 | 801 | // no segment defined on ODT is not an error |
@@ -799,19 +825,16 @@ discard block |
||
| 799 | 825 | try |
| 800 | 826 | { |
| 801 | 827 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 802 | - } |
|
| 803 | - catch(OdfException $e) |
|
| 828 | + } catch(OdfException $e) |
|
| 804 | 829 | { |
| 805 | - } |
|
| 806 | - catch(SegmentException $e) |
|
| 830 | + } catch(SegmentException $e) |
|
| 807 | 831 | { |
| 808 | 832 | } |
| 809 | 833 | } |
| 810 | 834 | $listlines->merge(); |
| 811 | 835 | } |
| 812 | 836 | $odfHandler->mergeSegment($listlines); |
| 813 | - } |
|
| 814 | - catch(OdfException $e) |
|
| 837 | + } catch(OdfException $e) |
|
| 815 | 838 | { |
| 816 | 839 | $this->error=$e->getMessage(); |
| 817 | 840 | dol_syslog($this->error, LOG_WARNING); |
@@ -856,19 +879,16 @@ discard block |
||
| 856 | 879 | try |
| 857 | 880 | { |
| 858 | 881 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 859 | - } |
|
| 860 | - catch(OdfException $e) |
|
| 882 | + } catch(OdfException $e) |
|
| 861 | 883 | { |
| 862 | - } |
|
| 863 | - catch(SegmentException $e) |
|
| 884 | + } catch(SegmentException $e) |
|
| 864 | 885 | { |
| 865 | 886 | } |
| 866 | 887 | } |
| 867 | 888 | $listlines->merge(); |
| 868 | 889 | } |
| 869 | 890 | $odfHandler->mergeSegment($listlines); |
| 870 | - } |
|
| 871 | - catch(OdfException $e) |
|
| 891 | + } catch(OdfException $e) |
|
| 872 | 892 | { |
| 873 | 893 | $this->error=$e->getMessage(); |
| 874 | 894 | dol_syslog($this->error, LOG_WARNING); |
@@ -968,8 +988,12 @@ discard block |
||
| 968 | 988 | |
| 969 | 989 | //Date object |
| 970 | 990 | $dateref=$element->date; |
| 971 | - if (empty($dateref)) $dateref=$element->datep; |
|
| 972 | - if (empty($dateref)) $dateref=$element->date_contrat; |
|
| 991 | + if (empty($dateref)) { |
|
| 992 | + $dateref=$element->datep; |
|
| 993 | + } |
|
| 994 | + if (empty($dateref)) { |
|
| 995 | + $dateref=$element->date_contrat; |
|
| 996 | + } |
|
| 973 | 997 | $ref_array['date']=$dateref; |
| 974 | 998 | |
| 975 | 999 | //Soc object |
@@ -984,11 +1008,11 @@ discard block |
||
| 984 | 1008 | if (!empty($element->total_ht)) { |
| 985 | 1009 | $ref_array['amountht']=$element->total_ht; |
| 986 | 1010 | $ref_array['amountttc']=$element->total_ttc; |
| 987 | - }else { |
|
| 1011 | + } else { |
|
| 988 | 1012 | $ref_array['amountht']=0; |
| 989 | 1013 | $ref_array['amountttc']=0; |
| 990 | 1014 | } |
| 991 | - }else { |
|
| 1015 | + } else { |
|
| 992 | 1016 | $ref_array['amountht']=''; |
| 993 | 1017 | $ref_array['amountttc']=''; |
| 994 | 1018 | } |
@@ -1002,11 +1026,9 @@ discard block |
||
| 1002 | 1026 | try |
| 1003 | 1027 | { |
| 1004 | 1028 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 1005 | - } |
|
| 1006 | - catch(OdfException $e) |
|
| 1029 | + } catch(OdfException $e) |
|
| 1007 | 1030 | { |
| 1008 | - } |
|
| 1009 | - catch(SegmentException $e) |
|
| 1031 | + } catch(SegmentException $e) |
|
| 1010 | 1032 | { |
| 1011 | 1033 | } |
| 1012 | 1034 | } |
@@ -1017,8 +1039,7 @@ discard block |
||
| 1017 | 1039 | } |
| 1018 | 1040 | $odfHandler->mergeSegment($listlines); |
| 1019 | 1041 | } |
| 1020 | - } |
|
| 1021 | - catch(OdfException $e) |
|
| 1042 | + } catch(OdfException $e) |
|
| 1022 | 1043 | { |
| 1023 | 1044 | $this->error=$e->getMessage(); |
| 1024 | 1045 | dol_syslog($this->error, LOG_WARNING); |
@@ -1031,8 +1052,7 @@ discard block |
||
| 1031 | 1052 | { |
| 1032 | 1053 | try { |
| 1033 | 1054 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 1034 | - } |
|
| 1035 | - catch(OdfException $e) |
|
| 1055 | + } catch(OdfException $e) |
|
| 1036 | 1056 | { |
| 1037 | 1057 | } |
| 1038 | 1058 | } |
@@ -1046,15 +1066,14 @@ discard block |
||
| 1046 | 1066 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
| 1047 | 1067 | try { |
| 1048 | 1068 | $odfHandler->exportAsAttachedPDF($file); |
| 1049 | - }catch (Exception $e){ |
|
| 1069 | + } catch (Exception $e){ |
|
| 1050 | 1070 | $this->error=$e->getMessage(); |
| 1051 | 1071 | return -1; |
| 1052 | 1072 | } |
| 1053 | - } |
|
| 1054 | - else { |
|
| 1073 | + } else { |
|
| 1055 | 1074 | try { |
| 1056 | 1075 | $odfHandler->saveToDisk($file); |
| 1057 | - }catch (Exception $e){ |
|
| 1076 | + } catch (Exception $e){ |
|
| 1058 | 1077 | $this->error=$e->getMessage(); |
| 1059 | 1078 | return -1; |
| 1060 | 1079 | } |
@@ -1062,16 +1081,16 @@ discard block |
||
| 1062 | 1081 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
| 1063 | 1082 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 1064 | 1083 | |
| 1065 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 1066 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 1084 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 1085 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 1086 | + } |
|
| 1067 | 1087 | |
| 1068 | 1088 | $odfHandler=null; // Destroy object |
| 1069 | 1089 | |
| 1070 | 1090 | $this->result = array('fullpath'=>$file); |
| 1071 | 1091 | |
| 1072 | 1092 | return 1; // Success |
| 1073 | - } |
|
| 1074 | - else |
|
| 1093 | + } else |
|
| 1075 | 1094 | { |
| 1076 | 1095 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 1077 | 1096 | return -1; |
@@ -83,7 +83,10 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | // Recupere emetteur |
| 85 | 85 | $this->emetteur=$mysoc; |
| 86 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 86 | + if (! $this->emetteur->country_code) { |
|
| 87 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
| 88 | + } |
|
| 89 | + // By default if not defined |
|
| 87 | 90 | } |
| 88 | 91 | |
| 89 | 92 | |
@@ -121,11 +124,14 @@ discard block |
||
| 121 | 124 | if (! $tmpdir) { |
| 122 | 125 | unset($listofdir[$key]); continue; |
| 123 | 126 | } |
| 124 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 125 | - else |
|
| 127 | + if (! is_dir($tmpdir)) { |
|
| 128 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 129 | + } else |
|
| 126 | 130 | { |
| 127 | 131 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
| 128 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 132 | + if (count($tmpfiles)) { |
|
| 133 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 134 | + } |
|
| 129 | 135 | } |
| 130 | 136 | } |
| 131 | 137 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -197,7 +203,9 @@ discard block |
||
| 197 | 203 | $hookmanager->initHooks(array('odtgeneration')); |
| 198 | 204 | global $action; |
| 199 | 205 | |
| 200 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 206 | + if (! is_object($outputlangs)) { |
|
| 207 | + $outputlangs=$langs; |
|
| 208 | + } |
|
| 201 | 209 | $sav_charset_output=$outputlangs->charset_output; |
| 202 | 210 | $outputlangs->charset_output='UTF-8'; |
| 203 | 211 | |
@@ -223,7 +231,9 @@ discard block |
||
| 223 | 231 | |
| 224 | 232 | $dir = $conf->contrat->dir_output; |
| 225 | 233 | $objectref = dol_sanitizeFileName($object->ref); |
| 226 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
| 234 | + if (! preg_match('/specimen/i',$objectref)) { |
|
| 235 | + $dir.= "/" . $objectref; |
|
| 236 | + } |
|
| 227 | 237 | $file = $dir . "/" . $objectref . ".odt"; |
| 228 | 238 | |
| 229 | 239 | if (! file_exists($dir)) |
@@ -250,10 +260,11 @@ discard block |
||
| 250 | 260 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 251 | 261 | { |
| 252 | 262 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
| 253 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 263 | + if ($format == '1') { |
|
| 264 | + $format='%Y%m%d%H%M%S'; |
|
| 265 | + } |
|
| 254 | 266 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 255 | - } |
|
| 256 | - else |
|
| 267 | + } else |
|
| 257 | 268 | { |
| 258 | 269 | $filename=$newfiletmp.'.'.$newfileformat; |
| 259 | 270 | } |
@@ -279,14 +290,14 @@ discard block |
||
| 279 | 290 | if (! empty($usecontact)) |
| 280 | 291 | { |
| 281 | 292 | // On peut utiliser le nom de la societe du contact |
| 282 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
| 283 | - else { |
|
| 293 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
| 294 | + $socobject = $object->contact; |
|
| 295 | + } else { |
|
| 284 | 296 | $socobject = $object->thirdparty; |
| 285 | 297 | // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
| 286 | 298 | $contactobject = $object->contact; |
| 287 | 299 | } |
| 288 | - } |
|
| 289 | - else |
|
| 300 | + } else |
|
| 290 | 301 | { |
| 291 | 302 | $socobject=$object->thirdparty; |
| 292 | 303 | } |
@@ -304,7 +315,9 @@ discard block |
||
| 304 | 315 | $array_other=$this->get_substitutionarray_other($outputlangs); |
| 305 | 316 | // retrieve contact information for use in contract as contact_xxx tags |
| 306 | 317 | $array_thirdparty_contact = array(); |
| 307 | - if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 318 | + if ($usecontact) { |
|
| 319 | + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 320 | + } |
|
| 308 | 321 | |
| 309 | 322 | $substitutionarray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); |
| 310 | 323 | complete_substitutions_array($substitutionarray, $outputlangs, $object); |
@@ -336,8 +349,7 @@ discard block |
||
| 336 | 349 | 'DELIMITER_RIGHT' => '}' |
| 337 | 350 | ) |
| 338 | 351 | ); |
| 339 | - } |
|
| 340 | - catch(Exception $e) |
|
| 352 | + } catch(Exception $e) |
|
| 341 | 353 | { |
| 342 | 354 | $this->error=$e->getMessage(); |
| 343 | 355 | return -1; |
@@ -352,25 +364,25 @@ discard block |
||
| 352 | 364 | // Make substitutions into odt of freetext |
| 353 | 365 | try { |
| 354 | 366 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
| 355 | - } |
|
| 356 | - catch(OdfException $e) |
|
| 367 | + } catch(OdfException $e) |
|
| 357 | 368 | { |
| 358 | 369 | } |
| 359 | 370 | |
| 360 | 371 | foreach($tmparray as $key=>$value) |
| 361 | 372 | { |
| 362 | 373 | try { |
| 363 | - if (preg_match('/logo$/',$key)) // Image |
|
| 374 | + if (preg_match('/logo$/',$key)) { |
|
| 375 | + // Image |
|
| 364 | 376 | { |
| 365 | 377 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
| 366 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 367 | - } |
|
| 368 | - else // Text |
|
| 378 | + } else { |
|
| 379 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 380 | + } |
|
| 381 | + } else // Text |
|
| 369 | 382 | { |
| 370 | 383 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 371 | 384 | } |
| 372 | - } |
|
| 373 | - catch(OdfException $e) |
|
| 385 | + } catch(OdfException $e) |
|
| 374 | 386 | { |
| 375 | 387 | } |
| 376 | 388 | } |
@@ -381,8 +393,7 @@ discard block |
||
| 381 | 393 | $foundtagforlines = 1; |
| 382 | 394 | try { |
| 383 | 395 | $listlines = $odfHandler->setSegment('lines'); |
| 384 | - } |
|
| 385 | - catch(OdfException $e) |
|
| 396 | + } catch(OdfException $e) |
|
| 386 | 397 | { |
| 387 | 398 | // We may arrive here if tags for lines not present into template |
| 388 | 399 | $foundtagforlines = 0; |
@@ -402,11 +413,9 @@ discard block |
||
| 402 | 413 | try |
| 403 | 414 | { |
| 404 | 415 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 405 | - } |
|
| 406 | - catch(OdfException $e) |
|
| 416 | + } catch(OdfException $e) |
|
| 407 | 417 | { |
| 408 | - } |
|
| 409 | - catch(SegmentException $e) |
|
| 418 | + } catch(SegmentException $e) |
|
| 410 | 419 | { |
| 411 | 420 | } |
| 412 | 421 | } |
@@ -414,8 +423,7 @@ discard block |
||
| 414 | 423 | } |
| 415 | 424 | $odfHandler->mergeSegment($listlines); |
| 416 | 425 | } |
| 417 | - } |
|
| 418 | - catch(OdfException $e) |
|
| 426 | + } catch(OdfException $e) |
|
| 419 | 427 | { |
| 420 | 428 | $this->error=$e->getMessage(); |
| 421 | 429 | dol_syslog($this->error, LOG_WARNING); |
@@ -428,8 +436,7 @@ discard block |
||
| 428 | 436 | { |
| 429 | 437 | try { |
| 430 | 438 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 431 | - } |
|
| 432 | - catch(OdfException $e) |
|
| 439 | + } catch(OdfException $e) |
|
| 433 | 440 | { |
| 434 | 441 | } |
| 435 | 442 | } |
@@ -442,15 +449,14 @@ discard block |
||
| 442 | 449 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
| 443 | 450 | try { |
| 444 | 451 | $odfHandler->exportAsAttachedPDF($file); |
| 445 | - }catch (Exception $e){ |
|
| 452 | + } catch (Exception $e){ |
|
| 446 | 453 | $this->error=$e->getMessage(); |
| 447 | 454 | return -1; |
| 448 | 455 | } |
| 449 | - } |
|
| 450 | - else { |
|
| 456 | + } else { |
|
| 451 | 457 | try { |
| 452 | 458 | $odfHandler->saveToDisk($file); |
| 453 | - }catch (Exception $e){ |
|
| 459 | + } catch (Exception $e){ |
|
| 454 | 460 | $this->error=$e->getMessage(); |
| 455 | 461 | return -1; |
| 456 | 462 | } |
@@ -458,16 +464,16 @@ discard block |
||
| 458 | 464 | |
| 459 | 465 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 460 | 466 | |
| 461 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 462 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 467 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 468 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 469 | + } |
|
| 463 | 470 | |
| 464 | 471 | $odfHandler=null; // Destroy object |
| 465 | 472 | |
| 466 | 473 | $this->result = array('fullpath'=>$file); |
| 467 | 474 | |
| 468 | 475 | return 1; // Success |
| 469 | - } |
|
| 470 | - else |
|
| 476 | + } else |
|
| 471 | 477 | { |
| 472 | 478 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 473 | 479 | return -1; |
@@ -83,7 +83,10 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | // Recupere emetteur |
| 85 | 85 | $this->emetteur=$mysoc; |
| 86 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 86 | + if (! $this->emetteur->country_code) { |
|
| 87 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
| 88 | + } |
|
| 89 | + // By default if not defined |
|
| 87 | 90 | } |
| 88 | 91 | |
| 89 | 92 | |
@@ -127,11 +130,14 @@ discard block |
||
| 127 | 130 | if (! $tmpdir) { |
| 128 | 131 | unset($listofdir[$key]); continue; |
| 129 | 132 | } |
| 130 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 131 | - else |
|
| 133 | + if (! is_dir($tmpdir)) { |
|
| 134 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 135 | + } else |
|
| 132 | 136 | { |
| 133 | 137 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
| 134 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 138 | + if (count($tmpfiles)) { |
|
| 139 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 140 | + } |
|
| 135 | 141 | } |
| 136 | 142 | } |
| 137 | 143 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -237,7 +243,9 @@ discard block |
||
| 237 | 243 | $hookmanager->initHooks(array('odtgeneration')); |
| 238 | 244 | global $action; |
| 239 | 245 | |
| 240 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 246 | + if (! is_object($outputlangs)) { |
|
| 247 | + $outputlangs=$langs; |
|
| 248 | + } |
|
| 241 | 249 | $sav_charset_output=$outputlangs->charset_output; |
| 242 | 250 | $outputlangs->charset_output='UTF-8'; |
| 243 | 251 | |
@@ -263,7 +271,9 @@ discard block |
||
| 263 | 271 | |
| 264 | 272 | $dir = $conf->supplier_proposal->dir_output; |
| 265 | 273 | $objectref = dol_sanitizeFileName($object->ref); |
| 266 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
| 274 | + if (! preg_match('/specimen/i',$objectref)) { |
|
| 275 | + $dir.= "/" . $objectref; |
|
| 276 | + } |
|
| 267 | 277 | $file = $dir . "/" . $objectref . ".odt"; |
| 268 | 278 | |
| 269 | 279 | if (! file_exists($dir)) |
@@ -290,10 +300,11 @@ discard block |
||
| 290 | 300 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 291 | 301 | { |
| 292 | 302 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
| 293 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 303 | + if ($format == '1') { |
|
| 304 | + $format='%Y%m%d%H%M%S'; |
|
| 305 | + } |
|
| 294 | 306 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 295 | - } |
|
| 296 | - else |
|
| 307 | + } else |
|
| 297 | 308 | { |
| 298 | 309 | $filename=$newfiletmp.'.'.$newfileformat; |
| 299 | 310 | } |
@@ -319,10 +330,12 @@ discard block |
||
| 319 | 330 | if (! empty($usecontact)) |
| 320 | 331 | { |
| 321 | 332 | // On peut utiliser le nom de la societe du contact |
| 322 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
| 323 | - else $socobject = $object->thirdparty; |
|
| 324 | - } |
|
| 325 | - else |
|
| 333 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
| 334 | + $socobject = $object->contact; |
|
| 335 | + } else { |
|
| 336 | + $socobject = $object->thirdparty; |
|
| 337 | + } |
|
| 338 | + } else |
|
| 326 | 339 | { |
| 327 | 340 | $socobject=$object->thirdparty; |
| 328 | 341 | } |
@@ -360,8 +373,7 @@ discard block |
||
| 360 | 373 | 'DELIMITER_RIGHT' => '}' |
| 361 | 374 | ) |
| 362 | 375 | ); |
| 363 | - } |
|
| 364 | - catch(Exception $e) |
|
| 376 | + } catch(Exception $e) |
|
| 365 | 377 | { |
| 366 | 378 | $this->error=$e->getMessage(); |
| 367 | 379 | return -1; |
@@ -376,8 +388,7 @@ discard block |
||
| 376 | 388 | // Make substitutions into odt of freetext |
| 377 | 389 | try { |
| 378 | 390 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
| 379 | - } |
|
| 380 | - catch(OdfException $e) |
|
| 391 | + } catch(OdfException $e) |
|
| 381 | 392 | { |
| 382 | 393 | } |
| 383 | 394 | |
@@ -399,17 +410,18 @@ discard block |
||
| 399 | 410 | foreach($tmparray as $key=>$value) |
| 400 | 411 | { |
| 401 | 412 | try { |
| 402 | - if (preg_match('/logo$/',$key)) // Image |
|
| 413 | + if (preg_match('/logo$/',$key)) { |
|
| 414 | + // Image |
|
| 403 | 415 | { |
| 404 | 416 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
| 405 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 406 | - } |
|
| 407 | - else // Text |
|
| 417 | + } else { |
|
| 418 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 419 | + } |
|
| 420 | + } else // Text |
|
| 408 | 421 | { |
| 409 | 422 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 410 | 423 | } |
| 411 | - } |
|
| 412 | - catch(OdfException $e) |
|
| 424 | + } catch(OdfException $e) |
|
| 413 | 425 | { |
| 414 | 426 | } |
| 415 | 427 | } |
@@ -419,8 +431,7 @@ discard block |
||
| 419 | 431 | $foundtagforlines = 1; |
| 420 | 432 | try { |
| 421 | 433 | $listlines = $odfHandler->setSegment('lines'); |
| 422 | - } |
|
| 423 | - catch(OdfException $e) |
|
| 434 | + } catch(OdfException $e) |
|
| 424 | 435 | { |
| 425 | 436 | // We may arrive here if tags for lines not present into template |
| 426 | 437 | $foundtagforlines = 0; |
@@ -440,11 +451,9 @@ discard block |
||
| 440 | 451 | try |
| 441 | 452 | { |
| 442 | 453 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 443 | - } |
|
| 444 | - catch(OdfException $e) |
|
| 454 | + } catch(OdfException $e) |
|
| 445 | 455 | { |
| 446 | - } |
|
| 447 | - catch(SegmentException $e) |
|
| 456 | + } catch(SegmentException $e) |
|
| 448 | 457 | { |
| 449 | 458 | } |
| 450 | 459 | } |
@@ -452,8 +461,7 @@ discard block |
||
| 452 | 461 | } |
| 453 | 462 | $odfHandler->mergeSegment($listlines); |
| 454 | 463 | } |
| 455 | - } |
|
| 456 | - catch(OdfException $e) |
|
| 464 | + } catch(OdfException $e) |
|
| 457 | 465 | { |
| 458 | 466 | $this->error=$e->getMessage(); |
| 459 | 467 | dol_syslog($this->error, LOG_WARNING); |
@@ -466,8 +474,7 @@ discard block |
||
| 466 | 474 | { |
| 467 | 475 | try { |
| 468 | 476 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 469 | - } |
|
| 470 | - catch(OdfException $e) |
|
| 477 | + } catch(OdfException $e) |
|
| 471 | 478 | { |
| 472 | 479 | } |
| 473 | 480 | } |
@@ -480,15 +487,14 @@ discard block |
||
| 480 | 487 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
| 481 | 488 | try { |
| 482 | 489 | $odfHandler->exportAsAttachedPDF($file); |
| 483 | - }catch (Exception $e){ |
|
| 490 | + } catch (Exception $e){ |
|
| 484 | 491 | $this->error=$e->getMessage(); |
| 485 | 492 | return -1; |
| 486 | 493 | } |
| 487 | - } |
|
| 488 | - else { |
|
| 494 | + } else { |
|
| 489 | 495 | try { |
| 490 | 496 | $odfHandler->saveToDisk($file); |
| 491 | - }catch (Exception $e){ |
|
| 497 | + } catch (Exception $e){ |
|
| 492 | 498 | $this->error=$e->getMessage(); |
| 493 | 499 | return -1; |
| 494 | 500 | } |
@@ -496,16 +502,16 @@ discard block |
||
| 496 | 502 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
| 497 | 503 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 498 | 504 | |
| 499 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 500 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 505 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 506 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 507 | + } |
|
| 501 | 508 | |
| 502 | 509 | $odfHandler=null; // Destroy object |
| 503 | 510 | |
| 504 | 511 | $this->result = array('fullpath'=>$file); |
| 505 | 512 | |
| 506 | 513 | return 1; // Success |
| 507 | - } |
|
| 508 | - else |
|
| 514 | + } else |
|
| 509 | 515 | { |
| 510 | 516 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 511 | 517 | return -1; |
@@ -84,7 +84,10 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | // Recupere emetteur |
| 86 | 86 | $this->emetteur=$mysoc; |
| 87 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 87 | + if (! $this->emetteur->country_code) { |
|
| 88 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
| 89 | + } |
|
| 90 | + // By default if not defined |
|
| 88 | 91 | } |
| 89 | 92 | |
| 90 | 93 | |
@@ -122,11 +125,14 @@ discard block |
||
| 122 | 125 | if (! $tmpdir) { |
| 123 | 126 | unset($listofdir[$key]); continue; |
| 124 | 127 | } |
| 125 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 126 | - else |
|
| 128 | + if (! is_dir($tmpdir)) { |
|
| 129 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 130 | + } else |
|
| 127 | 131 | { |
| 128 | 132 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
| 129 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 133 | + if (count($tmpfiles)) { |
|
| 134 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 135 | + } |
|
| 130 | 136 | } |
| 131 | 137 | } |
| 132 | 138 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -207,7 +213,9 @@ discard block |
||
| 207 | 213 | $hookmanager->initHooks(array('odtgeneration')); |
| 208 | 214 | global $action; |
| 209 | 215 | |
| 210 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 216 | + if (! is_object($outputlangs)) { |
|
| 217 | + $outputlangs=$langs; |
|
| 218 | + } |
|
| 211 | 219 | $sav_charset_output=$outputlangs->charset_output; |
| 212 | 220 | $outputlangs->charset_output='UTF-8'; |
| 213 | 221 | |
@@ -233,7 +241,9 @@ discard block |
||
| 233 | 241 | |
| 234 | 242 | $dir = $conf->commande->dir_output; |
| 235 | 243 | $objectref = dol_sanitizeFileName($object->ref); |
| 236 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
| 244 | + if (! preg_match('/specimen/i',$objectref)) { |
|
| 245 | + $dir.= "/" . $objectref; |
|
| 246 | + } |
|
| 237 | 247 | $file = $dir . "/" . $objectref . ".odt"; |
| 238 | 248 | |
| 239 | 249 | if (! file_exists($dir)) |
@@ -259,10 +269,11 @@ discard block |
||
| 259 | 269 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 260 | 270 | { |
| 261 | 271 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
| 262 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 272 | + if ($format == '1') { |
|
| 273 | + $format='%Y%m%d%H%M%S'; |
|
| 274 | + } |
|
| 263 | 275 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 264 | - } |
|
| 265 | - else |
|
| 276 | + } else |
|
| 266 | 277 | { |
| 267 | 278 | $filename=$newfiletmp.'.'.$newfileformat; |
| 268 | 279 | } |
@@ -288,14 +299,14 @@ discard block |
||
| 288 | 299 | if (! empty($usecontact)) |
| 289 | 300 | { |
| 290 | 301 | // On peut utiliser le nom de la societe du contact |
| 291 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
| 292 | - else { |
|
| 302 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
| 303 | + $socobject = $object->contact; |
|
| 304 | + } else { |
|
| 293 | 305 | $socobject = $object->thirdparty; |
| 294 | 306 | // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
| 295 | 307 | $contactobject = $object->contact; |
| 296 | 308 | } |
| 297 | - } |
|
| 298 | - else |
|
| 309 | + } else |
|
| 299 | 310 | { |
| 300 | 311 | $socobject=$object->thirdparty; |
| 301 | 312 | } |
@@ -333,8 +344,7 @@ discard block |
||
| 333 | 344 | 'DELIMITER_RIGHT' => '}' |
| 334 | 345 | ) |
| 335 | 346 | ); |
| 336 | - } |
|
| 337 | - catch(Exception $e) |
|
| 347 | + } catch(Exception $e) |
|
| 338 | 348 | { |
| 339 | 349 | $this->error=$e->getMessage(); |
| 340 | 350 | return -1; |
@@ -349,8 +359,7 @@ discard block |
||
| 349 | 359 | // Make substitutions into odt of freetext |
| 350 | 360 | try { |
| 351 | 361 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
| 352 | - } |
|
| 353 | - catch(OdfException $e) |
|
| 362 | + } catch(OdfException $e) |
|
| 354 | 363 | { |
| 355 | 364 | } |
| 356 | 365 | |
@@ -364,7 +373,9 @@ discard block |
||
| 364 | 373 | $array_other=$this->get_substitutionarray_other($outputlangs); |
| 365 | 374 | // retrieve contact information for use in order as contact_xxx tags |
| 366 | 375 | $array_thirdparty_contact = array(); |
| 367 | - if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 376 | + if ($usecontact) { |
|
| 377 | + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 378 | + } |
|
| 368 | 379 | |
| 369 | 380 | $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); |
| 370 | 381 | complete_substitutions_array($tmparray, $outputlangs, $object); |
@@ -376,17 +387,18 @@ discard block |
||
| 376 | 387 | foreach($tmparray as $key=>$value) |
| 377 | 388 | { |
| 378 | 389 | try { |
| 379 | - if (preg_match('/logo$/',$key)) // Image |
|
| 390 | + if (preg_match('/logo$/',$key)) { |
|
| 391 | + // Image |
|
| 380 | 392 | { |
| 381 | 393 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
| 382 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 383 | - } |
|
| 384 | - else // Text |
|
| 394 | + } else { |
|
| 395 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 396 | + } |
|
| 397 | + } else // Text |
|
| 385 | 398 | { |
| 386 | 399 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 387 | 400 | } |
| 388 | - } |
|
| 389 | - catch(OdfException $e) |
|
| 401 | + } catch(OdfException $e) |
|
| 390 | 402 | { |
| 391 | 403 | } |
| 392 | 404 | } |
@@ -396,8 +408,7 @@ discard block |
||
| 396 | 408 | $foundtagforlines = 1; |
| 397 | 409 | try { |
| 398 | 410 | $listlines = $odfHandler->setSegment('lines'); |
| 399 | - } |
|
| 400 | - catch(OdfException $e) |
|
| 411 | + } catch(OdfException $e) |
|
| 401 | 412 | { |
| 402 | 413 | // We may arrive here if tags for lines not present into template |
| 403 | 414 | $foundtagforlines = 0; |
@@ -417,11 +428,9 @@ discard block |
||
| 417 | 428 | try |
| 418 | 429 | { |
| 419 | 430 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 420 | - } |
|
| 421 | - catch(OdfException $e) |
|
| 431 | + } catch(OdfException $e) |
|
| 422 | 432 | { |
| 423 | - } |
|
| 424 | - catch(SegmentException $e) |
|
| 433 | + } catch(SegmentException $e) |
|
| 425 | 434 | { |
| 426 | 435 | } |
| 427 | 436 | } |
@@ -429,8 +438,7 @@ discard block |
||
| 429 | 438 | } |
| 430 | 439 | $odfHandler->mergeSegment($listlines); |
| 431 | 440 | } |
| 432 | - } |
|
| 433 | - catch(OdfException $e) |
|
| 441 | + } catch(OdfException $e) |
|
| 434 | 442 | { |
| 435 | 443 | $this->error=$e->getMessage(); |
| 436 | 444 | dol_syslog($this->error, LOG_WARNING); |
@@ -443,8 +451,7 @@ discard block |
||
| 443 | 451 | { |
| 444 | 452 | try { |
| 445 | 453 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 446 | - } |
|
| 447 | - catch(OdfException $e) |
|
| 454 | + } catch(OdfException $e) |
|
| 448 | 455 | { |
| 449 | 456 | } |
| 450 | 457 | } |
@@ -458,15 +465,14 @@ discard block |
||
| 458 | 465 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
| 459 | 466 | try { |
| 460 | 467 | $odfHandler->exportAsAttachedPDF($file); |
| 461 | - }catch (Exception $e){ |
|
| 468 | + } catch (Exception $e){ |
|
| 462 | 469 | $this->error=$e->getMessage(); |
| 463 | 470 | return -1; |
| 464 | 471 | } |
| 465 | - } |
|
| 466 | - else { |
|
| 472 | + } else { |
|
| 467 | 473 | try { |
| 468 | 474 | $odfHandler->saveToDisk($file); |
| 469 | - }catch (Exception $e){ |
|
| 475 | + } catch (Exception $e){ |
|
| 470 | 476 | $this->error=$e->getMessage(); |
| 471 | 477 | return -1; |
| 472 | 478 | } |
@@ -475,16 +481,16 @@ discard block |
||
| 475 | 481 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
| 476 | 482 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 477 | 483 | |
| 478 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 479 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 484 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 485 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 486 | + } |
|
| 480 | 487 | |
| 481 | 488 | $odfHandler=null; // Destroy object |
| 482 | 489 | |
| 483 | 490 | $this->result = array('fullpath'=>$file); |
| 484 | 491 | |
| 485 | 492 | return 1; // Success |
| 486 | - } |
|
| 487 | - else |
|
| 493 | + } else |
|
| 488 | 494 | { |
| 489 | 495 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 490 | 496 | return -1; |
@@ -83,7 +83,10 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | // Recupere emetteur |
| 85 | 85 | $this->emetteur=$mysoc; |
| 86 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 86 | + if (! $this->emetteur->country_code) { |
|
| 87 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
| 88 | + } |
|
| 89 | + // By default if not defined |
|
| 87 | 90 | } |
| 88 | 91 | |
| 89 | 92 | |
@@ -127,11 +130,14 @@ discard block |
||
| 127 | 130 | if (! $tmpdir) { |
| 128 | 131 | unset($listofdir[$key]); continue; |
| 129 | 132 | } |
| 130 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 131 | - else |
|
| 133 | + if (! is_dir($tmpdir)) { |
|
| 134 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 135 | + } else |
|
| 132 | 136 | { |
| 133 | 137 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
| 134 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 138 | + if (count($tmpfiles)) { |
|
| 139 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 140 | + } |
|
| 135 | 141 | } |
| 136 | 142 | } |
| 137 | 143 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -237,7 +243,9 @@ discard block |
||
| 237 | 243 | $hookmanager->initHooks(array('odtgeneration')); |
| 238 | 244 | global $action; |
| 239 | 245 | |
| 240 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 246 | + if (! is_object($outputlangs)) { |
|
| 247 | + $outputlangs=$langs; |
|
| 248 | + } |
|
| 241 | 249 | $sav_charset_output=$outputlangs->charset_output; |
| 242 | 250 | $outputlangs->charset_output='UTF-8'; |
| 243 | 251 | |
@@ -263,7 +271,9 @@ discard block |
||
| 263 | 271 | |
| 264 | 272 | $dir = $conf->propal->dir_output; |
| 265 | 273 | $objectref = dol_sanitizeFileName($object->ref); |
| 266 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
| 274 | + if (! preg_match('/specimen/i',$objectref)) { |
|
| 275 | + $dir.= "/" . $objectref; |
|
| 276 | + } |
|
| 267 | 277 | $file = $dir . "/" . $objectref . ".odt"; |
| 268 | 278 | |
| 269 | 279 | if (! file_exists($dir)) |
@@ -290,10 +300,11 @@ discard block |
||
| 290 | 300 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 291 | 301 | { |
| 292 | 302 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
| 293 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 303 | + if ($format == '1') { |
|
| 304 | + $format='%Y%m%d%H%M%S'; |
|
| 305 | + } |
|
| 294 | 306 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 295 | - } |
|
| 296 | - else |
|
| 307 | + } else |
|
| 297 | 308 | { |
| 298 | 309 | $filename=$newfiletmp.'.'.$newfileformat; |
| 299 | 310 | } |
@@ -319,14 +330,14 @@ discard block |
||
| 319 | 330 | if (! empty($usecontact)) |
| 320 | 331 | { |
| 321 | 332 | // On peut utiliser le nom de la societe du contact |
| 322 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
| 323 | - else { |
|
| 333 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
| 334 | + $socobject = $object->contact; |
|
| 335 | + } else { |
|
| 324 | 336 | $socobject = $object->thirdparty; |
| 325 | 337 | // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
| 326 | 338 | $contactobject = $object->contact; |
| 327 | 339 | } |
| 328 | - } |
|
| 329 | - else |
|
| 340 | + } else |
|
| 330 | 341 | { |
| 331 | 342 | $socobject=$object->thirdparty; |
| 332 | 343 | } |
@@ -363,8 +374,7 @@ discard block |
||
| 363 | 374 | 'DELIMITER_RIGHT' => '}' |
| 364 | 375 | ) |
| 365 | 376 | ); |
| 366 | - } |
|
| 367 | - catch(Exception $e) |
|
| 377 | + } catch(Exception $e) |
|
| 368 | 378 | { |
| 369 | 379 | $this->error=$e->getMessage(); |
| 370 | 380 | return -1; |
@@ -380,8 +390,7 @@ discard block |
||
| 380 | 390 | // Make substitutions into odt of freetext |
| 381 | 391 | try { |
| 382 | 392 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
| 383 | - } |
|
| 384 | - catch(OdfException $e) |
|
| 393 | + } catch(OdfException $e) |
|
| 385 | 394 | { |
| 386 | 395 | } |
| 387 | 396 | |
@@ -395,7 +404,9 @@ discard block |
||
| 395 | 404 | $array_other=$this->get_substitutionarray_other($outputlangs); |
| 396 | 405 | // retrieve contact information for use in proposal as contact_xxx tags |
| 397 | 406 | $array_thirdparty_contact = array(); |
| 398 | - if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 407 | + if ($usecontact) { |
|
| 408 | + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 409 | + } |
|
| 399 | 410 | |
| 400 | 411 | $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); |
| 401 | 412 | complete_substitutions_array($tmparray, $outputlangs, $object); |
@@ -407,17 +418,18 @@ discard block |
||
| 407 | 418 | foreach($tmparray as $key=>$value) |
| 408 | 419 | { |
| 409 | 420 | try { |
| 410 | - if (preg_match('/logo$/',$key)) // Image |
|
| 421 | + if (preg_match('/logo$/',$key)) { |
|
| 422 | + // Image |
|
| 411 | 423 | { |
| 412 | 424 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
| 413 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 414 | - } |
|
| 415 | - else // Text |
|
| 425 | + } else { |
|
| 426 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 427 | + } |
|
| 428 | + } else // Text |
|
| 416 | 429 | { |
| 417 | 430 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 418 | 431 | } |
| 419 | - } |
|
| 420 | - catch(OdfException $e) |
|
| 432 | + } catch(OdfException $e) |
|
| 421 | 433 | { |
| 422 | 434 | } |
| 423 | 435 | } |
@@ -427,8 +439,7 @@ discard block |
||
| 427 | 439 | $foundtagforlines = 1; |
| 428 | 440 | try { |
| 429 | 441 | $listlines = $odfHandler->setSegment('lines'); |
| 430 | - } |
|
| 431 | - catch(OdfException $e) |
|
| 442 | + } catch(OdfException $e) |
|
| 432 | 443 | { |
| 433 | 444 | // We may arrive here if tags for lines not present into template |
| 434 | 445 | $foundtagforlines = 0; |
@@ -448,11 +459,9 @@ discard block |
||
| 448 | 459 | try |
| 449 | 460 | { |
| 450 | 461 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 451 | - } |
|
| 452 | - catch(OdfException $e) |
|
| 462 | + } catch(OdfException $e) |
|
| 453 | 463 | { |
| 454 | - } |
|
| 455 | - catch(SegmentException $e) |
|
| 464 | + } catch(SegmentException $e) |
|
| 456 | 465 | { |
| 457 | 466 | } |
| 458 | 467 | } |
@@ -460,8 +469,7 @@ discard block |
||
| 460 | 469 | } |
| 461 | 470 | $odfHandler->mergeSegment($listlines); |
| 462 | 471 | } |
| 463 | - } |
|
| 464 | - catch(OdfException $e) |
|
| 472 | + } catch(OdfException $e) |
|
| 465 | 473 | { |
| 466 | 474 | $this->error=$e->getMessage(); |
| 467 | 475 | dol_syslog($this->error, LOG_WARNING); |
@@ -474,8 +482,7 @@ discard block |
||
| 474 | 482 | { |
| 475 | 483 | try { |
| 476 | 484 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 477 | - } |
|
| 478 | - catch(OdfException $e) |
|
| 485 | + } catch(OdfException $e) |
|
| 479 | 486 | { |
| 480 | 487 | } |
| 481 | 488 | } |
@@ -488,15 +495,14 @@ discard block |
||
| 488 | 495 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
| 489 | 496 | try { |
| 490 | 497 | $odfHandler->exportAsAttachedPDF($file); |
| 491 | - }catch (Exception $e){ |
|
| 498 | + } catch (Exception $e){ |
|
| 492 | 499 | $this->error=$e->getMessage(); |
| 493 | 500 | return -1; |
| 494 | 501 | } |
| 495 | - } |
|
| 496 | - else { |
|
| 502 | + } else { |
|
| 497 | 503 | try { |
| 498 | 504 | $odfHandler->saveToDisk($file); |
| 499 | - }catch (Exception $e){ |
|
| 505 | + } catch (Exception $e){ |
|
| 500 | 506 | $this->error=$e->getMessage(); |
| 501 | 507 | return -1; |
| 502 | 508 | } |
@@ -504,16 +510,16 @@ discard block |
||
| 504 | 510 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
| 505 | 511 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 506 | 512 | |
| 507 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 508 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 513 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 514 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 515 | + } |
|
| 509 | 516 | |
| 510 | 517 | $odfHandler=null; // Destroy object |
| 511 | 518 | |
| 512 | 519 | $this->result = array('fullpath'=>$file); |
| 513 | 520 | |
| 514 | 521 | return 1; // Success |
| 515 | - } |
|
| 516 | - else |
|
| 522 | + } else |
|
| 517 | 523 | { |
| 518 | 524 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 519 | 525 | return -1; |
@@ -82,7 +82,10 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | // Recupere emetteur |
| 84 | 84 | $this->emetteur=$mysoc; |
| 85 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 85 | + if (! $this->emetteur->country_code) { |
|
| 86 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
| 87 | + } |
|
| 88 | + // By default if not defined |
|
| 86 | 89 | } |
| 87 | 90 | |
| 88 | 91 | |
@@ -126,11 +129,14 @@ discard block |
||
| 126 | 129 | if (! $tmpdir) { |
| 127 | 130 | unset($listofdir[$key]); continue; |
| 128 | 131 | } |
| 129 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 130 | - else |
|
| 132 | + if (! is_dir($tmpdir)) { |
|
| 133 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 134 | + } else |
|
| 131 | 135 | { |
| 132 | 136 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
| 133 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 137 | + if (count($tmpfiles)) { |
|
| 138 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 139 | + } |
|
| 134 | 140 | } |
| 135 | 141 | } |
| 136 | 142 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -221,7 +227,9 @@ discard block |
||
| 221 | 227 | $hookmanager->initHooks(array('odtgeneration')); |
| 222 | 228 | global $action; |
| 223 | 229 | |
| 224 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 230 | + if (! is_object($outputlangs)) { |
|
| 231 | + $outputlangs=$langs; |
|
| 232 | + } |
|
| 225 | 233 | $sav_charset_output=$outputlangs->charset_output; |
| 226 | 234 | $outputlangs->charset_output='UTF-8'; |
| 227 | 235 | |
@@ -249,7 +257,9 @@ discard block |
||
| 249 | 257 | |
| 250 | 258 | $dir = $conf->produit->dir_output; |
| 251 | 259 | $objectref = dol_sanitizeFileName($object->ref); |
| 252 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
| 260 | + if (! preg_match('/specimen/i',$objectref)) { |
|
| 261 | + $dir.= "/" . $objectref; |
|
| 262 | + } |
|
| 253 | 263 | $file = $dir . "/" . $objectref . ".odt"; |
| 254 | 264 | |
| 255 | 265 | if (! file_exists($dir)) |
@@ -276,10 +286,11 @@ discard block |
||
| 276 | 286 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 277 | 287 | { |
| 278 | 288 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
| 279 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 289 | + if ($format == '1') { |
|
| 290 | + $format='%Y%m%d%H%M%S'; |
|
| 291 | + } |
|
| 280 | 292 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 281 | - } |
|
| 282 | - else |
|
| 293 | + } else |
|
| 283 | 294 | { |
| 284 | 295 | $filename=$newfiletmp.'.'.$newfileformat; |
| 285 | 296 | } |
@@ -305,14 +316,14 @@ discard block |
||
| 305 | 316 | if (! empty($usecontact)) |
| 306 | 317 | { |
| 307 | 318 | // On peut utiliser le nom de la societe du contact |
| 308 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
| 309 | - else { |
|
| 319 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
| 320 | + $socobject = $object->contact; |
|
| 321 | + } else { |
|
| 310 | 322 | $socobject = $object->thirdparty; |
| 311 | 323 | // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
| 312 | 324 | $contactobject = $object->contact; |
| 313 | 325 | } |
| 314 | - } |
|
| 315 | - else |
|
| 326 | + } else |
|
| 316 | 327 | { |
| 317 | 328 | $socobject=$object->thirdparty; |
| 318 | 329 | } |
@@ -349,8 +360,7 @@ discard block |
||
| 349 | 360 | 'DELIMITER_RIGHT' => '}' |
| 350 | 361 | ) |
| 351 | 362 | ); |
| 352 | - } |
|
| 353 | - catch(Exception $e) |
|
| 363 | + } catch(Exception $e) |
|
| 354 | 364 | { |
| 355 | 365 | $this->error=$e->getMessage(); |
| 356 | 366 | return -1; |
@@ -366,8 +376,7 @@ discard block |
||
| 366 | 376 | // Make substitutions into odt of freetext |
| 367 | 377 | try { |
| 368 | 378 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
| 369 | - } |
|
| 370 | - catch(OdfException $e) |
|
| 379 | + } catch(OdfException $e) |
|
| 371 | 380 | { |
| 372 | 381 | } |
| 373 | 382 | |
@@ -381,7 +390,9 @@ discard block |
||
| 381 | 390 | $array_other=$this->get_substitutionarray_other($outputlangs); |
| 382 | 391 | // retrieve contact information for use in product as contact_xxx tags |
| 383 | 392 | $array_thirdparty_contact = array(); |
| 384 | - if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 393 | + if ($usecontact) { |
|
| 394 | + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 395 | + } |
|
| 385 | 396 | |
| 386 | 397 | $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact); |
| 387 | 398 | complete_substitutions_array($tmparray, $outputlangs, $object); |
@@ -393,17 +404,18 @@ discard block |
||
| 393 | 404 | foreach($tmparray as $key=>$value) |
| 394 | 405 | { |
| 395 | 406 | try { |
| 396 | - if (preg_match('/logo$/',$key)) // Image |
|
| 407 | + if (preg_match('/logo$/',$key)) { |
|
| 408 | + // Image |
|
| 397 | 409 | { |
| 398 | 410 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
| 399 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 400 | - } |
|
| 401 | - else // Text |
|
| 411 | + } else { |
|
| 412 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 413 | + } |
|
| 414 | + } else // Text |
|
| 402 | 415 | { |
| 403 | 416 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 404 | 417 | } |
| 405 | - } |
|
| 406 | - catch(OdfException $e) |
|
| 418 | + } catch(OdfException $e) |
|
| 407 | 419 | { |
| 408 | 420 | } |
| 409 | 421 | } |
@@ -424,11 +436,9 @@ discard block |
||
| 424 | 436 | try |
| 425 | 437 | { |
| 426 | 438 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 427 | - } |
|
| 428 | - catch(OdfException $e) |
|
| 439 | + } catch(OdfException $e) |
|
| 429 | 440 | { |
| 430 | - } |
|
| 431 | - catch(SegmentException $e) |
|
| 441 | + } catch(SegmentException $e) |
|
| 432 | 442 | { |
| 433 | 443 | } |
| 434 | 444 | } |
@@ -436,8 +446,7 @@ discard block |
||
| 436 | 446 | } |
| 437 | 447 | } |
| 438 | 448 | $odfHandler->mergeSegment($listlines); |
| 439 | - } |
|
| 440 | - catch(OdfException $e) |
|
| 449 | + } catch(OdfException $e) |
|
| 441 | 450 | { |
| 442 | 451 | $this->error=$e->getMessage(); |
| 443 | 452 | dol_syslog($this->error, LOG_WARNING); |
@@ -450,8 +459,7 @@ discard block |
||
| 450 | 459 | { |
| 451 | 460 | try { |
| 452 | 461 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 453 | - } |
|
| 454 | - catch(OdfException $e) |
|
| 462 | + } catch(OdfException $e) |
|
| 455 | 463 | { |
| 456 | 464 | } |
| 457 | 465 | } |
@@ -464,15 +472,14 @@ discard block |
||
| 464 | 472 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
| 465 | 473 | try { |
| 466 | 474 | $odfHandler->exportAsAttachedPDF($file); |
| 467 | - }catch (Exception $e){ |
|
| 475 | + } catch (Exception $e){ |
|
| 468 | 476 | $this->error=$e->getMessage(); |
| 469 | 477 | return -1; |
| 470 | 478 | } |
| 471 | - } |
|
| 472 | - else { |
|
| 479 | + } else { |
|
| 473 | 480 | try { |
| 474 | 481 | $odfHandler->saveToDisk($file); |
| 475 | - }catch (Exception $e){ |
|
| 482 | + } catch (Exception $e){ |
|
| 476 | 483 | $this->error=$e->getMessage(); |
| 477 | 484 | return -1; |
| 478 | 485 | } |
@@ -480,16 +487,16 @@ discard block |
||
| 480 | 487 | |
| 481 | 488 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 482 | 489 | |
| 483 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 484 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 490 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 491 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 492 | + } |
|
| 485 | 493 | |
| 486 | 494 | $odfHandler=null; // Destroy object |
| 487 | 495 | |
| 488 | 496 | $this->result = array('fullpath'=>$file); |
| 489 | 497 | |
| 490 | 498 | return 1; // Success |
| 491 | - } |
|
| 492 | - else |
|
| 499 | + } else |
|
| 493 | 500 | { |
| 494 | 501 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 495 | 502 | return -1; |
@@ -83,7 +83,10 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | // Recupere emetteur |
| 85 | 85 | $this->emetteur=$mysoc; |
| 86 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 86 | + if (! $this->emetteur->country_code) { |
|
| 87 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
| 88 | + } |
|
| 89 | + // By default if not defined |
|
| 87 | 90 | } |
| 88 | 91 | |
| 89 | 92 | |
@@ -127,11 +130,14 @@ discard block |
||
| 127 | 130 | if (! $tmpdir) { |
| 128 | 131 | unset($listofdir[$key]); continue; |
| 129 | 132 | } |
| 130 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 131 | - else |
|
| 133 | + if (! is_dir($tmpdir)) { |
|
| 134 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 135 | + } else |
|
| 132 | 136 | { |
| 133 | 137 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
| 134 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 138 | + if (count($tmpfiles)) { |
|
| 139 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 140 | + } |
|
| 135 | 141 | } |
| 136 | 142 | } |
| 137 | 143 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -222,7 +228,9 @@ discard block |
||
| 222 | 228 | $hookmanager->initHooks(array('odtgeneration')); |
| 223 | 229 | global $action; |
| 224 | 230 | |
| 225 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 231 | + if (! is_object($outputlangs)) { |
|
| 232 | + $outputlangs=$langs; |
|
| 233 | + } |
|
| 226 | 234 | $sav_charset_output=$outputlangs->charset_output; |
| 227 | 235 | $outputlangs->charset_output='UTF-8'; |
| 228 | 236 | |
@@ -248,7 +256,9 @@ discard block |
||
| 248 | 256 | |
| 249 | 257 | $dir = $conf->usergroup->dir_output; |
| 250 | 258 | $objectref = dol_sanitizeFileName($object->ref); |
| 251 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
| 259 | + if (! preg_match('/specimen/i',$objectref)) { |
|
| 260 | + $dir.= "/" . $objectref; |
|
| 261 | + } |
|
| 252 | 262 | $file = $dir . "/" . $objectref . ".odt"; |
| 253 | 263 | |
| 254 | 264 | if (! file_exists($dir)) |
@@ -275,10 +285,11 @@ discard block |
||
| 275 | 285 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 276 | 286 | { |
| 277 | 287 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
| 278 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 288 | + if ($format == '1') { |
|
| 289 | + $format='%Y%m%d%H%M%S'; |
|
| 290 | + } |
|
| 279 | 291 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 280 | - } |
|
| 281 | - else |
|
| 292 | + } else |
|
| 282 | 293 | { |
| 283 | 294 | $filename=$newfiletmp.'.'.$newfileformat; |
| 284 | 295 | } |
@@ -304,14 +315,14 @@ discard block |
||
| 304 | 315 | if (! empty($usecontact)) |
| 305 | 316 | { |
| 306 | 317 | // On peut utiliser le nom de la societe du contact |
| 307 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
| 308 | - else { |
|
| 318 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
| 319 | + $socobject = $object->contact; |
|
| 320 | + } else { |
|
| 309 | 321 | $socobject = $object->thirdparty; |
| 310 | 322 | // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
| 311 | 323 | $contactobject = $object->contact; |
| 312 | 324 | } |
| 313 | - } |
|
| 314 | - else |
|
| 325 | + } else |
|
| 315 | 326 | { |
| 316 | 327 | $socobject=$object->thirdparty; |
| 317 | 328 | } |
@@ -348,8 +359,7 @@ discard block |
||
| 348 | 359 | 'DELIMITER_RIGHT' => '}' |
| 349 | 360 | ) |
| 350 | 361 | ); |
| 351 | - } |
|
| 352 | - catch(Exception $e) |
|
| 362 | + } catch(Exception $e) |
|
| 353 | 363 | { |
| 354 | 364 | $this->error=$e->getMessage(); |
| 355 | 365 | return -1; |
@@ -364,8 +374,7 @@ discard block |
||
| 364 | 374 | // Make substitutions into odt of freetext |
| 365 | 375 | try { |
| 366 | 376 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
| 367 | - } |
|
| 368 | - catch(OdfException $e) |
|
| 377 | + } catch(OdfException $e) |
|
| 369 | 378 | { |
| 370 | 379 | } |
| 371 | 380 | |
@@ -378,8 +387,9 @@ discard block |
||
| 378 | 387 | $array_other=$this->get_substitutionarray_other($outputlangs); |
| 379 | 388 | // retrieve contact information for use in user as contact_xxx tags |
| 380 | 389 | $array_thirdparty_contact = array(); |
| 381 | - if ($usecontact) |
|
| 382 | - $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 390 | + if ($usecontact) { |
|
| 391 | + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 392 | + } |
|
| 383 | 393 | |
| 384 | 394 | $tmparray = array_merge($array_global,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); |
| 385 | 395 | complete_substitutions_array($tmparray, $outputlangs, $object); |
@@ -391,17 +401,18 @@ discard block |
||
| 391 | 401 | { |
| 392 | 402 | try |
| 393 | 403 | { |
| 394 | - if (preg_match('/logo$/',$key)) // Image |
|
| 404 | + if (preg_match('/logo$/',$key)) { |
|
| 405 | + // Image |
|
| 395 | 406 | { |
| 396 | 407 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
| 397 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 398 | - } |
|
| 399 | - else // Text |
|
| 408 | + } else { |
|
| 409 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 410 | + } |
|
| 411 | + } else // Text |
|
| 400 | 412 | { |
| 401 | 413 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 402 | 414 | } |
| 403 | - } |
|
| 404 | - catch(OdfException $e) |
|
| 415 | + } catch(OdfException $e) |
|
| 405 | 416 | { |
| 406 | 417 | } |
| 407 | 418 | } |
@@ -411,8 +422,7 @@ discard block |
||
| 411 | 422 | $foundtagforlines = 1; |
| 412 | 423 | try { |
| 413 | 424 | $listlines = $odfHandler->setSegment('lines'); |
| 414 | - } |
|
| 415 | - catch(OdfException $e) |
|
| 425 | + } catch(OdfException $e) |
|
| 416 | 426 | { |
| 417 | 427 | // We may arrive here if tags for lines not present into template |
| 418 | 428 | $foundtagforlines = 0; |
@@ -436,11 +446,9 @@ discard block |
||
| 436 | 446 | if(!is_array($val)) { |
| 437 | 447 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 438 | 448 | } |
| 439 | - } |
|
| 440 | - catch(OdfException $e) |
|
| 449 | + } catch(OdfException $e) |
|
| 441 | 450 | { |
| 442 | - } |
|
| 443 | - catch(SegmentException $e) |
|
| 451 | + } catch(SegmentException $e) |
|
| 444 | 452 | { |
| 445 | 453 | } |
| 446 | 454 | } |
@@ -448,8 +456,7 @@ discard block |
||
| 448 | 456 | } |
| 449 | 457 | $odfHandler->mergeSegment($listlines); |
| 450 | 458 | } |
| 451 | - } |
|
| 452 | - catch(OdfException $e) |
|
| 459 | + } catch(OdfException $e) |
|
| 453 | 460 | { |
| 454 | 461 | $this->error=$e->getMessage(); |
| 455 | 462 | dol_syslog($this->error, LOG_WARNING); |
@@ -462,8 +469,7 @@ discard block |
||
| 462 | 469 | { |
| 463 | 470 | try { |
| 464 | 471 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 465 | - } |
|
| 466 | - catch(OdfException $e) |
|
| 472 | + } catch(OdfException $e) |
|
| 467 | 473 | { |
| 468 | 474 | } |
| 469 | 475 | } |
@@ -476,15 +482,14 @@ discard block |
||
| 476 | 482 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
| 477 | 483 | try { |
| 478 | 484 | $odfHandler->exportAsAttachedPDF($file); |
| 479 | - }catch (Exception $e){ |
|
| 485 | + } catch (Exception $e){ |
|
| 480 | 486 | $this->error=$e->getMessage(); |
| 481 | 487 | return -1; |
| 482 | 488 | } |
| 483 | - } |
|
| 484 | - else { |
|
| 489 | + } else { |
|
| 485 | 490 | try { |
| 486 | 491 | $odfHandler->saveToDisk($file); |
| 487 | - }catch (Exception $e){ |
|
| 492 | + } catch (Exception $e){ |
|
| 488 | 493 | $this->error=$e->getMessage(); |
| 489 | 494 | return -1; |
| 490 | 495 | } |
@@ -492,16 +497,16 @@ discard block |
||
| 492 | 497 | |
| 493 | 498 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 494 | 499 | |
| 495 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 496 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 500 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 501 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 502 | + } |
|
| 497 | 503 | |
| 498 | 504 | $odfHandler=null; // Destroy object |
| 499 | 505 | |
| 500 | 506 | $this->result = array('fullpath'=>$file); |
| 501 | 507 | |
| 502 | 508 | return 1; // Success |
| 503 | - } |
|
| 504 | - else |
|
| 509 | + } else |
|
| 505 | 510 | { |
| 506 | 511 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 507 | 512 | return -1; |