@@ -98,7 +98,10 @@ discard block |
||
98 | 98 | |
99 | 99 | // Recupere emetteur |
100 | 100 | $this->emetteur=$mysoc; |
101 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // Par defaut, si n'etait pas defini |
|
101 | + if (! $this->emetteur->country_code) { |
|
102 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
103 | + } |
|
104 | + // Par defaut, si n'etait pas defini |
|
102 | 105 | } |
103 | 106 | |
104 | 107 | |
@@ -136,11 +139,14 @@ discard block |
||
136 | 139 | if (! $tmpdir) { |
137 | 140 | unset($listofdir[$key]); continue; |
138 | 141 | } |
139 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
140 | - else |
|
142 | + if (! is_dir($tmpdir)) { |
|
143 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
144 | + } else |
|
141 | 145 | { |
142 | 146 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
143 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
147 | + if (count($tmpfiles)) { |
|
148 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
149 | + } |
|
144 | 150 | } |
145 | 151 | } |
146 | 152 | $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 | |
@@ -246,7 +254,9 @@ discard block |
||
246 | 254 | |
247 | 255 | $dir = $conf->facture->dir_output; |
248 | 256 | $objectref = dol_sanitizeFileName($object->ref); |
249 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
257 | + if (! preg_match('/specimen/i',$objectref)) { |
|
258 | + $dir.= "/" . $objectref; |
|
259 | + } |
|
250 | 260 | $file = $dir . "/" . $objectref . ".odt"; |
251 | 261 | |
252 | 262 | 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 | } |
@@ -303,9 +314,9 @@ discard block |
||
303 | 314 | $contactobject = null; |
304 | 315 | if (! empty($usecontact)) { |
305 | 316 | // On peut utiliser le nom de la societe du contact |
306 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) |
|
307 | - $socobject = $object->contact; |
|
308 | - else { |
|
317 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
318 | + $socobject = $object->contact; |
|
319 | + } else { |
|
309 | 320 | $socobject = $object->thirdparty; |
310 | 321 | // if we have a BILLING contact and we dont use it as recipient we store the contact object for later use |
311 | 322 | $contactobject = $object->contact; |
@@ -353,8 +364,7 @@ discard block |
||
353 | 364 | 'DELIMITER_RIGHT' => '}' |
354 | 365 | ) |
355 | 366 | ); |
356 | - } |
|
357 | - catch (Exception $e) |
|
367 | + } catch (Exception $e) |
|
358 | 368 | { |
359 | 369 | $this->error=$e->getMessage(); |
360 | 370 | dol_syslog($e->getMessage(), LOG_INFO); |
@@ -370,8 +380,7 @@ discard block |
||
370 | 380 | // Make substitutions into odt of freetext |
371 | 381 | try { |
372 | 382 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
373 | - } |
|
374 | - catch (OdfException $e) |
|
383 | + } catch (OdfException $e) |
|
375 | 384 | { |
376 | 385 | dol_syslog($e->getMessage(), LOG_INFO); |
377 | 386 | } |
@@ -387,7 +396,9 @@ discard block |
||
387 | 396 | $array_other=$this->get_substitutionarray_other($outputlangs); |
388 | 397 | // retrieve contact information for use in object as contact_xxx tags |
389 | 398 | $array_thirdparty_contact = array(); |
390 | - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
399 | + if ($usecontact && is_object($contactobject)) { |
|
400 | + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
401 | + } |
|
391 | 402 | |
392 | 403 | $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal,$array_other,$array_thirdparty_contact); |
393 | 404 | complete_substitutions_array($tmparray, $outputlangs, $object); |
@@ -400,18 +411,19 @@ discard block |
||
400 | 411 | foreach($tmparray as $key=>$value) |
401 | 412 | { |
402 | 413 | try { |
403 | - if (preg_match('/logo$/',$key)) // Image |
|
414 | + if (preg_match('/logo$/',$key)) { |
|
415 | + // Image |
|
404 | 416 | { |
405 | 417 | //var_dump($value);exit; |
406 | 418 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
407 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
408 | - } |
|
409 | - else // Text |
|
419 | + } else { |
|
420 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
421 | + } |
|
422 | + } else // Text |
|
410 | 423 | { |
411 | 424 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
412 | 425 | } |
413 | - } |
|
414 | - catch (OdfException $e) |
|
426 | + } catch (OdfException $e) |
|
415 | 427 | { |
416 | 428 | dol_syslog($e->getMessage(), LOG_INFO); |
417 | 429 | } |
@@ -422,8 +434,7 @@ discard block |
||
422 | 434 | $foundtagforlines = 1; |
423 | 435 | try { |
424 | 436 | $listlines = $odfHandler->setSegment('lines'); |
425 | - } |
|
426 | - catch(OdfException $e) |
|
437 | + } catch(OdfException $e) |
|
427 | 438 | { |
428 | 439 | // We may arrive here if tags for lines not present into template |
429 | 440 | $foundtagforlines = 0; |
@@ -443,12 +454,10 @@ discard block |
||
443 | 454 | try |
444 | 455 | { |
445 | 456 | $listlines->setVars($key, $val, true, 'UTF-8'); |
446 | - } |
|
447 | - catch(OdfException $e) |
|
457 | + } catch(OdfException $e) |
|
448 | 458 | { |
449 | 459 | dol_syslog($e->getMessage(), LOG_INFO); |
450 | - } |
|
451 | - catch(SegmentException $e) |
|
460 | + } catch(SegmentException $e) |
|
452 | 461 | { |
453 | 462 | dol_syslog($e->getMessage(), LOG_INFO); |
454 | 463 | } |
@@ -457,8 +466,7 @@ discard block |
||
457 | 466 | } |
458 | 467 | $odfHandler->mergeSegment($listlines); |
459 | 468 | } |
460 | - } |
|
461 | - catch(OdfException $e) |
|
469 | + } catch(OdfException $e) |
|
462 | 470 | { |
463 | 471 | $this->error=$e->getMessage(); |
464 | 472 | dol_syslog($this->error, LOG_WARNING); |
@@ -471,8 +479,7 @@ discard block |
||
471 | 479 | { |
472 | 480 | try { |
473 | 481 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
474 | - } |
|
475 | - catch(OdfException $e) |
|
482 | + } catch(OdfException $e) |
|
476 | 483 | { |
477 | 484 | dol_syslog($e->getMessage(), LOG_INFO); |
478 | 485 | } |
@@ -486,13 +493,12 @@ discard block |
||
486 | 493 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
487 | 494 | try { |
488 | 495 | $odfHandler->exportAsAttachedPDF($file); |
489 | - }catch (Exception $e){ |
|
496 | + } catch (Exception $e){ |
|
490 | 497 | $this->error=$e->getMessage(); |
491 | 498 | dol_syslog($e->getMessage(), LOG_INFO); |
492 | 499 | return -1; |
493 | 500 | } |
494 | - } |
|
495 | - else { |
|
501 | + } else { |
|
496 | 502 | try { |
497 | 503 | $odfHandler->saveToDisk($file); |
498 | 504 | } catch (Exception $e) { |
@@ -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; |
@@ -175,7 +175,10 @@ discard block |
||
175 | 175 | |
176 | 176 | // Get source company |
177 | 177 | $this->emetteur=$mysoc; |
178 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
178 | + if (empty($this->emetteur->country_code)) { |
|
179 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
180 | + } |
|
181 | + // By default, if was not defined |
|
179 | 182 | |
180 | 183 | // Define position of columns |
181 | 184 | $this->posxdesc=$this->marge_gauche+1; |
@@ -185,8 +188,7 @@ discard block |
||
185 | 188 | $this->posxup=118; |
186 | 189 | $this->posxqty=135; |
187 | 190 | $this->posxunit=151; |
188 | - } |
|
189 | - else |
|
191 | + } else |
|
190 | 192 | { |
191 | 193 | $this->posxtva=110; |
192 | 194 | $this->posxup=126; |
@@ -195,11 +197,15 @@ discard block |
||
195 | 197 | $this->posxdiscount=162; |
196 | 198 | $this->posxprogress=126; // Only displayed for situation invoices |
197 | 199 | $this->postotalht=174; |
198 | - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup; |
|
200 | + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { |
|
201 | + $this->posxtva=$this->posxup; |
|
202 | + } |
|
199 | 203 | $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
200 | - if ($this->page_largeur < 210) // To work with US executive format |
|
204 | + if ($this->page_largeur < 210) { |
|
205 | + // To work with US executive format |
|
201 | 206 | { |
202 | 207 | $this->posxpicture-=20; |
208 | + } |
|
203 | 209 | $this->posxtva-=20; |
204 | 210 | $this->posxup-=20; |
205 | 211 | $this->posxqty-=20; |
@@ -235,9 +241,13 @@ discard block |
||
235 | 241 | // phpcs:enable |
236 | 242 | global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes; |
237 | 243 | |
238 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
244 | + if (! is_object($outputlangs)) { |
|
245 | + $outputlangs=$langs; |
|
246 | + } |
|
239 | 247 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
240 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
248 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
249 | + $outputlangs->charset_output='ISO-8859-1'; |
|
250 | + } |
|
241 | 251 | |
242 | 252 | // Load traductions files requiredby by page |
243 | 253 | $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies")); |
@@ -250,7 +260,9 @@ discard block |
||
250 | 260 | { |
251 | 261 | for ($i = 0 ; $i < $nblignes ; $i++) |
252 | 262 | { |
253 | - if (empty($object->lines[$i]->fk_product)) continue; |
|
263 | + if (empty($object->lines[$i]->fk_product)) { |
|
264 | + continue; |
|
265 | + } |
|
254 | 266 | |
255 | 267 | $objphoto = new Product($this->db); |
256 | 268 | $objphoto->fetch($object->lines[$i]->fk_product); |
@@ -267,10 +279,14 @@ discard block |
||
267 | 279 | break; |
268 | 280 | } |
269 | 281 | |
270 | - if ($realpath) $realpatharray[$i]=$realpath; |
|
282 | + if ($realpath) { |
|
283 | + $realpatharray[$i]=$realpath; |
|
284 | + } |
|
271 | 285 | } |
272 | 286 | } |
273 | - if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; |
|
287 | + if (count($realpatharray) == 0) { |
|
288 | + $this->posxpicture=$this->posxtva; |
|
289 | + } |
|
274 | 290 | |
275 | 291 | if ($conf->facture->dir_output) |
276 | 292 | { |
@@ -285,8 +301,7 @@ discard block |
||
285 | 301 | { |
286 | 302 | $dir = $conf->facture->dir_output; |
287 | 303 | $file = $dir . "/SPECIMEN.pdf"; |
288 | - } |
|
289 | - else |
|
304 | + } else |
|
290 | 305 | { |
291 | 306 | $objectref = dol_sanitizeFileName($object->ref); |
292 | 307 | $dir = $conf->facture->dir_output . "/" . $objectref; |
@@ -326,7 +341,9 @@ discard block |
||
326 | 341 | $heightforinfotot = 50+(4*$nbpayments); // Height reserved to output the info and total part and payment part |
327 | 342 | $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 |
328 | 343 | $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
329 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
344 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) { |
|
345 | + $heightforfooter+= 6; |
|
346 | + } |
|
330 | 347 | |
331 | 348 | if (class_exists('TCPDF')) |
332 | 349 | { |
@@ -351,7 +368,9 @@ discard block |
||
351 | 368 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
352 | 369 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
353 | 370 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
354 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
371 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
372 | + $pdf->SetCompression(false); |
|
373 | + } |
|
355 | 374 | |
356 | 375 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
357 | 376 | |
@@ -363,9 +382,11 @@ discard block |
||
363 | 382 | $this->atleastonediscount++; |
364 | 383 | } |
365 | 384 | } |
366 | - if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) // retreive space not used by discount |
|
385 | + if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) { |
|
386 | + // retreive space not used by discount |
|
367 | 387 | { |
368 | 388 | $this->posxpicture+=($this->postotalht - $this->posxdiscount); |
389 | + } |
|
369 | 390 | $this->posxtva+=($this->postotalht - $this->posxdiscount); |
370 | 391 | $this->posxup+=($this->postotalht - $this->posxdiscount); |
371 | 392 | $this->posxqty+=($this->postotalht - $this->posxdiscount); |
@@ -391,7 +412,9 @@ discard block |
||
391 | 412 | |
392 | 413 | // New page |
393 | 414 | $pdf->AddPage(); |
394 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
415 | + if (! empty($tplidx)) { |
|
416 | + $pdf->useTemplate($tplidx); |
|
417 | + } |
|
395 | 418 | $pagenb++; |
396 | 419 | |
397 | 420 | $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); |
@@ -433,7 +456,9 @@ discard block |
||
433 | 456 | $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
434 | 457 | $salerepobj=new User($this->db); |
435 | 458 | $salerepobj->fetch($salereparray[0]['id']); |
436 | - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
459 | + if (! empty($salerepobj->signature)) { |
|
460 | + $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
461 | + } |
|
437 | 462 | } |
438 | 463 | } |
439 | 464 | if ($notetoshow) |
@@ -469,7 +494,9 @@ discard block |
||
469 | 494 | |
470 | 495 | // Define size of image if we need it |
471 | 496 | $imglinesize=array(); |
472 | - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
497 | + if (! empty($realpatharray[$i])) { |
|
498 | + $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
499 | + } |
|
473 | 500 | |
474 | 501 | $pdf->setTopMargin($tab_top_newpage); |
475 | 502 | $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
@@ -480,11 +507,17 @@ discard block |
||
480 | 507 | $posYAfterDescription=0; |
481 | 508 | |
482 | 509 | // We start with Photo of product line |
483 | - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page |
|
510 | + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
511 | + // If photo too high, we moved completely on new page |
|
484 | 512 | { |
485 | 513 | $pdf->AddPage('','',true); |
486 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
487 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
514 | + } |
|
515 | + if (! empty($tplidx)) { |
|
516 | + $pdf->useTemplate($tplidx); |
|
517 | + } |
|
518 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
519 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
520 | + } |
|
488 | 521 | $pdf->setPage($pageposbefore+1); |
489 | 522 | |
490 | 523 | $curY = $tab_top_newpage; |
@@ -505,9 +538,11 @@ discard block |
||
505 | 538 | $pdf->startTransaction(); |
506 | 539 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX-$progress_width,3,$curX,$curY,$hideref,$hidedesc); |
507 | 540 | $pageposafter=$pdf->getPage(); |
508 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
541 | + if ($pageposafter > $pageposbefore) { |
|
542 | + // There is a pagebreak |
|
509 | 543 | { |
510 | 544 | $pdf->rollbackTransaction(true); |
545 | + } |
|
511 | 546 | $pageposafter=$pageposbefore; |
512 | 547 | //print $pageposafter.'-'.$pageposbefore;exit; |
513 | 548 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
@@ -515,23 +550,27 @@ discard block |
||
515 | 550 | $pageposafter=$pdf->getPage(); |
516 | 551 | $posyafter=$pdf->GetY(); |
517 | 552 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
518 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
553 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
554 | + // There is no space left for total+free text |
|
519 | 555 | { |
520 | 556 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
521 | 557 | { |
522 | 558 | $pdf->AddPage('','',true); |
523 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
524 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
559 | + } |
|
560 | + if (! empty($tplidx)) { |
|
561 | + $pdf->useTemplate($tplidx); |
|
562 | + } |
|
563 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
564 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
565 | + } |
|
525 | 566 | $pdf->setPage($pageposafter+1); |
526 | 567 | } |
527 | - } |
|
528 | - else |
|
568 | + } else |
|
529 | 569 | { |
530 | 570 | // We found a page break |
531 | 571 | $showpricebeforepagebreak=0; |
532 | 572 | } |
533 | - } |
|
534 | - else // No pagebreak |
|
573 | + } else // No pagebreak |
|
535 | 574 | { |
536 | 575 | $pdf->commitTransaction(); |
537 | 576 | } |
@@ -571,12 +610,10 @@ discard block |
||
571 | 610 | if ($this->situationinvoice) |
572 | 611 | { |
573 | 612 | $pdf->MultiCell($this->posxprogress-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
574 | - } |
|
575 | - else if($conf->global->PRODUCT_USE_UNITS) |
|
613 | + } else if($conf->global->PRODUCT_USE_UNITS) |
|
576 | 614 | { |
577 | 615 | $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
578 | - } |
|
579 | - else |
|
616 | + } else |
|
580 | 617 | { |
581 | 618 | $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
582 | 619 | } |
@@ -589,12 +626,10 @@ discard block |
||
589 | 626 | if($conf->global->PRODUCT_USE_UNITS) |
590 | 627 | { |
591 | 628 | $pdf->MultiCell($this->posxunit-$this->posxprogress-1, 3, $progress, 0, 'R'); |
592 | - } |
|
593 | - else if ($this->atleastonediscount) |
|
629 | + } else if ($this->atleastonediscount) |
|
594 | 630 | { |
595 | 631 | $pdf->MultiCell($this->posxdiscount-$this->posxprogress-1, 3, $progress, 0, 'R'); |
596 | - } |
|
597 | - else |
|
632 | + } else |
|
598 | 633 | { |
599 | 634 | $pdf->MultiCell($this->postotalht-$this->posxprogress-1, 3, $progress, 0, 'R'); |
600 | 635 | } |
@@ -623,16 +658,24 @@ discard block |
||
623 | 658 | |
624 | 659 | |
625 | 660 | $sign=1; |
626 | - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
661 | + if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { |
|
662 | + $sign=-1; |
|
663 | + } |
|
627 | 664 | // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva |
628 | 665 | $prev_progress = $object->lines[$i]->get_prev_progress($object->id); |
629 | - if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation |
|
666 | + if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) { |
|
667 | + // Compute progress from previous situation |
|
630 | 668 | { |
631 | 669 | if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; |
632 | - else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; |
|
633 | 670 | } else { |
634 | - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne= $sign * $object->lines[$i]->multicurrency_total_tva; |
|
635 | - else $tvaligne= $sign * $object->lines[$i]->total_tva; |
|
671 | + $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; |
|
672 | + } |
|
673 | + } else { |
|
674 | + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) { |
|
675 | + $tvaligne= $sign * $object->lines[$i]->multicurrency_total_tva; |
|
676 | + } else { |
|
677 | + $tvaligne= $sign * $object->lines[$i]->total_tva; |
|
678 | + } |
|
636 | 679 | } |
637 | 680 | |
638 | 681 | $localtax1ligne=$object->lines[$i]->total_localtax1; |
@@ -642,32 +685,48 @@ discard block |
||
642 | 685 | $localtax1_type=$object->lines[$i]->localtax1_type; |
643 | 686 | $localtax2_type=$object->lines[$i]->localtax2_type; |
644 | 687 | |
645 | - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
646 | - if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
647 | - if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
688 | + if ($object->remise_percent) { |
|
689 | + $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
690 | + } |
|
691 | + if ($object->remise_percent) { |
|
692 | + $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
693 | + } |
|
694 | + if ($object->remise_percent) { |
|
695 | + $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
696 | + } |
|
648 | 697 | |
649 | 698 | $vatrate=(string) $object->lines[$i]->tva_tx; |
650 | 699 | |
651 | 700 | // Retrieve type from database for backward compatibility with old records |
652 | 701 | if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined |
653 | - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax |
|
702 | + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) { |
|
703 | + // and there is local tax |
|
654 | 704 | { |
655 | 705 | $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0, $object->thirdparty, $mysoc); |
706 | + } |
|
656 | 707 | $localtax1_type = $localtaxtmp_array[0]; |
657 | 708 | $localtax2_type = $localtaxtmp_array[2]; |
658 | 709 | } |
659 | 710 | |
660 | 711 | // retrieve global local tax |
661 | - if ($localtax1_type && $localtax1ligne != 0) |
|
662 | - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
663 | - if ($localtax2_type && $localtax2ligne != 0) |
|
664 | - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
712 | + if ($localtax1_type && $localtax1ligne != 0) { |
|
713 | + $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
714 | + } |
|
715 | + if ($localtax2_type && $localtax2ligne != 0) { |
|
716 | + $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
717 | + } |
|
665 | 718 | |
666 | - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
|
667 | - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; |
|
719 | + if (($object->lines[$i]->info_bits & 0x01) == 0x01) { |
|
720 | + $vatrate.='*'; |
|
721 | + } |
|
722 | + if (! isset($this->tva[$vatrate])) { |
|
723 | + $this->tva[$vatrate]=0; |
|
724 | + } |
|
668 | 725 | $this->tva[$vatrate] += $tvaligne; |
669 | 726 | |
670 | - if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; |
|
727 | + if ($posYAfterImage > $posYAfterDescription) { |
|
728 | + $nexY=$posYAfterImage; |
|
729 | + } |
|
671 | 730 | |
672 | 731 | // Add line |
673 | 732 | if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
@@ -688,8 +747,7 @@ discard block |
||
688 | 747 | if ($pagenb == 1) |
689 | 748 | { |
690 | 749 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
691 | - } |
|
692 | - else |
|
750 | + } else |
|
693 | 751 | { |
694 | 752 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
695 | 753 | } |
@@ -697,24 +755,29 @@ discard block |
||
697 | 755 | $pagenb++; |
698 | 756 | $pdf->setPage($pagenb); |
699 | 757 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
700 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
758 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
759 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
760 | + } |
|
701 | 761 | } |
702 | 762 | if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
703 | 763 | { |
704 | 764 | if ($pagenb == 1) |
705 | 765 | { |
706 | 766 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
707 | - } |
|
708 | - else |
|
767 | + } else |
|
709 | 768 | { |
710 | 769 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
711 | 770 | } |
712 | 771 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
713 | 772 | // New page |
714 | 773 | $pdf->AddPage(); |
715 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
774 | + if (! empty($tplidx)) { |
|
775 | + $pdf->useTemplate($tplidx); |
|
776 | + } |
|
716 | 777 | $pagenb++; |
717 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
778 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
779 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
780 | + } |
|
718 | 781 | } |
719 | 782 | } |
720 | 783 | |
@@ -723,8 +786,7 @@ discard block |
||
723 | 786 | { |
724 | 787 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
725 | 788 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
726 | - } |
|
727 | - else |
|
789 | + } else |
|
728 | 790 | { |
729 | 791 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); |
730 | 792 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
@@ -744,7 +806,9 @@ discard block |
||
744 | 806 | |
745 | 807 | // Pied de page |
746 | 808 | $this->_pagefoot($pdf,$object,$outputlangs); |
747 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
809 | + if (method_exists($pdf,'AliasNbPages')) { |
|
810 | + $pdf->AliasNbPages(); |
|
811 | + } |
|
748 | 812 | |
749 | 813 | $pdf->Close(); |
750 | 814 | |
@@ -756,20 +820,19 @@ discard block |
||
756 | 820 | global $action; |
757 | 821 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
758 | 822 | |
759 | - if (! empty($conf->global->MAIN_UMASK)) |
|
760 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
823 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
824 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
825 | + } |
|
761 | 826 | |
762 | 827 | $this->result = array('fullpath'=>$file); |
763 | 828 | |
764 | 829 | return 1; // No error |
765 | - } |
|
766 | - else |
|
830 | + } else |
|
767 | 831 | { |
768 | 832 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
769 | 833 | return 0; |
770 | 834 | } |
771 | - } |
|
772 | - else |
|
835 | + } else |
|
773 | 836 | { |
774 | 837 | $this->error=$langs->transnoentities("ErrorConstantNotDefined","FAC_OUTPUTDIR"); |
775 | 838 | return 0; |
@@ -793,21 +856,27 @@ discard block |
||
793 | 856 | global $conf; |
794 | 857 | |
795 | 858 | $sign=1; |
796 | - if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
859 | + if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { |
|
860 | + $sign=-1; |
|
861 | + } |
|
797 | 862 | |
798 | 863 | $tab3_posx = 120; |
799 | 864 | $tab3_top = $posy + 8; |
800 | 865 | $tab3_width = 80; |
801 | 866 | $tab3_height = 4; |
802 | - if ($this->page_largeur < 210) // To work with US executive format |
|
867 | + if ($this->page_largeur < 210) { |
|
868 | + // To work with US executive format |
|
803 | 869 | { |
804 | 870 | $tab3_posx -= 20; |
805 | 871 | } |
872 | + } |
|
806 | 873 | |
807 | 874 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
808 | 875 | |
809 | 876 | $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); |
810 | - if ($object->type == 2) $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone"); |
|
877 | + if ($object->type == 2) { |
|
878 | + $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone"); |
|
879 | + } |
|
811 | 880 | |
812 | 881 | $pdf->SetFont('','', $default_font_size - 3); |
813 | 882 | $pdf->SetXY($tab3_posx, $tab3_top - 4); |
@@ -849,10 +918,15 @@ discard block |
||
849 | 918 | $y+=3; |
850 | 919 | $obj = $this->db->fetch_object($resql); |
851 | 920 | |
852 | - if ($obj->type == 2) $text=$outputlangs->transnoentities("CreditNote"); |
|
853 | - elseif ($obj->type == 3) $text=$outputlangs->transnoentities("Deposit"); |
|
854 | - elseif ($obj->type == 0) $text=$outputlangs->transnoentities("ExcessReceived"); |
|
855 | - else $text=$outputlangs->transnoentities("UnknownType"); |
|
921 | + if ($obj->type == 2) { |
|
922 | + $text=$outputlangs->transnoentities("CreditNote"); |
|
923 | + } elseif ($obj->type == 3) { |
|
924 | + $text=$outputlangs->transnoentities("Deposit"); |
|
925 | + } elseif ($obj->type == 0) { |
|
926 | + $text=$outputlangs->transnoentities("ExcessReceived"); |
|
927 | + } else { |
|
928 | + $text=$outputlangs->transnoentities("UnknownType"); |
|
929 | + } |
|
856 | 930 | |
857 | 931 | $invoice->fetch($obj->fk_facture_source); |
858 | 932 | |
@@ -869,8 +943,7 @@ discard block |
||
869 | 943 | |
870 | 944 | $i++; |
871 | 945 | } |
872 | - } |
|
873 | - else |
|
946 | + } else |
|
874 | 947 | { |
875 | 948 | $this->error=$this->db->lasterror(); |
876 | 949 | return -1; |
@@ -910,8 +983,7 @@ discard block |
||
910 | 983 | |
911 | 984 | $i++; |
912 | 985 | } |
913 | - } |
|
914 | - else |
|
986 | + } else |
|
915 | 987 | { |
916 | 988 | $this->error=$this->db->lasterror(); |
917 | 989 | return -1; |
@@ -1060,7 +1132,10 @@ discard block |
||
1060 | 1132 | if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER)) |
1061 | 1133 | { |
1062 | 1134 | $bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account); |
1063 | - if (! empty($object->fk_bank)) $bankid=$object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank |
|
1135 | + if (! empty($object->fk_bank)) { |
|
1136 | + $bankid=$object->fk_bank; |
|
1137 | + } |
|
1138 | + // For backward compatibility when object->fk_account is forced with object->fk_bank |
|
1064 | 1139 | $account = new Account($this->db); |
1065 | 1140 | $account->fetch($bankid); |
1066 | 1141 | |
@@ -1095,7 +1170,9 @@ discard block |
||
1095 | 1170 | global $conf,$mysoc; |
1096 | 1171 | |
1097 | 1172 | $sign=1; |
1098 | - if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
1173 | + if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { |
|
1174 | + $sign=-1; |
|
1175 | + } |
|
1099 | 1176 | |
1100 | 1177 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
1101 | 1178 | |
@@ -1105,10 +1182,12 @@ discard block |
||
1105 | 1182 | |
1106 | 1183 | // Tableau total |
1107 | 1184 | $col1x = 120; $col2x = 170; |
1108 | - if ($this->page_largeur < 210) // To work with US executive format |
|
1185 | + if ($this->page_largeur < 210) { |
|
1186 | + // To work with US executive format |
|
1109 | 1187 | { |
1110 | 1188 | $col2x-=20; |
1111 | 1189 | } |
1190 | + } |
|
1112 | 1191 | $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
1113 | 1192 | |
1114 | 1193 | $useborder=0; |
@@ -1135,8 +1214,7 @@ discard block |
||
1135 | 1214 | if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) |
1136 | 1215 | { |
1137 | 1216 | // Nothing to do |
1138 | - } |
|
1139 | - else |
|
1217 | + } else |
|
1140 | 1218 | { |
1141 | 1219 | // FIXME amount of vat not supported with multicurrency |
1142 | 1220 | |
@@ -1145,15 +1223,19 @@ discard block |
||
1145 | 1223 | //{ |
1146 | 1224 | foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
1147 | 1225 | { |
1148 | - if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
1226 | + if (in_array((string) $localtax_type, array('1','3','5'))) { |
|
1227 | + continue; |
|
1228 | + } |
|
1149 | 1229 | |
1150 | 1230 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1151 | 1231 | { |
1152 | - if ($tvakey!=0) // On affiche pas taux 0 |
|
1232 | + if ($tvakey!=0) { |
|
1233 | + // On affiche pas taux 0 |
|
1153 | 1234 | { |
1154 | 1235 | //$this->atleastoneratenotnull++; |
1155 | 1236 | |
1156 | 1237 | $index++; |
1238 | + } |
|
1157 | 1239 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1158 | 1240 | |
1159 | 1241 | $tvacompl=''; |
@@ -1178,17 +1260,21 @@ discard block |
||
1178 | 1260 | //{ |
1179 | 1261 | foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
1180 | 1262 | { |
1181 | - if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
1263 | + if (in_array((string) $localtax_type, array('1','3','5'))) { |
|
1264 | + continue; |
|
1265 | + } |
|
1182 | 1266 | |
1183 | 1267 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1184 | 1268 | { |
1185 | - if ($tvakey!=0) // On affiche pas taux 0 |
|
1269 | + if ($tvakey!=0) { |
|
1270 | + // On affiche pas taux 0 |
|
1186 | 1271 | { |
1187 | 1272 | //$this->atleastoneratenotnull++; |
1188 | 1273 | |
1189 | 1274 | |
1190 | 1275 | |
1191 | 1276 | $index++; |
1277 | + } |
|
1192 | 1278 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1193 | 1279 | |
1194 | 1280 | $tvacompl=''; |
@@ -1229,9 +1315,11 @@ discard block |
||
1229 | 1315 | |
1230 | 1316 | foreach($this->tva as $tvakey => $tvaval) |
1231 | 1317 | { |
1232 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1318 | + if ($tvakey != 0) { |
|
1319 | + // On affiche pas taux 0 |
|
1233 | 1320 | { |
1234 | 1321 | $this->atleastoneratenotnull++; |
1322 | + } |
|
1235 | 1323 | |
1236 | 1324 | $index++; |
1237 | 1325 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -1256,15 +1344,19 @@ discard block |
||
1256 | 1344 | //{ |
1257 | 1345 | foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
1258 | 1346 | { |
1259 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1347 | + if (in_array((string) $localtax_type, array('2','4','6'))) { |
|
1348 | + continue; |
|
1349 | + } |
|
1260 | 1350 | |
1261 | 1351 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1262 | 1352 | { |
1263 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1353 | + if ($tvakey != 0) { |
|
1354 | + // On affiche pas taux 0 |
|
1264 | 1355 | { |
1265 | 1356 | //$this->atleastoneratenotnull++; |
1266 | 1357 | |
1267 | 1358 | $index++; |
1359 | + } |
|
1268 | 1360 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1269 | 1361 | |
1270 | 1362 | $tvacompl=''; |
@@ -1288,16 +1380,20 @@ discard block |
||
1288 | 1380 | //{ |
1289 | 1381 | foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
1290 | 1382 | { |
1291 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1383 | + if (in_array((string) $localtax_type, array('2','4','6'))) { |
|
1384 | + continue; |
|
1385 | + } |
|
1292 | 1386 | |
1293 | 1387 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1294 | 1388 | { |
1295 | 1389 | // retrieve global local tax |
1296 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1390 | + if ($tvakey != 0) { |
|
1391 | + // On affiche pas taux 0 |
|
1297 | 1392 | { |
1298 | 1393 | //$this->atleastoneratenotnull++; |
1299 | 1394 | |
1300 | 1395 | $index++; |
1396 | + } |
|
1301 | 1397 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1302 | 1398 | |
1303 | 1399 | $tvacompl=''; |
@@ -1346,7 +1442,9 @@ discard block |
||
1346 | 1442 | $depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); |
1347 | 1443 | //print "x".$creditnoteamount."-".$depositsamount;exit; |
1348 | 1444 | $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); |
1349 | - if ($object->paye) $resteapayer=0; |
|
1445 | + if ($object->paye) { |
|
1446 | + $resteapayer=0; |
|
1447 | + } |
|
1350 | 1448 | |
1351 | 1449 | if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) |
1352 | 1450 | { |
@@ -1417,7 +1515,9 @@ discard block |
||
1417 | 1515 | |
1418 | 1516 | // Force to disable hidetop and hidebottom |
1419 | 1517 | $hidebottom=0; |
1420 | - if ($hidetop) $hidetop=-1; |
|
1518 | + if ($hidetop) { |
|
1519 | + $hidetop=-1; |
|
1520 | + } |
|
1421 | 1521 | |
1422 | 1522 | $currency = !empty($currency) ? $currency : $conf->currency; |
1423 | 1523 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
@@ -1433,7 +1533,9 @@ discard block |
||
1433 | 1533 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
1434 | 1534 | |
1435 | 1535 | //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
1436 | - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
1536 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { |
|
1537 | + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
1538 | + } |
|
1437 | 1539 | } |
1438 | 1540 | |
1439 | 1541 | $pdf->SetDrawColor(128,128,128); |
@@ -1485,12 +1587,10 @@ discard block |
||
1485 | 1587 | if($this->situationinvoice) |
1486 | 1588 | { |
1487 | 1589 | $pdf->MultiCell($this->posxprogress-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
1488 | - } |
|
1489 | - else if($conf->global->PRODUCT_USE_UNITS) |
|
1590 | + } else if($conf->global->PRODUCT_USE_UNITS) |
|
1490 | 1591 | { |
1491 | 1592 | $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
1492 | - } |
|
1493 | - else |
|
1593 | + } else |
|
1494 | 1594 | { |
1495 | 1595 | $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
1496 | 1596 | } |
@@ -1506,12 +1606,10 @@ discard block |
||
1506 | 1606 | if($conf->global->PRODUCT_USE_UNITS) |
1507 | 1607 | { |
1508 | 1608 | $pdf->MultiCell($this->posxunit-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C'); |
1509 | - } |
|
1510 | - else if ($this->atleastonediscount) |
|
1609 | + } else if ($this->atleastonediscount) |
|
1511 | 1610 | { |
1512 | 1611 | $pdf->MultiCell($this->posxdiscount-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C'); |
1513 | - } |
|
1514 | - else |
|
1612 | + } else |
|
1515 | 1613 | { |
1516 | 1614 | $pdf->MultiCell($this->postotalht-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C'); |
1517 | 1615 | } |
@@ -1604,16 +1702,14 @@ discard block |
||
1604 | 1702 | { |
1605 | 1703 | $height=pdf_getHeightForLogo($logo); |
1606 | 1704 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
1607 | - } |
|
1608 | - else |
|
1705 | + } else |
|
1609 | 1706 | { |
1610 | 1707 | $pdf->SetTextColor(200,0,0); |
1611 | 1708 | $pdf->SetFont('','B',$default_font_size - 2); |
1612 | 1709 | $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
1613 | 1710 | $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
1614 | 1711 | } |
1615 | - } |
|
1616 | - else |
|
1712 | + } else |
|
1617 | 1713 | { |
1618 | 1714 | $text=$this->emetteur->name; |
1619 | 1715 | $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -1624,11 +1720,21 @@ discard block |
||
1624 | 1720 | $pdf->SetXY($posx,$posy); |
1625 | 1721 | $pdf->SetTextColor(0,0,60); |
1626 | 1722 | $title=$outputlangs->transnoentities("PdfInvoiceTitle"); |
1627 | - if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement"); |
|
1628 | - if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir"); |
|
1629 | - if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit"); |
|
1630 | - if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProForma"); |
|
1631 | - if ($this->situationinvoice) $title=$outputlangs->transnoentities("InvoiceSituation"); |
|
1723 | + if ($object->type == 1) { |
|
1724 | + $title=$outputlangs->transnoentities("InvoiceReplacement"); |
|
1725 | + } |
|
1726 | + if ($object->type == 2) { |
|
1727 | + $title=$outputlangs->transnoentities("InvoiceAvoir"); |
|
1728 | + } |
|
1729 | + if ($object->type == 3) { |
|
1730 | + $title=$outputlangs->transnoentities("InvoiceDeposit"); |
|
1731 | + } |
|
1732 | + if ($object->type == 4) { |
|
1733 | + $title=$outputlangs->transnoentities("InvoiceProForma"); |
|
1734 | + } |
|
1735 | + if ($this->situationinvoice) { |
|
1736 | + $title=$outputlangs->transnoentities("InvoiceSituation"); |
|
1737 | + } |
|
1632 | 1738 | $pdf->MultiCell($w, 3, $title, '', 'R'); |
1633 | 1739 | |
1634 | 1740 | $pdf->SetFont('','B',$default_font_size); |
@@ -1751,7 +1857,9 @@ discard block |
||
1751 | 1857 | $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
1752 | 1858 | $posy+=$top_shift; |
1753 | 1859 | $posx=$this->marge_gauche; |
1754 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1860 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1861 | + $posx=$this->page_largeur-$this->marge_droite-80; |
|
1862 | + } |
|
1755 | 1863 | |
1756 | 1864 | $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; |
1757 | 1865 | $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; |
@@ -1803,11 +1911,16 @@ discard block |
||
1803 | 1911 | |
1804 | 1912 | // Show recipient |
1805 | 1913 | $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; |
1806 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1914 | + if ($this->page_largeur < 210) { |
|
1915 | + $widthrecbox=84; |
|
1916 | + } |
|
1917 | + // To work with US executive format |
|
1807 | 1918 | $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; |
1808 | 1919 | $posy+=$top_shift; |
1809 | 1920 | $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
1810 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1921 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1922 | + $posx=$this->marge_gauche; |
|
1923 | + } |
|
1811 | 1924 | |
1812 | 1925 | // Show recipient frame |
1813 | 1926 | $pdf->SetTextColor(0,0,0); |
@@ -155,10 +155,15 @@ discard block |
||
155 | 155 | |
156 | 156 | $prefix=$this->prefixinvoice; |
157 | 157 | |
158 | - if ($invoice->type == 1) $prefix=$this->prefixreplacement; |
|
159 | - else if ($invoice->type == 2) $prefix=$this->prefixcreditnote; |
|
160 | - else if ($invoice->type == 3) $prefix=$this->prefixdeposit; |
|
161 | - else $prefix=$this->prefixinvoice; |
|
158 | + if ($invoice->type == 1) { |
|
159 | + $prefix=$this->prefixreplacement; |
|
160 | + } else if ($invoice->type == 2) { |
|
161 | + $prefix=$this->prefixcreditnote; |
|
162 | + } else if ($invoice->type == 3) { |
|
163 | + $prefix=$this->prefixdeposit; |
|
164 | + } else { |
|
165 | + $prefix=$this->prefixinvoice; |
|
166 | + } |
|
162 | 167 | |
163 | 168 | // D'abord on recupere la valeur max |
164 | 169 | $posindice=8; |
@@ -172,18 +177,25 @@ discard block |
||
172 | 177 | if ($resql) |
173 | 178 | { |
174 | 179 | $obj = $db->fetch_object($resql); |
175 | - if ($obj) $max = intval($obj->max); |
|
176 | - else $max=0; |
|
177 | - } |
|
178 | - else |
|
180 | + if ($obj) { |
|
181 | + $max = intval($obj->max); |
|
182 | + } else { |
|
183 | + $max=0; |
|
184 | + } |
|
185 | + } else |
|
179 | 186 | { |
180 | 187 | return -1; |
181 | 188 | } |
182 | 189 | |
183 | 190 | if ($mode == 'last') |
184 | 191 | { |
185 | - if ($max >= (pow(10, 4) - 1)) $num=$max; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
186 | - else $num = sprintf("%04s",$max); |
|
192 | + if ($max >= (pow(10, 4) - 1)) { |
|
193 | + $num=$max; |
|
194 | + } |
|
195 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
196 | + else { |
|
197 | + $num = sprintf("%04s",$max); |
|
198 | + } |
|
187 | 199 | |
188 | 200 | $ref=''; |
189 | 201 | $sql = "SELECT ref as ref"; |
@@ -196,24 +208,32 @@ discard block |
||
196 | 208 | if ($resql) |
197 | 209 | { |
198 | 210 | $obj = $db->fetch_object($resql); |
199 | - if ($obj) $ref = $obj->ref; |
|
211 | + if ($obj) { |
|
212 | + $ref = $obj->ref; |
|
213 | + } |
|
214 | + } else { |
|
215 | + dol_print_error($db); |
|
200 | 216 | } |
201 | - else dol_print_error($db); |
|
202 | 217 | |
203 | 218 | return $ref; |
204 | - } |
|
205 | - else if ($mode == 'next') |
|
219 | + } else if ($mode == 'next') |
|
206 | 220 | { |
207 | 221 | $date=$invoice->date; // This is invoice date (not creation date) |
208 | 222 | $yymm = strftime("%y%m",$date); |
209 | 223 | |
210 | - 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 |
|
211 | - else $num = sprintf("%04s",$max+1); |
|
224 | + if ($max >= (pow(10, 4) - 1)) { |
|
225 | + $num=$max+1; |
|
226 | + } |
|
227 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
228 | + else { |
|
229 | + $num = sprintf("%04s",$max+1); |
|
230 | + } |
|
212 | 231 | |
213 | 232 | dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
214 | 233 | return $prefix.$yymm."-".$num; |
234 | + } else { |
|
235 | + dol_print_error('','Bad parameter for getNextValue'); |
|
215 | 236 | } |
216 | - else dol_print_error('','Bad parameter for getNextValue'); |
|
217 | 237 | } |
218 | 238 | |
219 | 239 | /** |
@@ -150,10 +150,13 @@ discard block |
||
150 | 150 | { |
151 | 151 | $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE; |
152 | 152 | } |
153 | + } else if (is_object($invoice) && $invoice->type == 2) { |
|
154 | + $mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT; |
|
155 | + } else if (is_object($invoice) && $invoice->type == 3) { |
|
156 | + $mask=$conf->global->FACTURE_MERCURE_MASK_DEPOSIT; |
|
157 | + } else { |
|
158 | + $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE; |
|
153 | 159 | } |
154 | - else if (is_object($invoice) && $invoice->type == 2) $mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT; |
|
155 | - else if (is_object($invoice) && $invoice->type == 3) $mask=$conf->global->FACTURE_MERCURE_MASK_DEPOSIT; |
|
156 | - else $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE; |
|
157 | 160 | if (! $mask) |
158 | 161 | { |
159 | 162 | $this->error='NotConfigured'; |
@@ -168,7 +171,9 @@ discard block |
||
168 | 171 | $entity = getEntity('invoicenumber', 1, $invoice); |
169 | 172 | |
170 | 173 | $numFinal=get_next_value($db,$mask,'facture','ref',$where,$objsoc,$invoice->date,$mode,false,null,$entity); |
171 | - if (! preg_match('/([0-9])+/',$numFinal)) $this->error = $numFinal; |
|
174 | + if (! preg_match('/([0-9])+/',$numFinal)) { |
|
175 | + $this->error = $numFinal; |
|
176 | + } |
|
172 | 177 | |
173 | 178 | return $numFinal; |
174 | 179 | } |
@@ -171,9 +171,13 @@ discard block |
||
171 | 171 | { |
172 | 172 | global $db; |
173 | 173 | |
174 | - if ($invoice->type == 2) $prefix=$this->prefixcreditnote; |
|
175 | - else if ($invoice->type == 3) $prefix=$this->prefixdeposit; |
|
176 | - else $prefix=$this->prefixinvoice; |
|
174 | + if ($invoice->type == 2) { |
|
175 | + $prefix=$this->prefixcreditnote; |
|
176 | + } else if ($invoice->type == 3) { |
|
177 | + $prefix=$this->prefixdeposit; |
|
178 | + } else { |
|
179 | + $prefix=$this->prefixinvoice; |
|
180 | + } |
|
177 | 181 | |
178 | 182 | // D'abord on recupere la valeur max |
179 | 183 | $posindice=8; |
@@ -187,18 +191,25 @@ discard block |
||
187 | 191 | if ($resql) |
188 | 192 | { |
189 | 193 | $obj = $db->fetch_object($resql); |
190 | - if ($obj) $max = intval($obj->max); |
|
191 | - else $max=0; |
|
192 | - } |
|
193 | - else |
|
194 | + if ($obj) { |
|
195 | + $max = intval($obj->max); |
|
196 | + } else { |
|
197 | + $max=0; |
|
198 | + } |
|
199 | + } else |
|
194 | 200 | { |
195 | 201 | return -1; |
196 | 202 | } |
197 | 203 | |
198 | 204 | if ($mode == 'last') |
199 | 205 | { |
200 | - if ($max >= (pow(10, 4) - 1)) $num=$max; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
201 | - else $num = sprintf("%04s",$max); |
|
206 | + if ($max >= (pow(10, 4) - 1)) { |
|
207 | + $num=$max; |
|
208 | + } |
|
209 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
210 | + else { |
|
211 | + $num = sprintf("%04s",$max); |
|
212 | + } |
|
202 | 213 | |
203 | 214 | $ref=''; |
204 | 215 | $sql = "SELECT ref as ref"; |
@@ -211,24 +222,32 @@ discard block |
||
211 | 222 | if ($resql) |
212 | 223 | { |
213 | 224 | $obj = $db->fetch_object($resql); |
214 | - if ($obj) $ref = $obj->ref; |
|
225 | + if ($obj) { |
|
226 | + $ref = $obj->ref; |
|
227 | + } |
|
228 | + } else { |
|
229 | + dol_print_error($db); |
|
215 | 230 | } |
216 | - else dol_print_error($db); |
|
217 | 231 | |
218 | 232 | return $ref; |
219 | - } |
|
220 | - else if ($mode == 'next') |
|
233 | + } else if ($mode == 'next') |
|
221 | 234 | { |
222 | 235 | $date=$invoice->date; // This is invoice date (not creation date) |
223 | 236 | $yymm = strftime("%y%m",$date); |
224 | 237 | |
225 | - 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 |
|
226 | - else $num = sprintf("%04s",$max+1); |
|
238 | + if ($max >= (pow(10, 4) - 1)) { |
|
239 | + $num=$max+1; |
|
240 | + } |
|
241 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
242 | + else { |
|
243 | + $num = sprintf("%04s",$max+1); |
|
244 | + } |
|
227 | 245 | |
228 | 246 | dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
229 | 247 | return $prefix.$yymm."-".$num; |
248 | + } else { |
|
249 | + dol_print_error('','Bad parameter for getNextValue'); |
|
230 | 250 | } |
231 | - else dol_print_error('','Bad parameter for getNextValue'); |
|
232 | 251 | } |
233 | 252 | |
234 | 253 | /** |
@@ -253,7 +253,9 @@ discard block |
||
253 | 253 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
254 | 254 | $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
255 | 255 | $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s'; |
256 | - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
256 | + if (empty($user->rights->societe->client->voir)) { |
|
257 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
258 | + } |
|
257 | 259 | $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,'; |
258 | 260 | $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'facture as f'; |
259 | 261 | $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; |
@@ -266,7 +268,9 @@ discard block |
||
266 | 268 | $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; |
267 | 269 | $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; |
268 | 270 | $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('invoice').')'; |
269 | - if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; |
|
271 | + if (isset($user) && empty($user->rights->societe->client->voir)) { |
|
272 | + $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; |
|
273 | + } |
|
270 | 274 | $r++; |
271 | 275 | |
272 | 276 | $this->export_code[$r] = $this->rights_class.'_'.$r; |
@@ -307,7 +311,9 @@ discard block |
||
307 | 311 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
308 | 312 | $this->export_sql_start[$r]='SELECT DISTINCT '; |
309 | 313 | $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; |
310 | - if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
314 | + if (empty($user->rights->societe->client->voir)) { |
|
315 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
316 | + } |
|
311 | 317 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,'; |
312 | 318 | $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture as f'; |
313 | 319 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; |
@@ -321,7 +327,9 @@ discard block |
||
321 | 327 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON ba.rowid = b.fk_account'; |
322 | 328 | $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; |
323 | 329 | $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('invoice').')'; |
324 | - if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
330 | + if (isset($user) && empty($user->rights->societe->client->voir)) { |
|
331 | + $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; |
|
332 | + } |
|
325 | 333 | $r++; |
326 | 334 | } |
327 | 335 |
@@ -71,7 +71,10 @@ discard block |
||
71 | 71 | ); |
72 | 72 | |
73 | 73 | $requestedpermissionsarray=array(); |
74 | -if (GETPOST('state')) $requestedpermissionsarray=explode(',', GETPOST('state')); // Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back |
|
74 | +if (GETPOST('state')) { |
|
75 | + $requestedpermissionsarray=explode(',', GETPOST('state')); |
|
76 | +} |
|
77 | +// Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back |
|
75 | 78 | /*if ($action != 'delete' && empty($requestedpermissionsarray)) |
76 | 79 | { |
77 | 80 | print 'Error, parameter state is not defined'; |
@@ -107,12 +110,14 @@ discard block |
||
107 | 110 | exit(); |
108 | 111 | } |
109 | 112 | |
110 | -if (! empty($_GET['code'])) // We are coming from oauth provider page |
|
113 | +if (! empty($_GET['code'])) { |
|
114 | + // We are coming from oauth provider page |
|
111 | 115 | { |
112 | 116 | // We should have |
113 | 117 | //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16)) |
114 | 118 | |
115 | 119 | dol_syslog("We are coming from the oauth provider page"); |
120 | +} |
|
116 | 121 | //llxHeader('',$langs->trans("OAuthSetup")); |
117 | 122 | |
118 | 123 | //$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; |
@@ -146,8 +151,7 @@ discard block |
||
146 | 151 | } catch (Exception $e) { |
147 | 152 | print $e->getMessage(); |
148 | 153 | } |
149 | -} |
|
150 | -else // If entry on page with no parameter, we arrive here |
|
154 | +} else // If entry on page with no parameter, we arrive here |
|
151 | 155 | { |
152 | 156 | $_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl; |
153 | 157 | |
@@ -156,8 +160,7 @@ discard block |
||
156 | 160 | if (GETPOST('state')) |
157 | 161 | { |
158 | 162 | $url = $apiService->getAuthorizationUri(array('state'=>GETPOST('state'))); |
159 | - } |
|
160 | - else |
|
163 | + } else |
|
161 | 164 | { |
162 | 165 | //$url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated |
163 | 166 | //https://connect.stripe.com/oauth/authorize?response_type=code&client_id=ca_AX27ut70tJ1j6eyFCV3ObEXhNOo2jY6V&scope=read_write |
@@ -71,7 +71,10 @@ discard block |
||
71 | 71 | ); |
72 | 72 | |
73 | 73 | $requestedpermissionsarray=array(); |
74 | -if (GETPOST('state')) $requestedpermissionsarray=explode(',', GETPOST('state')); // Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back |
|
74 | +if (GETPOST('state')) { |
|
75 | + $requestedpermissionsarray=explode(',', GETPOST('state')); |
|
76 | +} |
|
77 | +// Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back |
|
75 | 78 | if ($action != 'delete' && empty($requestedpermissionsarray)) |
76 | 79 | { |
77 | 80 | print 'Error, parameter state is not defined'; |
@@ -107,9 +110,11 @@ discard block |
||
107 | 110 | exit(); |
108 | 111 | } |
109 | 112 | |
110 | -if (! empty($_GET['code'])) // We are coming from oauth provider page |
|
113 | +if (! empty($_GET['code'])) { |
|
114 | + // We are coming from oauth provider page |
|
111 | 115 | { |
112 | 116 | dol_syslog("We are coming from the oauth provider page"); |
117 | +} |
|
113 | 118 | //llxHeader('',$langs->trans("OAuthSetup")); |
114 | 119 | |
115 | 120 | //$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; |
@@ -138,8 +143,7 @@ discard block |
||
138 | 143 | } catch (Exception $e) { |
139 | 144 | print $e->getMessage(); |
140 | 145 | } |
141 | -} |
|
142 | -else // If entry on page with no parameter, we arrive here |
|
146 | +} else // If entry on page with no parameter, we arrive here |
|
143 | 147 | { |
144 | 148 | $_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl; |
145 | 149 | |
@@ -148,8 +152,7 @@ discard block |
||
148 | 152 | if (GETPOST('state')) |
149 | 153 | { |
150 | 154 | $url = $apiService->getAuthorizationUri(array('state'=>GETPOST('state'))); |
151 | - } |
|
152 | - else |
|
155 | + } else |
|
153 | 156 | { |
154 | 157 | $url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated |
155 | 158 | } |
@@ -71,7 +71,10 @@ discard block |
||
71 | 71 | ); |
72 | 72 | |
73 | 73 | $requestedpermissionsarray=array(); |
74 | -if (GETPOST('state')) $requestedpermissionsarray=explode(',', GETPOST('state')); // Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back |
|
74 | +if (GETPOST('state')) { |
|
75 | + $requestedpermissionsarray=explode(',', GETPOST('state')); |
|
76 | +} |
|
77 | +// Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back |
|
75 | 78 | if ($action != 'delete' && empty($requestedpermissionsarray)) |
76 | 79 | { |
77 | 80 | print 'Error, parameter state is not defined'; |
@@ -104,12 +107,14 @@ discard block |
||
104 | 107 | exit(); |
105 | 108 | } |
106 | 109 | |
107 | -if (! empty($_GET['code'])) // We are coming from oauth provider page |
|
110 | +if (! empty($_GET['code'])) { |
|
111 | + // We are coming from oauth provider page |
|
108 | 112 | { |
109 | 113 | // We should have |
110 | 114 | //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16)) |
111 | 115 | |
112 | 116 | dol_syslog("We are coming from the oauth provider page"); |
117 | +} |
|
113 | 118 | //llxHeader('',$langs->trans("OAuthSetup")); |
114 | 119 | |
115 | 120 | //$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; |
@@ -143,8 +148,7 @@ discard block |
||
143 | 148 | } catch (Exception $e) { |
144 | 149 | print $e->getMessage(); |
145 | 150 | } |
146 | -} |
|
147 | -else // If entry on page with no parameter, we arrive here |
|
151 | +} else // If entry on page with no parameter, we arrive here |
|
148 | 152 | { |
149 | 153 | $_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl; |
150 | 154 | |
@@ -153,8 +157,7 @@ discard block |
||
153 | 157 | if (GETPOST('state')) |
154 | 158 | { |
155 | 159 | $url = $apiService->getAuthorizationUri(array('state'=>GETPOST('state'))); |
156 | - } |
|
157 | - else |
|
160 | + } else |
|
158 | 161 | { |
159 | 162 | $url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated |
160 | 163 | } |