@@ -1,8 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | |
4 | - if(is_file('../main.inc.php'))$dir = '../'; |
|
5 | - else if(is_file('../../../main.inc.php'))$dir = '../../../'; |
|
6 | - else $dir = '../../'; |
|
4 | + if(is_file('../main.inc.php')) { |
|
5 | + $dir = '../'; |
|
6 | + } else if(is_file('../../../main.inc.php')) { |
|
7 | + $dir = '../../../'; |
|
8 | + } else { |
|
9 | + $dir = '../../'; |
|
10 | + } |
|
7 | 11 | |
8 | 12 | include($dir."main.inc.php"); |
@@ -50,8 +50,9 @@ discard block |
||
50 | 50 | { |
51 | 51 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
52 | 52 | $pdfformat=dol_getDefaultFormat($outputlangs); |
53 | + } else { |
|
54 | + $pdfformat=$conf->global->MAIN_PDF_FORMAT; |
|
53 | 55 | } |
54 | - else $pdfformat=$conf->global->MAIN_PDF_FORMAT; |
|
55 | 56 | |
56 | 57 | $sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format"; |
57 | 58 | $sql.=" WHERE code = '".$pdfformat."'"; |
@@ -119,16 +120,23 @@ discard block |
||
119 | 120 | define('K_TCPDF_THROW_EXCEPTION_ERROR', false); |
120 | 121 | } |
121 | 122 | |
122 | - if (! empty($conf->global->MAIN_USE_FPDF) && ! empty($conf->global->MAIN_DISABLE_FPDI)) |
|
123 | - return "Error MAIN_USE_FPDF and MAIN_DISABLE_FPDI can't be set together"; |
|
123 | + if (! empty($conf->global->MAIN_USE_FPDF) && ! empty($conf->global->MAIN_DISABLE_FPDI)) { |
|
124 | + return "Error MAIN_USE_FPDF and MAIN_DISABLE_FPDI can't be set together"; |
|
125 | + } |
|
124 | 126 | |
125 | 127 | // We use by default TCPDF else FPDF |
126 | - if (empty($conf->global->MAIN_USE_FPDF)) require_once TCPDF_PATH.'tcpdf.php'; |
|
127 | - else require_once FPDF_PATH.'fpdf.php'; |
|
128 | + if (empty($conf->global->MAIN_USE_FPDF)) { |
|
129 | + require_once TCPDF_PATH.'tcpdf.php'; |
|
130 | + } else { |
|
131 | + require_once FPDF_PATH.'fpdf.php'; |
|
132 | + } |
|
128 | 133 | |
129 | 134 | // We need to instantiate tcpdi or fpdi object (instead of tcpdf) to use merging features. But we can disable it (this will break all merge features). |
130 | - if (empty($conf->global->MAIN_DISABLE_TCPDI)) require_once TCPDI_PATH.'tcpdi.php'; |
|
131 | - else if (empty($conf->global->MAIN_DISABLE_FPDI)) require_once FPDI_PATH.'fpdi.php'; |
|
135 | + if (empty($conf->global->MAIN_DISABLE_TCPDI)) { |
|
136 | + require_once TCPDI_PATH.'tcpdi.php'; |
|
137 | + } else if (empty($conf->global->MAIN_DISABLE_FPDI)) { |
|
138 | + require_once FPDI_PATH.'fpdi.php'; |
|
139 | + } |
|
132 | 140 | |
133 | 141 | //$arrayformat=pdf_getFormat(); |
134 | 142 | //$format=array($arrayformat['width'],$arrayformat['height']); |
@@ -148,21 +156,28 @@ discard block |
||
148 | 156 | - print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality. |
149 | 157 | - owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions. |
150 | 158 | */ |
151 | - if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype,$metric,$format); |
|
152 | - else if (class_exists('FPDI')) $pdf = new FPDI($pagetype,$metric,$format); |
|
153 | - else $pdf = new TCPDF($pagetype,$metric,$format); |
|
159 | + if (class_exists('TCPDI')) { |
|
160 | + $pdf = new TCPDI($pagetype,$metric,$format); |
|
161 | + } else if (class_exists('FPDI')) { |
|
162 | + $pdf = new FPDI($pagetype,$metric,$format); |
|
163 | + } else { |
|
164 | + $pdf = new TCPDF($pagetype,$metric,$format); |
|
165 | + } |
|
154 | 166 | // For TCPDF, we specify permission we want to block |
155 | 167 | $pdfrights = array('modify','copy'); |
156 | 168 | |
157 | 169 | $pdfuserpass = ''; // Password for the end user |
158 | 170 | $pdfownerpass = NULL; // Password of the owner, created randomly if not defined |
159 | 171 | $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); |
160 | - } |
|
161 | - else |
|
172 | + } else |
|
162 | 173 | { |
163 | - if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype,$metric,$format); |
|
164 | - else if (class_exists('FPDI')) $pdf = new FPDI($pagetype,$metric,$format); |
|
165 | - else $pdf = new TCPDF($pagetype,$metric,$format); |
|
174 | + if (class_exists('TCPDI')) { |
|
175 | + $pdf = new TCPDI($pagetype,$metric,$format); |
|
176 | + } else if (class_exists('FPDI')) { |
|
177 | + $pdf = new FPDI($pagetype,$metric,$format); |
|
178 | + } else { |
|
179 | + $pdf = new TCPDF($pagetype,$metric,$format); |
|
180 | + } |
|
166 | 181 | } |
167 | 182 | |
168 | 183 | // If we use FPDF class, we may need to add method writeHTMLCell |
@@ -234,14 +249,18 @@ discard block |
||
234 | 249 | { |
235 | 250 | global $conf; |
236 | 251 | |
237 | - if (! empty($conf->global->MAIN_PDF_FORCE_FONT)) return $conf->global->MAIN_PDF_FORCE_FONT; |
|
252 | + if (! empty($conf->global->MAIN_PDF_FORCE_FONT)) { |
|
253 | + return $conf->global->MAIN_PDF_FORCE_FONT; |
|
254 | + } |
|
238 | 255 | |
239 | 256 | $font='Helvetica'; // By default, for FPDI, or ISO language on TCPDF |
240 | - if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) |
|
257 | + if (class_exists('TCPDF')) { |
|
258 | + // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) |
|
241 | 259 | { |
242 | 260 | if ($outputlangs->trans('FONTFORPDF')!='FONTFORPDF') |
243 | 261 | { |
244 | 262 | $font=$outputlangs->trans('FONTFORPDF'); |
263 | + } |
|
245 | 264 | } |
246 | 265 | } |
247 | 266 | return $font; |
@@ -256,11 +275,13 @@ discard block |
||
256 | 275 | function pdf_getPDFFontSize($outputlangs) |
257 | 276 | { |
258 | 277 | $size=10; // By default, for FPDI or ISO language on TCPDF |
259 | - if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) |
|
278 | + if (class_exists('TCPDF')) { |
|
279 | + // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) |
|
260 | 280 | { |
261 | 281 | if ($outputlangs->trans('FONTSIZEFORPDF')!='FONTSIZEFORPDF') |
262 | 282 | { |
263 | 283 | $size = (int) $outputlangs->trans('FONTSIZEFORPDF'); |
284 | + } |
|
264 | 285 | } |
265 | 286 | } |
266 | 287 | return $size; |
@@ -284,7 +305,9 @@ discard block |
||
284 | 305 | if ($tmp['height']) |
285 | 306 | { |
286 | 307 | $width=round($height*$tmp['width']/$tmp['height']); |
287 | - if ($width > $maxwidth) $height=$height*$maxwidth/$width; |
|
308 | + if ($width > $maxwidth) { |
|
309 | + $height=$height*$maxwidth/$width; |
|
310 | + } |
|
288 | 311 | } |
289 | 312 | //print $tmp['width'].' '.$tmp['height'].' '.$width; exit; |
290 | 313 | return $height; |
@@ -333,31 +356,54 @@ discard block |
||
333 | 356 | global $conf; |
334 | 357 | $stringaddress = ''; |
335 | 358 | |
336 | - if ($mode == 'source' && ! is_object($sourcecompany)) return -1; |
|
337 | - if ($mode == 'target' && ! is_object($targetcompany)) return -1; |
|
338 | - if ($mode == 'delivery' && ! is_object($deliverycompany)) return -1; |
|
359 | + if ($mode == 'source' && ! is_object($sourcecompany)) { |
|
360 | + return -1; |
|
361 | + } |
|
362 | + if ($mode == 'target' && ! is_object($targetcompany)) { |
|
363 | + return -1; |
|
364 | + } |
|
365 | + if ($mode == 'delivery' && ! is_object($deliverycompany)) { |
|
366 | + return -1; |
|
367 | + } |
|
339 | 368 | |
340 | - if (! empty($sourcecompany->state_id) && empty($sourcecompany->departement)) $sourcecompany->departement=getState($sourcecompany->state_id); //TODO: Deprecated |
|
341 | - if (! empty($sourcecompany->state_id) && empty($sourcecompany->state)) $sourcecompany->state=getState($sourcecompany->state_id); |
|
342 | - if (! empty($targetcompany->state_id) && empty($targetcompany->departement)) $targetcompany->departement=getState($targetcompany->state_id); |
|
369 | + if (! empty($sourcecompany->state_id) && empty($sourcecompany->departement)) { |
|
370 | + $sourcecompany->departement=getState($sourcecompany->state_id); |
|
371 | + } |
|
372 | + //TODO: Deprecated |
|
373 | + if (! empty($sourcecompany->state_id) && empty($sourcecompany->state)) { |
|
374 | + $sourcecompany->state=getState($sourcecompany->state_id); |
|
375 | + } |
|
376 | + if (! empty($targetcompany->state_id) && empty($targetcompany->departement)) { |
|
377 | + $targetcompany->departement=getState($targetcompany->state_id); |
|
378 | + } |
|
343 | 379 | |
344 | 380 | if ($mode == 'source') |
345 | 381 | { |
346 | 382 | $withCountry = 0; |
347 | - if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) $withCountry = 1; |
|
383 | + if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) { |
|
384 | + $withCountry = 1; |
|
385 | + } |
|
348 | 386 | |
349 | 387 | $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n"; |
350 | 388 | |
351 | 389 | if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS)) |
352 | 390 | { |
353 | 391 | // Phone |
354 | - if ($sourcecompany->phone) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone); |
|
392 | + if ($sourcecompany->phone) { |
|
393 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone); |
|
394 | + } |
|
355 | 395 | // Fax |
356 | - if ($sourcecompany->fax) $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax); |
|
396 | + if ($sourcecompany->fax) { |
|
397 | + $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax); |
|
398 | + } |
|
357 | 399 | |
358 | - if ($sourcecompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email); |
|
400 | + if ($sourcecompany->email) { |
|
401 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email); |
|
402 | + } |
|
359 | 403 | // Web |
360 | - if ($sourcecompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url); |
|
404 | + if ($sourcecompany->url) { |
|
405 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url); |
|
406 | + } |
|
361 | 407 | } |
362 | 408 | } |
363 | 409 | |
@@ -369,83 +415,121 @@ discard block |
||
369 | 415 | |
370 | 416 | if (!empty($targetcontact->address)) { |
371 | 417 | $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcontact))."\n"; |
372 | - }else { |
|
418 | + } else { |
|
373 | 419 | $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany))."\n"; |
374 | 420 | } |
375 | 421 | // Country |
376 | 422 | if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) { |
377 | 423 | $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code))."\n"; |
378 | - } |
|
379 | - else if (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) { |
|
424 | + } else if (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) { |
|
380 | 425 | $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n"; |
381 | 426 | } |
382 | 427 | |
383 | 428 | if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails') |
384 | 429 | { |
385 | 430 | // Phone |
386 | - if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; |
|
387 | - if (! empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro); |
|
388 | - if (! empty($targetcontact->phone_pro) && ! empty($targetcontact->phone_mobile)) $stringaddress .= " / "; |
|
389 | - if (! empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile); |
|
431 | + if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) { |
|
432 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; |
|
433 | + } |
|
434 | + if (! empty($targetcontact->phone_pro)) { |
|
435 | + $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro); |
|
436 | + } |
|
437 | + if (! empty($targetcontact->phone_pro) && ! empty($targetcontact->phone_mobile)) { |
|
438 | + $stringaddress .= " / "; |
|
439 | + } |
|
440 | + if (! empty($targetcontact->phone_mobile)) { |
|
441 | + $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile); |
|
442 | + } |
|
390 | 443 | // Fax |
391 | - if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax); |
|
444 | + if ($targetcontact->fax) { |
|
445 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax); |
|
446 | + } |
|
392 | 447 | |
393 | - if ($targetcontact->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email); |
|
448 | + if ($targetcontact->email) { |
|
449 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email); |
|
450 | + } |
|
394 | 451 | // Web |
395 | - if ($targetcontact->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url); |
|
452 | + if ($targetcontact->url) { |
|
453 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url); |
|
454 | + } |
|
396 | 455 | } |
397 | - } |
|
398 | - else |
|
456 | + } else |
|
399 | 457 | { |
400 | 458 | $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany))."\n"; |
401 | 459 | // Country |
402 | - if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n"; |
|
460 | + if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) { |
|
461 | + $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n"; |
|
462 | + } |
|
403 | 463 | |
404 | 464 | if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails') |
405 | 465 | { |
406 | 466 | // Phone |
407 | - if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; |
|
408 | - if (! empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone); |
|
409 | - if (! empty($targetcompany->phone) && ! empty($targetcompany->phone_mobile)) $stringaddress .= " / "; |
|
410 | - if (! empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile); |
|
467 | + if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) { |
|
468 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; |
|
469 | + } |
|
470 | + if (! empty($targetcompany->phone)) { |
|
471 | + $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone); |
|
472 | + } |
|
473 | + if (! empty($targetcompany->phone) && ! empty($targetcompany->phone_mobile)) { |
|
474 | + $stringaddress .= " / "; |
|
475 | + } |
|
476 | + if (! empty($targetcompany->phone_mobile)) { |
|
477 | + $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile); |
|
478 | + } |
|
411 | 479 | // Fax |
412 | - if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax); |
|
480 | + if ($targetcompany->fax) { |
|
481 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax); |
|
482 | + } |
|
413 | 483 | |
414 | - if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email); |
|
484 | + if ($targetcompany->email) { |
|
485 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email); |
|
486 | + } |
|
415 | 487 | // Web |
416 | - if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url); |
|
488 | + if ($targetcompany->url) { |
|
489 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url); |
|
490 | + } |
|
417 | 491 | } |
418 | 492 | } |
419 | 493 | |
420 | 494 | // Intra VAT |
421 | 495 | if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) |
422 | 496 | { |
423 | - if ($targetcompany->tva_intra) $stringaddress.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); |
|
497 | + if ($targetcompany->tva_intra) { |
|
498 | + $stringaddress.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); |
|
499 | + } |
|
424 | 500 | } |
425 | 501 | |
426 | 502 | // Professionnal Ids |
427 | 503 | if (! empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && ! empty($targetcompany->idprof1)) |
428 | 504 | { |
429 | 505 | $tmp=$outputlangs->transcountrynoentities("ProfId1",$targetcompany->country_code); |
430 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
506 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) { |
|
507 | + $tmp=$reg[1]; |
|
508 | + } |
|
431 | 509 | $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1); |
432 | 510 | } |
433 | 511 | if (! empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && ! empty($targetcompany->idprof2)) |
434 | 512 | { |
435 | 513 | $tmp=$outputlangs->transcountrynoentities("ProfId2",$targetcompany->country_code); |
436 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
514 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) { |
|
515 | + $tmp=$reg[1]; |
|
516 | + } |
|
437 | 517 | $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2); |
438 | 518 | } |
439 | 519 | if (! empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && ! empty($targetcompany->idprof3)) |
440 | 520 | { |
441 | 521 | $tmp=$outputlangs->transcountrynoentities("ProfId3",$targetcompany->country_code); |
442 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
522 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) { |
|
523 | + $tmp=$reg[1]; |
|
524 | + } |
|
443 | 525 | $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3); |
444 | 526 | } |
445 | 527 | if (! empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && ! empty($targetcompany->idprof4)) |
446 | 528 | { |
447 | 529 | $tmp=$outputlangs->transcountrynoentities("ProfId4",$targetcompany->country_code); |
448 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
530 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) { |
|
531 | + $tmp=$reg[1]; |
|
532 | + } |
|
449 | 533 | $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4); |
450 | 534 | } |
451 | 535 | } |
@@ -467,9 +551,12 @@ discard block |
||
467 | 551 | global $conf; |
468 | 552 | |
469 | 553 | // Add a background image on document |
470 | - if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) // Warning, this option make TCPDF generation beeing crazy and some content disappeared behin the image |
|
554 | + if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) { |
|
555 | + // Warning, this option make TCPDF generation beeing crazy and some content disappeared behin the image |
|
471 | 556 | { |
472 | - $pdf->SetAutoPageBreak(0,0); // Disable auto pagebreak before adding image |
|
557 | + $pdf->SetAutoPageBreak(0,0); |
|
558 | + } |
|
559 | + // Disable auto pagebreak before adding image |
|
473 | 560 | $pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_X:0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y:0), 0, $page_height); |
474 | 561 | $pdf->SetAutoPageBreak(1,0); // Restore pagebreak |
475 | 562 | } |
@@ -489,10 +576,15 @@ discard block |
||
489 | 576 | function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text) |
490 | 577 | { |
491 | 578 | // Print Draft Watermark |
492 | - if ($unit=='pt') $k=1; |
|
493 | - elseif ($unit=='mm') $k=72/25.4; |
|
494 | - elseif ($unit=='cm') $k=72/2.54; |
|
495 | - elseif ($unit=='in') $k=72; |
|
579 | + if ($unit=='pt') { |
|
580 | + $k=1; |
|
581 | + } elseif ($unit=='mm') { |
|
582 | + $k=72/25.4; |
|
583 | + } elseif ($unit=='cm') { |
|
584 | + $k=72/2.54; |
|
585 | + } elseif ($unit=='in') { |
|
586 | + $k=72; |
|
587 | + } |
|
496 | 588 | |
497 | 589 | $savx=$pdf->getX(); $savy=$pdf->getY(); |
498 | 590 | |
@@ -546,7 +638,9 @@ discard block |
||
546 | 638 | |
547 | 639 | // Use correct name of bank id according to country |
548 | 640 | $bickey="BICNumber"; |
549 | - if ($account->getCountryCode() == 'IN') $bickey="SWIFT"; |
|
641 | + if ($account->getCountryCode() == 'IN') { |
|
642 | + $bickey="SWIFT"; |
|
643 | + } |
|
550 | 644 | |
551 | 645 | // Get format of bank account according to its country |
552 | 646 | $usedetailedbban=$account->useDetailedBBAN(); |
@@ -629,8 +723,7 @@ discard block |
||
629 | 723 | $curx=$savcurx; |
630 | 724 | $cury+=9; |
631 | 725 | */ |
632 | - } |
|
633 | - else |
|
726 | + } else |
|
634 | 727 | { |
635 | 728 | $pdf->SetFont('','B',$default_font_size - $diffsizecontent); |
636 | 729 | $pdf->SetXY($curx, $cury); |
@@ -642,7 +735,9 @@ discard block |
||
642 | 735 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0); |
643 | 736 | $cury+=3; |
644 | 737 | |
645 | - if ($diffsizecontent <= 2) $cury+=1; |
|
738 | + if ($diffsizecontent <= 2) { |
|
739 | + $cury+=1; |
|
740 | + } |
|
646 | 741 | } |
647 | 742 | |
648 | 743 | $pdf->SetFont('','',$default_font_size - $diffsizecontent); |
@@ -665,13 +760,15 @@ discard block |
||
665 | 760 | $pdf->MultiCell(100, 3, $val, 0, 'L', 0); |
666 | 761 | $tmpy=$pdf->getStringHeight(100, $val); |
667 | 762 | $cury+=$tmpy; |
763 | + } else if (! $usedetailedbban) { |
|
764 | + $cury+=1; |
|
668 | 765 | } |
669 | 766 | |
670 | - else if (! $usedetailedbban) $cury+=1; |
|
671 | - |
|
672 | 767 | // Use correct name of bank id according to country |
673 | 768 | $ibankey="IBANNumber"; |
674 | - if ($account->getCountryCode() == 'IN') $ibankey="IFSC"; |
|
769 | + if ($account->getCountryCode() == 'IN') { |
|
770 | + $ibankey="IFSC"; |
|
771 | + } |
|
675 | 772 | if (! empty($account->iban)) |
676 | 773 | { |
677 | 774 | //Remove whitespaces to ensure we are dealing with the format we expect |
@@ -681,7 +778,9 @@ discard block |
||
681 | 778 | for($i = 0; $i < dol_strlen($ibanDisplay_temp); $i++) |
682 | 779 | { |
683 | 780 | $ibanDisplay .= $ibanDisplay_temp[$i]; |
684 | - if($i%4 == 3 && $i > 0) $ibanDisplay .= " "; |
|
781 | + if($i%4 == 3 && $i > 0) { |
|
782 | + $ibanDisplay .= " "; |
|
783 | + } |
|
685 | 784 | } |
686 | 785 | |
687 | 786 | $pdf->SetFont('','B',$default_font_size - 3); |
@@ -806,21 +905,28 @@ discard block |
||
806 | 905 | if ($fromcompany->capital) |
807 | 906 | { |
808 | 907 | $tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string |
809 | - if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); |
|
810 | - else $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",$tmpamounttoshow,$outputlangs); |
|
908 | + if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) { |
|
909 | + $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); |
|
910 | + } else { |
|
911 | + $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",$tmpamounttoshow,$outputlangs); |
|
912 | + } |
|
811 | 913 | } |
812 | 914 | // Prof Id 1 |
813 | 915 | if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2)) |
814 | 916 | { |
815 | 917 | $field=$outputlangs->transcountrynoentities("ProfId1",$fromcompany->country_code); |
816 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
918 | + if (preg_match('/\((.*)\)/i',$field,$reg)) { |
|
919 | + $field=$reg[1]; |
|
920 | + } |
|
817 | 921 | $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1); |
818 | 922 | } |
819 | 923 | // Prof Id 2 |
820 | 924 | if ($fromcompany->idprof2) |
821 | 925 | { |
822 | 926 | $field=$outputlangs->transcountrynoentities("ProfId2",$fromcompany->country_code); |
823 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
927 | + if (preg_match('/\((.*)\)/i',$field,$reg)) { |
|
928 | + $field=$reg[1]; |
|
929 | + } |
|
824 | 930 | $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2); |
825 | 931 | } |
826 | 932 | |
@@ -829,14 +935,18 @@ discard block |
||
829 | 935 | if ($fromcompany->idprof3) |
830 | 936 | { |
831 | 937 | $field=$outputlangs->transcountrynoentities("ProfId3",$fromcompany->country_code); |
832 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
938 | + if (preg_match('/\((.*)\)/i',$field,$reg)) { |
|
939 | + $field=$reg[1]; |
|
940 | + } |
|
833 | 941 | $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3); |
834 | 942 | } |
835 | 943 | // Prof Id 4 |
836 | 944 | if ($fromcompany->idprof4) |
837 | 945 | { |
838 | 946 | $field=$outputlangs->transcountrynoentities("ProfId4",$fromcompany->country_code); |
839 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
947 | + if (preg_match('/\((.*)\)/i',$field,$reg)) { |
|
948 | + $field=$reg[1]; |
|
949 | + } |
|
840 | 950 | $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4); |
841 | 951 | } |
842 | 952 | // IntraCommunautary VAT |
@@ -850,9 +960,12 @@ discard block |
||
850 | 960 | |
851 | 961 | // The start of the bottom of this page footer is positioned according to # of lines |
852 | 962 | $freetextheight=0; |
853 | - if ($line) // Free text |
|
963 | + if ($line) { |
|
964 | + // Free text |
|
854 | 965 | { |
855 | - $width=20000; $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. |
|
966 | + $width=20000; |
|
967 | + } |
|
968 | + $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. |
|
856 | 969 | if (! empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) { |
857 | 970 | $width=200; $align='C'; |
858 | 971 | } |
@@ -862,9 +975,11 @@ discard block |
||
862 | 975 | $marginwithfooter=$marge_basse + $freetextheight + (! empty($line1)?3:0) + (! empty($line2)?3:0) + (! empty($line3)?3:0) + (! empty($line4)?3:0); |
863 | 976 | $posy=$marginwithfooter+0; |
864 | 977 | |
865 | - if ($line) // Free text |
|
978 | + if ($line) { |
|
979 | + // Free text |
|
866 | 980 | { |
867 | 981 | $pdf->SetXY($dims['lm'],-$posy); |
982 | + } |
|
868 | 983 | $pdf->MultiCell(0, 3, $line, 0, $align, 0); |
869 | 984 | $posy-=$freetextheight; |
870 | 985 | } |
@@ -909,8 +1024,11 @@ discard block |
||
909 | 1024 | { |
910 | 1025 | $pdf->SetXY(-20,-$posy); |
911 | 1026 | //print 'xxx'.$pdf->PageNo().'-'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit; |
912 | - if (empty($conf->global->MAIN_USE_FPDF)) $pdf->MultiCell(13, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); |
|
913 | - else $pdf->MultiCell(13, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0); |
|
1027 | + if (empty($conf->global->MAIN_USE_FPDF)) { |
|
1028 | + $pdf->MultiCell(13, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); |
|
1029 | + } else { |
|
1030 | + $pdf->MultiCell(13, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0); |
|
1031 | + } |
|
914 | 1032 | } |
915 | 1033 | |
916 | 1034 | return $marginwithfooter; |
@@ -978,7 +1096,9 @@ discard block |
||
978 | 1096 | if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
979 | 1097 | { |
980 | 1098 | $special_code = $object->lines[$i]->special_code; |
981 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1099 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1100 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1101 | + } |
|
982 | 1102 | $parameters = array('pdf'=>$pdf,'i'=>$i,'outputlangs'=>$outputlangs,'w'=>$w,'h'=>$h,'posx'=>$posx,'posy'=>$posy,'hideref'=>$hideref,'hidedesc'=>$hidedesc,'issupplierline'=>$issupplierline,'special_code'=>$special_code); |
983 | 1103 | $action=''; |
984 | 1104 | $reshook=$hookmanager->executeHooks('pdf_writelinedesc',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
@@ -1014,8 +1134,11 @@ discard block |
||
1014 | 1134 | $note=(! empty($object->lines[$i]->note)?$object->lines[$i]->note:''); |
1015 | 1135 | $dbatch=(! empty($object->lines[$i]->detail_batch)?$object->lines[$i]->detail_batch:false); |
1016 | 1136 | |
1017 | - if ($issupplierline) $prodser = new ProductFournisseur($db); |
|
1018 | - else $prodser = new Product($db); |
|
1137 | + if ($issupplierline) { |
|
1138 | + $prodser = new ProductFournisseur($db); |
|
1139 | + } else { |
|
1140 | + $prodser = new Product($db); |
|
1141 | + } |
|
1019 | 1142 | |
1020 | 1143 | if ($idprod) |
1021 | 1144 | { |
@@ -1032,7 +1155,9 @@ discard block |
||
1032 | 1155 | // If we want another language, and if label is same than default language (we did force it to a specific value), we can use translation. |
1033 | 1156 | //var_dump($outputlangs->defaultlang.' - '.$langs->defaultlang.' - '.$label.' - '.$prodser->label);exit; |
1034 | 1157 | $textwasmodified=($label == $prodser->label); |
1035 | - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; |
|
1158 | + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) { |
|
1159 | + $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; |
|
1160 | + } |
|
1036 | 1161 | |
1037 | 1162 | // Set desc |
1038 | 1163 | // Manage HTML entities description test because $prodser->description is store with htmlentities but $desc no |
@@ -1042,11 +1167,15 @@ discard block |
||
1042 | 1167 | } else { |
1043 | 1168 | $textwasmodified=($desc == $prodser->description); |
1044 | 1169 | } |
1045 | - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; |
|
1170 | + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) { |
|
1171 | + $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; |
|
1172 | + } |
|
1046 | 1173 | |
1047 | 1174 | // Set note |
1048 | 1175 | $textwasmodified=($note == $prodser->note); |
1049 | - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; |
|
1176 | + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) { |
|
1177 | + $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; |
|
1178 | + } |
|
1050 | 1179 | } |
1051 | 1180 | } |
1052 | 1181 | |
@@ -1066,22 +1195,23 @@ discard block |
||
1066 | 1195 | $discount=new DiscountAbsolute($db); |
1067 | 1196 | $discount->fetch($object->lines[$i]->fk_remise_except); |
1068 | 1197 | $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$discount->ref_facture_source); |
1069 | - } |
|
1070 | - elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) |
|
1198 | + } elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) |
|
1071 | 1199 | { |
1072 | 1200 | $discount=new DiscountAbsolute($db); |
1073 | 1201 | $discount->fetch($object->lines[$i]->fk_remise_except); |
1074 | 1202 | $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit",$discount->ref_facture_source); |
1075 | 1203 | // Add date of deposit |
1076 | - if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec,'day','',$outputlangs).')'; |
|
1077 | - } |
|
1078 | - else |
|
1204 | + if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) { |
|
1205 | + echo ' ('.dol_print_date($discount->datec,'day','',$outputlangs).')'; |
|
1206 | + } |
|
1207 | + } else |
|
1079 | 1208 | { |
1080 | 1209 | if ($idprod) |
1081 | 1210 | { |
1082 | - if (empty($hidedesc)) $libelleproduitservice.=$desc; |
|
1083 | - } |
|
1084 | - else |
|
1211 | + if (empty($hidedesc)) { |
|
1212 | + $libelleproduitservice.=$desc; |
|
1213 | + } |
|
1214 | + } else |
|
1085 | 1215 | { |
1086 | 1216 | $libelleproduitservice.=$desc; |
1087 | 1217 | } |
@@ -1096,13 +1226,14 @@ discard block |
||
1096 | 1226 | { |
1097 | 1227 | $prefix_prodserv = ""; |
1098 | 1228 | $ref_prodserv = ""; |
1099 | - if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this |
|
1229 | + if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) { |
|
1230 | + // In standard mode, we do not show this |
|
1100 | 1231 | { |
1101 | 1232 | if ($prodser->isservice()) |
1102 | 1233 | { |
1103 | 1234 | $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." "; |
1104 | - } |
|
1105 | - else |
|
1235 | + } |
|
1236 | + } else |
|
1106 | 1237 | { |
1107 | 1238 | $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." "; |
1108 | 1239 | } |
@@ -1110,10 +1241,18 @@ discard block |
||
1110 | 1241 | |
1111 | 1242 | if (empty($hideref)) |
1112 | 1243 | { |
1113 | - if ($issupplierline) $ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref |
|
1114 | - else $ref_prodserv = $prodser->ref; // Show local ref only |
|
1244 | + if ($issupplierline) { |
|
1245 | + $ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); |
|
1246 | + } |
|
1247 | + // Show local ref and supplier ref |
|
1248 | + else { |
|
1249 | + $ref_prodserv = $prodser->ref; |
|
1250 | + } |
|
1251 | + // Show local ref only |
|
1115 | 1252 | |
1116 | - if (! empty($libelleproduitservice)) $ref_prodserv .= " - "; |
|
1253 | + if (! empty($libelleproduitservice)) { |
|
1254 | + $ref_prodserv .= " - "; |
|
1255 | + } |
|
1117 | 1256 | } |
1118 | 1257 | |
1119 | 1258 | $libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice; |
@@ -1131,8 +1270,9 @@ discard block |
||
1131 | 1270 | { |
1132 | 1271 | // Adding the descriptions if they are filled |
1133 | 1272 | $desccateg=$cate->add_description; |
1134 | - if ($desccateg) |
|
1135 | - $libelleproduitservice.='__N__'.$desccateg; |
|
1273 | + if ($desccateg) { |
|
1274 | + $libelleproduitservice.='__N__'.$desccateg; |
|
1275 | + } |
|
1136 | 1276 | } |
1137 | 1277 | } |
1138 | 1278 | |
@@ -1163,17 +1303,26 @@ discard block |
||
1163 | 1303 | foreach ($dbatch as $detail) |
1164 | 1304 | { |
1165 | 1305 | $dte=array(); |
1166 | - if ($detail->eatby) $dte[]=$outputlangs->transnoentitiesnoconv('printEatby',dol_print_date($detail->eatby, $format, false, $outputlangs)); |
|
1167 | - if ($detail->sellby) $dte[]=$outputlangs->transnoentitiesnoconv('printSellby',dol_print_date($detail->sellby, $format, false, $outputlangs)); |
|
1168 | - if ($detail->batch) $dte[]=$outputlangs->transnoentitiesnoconv('printBatch',$detail->batch); |
|
1306 | + if ($detail->eatby) { |
|
1307 | + $dte[]=$outputlangs->transnoentitiesnoconv('printEatby',dol_print_date($detail->eatby, $format, false, $outputlangs)); |
|
1308 | + } |
|
1309 | + if ($detail->sellby) { |
|
1310 | + $dte[]=$outputlangs->transnoentitiesnoconv('printSellby',dol_print_date($detail->sellby, $format, false, $outputlangs)); |
|
1311 | + } |
|
1312 | + if ($detail->batch) { |
|
1313 | + $dte[]=$outputlangs->transnoentitiesnoconv('printBatch',$detail->batch); |
|
1314 | + } |
|
1169 | 1315 | $dte[]=$outputlangs->transnoentitiesnoconv('printQty',$detail->dluo_qty); |
1170 | 1316 | $libelleproduitservice.= "__N__ ".implode($dte,"-"); |
1171 | 1317 | } |
1172 | 1318 | } |
1173 | 1319 | |
1174 | 1320 | // Now we convert \n into br |
1175 | - if (dol_textishtml($libelleproduitservice)) $libelleproduitservice=preg_replace('/__N__/','<br>',$libelleproduitservice); |
|
1176 | - else $libelleproduitservice=preg_replace('/__N__/',"\n",$libelleproduitservice); |
|
1321 | + if (dol_textishtml($libelleproduitservice)) { |
|
1322 | + $libelleproduitservice=preg_replace('/__N__/','<br>',$libelleproduitservice); |
|
1323 | + } else { |
|
1324 | + $libelleproduitservice=preg_replace('/__N__/',"\n",$libelleproduitservice); |
|
1325 | + } |
|
1177 | 1326 | $libelleproduitservice=dol_htmlentitiesbr($libelleproduitservice,1); |
1178 | 1327 | |
1179 | 1328 | return $libelleproduitservice; |
@@ -1195,10 +1344,11 @@ discard block |
||
1195 | 1344 | if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) |
1196 | 1345 | { |
1197 | 1346 | $special_code = $object->lines[$i]->special_code; |
1198 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1347 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1348 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1349 | + } |
|
1199 | 1350 | // TODO add hook function |
1200 | - } |
|
1201 | - else |
|
1351 | + } else |
|
1202 | 1352 | { |
1203 | 1353 | return dol_htmlentitiesbr($object->lines[$i]->num); |
1204 | 1354 | } |
@@ -1221,10 +1371,11 @@ discard block |
||
1221 | 1371 | if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) |
1222 | 1372 | { |
1223 | 1373 | $special_code = $object->lines[$i]->special_code; |
1224 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1374 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1375 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1376 | + } |
|
1225 | 1377 | // TODO add hook function |
1226 | - } |
|
1227 | - else |
|
1378 | + } else |
|
1228 | 1379 | { |
1229 | 1380 | return dol_htmlentitiesbr($object->lines[$i]->product_ref); |
1230 | 1381 | } |
@@ -1246,10 +1397,11 @@ discard block |
||
1246 | 1397 | if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1247 | 1398 | { |
1248 | 1399 | $special_code = $object->lines[$i]->special_code; |
1249 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1400 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1401 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1402 | + } |
|
1250 | 1403 | // TODO add hook function |
1251 | - } |
|
1252 | - else |
|
1404 | + } else |
|
1253 | 1405 | { |
1254 | 1406 | return dol_htmlentitiesbr($object->lines[$i]->ref_supplier); |
1255 | 1407 | } |
@@ -1271,17 +1423,23 @@ discard block |
||
1271 | 1423 | if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) |
1272 | 1424 | { |
1273 | 1425 | $special_code = $object->lines[$i]->special_code; |
1274 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1426 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1427 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1428 | + } |
|
1275 | 1429 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1276 | 1430 | $action=''; |
1277 | 1431 | $reshook = $hookmanager->executeHooks('pdf_getlinevatrate',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1278 | 1432 | |
1279 | - if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; |
|
1280 | - else return $reshook; |
|
1281 | - } |
|
1282 | - else |
|
1433 | + if(!empty($hookmanager->resPrint)) { |
|
1434 | + return $hookmanager->resPrint; |
|
1435 | + } else { |
|
1436 | + return $reshook; |
|
1437 | + } |
|
1438 | + } else |
|
1283 | 1439 | { |
1284 | - if (empty($hidedetails) || $hidedetails > 1) return vatrate($object->lines[$i]->tva_tx,1,$object->lines[$i]->info_bits,1); |
|
1440 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
1441 | + return vatrate($object->lines[$i]->tva_tx,1,$object->lines[$i]->info_bits,1); |
|
1442 | + } |
|
1285 | 1443 | } |
1286 | 1444 | } |
1287 | 1445 | |
@@ -1299,22 +1457,30 @@ discard block |
||
1299 | 1457 | global $conf, $hookmanager; |
1300 | 1458 | |
1301 | 1459 | $sign=1; |
1302 | - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
1460 | + if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { |
|
1461 | + $sign=-1; |
|
1462 | + } |
|
1303 | 1463 | |
1304 | 1464 | if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) |
1305 | 1465 | { |
1306 | 1466 | $special_code = $object->lines[$i]->special_code; |
1307 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1467 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1468 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1469 | + } |
|
1308 | 1470 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1309 | 1471 | $action=''; |
1310 | 1472 | $reshook = $hookmanager->executeHooks('pdf_getlineupexcltax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1311 | 1473 | |
1312 | - if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; |
|
1313 | - else return $reshook; |
|
1314 | - } |
|
1315 | - else |
|
1474 | + if(!empty($hookmanager->resPrint)) { |
|
1475 | + return $hookmanager->resPrint; |
|
1476 | + } else { |
|
1477 | + return $reshook; |
|
1478 | + } |
|
1479 | + } else |
|
1316 | 1480 | { |
1317 | - if (empty($hidedetails) || $hidedetails > 1) return price($sign * $object->lines[$i]->subprice, 0, $outputlangs); |
|
1481 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
1482 | + return price($sign * $object->lines[$i]->subprice, 0, $outputlangs); |
|
1483 | + } |
|
1318 | 1484 | } |
1319 | 1485 | } |
1320 | 1486 | |
@@ -1334,15 +1500,20 @@ discard block |
||
1334 | 1500 | if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) |
1335 | 1501 | { |
1336 | 1502 | $special_code = $object->lines[$i]->special_code; |
1337 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1503 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1504 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1505 | + } |
|
1338 | 1506 | foreach($object->hooks as $modules) |
1339 | 1507 | { |
1340 | - if (method_exists($modules[$special_code],'pdf_getlineupwithtax')) return $modules[$special_code]->pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails); |
|
1508 | + if (method_exists($modules[$special_code],'pdf_getlineupwithtax')) { |
|
1509 | + return $modules[$special_code]->pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails); |
|
1510 | + } |
|
1341 | 1511 | } |
1342 | - } |
|
1343 | - else |
|
1512 | + } else |
|
1344 | 1513 | { |
1345 | - if (empty($hidedetails) || $hidedetails > 1) return price(($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs); |
|
1514 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
1515 | + return price(($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs); |
|
1516 | + } |
|
1346 | 1517 | } |
1347 | 1518 | } |
1348 | 1519 | |
@@ -1364,18 +1535,24 @@ discard block |
||
1364 | 1535 | if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1365 | 1536 | { |
1366 | 1537 | $special_code = $object->lines[$i]->special_code; |
1367 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1538 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1539 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1540 | + } |
|
1368 | 1541 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1369 | 1542 | $action=''; |
1370 | 1543 | $reshook = $hookmanager->executeHooks('pdf_getlineqty',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1371 | 1544 | |
1372 | - if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; |
|
1373 | - else return $reshook; |
|
1545 | + if(!empty($hookmanager->resPrint)) { |
|
1546 | + return $hookmanager->resPrint; |
|
1547 | + } else { |
|
1548 | + return $reshook; |
|
1549 | + } |
|
1374 | 1550 | |
1375 | - } |
|
1376 | - else |
|
1551 | + } else |
|
1377 | 1552 | { |
1378 | - if (empty($hidedetails) || $hidedetails > 1) return $object->lines[$i]->qty; |
|
1553 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
1554 | + return $object->lines[$i]->qty; |
|
1555 | + } |
|
1379 | 1556 | } |
1380 | 1557 | } |
1381 | 1558 | } |
@@ -1398,17 +1575,23 @@ discard block |
||
1398 | 1575 | if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1399 | 1576 | { |
1400 | 1577 | $special_code = $object->lines[$i]->special_code; |
1401 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1578 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1579 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1580 | + } |
|
1402 | 1581 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1403 | 1582 | $action=''; |
1404 | 1583 | $reshook = $hookmanager->executeHooks('pdf_getlineqty_asked',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1405 | 1584 | |
1406 | - if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; |
|
1407 | - else return $reshook; |
|
1408 | - } |
|
1409 | - else |
|
1585 | + if(!empty($hookmanager->resPrint)) { |
|
1586 | + return $hookmanager->resPrint; |
|
1587 | + } else { |
|
1588 | + return $reshook; |
|
1589 | + } |
|
1590 | + } else |
|
1410 | 1591 | { |
1411 | - if (empty($hidedetails) || $hidedetails > 1) return $object->lines[$i]->qty_asked; |
|
1592 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
1593 | + return $object->lines[$i]->qty_asked; |
|
1594 | + } |
|
1412 | 1595 | } |
1413 | 1596 | } |
1414 | 1597 | } |
@@ -1431,17 +1614,23 @@ discard block |
||
1431 | 1614 | if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1432 | 1615 | { |
1433 | 1616 | $special_code = $object->lines[$i]->special_code; |
1434 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1617 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1618 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1619 | + } |
|
1435 | 1620 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1436 | 1621 | $action=''; |
1437 | 1622 | $reshook = $hookmanager->executeHooks('pdf_getlineqty_shipped',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1438 | 1623 | |
1439 | - if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; |
|
1440 | - else return $reshook; |
|
1441 | - } |
|
1442 | - else |
|
1624 | + if(!empty($hookmanager->resPrint)) { |
|
1625 | + return $hookmanager->resPrint; |
|
1626 | + } else { |
|
1627 | + return $reshook; |
|
1628 | + } |
|
1629 | + } else |
|
1443 | 1630 | { |
1444 | - if (empty($hidedetails) || $hidedetails > 1) return $object->lines[$i]->qty_shipped; |
|
1631 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
1632 | + return $object->lines[$i]->qty_shipped; |
|
1633 | + } |
|
1445 | 1634 | } |
1446 | 1635 | } |
1447 | 1636 | } |
@@ -1464,17 +1653,23 @@ discard block |
||
1464 | 1653 | if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1465 | 1654 | { |
1466 | 1655 | $special_code = $object->lines[$i]->special_code; |
1467 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1656 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1657 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1658 | + } |
|
1468 | 1659 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1469 | 1660 | $action=''; |
1470 | 1661 | $reshook = $hookmanager->executeHooks('pdf_getlineqty_keeptoship',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1471 | 1662 | |
1472 | - if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; |
|
1473 | - else return $reshook; |
|
1474 | - } |
|
1475 | - else |
|
1663 | + if(!empty($hookmanager->resPrint)) { |
|
1664 | + return $hookmanager->resPrint; |
|
1665 | + } else { |
|
1666 | + return $reshook; |
|
1667 | + } |
|
1668 | + } else |
|
1476 | 1669 | { |
1477 | - if (empty($hidedetails) || $hidedetails > 1) return ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped); |
|
1670 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
1671 | + return ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped); |
|
1672 | + } |
|
1478 | 1673 | } |
1479 | 1674 | } |
1480 | 1675 | } |
@@ -1508,8 +1703,11 @@ discard block |
||
1508 | 1703 | $reshook = $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object, |
1509 | 1704 | $action); // Note that $action and $object may have been modified by some hooks |
1510 | 1705 | |
1511 | - if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; |
|
1512 | - else return $reshook; |
|
1706 | + if(!empty($hookmanager->resPrint)) { |
|
1707 | + return $hookmanager->resPrint; |
|
1708 | + } else { |
|
1709 | + return $reshook; |
|
1710 | + } |
|
1513 | 1711 | |
1514 | 1712 | } else { |
1515 | 1713 | if (empty($hidedetails) || $hidedetails > 1) { |
@@ -1540,17 +1738,23 @@ discard block |
||
1540 | 1738 | if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1541 | 1739 | { |
1542 | 1740 | $special_code = $object->lines[$i]->special_code; |
1543 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1741 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1742 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1743 | + } |
|
1544 | 1744 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1545 | 1745 | $action=''; |
1546 | 1746 | $reshook = $hookmanager->executeHooks('pdf_getlineremisepercent',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1547 | 1747 | |
1548 | - if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; |
|
1549 | - else return $reshook; |
|
1550 | - } |
|
1551 | - else |
|
1748 | + if(!empty($hookmanager->resPrint)) { |
|
1749 | + return $hookmanager->resPrint; |
|
1750 | + } else { |
|
1751 | + return $reshook; |
|
1752 | + } |
|
1753 | + } else |
|
1552 | 1754 | { |
1553 | - if (empty($hidedetails) || $hidedetails > 1) return dol_print_reduction($object->lines[$i]->remise_percent,$outputlangs); |
|
1755 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
1756 | + return dol_print_reduction($object->lines[$i]->remise_percent,$outputlangs); |
|
1757 | + } |
|
1554 | 1758 | } |
1555 | 1759 | } |
1556 | 1760 | } |
@@ -1572,15 +1776,22 @@ discard block |
||
1572 | 1776 | if ($object->lines[$i]->special_code != 3) { |
1573 | 1777 | if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line))) { |
1574 | 1778 | $special_code = $object->lines[$i]->special_code; |
1575 | - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1779 | + if (!empty($object->lines[$i]->fk_parent_line)) { |
|
1780 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1781 | + } |
|
1576 | 1782 | $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code); |
1577 | 1783 | $action = ''; |
1578 | 1784 | $reshook = $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
1579 | 1785 | |
1580 | - if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; |
|
1581 | - else return $reshook; |
|
1786 | + if(!empty($hookmanager->resPrint)) { |
|
1787 | + return $hookmanager->resPrint; |
|
1788 | + } else { |
|
1789 | + return $reshook; |
|
1790 | + } |
|
1582 | 1791 | } else { |
1583 | - if (empty($hidedetails) || $hidedetails > 1) return $object->lines[$i]->situation_percent . '%'; |
|
1792 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
1793 | + return $object->lines[$i]->situation_percent . '%'; |
|
1794 | + } |
|
1584 | 1795 | } |
1585 | 1796 | } |
1586 | 1797 | } |
@@ -1599,28 +1810,35 @@ discard block |
||
1599 | 1810 | global $conf, $hookmanager; |
1600 | 1811 | |
1601 | 1812 | $sign=1; |
1602 | - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
1813 | + if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { |
|
1814 | + $sign=-1; |
|
1815 | + } |
|
1603 | 1816 | |
1604 | 1817 | if ($object->lines[$i]->special_code == 3) |
1605 | 1818 | { |
1606 | 1819 | return $outputlangs->transnoentities("Option"); |
1607 | - } |
|
1608 | - else |
|
1820 | + } else |
|
1609 | 1821 | { |
1610 | 1822 | if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) |
1611 | 1823 | { |
1612 | 1824 | $special_code = $object->lines[$i]->special_code; |
1613 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1825 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1826 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1827 | + } |
|
1614 | 1828 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1615 | 1829 | $action=''; |
1616 | 1830 | $reshook = $hookmanager->executeHooks('pdf_getlinetotalexcltax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1617 | 1831 | |
1618 | - if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; |
|
1619 | - else return $reshook; |
|
1620 | - } |
|
1621 | - else |
|
1832 | + if(!empty($hookmanager->resPrint)) { |
|
1833 | + return $hookmanager->resPrint; |
|
1834 | + } else { |
|
1835 | + return $reshook; |
|
1836 | + } |
|
1837 | + } else |
|
1622 | 1838 | { |
1623 | - if (empty($hidedetails) || $hidedetails > 1) return price($sign * $object->lines[$i]->total_ht, 0, $outputlangs); |
|
1839 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
1840 | + return price($sign * $object->lines[$i]->total_ht, 0, $outputlangs); |
|
1841 | + } |
|
1624 | 1842 | } |
1625 | 1843 | } |
1626 | 1844 | return ''; |
@@ -1642,23 +1860,28 @@ discard block |
||
1642 | 1860 | if ($object->lines[$i]->special_code == 3) |
1643 | 1861 | { |
1644 | 1862 | return $outputlangs->transnoentities("Option"); |
1645 | - } |
|
1646 | - else |
|
1863 | + } else |
|
1647 | 1864 | { |
1648 | 1865 | if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) |
1649 | 1866 | { |
1650 | 1867 | $special_code = $object->lines[$i]->special_code; |
1651 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1868 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1869 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1870 | + } |
|
1652 | 1871 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1653 | 1872 | $action=''; |
1654 | 1873 | $reshook = $hookmanager->executeHooks('pdf_getlinetotalwithtax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1655 | 1874 | |
1656 | - if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; |
|
1657 | - else return $reshook; |
|
1658 | - } |
|
1659 | - else |
|
1875 | + if(!empty($hookmanager->resPrint)) { |
|
1876 | + return $hookmanager->resPrint; |
|
1877 | + } else { |
|
1878 | + return $reshook; |
|
1879 | + } |
|
1880 | + } else |
|
1660 | 1881 | { |
1661 | - if (empty($hidedetails) || $hidedetails > 1) return price(($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs); |
|
1882 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
1883 | + return price(($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs); |
|
1884 | + } |
|
1662 | 1885 | } |
1663 | 1886 | } |
1664 | 1887 | return ''; |
@@ -1687,18 +1910,17 @@ discard block |
||
1687 | 1910 | if ($type=='all') |
1688 | 1911 | { |
1689 | 1912 | $total += $object->lines[$i]->qty; |
1690 | - } |
|
1691 | - else if ($type==9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) |
|
1913 | + } else if ($type==9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) |
|
1692 | 1914 | { |
1693 | 1915 | $special_code = $object->lines[$i]->special_code; |
1694 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1916 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1917 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1918 | + } |
|
1695 | 1919 | // TODO add hook function |
1696 | - } |
|
1697 | - else if ($type==0 && $object->lines[$i]->product_type == 0) |
|
1920 | + } else if ($type==0 && $object->lines[$i]->product_type == 0) |
|
1698 | 1921 | { |
1699 | 1922 | $total += $object->lines[$i]->qty; |
1700 | - } |
|
1701 | - else if ($type==1 && $object->lines[$i]->product_type == 1) |
|
1923 | + } else if ($type==1 && $object->lines[$i]->product_type == 1) |
|
1702 | 1924 | { |
1703 | 1925 | $total += $object->lines[$i]->qty; |
1704 | 1926 | } |
@@ -1736,8 +1958,7 @@ discard block |
||
1736 | 1958 | $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DatePropal"); |
1737 | 1959 | $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date,'day','',$outputlangs); |
1738 | 1960 | } |
1739 | - } |
|
1740 | - else if ($objecttype == 'commande') |
|
1961 | + } else if ($objecttype == 'commande') |
|
1741 | 1962 | { |
1742 | 1963 | $outputlangs->load('orders'); |
1743 | 1964 | foreach($objects as $elementobject) |
@@ -1747,8 +1968,7 @@ discard block |
||
1747 | 1968 | $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate"); |
1748 | 1969 | $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date,'day','',$outputlangs); |
1749 | 1970 | } |
1750 | - } |
|
1751 | - else if ($objecttype == 'contrat') |
|
1971 | + } else if ($objecttype == 'contrat') |
|
1752 | 1972 | { |
1753 | 1973 | $outputlangs->load('contracts'); |
1754 | 1974 | foreach($objects as $elementobject) |
@@ -1758,8 +1978,7 @@ discard block |
||
1758 | 1978 | $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract"); |
1759 | 1979 | $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date_contrat,'day','',$outputlangs); |
1760 | 1980 | } |
1761 | - } |
|
1762 | - else if ($objecttype == 'shipping') |
|
1981 | + } else if ($objecttype == 'shipping') |
|
1763 | 1982 | { |
1764 | 1983 | $outputlangs->load('orders'); |
1765 | 1984 | $outputlangs->load('sendings'); |
@@ -1768,14 +1987,15 @@ discard block |
||
1768 | 1987 | $elementobject->fetchObjectLinked(); |
1769 | 1988 | $order = $elementobject->linkedObjects['commande'][0]; |
1770 | 1989 | |
1771 | - if (! empty($object->linkedObjects['commande'])) // There is already a link to order so we show only info of shipment |
|
1990 | + if (! empty($object->linkedObjects['commande'])) { |
|
1991 | + // There is already a link to order so we show only info of shipment |
|
1772 | 1992 | { |
1773 | 1993 | $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefSending"); |
1994 | + } |
|
1774 | 1995 | $linkedobjects[$objecttype]['ref_value'].= $outputlangs->transnoentities($elementobject->ref); |
1775 | 1996 | $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateSending"); |
1776 | 1997 | $linkedobjects[$objecttype]['date_value'].= dol_print_date($elementobject->date_delivery,'day','',$outputlangs); |
1777 | - } |
|
1778 | - else // We show both info of order and shipment |
|
1998 | + } else // We show both info of order and shipment |
|
1779 | 1999 | { |
1780 | 2000 | $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder") . ' / ' . $outputlangs->transnoentities("RefSending"); |
1781 | 2001 | $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($order->ref) . ($order->ref_client ? ' ('.$order->ref_client.')' : ''); |
@@ -1794,7 +2014,9 @@ discard block |
||
1794 | 2014 | $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs); |
1795 | 2015 | $action=''; |
1796 | 2016 | $hookmanager->executeHooks('pdf_getLinkedObjects',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1797 | - if (! empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray; |
|
2017 | + if (! empty($hookmanager->resArray)) { |
|
2018 | + $linkedobjects = $hookmanager->resArray; |
|
2019 | + } |
|
1798 | 2020 | } |
1799 | 2021 | |
1800 | 2022 | return $linkedobjects; |
@@ -1818,12 +2040,13 @@ discard block |
||
1818 | 2040 | if ($tmp['height']) |
1819 | 2041 | { |
1820 | 2042 | $width=(int) round($maxheight*$tmp['width']/$tmp['height']); // I try to use maxheight |
1821 | - if ($width > $maxwidth) // Pb with maxheight, so i use maxwidth |
|
2043 | + if ($width > $maxwidth) { |
|
2044 | + // Pb with maxheight, so i use maxwidth |
|
1822 | 2045 | { |
1823 | 2046 | $width=$maxwidth; |
1824 | - $height=(int) round($maxwidth*$tmp['height']/$tmp['width']); |
|
1825 | 2047 | } |
1826 | - else // No pb with maxheight |
|
2048 | + $height=(int) round($maxwidth*$tmp['height']/$tmp['width']); |
|
2049 | + } else // No pb with maxheight |
|
1827 | 2050 | { |
1828 | 2051 | $height=$maxheight; |
1829 | 2052 | } |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | $prop->desc = ''; |
24 | 24 | } |
25 | 25 | $ret = $prop->update(1); |
26 | - if($ret>0) $i++; |
|
26 | + if($ret>0) { |
|
27 | + $i++; |
|
28 | + } |
|
27 | 29 | } |
28 | 30 | print $i." lignes converties<br>"; |
29 | 31 | } |
@@ -45,7 +47,9 @@ discard block |
||
45 | 47 | $cdeline->desc = ''; |
46 | 48 | } |
47 | 49 | $ret = $cdeline->update($user, 1); |
48 | - if($ret>0) $i++; |
|
50 | + if($ret>0) { |
|
51 | + $i++; |
|
52 | + } |
|
49 | 53 | } |
50 | 54 | |
51 | 55 | print $i." lignes converties<br>"; |
@@ -69,7 +73,9 @@ discard block |
||
69 | 73 | $facline->desc = ''; |
70 | 74 | } |
71 | 75 | $ret = $facline->update($user, 1); |
72 | - if($ret>0) $i++; |
|
76 | + if($ret>0) { |
|
77 | + $i++; |
|
78 | + } |
|
73 | 79 | } |
74 | 80 | |
75 | 81 | print $i." lignes converties<br>"; |
@@ -13,7 +13,9 @@ discard block |
||
13 | 13 | $sql = 'SELECT rowid'; |
14 | 14 | $sql .= ' FROM '.MAIN_DB_PREFIX.'propal'; |
15 | 15 | $sql .= ' WHERE total_ht + tva != total'; |
16 | -if(! empty($limit)) $sql .= ' LIMIT '.$limit; |
|
16 | +if(! empty($limit)) { |
|
17 | + $sql .= ' LIMIT '.$limit; |
|
18 | +} |
|
17 | 19 | |
18 | 20 | $resql = $db->query($sql); |
19 | 21 | if($resql) { |
@@ -24,7 +26,9 @@ discard block |
||
24 | 26 | $propal->fetch($obj->rowid); |
25 | 27 | |
26 | 28 | foreach($propal->lines as &$l) { |
27 | - if(empty($l->array_options)) $l->fetch_optionals(); |
|
29 | + if(empty($l->array_options)) { |
|
30 | + $l->fetch_optionals(); |
|
31 | + } |
|
28 | 32 | if(! empty($l->array_options['options_subtotal_nc']) && ! TSubtotal::isModSubtotalLine($l)) { |
29 | 33 | _updateLineNC($propal->element, $propal->id, $l->id, $l->array_options['options_subtotal_nc']); |
30 | 34 | } |
@@ -99,7 +99,10 @@ discard block |
||
99 | 99 | |
100 | 100 | // Get source company |
101 | 101 | $this->emetteur=$mysoc; |
102 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
102 | + if (empty($this->emetteur->country_code)) { |
|
103 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
104 | + } |
|
105 | + // By default, if was not defined |
|
103 | 106 | |
104 | 107 | // Define position of columns |
105 | 108 | $this->posxdesc=$this->marge_gauche+1; |
@@ -108,11 +111,15 @@ discard block |
||
108 | 111 | $this->posxqty=145; |
109 | 112 | $this->posxdiscount=162; |
110 | 113 | $this->postotalht=174; |
111 | - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; |
|
114 | + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { |
|
115 | + $this->posxtva=$this->posxup; |
|
116 | + } |
|
112 | 117 | $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
113 | - if ($this->page_largeur < 210) // To work with US executive format |
|
118 | + if ($this->page_largeur < 210) { |
|
119 | + // To work with US executive format |
|
114 | 120 | { |
115 | 121 | $this->posxpicture-=20; |
122 | + } |
|
116 | 123 | $this->posxtva-=20; |
117 | 124 | $this->posxup-=20; |
118 | 125 | $this->posxqty-=20; |
@@ -142,9 +149,13 @@ discard block |
||
142 | 149 | { |
143 | 150 | global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes; |
144 | 151 | |
145 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
152 | + if (! is_object($outputlangs)) { |
|
153 | + $outputlangs=$langs; |
|
154 | + } |
|
146 | 155 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
147 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
156 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
157 | + $outputlangs->charset_output='ISO-8859-1'; |
|
158 | + } |
|
148 | 159 | |
149 | 160 | $outputlangs->load("main"); |
150 | 161 | $outputlangs->load("dict"); |
@@ -163,7 +174,9 @@ discard block |
||
163 | 174 | |
164 | 175 | for ($i = 0 ; $i < $nblignes ; $i++) |
165 | 176 | { |
166 | - if (empty($object->lines[$i]->fk_product)) continue; |
|
177 | + if (empty($object->lines[$i]->fk_product)) { |
|
178 | + continue; |
|
179 | + } |
|
167 | 180 | |
168 | 181 | $objphoto->fetch($object->lines[$i]->fk_product); |
169 | 182 | |
@@ -171,8 +184,7 @@ discard block |
||
171 | 184 | { |
172 | 185 | $pdir[0] = get_exdir($objphoto->id,2) . $objphoto->id ."/photos/"; |
173 | 186 | $pdir[1] = dol_sanitizeFileName($objphoto->ref).'/'; |
174 | - } |
|
175 | - else |
|
187 | + } else |
|
176 | 188 | { |
177 | 189 | $pdir[0] = dol_sanitizeFileName($objphoto->ref).'/'; |
178 | 190 | $pdir[1] = get_exdir($objphoto->id,2) . $objphoto->id ."/photos/"; |
@@ -187,18 +199,18 @@ discard block |
||
187 | 199 | |
188 | 200 | foreach ($objphoto->liste_photos($dir,1) as $key => $obj) |
189 | 201 | { |
190 | - if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo |
|
202 | + if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) { |
|
203 | + // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo |
|
191 | 204 | { |
192 | 205 | if ($obj['photo_vignette']) |
193 | 206 | { |
194 | 207 | $filename= $obj['photo_vignette']; |
195 | - } |
|
196 | - else |
|
208 | + } |
|
209 | + } else |
|
197 | 210 | { |
198 | 211 | $filename=$obj['photo']; |
199 | 212 | } |
200 | - } |
|
201 | - else |
|
213 | + } else |
|
202 | 214 | { |
203 | 215 | $filename=$obj['photo']; |
204 | 216 | } |
@@ -209,11 +221,15 @@ discard block |
||
209 | 221 | } |
210 | 222 | } |
211 | 223 | |
212 | - if ($realpath && $arephoto) $realpatharray[$i]=$realpath; |
|
224 | + if ($realpath && $arephoto) { |
|
225 | + $realpatharray[$i]=$realpath; |
|
226 | + } |
|
213 | 227 | } |
214 | 228 | } |
215 | 229 | |
216 | - if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; |
|
230 | + if (count($realpatharray) == 0) { |
|
231 | + $this->posxpicture=$this->posxtva; |
|
232 | + } |
|
217 | 233 | |
218 | 234 | if ($conf->propal->dir_output) |
219 | 235 | { |
@@ -228,8 +244,7 @@ discard block |
||
228 | 244 | { |
229 | 245 | $dir = $conf->propal->dir_output; |
230 | 246 | $file = $dir . "/SPECIMEN.pdf"; |
231 | - } |
|
232 | - else |
|
247 | + } else |
|
233 | 248 | { |
234 | 249 | $objectref = dol_sanitizeFileName($object->ref); |
235 | 250 | $dir = $conf->propal->dir_output . "/" . $objectref; |
@@ -288,7 +303,9 @@ discard block |
||
288 | 303 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
289 | 304 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
290 | 305 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialProposal")); |
291 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
306 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
307 | + $pdf->SetCompression(false); |
|
308 | + } |
|
292 | 309 | |
293 | 310 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
294 | 311 | |
@@ -312,7 +329,9 @@ discard block |
||
312 | 329 | |
313 | 330 | // New page |
314 | 331 | $pdf->AddPage(); |
315 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
332 | + if (! empty($tplidx)) { |
|
333 | + $pdf->useTemplate($tplidx); |
|
334 | + } |
|
316 | 335 | $pagenb++; |
317 | 336 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
318 | 337 | $pdf->SetFont('','', $default_font_size - 1); |
@@ -334,7 +353,9 @@ discard block |
||
334 | 353 | $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
335 | 354 | $salerepobj=new User($this->db); |
336 | 355 | $salerepobj->fetch($salereparray[0]['id']); |
337 | - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
356 | + if (! empty($salerepobj->signature)) { |
|
357 | + $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
358 | + } |
|
338 | 359 | } |
339 | 360 | } |
340 | 361 | if ($notetoshow) |
@@ -352,8 +373,7 @@ discard block |
||
352 | 373 | |
353 | 374 | $tab_height = $tab_height - $height_note; |
354 | 375 | $tab_top = $nexY+6; |
355 | - } |
|
356 | - else |
|
376 | + } else |
|
357 | 377 | { |
358 | 378 | $height_note=0; |
359 | 379 | } |
@@ -438,7 +458,9 @@ discard block |
||
438 | 458 | |
439 | 459 | // Define size of image if we need it |
440 | 460 | $imglinesize=array(); |
441 | - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
461 | + if (! empty($realpatharray[$i])) { |
|
462 | + $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
463 | + } |
|
442 | 464 | |
443 | 465 | $pdf->setTopMargin($tab_top_newpage); |
444 | 466 | $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
@@ -449,11 +471,17 @@ discard block |
||
449 | 471 | $posYAfterDescription=0; |
450 | 472 | |
451 | 473 | // We start with Photo of product line |
452 | - 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 |
|
474 | + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
475 | + // If photo too high, we moved completely on new page |
|
453 | 476 | { |
454 | 477 | $pdf->AddPage('','',true); |
455 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
456 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
478 | + } |
|
479 | + if (! empty($tplidx)) { |
|
480 | + $pdf->useTemplate($tplidx); |
|
481 | + } |
|
482 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
483 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
484 | + } |
|
457 | 485 | $pdf->setPage($pageposbefore+1); |
458 | 486 | |
459 | 487 | $curY = $tab_top_newpage; |
@@ -475,9 +503,11 @@ discard block |
||
475 | 503 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); |
476 | 504 | |
477 | 505 | $pageposafter=$pdf->getPage(); |
478 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
506 | + if ($pageposafter > $pageposbefore) { |
|
507 | + // There is a pagebreak |
|
479 | 508 | { |
480 | 509 | $pdf->rollbackTransaction(true); |
510 | + } |
|
481 | 511 | $pageposafter=$pageposbefore; |
482 | 512 | //print $pageposafter.'-'.$pageposbefore;exit; |
483 | 513 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
@@ -486,23 +516,27 @@ discard block |
||
486 | 516 | $pageposafter=$pdf->getPage(); |
487 | 517 | $posyafter=$pdf->GetY(); |
488 | 518 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
489 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
519 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
520 | + // There is no space left for total+free text |
|
490 | 521 | { |
491 | 522 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
492 | 523 | { |
493 | 524 | $pdf->AddPage('','',true); |
494 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
495 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
525 | + } |
|
526 | + if (! empty($tplidx)) { |
|
527 | + $pdf->useTemplate($tplidx); |
|
528 | + } |
|
529 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
530 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
531 | + } |
|
496 | 532 | $pdf->setPage($pageposafter+1); |
497 | 533 | } |
498 | - } |
|
499 | - else |
|
534 | + } else |
|
500 | 535 | { |
501 | 536 | // We found a page break |
502 | 537 | $showpricebeforepagebreak=0; |
503 | 538 | } |
504 | - } |
|
505 | - else // No pagebreak |
|
539 | + } else // No pagebreak |
|
506 | 540 | { |
507 | 541 | $pdf->commitTransaction(); |
508 | 542 | } |
@@ -597,29 +631,43 @@ discard block |
||
597 | 631 | $localtax1_type=$object->lines[$i]->localtax1_type; |
598 | 632 | $localtax2_type=$object->lines[$i]->localtax2_type; |
599 | 633 | |
600 | - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
601 | - if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
602 | - if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
634 | + if ($object->remise_percent) { |
|
635 | + $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
636 | + } |
|
637 | + if ($object->remise_percent) { |
|
638 | + $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
639 | + } |
|
640 | + if ($object->remise_percent) { |
|
641 | + $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
642 | + } |
|
603 | 643 | |
604 | 644 | $vatrate=(string) $object->lines[$i]->tva_tx; |
605 | 645 | |
606 | 646 | // Retrieve type from database for backward compatibility with old records |
607 | 647 | if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined |
608 | - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax |
|
648 | + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) { |
|
649 | + // and there is local tax |
|
609 | 650 | { |
610 | 651 | $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc); |
652 | + } |
|
611 | 653 | $localtax1_type = $localtaxtmp_array[0]; |
612 | 654 | $localtax2_type = $localtaxtmp_array[2]; |
613 | 655 | } |
614 | 656 | |
615 | 657 | // retrieve global local tax |
616 | - if ($localtax1_type && $localtax1ligne != 0) |
|
617 | - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
618 | - if ($localtax2_type && $localtax2ligne != 0) |
|
619 | - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
658 | + if ($localtax1_type && $localtax1ligne != 0) { |
|
659 | + $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
660 | + } |
|
661 | + if ($localtax2_type && $localtax2ligne != 0) { |
|
662 | + $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
663 | + } |
|
620 | 664 | |
621 | - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
|
622 | - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=''; |
|
665 | + if (($object->lines[$i]->info_bits & 0x01) == 0x01) { |
|
666 | + $vatrate.='*'; |
|
667 | + } |
|
668 | + if (! isset($this->tva[$vatrate])) { |
|
669 | + $this->tva[$vatrate]=''; |
|
670 | + } |
|
623 | 671 | |
624 | 672 | if (!empty($object->lines[$i]->TTotal_tva)) |
625 | 673 | { |
@@ -627,13 +675,16 @@ discard block |
||
627 | 675 | { |
628 | 676 | $this->tva[$vatrate] += $tvaligne; |
629 | 677 | } |
630 | - } |
|
631 | - else { |
|
678 | + } else { |
|
632 | 679 | // standard |
633 | - if(!empty($tvaligne)) $this->tva[$vatrate] += $tvaligne; |
|
680 | + if(!empty($tvaligne)) { |
|
681 | + $this->tva[$vatrate] += $tvaligne; |
|
682 | + } |
|
634 | 683 | } |
635 | 684 | |
636 | - if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; |
|
685 | + if ($posYAfterImage > $posYAfterDescription) { |
|
686 | + $nexY=$posYAfterImage; |
|
687 | + } |
|
637 | 688 | |
638 | 689 | // Add line |
639 | 690 | if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
@@ -654,8 +705,7 @@ discard block |
||
654 | 705 | if ($pagenb == 1) |
655 | 706 | { |
656 | 707 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
657 | - } |
|
658 | - else |
|
708 | + } else |
|
659 | 709 | { |
660 | 710 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
661 | 711 | } |
@@ -663,24 +713,29 @@ discard block |
||
663 | 713 | $pagenb++; |
664 | 714 | $pdf->setPage($pagenb); |
665 | 715 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
666 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
716 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
717 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
718 | + } |
|
667 | 719 | } |
668 | 720 | if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
669 | 721 | { |
670 | 722 | if ($pagenb == 1) |
671 | 723 | { |
672 | 724 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
673 | - } |
|
674 | - else |
|
725 | + } else |
|
675 | 726 | { |
676 | 727 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
677 | 728 | } |
678 | 729 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
679 | 730 | // New page |
680 | 731 | $pdf->AddPage(); |
681 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
732 | + if (! empty($tplidx)) { |
|
733 | + $pdf->useTemplate($tplidx); |
|
734 | + } |
|
682 | 735 | $pagenb++; |
683 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
736 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
737 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
738 | + } |
|
684 | 739 | } |
685 | 740 | } |
686 | 741 | |
@@ -689,8 +744,7 @@ discard block |
||
689 | 744 | { |
690 | 745 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
691 | 746 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
692 | - } |
|
693 | - else |
|
747 | + } else |
|
694 | 748 | { |
695 | 749 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
696 | 750 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
@@ -714,7 +768,9 @@ discard block |
||
714 | 768 | |
715 | 769 | // Pied de page |
716 | 770 | $this->_pagefoot($pdf,$object,$outputlangs); |
717 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
771 | + if (method_exists($pdf,'AliasNbPages')) { |
|
772 | + $pdf->AliasNbPages(); |
|
773 | + } |
|
718 | 774 | |
719 | 775 | $pdf->Close(); |
720 | 776 | |
@@ -726,18 +782,17 @@ discard block |
||
726 | 782 | global $action; |
727 | 783 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
728 | 784 | |
729 | - if (! empty($conf->global->MAIN_UMASK)) |
|
730 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
785 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
786 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
787 | + } |
|
731 | 788 | |
732 | 789 | return 1; // Pas d'erreur |
733 | - } |
|
734 | - else |
|
790 | + } else |
|
735 | 791 | { |
736 | 792 | $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
737 | 793 | return 0; |
738 | 794 | } |
739 | - } |
|
740 | - else |
|
795 | + } else |
|
741 | 796 | { |
742 | 797 | $this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR"); |
743 | 798 | return 0; |
@@ -804,10 +859,11 @@ discard block |
||
804 | 859 | $pdf->MultiCell(80, 4, $dlp, 0, 'L'); |
805 | 860 | |
806 | 861 | $posy=$pdf->GetY()+1; |
807 | - } |
|
808 | - elseif ($object->availability_code || $object->availability) // Show availability conditions |
|
862 | + } elseif ($object->availability_code || $object->availability) { |
|
863 | + // Show availability conditions |
|
809 | 864 | { |
810 | 865 | $pdf->SetFont('','B', $default_font_size - 2); |
866 | + } |
|
811 | 867 | $pdf->SetXY($this->marge_gauche, $posy); |
812 | 868 | $titre = $outputlangs->transnoentities("AvailabilityPeriod").':'; |
813 | 869 | $pdf->MultiCell(80, 4, $titre, 0, 'L'); |
@@ -961,10 +1017,12 @@ discard block |
||
961 | 1017 | |
962 | 1018 | // Tableau total |
963 | 1019 | $col1x = 120; $col2x = 170; |
964 | - if ($this->page_largeur < 210) // To work with US executive format |
|
1020 | + if ($this->page_largeur < 210) { |
|
1021 | + // To work with US executive format |
|
965 | 1022 | { |
966 | 1023 | $col2x-=20; |
967 | 1024 | } |
1025 | + } |
|
968 | 1026 | $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
969 | 1027 | |
970 | 1028 | $useborder=0; |
@@ -988,23 +1046,26 @@ discard block |
||
988 | 1046 | if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) |
989 | 1047 | { |
990 | 1048 | // Nothing to do |
991 | - } |
|
992 | - else |
|
1049 | + } else |
|
993 | 1050 | { |
994 | 1051 | //Local tax 1 before VAT |
995 | 1052 | //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
996 | 1053 | //{ |
997 | 1054 | foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
998 | 1055 | { |
999 | - if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
1056 | + if (in_array((string) $localtax_type, array('1','3','5'))) { |
|
1057 | + continue; |
|
1058 | + } |
|
1000 | 1059 | |
1001 | 1060 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1002 | 1061 | { |
1003 | - if ($tvakey!=0) // On affiche pas taux 0 |
|
1062 | + if ($tvakey!=0) { |
|
1063 | + // On affiche pas taux 0 |
|
1004 | 1064 | { |
1005 | 1065 | //$this->atleastoneratenotnull++; |
1006 | 1066 | |
1007 | 1067 | $index++; |
1068 | + } |
|
1008 | 1069 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1009 | 1070 | |
1010 | 1071 | $tvacompl=''; |
@@ -1028,17 +1089,21 @@ discard block |
||
1028 | 1089 | //{ |
1029 | 1090 | foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
1030 | 1091 | { |
1031 | - if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
1092 | + if (in_array((string) $localtax_type, array('1','3','5'))) { |
|
1093 | + continue; |
|
1094 | + } |
|
1032 | 1095 | |
1033 | 1096 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1034 | 1097 | { |
1035 | - if ($tvakey!=0) // On affiche pas taux 0 |
|
1098 | + if ($tvakey!=0) { |
|
1099 | + // On affiche pas taux 0 |
|
1036 | 1100 | { |
1037 | 1101 | //$this->atleastoneratenotnull++; |
1038 | 1102 | |
1039 | 1103 | |
1040 | 1104 | |
1041 | 1105 | $index++; |
1106 | + } |
|
1042 | 1107 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1043 | 1108 | |
1044 | 1109 | $tvacompl=''; |
@@ -1061,9 +1126,11 @@ discard block |
||
1061 | 1126 | // VAT |
1062 | 1127 | foreach($this->tva as $tvakey => $tvaval) |
1063 | 1128 | { |
1064 | - if ($tvakey > 0) // On affiche pas taux 0 |
|
1129 | + if ($tvakey > 0) { |
|
1130 | + // On affiche pas taux 0 |
|
1065 | 1131 | { |
1066 | 1132 | $this->atleastoneratenotnull++; |
1133 | + } |
|
1067 | 1134 | |
1068 | 1135 | $index++; |
1069 | 1136 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -1088,15 +1155,19 @@ discard block |
||
1088 | 1155 | //{ |
1089 | 1156 | foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
1090 | 1157 | { |
1091 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1158 | + if (in_array((string) $localtax_type, array('2','4','6'))) { |
|
1159 | + continue; |
|
1160 | + } |
|
1092 | 1161 | |
1093 | 1162 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1094 | 1163 | { |
1095 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1164 | + if ($tvakey != 0) { |
|
1165 | + // On affiche pas taux 0 |
|
1096 | 1166 | { |
1097 | 1167 | //$this->atleastoneratenotnull++; |
1098 | 1168 | |
1099 | 1169 | $index++; |
1170 | + } |
|
1100 | 1171 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1101 | 1172 | |
1102 | 1173 | $tvacompl=''; |
@@ -1120,16 +1191,20 @@ discard block |
||
1120 | 1191 | //{ |
1121 | 1192 | foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
1122 | 1193 | { |
1123 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1194 | + if (in_array((string) $localtax_type, array('2','4','6'))) { |
|
1195 | + continue; |
|
1196 | + } |
|
1124 | 1197 | |
1125 | 1198 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1126 | 1199 | { |
1127 | 1200 | // retrieve global local tax |
1128 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1201 | + if ($tvakey != 0) { |
|
1202 | + // On affiche pas taux 0 |
|
1129 | 1203 | { |
1130 | 1204 | //$this->atleastoneratenotnull++; |
1131 | 1205 | |
1132 | 1206 | $index++; |
1207 | + } |
|
1133 | 1208 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1134 | 1209 | |
1135 | 1210 | $tvacompl=''; |
@@ -1230,7 +1305,9 @@ discard block |
||
1230 | 1305 | |
1231 | 1306 | // Force to disable hidetop and hidebottom |
1232 | 1307 | $hidebottom=0; |
1233 | - if ($hidetop) $hidetop=-1; |
|
1308 | + if ($hidetop) { |
|
1309 | + $hidetop=-1; |
|
1310 | + } |
|
1234 | 1311 | |
1235 | 1312 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
1236 | 1313 | |
@@ -1245,7 +1322,9 @@ discard block |
||
1245 | 1322 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
1246 | 1323 | |
1247 | 1324 | //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
1248 | - 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)); |
|
1325 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { |
|
1326 | + $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)); |
|
1327 | + } |
|
1249 | 1328 | } |
1250 | 1329 | |
1251 | 1330 | $pdf->SetDrawColor(128,128,128); |
@@ -1360,16 +1439,14 @@ discard block |
||
1360 | 1439 | { |
1361 | 1440 | $height=pdf_getHeightForLogo($logo); |
1362 | 1441 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
1363 | - } |
|
1364 | - else |
|
1442 | + } else |
|
1365 | 1443 | { |
1366 | 1444 | $pdf->SetTextColor(200,0,0); |
1367 | 1445 | $pdf->SetFont('','B',$default_font_size - 2); |
1368 | 1446 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
1369 | 1447 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
1370 | 1448 | } |
1371 | - } |
|
1372 | - else |
|
1449 | + } else |
|
1373 | 1450 | { |
1374 | 1451 | $text=$this->emetteur->name; |
1375 | 1452 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -1438,7 +1515,9 @@ discard block |
||
1438 | 1515 | // Show sender |
1439 | 1516 | $posy=42; |
1440 | 1517 | $posx=$this->marge_gauche; |
1441 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1518 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1519 | + $posx=$this->page_largeur-$this->marge_droite-80; |
|
1520 | + } |
|
1442 | 1521 | $hautcadre=40; |
1443 | 1522 | |
1444 | 1523 | // Show sender frame |
@@ -1476,11 +1555,13 @@ discard block |
||
1476 | 1555 | if (! empty($usecontact)) |
1477 | 1556 | { |
1478 | 1557 | // On peut utiliser le nom de la societe du contact |
1479 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; |
|
1480 | - else $socname = $object->thirdparty->name; |
|
1558 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
1559 | + $socname = $object->contact->socname; |
|
1560 | + } else { |
|
1561 | + $socname = $object->thirdparty->name; |
|
1562 | + } |
|
1481 | 1563 | $carac_client_name=$outputlangs->convToOutputCharset($socname); |
1482 | - } |
|
1483 | - else |
|
1564 | + } else |
|
1484 | 1565 | { |
1485 | 1566 | $carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name); |
1486 | 1567 | } |
@@ -1489,10 +1570,15 @@ discard block |
||
1489 | 1570 | |
1490 | 1571 | // Show recipient |
1491 | 1572 | $widthrecbox=100; |
1492 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1573 | + if ($this->page_largeur < 210) { |
|
1574 | + $widthrecbox=84; |
|
1575 | + } |
|
1576 | + // To work with US executive format |
|
1493 | 1577 | $posy=42; |
1494 | 1578 | $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
1495 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1579 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1580 | + $posx=$this->marge_gauche; |
|
1581 | + } |
|
1496 | 1582 | |
1497 | 1583 | // Show recipient frame |
1498 | 1584 | $pdf->SetTextColor(0,0,0); |
@@ -100,7 +100,10 @@ discard block |
||
100 | 100 | |
101 | 101 | // Get source company |
102 | 102 | $this->emetteur=$mysoc; |
103 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
103 | + if (empty($this->emetteur->country_code)) { |
|
104 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
105 | + } |
|
106 | + // By default, if was not defined |
|
104 | 107 | |
105 | 108 | // Define position of columns |
106 | 109 | $this->posxdesc=$this->marge_gauche+1; |
@@ -109,11 +112,15 @@ discard block |
||
109 | 112 | $this->posxqty=145; |
110 | 113 | $this->posxdiscount=162; |
111 | 114 | $this->postotalht=174; |
112 | - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; |
|
115 | + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { |
|
116 | + $this->posxtva=$this->posxup; |
|
117 | + } |
|
113 | 118 | $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
114 | - if ($this->page_largeur < 210) // To work with US executive format |
|
119 | + if ($this->page_largeur < 210) { |
|
120 | + // To work with US executive format |
|
115 | 121 | { |
116 | 122 | $this->posxpicture-=20; |
123 | + } |
|
117 | 124 | $this->posxtva-=20; |
118 | 125 | $this->posxup-=20; |
119 | 126 | $this->posxqty-=20; |
@@ -144,9 +151,13 @@ discard block |
||
144 | 151 | { |
145 | 152 | global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes; |
146 | 153 | |
147 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
154 | + if (! is_object($outputlangs)) { |
|
155 | + $outputlangs=$langs; |
|
156 | + } |
|
148 | 157 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
149 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
158 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
159 | + $outputlangs->charset_output='ISO-8859-1'; |
|
160 | + } |
|
150 | 161 | |
151 | 162 | $outputlangs->load("main"); |
152 | 163 | $outputlangs->load("dict"); |
@@ -162,7 +173,9 @@ discard block |
||
162 | 173 | { |
163 | 174 | for ($i = 0 ; $i < $nblignes ; $i++) |
164 | 175 | { |
165 | - if (empty($object->lines[$i]->fk_product)) continue; |
|
176 | + if (empty($object->lines[$i]->fk_product)) { |
|
177 | + continue; |
|
178 | + } |
|
166 | 179 | |
167 | 180 | $objphoto = new Product($this->db); |
168 | 181 | $objphoto->fetch($object->lines[$i]->fk_product); |
@@ -179,10 +192,14 @@ discard block |
||
179 | 192 | break; |
180 | 193 | } |
181 | 194 | |
182 | - if ($realpath) $realpatharray[$i]=$realpath; |
|
195 | + if ($realpath) { |
|
196 | + $realpatharray[$i]=$realpath; |
|
197 | + } |
|
183 | 198 | } |
184 | 199 | } |
185 | - if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; |
|
200 | + if (count($realpatharray) == 0) { |
|
201 | + $this->posxpicture=$this->posxtva; |
|
202 | + } |
|
186 | 203 | |
187 | 204 | if ($conf->facture->dir_output) |
188 | 205 | { |
@@ -199,8 +216,7 @@ discard block |
||
199 | 216 | { |
200 | 217 | $dir = $conf->facture->dir_output; |
201 | 218 | $file = $dir . "/SPECIMEN.pdf"; |
202 | - } |
|
203 | - else |
|
219 | + } else |
|
204 | 220 | { |
205 | 221 | $objectref = dol_sanitizeFileName($object->ref); |
206 | 222 | $dir = $conf->facture->dir_output . "/" . $objectref; |
@@ -259,7 +275,9 @@ discard block |
||
259 | 275 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
260 | 276 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
261 | 277 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Invoice")); |
262 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
278 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
279 | + $pdf->SetCompression(false); |
|
280 | + } |
|
263 | 281 | |
264 | 282 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
265 | 283 | |
@@ -283,7 +301,9 @@ discard block |
||
283 | 301 | |
284 | 302 | // New page |
285 | 303 | $pdf->AddPage(); |
286 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
304 | + if (! empty($tplidx)) { |
|
305 | + $pdf->useTemplate($tplidx); |
|
306 | + } |
|
287 | 307 | $pagenb++; |
288 | 308 | |
289 | 309 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
@@ -306,7 +326,9 @@ discard block |
||
306 | 326 | $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
307 | 327 | $salerepobj=new User($this->db); |
308 | 328 | $salerepobj->fetch($salereparray[0]['id']); |
309 | - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
329 | + if (! empty($salerepobj->signature)) { |
|
330 | + $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
331 | + } |
|
310 | 332 | } |
311 | 333 | } |
312 | 334 | if ($notetoshow) |
@@ -324,8 +346,7 @@ discard block |
||
324 | 346 | |
325 | 347 | $tab_height = $tab_height - $height_note; |
326 | 348 | $tab_top = $nexY+6; |
327 | - } |
|
328 | - else |
|
349 | + } else |
|
329 | 350 | { |
330 | 351 | $height_note=0; |
331 | 352 | } |
@@ -409,7 +430,9 @@ discard block |
||
409 | 430 | |
410 | 431 | // Define size of image if we need it |
411 | 432 | $imglinesize=array(); |
412 | - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
433 | + if (! empty($realpatharray[$i])) { |
|
434 | + $imglinesize=pdf_getSizeForImage($realpatharray[$i]); |
|
435 | + } |
|
413 | 436 | |
414 | 437 | $pdf->setTopMargin($tab_top_newpage); |
415 | 438 | $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
@@ -420,11 +443,17 @@ discard block |
||
420 | 443 | $posYAfterDescription=0; |
421 | 444 | |
422 | 445 | // We start with Photo of product line |
423 | - 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 |
|
446 | + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
447 | + // If photo too high, we moved completely on new page |
|
424 | 448 | { |
425 | 449 | $pdf->AddPage('','',true); |
426 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
427 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
450 | + } |
|
451 | + if (! empty($tplidx)) { |
|
452 | + $pdf->useTemplate($tplidx); |
|
453 | + } |
|
454 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
455 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
456 | + } |
|
428 | 457 | $pdf->setPage($pageposbefore+1); |
429 | 458 | |
430 | 459 | $curY = $tab_top_newpage; |
@@ -445,9 +474,11 @@ discard block |
||
445 | 474 | $pdf->startTransaction(); |
446 | 475 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); |
447 | 476 | $pageposafter=$pdf->getPage(); |
448 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
477 | + if ($pageposafter > $pageposbefore) { |
|
478 | + // There is a pagebreak |
|
449 | 479 | { |
450 | 480 | $pdf->rollbackTransaction(true); |
481 | + } |
|
451 | 482 | $pageposafter=$pageposbefore; |
452 | 483 | //print $pageposafter.'-'.$pageposbefore;exit; |
453 | 484 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
@@ -455,23 +486,27 @@ discard block |
||
455 | 486 | $pageposafter=$pdf->getPage(); |
456 | 487 | $posyafter=$pdf->GetY(); |
457 | 488 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
458 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
489 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
490 | + // There is no space left for total+free text |
|
459 | 491 | { |
460 | 492 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
461 | 493 | { |
462 | 494 | $pdf->AddPage('','',true); |
463 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
464 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
495 | + } |
|
496 | + if (! empty($tplidx)) { |
|
497 | + $pdf->useTemplate($tplidx); |
|
498 | + } |
|
499 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
500 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
501 | + } |
|
465 | 502 | $pdf->setPage($pageposafter+1); |
466 | 503 | } |
467 | - } |
|
468 | - else |
|
504 | + } else |
|
469 | 505 | { |
470 | 506 | // We found a page break |
471 | 507 | $showpricebeforepagebreak=0; |
472 | 508 | } |
473 | - } |
|
474 | - else // No pagebreak |
|
509 | + } else // No pagebreak |
|
475 | 510 | { |
476 | 511 | $pdf->commitTransaction(); |
477 | 512 | } |
@@ -562,29 +597,43 @@ discard block |
||
562 | 597 | $localtax1_type=$object->lines[$i]->localtax1_type; |
563 | 598 | $localtax2_type=$object->lines[$i]->localtax2_type; |
564 | 599 | |
565 | - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
566 | - if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
567 | - if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
600 | + if ($object->remise_percent) { |
|
601 | + $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
602 | + } |
|
603 | + if ($object->remise_percent) { |
|
604 | + $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
605 | + } |
|
606 | + if ($object->remise_percent) { |
|
607 | + $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
608 | + } |
|
568 | 609 | |
569 | 610 | $vatrate=(string) $object->lines[$i]->tva_tx; |
570 | 611 | |
571 | 612 | // Retrieve type from database for backward compatibility with old records |
572 | 613 | if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined |
573 | - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax |
|
614 | + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) { |
|
615 | + // and there is local tax |
|
574 | 616 | { |
575 | 617 | $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0, $object->thirdparty, $mysoc); |
618 | + } |
|
576 | 619 | $localtax1_type = $localtaxtmp_array[0]; |
577 | 620 | $localtax2_type = $localtaxtmp_array[2]; |
578 | 621 | } |
579 | 622 | |
580 | 623 | // retrieve global local tax |
581 | - if ($localtax1_type && $localtax1ligne != 0) |
|
582 | - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
583 | - if ($localtax2_type && $localtax2ligne != 0) |
|
584 | - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
624 | + if ($localtax1_type && $localtax1ligne != 0) { |
|
625 | + $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
626 | + } |
|
627 | + if ($localtax2_type && $localtax2ligne != 0) { |
|
628 | + $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
629 | + } |
|
585 | 630 | |
586 | - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
|
587 | - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=''; |
|
631 | + if (($object->lines[$i]->info_bits & 0x01) == 0x01) { |
|
632 | + $vatrate.='*'; |
|
633 | + } |
|
634 | + if (! isset($this->tva[$vatrate])) { |
|
635 | + $this->tva[$vatrate]=''; |
|
636 | + } |
|
588 | 637 | |
589 | 638 | if (!empty($object->lines[$i]->TTotal_tva)) |
590 | 639 | { |
@@ -592,13 +641,16 @@ discard block |
||
592 | 641 | { |
593 | 642 | $this->tva[$vatrate] += $tvaligne; |
594 | 643 | } |
595 | - } |
|
596 | - else { |
|
644 | + } else { |
|
597 | 645 | // standard |
598 | - if(!empty($tvaligne)) $this->tva[$vatrate] += $tvaligne; |
|
646 | + if(!empty($tvaligne)) { |
|
647 | + $this->tva[$vatrate] += $tvaligne; |
|
648 | + } |
|
599 | 649 | } |
600 | 650 | |
601 | - if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; |
|
651 | + if ($posYAfterImage > $posYAfterDescription) { |
|
652 | + $nexY=$posYAfterImage; |
|
653 | + } |
|
602 | 654 | |
603 | 655 | // Add line |
604 | 656 | if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
@@ -619,8 +671,7 @@ discard block |
||
619 | 671 | if ($pagenb == 1) |
620 | 672 | { |
621 | 673 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
622 | - } |
|
623 | - else |
|
674 | + } else |
|
624 | 675 | { |
625 | 676 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
626 | 677 | } |
@@ -628,24 +679,29 @@ discard block |
||
628 | 679 | $pagenb++; |
629 | 680 | $pdf->setPage($pagenb); |
630 | 681 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
631 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
682 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
683 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
684 | + } |
|
632 | 685 | } |
633 | 686 | if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
634 | 687 | { |
635 | 688 | if ($pagenb == 1) |
636 | 689 | { |
637 | 690 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
638 | - } |
|
639 | - else |
|
691 | + } else |
|
640 | 692 | { |
641 | 693 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
642 | 694 | } |
643 | 695 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
644 | 696 | // New page |
645 | 697 | $pdf->AddPage(); |
646 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
698 | + if (! empty($tplidx)) { |
|
699 | + $pdf->useTemplate($tplidx); |
|
700 | + } |
|
647 | 701 | $pagenb++; |
648 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
702 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
703 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
704 | + } |
|
649 | 705 | } |
650 | 706 | } |
651 | 707 | |
@@ -654,8 +710,7 @@ discard block |
||
654 | 710 | { |
655 | 711 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
656 | 712 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
657 | - } |
|
658 | - else |
|
713 | + } else |
|
659 | 714 | { |
660 | 715 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
661 | 716 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
@@ -677,7 +732,9 @@ discard block |
||
677 | 732 | |
678 | 733 | // Pied de page |
679 | 734 | $this->_pagefoot($pdf,$object,$outputlangs); |
680 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
735 | + if (method_exists($pdf,'AliasNbPages')) { |
|
736 | + $pdf->AliasNbPages(); |
|
737 | + } |
|
681 | 738 | |
682 | 739 | $pdf->Close(); |
683 | 740 | |
@@ -689,18 +746,17 @@ discard block |
||
689 | 746 | global $action; |
690 | 747 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
691 | 748 | |
692 | - if (! empty($conf->global->MAIN_UMASK)) |
|
693 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
749 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
750 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
751 | + } |
|
694 | 752 | |
695 | 753 | return 1; // Pas d'erreur |
696 | - } |
|
697 | - else |
|
754 | + } else |
|
698 | 755 | { |
699 | 756 | $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
700 | 757 | return 0; |
701 | 758 | } |
702 | - } |
|
703 | - else |
|
759 | + } else |
|
704 | 760 | { |
705 | 761 | $this->error=$langs->trans("ErrorConstantNotDefined","FAC_OUTPUTDIR"); |
706 | 762 | return 0; |
@@ -724,21 +780,27 @@ discard block |
||
724 | 780 | global $conf; |
725 | 781 | |
726 | 782 | $sign=1; |
727 | - if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
783 | + if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { |
|
784 | + $sign=-1; |
|
785 | + } |
|
728 | 786 | |
729 | 787 | $tab3_posx = 120; |
730 | 788 | $tab3_top = $posy + 8; |
731 | 789 | $tab3_width = 80; |
732 | 790 | $tab3_height = 4; |
733 | - if ($this->page_largeur < 210) // To work with US executive format |
|
791 | + if ($this->page_largeur < 210) { |
|
792 | + // To work with US executive format |
|
734 | 793 | { |
735 | 794 | $tab3_posx -= 20; |
736 | 795 | } |
796 | + } |
|
737 | 797 | |
738 | 798 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
739 | 799 | |
740 | 800 | $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); |
741 | - if ($object->type == 2) $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone"); |
|
801 | + if ($object->type == 2) { |
|
802 | + $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone"); |
|
803 | + } |
|
742 | 804 | |
743 | 805 | $pdf->SetFont('','', $default_font_size - 3); |
744 | 806 | $pdf->SetXY($tab3_posx, $tab3_top - 4); |
@@ -779,9 +841,13 @@ discard block |
||
779 | 841 | $y+=3; |
780 | 842 | $obj = $this->db->fetch_object($resql); |
781 | 843 | |
782 | - if ($obj->type == 2) $text=$outputlangs->trans("CreditNote"); |
|
783 | - elseif ($obj->type == 3) $text=$outputlangs->trans("Deposit"); |
|
784 | - else $text=$outputlangs->trans("UnknownType"); |
|
844 | + if ($obj->type == 2) { |
|
845 | + $text=$outputlangs->trans("CreditNote"); |
|
846 | + } elseif ($obj->type == 3) { |
|
847 | + $text=$outputlangs->trans("Deposit"); |
|
848 | + } else { |
|
849 | + $text=$outputlangs->trans("UnknownType"); |
|
850 | + } |
|
785 | 851 | |
786 | 852 | $invoice->fetch($obj->fk_facture_source); |
787 | 853 | |
@@ -798,8 +864,7 @@ discard block |
||
798 | 864 | |
799 | 865 | $i++; |
800 | 866 | } |
801 | - } |
|
802 | - else |
|
867 | + } else |
|
803 | 868 | { |
804 | 869 | $this->error=$this->db->lasterror(); |
805 | 870 | return -1; |
@@ -836,8 +901,7 @@ discard block |
||
836 | 901 | |
837 | 902 | $i++; |
838 | 903 | } |
839 | - } |
|
840 | - else |
|
904 | + } else |
|
841 | 905 | { |
842 | 906 | $this->error=$this->db->lasterror(); |
843 | 907 | return -1; |
@@ -1017,7 +1081,9 @@ discard block |
||
1017 | 1081 | global $conf,$mysoc; |
1018 | 1082 | |
1019 | 1083 | $sign=1; |
1020 | - if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
1084 | + if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { |
|
1085 | + $sign=-1; |
|
1086 | + } |
|
1021 | 1087 | |
1022 | 1088 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
1023 | 1089 | |
@@ -1027,10 +1093,12 @@ discard block |
||
1027 | 1093 | |
1028 | 1094 | // Tableau total |
1029 | 1095 | $col1x = 120; $col2x = 170; |
1030 | - if ($this->page_largeur < 210) // To work with US executive format |
|
1096 | + if ($this->page_largeur < 210) { |
|
1097 | + // To work with US executive format |
|
1031 | 1098 | { |
1032 | 1099 | $col2x-=20; |
1033 | 1100 | } |
1101 | + } |
|
1034 | 1102 | $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
1035 | 1103 | |
1036 | 1104 | $useborder=0; |
@@ -1053,23 +1121,26 @@ discard block |
||
1053 | 1121 | if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) |
1054 | 1122 | { |
1055 | 1123 | // Nothing to do |
1056 | - } |
|
1057 | - else |
|
1124 | + } else |
|
1058 | 1125 | { |
1059 | 1126 | //Local tax 1 before VAT |
1060 | 1127 | //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
1061 | 1128 | //{ |
1062 | 1129 | foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
1063 | 1130 | { |
1064 | - if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
1131 | + if (in_array((string) $localtax_type, array('1','3','5'))) { |
|
1132 | + continue; |
|
1133 | + } |
|
1065 | 1134 | |
1066 | 1135 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1067 | 1136 | { |
1068 | - if ($tvakey!=0) // On affiche pas taux 0 |
|
1137 | + if ($tvakey!=0) { |
|
1138 | + // On affiche pas taux 0 |
|
1069 | 1139 | { |
1070 | 1140 | //$this->atleastoneratenotnull++; |
1071 | 1141 | |
1072 | 1142 | $index++; |
1143 | + } |
|
1073 | 1144 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1074 | 1145 | |
1075 | 1146 | $tvacompl=''; |
@@ -1094,17 +1165,21 @@ discard block |
||
1094 | 1165 | //{ |
1095 | 1166 | foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
1096 | 1167 | { |
1097 | - if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
1168 | + if (in_array((string) $localtax_type, array('1','3','5'))) { |
|
1169 | + continue; |
|
1170 | + } |
|
1098 | 1171 | |
1099 | 1172 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1100 | 1173 | { |
1101 | - if ($tvakey!=0) // On affiche pas taux 0 |
|
1174 | + if ($tvakey!=0) { |
|
1175 | + // On affiche pas taux 0 |
|
1102 | 1176 | { |
1103 | 1177 | //$this->atleastoneratenotnull++; |
1104 | 1178 | |
1105 | 1179 | |
1106 | 1180 | |
1107 | 1181 | $index++; |
1182 | + } |
|
1108 | 1183 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1109 | 1184 | |
1110 | 1185 | $tvacompl=''; |
@@ -1127,9 +1202,11 @@ discard block |
||
1127 | 1202 | // VAT |
1128 | 1203 | foreach($this->tva as $tvakey => $tvaval) |
1129 | 1204 | { |
1130 | - if ($tvakey > 0) // On affiche pas taux 0 |
|
1205 | + if ($tvakey > 0) { |
|
1206 | + // On affiche pas taux 0 |
|
1131 | 1207 | { |
1132 | 1208 | $this->atleastoneratenotnull++; |
1209 | + } |
|
1133 | 1210 | |
1134 | 1211 | $index++; |
1135 | 1212 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -1154,15 +1231,19 @@ discard block |
||
1154 | 1231 | //{ |
1155 | 1232 | foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
1156 | 1233 | { |
1157 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1234 | + if (in_array((string) $localtax_type, array('2','4','6'))) { |
|
1235 | + continue; |
|
1236 | + } |
|
1158 | 1237 | |
1159 | 1238 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1160 | 1239 | { |
1161 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1240 | + if ($tvakey != 0) { |
|
1241 | + // On affiche pas taux 0 |
|
1162 | 1242 | { |
1163 | 1243 | //$this->atleastoneratenotnull++; |
1164 | 1244 | |
1165 | 1245 | $index++; |
1246 | + } |
|
1166 | 1247 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1167 | 1248 | |
1168 | 1249 | $tvacompl=''; |
@@ -1186,16 +1267,20 @@ discard block |
||
1186 | 1267 | //{ |
1187 | 1268 | foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
1188 | 1269 | { |
1189 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1270 | + if (in_array((string) $localtax_type, array('2','4','6'))) { |
|
1271 | + continue; |
|
1272 | + } |
|
1190 | 1273 | |
1191 | 1274 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1192 | 1275 | { |
1193 | 1276 | // retrieve global local tax |
1194 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1277 | + if ($tvakey != 0) { |
|
1278 | + // On affiche pas taux 0 |
|
1195 | 1279 | { |
1196 | 1280 | //$this->atleastoneratenotnull++; |
1197 | 1281 | |
1198 | 1282 | $index++; |
1283 | + } |
|
1199 | 1284 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1200 | 1285 | |
1201 | 1286 | $tvacompl=''; |
@@ -1245,7 +1330,9 @@ discard block |
||
1245 | 1330 | $depositsamount=$object->getSumDepositsUsed(); |
1246 | 1331 | //print "x".$creditnoteamount."-".$depositsamount;exit; |
1247 | 1332 | $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); |
1248 | - if ($object->paye) $resteapayer=0; |
|
1333 | + if ($object->paye) { |
|
1334 | + $resteapayer=0; |
|
1335 | + } |
|
1249 | 1336 | |
1250 | 1337 | if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) |
1251 | 1338 | { |
@@ -1314,7 +1401,9 @@ discard block |
||
1314 | 1401 | |
1315 | 1402 | // Force to disable hidetop and hidebottom |
1316 | 1403 | $hidebottom=0; |
1317 | - if ($hidetop) $hidetop=-1; |
|
1404 | + if ($hidetop) { |
|
1405 | + $hidetop=-1; |
|
1406 | + } |
|
1318 | 1407 | |
1319 | 1408 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
1320 | 1409 | |
@@ -1329,7 +1418,9 @@ discard block |
||
1329 | 1418 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
1330 | 1419 | |
1331 | 1420 | //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
1332 | - 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)); |
|
1421 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { |
|
1422 | + $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)); |
|
1423 | + } |
|
1333 | 1424 | } |
1334 | 1425 | |
1335 | 1426 | $pdf->SetDrawColor(128,128,128); |
@@ -1444,16 +1535,14 @@ discard block |
||
1444 | 1535 | { |
1445 | 1536 | $height=pdf_getHeightForLogo($logo); |
1446 | 1537 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
1447 | - } |
|
1448 | - else |
|
1538 | + } else |
|
1449 | 1539 | { |
1450 | 1540 | $pdf->SetTextColor(200,0,0); |
1451 | 1541 | $pdf->SetFont('','B',$default_font_size - 2); |
1452 | 1542 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
1453 | 1543 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
1454 | 1544 | } |
1455 | - } |
|
1456 | - else |
|
1545 | + } else |
|
1457 | 1546 | { |
1458 | 1547 | $text=$this->emetteur->name; |
1459 | 1548 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -1463,10 +1552,18 @@ discard block |
||
1463 | 1552 | $pdf->SetXY($posx,$posy); |
1464 | 1553 | $pdf->SetTextColor(0,0,60); |
1465 | 1554 | $title=$outputlangs->transnoentities("Invoice"); |
1466 | - if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement"); |
|
1467 | - if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir"); |
|
1468 | - if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit"); |
|
1469 | - if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProFormat"); |
|
1555 | + if ($object->type == 1) { |
|
1556 | + $title=$outputlangs->transnoentities("InvoiceReplacement"); |
|
1557 | + } |
|
1558 | + if ($object->type == 2) { |
|
1559 | + $title=$outputlangs->transnoentities("InvoiceAvoir"); |
|
1560 | + } |
|
1561 | + if ($object->type == 3) { |
|
1562 | + $title=$outputlangs->transnoentities("InvoiceDeposit"); |
|
1563 | + } |
|
1564 | + if ($object->type == 4) { |
|
1565 | + $title=$outputlangs->transnoentities("InvoiceProFormat"); |
|
1566 | + } |
|
1470 | 1567 | $pdf->MultiCell(100, 3, $title, '', 'R'); |
1471 | 1568 | |
1472 | 1569 | $pdf->SetFont('','B',$default_font_size); |
@@ -1553,7 +1650,9 @@ discard block |
||
1553 | 1650 | // Show sender |
1554 | 1651 | $posy=42; |
1555 | 1652 | $posx=$this->marge_gauche; |
1556 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1653 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1654 | + $posx=$this->page_largeur-$this->marge_droite-80; |
|
1655 | + } |
|
1557 | 1656 | $hautcadre=40; |
1558 | 1657 | |
1559 | 1658 | // Show sender frame |
@@ -1592,11 +1691,13 @@ discard block |
||
1592 | 1691 | if (! empty($usecontact)) |
1593 | 1692 | { |
1594 | 1693 | // On peut utiliser le nom de la societe du contact |
1595 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; |
|
1596 | - else $socname = $object->thirdparty->name; |
|
1694 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
1695 | + $socname = $object->contact->socname; |
|
1696 | + } else { |
|
1697 | + $socname = $object->thirdparty->name; |
|
1698 | + } |
|
1597 | 1699 | $carac_client_name=$outputlangs->convToOutputCharset($socname); |
1598 | - } |
|
1599 | - else |
|
1700 | + } else |
|
1600 | 1701 | { |
1601 | 1702 | $carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name); |
1602 | 1703 | } |
@@ -1605,10 +1706,15 @@ discard block |
||
1605 | 1706 | |
1606 | 1707 | // Show recipient |
1607 | 1708 | $widthrecbox=100; |
1608 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1709 | + if ($this->page_largeur < 210) { |
|
1710 | + $widthrecbox=84; |
|
1711 | + } |
|
1712 | + // To work with US executive format |
|
1609 | 1713 | $posy=42; |
1610 | 1714 | $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
1611 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1715 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1716 | + $posx=$this->marge_gauche; |
|
1717 | + } |
|
1612 | 1718 | |
1613 | 1719 | // Show recipient frame |
1614 | 1720 | $pdf->SetTextColor(0,0,0); |
@@ -100,7 +100,10 @@ discard block |
||
100 | 100 | |
101 | 101 | // Get source company |
102 | 102 | $this->emetteur=$mysoc; |
103 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
103 | + if (empty($this->emetteur->country_code)) { |
|
104 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
105 | + } |
|
106 | + // By default, if was not defined |
|
104 | 107 | |
105 | 108 | // Define position of columns |
106 | 109 | $this->posxdesc=$this->marge_gauche+1; |
@@ -109,11 +112,15 @@ discard block |
||
109 | 112 | $this->posxqty=145; |
110 | 113 | $this->posxdiscount=162; |
111 | 114 | $this->postotalht=174; |
112 | - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; |
|
115 | + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { |
|
116 | + $this->posxtva=$this->posxup; |
|
117 | + } |
|
113 | 118 | $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
114 | - if ($this->page_largeur < 210) // To work with US executive format |
|
119 | + if ($this->page_largeur < 210) { |
|
120 | + // To work with US executive format |
|
115 | 121 | { |
116 | 122 | $this->posxpicture-=20; |
123 | + } |
|
117 | 124 | $this->posxtva-=20; |
118 | 125 | $this->posxup-=20; |
119 | 126 | $this->posxqty-=20; |
@@ -143,9 +150,13 @@ discard block |
||
143 | 150 | { |
144 | 151 | global $user,$langs,$conf,$mysoc,$db,$hookmanager; |
145 | 152 | |
146 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
153 | + if (! is_object($outputlangs)) { |
|
154 | + $outputlangs=$langs; |
|
155 | + } |
|
147 | 156 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
148 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
157 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
158 | + $outputlangs->charset_output='ISO-8859-1'; |
|
159 | + } |
|
149 | 160 | |
150 | 161 | $outputlangs->load("main"); |
151 | 162 | $outputlangs->load("dict"); |
@@ -170,8 +181,7 @@ discard block |
||
170 | 181 | { |
171 | 182 | $dir = $conf->commande->dir_output; |
172 | 183 | $file = $dir . "/SPECIMEN.pdf"; |
173 | - } |
|
174 | - else |
|
184 | + } else |
|
175 | 185 | { |
176 | 186 | $objectref = dol_sanitizeFileName($object->ref); |
177 | 187 | $dir = $conf->commande->dir_output . "/" . $objectref; |
@@ -230,7 +240,9 @@ discard block |
||
230 | 240 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
231 | 241 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
232 | 242 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")); |
233 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
243 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
244 | + $pdf->SetCompression(false); |
|
245 | + } |
|
234 | 246 | |
235 | 247 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
236 | 248 | |
@@ -254,7 +266,9 @@ discard block |
||
254 | 266 | |
255 | 267 | // New page |
256 | 268 | $pdf->AddPage(); |
257 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
269 | + if (! empty($tplidx)) { |
|
270 | + $pdf->useTemplate($tplidx); |
|
271 | + } |
|
258 | 272 | $pagenb++; |
259 | 273 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
260 | 274 | $pdf->SetFont('','', $default_font_size - 1); |
@@ -277,7 +291,9 @@ discard block |
||
277 | 291 | $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
278 | 292 | $salerepobj=new User($this->db); |
279 | 293 | $salerepobj->fetch($salereparray[0]['id']); |
280 | - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
294 | + if (! empty($salerepobj->signature)) { |
|
295 | + $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
296 | + } |
|
281 | 297 | } |
282 | 298 | } |
283 | 299 | if ($notetoshow) |
@@ -295,8 +311,7 @@ discard block |
||
295 | 311 | |
296 | 312 | $tab_height = $tab_height - $height_note; |
297 | 313 | $tab_top = $nexY+6; |
298 | - } |
|
299 | - else |
|
314 | + } else |
|
300 | 315 | { |
301 | 316 | $height_note=0; |
302 | 317 | } |
@@ -391,32 +406,38 @@ discard block |
||
391 | 406 | $pdf->startTransaction(); |
392 | 407 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); |
393 | 408 | $pageposafter=$pdf->getPage(); |
394 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
409 | + if ($pageposafter > $pageposbefore) { |
|
410 | + // There is a pagebreak |
|
395 | 411 | { |
396 | 412 | $pdf->rollbackTransaction(true); |
413 | + } |
|
397 | 414 | $pageposafter=$pageposbefore; |
398 | 415 | //print $pageposafter.'-'.$pageposbefore;exit; |
399 | 416 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
400 | 417 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); |
401 | 418 | $pageposafter=$pdf->getPage(); |
402 | 419 | $posyafter=$pdf->GetY(); |
403 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
420 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
421 | + // There is no space left for total+free text |
|
404 | 422 | { |
405 | 423 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
406 | 424 | { |
407 | 425 | $pdf->AddPage('','',true); |
408 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
409 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
426 | + } |
|
427 | + if (! empty($tplidx)) { |
|
428 | + $pdf->useTemplate($tplidx); |
|
429 | + } |
|
430 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
431 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
432 | + } |
|
410 | 433 | $pdf->setPage($pageposafter+1); |
411 | 434 | } |
412 | - } |
|
413 | - else |
|
435 | + } else |
|
414 | 436 | { |
415 | 437 | // We found a page break |
416 | 438 | $showpricebeforepagebreak=0; |
417 | 439 | } |
418 | - } |
|
419 | - else // No pagebreak |
|
440 | + } else // No pagebreak |
|
420 | 441 | { |
421 | 442 | $pdf->commitTransaction(); |
422 | 443 | } |
@@ -508,29 +529,43 @@ discard block |
||
508 | 529 | $localtax1_type=$object->lines[$i]->localtax1_type; |
509 | 530 | $localtax2_type=$object->lines[$i]->localtax2_type; |
510 | 531 | |
511 | - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
512 | - if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
513 | - if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
532 | + if ($object->remise_percent) { |
|
533 | + $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
534 | + } |
|
535 | + if ($object->remise_percent) { |
|
536 | + $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
537 | + } |
|
538 | + if ($object->remise_percent) { |
|
539 | + $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
540 | + } |
|
514 | 541 | |
515 | 542 | $vatrate=(string) $object->lines[$i]->tva_tx; |
516 | 543 | |
517 | 544 | // Retrieve type from database for backward compatibility with old records |
518 | 545 | if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined |
519 | - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax |
|
546 | + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) { |
|
547 | + // and there is local tax |
|
520 | 548 | { |
521 | 549 | $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc); |
550 | + } |
|
522 | 551 | $localtax1_type = $localtaxtmp_array[0]; |
523 | 552 | $localtax2_type = $localtaxtmp_array[2]; |
524 | 553 | } |
525 | 554 | |
526 | 555 | // retrieve global local tax |
527 | - if ($localtax1_type && $localtax1ligne != 0) |
|
528 | - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
529 | - if ($localtax2_type && $localtax2ligne != 0) |
|
530 | - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
556 | + if ($localtax1_type && $localtax1ligne != 0) { |
|
557 | + $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
558 | + } |
|
559 | + if ($localtax2_type && $localtax2ligne != 0) { |
|
560 | + $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
561 | + } |
|
531 | 562 | |
532 | - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
|
533 | - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; |
|
563 | + if (($object->lines[$i]->info_bits & 0x01) == 0x01) { |
|
564 | + $vatrate.='*'; |
|
565 | + } |
|
566 | + if (! isset($this->tva[$vatrate])) { |
|
567 | + $this->tva[$vatrate]=0; |
|
568 | + } |
|
534 | 569 | |
535 | 570 | if (!empty($object->lines[$i]->TTotal_tva)) |
536 | 571 | { |
@@ -538,10 +573,11 @@ discard block |
||
538 | 573 | { |
539 | 574 | $this->tva[$vatrate] += $tvaligne; |
540 | 575 | } |
541 | - } |
|
542 | - else { |
|
576 | + } else { |
|
543 | 577 | // standard |
544 | - if(!empty($tvaligne)) $this->tva[$vatrate] += $tvaligne; |
|
578 | + if(!empty($tvaligne)) { |
|
579 | + $this->tva[$vatrate] += $tvaligne; |
|
580 | + } |
|
545 | 581 | } |
546 | 582 | |
547 | 583 | // Add line |
@@ -563,8 +599,7 @@ discard block |
||
563 | 599 | if ($pagenb == 1) |
564 | 600 | { |
565 | 601 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
566 | - } |
|
567 | - else |
|
602 | + } else |
|
568 | 603 | { |
569 | 604 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
570 | 605 | } |
@@ -572,24 +607,29 @@ discard block |
||
572 | 607 | $pagenb++; |
573 | 608 | $pdf->setPage($pagenb); |
574 | 609 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
575 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
610 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
611 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
612 | + } |
|
576 | 613 | } |
577 | 614 | if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
578 | 615 | { |
579 | 616 | if ($pagenb == 1) |
580 | 617 | { |
581 | 618 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
582 | - } |
|
583 | - else |
|
619 | + } else |
|
584 | 620 | { |
585 | 621 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
586 | 622 | } |
587 | 623 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
588 | 624 | // New page |
589 | 625 | $pdf->AddPage(); |
590 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
626 | + if (! empty($tplidx)) { |
|
627 | + $pdf->useTemplate($tplidx); |
|
628 | + } |
|
591 | 629 | $pagenb++; |
592 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
630 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
631 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
632 | + } |
|
593 | 633 | } |
594 | 634 | } |
595 | 635 | |
@@ -598,8 +638,7 @@ discard block |
||
598 | 638 | { |
599 | 639 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
600 | 640 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
601 | - } |
|
602 | - else |
|
641 | + } else |
|
603 | 642 | { |
604 | 643 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
605 | 644 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
@@ -621,7 +660,9 @@ discard block |
||
621 | 660 | |
622 | 661 | // Pied de page |
623 | 662 | $this->_pagefoot($pdf,$object,$outputlangs); |
624 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
663 | + if (method_exists($pdf,'AliasNbPages')) { |
|
664 | + $pdf->AliasNbPages(); |
|
665 | + } |
|
625 | 666 | |
626 | 667 | $pdf->Close(); |
627 | 668 | |
@@ -633,18 +674,17 @@ discard block |
||
633 | 674 | global $action; |
634 | 675 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
635 | 676 | |
636 | - if (! empty($conf->global->MAIN_UMASK)) |
|
637 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
677 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
678 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
679 | + } |
|
638 | 680 | |
639 | 681 | return 1; // Pas d'erreur |
640 | - } |
|
641 | - else |
|
682 | + } else |
|
642 | 683 | { |
643 | 684 | $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
644 | 685 | return 0; |
645 | 686 | } |
646 | - } |
|
647 | - else |
|
687 | + } else |
|
648 | 688 | { |
649 | 689 | $this->error=$langs->trans("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR"); |
650 | 690 | return 0; |
@@ -754,10 +794,11 @@ discard block |
||
754 | 794 | $pdf->MultiCell(80, 4, $dlp, 0, 'L'); |
755 | 795 | |
756 | 796 | $posy=$pdf->GetY()+1; |
757 | - } |
|
758 | - elseif ($object->availability_code || $object->availability) // Show availability conditions |
|
797 | + } elseif ($object->availability_code || $object->availability) { |
|
798 | + // Show availability conditions |
|
759 | 799 | { |
760 | 800 | $pdf->SetFont('','B', $default_font_size - 2); |
801 | + } |
|
761 | 802 | $pdf->SetXY($this->marge_gauche, $posy); |
762 | 803 | $titre = $outputlangs->transnoentities("AvailabilityPeriod").':'; |
763 | 804 | $pdf->MultiCell(80, 4, $titre, 0, 'L'); |
@@ -875,10 +916,12 @@ discard block |
||
875 | 916 | |
876 | 917 | // Tableau total |
877 | 918 | $col1x = 120; $col2x = 170; |
878 | - if ($this->page_largeur < 210) // To work with US executive format |
|
919 | + if ($this->page_largeur < 210) { |
|
920 | + // To work with US executive format |
|
879 | 921 | { |
880 | 922 | $col2x-=20; |
881 | 923 | } |
924 | + } |
|
882 | 925 | $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
883 | 926 | |
884 | 927 | $useborder=0; |
@@ -902,22 +945,25 @@ discard block |
||
902 | 945 | if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) |
903 | 946 | { |
904 | 947 | // Nothing to do |
905 | - } |
|
906 | - else |
|
948 | + } else |
|
907 | 949 | { |
908 | 950 | //Local tax 1 before VAT |
909 | 951 | //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
910 | 952 | //{ |
911 | 953 | foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
912 | 954 | { |
913 | - if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
955 | + if (in_array((string) $localtax_type, array('1','3','5'))) { |
|
956 | + continue; |
|
957 | + } |
|
914 | 958 | foreach( $localtax_rate as $tvakey => $tvaval ) |
915 | 959 | { |
916 | - if ($tvakey!=0) // On affiche pas taux 0 |
|
960 | + if ($tvakey!=0) { |
|
961 | + // On affiche pas taux 0 |
|
917 | 962 | { |
918 | 963 | //$this->atleastoneratenotnull++; |
919 | 964 | |
920 | 965 | $index++; |
966 | + } |
|
921 | 967 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
922 | 968 | |
923 | 969 | $tvacompl=''; |
@@ -941,16 +987,20 @@ discard block |
||
941 | 987 | //{ |
942 | 988 | foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
943 | 989 | { |
944 | - if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
990 | + if (in_array((string) $localtax_type, array('1','3','5'))) { |
|
991 | + continue; |
|
992 | + } |
|
945 | 993 | foreach( $localtax_rate as $tvakey => $tvaval ) |
946 | 994 | { |
947 | - if ($tvakey!=0) // On affiche pas taux 0 |
|
995 | + if ($tvakey!=0) { |
|
996 | + // On affiche pas taux 0 |
|
948 | 997 | { |
949 | 998 | //$this->atleastoneratenotnull++; |
950 | 999 | |
951 | 1000 | |
952 | 1001 | |
953 | 1002 | $index++; |
1003 | + } |
|
954 | 1004 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
955 | 1005 | |
956 | 1006 | $tvacompl=''; |
@@ -973,9 +1023,11 @@ discard block |
||
973 | 1023 | // VAT |
974 | 1024 | foreach($this->tva as $tvakey => $tvaval) |
975 | 1025 | { |
976 | - if ($tvakey > 0) // On affiche pas taux 0 |
|
1026 | + if ($tvakey > 0) { |
|
1027 | + // On affiche pas taux 0 |
|
977 | 1028 | { |
978 | 1029 | $this->atleastoneratenotnull++; |
1030 | + } |
|
979 | 1031 | |
980 | 1032 | $index++; |
981 | 1033 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -1000,15 +1052,19 @@ discard block |
||
1000 | 1052 | //{ |
1001 | 1053 | foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
1002 | 1054 | { |
1003 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1055 | + if (in_array((string) $localtax_type, array('2','4','6'))) { |
|
1056 | + continue; |
|
1057 | + } |
|
1004 | 1058 | |
1005 | 1059 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1006 | 1060 | { |
1007 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1061 | + if ($tvakey != 0) { |
|
1062 | + // On affiche pas taux 0 |
|
1008 | 1063 | { |
1009 | 1064 | //$this->atleastoneratenotnull++; |
1010 | 1065 | |
1011 | 1066 | $index++; |
1067 | + } |
|
1012 | 1068 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1013 | 1069 | |
1014 | 1070 | $tvacompl=''; |
@@ -1032,15 +1088,19 @@ discard block |
||
1032 | 1088 | //{ |
1033 | 1089 | foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
1034 | 1090 | { |
1035 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1091 | + if (in_array((string) $localtax_type, array('2','4','6'))) { |
|
1092 | + continue; |
|
1093 | + } |
|
1036 | 1094 | |
1037 | 1095 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1038 | 1096 | { |
1039 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1097 | + if ($tvakey != 0) { |
|
1098 | + // On affiche pas taux 0 |
|
1040 | 1099 | { |
1041 | 1100 | //$this->atleastoneratenotnull++; |
1042 | 1101 | |
1043 | 1102 | $index++; |
1103 | + } |
|
1044 | 1104 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1045 | 1105 | |
1046 | 1106 | $tvacompl=''; |
@@ -1081,7 +1141,9 @@ discard block |
||
1081 | 1141 | //$depositsamount=$object->getSumDepositsUsed(); |
1082 | 1142 | //print "x".$creditnoteamount."-".$depositsamount;exit; |
1083 | 1143 | $resteapayer = price2num(doubleval($object->total_ttc) - doubleval($deja_regle) - $creditnoteamount - $depositsamount, 'MT'); |
1084 | - if (! empty($object->paye)) $resteapayer=0; |
|
1144 | + if (! empty($object->paye)) { |
|
1145 | + $resteapayer=0; |
|
1146 | + } |
|
1085 | 1147 | |
1086 | 1148 | if ($deja_regle > 0) |
1087 | 1149 | { |
@@ -1128,7 +1190,9 @@ discard block |
||
1128 | 1190 | |
1129 | 1191 | // Force to disable hidetop and hidebottom |
1130 | 1192 | $hidebottom=0; |
1131 | - if ($hidetop) $hidetop=-1; |
|
1193 | + if ($hidetop) { |
|
1194 | + $hidetop=-1; |
|
1195 | + } |
|
1132 | 1196 | |
1133 | 1197 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
1134 | 1198 | |
@@ -1143,7 +1207,9 @@ discard block |
||
1143 | 1207 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
1144 | 1208 | |
1145 | 1209 | //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
1146 | - 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)); |
|
1210 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { |
|
1211 | + $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)); |
|
1212 | + } |
|
1147 | 1213 | } |
1148 | 1214 | |
1149 | 1215 | $pdf->SetDrawColor(128,128,128); |
@@ -1249,16 +1315,14 @@ discard block |
||
1249 | 1315 | { |
1250 | 1316 | $height=pdf_getHeightForLogo($logo); |
1251 | 1317 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
1252 | - } |
|
1253 | - else |
|
1318 | + } else |
|
1254 | 1319 | { |
1255 | 1320 | $pdf->SetTextColor(200,0,0); |
1256 | 1321 | $pdf->SetFont('','B', $default_font_size -2); |
1257 | 1322 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
1258 | 1323 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
1259 | 1324 | } |
1260 | - } |
|
1261 | - else |
|
1325 | + } else |
|
1262 | 1326 | { |
1263 | 1327 | $text=$this->emetteur->name; |
1264 | 1328 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -1306,7 +1370,9 @@ discard block |
||
1306 | 1370 | // Show sender |
1307 | 1371 | $posy=42; |
1308 | 1372 | $posx=$this->marge_gauche; |
1309 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1373 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1374 | + $posx=$this->page_largeur-$this->marge_droite-80; |
|
1375 | + } |
|
1310 | 1376 | $hautcadre=40; |
1311 | 1377 | |
1312 | 1378 | // Show sender frame |
@@ -1345,11 +1411,13 @@ discard block |
||
1345 | 1411 | if (! empty($usecontact)) |
1346 | 1412 | { |
1347 | 1413 | // On peut utiliser le nom de la societe du contact |
1348 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; |
|
1349 | - else $socname = $object->thirdparty->name; |
|
1414 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
1415 | + $socname = $object->contact->socname; |
|
1416 | + } else { |
|
1417 | + $socname = $object->thirdparty->name; |
|
1418 | + } |
|
1350 | 1419 | $carac_client_name=$outputlangs->convToOutputCharset($socname); |
1351 | - } |
|
1352 | - else |
|
1420 | + } else |
|
1353 | 1421 | { |
1354 | 1422 | $carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name); |
1355 | 1423 | } |
@@ -1358,10 +1426,15 @@ discard block |
||
1358 | 1426 | |
1359 | 1427 | // Show recipient |
1360 | 1428 | $widthrecbox=100; |
1361 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1429 | + if ($this->page_largeur < 210) { |
|
1430 | + $widthrecbox=84; |
|
1431 | + } |
|
1432 | + // To work with US executive format |
|
1362 | 1433 | $posy=42; |
1363 | 1434 | $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
1364 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1435 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1436 | + $posx=$this->marge_gauche; |
|
1437 | + } |
|
1365 | 1438 | |
1366 | 1439 | // Show recipient frame |
1367 | 1440 | $pdf->SetTextColor(0,0,0); |
@@ -89,12 +89,14 @@ discard block |
||
89 | 89 | |
90 | 90 | if ($this->version == 'development') { |
91 | 91 | return $langs->trans("Development"); |
92 | - } elseif ($this->version == 'experimental') |
|
93 | - |
|
92 | + } elseif ($this->version == 'experimental') { |
|
93 | + |
|
94 | 94 | return $langs->trans("Experimental"); |
95 | - elseif ($this->version == 'dolibarr') return DOL_VERSION; |
|
96 | - elseif ($this->version) return $this->version; |
|
97 | - else { |
|
95 | + } elseif ($this->version == 'dolibarr') { |
|
96 | + return DOL_VERSION; |
|
97 | + } elseif ($this->version) { |
|
98 | + return $this->version; |
|
99 | + } else { |
|
98 | 100 | return $langs->trans("Unknown"); |
99 | 101 | } |
100 | 102 | } |
@@ -122,14 +124,18 @@ discard block |
||
122 | 124 | $subtotal_line_found = false; |
123 | 125 | foreach ($parent->lines as $k => &$line) |
124 | 126 | { |
125 | - if ($line->rang < $rang) continue; |
|
126 | - elseif ($line->rang == $rang) // Je suis sur la ligne de titre où je souhaite ajouter ma nouvelle ligne en fin de bloc |
|
127 | + if ($line->rang < $rang) { |
|
128 | + continue; |
|
129 | + } elseif ($line->rang == $rang) { |
|
130 | + // Je suis sur la ligne de titre où je souhaite ajouter ma nouvelle ligne en fin de bloc |
|
127 | 131 | { |
128 | 132 | $title_level = $line->qty; |
129 | 133 | } |
130 | - elseif (!$subtotal_line_found && $title_level > -1 && ($line->qty == 100 - $title_level)) // Le level de mon titre a été trouvé avant, donc maintenant je vais m'arrêter jusqu'à trouver un sous-total |
|
134 | + } elseif (!$subtotal_line_found && $title_level > -1 && ($line->qty == 100 - $title_level)) { |
|
135 | + // Le level de mon titre a été trouvé avant, donc maintenant je vais m'arrêter jusqu'à trouver un sous-total |
|
131 | 136 | { |
132 | 137 | $subtotal_line_found = true; |
138 | + } |
|
133 | 139 | $rang = $line->rang; |
134 | 140 | } |
135 | 141 | |
@@ -193,8 +199,11 @@ discard block |
||
193 | 199 | break; |
194 | 200 | } |
195 | 201 | |
196 | - if (!empty($conf->global->SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK)) $this->addToEnd($parent, $object, $rang); |
|
197 | - else $this->addToBegin($parent, $object, $rang); |
|
202 | + if (!empty($conf->global->SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK)) { |
|
203 | + $this->addToEnd($parent, $object, $rang); |
|
204 | + } else { |
|
205 | + $this->addToBegin($parent, $object, $rang); |
|
206 | + } |
|
198 | 207 | |
199 | 208 | } |
200 | 209 | |
@@ -210,8 +219,7 @@ discard block |
||
210 | 219 | if ($subtotal_skip) |
211 | 220 | { |
212 | 221 | $subtotal_skip = false; |
213 | - } |
|
214 | - else |
|
222 | + } else |
|
215 | 223 | { |
216 | 224 | $subtotal_add_title_bloc_from_orderstoinvoice = GETPOST('subtotal_add_title_bloc_from_orderstoinvoice'); |
217 | 225 | if (!empty($subtotal_add_title_bloc_from_orderstoinvoice)) |
@@ -224,8 +232,7 @@ discard block |
||
224 | 232 | if (!$is_supplier){ |
225 | 233 | $facture = new Facture($this->db); |
226 | 234 | $ret = $facture->fetch($object->fk_facture); |
227 | - } |
|
228 | - else |
|
235 | + } else |
|
229 | 236 | { |
230 | 237 | $facture = new FactureFournisseur($this->db); |
231 | 238 | $ret = $facture->fetch($object->fk_facture_fourn); |
@@ -236,14 +243,19 @@ discard block |
||
236 | 243 | $rang = !empty($subtotal_current_rang) ? $subtotal_current_rang : $object->rang; |
237 | 244 | // Si le fk_commande courrant est différent alors on change de commande => ajout d'un titre |
238 | 245 | if ($current_fk_commande != $subtotal_bloc_previous_fk_commande ) { |
239 | - if (!$is_supplier) $commande = new Commande($this->db); |
|
240 | - else $commande = new CommandeFournisseur($this->db); |
|
246 | + if (!$is_supplier) { |
|
247 | + $commande = new Commande($this->db); |
|
248 | + } else { |
|
249 | + $commande = new CommandeFournisseur($this->db); |
|
250 | + } |
|
241 | 251 | $commande->fetch($current_fk_commande); |
242 | 252 | |
243 | 253 | $label = $conf->global->SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE; |
244 | 254 | if (empty($label)) { |
245 | 255 | $label = 'Commande [__REFORDER__]'; |
246 | - if (!$is_supplier) $label .= ' - Référence client : [__REFCUSTOMER__]'; |
|
256 | + if (!$is_supplier) { |
|
257 | + $label .= ' - Référence client : [__REFCUSTOMER__]'; |
|
258 | + } |
|
247 | 259 | } |
248 | 260 | $label = str_replace(array('__REFORDER__', '__REFCUSTOMER__'), array($commande->ref, $commande->ref_client), $label); |
249 | 261 | |
@@ -286,7 +298,9 @@ discard block |
||
286 | 298 | |
287 | 299 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && in_array($action, array('LINEPROPAL_INSERT', 'LINEPROPAL_UPDATE', 'LINEORDER_INSERT', 'LINEORDER_UPDATE', 'LINEBILL_INSERT', 'LINEBILL_UPDATE', 'LINEBILL_SUPPLIER_CREATE', 'LINEBILL_SUPPLIER_UPDATE'))) |
288 | 300 | { |
289 | - if(! function_exists('_updateLineNC')) dol_include_once('/subtotal/lib/subtotal.lib.php'); |
|
301 | + if(! function_exists('_updateLineNC')) { |
|
302 | + dol_include_once('/subtotal/lib/subtotal.lib.php'); |
|
303 | + } |
|
290 | 304 | |
291 | 305 | $doli_action = GETPOST('action'); |
292 | 306 | $set = GETPOST('set'); |
@@ -304,32 +318,50 @@ discard block |
||
304 | 318 | $object->total_ht = $object->total_tva = $object->total_ttc = $object->total_localtax1 = $object->total_localtax2 = |
305 | 319 | $object->multicurrency_total_ht = $object->multicurrency_total_tva = $object->multicurrency_total_ttc = 0; |
306 | 320 | |
307 | - if ($object->element == 'propal') $res = $object->update(1); |
|
308 | - else $res = $object->update($user, 1); |
|
321 | + if ($object->element == 'propal') { |
|
322 | + $res = $object->update(1); |
|
323 | + } else { |
|
324 | + $res = $object->update($user, 1); |
|
325 | + } |
|
309 | 326 | |
310 | - if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
327 | + if ($res > 0) { |
|
328 | + setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
329 | + } |
|
311 | 330 | break; |
312 | 331 | } |
313 | 332 | } |
314 | 333 | |
315 | 334 | // $object correspond à la ligne ajoutée |
316 | - if(empty($object->array_options)) $object->fetch_optionals(); |
|
335 | + if(empty($object->array_options)) { |
|
336 | + $object->fetch_optionals(); |
|
337 | + } |
|
317 | 338 | |
318 | 339 | if(! empty($object->array_options['options_subtotal_nc'])) { |
319 | 340 | $object->total_ht = $object->total_tva = $object->total_ttc = $object->total_localtax1 = $object->total_localtax2 = |
320 | 341 | $object->multicurrency_total_ht = $object->multicurrency_total_tva = $object->multicurrency_total_ttc = 0; |
321 | 342 | |
322 | - if ($object->element == 'propaldet') $res = $object->update(1); |
|
323 | - else $res = $object->update($user, 1); |
|
343 | + if ($object->element == 'propaldet') { |
|
344 | + $res = $object->update(1); |
|
345 | + } else { |
|
346 | + $res = $object->update($user, 1); |
|
347 | + } |
|
324 | 348 | |
325 | - if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
349 | + if ($res > 0) { |
|
350 | + setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
351 | + } |
|
326 | 352 | } |
327 | 353 | |
328 | 354 | // Correction d'un bug lors de la création d'une commande depuis une propale qui a, au moins, une ligne NC |
329 | 355 | $parent_element = ''; |
330 | - if($object->element == 'propaldet') $parent_element = 'propal'; |
|
331 | - if($object->element == 'commandedet') $parent_element = 'commande'; |
|
332 | - if($object->element == 'facturedet') $parent_element = 'facture'; |
|
356 | + if($object->element == 'propaldet') { |
|
357 | + $parent_element = 'propal'; |
|
358 | + } |
|
359 | + if($object->element == 'commandedet') { |
|
360 | + $parent_element = 'commande'; |
|
361 | + } |
|
362 | + if($object->element == 'facturedet') { |
|
363 | + $parent_element = 'facture'; |
|
364 | + } |
|
333 | 365 | |
334 | 366 | if(! empty($parent_element) && ! empty($object->array_options['options_subtotal_nc'])) { |
335 | 367 | _updateLineNC($parent_element, $object->{'fk_'.$parent_element}, $object->id, $object->array_options['options_subtotal_nc'], 1); |
@@ -529,26 +561,38 @@ discard block |
||
529 | 561 | ); |
530 | 562 | |
531 | 563 | // En fonction de l'objet et de la version, les lignes conservent l'id de l'objet d'origine |
532 | - if (method_exists($object, 'fetch_lines')) $object->fetch_lines(); |
|
533 | - else $object->fetch($object->id); |
|
564 | + if (method_exists($object, 'fetch_lines')) { |
|
565 | + $object->fetch_lines(); |
|
566 | + } else { |
|
567 | + $object->fetch($object->id); |
|
568 | + } |
|
534 | 569 | |
535 | 570 | foreach ($object->lines as &$line) |
536 | 571 | { |
537 | - if (empty($line->array_options)) $line->fetch_optionals(); |
|
572 | + if (empty($line->array_options)) { |
|
573 | + $line->fetch_optionals(); |
|
574 | + } |
|
538 | 575 | |
539 | 576 | if (!TSubtotal::isModSubtotalLine($line) && !empty($line->array_options['options_subtotal_nc'])) |
540 | 577 | { |
541 | 578 | $line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = |
542 | 579 | $line->multicurrency_total_ht = $line->multicurrency_total_tva = $line->multicurrency_total_ttc = 0; |
543 | 580 | |
544 | - if ($line->element == 'propaldet') $res = $line->update(1); |
|
545 | - else $res = $line->update($user, 1); |
|
581 | + if ($line->element == 'propaldet') { |
|
582 | + $res = $line->update(1); |
|
583 | + } else { |
|
584 | + $res = $line->update($user, 1); |
|
585 | + } |
|
546 | 586 | |
547 | - if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
587 | + if ($res > 0) { |
|
588 | + setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
589 | + } |
|
548 | 590 | } |
549 | 591 | } |
550 | 592 | |
551 | - if (!empty($line)) $object->update_price(1); |
|
593 | + if (!empty($line)) { |
|
594 | + $object->update_price(1); |
|
595 | + } |
|
552 | 596 | } |
553 | 597 | |
554 | 598 | } elseif ($action == 'PROPAL_MODIFY') { |
@@ -618,9 +662,7 @@ discard block |
||
618 | 662 | dol_syslog( |
619 | 663 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id |
620 | 664 | ); |
621 | - } |
|
622 | - |
|
623 | - elseif ($action == 'BILL_MODIFY') { |
|
665 | + } elseif ($action == 'BILL_MODIFY') { |
|
624 | 666 | dol_syslog( |
625 | 667 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id |
626 | 668 | ); |
@@ -13,18 +13,23 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * @var $object Facture |
15 | 15 | */ |
16 | - if($object->element=='facture') $res = $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number); |
|
16 | + if($object->element=='facture') { |
|
17 | + $res = $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number); |
|
18 | + } |
|
17 | 19 | /** |
18 | 20 | * @var $object Propal |
19 | 21 | */ |
20 | - else if($object->element=='propal') $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number); |
|
22 | + else if($object->element=='propal') { |
|
23 | + $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number); |
|
24 | + } |
|
21 | 25 | /** |
22 | 26 | * @var $object Commande |
23 | 27 | */ |
24 | - else if($object->element=='commande') $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number); |
|
28 | + else if($object->element=='commande') { |
|
29 | + $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number); |
|
30 | + } |
|
25 | 31 | |
26 | - } |
|
27 | - else { |
|
32 | + } else { |
|
28 | 33 | $desc = ''; |
29 | 34 | |
30 | 35 | $TNotElements = array ('invoice_supplier', 'order_supplier'); |
@@ -37,26 +42,33 @@ discard block |
||
37 | 42 | { |
38 | 43 | /** @var Facture $object */ |
39 | 44 | $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label); |
40 | - } |
|
41 | - elseif($object->element=='invoice_supplier') { |
|
45 | + } elseif($object->element=='invoice_supplier') { |
|
42 | 46 | /** @var FactureFournisseur $object */ |
43 | 47 | $object->special_code = TSubtotal::$module_number; |
44 | - if( (float)DOL_VERSION < 6 ) $rang = $object->line_max() + 1; |
|
48 | + if( (float)DOL_VERSION < 6 ) { |
|
49 | + $rang = $object->line_max() + 1; |
|
50 | + } |
|
45 | 51 | $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
46 | 52 | } |
47 | 53 | /** |
48 | 54 | * @var $object Propal |
49 | 55 | */ |
50 | - else if($object->element=='propal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
56 | + else if($object->element=='propal') { |
|
57 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
58 | + } |
|
51 | 59 | /** |
52 | 60 | * @var $object Propal Fournisseur |
53 | 61 | */ |
54 | - else if($object->element=='supplier_proposal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
62 | + else if($object->element=='supplier_proposal') { |
|
63 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
64 | + } |
|
55 | 65 | |
56 | 66 | /** |
57 | 67 | * @var $object Commande |
58 | 68 | */ |
59 | - else if($object->element=='commande') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label); |
|
69 | + else if($object->element=='commande') { |
|
70 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label); |
|
71 | + } |
|
60 | 72 | /** |
61 | 73 | * @var $object Commande fournisseur |
62 | 74 | */ |
@@ -67,7 +79,9 @@ discard block |
||
67 | 79 | /** |
68 | 80 | * @var $object Facturerec |
69 | 81 | */ |
70 | - else if($object->element=='facturerec') $res = $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); |
|
82 | + else if($object->element=='facturerec') { |
|
83 | + $res = $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); |
|
84 | + } |
|
71 | 85 | |
72 | 86 | } |
73 | 87 | |
@@ -89,8 +103,9 @@ discard block |
||
89 | 103 | // Define output language |
90 | 104 | $outputlangs = $langs; |
91 | 105 | $newlang = GETPOST('lang_id', 'alpha'); |
92 | - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) |
|
93 | - $newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang; |
|
106 | + if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { |
|
107 | + $newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang; |
|
108 | + } |
|
94 | 109 | if (! empty($newlang)) { |
95 | 110 | $outputlangs = new Translate("", $conf); |
96 | 111 | $outputlangs->setDefaultLang($newlang); |
@@ -99,13 +114,18 @@ discard block |
||
99 | 114 | $ret = $object->fetch($object->id); // Reload to get new records |
100 | 115 | if ((float) DOL_VERSION <= 3.6) |
101 | 116 | { |
102 | - if ($object->element == 'propal') propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
103 | - elseif ($object->element == 'commande') commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
104 | - elseif ($object->element == 'facture') facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
105 | - } |
|
106 | - else |
|
117 | + if ($object->element == 'propal') { |
|
118 | + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
119 | + } elseif ($object->element == 'commande') { |
|
120 | + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
121 | + } elseif ($object->element == 'facture') { |
|
122 | + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
123 | + } |
|
124 | + } else |
|
107 | 125 | { |
108 | - if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
126 | + if ($object->element!= 'facturerec') { |
|
127 | + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
128 | + } |
|
109 | 129 | } |
110 | 130 | } |
111 | 131 | } |
@@ -119,7 +139,9 @@ discard block |
||
119 | 139 | */ |
120 | 140 | public static function updateRang(&$object, $rang_start, $move_to=1) |
121 | 141 | { |
122 | - if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
|
142 | + if (!class_exists('GenericObject')) { |
|
143 | + require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
|
144 | + } |
|
123 | 145 | |
124 | 146 | $row=new GenericObject($object->db); |
125 | 147 | $row->table_element_line = $object->table_element_line; |
@@ -128,7 +150,9 @@ discard block |
||
128 | 150 | |
129 | 151 | foreach ($object->lines as &$line) |
130 | 152 | { |
131 | - if ($line->rang < $rang_start) continue; |
|
153 | + if ($line->rang < $rang_start) { |
|
154 | + continue; |
|
155 | + } |
|
132 | 156 | |
133 | 157 | $row->updateRangOfLine($line->id, $line->rang+$move_to); |
134 | 158 | } |
@@ -151,21 +175,28 @@ discard block |
||
151 | 175 | foreach ($TTitle_reverse as $k => $title_line) |
152 | 176 | { |
153 | 177 | $title_niveau = self::getNiveau($title_line); |
154 | - if ($title_niveau < $level_new_title) break; |
|
178 | + if ($title_niveau < $level_new_title) { |
|
179 | + break; |
|
180 | + } |
|
155 | 181 | |
156 | 182 | $rang_to_add = self::titleHasTotalLine($object, $title_line, true, true); |
157 | 183 | |
158 | 184 | if (is_numeric($rang_to_add)) |
159 | 185 | { |
160 | - if ($rang_to_add != -1) self::updateRang($object, $rang_to_add); |
|
186 | + if ($rang_to_add != -1) { |
|
187 | + self::updateRang($object, $rang_to_add); |
|
188 | + } |
|
161 | 189 | |
162 | 190 | self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add); |
163 | 191 | |
164 | 192 | $object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas) |
165 | 193 | if ($rang_to_add != -1) |
166 | 194 | { |
167 | - if (method_exists($object, 'fetch_lines')) $object->fetch_lines(); |
|
168 | - else $object->fetch($object->id); |
|
195 | + if (method_exists($object, 'fetch_lines')) { |
|
196 | + $object->fetch_lines(); |
|
197 | + } else { |
|
198 | + $object->fetch($object->id); |
|
199 | + } |
|
169 | 200 | } |
170 | 201 | } |
171 | 202 | } |
@@ -195,7 +226,9 @@ discard block |
||
195 | 226 | |
196 | 227 | foreach ($TTitle as $k => $title_line) |
197 | 228 | { |
198 | - if (self::titleHasTotalLine($object, $title_line)) unset($TTitle[$k]); |
|
229 | + if (self::titleHasTotalLine($object, $title_line)) { |
|
230 | + unset($TTitle[$k]); |
|
231 | + } |
|
199 | 232 | } |
200 | 233 | |
201 | 234 | return $TTitle; |
@@ -212,23 +245,41 @@ discard block |
||
212 | 245 | */ |
213 | 246 | public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false) |
214 | 247 | { |
215 | - if (empty($object->lines) || !is_array($object->lines)) return false; |
|
248 | + if (empty($object->lines) || !is_array($object->lines)) { |
|
249 | + return false; |
|
250 | + } |
|
216 | 251 | |
217 | 252 | $title_niveau = self::getNiveau($title_line); |
218 | 253 | foreach ($object->lines as &$line) |
219 | 254 | { |
220 | - if ($line->rang <= $title_line->rang) continue; |
|
221 | - if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) return false; // Oups on croise un titre d'un niveau inférieur ou égale (exemple : je croise un titre niveau 2 alors que je suis sur un titre de niveau 3) pas lieu de continuer car un nouveau bloc commence |
|
222 | - if (!self::isSubtotal($line)) continue; |
|
255 | + if ($line->rang <= $title_line->rang) { |
|
256 | + continue; |
|
257 | + } |
|
258 | + if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) { |
|
259 | + return false; |
|
260 | + } |
|
261 | + // Oups on croise un titre d'un niveau inférieur ou égale (exemple : je croise un titre niveau 2 alors que je suis sur un titre de niveau 3) pas lieu de continuer car un nouveau bloc commence |
|
262 | + if (!self::isSubtotal($line)) { |
|
263 | + continue; |
|
264 | + } |
|
223 | 265 | |
224 | 266 | $subtotal_niveau = self::getNiveau($line); |
225 | 267 | |
226 | 268 | // Comparaison du niveau de la ligne de sous-total avec celui du titre |
227 | - if ($subtotal_niveau == $title_niveau) return true; // niveau égale => Ok mon titre a un sous-total |
|
228 | - elseif ($subtotal_niveau < $title_niveau) // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3) |
|
269 | + if ($subtotal_niveau == $title_niveau) { |
|
270 | + return true; |
|
271 | + } |
|
272 | + // niveau égale => Ok mon titre a un sous-total |
|
273 | + elseif ($subtotal_niveau < $title_niveau) { |
|
274 | + // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3) |
|
229 | 275 | { |
230 | - if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; // mode strict niveau pas égale donc faux |
|
231 | - else return true; // mode libre => OK je considère que mon titre à un sous-total |
|
276 | + if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; |
|
277 | + } |
|
278 | + // mode strict niveau pas égale donc faux |
|
279 | + else { |
|
280 | + return true; |
|
281 | + } |
|
282 | + // mode libre => OK je considère que mon titre à un sous-total |
|
232 | 283 | } |
233 | 284 | } |
234 | 285 | |
@@ -276,16 +327,19 @@ discard block |
||
276 | 327 | |
277 | 328 | foreach ($object->lines as &$l) |
278 | 329 | { |
279 | - if ($l->rang <= $line->rang) continue; |
|
280 | - elseif (self::isSubtotal($l) && self::getNiveau($l) <= self::getNiveau($line)) break; |
|
281 | - elseif ($breakOnTitle && self::isTitle($l) && self::getNiveau($l) <= self::getNiveau($line)) break; |
|
330 | + if ($l->rang <= $line->rang) { |
|
331 | + continue; |
|
332 | + } elseif (self::isSubtotal($l) && self::getNiveau($l) <= self::getNiveau($line)) { |
|
333 | + break; |
|
334 | + } elseif ($breakOnTitle && self::isTitle($l) && self::getNiveau($l) <= self::getNiveau($line)) { |
|
335 | + break; |
|
336 | + } |
|
282 | 337 | |
283 | 338 | if (!empty($l->array_options['options_subtotal_nc'])) |
284 | 339 | { |
285 | 340 | $tabprice = calcul_price_total($l->qty, $l->subprice, $l->remise_percent, $l->tva_tx, $l->localtax1_tx, $l->localtax2_tx, 0, 'HT', $l->info_bits, $l->product_type); |
286 | 341 | $TTot['total_options'] += $tabprice[0]; // total ht |
287 | - } |
|
288 | - else |
|
342 | + } else |
|
289 | 343 | { |
290 | 344 | $TTot['total_pa_ht'] += $l->pa_ht * $l->qty; |
291 | 345 | $TTot['total_subprice'] += $l->subprice * $l->qty; |
@@ -306,42 +360,61 @@ discard block |
||
306 | 360 | |
307 | 361 | public static function getOrderIdFromLineId(&$db, $fk_commandedet, $supplier = false) |
308 | 362 | { |
309 | - if (empty($fk_commandedet)) return false; |
|
363 | + if (empty($fk_commandedet)) { |
|
364 | + return false; |
|
365 | + } |
|
310 | 366 | |
311 | 367 | $table = 'commandedet'; |
312 | - if ($supplier) $table = 'commande_fournisseurdet'; |
|
368 | + if ($supplier) { |
|
369 | + $table = 'commande_fournisseurdet'; |
|
370 | + } |
|
313 | 371 | |
314 | 372 | $sql = 'SELECT fk_commande FROM '.MAIN_DB_PREFIX.$table.' WHERE rowid = '.$fk_commandedet; |
315 | 373 | $resql = $db->query($sql); |
316 | 374 | |
317 | - if ($resql && ($row = $db->fetch_object($resql))) return $row->fk_commande; |
|
318 | - else return false; |
|
375 | + if ($resql && ($row = $db->fetch_object($resql))) { |
|
376 | + return $row->fk_commande; |
|
377 | + } else { |
|
378 | + return false; |
|
379 | + } |
|
319 | 380 | } |
320 | 381 | |
321 | 382 | public static function getLastLineOrderId(&$db, $fk_commande, $supplier = false) |
322 | 383 | { |
323 | - if (empty($fk_commande)) return false; |
|
384 | + if (empty($fk_commande)) { |
|
385 | + return false; |
|
386 | + } |
|
324 | 387 | |
325 | 388 | $table = 'commandedet'; |
326 | - if ($supplier) $table = 'commande_fournisseurdet'; |
|
389 | + if ($supplier) { |
|
390 | + $table = 'commande_fournisseurdet'; |
|
391 | + } |
|
327 | 392 | |
328 | 393 | $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$table.' WHERE fk_commande = '.$fk_commande.' ORDER BY rang DESC LIMIT 1'; |
329 | 394 | $resql = $db->query($sql); |
330 | 395 | |
331 | - if ($resql && ($row = $db->fetch_object($resql))) return (int) $row->rowid; |
|
332 | - else return false; |
|
396 | + if ($resql && ($row = $db->fetch_object($resql))) { |
|
397 | + return (int) $row->rowid; |
|
398 | + } else { |
|
399 | + return false; |
|
400 | + } |
|
333 | 401 | } |
334 | 402 | |
335 | 403 | public static function getParentTitleOfLine(&$object, $rang) |
336 | 404 | { |
337 | - if ($rang <= 0) return false; |
|
405 | + if ($rang <= 0) { |
|
406 | + return false; |
|
407 | + } |
|
338 | 408 | |
339 | 409 | $skip_title = 0; |
340 | 410 | $TLineReverse = array_reverse($object->lines); |
341 | 411 | |
342 | 412 | foreach($TLineReverse as $line) |
343 | 413 | { |
344 | - if ($line->rang >= $rang) continue; // Tout ce qui ce trouve en dessous j'ignore, nous voulons uniquement ce qui ce trouve au dessus |
|
414 | + if ($line->rang >= $rang) { |
|
415 | + continue; |
|
416 | + } |
|
417 | + // Tout ce qui ce trouve en dessous j'ignore, nous voulons uniquement ce qui ce trouve au dessus |
|
345 | 418 | |
346 | 419 | if (self::isTitle($line)) |
347 | 420 | { |
@@ -354,8 +427,7 @@ discard block |
||
354 | 427 | //@INFO J'ai ma ligne titre qui contient ma ligne, par contre je check pas s'il y a un sous-total |
355 | 428 | return $line; |
356 | 429 | break; |
357 | - } |
|
358 | - elseif (self::isSubtotal($line)) |
|
430 | + } elseif (self::isSubtotal($line)) |
|
359 | 431 | { |
360 | 432 | // Il s'agit d'un sous-total, ça veut dire que le prochain titre théoriquement doit être ignorer (je travail avec un incrément au cas ou je croise plusieurs sous-totaux) |
361 | 433 | $skip_title++; |
@@ -370,7 +442,9 @@ discard block |
||
370 | 442 | $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9; |
371 | 443 | if($res && $level > -1) { |
372 | 444 | return $line->qty == $level; |
373 | - } else return $res; |
|
445 | + } else { |
|
446 | + return $res; |
|
447 | + } |
|
374 | 448 | |
375 | 449 | } |
376 | 450 | |
@@ -379,7 +453,9 @@ discard block |
||
379 | 453 | $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90; |
380 | 454 | if($res && $level > -1) { |
381 | 455 | return self::getNiveau($line) == $level; |
382 | - } else return $res; |
|
456 | + } else { |
|
457 | + return $res; |
|
458 | + } |
|
383 | 459 | } |
384 | 460 | |
385 | 461 | public static function isFreeText(&$line) |
@@ -400,10 +476,14 @@ discard block |
||
400 | 476 | // editeur wysiwyg |
401 | 477 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
402 | 478 | $nbrows=ROWS_2; |
403 | - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
479 | + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) { |
|
480 | + $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
481 | + } |
|
404 | 482 | $enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); |
405 | 483 | $toolbarname='dolibarr_details'; |
406 | - if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; |
|
484 | + if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) { |
|
485 | + $toolbarname='dolibarr_notes'; |
|
486 | + } |
|
407 | 487 | $text = !empty($line->description)?$line->description:$line->label; |
408 | 488 | $doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly); |
409 | 489 | return $doleditor->Create(1); |
@@ -418,12 +498,10 @@ discard block |
||
418 | 498 | { |
419 | 499 | $object->statut = 0; // hack for facture rec |
420 | 500 | $createRight = $user->rights->facture->creer; |
421 | - } |
|
422 | - elseif($object->element == 'order_supplier' ) |
|
501 | + } elseif($object->element == 'order_supplier' ) |
|
423 | 502 | { |
424 | 503 | $createRight = $user->rights->fournisseur->commande->creer; |
425 | - } |
|
426 | - elseif($object->element == 'invoice_supplier' ) |
|
504 | + } elseif($object->element == 'invoice_supplier' ) |
|
427 | 505 | { |
428 | 506 | $createRight = $user->rights->fournisseur->facture->creer; |
429 | 507 | } |
@@ -434,11 +512,16 @@ discard block |
||
434 | 512 | |
435 | 513 | if(!empty($object->lines)) { |
436 | 514 | foreach($object->lines as $line) { |
437 | - if($line->id == $lineid) $duplicateLine = $line; |
|
515 | + if($line->id == $lineid) { |
|
516 | + $duplicateLine = $line; |
|
517 | + } |
|
438 | 518 | } |
439 | 519 | } |
440 | - if(!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) $TLine = array($duplicateLine); |
|
441 | - else $TLine = self::getLinesFromTitleId($object, $lineid, $withBlockLine); |
|
520 | + if(!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) { |
|
521 | + $TLine = array($duplicateLine); |
|
522 | + } else { |
|
523 | + $TLine = self::getLinesFromTitleId($object, $lineid, $withBlockLine); |
|
524 | + } |
|
442 | 525 | |
443 | 526 | if (!empty($TLine)) |
444 | 527 | { |
@@ -504,8 +587,9 @@ discard block |
||
504 | 587 | |
505 | 588 | $TLineAdded[] = $object->line; |
506 | 589 | // Error from addline |
507 | - if ($res <= 0) break; |
|
508 | - else |
|
590 | + if ($res <= 0) { |
|
591 | + break; |
|
592 | + } else |
|
509 | 593 | { |
510 | 594 | $object->line_from = $line; |
511 | 595 | // Call trigger |
@@ -527,8 +611,7 @@ discard block |
||
527 | 611 | _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']); |
528 | 612 | } |
529 | 613 | return count($TLineAdded); |
530 | - } |
|
531 | - else |
|
614 | + } else |
|
532 | 615 | { |
533 | 616 | $object->db->rollback(); |
534 | 617 | return -1; |
@@ -544,10 +627,14 @@ discard block |
||
544 | 627 | global $langs; |
545 | 628 | |
546 | 629 | // Besoin de comparer sur les 2 formes d'écriture |
547 | - if (!$key_is_id) $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad)); |
|
630 | + if (!$key_is_id) { |
|
631 | + $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad)); |
|
632 | + } |
|
548 | 633 | |
549 | 634 | $TTitle_under_search = array(); |
550 | - if (!empty($under_title)) $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title)); |
|
635 | + if (!empty($under_title)) { |
|
636 | + $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title)); |
|
637 | + } |
|
551 | 638 | |
552 | 639 | $TLine = array(); |
553 | 640 | $add_line = false; |
@@ -557,28 +644,37 @@ discard block |
||
557 | 644 | { |
558 | 645 | if (!$under_title_found && !empty($TTitle_under_search)) |
559 | 646 | { |
560 | - if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true; |
|
561 | - } |
|
562 | - else |
|
647 | + if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) { |
|
648 | + $under_title_found = true; |
|
649 | + } |
|
650 | + } else |
|
563 | 651 | { |
564 | 652 | if ( ($key_is_id && $line->id == $key_trad) || (!$key_is_id && $line->product_type == 9 && $line->qty == $level && (in_array($line->desc, $TTitle_search) || in_array($line->label, $TTitle_search) ))) |
565 | 653 | { |
566 | - if ($key_is_id) $level = $line->qty; |
|
654 | + if ($key_is_id) { |
|
655 | + $level = $line->qty; |
|
656 | + } |
|
567 | 657 | |
568 | 658 | $add_line = true; |
569 | - if ($withBlockLine) $TLine[] = $line; |
|
659 | + if ($withBlockLine) { |
|
660 | + $TLine[] = $line; |
|
661 | + } |
|
570 | 662 | continue; |
571 | - } |
|
572 | - elseif ($add_line && TSubtotal::isModSubtotalLine($line) && TSubtotal::getNiveau($line) == $level) // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
663 | + } elseif ($add_line && TSubtotal::isModSubtotalLine($line) && TSubtotal::getNiveau($line) == $level) { |
|
664 | + // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
573 | 665 | { |
574 | 666 | if ($withBlockLine) $TLine[] = $line; |
667 | + } |
|
575 | 668 | break; |
576 | 669 | } |
577 | 670 | |
578 | 671 | if ($add_line) |
579 | 672 | { |
580 | - if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue; |
|
581 | - else $TLine[] = $line; |
|
673 | + if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) { |
|
674 | + continue; |
|
675 | + } else { |
|
676 | + $TLine[] = $line; |
|
677 | + } |
|
582 | 678 | } |
583 | 679 | } |
584 | 680 | } |
@@ -612,7 +708,9 @@ discard block |
||
612 | 708 | |
613 | 709 | case 'order_supplier': |
614 | 710 | $object->special_code = SELF::$module_number; |
615 | - if (empty($desc)) $desc = $label; |
|
711 | + if (empty($desc)) { |
|
712 | + $desc = $label; |
|
713 | + } |
|
616 | 714 | $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit); |
617 | 715 | break; |
618 | 716 | |
@@ -622,7 +720,9 @@ discard block |
||
622 | 720 | |
623 | 721 | case 'invoice_supplier': |
624 | 722 | $object->special_code = SELF::$module_number; |
625 | - if (empty($desc)) $desc = $label; |
|
723 | + if (empty($desc)) { |
|
724 | + $desc = $label; |
|
725 | + } |
|
626 | 726 | $res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit); |
627 | 727 | break; |
628 | 728 | |
@@ -639,8 +739,11 @@ discard block |
||
639 | 739 | break; |
640 | 740 | } |
641 | 741 | |
642 | - if ($res <= 0) $object->db->rollback(); |
|
643 | - else $object->db->commit(); |
|
742 | + if ($res <= 0) { |
|
743 | + $object->db->rollback(); |
|
744 | + } else { |
|
745 | + $object->db->commit(); |
|
746 | + } |
|
644 | 747 | |
645 | 748 | return $res; |
646 | 749 | } |
@@ -650,24 +753,20 @@ discard block |
||
650 | 753 | global $db, $object; |
651 | 754 | |
652 | 755 | $TTitle = array(); |
653 | - if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} |
|
654 | - else { |
|
756 | + if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} else { |
|
655 | 757 | if ($origin_line->element == 'propaldet') |
656 | 758 | { |
657 | 759 | $object = new Propal($db); |
658 | 760 | $object->fetch($origin_line->fk_propal); |
659 | - } |
|
660 | - else if ($origin_line->element == 'commandedet') |
|
761 | + } else if ($origin_line->element == 'commandedet') |
|
661 | 762 | { |
662 | 763 | $object = new Commande($db); |
663 | 764 | $object->fetch($origin_line->fk_commande); |
664 | - } |
|
665 | - else if ($origin_line->element == 'facturedet') |
|
765 | + } else if ($origin_line->element == 'facturedet') |
|
666 | 766 | { |
667 | 767 | $object = new Facture($db); |
668 | 768 | $object->fetch($origin_line->fk_facture); |
669 | - } |
|
670 | - else |
|
769 | + } else |
|
671 | 770 | { |
672 | 771 | return $TTitle; |
673 | 772 | } |
@@ -677,8 +776,11 @@ discard block |
||
677 | 776 | $i = 0; |
678 | 777 | foreach ($object->lines as &$line) |
679 | 778 | { |
680 | - if ($origin_line->id == $line->id) break; |
|
681 | - else $i++; |
|
779 | + if ($origin_line->id == $line->id) { |
|
780 | + break; |
|
781 | + } else { |
|
782 | + $i++; |
|
783 | + } |
|
682 | 784 | } |
683 | 785 | |
684 | 786 | $i--; // Skip la ligne d'origine |
@@ -693,35 +795,43 @@ discard block |
||
693 | 795 | if (self::isSubtotal($object->lines[$y])) |
694 | 796 | { |
695 | 797 | $next_title_lvl_to_skip = self::getNiveau($object->lines[$y]); |
696 | - } |
|
697 | - elseif (self::isTitle($object->lines[$y])) |
|
798 | + } elseif (self::isTitle($object->lines[$y])) |
|
698 | 799 | { |
699 | 800 | if ($object->lines[$y]->qty == $next_title_lvl_to_skip) |
700 | 801 | { |
701 | 802 | $next_title_lvl_to_skip = 0; |
702 | 803 | continue; |
703 | - } |
|
704 | - else |
|
804 | + } else |
|
705 | 805 | { |
706 | - if (empty($object->lines[$y]->array_options)) $object->lines[$y]->fetch_optionals(); |
|
806 | + if (empty($object->lines[$y]->array_options)) { |
|
807 | + $object->lines[$y]->fetch_optionals(); |
|
808 | + } |
|
707 | 809 | $TTitle[$object->lines[$y]->id] = $object->lines[$y]; |
708 | 810 | |
709 | - if ($object->lines[$y]->qty == 1) break; |
|
811 | + if ($object->lines[$y]->qty == 1) { |
|
812 | + break; |
|
813 | + } |
|
710 | 814 | } |
711 | 815 | } |
712 | 816 | } |
713 | 817 | } |
714 | 818 | |
715 | - if ($reverse) $TTitle = array_reverse($TTitle, true); |
|
819 | + if ($reverse) { |
|
820 | + $TTitle = array_reverse($TTitle, true); |
|
821 | + } |
|
716 | 822 | |
717 | 823 | return $TTitle; |
718 | 824 | } |
719 | 825 | |
720 | 826 | public static function getNiveau(&$line) |
721 | 827 | { |
722 | - if (self::isTitle($line)) return $line->qty; |
|
723 | - elseif (self::isSubtotal($line)) return 100 - $line->qty; |
|
724 | - else return 0; |
|
828 | + if (self::isTitle($line)) { |
|
829 | + return $line->qty; |
|
830 | + } elseif (self::isSubtotal($line)) { |
|
831 | + return 100 - $line->qty; |
|
832 | + } else { |
|
833 | + return 0; |
|
834 | + } |
|
725 | 835 | } |
726 | 836 | |
727 | 837 | /** |
@@ -746,10 +856,16 @@ discard block |
||
746 | 856 | $objmarge->marge_droite = 10; |
747 | 857 | |
748 | 858 | $objectref = dol_sanitizeFileName($object->ref); |
749 | - if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref; |
|
750 | - elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref; |
|
751 | - elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref; |
|
752 | - elseif ($object->element == 'facturerec') return; // no PDF for facturerec |
|
859 | + if ($object->element == 'propal') { |
|
860 | + $dir = $conf->propal->dir_output . '/' . $objectref; |
|
861 | + } elseif ($object->element == 'commande') { |
|
862 | + $dir = $conf->commande->dir_output . '/' . $objectref; |
|
863 | + } elseif ($object->element == 'facture') { |
|
864 | + $dir = $conf->facture->dir_output . '/' . $objectref; |
|
865 | + } elseif ($object->element == 'facturerec') { |
|
866 | + return; |
|
867 | + } |
|
868 | + // no PDF for facturerec |
|
753 | 869 | else |
754 | 870 | { |
755 | 871 | setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings'); |
@@ -784,7 +900,9 @@ discard block |
||
784 | 900 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
785 | 901 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
786 | 902 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
787 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
903 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
904 | + $pdf->SetCompression(false); |
|
905 | + } |
|
788 | 906 | |
789 | 907 | $pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right |
790 | 908 | |
@@ -794,7 +912,9 @@ discard block |
||
794 | 912 | |
795 | 913 | // New page |
796 | 914 | $pdf->AddPage(); |
797 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
915 | + if (! empty($tplidx)) { |
|
916 | + $pdf->useTemplate($tplidx); |
|
917 | + } |
|
798 | 918 | $pagenb++; |
799 | 919 | |
800 | 920 | |
@@ -850,8 +970,10 @@ discard block |
||
850 | 970 | { |
851 | 971 | $TTot['TTotal_tva_multicurrency'][$tx] += $amount; |
852 | 972 | } |
973 | + } else { |
|
974 | + $pdf->SetFont('','', $default_font_size - 1); |
|
853 | 975 | } |
854 | - else $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
976 | + // Into loop to work with multipage |
|
855 | 977 | |
856 | 978 | $pdf->SetTextColor(0,0,0); |
857 | 979 | |
@@ -873,9 +995,11 @@ discard block |
||
873 | 995 | $pdf->startTransaction(); |
874 | 996 | $pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true); |
875 | 997 | $pageposafter=$pdf->getPage(); |
876 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
998 | + if ($pageposafter > $pageposbefore) { |
|
999 | + // There is a pagebreak |
|
877 | 1000 | { |
878 | 1001 | $pdf->rollbackTransaction(true); |
1002 | + } |
|
879 | 1003 | $pageposafter=$pageposbefore; |
880 | 1004 | //print $pageposafter.'-'.$pageposbefore;exit; |
881 | 1005 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
@@ -884,23 +1008,27 @@ discard block |
||
884 | 1008 | $pageposafter=$pdf->getPage(); |
885 | 1009 | $posyafter=$pdf->GetY(); |
886 | 1010 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
887 | - if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) // There is no space left for total+free text |
|
1011 | + if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) { |
|
1012 | + // There is no space left for total+free text |
|
888 | 1013 | { |
889 | 1014 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
890 | 1015 | { |
891 | 1016 | $pdf->AddPage('','',true); |
892 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
893 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
1017 | + } |
|
1018 | + if (! empty($tplidx)) { |
|
1019 | + $pdf->useTemplate($tplidx); |
|
1020 | + } |
|
1021 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
1022 | + self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
1023 | + } |
|
894 | 1024 | $pdf->setPage($pageposafter+1); |
895 | 1025 | } |
896 | - } |
|
897 | - else |
|
1026 | + } else |
|
898 | 1027 | { |
899 | 1028 | // We found a page break |
900 | 1029 | $showpricebeforepagebreak=0; |
901 | 1030 | } |
902 | - } |
|
903 | - else // No pagebreak |
|
1031 | + } else // No pagebreak |
|
904 | 1032 | { |
905 | 1033 | $pdf->commitTransaction(); |
906 | 1034 | } |
@@ -940,8 +1068,7 @@ discard block |
||
940 | 1068 | if ($pagenb == 1) |
941 | 1069 | { |
942 | 1070 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
943 | - } |
|
944 | - else |
|
1071 | + } else |
|
945 | 1072 | { |
946 | 1073 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code); |
947 | 1074 | } |
@@ -949,7 +1076,9 @@ discard block |
||
949 | 1076 | $pagenb++; |
950 | 1077 | $pdf->setPage($pagenb); |
951 | 1078 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
952 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
1079 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
1080 | + self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
1081 | + } |
|
953 | 1082 | } |
954 | 1083 | } |
955 | 1084 | } |
@@ -959,8 +1088,7 @@ discard block |
||
959 | 1088 | { |
960 | 1089 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
961 | 1090 | $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
962 | - } |
|
963 | - else |
|
1091 | + } else |
|
964 | 1092 | { |
965 | 1093 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); |
966 | 1094 | $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
@@ -974,7 +1102,9 @@ discard block |
||
974 | 1102 | |
975 | 1103 | $pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file); |
976 | 1104 | |
977 | - if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) unlink($file); |
|
1105 | + if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) { |
|
1106 | + unlink($file); |
|
1107 | + } |
|
978 | 1108 | } |
979 | 1109 | |
980 | 1110 | private static function printLevel($objmarge, $pdf, $line, $curY, $posx_designation) |
@@ -1017,8 +1147,7 @@ discard block |
||
1017 | 1147 | { |
1018 | 1148 | $height=pdf_getHeightForLogo($logo); |
1019 | 1149 | $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto) |
1020 | - } |
|
1021 | - else |
|
1150 | + } else |
|
1022 | 1151 | { |
1023 | 1152 | $pdf->SetTextColor(200,0,0); |
1024 | 1153 | $pdf->SetFont('','B',$default_font_size - 2); |
@@ -1027,8 +1156,7 @@ discard block |
||
1027 | 1156 | } |
1028 | 1157 | |
1029 | 1158 | $posy+=35; |
1030 | - } |
|
1031 | - else |
|
1159 | + } else |
|
1032 | 1160 | { |
1033 | 1161 | $text=$mysoc->name; |
1034 | 1162 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -1042,9 +1170,13 @@ discard block |
||
1042 | 1170 | $pdf->SetXY($objmarge->marge_gauche,$posy); |
1043 | 1171 | |
1044 | 1172 | $key = 'subtotalPropalTitle'; |
1045 | - if ($object->element == 'commande') $key = 'subtotalCommandeTitle'; |
|
1046 | - elseif ($object->element == 'facture') $key = 'subtotalInvoiceTitle'; |
|
1047 | - elseif ($object->element == 'facturerec') $key = 'subtotalInvoiceTitle'; |
|
1173 | + if ($object->element == 'commande') { |
|
1174 | + $key = 'subtotalCommandeTitle'; |
|
1175 | + } elseif ($object->element == 'facture') { |
|
1176 | + $key = 'subtotalInvoiceTitle'; |
|
1177 | + } elseif ($object->element == 'facturerec') { |
|
1178 | + $key = 'subtotalInvoiceTitle'; |
|
1179 | + } |
|
1048 | 1180 | |
1049 | 1181 | $pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L'); |
1050 | 1182 | |
@@ -1079,7 +1211,9 @@ discard block |
||
1079 | 1211 | |
1080 | 1212 | // Force to disable hidetop and hidebottom |
1081 | 1213 | $hidebottom=0; |
1082 | - if ($hidetop) $hidetop=-1; |
|
1214 | + if ($hidetop) { |
|
1215 | + $hidetop=-1; |
|
1216 | + } |
|
1083 | 1217 | |
1084 | 1218 | $currency = !empty($currency) ? $currency : $conf->currency; |
1085 | 1219 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
@@ -1094,7 +1228,9 @@ discard block |
||
1094 | 1228 | $pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5); |
1095 | 1229 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
1096 | 1230 | |
1097 | - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
1231 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { |
|
1232 | + $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
1233 | + } |
|
1098 | 1234 | |
1099 | 1235 | |
1100 | 1236 | $pdf->line($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top); // line prend une position y en 2eme param et 4eme param |
@@ -1107,8 +1243,7 @@ discard block |
||
1107 | 1243 | $pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R'); |
1108 | 1244 | |
1109 | 1245 | $pdf->line($objmarge->marge_gauche, $tab_top+8, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top+8); // line prend une position y en 2eme param et 4eme param |
1110 | - } |
|
1111 | - else |
|
1246 | + } else |
|
1112 | 1247 | { |
1113 | 1248 | $pdf->line($objmarge->marge_gauche, $tab_top-2, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top-2); // line prend une position y en 2eme param et 4eme param |
1114 | 1249 | } |
@@ -1129,10 +1264,12 @@ discard block |
||
1129 | 1264 | |
1130 | 1265 | // Tableau total |
1131 | 1266 | $col1x = 120; $col2x = 170; |
1132 | - if ($objmarge->page_largeur < 210) // To work with US executive format |
|
1267 | + if ($objmarge->page_largeur < 210) { |
|
1268 | + // To work with US executive format |
|
1133 | 1269 | { |
1134 | 1270 | $col2x-=20; |
1135 | 1271 | } |
1272 | + } |
|
1136 | 1273 | $largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x); |
1137 | 1274 | |
1138 | 1275 | $useborder=0; |
@@ -1154,9 +1291,11 @@ discard block |
||
1154 | 1291 | $atleastoneratenotnull=0; |
1155 | 1292 | foreach($TTot['TTotal_tva'] as $tvakey => $tvaval) |
1156 | 1293 | { |
1157 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1294 | + if ($tvakey != 0) { |
|
1295 | + // On affiche pas taux 0 |
|
1158 | 1296 | { |
1159 | 1297 | $atleastoneratenotnull++; |
1298 | + } |
|
1160 | 1299 | |
1161 | 1300 | $index++; |
1162 | 1301 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -1209,9 +1348,13 @@ discard block |
||
1209 | 1348 | */ |
1210 | 1349 | private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
1211 | 1350 | { |
1212 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
1351 | + if (empty($hidetop) || $hidetop==-1) { |
|
1352 | + $pdf->line($x, $y, $x+$l, $y); |
|
1353 | + } |
|
1213 | 1354 | $pdf->line($x+$l, $y, $x+$l, $y+$h); |
1214 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
1355 | + if (empty($hidebottom)) { |
|
1356 | + $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
1357 | + } |
|
1215 | 1358 | $pdf->line($x, $y+$h, $x, $y); |
1216 | 1359 | } |
1217 | 1360 | |
@@ -1220,7 +1363,9 @@ discard block |
||
1220 | 1363 | { |
1221 | 1364 | global $conf; |
1222 | 1365 | |
1223 | - if (empty($fileoutput)) $fileoutput = $file[0]; |
|
1366 | + if (empty($fileoutput)) { |
|
1367 | + $fileoutput = $file[0]; |
|
1368 | + } |
|
1224 | 1369 | |
1225 | 1370 | $pdf=pdf_getInstance(); |
1226 | 1371 | if (class_exists('TCPDF')) |
@@ -1230,7 +1375,9 @@ discard block |
||
1230 | 1375 | } |
1231 | 1376 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
1232 | 1377 | |
1233 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
1378 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
1379 | + $pdf->SetCompression(false); |
|
1380 | + } |
|
1234 | 1381 | |
1235 | 1382 | |
1236 | 1383 | foreach($files as $file) |
@@ -1246,7 +1393,9 @@ discard block |
||
1246 | 1393 | } |
1247 | 1394 | |
1248 | 1395 | $pdf->Output($fileoutput,'F'); |
1249 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
1396 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
1397 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
1398 | + } |
|
1250 | 1399 | |
1251 | 1400 | return $pagecount; |
1252 | 1401 | } |
@@ -1259,7 +1408,9 @@ discard block |
||
1259 | 1408 | */ |
1260 | 1409 | public static function hasNcTitle(&$line) |
1261 | 1410 | { |
1262 | - if(isset($line->has_nc_title)) return $line->has_nc_title; |
|
1411 | + if(isset($line->has_nc_title)) { |
|
1412 | + return $line->has_nc_title; |
|
1413 | + } |
|
1263 | 1414 | |
1264 | 1415 | $TTitle = self::getAllTitleFromLine($line); |
1265 | 1416 | foreach ($TTitle as &$line_title) |
@@ -1284,7 +1435,9 @@ discard block |
||
1284 | 1435 | public static function getTitleLabel($line) |
1285 | 1436 | { |
1286 | 1437 | $title = $line->label; |
1287 | - if (empty($title)) $title = !empty($line->description) ? $line->description : $line->desc; |
|
1438 | + if (empty($title)) { |
|
1439 | + $title = !empty($line->description) ? $line->description : $line->desc; |
|
1440 | + } |
|
1288 | 1441 | return $title; |
1289 | 1442 | } |
1290 | 1443 | } |