Passed
Push — master ( 036d63...06978a )
by
unknown
04:05
created
class/subtotal.class.php 3 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 			 * @var $object Facture fournisseur
42 42
 			 */
43 43
 			else if($object->element=='invoice_supplier') {
44
-			    $object->special_code = TSubtotal::$module_number;
45
-                if( (float)DOL_VERSION < 6 ) $rang = $object->line_max() + 1;
46
-			    $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
44
+				$object->special_code = TSubtotal::$module_number;
45
+				if( (float)DOL_VERSION < 6 ) $rang = $object->line_max() + 1;
46
+				$res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
47 47
 			}
48 48
 			/**
49 49
 			 * @var $object Propal
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 			 * @var $object Commande fournisseur
63 63
 			 */
64 64
 			else if($object->element=='order_supplier') {
65
-			    $object->special_code = TSubtotal::$module_number;
66
-			    $res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9);
65
+				$object->special_code = TSubtotal::$module_number;
66
+				$res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9);
67 67
 			}
68 68
 			/**
69 69
 			 * @var $object Facturerec
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
 	{
324 324
 		if (empty($fk_commande)) return false;
325 325
 
326
-        $table = 'commandedet';
327
-        if ($supplier) $table = 'commande_fournisseurdet';
326
+		$table = 'commandedet';
327
+		if ($supplier) $table = 'commande_fournisseurdet';
328 328
 
329 329
 		$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$table.' WHERE fk_commande = '.$fk_commande.' ORDER BY rang DESC LIMIT 1';
330 330
 		$resql = $db->query($sql);
@@ -376,10 +376,10 @@  discard block
 block discarded – undo
376 376
 	
377 377
 	public static function isSubtotal(&$line, $level=-1)
378 378
 	{
379
-	    $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90;
380
-	    if($res && $level > -1) {
381
-	        return self::getNiveau($line) == $level;
382
-	    } else return $res;
379
+		$res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90;
380
+		if($res && $level > -1) {
381
+			return self::getNiveau($line) == $level;
382
+		} else return $res;
383 383
 	}
384 384
 	
385 385
 	public static function isFreeText(&$line)
@@ -416,29 +416,29 @@  discard block
 block discarded – undo
416 416
 		$createRight = $user->rights->{$object->element}->creer;
417 417
 		if($object->element == 'facturerec' )
418 418
 		{
419
-		    $object->statut = 0; // hack for facture rec
420
-		    $createRight = $user->rights->facture->creer;
419
+			$object->statut = 0; // hack for facture rec
420
+			$createRight = $user->rights->facture->creer;
421 421
 		}
422 422
 		elseif($object->element == 'order_supplier' )
423 423
 		{
424
-		    $createRight = $user->rights->fournisseur->commande->creer;
424
+			$createRight = $user->rights->fournisseur->commande->creer;
425 425
 		}
426 426
 		elseif($object->element == 'invoice_supplier' )
427 427
 		{
428
-		    $createRight = $user->rights->fournisseur->facture->creer;
428
+			$createRight = $user->rights->fournisseur->facture->creer;
429 429
 		}
430 430
 		
431 431
 		if ($object->statut == 0  && $createRight && (!empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) || !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE)))
432 432
 		{
433 433
 			dol_include_once('/subtotal/lib/subtotal.lib.php');
434 434
 
435
-            if(!empty($object->lines)) {
436
-                foreach($object->lines as $line) {
437
-                    if($line->id == $lineid) $duplicateLine = $line;
438
-                }
439
-            }
440
-            if(!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) $TLine = array($duplicateLine);
441
-            else $TLine = self::getLinesFromTitleId($object, $lineid, $withBlockLine);
435
+			if(!empty($object->lines)) {
436
+				foreach($object->lines as $line) {
437
+					if($line->id == $lineid) $duplicateLine = $line;
438
+				}
439
+			}
440
+			if(!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) $TLine = array($duplicateLine);
441
+			else $TLine = self::getLinesFromTitleId($object, $lineid, $withBlockLine);
442 442
 
443 443
 			if (!empty($TLine))
444 444
 			{
@@ -456,8 +456,8 @@  discard block
 block discarded – undo
456 456
 							break;
457 457
 							
458 458
 						case 'supplier_proposal':
459
-						    $res = $object->addline($line->desc, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, 'HT', 0, $line->info_bits, $line->product_type, -1, $line->special_code, 0, 0, $line->pa_ht, $line->label, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->origin, $line->origin_id);
460
-						    break;
459
+							$res = $object->addline($line->desc, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, 'HT', 0, $line->info_bits, $line->product_type, -1, $line->special_code, 0, 0, $line->pa_ht, $line->label, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->origin, $line->origin_id);
460
+							break;
461 461
 							
462 462
 						case 'commande':
463 463
 							//$desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0)
@@ -465,10 +465,10 @@  discard block
 block discarded – undo
465 465
 							break;
466 466
 							
467 467
 						case 'order_supplier':
468
-						    $object->line = $line;
469
-						    $object->line->fk_commande = $object->id;
470
-						    $object->line->rang = $object->line_max() +1;
471
-						    $res = $object->line->insert(1);
468
+							$object->line = $line;
469
+							$object->line->fk_commande = $object->id;
470
+							$object->line->rang = $object->line_max() +1;
471
+							$res = $object->line->insert(1);
472 472
 							break;
473 473
 							
474 474
 						case 'facture':
@@ -521,8 +521,8 @@  discard block
 block discarded – undo
521 521
 					$object->db->commit();
522 522
 					foreach ($TLineAdded as &$line)
523 523
 					{
524
-					    // ça peut paraitre non optimisé de déclancher la fonction sur toutes les lignes mais ceci est nécessaire pour réappliquer l'état exact de chaque ligne
525
-					    _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']);
524
+						// ça peut paraitre non optimisé de déclancher la fonction sur toutes les lignes mais ceci est nécessaire pour réappliquer l'état exact de chaque ligne
525
+						_updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']);
526 526
 					}
527 527
 					return count($TLineAdded);
528 528
 				}
@@ -596,33 +596,33 @@  discard block
 block discarded – undo
596 596
 		
597 597
 		switch ($object->element) 
598 598
 		{
599
-		    case 'propal':
600
-		        $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $date_start, $date_end, $array_options, $fk_unit, 0, $notrigger);
601
-		        break;
599
+			case 'propal':
600
+				$res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $date_start, $date_end, $array_options, $fk_unit, 0, $notrigger);
601
+				break;
602 602
 		        
603
-		    case 'supplier_proposal':
604
-		        $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options,'', $fk_unit);
605
-		        break;
603
+			case 'supplier_proposal':
604
+				$res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options,'', $fk_unit);
605
+				break;
606 606
 		        
607 607
 			case 'commande':
608 608
 				$res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $date_start, $date_end, $type, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $special_code, $array_options, $fk_unit, 0, $notrigger);
609 609
 				break;
610 610
 				
611 611
 			case 'order_supplier':
612
-			    $object->special_code = SELF::$module_number;
613
-			    if (empty($desc)) $desc = $label;
614
-			    $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);
615
-			    break;
612
+				$object->special_code = SELF::$module_number;
613
+				if (empty($desc)) $desc = $label;
614
+				$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);
615
+				break;
616 616
 			
617 617
 			case 'facture':
618 618
 				$res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $special_code, $array_options, $situation_percent, $fk_unit, 0, $notrigger);
619 619
 				break;
620 620
 				
621 621
 			case 'invoice_supplier':
622
-			    $object->special_code = SELF::$module_number;
623
-			    if (empty($desc)) $desc = $label;
624
-			    $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);
625
-			    break;
622
+				$object->special_code = SELF::$module_number;
623
+				if (empty($desc)) $desc = $label;
624
+				$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);
625
+				break;
626 626
 				
627 627
 			case 'facturerec':
628 628
 				// Add extrafields and get rang
@@ -1013,8 +1013,8 @@  discard block
 block discarded – undo
1013 1013
 		{
1014 1014
 			if (is_readable($logo))
1015 1015
 			{
1016
-			    $height=pdf_getHeightForLogo($logo);
1017
-			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1016
+				$height=pdf_getHeightForLogo($logo);
1017
+				$pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1018 1018
 			}
1019 1019
 			else
1020 1020
 			{
@@ -1205,13 +1205,13 @@  discard block
 block discarded – undo
1205 1205
 	 * @param	int		$hidebottom		Hide bottom
1206 1206
 	 * @return	void
1207 1207
 	 */
1208
-    private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1209
-    {
1210
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1211
-	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1212
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1213
-	    $pdf->line($x, $y+$h, $x, $y);
1214
-    }
1208
+	private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1209
+	{
1210
+		if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1211
+		$pdf->line($x+$l, $y, $x+$l, $y+$h);
1212
+		if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1213
+		$pdf->line($x, $y+$h, $x, $y);
1214
+	}
1215 1215
 	
1216 1216
 	
1217 1217
 	public static function concat(&$outputlangs, $files, $fileoutput='')
@@ -1221,14 +1221,14 @@  discard block
 block discarded – undo
1221 1221
 		if (empty($fileoutput)) $fileoutput = $file[0];
1222 1222
 		
1223 1223
 		$pdf=pdf_getInstance();
1224
-        if (class_exists('TCPDF'))
1225
-        {
1226
-            $pdf->setPrintHeader(false);
1227
-            $pdf->setPrintFooter(false);
1228
-        }
1229
-        $pdf->SetFont(pdf_getPDFFont($outputlangs));
1224
+		if (class_exists('TCPDF'))
1225
+		{
1226
+			$pdf->setPrintHeader(false);
1227
+			$pdf->setPrintFooter(false);
1228
+		}
1229
+		$pdf->SetFont(pdf_getPDFFont($outputlangs));
1230 1230
 
1231
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1231
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1232 1232
 
1233 1233
 		
1234 1234
 		foreach($files as $file)
Please login to merge, or discard this patch.
Spacing   +197 added lines, -197 removed lines patch added patch discarded remove patch
@@ -5,30 +5,30 @@  discard block
 block discarded – undo
5 5
 	
6 6
 	static $module_number = 104777;
7 7
 	
8
-	static function addSubTotalLine(&$object, $label, $qty, $rang=-1) {
8
+	static function addSubTotalLine(&$object, $label, $qty, $rang = -1) {
9 9
 		
10 10
 		$res = 0;
11 11
 		
12
-		if( (float)DOL_VERSION <= 3.4 ) {
12
+		if ((float) DOL_VERSION <= 3.4) {
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') $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, '', '', 0, 0, '', 'HT', 0, 9, -1, TSubtotal::$module_number);
17 17
 			/**
18 18
 			 * @var $object Propal
19 19
 			 */
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);
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);
21 21
 			/**
22 22
 			 * @var $object Commande
23 23
 			 */
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);
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);
25 25
 
26 26
 		}
27 27
 		else {
28 28
 			$desc = '';
29 29
 			
30
-			$TNotElements = array ('invoice_supplier', 'order_supplier');
31
-			if ((float) DOL_VERSION < 6  || $qty==50 && !in_array($object->element, $TNotElements) ) {
30
+			$TNotElements = array('invoice_supplier', 'order_supplier');
31
+			if ((float) DOL_VERSION < 6 || $qty == 50 && !in_array($object->element, $TNotElements)) {
32 32
 				$desc = $label;
33 33
 				$label = '';
34 34
 			}
@@ -36,39 +36,39 @@  discard block
 block discarded – undo
36 36
 			/**
37 37
 			 * @var $object Facture
38 38
 			 */
39
-			if($object->element=='facture') $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);
39
+			if ($object->element == 'facture') $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 40
 			/**
41 41
 			 * @var $object Facture fournisseur
42 42
 			 */
43
-			else if($object->element=='invoice_supplier') {
43
+			else if ($object->element == 'invoice_supplier') {
44 44
 			    $object->special_code = TSubtotal::$module_number;
45
-                if( (float)DOL_VERSION < 6 ) $rang = $object->line_max() + 1;
46
-			    $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
45
+                if ((float) DOL_VERSION < 6) $rang = $object->line_max() + 1;
46
+			    $res = $object->addline($label, 0, 0, 0, 0, $qty, 0, 0, '', '', 0, 0, 'HT', 9, $rang);
47 47
 			}
48 48
 			/**
49 49
 			 * @var $object Propal
50 50
 			 */
51
-			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);
51
+			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);
52 52
 			/**
53 53
 			 * @var $object Propal Fournisseur
54 54
 			 */
55
-			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);
55
+			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);
56 56
 			
57 57
 			/**
58 58
 			 * @var $object Commande
59 59
 			 */
60
-			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);
60
+			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);
61 61
 			/**
62 62
 			 * @var $object Commande fournisseur
63 63
 			 */
64
-			else if($object->element=='order_supplier') {
64
+			else if ($object->element == 'order_supplier') {
65 65
 			    $object->special_code = TSubtotal::$module_number;
66
-			    $res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9);
66
+			    $res = $object->addline($label, 0, $qty, 0, 0, 0, 0, 0, '', 0, 'HT', 0, 9);
67 67
 			}
68 68
 			/**
69 69
 			 * @var $object Facturerec
70 70
 			 */
71
-			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); 
71
+			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); 
72 72
 			
73 73
 		}
74 74
 	
@@ -79,20 +79,20 @@  discard block
 block discarded – undo
79 79
 
80 80
 	public static function generateDoc(&$object)
81 81
 	{
82
-		global $conf,$langs,$db;
82
+		global $conf, $langs, $db;
83 83
 		
84 84
 		if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
85 85
 		{
86
-			$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
87
-			$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
88
-			$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
86
+			$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
87
+			$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
88
+			$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
89 89
 			
90 90
 			// Define output language
91 91
 			$outputlangs = $langs;
92 92
 			$newlang = GETPOST('lang_id', 'alpha');
93
-			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
93
+			if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
94 94
 				$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
95
-			if (! empty($newlang)) {
95
+			if (!empty($newlang)) {
96 96
 				$outputlangs = new Translate("", $conf);
97 97
 				$outputlangs->setDefaultLang($newlang);
98 98
 			}
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 			}
107 107
 			else
108 108
 			{
109
-				if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
109
+				if ($object->element != 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
110 110
 			}
111 111
 		}
112 112
 	}
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
 	 * @param type $rang_start
119 119
 	 * @param type $move_to
120 120
 	 */
121
-	public static function updateRang(&$object, $rang_start, $move_to=1)
121
+	public static function updateRang(&$object, $rang_start, $move_to = 1)
122 122
 	{
123 123
 		if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
124 124
 		
125
-		$row=new GenericObject($object->db);
125
+		$row = new GenericObject($object->db);
126 126
 		$row->table_element_line = $object->table_element_line;
127 127
 		$row->fk_element = $object->fk_element;
128 128
 		$row->id = $object->id;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		{
132 132
 			if ($line->rang < $rang_start) continue;
133 133
 			
134
-			$row->updateRangOfLine($line->id, $line->rang+$move_to);
134
+			$row->updateRangOfLine($line->id, $line->rang + $move_to);
135 135
 		}
136 136
 	}
137 137
 	
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			{
161 161
 				if ($rang_to_add != -1) self::updateRang($object, $rang_to_add);
162 162
 				
163
-				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add);
163
+				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100 - $title_niveau, $rang_to_add);
164 164
 				
165 165
 				$object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas)
166 166
 				if ($rang_to_add != -1) 
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 		}
173 173
 	}
174 174
 	
175
-	public static function addTitle(&$object, $label, $level, $rang=-1)
175
+	public static function addTitle(&$object, $label, $level, $rang = -1)
176 176
 	{
177 177
 		self::addSubTotalLine($object, $label, $level, $rang);
178 178
 	}
179 179
 	
180
-	public static function addTotal(&$object, $label, $level, $rang=-1)
180
+	public static function addTotal(&$object, $label, $level, $rang = -1)
181 181
 	{
182
-		self::addSubTotalLine($object, $label, (100-$level), $rang);
182
+		self::addSubTotalLine($object, $label, (100 - $level), $rang);
183 183
 	}
184 184
 
185 185
 	/**
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * 
191 191
 	 * @return array
192 192
 	 */
193
-	public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total=false)
193
+	public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total = false)
194 194
 	{
195 195
 		$TTitle = self::getAllTitleFromDocument($object, $get_block_total);
196 196
 		
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	 * @param boolean								$return_rang_on_false	si true alors renvoi le rang où devrait ce trouver le sous-total
212 212
 	 * @return boolean
213 213
 	 */
214
-	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false)
214
+	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode = false, $return_rang_on_false = false)
215 215
 	{
216 216
 		if (empty($object->lines) || !is_array($object->lines)) return false;
217 217
 		
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		return ($return_rang_on_false) ? -1 : false;
238 238
 	}
239 239
 	
240
-	public static function getAllTitleFromDocument(&$object, $get_block_total=false)
240
+	public static function getAllTitleFromDocument(&$object, $get_block_total = false)
241 241
 	{
242 242
 		$TRes = array();
243 243
 		if (!empty($object->lines))
@@ -365,19 +365,19 @@  discard block
 block discarded – undo
365 365
 		return false;
366 366
 	}
367 367
 	
368
-	public static function isTitle(&$line, $level=-1)
368
+	public static function isTitle(&$line, $level = -1)
369 369
 	{
370 370
 		$res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9;
371
-		if($res && $level > -1) {
371
+		if ($res && $level > -1) {
372 372
 			return $line->qty == $level;
373 373
 		} else return $res;
374 374
 		
375 375
 	}
376 376
 	
377
-	public static function isSubtotal(&$line, $level=-1)
377
+	public static function isSubtotal(&$line, $level = -1)
378 378
 	{
379 379
 	    $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90;
380
-	    if($res && $level > -1) {
380
+	    if ($res && $level > -1) {
381 381
 	        return self::getNiveau($line) == $level;
382 382
 	    } else return $res;
383 383
 	}
@@ -392,52 +392,52 @@  discard block
 block discarded – undo
392 392
 		return self::isTitle($line) || self::isSubtotal($line) || self::isFreeText($line);
393 393
 	}
394 394
 
395
-	public static function getFreeTextHtml(&$line, $readonly=0)
395
+	public static function getFreeTextHtml(&$line, $readonly = 0)
396 396
 	{
397 397
 		global $conf;
398 398
 		
399 399
 		// Copie du fichier "objectline_edit.tpl.php"
400 400
 		// editeur wysiwyg
401 401
 		require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
402
-		$nbrows=ROWS_2;
403
-		if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
404
-		$enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
405
-		$toolbarname='dolibarr_details';
406
-		if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes';
407
-		$text = !empty($line->description)?$line->description:$line->label;
408
-		$doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly);
402
+		$nbrows = ROWS_2;
403
+		if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
404
+		$enable = (isset($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
405
+		$toolbarname = 'dolibarr_details';
406
+		if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname = 'dolibarr_notes';
407
+		$text = !empty($line->description) ? $line->description : $line->label;
408
+		$doleditor = new DolEditor('line-description', $text, '', 164, $toolbarname, '', false, true, $enable, $nbrows, '98%', $readonly);
409 409
 		return $doleditor->Create(1);
410 410
 	}
411 411
 	
412
-	public static function duplicateLines(&$object, $lineid, $withBlockLine=false)
412
+	public static function duplicateLines(&$object, $lineid, $withBlockLine = false)
413 413
 	{
414
-		global $db,$user,$conf;
414
+		global $db, $user, $conf;
415 415
 
416 416
 		$createRight = $user->rights->{$object->element}->creer;
417
-		if($object->element == 'facturerec' )
417
+		if ($object->element == 'facturerec')
418 418
 		{
419 419
 		    $object->statut = 0; // hack for facture rec
420 420
 		    $createRight = $user->rights->facture->creer;
421 421
 		}
422
-		elseif($object->element == 'order_supplier' )
422
+		elseif ($object->element == 'order_supplier')
423 423
 		{
424 424
 		    $createRight = $user->rights->fournisseur->commande->creer;
425 425
 		}
426
-		elseif($object->element == 'invoice_supplier' )
426
+		elseif ($object->element == 'invoice_supplier')
427 427
 		{
428 428
 		    $createRight = $user->rights->fournisseur->facture->creer;
429 429
 		}
430 430
 		
431
-		if ($object->statut == 0  && $createRight && (!empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) || !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE)))
431
+		if ($object->statut == 0 && $createRight && (!empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) || !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE)))
432 432
 		{
433 433
 			dol_include_once('/subtotal/lib/subtotal.lib.php');
434 434
 
435
-            if(!empty($object->lines)) {
436
-                foreach($object->lines as $line) {
437
-                    if($line->id == $lineid) $duplicateLine = $line;
435
+            if (!empty($object->lines)) {
436
+                foreach ($object->lines as $line) {
437
+                    if ($line->id == $lineid) $duplicateLine = $line;
438 438
                 }
439 439
             }
440
-            if(!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) $TLine = array($duplicateLine);
440
+            if (!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) $TLine = array($duplicateLine);
441 441
             else $TLine = self::getLinesFromTitleId($object, $lineid, $withBlockLine);
442 442
 
443 443
 			if (!empty($TLine))
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 						case 'order_supplier':
468 468
 						    $object->line = $line;
469 469
 						    $object->line->fk_commande = $object->id;
470
-						    $object->line->rang = $object->line_max() +1;
470
+						    $object->line->rang = $object->line_max() + 1;
471 471
 						    $res = $object->line->insert(1);
472 472
 							break;
473 473
 							
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 					{
508 508
 						$object->line_from = $line;
509 509
 						// Call trigger
510
-						$result=$object->call_trigger('LINE_DUPLICATE',$user); // $object->line
510
+						$result = $object->call_trigger('LINE_DUPLICATE', $user); // $object->line
511 511
 						if ($result < 0)
512 512
 						{
513 513
 							$object->db->rollback();
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 		}
538 538
 	}
539 539
 	
540
-	public static function getLinesFromTitle(&$object, $key_trad, $level=1, $under_title='', $withBlockLine=false, $key_is_id=false)
540
+	public static function getLinesFromTitle(&$object, $key_trad, $level = 1, $under_title = '', $withBlockLine = false, $key_is_id = false)
541 541
 	{
542 542
 		global $langs;
543 543
 		
@@ -549,17 +549,17 @@  discard block
 block discarded – undo
549 549
 		
550 550
 		$TLine = array();
551 551
 		$add_line = false;
552
-		$under_title_found=false;
552
+		$under_title_found = false;
553 553
 		
554 554
 		foreach ($object->lines as $key => &$line)
555 555
 		{
556 556
 			if (!$under_title_found && !empty($TTitle_under_search))
557 557
 			{
558
-				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true;
558
+				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search))) $under_title_found = true;
559 559
 			}
560 560
 			else
561 561
 			{
562
-				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) )))
562
+				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))))
563 563
 				{
564 564
 					if ($key_is_id) $level = $line->qty;
565 565
 					
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 				
576 576
 				if ($add_line)
577 577
 				{
578
-					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue;
578
+					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line))) continue;
579 579
 					else $TLine[] = $line;
580 580
 				}
581 581
 			}
@@ -584,12 +584,12 @@  discard block
 block discarded – undo
584 584
 		return $TLine;
585 585
 	}
586 586
 	
587
-	public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine=false)
587
+	public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine = false)
588 588
 	{
589 589
 		return self::getLinesFromTitle($object, $lineid, '', '', $withBlockLine, true);
590 590
 	}
591 591
 	
592
-	public static function doUpdateLine(&$object, $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $type, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0, $fk_unit = null, $notrigger = 0)
592
+	public static function doUpdateLine(&$object, $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $type, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 0, $fk_unit = null, $notrigger = 0)
593 593
 	{
594 594
 		$res = 0;
595 595
 		$object->db->begin();
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		        break;
602 602
 		        
603 603
 		    case 'supplier_proposal':
604
-		        $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options,'', $fk_unit);
604
+		        $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options, '', $fk_unit);
605 605
 		        break;
606 606
 		        
607 607
 			case 'commande':
@@ -630,9 +630,9 @@  discard block
 block discarded – undo
630 630
 				$factureRecLine->fetch($rowid);
631 631
 				$factureRecLine->array_options = $array_options;
632 632
 				$factureRecLine->insertExtraFields();
633
-				$rang=$factureRecLine->rang;
633
+				$rang = $factureRecLine->rang;
634 634
 				
635
-				$fk_product=0; $fk_remise_except=''; $pu_ttc=0;	
635
+				$fk_product = 0; $fk_remise_except = ''; $pu_ttc = 0;	
636 636
 				$res = $object->updateline($rowid, $desc, $pu, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $price_base_type, $info_bits, $fk_remise_except, $pu_ttc, $type, $rang, $special_code, $label, $fk_unit);
637 637
 				break;
638 638
 		}
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 		global $db, $object;
649 649
 		
650 650
 		$TTitle = array();
651
-		if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {}
651
+		if (!empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {}
652 652
 		else {
653 653
 			if ($origin_line->element == 'propaldet')
654 654
 			{
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 	 */
729 729
 	public static function addRecapPage(&$parameters, &$origin_pdf)
730 730
 	{
731
-		global $user,$conf,$langs;
731
+		global $user, $conf, $langs;
732 732
 		
733 733
 		$origin_file = $parameters['file'];
734 734
 		$outputlangs = $parameters['outputlangs'];
@@ -744,21 +744,21 @@  discard block
 block discarded – undo
744 744
 		$objmarge->marge_droite = 10;
745 745
 		
746 746
 		$objectref = dol_sanitizeFileName($object->ref);
747
-		if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref;
748
-		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref;
749
-		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref;
747
+		if ($object->element == 'propal') $dir = $conf->propal->dir_output.'/'.$objectref;
748
+		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output.'/'.$objectref;
749
+		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output.'/'.$objectref;
750 750
 		elseif ($object->element == 'facturerec') return; // no PDF for facturerec
751 751
 		else
752 752
 		{
753 753
 			setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings');
754 754
 			return -1;
755 755
 		}
756
-		$file = $dir . '/' . $objectref . '_recap.pdf';
756
+		$file = $dir.'/'.$objectref.'_recap.pdf';
757 757
 
758 758
 //		$pdf=pdf_getInstance($origin_pdf->format);
759
-		$pdf=pdf_getInstance(array(210, 297)); // Format A4 Portrait
760
-		$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
761
-		$pdf->SetAutoPageBreak(1,0);
759
+		$pdf = pdf_getInstance(array(210, 297)); // Format A4 Portrait
760
+		$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
761
+		$pdf->SetAutoPageBreak(1, 0);
762 762
 	             
763 763
 		if (class_exists('TCPDF'))
764 764
 		{
@@ -767,49 +767,49 @@  discard block
 block discarded – undo
767 767
 		}
768 768
 		$pdf->SetFont(pdf_getPDFFont($outputlangs));
769 769
 		// Set path to the background PDF File
770
-		if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
770
+		if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
771 771
 		{
772 772
 			$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
773 773
 			$tplidx = $pdf->importPage(1);
774 774
 		}
775 775
 
776 776
 		$pdf->Open();
777
-		$pagenb=0;
778
-		$pdf->SetDrawColor(128,128,128);
777
+		$pagenb = 0;
778
+		$pdf->SetDrawColor(128, 128, 128);
779 779
 
780 780
 		$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
781 781
 		$pdf->SetSubject($outputlangs->transnoentities("subtotalRecap"));
782 782
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
783 783
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
784 784
 		$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
785
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
785
+		if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
786 786
 
787
-		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite);   // Left, Top, Right
787
+		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right
788 788
 
789
-		$pagenb=0;
790
-		$pdf->SetDrawColor(128,128,128);
789
+		$pagenb = 0;
790
+		$pdf->SetDrawColor(128, 128, 128);
791 791
 
792 792
 			
793 793
 		// New page
794 794
 		$pdf->AddPage();
795
-		if (! empty($tplidx)) $pdf->useTemplate($tplidx);
795
+		if (!empty($tplidx)) $pdf->useTemplate($tplidx);
796 796
 		$pagenb++;
797 797
 		
798 798
 		
799 799
 		self::pagehead($objmarge, $pdf, $object, 1, $outputlangs);
800
-		$pdf->SetFont('','', $default_font_size - 1);
801
-		$pdf->MultiCell(0, 3, '');		// Set interline to 3
802
-		$pdf->SetTextColor(0,0,0);
800
+		$pdf->SetFont('', '', $default_font_size - 1);
801
+		$pdf->MultiCell(0, 3, ''); // Set interline to 3
802
+		$pdf->SetTextColor(0, 0, 0);
803 803
 		
804
-		$heightforinfotot = 25;	// Height reserved to output the info and total part
805
-		$heightforfooter = $objmarge->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
804
+		$heightforinfotot = 25; // Height reserved to output the info and total part
805
+		$heightforfooter = $objmarge->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
806 806
 		
807 807
 		$posx_designation = 25;
808 808
 		$posx_options = 150;
809 809
 		$posx_montant = 170;
810 810
 		
811 811
 		$tab_top = 72;
812
-		$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?72:20); // TODO à vérifier
812
+		$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 72 : 20); // TODO à vérifier
813 813
 		
814 814
 		$TTot = array('total_ht' => 0, 'total_ttc' => 0, 'TTotal_tva' => array());
815 815
 		
@@ -823,14 +823,14 @@  discard block
 block discarded – undo
823 823
 			$nexY = $tab_top + 10;
824 824
 			
825 825
 			$nblignes = count($TLine);
826
-			foreach($TLine as $i => &$line)
826
+			foreach ($TLine as $i => &$line)
827 827
 			{
828 828
 				$curY = $nexY;
829 829
 				
830 830
 				if (self::getNiveau($line) == 1) 
831 831
 				{
832
-					$pdf->SetFont('','B', $default_font_size - 1);   // Into loop to work with multipage
833
-					$curY+=2;
832
+					$pdf->SetFont('', 'B', $default_font_size - 1); // Into loop to work with multipage
833
+					$curY += 2;
834 834
 					
835 835
 					$TTot['total_ht'] += $line->total_ht;
836 836
 					$TTot['total_tva'] += $line->total_tva;
@@ -849,67 +849,67 @@  discard block
 block discarded – undo
849 849
 						$TTot['TTotal_tva_multicurrency'][$tx] += $amount;
850 850
 					}	
851 851
 				}
852
-				else $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
852
+				else $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
853 853
 				
854
-				$pdf->SetTextColor(0,0,0);
854
+				$pdf->SetTextColor(0, 0, 0);
855 855
 				
856 856
 				$pdf->setTopMargin($tab_top_newpage + 10);
857
-				$pdf->setPageOrientation('', 1, $heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
858
-				$pageposbefore=$pdf->getPage();
857
+				$pdf->setPageOrientation('', 1, $heightforfooter + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
858
+				$pageposbefore = $pdf->getPage();
859 859
 				
860
-				$showpricebeforepagebreak=1;
860
+				$showpricebeforepagebreak = 1;
861 861
 				
862 862
 				$decalage = (self::getNiveau($line) - 1) * 2;
863 863
 				
864 864
 				// Print: Designation
865 865
 				$label = $line->label;
866
-				if( (float)DOL_VERSION < 6 ) {
866
+				if ((float) DOL_VERSION < 6) {
867 867
 					$label = !empty($line->label) ? $line->label : $line->desc;
868 868
 				}
869 869
 				
870 870
 				
871 871
 				$pdf->startTransaction();
872
-				$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
873
-				$pageposafter=$pdf->getPage();
872
+				$pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true);
873
+				$pageposafter = $pdf->getPage();
874 874
 				if ($pageposafter > $pageposbefore)	// There is a pagebreak
875 875
 				{
876 876
 					$pdf->rollbackTransaction(true);
877
-					$pageposafter=$pageposbefore;
877
+					$pageposafter = $pageposbefore;
878 878
 					//print $pageposafter.'-'.$pageposbefore;exit;
879
-					$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
880
-					$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
879
+					$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
880
+					$pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true);
881 881
 
882
-					$pageposafter=$pdf->getPage();
883
-					$posyafter=$pdf->GetY();
882
+					$pageposafter = $pdf->getPage();
883
+					$posyafter = $pdf->GetY();
884 884
 					//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
885
-					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot)))	// There is no space left for total+free text
885
+					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter + $heightforinfotot)))	// There is no space left for total+free text
886 886
 					{
887
-						if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
887
+						if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
888 888
 						{
889
-							$pdf->AddPage('','',true);
890
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
889
+							$pdf->AddPage('', '', true);
890
+							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
891 891
 							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
892
-							$pdf->setPage($pageposafter+1);
892
+							$pdf->setPage($pageposafter + 1);
893 893
 						}
894 894
 					}
895 895
 					else
896 896
 					{
897 897
 						// We found a page break
898
-						$showpricebeforepagebreak=0;
898
+						$showpricebeforepagebreak = 0;
899 899
 					}
900 900
 				}
901 901
 				else	// No pagebreak
902 902
 				{
903 903
 					$pdf->commitTransaction();
904 904
 				}
905
-				$posYAfterDescription=$pdf->GetY();
905
+				$posYAfterDescription = $pdf->GetY();
906 906
 
907 907
 				$nexY = $pdf->GetY();
908
-				$pageposafter=$pdf->getPage();
908
+				$pageposafter = $pdf->getPage();
909 909
 
910 910
 				$pdf->setPage($pageposbefore);
911 911
 				$pdf->setTopMargin($objmarge->marge_haute);
912
-				$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
912
+				$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
913 913
 
914 914
 				// We suppose that a too long description or photo were moved completely on next page
915 915
 				if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
@@ -922,14 +922,14 @@  discard block
 block discarded – undo
922 922
 				if (!empty($line->total_options))
923 923
 				{
924 924
 					$pdf->SetXY($posx_options, $curY);
925
-					$pdf->MultiCell($posx_montant-$posx_options-0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0);
925
+					$pdf->MultiCell($posx_montant - $posx_options - 0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0);
926 926
 				}
927 927
 				
928 928
 				// Print: Montant
929 929
 				$pdf->SetXY($posx_montant, $curY);
930
-				$pdf->MultiCell($objmarge->page_largeur-$objmarge->marge_droite-$posx_montant-0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0);
930
+				$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant - 0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0);
931 931
 				
932
-				$nexY+=2;    // Passe espace entre les lignes
932
+				$nexY += 2; // Passe espace entre les lignes
933 933
 
934 934
 				// Detect if some page were added automatically and output _tableau for past pages
935 935
 				while ($pagenb < $pageposafter)
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
 					
947 947
 					$pagenb++;
948 948
 					$pdf->setPage($pagenb);
949
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
949
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
950 950
 					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
951 951
 				}
952 952
 			}
@@ -956,19 +956,19 @@  discard block
 block discarded – undo
956 956
 		if ($pagenb == 1)
957 957
 		{
958 958
 			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);
959
-			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
959
+			$bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
960 960
 		}
961 961
 		else
962 962
 		{
963 963
 			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);
964
-			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
964
+			$bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
965 965
 		}
966 966
 		
967 967
 		// Affiche zone totaux
968
-		$posy=self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot);
968
+		$posy = self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot);
969 969
 		
970 970
 		$pdf->Close();
971
-		$pdf->Output($file,'F');
971
+		$pdf->Output($file, 'F');
972 972
 		
973 973
 		$pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file);
974 974
 		
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
 		$level = $line->qty; // TODO à améliorer
981 981
 		
982 982
 		$pdf->SetXY($objmarge->marge_gauche, $curY);
983
-		$pdf->MultiCell($posx_designation-$objmarge->marge_gauche-0.8, 5, $level, 0, 'L', 0);
983
+		$pdf->MultiCell($posx_designation - $objmarge->marge_gauche - 0.8, 5, $level, 0, 'L', 0);
984 984
 	}
985 985
 	
986 986
 	/**
@@ -994,50 +994,50 @@  discard block
 block discarded – undo
994 994
 	 */
995 995
 	private static function pagehead(&$objmarge, &$pdf, &$object, $showdetail, $outputlangs)
996 996
 	{
997
-		global $conf,$mysoc;
997
+		global $conf, $mysoc;
998 998
 
999 999
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1000 1000
 
1001
-		pdf_pagehead($pdf,$outputlangs,$objmarge->page_hauteur);
1001
+		pdf_pagehead($pdf, $outputlangs, $objmarge->page_hauteur);
1002 1002
 
1003
-		$pdf->SetTextColor(0,0,60);
1004
-		$pdf->SetFont('','B', $default_font_size + 3);
1003
+		$pdf->SetTextColor(0, 0, 60);
1004
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1005 1005
 
1006
-		$posy=$objmarge->marge_haute;
1007
-		$posx=$objmarge->page_largeur-$objmarge->marge_droite-100;
1006
+		$posy = $objmarge->marge_haute;
1007
+		$posx = $objmarge->page_largeur - $objmarge->marge_droite - 100;
1008 1008
 		
1009
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
1009
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
1010 1010
 
1011
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
1011
+		$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
1012 1012
 		if ($mysoc->logo)
1013 1013
 		{
1014 1014
 			if (is_readable($logo))
1015 1015
 			{
1016
-			    $height=pdf_getHeightForLogo($logo);
1017
-			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1016
+			    $height = pdf_getHeightForLogo($logo);
1017
+			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto)
1018 1018
 			}
1019 1019
 			else
1020 1020
 			{
1021
-				$pdf->SetTextColor(200,0,0);
1022
-				$pdf->SetFont('','B',$default_font_size - 2);
1023
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1021
+				$pdf->SetTextColor(200, 0, 0);
1022
+				$pdf->SetFont('', 'B', $default_font_size - 2);
1023
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1024 1024
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1025 1025
 			}
1026 1026
 			
1027
-			$posy+=35;
1027
+			$posy += 35;
1028 1028
 		}
1029 1029
 		else
1030 1030
 		{
1031
-			$text=$mysoc->name;
1031
+			$text = $mysoc->name;
1032 1032
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1033 1033
 			
1034
-			$posy+=15;
1034
+			$posy += 15;
1035 1035
 		}
1036 1036
 		
1037 1037
 		
1038
-		$pdf->SetTextColor(0,0,0);
1039
-		$pdf->SetFont('','B', $default_font_size + 2);
1040
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
1038
+		$pdf->SetTextColor(0, 0, 0);
1039
+		$pdf->SetFont('', 'B', $default_font_size + 2);
1040
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
1041 1041
 		
1042 1042
 		$key = 'subtotalPropalTitle';
1043 1043
 		if ($object->element == 'commande') $key = 'subtotalCommandeTitle';
@@ -1046,14 +1046,14 @@  discard block
 block discarded – undo
1046 1046
 		
1047 1047
 		$pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L');
1048 1048
 		
1049
-		$pdf->SetFont('','', $default_font_size);
1050
-		$pdf->SetXY($objmarge->page_largeur-$objmarge->marge_droite-40,$posy);
1049
+		$pdf->SetFont('', '', $default_font_size);
1050
+		$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - 40, $posy);
1051 1051
 		$pdf->MultiCell(40, 4, dol_print_date($object->date, 'daytext'), '', 'R');
1052 1052
 		
1053 1053
 		$posy += 8;
1054 1054
 			
1055
-		$pdf->SetFont('','B', $default_font_size + 2);
1056
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
1055
+		$pdf->SetFont('', 'B', $default_font_size + 2);
1056
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
1057 1057
 		$pdf->MultiCell(70, 4, $outputlangs->transnoentities('subtotalRecapLot'), '', 'L');
1058 1058
 		
1059 1059
 	}
@@ -1071,44 +1071,44 @@  discard block
 block discarded – undo
1071 1071
 	 *   @param		string		$currency		Currency code
1072 1072
 	 *   @return	void
1073 1073
 	 */
1074
-	private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1074
+	private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1075 1075
 	{
1076 1076
 		global $conf;
1077 1077
 		
1078 1078
 		// Force to disable hidetop and hidebottom
1079
-		$hidebottom=0;
1080
-		if ($hidetop) $hidetop=-1;
1079
+		$hidebottom = 0;
1080
+		if ($hidetop) $hidetop = -1;
1081 1081
 
1082 1082
 		$currency = !empty($currency) ? $currency : $conf->currency;
1083 1083
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1084 1084
 
1085 1085
 		// Amount in (at tab_top - 1)
1086
-		$pdf->SetTextColor(0,0,0);
1087
-		$pdf->SetFont('','',$default_font_size);
1086
+		$pdf->SetTextColor(0, 0, 0);
1087
+		$pdf->SetFont('', '', $default_font_size);
1088 1088
 
1089 1089
 		if (empty($hidetop))
1090 1090
 		{
1091
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1092
-			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5);
1091
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1092
+			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4.5);
1093 1093
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1094 1094
 			
1095
-			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));
1095
+			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));
1096 1096
 			
1097 1097
 			
1098
-			$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
1098
+			$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
1099 1099
 
1100
-			$pdf->SetXY($posx_designation, $tab_top+2);
1101
-			$pdf->MultiCell($posx_options - $posx_designation,2, $outputlangs->transnoentities("Designation"),'','L');
1102
-			$pdf->SetXY($posx_options, $tab_top+2);
1103
-			$pdf->MultiCell($posx_montant - $posx_options,2, $outputlangs->transnoentities("Options"),'','R');
1104
-			$pdf->SetXY($posx_montant, $tab_top+2);
1105
-			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R');
1100
+			$pdf->SetXY($posx_designation, $tab_top + 2);
1101
+			$pdf->MultiCell($posx_options - $posx_designation, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1102
+			$pdf->SetXY($posx_options, $tab_top + 2);
1103
+			$pdf->MultiCell($posx_montant - $posx_options, 2, $outputlangs->transnoentities("Options"), '', 'R');
1104
+			$pdf->SetXY($posx_montant, $tab_top + 2);
1105
+			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant, 2, $outputlangs->transnoentities("Amount"), '', 'R');
1106 1106
 			
1107
-			$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
1107
+			$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
1108 1108
 		}
1109 1109
 		else
1110 1110
 		{
1111
-			$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
1111
+			$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
1112 1112
 		}
1113 1113
 		
1114 1114
 	}
@@ -1117,29 +1117,29 @@  discard block
 block discarded – undo
1117 1117
 	{
1118 1118
 		global $conf;
1119 1119
 		
1120
-		$pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur-$objmarge->marge_droite, $posy);	// line prend une position y en 2eme param et 4eme param
1120
+		$pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur - $objmarge->marge_droite, $posy); // line prend une position y en 2eme param et 4eme param
1121 1121
 		
1122 1122
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1123 1123
 		
1124
-		$tab2_top = $posy+2;
1124
+		$tab2_top = $posy + 2;
1125 1125
 		$tab2_hl = 4;
1126
-		$pdf->SetFont('','', $default_font_size - 1);
1126
+		$pdf->SetFont('', '', $default_font_size - 1);
1127 1127
 
1128 1128
 		// Tableau total
1129 1129
 		$col1x = 120; $col2x = 170;
1130 1130
 		if ($objmarge->page_largeur < 210) // To work with US executive format
1131 1131
 		{
1132
-			$col2x-=20;
1132
+			$col2x -= 20;
1133 1133
 		}
1134 1134
 		$largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x);
1135 1135
 
1136
-		$useborder=0;
1136
+		$useborder = 0;
1137 1137
 		$index = 0;
1138 1138
 
1139 1139
 		// Total HT
1140
-		$pdf->SetFillColor(255,255,255);
1140
+		$pdf->SetFillColor(255, 255, 255);
1141 1141
 		$pdf->SetXY($col1x, $tab2_top + 0);
1142
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1142
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1143 1143
 
1144 1144
 		// $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1) ? $TTot['multicurrency_total_ht'] : $TTot['total_ht'];
1145 1145
 		$total_ht = $TTot['total_ht'];
@@ -1147,10 +1147,10 @@  discard block
 block discarded – undo
1147 1147
 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht, 0, $outputlangs), 0, 'R', 1);
1148 1148
 
1149 1149
 		// Show VAT by rates and total
1150
-		$pdf->SetFillColor(248,248,248);
1150
+		$pdf->SetFillColor(248, 248, 248);
1151 1151
 		
1152
-		$atleastoneratenotnull=0;
1153
-		foreach($TTot['TTotal_tva'] as $tvakey => $tvaval)
1152
+		$atleastoneratenotnull = 0;
1153
+		foreach ($TTot['TTotal_tva'] as $tvakey => $tvaval)
1154 1154
 		{
1155 1155
 			if ($tvakey != 0)    // On affiche pas taux 0
1156 1156
 			{
@@ -1159,15 +1159,15 @@  discard block
 block discarded – undo
1159 1159
 				$index++;
1160 1160
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1161 1161
 
1162
-				$tvacompl='';
1163
-				if (preg_match('/\*/',$tvakey))
1162
+				$tvacompl = '';
1163
+				if (preg_match('/\*/', $tvakey))
1164 1164
 				{
1165
-					$tvakey=str_replace('*','',$tvakey);
1165
+					$tvakey = str_replace('*', '', $tvakey);
1166 1166
 					$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1167 1167
 				}
1168
-				$totalvat =$outputlangs->transnoentities("TotalVAT").' ';
1169
-				$totalvat.=vatrate($tvakey,1).$tvacompl;
1170
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1168
+				$totalvat = $outputlangs->transnoentities("TotalVAT").' ';
1169
+				$totalvat .= vatrate($tvakey, 1).$tvacompl;
1170
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1171 1171
 
1172 1172
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1173 1173
 				$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1177,16 +1177,16 @@  discard block
 block discarded – undo
1177 1177
 		// Total TTC
1178 1178
 		$index++;
1179 1179
 		$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1180
-		$pdf->SetTextColor(0,0,60);
1181
-		$pdf->SetFillColor(224,224,224);
1182
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1180
+		$pdf->SetTextColor(0, 0, 60);
1181
+		$pdf->SetFillColor(224, 224, 224);
1182
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1183 1183
 
1184 1184
 		// $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $TTot['multicurrency_total_ttc'] : $TTot['total_ttc'];
1185 1185
 		$total_ttc = $TTot['total_ttc'];
1186 1186
 		$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1187 1187
 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1188 1188
 
1189
-		$pdf->SetTextColor(0,0,0);
1189
+		$pdf->SetTextColor(0, 0, 0);
1190 1190
 				
1191 1191
 		$index++;
1192 1192
 		return ($tab2_top + ($tab2_hl * $index));
@@ -1205,22 +1205,22 @@  discard block
 block discarded – undo
1205 1205
 	 * @param	int		$hidebottom		Hide bottom
1206 1206
 	 * @return	void
1207 1207
 	 */
1208
-    private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1208
+    private static function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0)
1209 1209
     {
1210
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1211
-	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1212
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1213
-	    $pdf->line($x, $y+$h, $x, $y);
1210
+	    if (empty($hidetop) || $hidetop == -1) $pdf->line($x, $y, $x + $l, $y);
1211
+	    $pdf->line($x + $l, $y, $x + $l, $y + $h);
1212
+	    if (empty($hidebottom)) $pdf->line($x + $l, $y + $h, $x, $y + $h);
1213
+	    $pdf->line($x, $y + $h, $x, $y);
1214 1214
     }
1215 1215
 	
1216 1216
 	
1217
-	public static function concat(&$outputlangs, $files, $fileoutput='')
1217
+	public static function concat(&$outputlangs, $files, $fileoutput = '')
1218 1218
 	{
1219 1219
 		global $conf;
1220 1220
 		
1221 1221
 		if (empty($fileoutput)) $fileoutput = $file[0];
1222 1222
 		
1223
-		$pdf=pdf_getInstance();
1223
+		$pdf = pdf_getInstance();
1224 1224
         if (class_exists('TCPDF'))
1225 1225
         {
1226 1226
             $pdf->setPrintHeader(false);
@@ -1228,10 +1228,10 @@  discard block
 block discarded – undo
1228 1228
         }
1229 1229
         $pdf->SetFont(pdf_getPDFFont($outputlangs));
1230 1230
 
1231
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1231
+        if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1232 1232
 
1233 1233
 		
1234
-		foreach($files as $file)
1234
+		foreach ($files as $file)
1235 1235
 		{
1236 1236
 			$pagecount = $pdf->setSourceFile($file);
1237 1237
 			for ($i = 1; $i <= $pagecount; $i++)
@@ -1243,8 +1243,8 @@  discard block
 block discarded – undo
1243 1243
 			}
1244 1244
 		}
1245 1245
 		
1246
-		$pdf->Output($fileoutput,'F');
1247
-		if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1246
+		$pdf->Output($fileoutput, 'F');
1247
+		if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1248 1248
 
1249 1249
 		return $pagecount;
1250 1250
 	}
@@ -1257,7 +1257,7 @@  discard block
 block discarded – undo
1257 1257
 	 */
1258 1258
 	public static function hasNcTitle(&$line)
1259 1259
 	{
1260
-		if(isset($line->has_nc_title)) return $line->has_nc_title;
1260
+		if (isset($line->has_nc_title)) return $line->has_nc_title;
1261 1261
 
1262 1262
 		$TTitle = self::getAllTitleFromLine($line);
1263 1263
 		foreach ($TTitle as &$line_title)
Please login to merge, or discard this patch.
Braces   +294 added lines, -141 removed lines patch added patch discarded remove patch
@@ -13,18 +13,23 @@  discard block
 block discarded – undo
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');
@@ -36,28 +41,38 @@  discard block
 block discarded – undo
36 41
 			/**
37 42
 			 * @var $object Facture
38 43
 			 */
39
-			if($object->element=='facture') $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);
44
+			if($object->element=='facture') {
45
+				$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);
46
+			}
40 47
 			/**
41 48
 			 * @var $object Facture fournisseur
42 49
 			 */
43 50
 			else if($object->element=='invoice_supplier') {
44 51
 			    $object->special_code = TSubtotal::$module_number;
45
-                if( (float)DOL_VERSION < 6 ) $rang = $object->line_max() + 1;
52
+                if( (float)DOL_VERSION < 6 ) {
53
+                	$rang = $object->line_max() + 1;
54
+                }
46 55
 			    $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
47 56
 			}
48 57
 			/**
49 58
 			 * @var $object Propal
50 59
 			 */
51
-			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);
60
+			else if($object->element=='propal') {
61
+				$res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
62
+			}
52 63
 			/**
53 64
 			 * @var $object Propal Fournisseur
54 65
 			 */
55
-			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);
66
+			else if($object->element=='supplier_proposal') {
67
+				$res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
68
+			}
56 69
 			
57 70
 			/**
58 71
 			 * @var $object Commande
59 72
 			 */
60
-			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);
73
+			else if($object->element=='commande') {
74
+				$res =  $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label);
75
+			}
61 76
 			/**
62 77
 			 * @var $object Commande fournisseur
63 78
 			 */
@@ -68,7 +83,9 @@  discard block
 block discarded – undo
68 83
 			/**
69 84
 			 * @var $object Facturerec
70 85
 			 */
71
-			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); 
86
+			else if($object->element=='facturerec') {
87
+				$res =  $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label);
88
+			}
72 89
 			
73 90
 		}
74 91
 	
@@ -90,8 +107,9 @@  discard block
 block discarded – undo
90 107
 			// Define output language
91 108
 			$outputlangs = $langs;
92 109
 			$newlang = GETPOST('lang_id', 'alpha');
93
-			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
94
-				$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
110
+			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
111
+							$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
112
+			}
95 113
 			if (! empty($newlang)) {
96 114
 				$outputlangs = new Translate("", $conf);
97 115
 				$outputlangs->setDefaultLang($newlang);
@@ -100,13 +118,18 @@  discard block
 block discarded – undo
100 118
 			$ret = $object->fetch($object->id); // Reload to get new records
101 119
 			if ((float) DOL_VERSION <= 3.6)
102 120
 			{
103
-				if ($object->element == 'propal') propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
104
-				elseif ($object->element == 'commande') commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
105
-				elseif ($object->element == 'facture') facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
106
-			}
107
-			else
121
+				if ($object->element == 'propal') {
122
+					propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
123
+				} elseif ($object->element == 'commande') {
124
+					commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
125
+				} elseif ($object->element == 'facture') {
126
+					facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
127
+				}
128
+			} else
108 129
 			{
109
-				if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
130
+				if ($object->element!= 'facturerec') {
131
+					$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
132
+				}
110 133
 			}
111 134
 		}
112 135
 	}
@@ -120,7 +143,9 @@  discard block
 block discarded – undo
120 143
 	 */
121 144
 	public static function updateRang(&$object, $rang_start, $move_to=1)
122 145
 	{
123
-		if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
146
+		if (!class_exists('GenericObject')) {
147
+			require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
148
+		}
124 149
 		
125 150
 		$row=new GenericObject($object->db);
126 151
 		$row->table_element_line = $object->table_element_line;
@@ -129,7 +154,9 @@  discard block
 block discarded – undo
129 154
 		
130 155
 		foreach ($object->lines as &$line)
131 156
 		{
132
-			if ($line->rang < $rang_start) continue;
157
+			if ($line->rang < $rang_start) {
158
+				continue;
159
+			}
133 160
 			
134 161
 			$row->updateRangOfLine($line->id, $line->rang+$move_to);
135 162
 		}
@@ -152,21 +179,28 @@  discard block
 block discarded – undo
152 179
 		foreach ($TTitle_reverse as $k => $title_line)
153 180
 		{
154 181
 			$title_niveau = self::getNiveau($title_line);
155
-			if ($title_niveau < $level_new_title) break;
182
+			if ($title_niveau < $level_new_title) {
183
+				break;
184
+			}
156 185
 			
157 186
 			$rang_to_add = self::titleHasTotalLine($object, $title_line, true, true);
158 187
 			
159 188
 			if (is_numeric($rang_to_add)) 
160 189
 			{
161
-				if ($rang_to_add != -1) self::updateRang($object, $rang_to_add);
190
+				if ($rang_to_add != -1) {
191
+					self::updateRang($object, $rang_to_add);
192
+				}
162 193
 				
163 194
 				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add);
164 195
 				
165 196
 				$object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas)
166 197
 				if ($rang_to_add != -1) 
167 198
 				{
168
-					if (method_exists($object, 'fetch_lines')) $object->fetch_lines();
169
-					else $object->fetch($object->id);
199
+					if (method_exists($object, 'fetch_lines')) {
200
+						$object->fetch_lines();
201
+					} else {
202
+						$object->fetch($object->id);
203
+					}
170 204
 				}
171 205
 			}
172 206
 		}
@@ -196,7 +230,9 @@  discard block
 block discarded – undo
196 230
 		
197 231
 		foreach ($TTitle as $k => $title_line)
198 232
 		{
199
-			if (self::titleHasTotalLine($object, $title_line)) unset($TTitle[$k]);
233
+			if (self::titleHasTotalLine($object, $title_line)) {
234
+				unset($TTitle[$k]);
235
+			}
200 236
 		}
201 237
 		
202 238
 		return $TTitle;
@@ -213,23 +249,41 @@  discard block
 block discarded – undo
213 249
 	 */
214 250
 	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false)
215 251
 	{
216
-		if (empty($object->lines) || !is_array($object->lines)) return false;
252
+		if (empty($object->lines) || !is_array($object->lines)) {
253
+			return false;
254
+		}
217 255
 		
218 256
 		$title_niveau = self::getNiveau($title_line);
219 257
 		foreach ($object->lines as &$line)
220 258
 		{
221
-			if ($line->rang <= $title_line->rang) continue;
222
-			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
223
-			if (!self::isSubtotal($line)) continue;
259
+			if ($line->rang <= $title_line->rang) {
260
+				continue;
261
+			}
262
+			if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) {
263
+				return false;
264
+			}
265
+			// 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
266
+			if (!self::isSubtotal($line)) {
267
+				continue;
268
+			}
224 269
 			
225 270
 			$subtotal_niveau = self::getNiveau($line);
226 271
 			
227 272
 			// Comparaison du niveau de la ligne de sous-total avec celui du titre
228
-			if ($subtotal_niveau == $title_niveau) return true; // niveau égale => Ok mon titre a un sous-total
229
-			elseif ($subtotal_niveau < $title_niveau) // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3)
273
+			if ($subtotal_niveau == $title_niveau) {
274
+				return true;
275
+			}
276
+			// niveau égale => Ok mon titre a un sous-total
277
+			elseif ($subtotal_niveau < $title_niveau) {
278
+				// niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3)
230 279
 			{
231
-				if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; // mode strict niveau pas égale donc faux
232
-				else return true; // mode libre => OK je considère que mon titre à un sous-total
280
+				if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false;
281
+			}
282
+			// mode strict niveau pas égale donc faux
283
+				else {
284
+					return true;
285
+				}
286
+				// mode libre => OK je considère que mon titre à un sous-total
233 287
 			}
234 288
 		}
235 289
 		
@@ -277,16 +331,19 @@  discard block
 block discarded – undo
277 331
 		
278 332
 		foreach ($object->lines as &$l)
279 333
 		{
280
-			if ($l->rang <= $line->rang) continue;
281
-			elseif (self::isSubtotal($l) && self::getNiveau($l) <= self::getNiveau($line)) break;
282
-			elseif ($breakOnTitle && self::isTitle($l) && self::getNiveau($l) <= self::getNiveau($line)) break;
334
+			if ($l->rang <= $line->rang) {
335
+				continue;
336
+			} elseif (self::isSubtotal($l) && self::getNiveau($l) <= self::getNiveau($line)) {
337
+				break;
338
+			} elseif ($breakOnTitle && self::isTitle($l) && self::getNiveau($l) <= self::getNiveau($line)) {
339
+				break;
340
+			}
283 341
 			
284 342
 			if (!empty($l->array_options['options_subtotal_nc']))
285 343
 			{
286 344
 				$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);
287 345
 				$TTot['total_options'] += $tabprice[0]; // total ht
288
-			}
289
-			else
346
+			} else
290 347
 			{
291 348
 				$TTot['total_pa_ht'] += $l->pa_ht * $l->qty;
292 349
 				$TTot['total_subprice'] += $l->subprice * $l->qty;
@@ -307,35 +364,51 @@  discard block
 block discarded – undo
307 364
 
308 365
 	public static function getOrderIdFromLineId(&$db, $fk_commandedet, $supplier = false)
309 366
 	{
310
-		if (empty($fk_commandedet)) return false;
367
+		if (empty($fk_commandedet)) {
368
+			return false;
369
+		}
311 370
 
312 371
 		$table = 'commandedet';
313
-		if ($supplier) $table = 'commande_fournisseurdet';
372
+		if ($supplier) {
373
+			$table = 'commande_fournisseurdet';
374
+		}
314 375
 
315 376
 		$sql = 'SELECT fk_commande FROM '.MAIN_DB_PREFIX.$table.' WHERE rowid = '.$fk_commandedet;
316 377
 		$resql = $db->query($sql);
317 378
 
318
-		if ($resql && ($row = $db->fetch_object($resql))) return $row->fk_commande;
319
-		else return false;
379
+		if ($resql && ($row = $db->fetch_object($resql))) {
380
+			return $row->fk_commande;
381
+		} else {
382
+			return false;
383
+		}
320 384
 	}
321 385
 	
322 386
 	public static function getLastLineOrderId(&$db, $fk_commande, $supplier = false)
323 387
 	{
324
-		if (empty($fk_commande)) return false;
388
+		if (empty($fk_commande)) {
389
+			return false;
390
+		}
325 391
 
326 392
         $table = 'commandedet';
327
-        if ($supplier) $table = 'commande_fournisseurdet';
393
+        if ($supplier) {
394
+        	$table = 'commande_fournisseurdet';
395
+        }
328 396
 
329 397
 		$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$table.' WHERE fk_commande = '.$fk_commande.' ORDER BY rang DESC LIMIT 1';
330 398
 		$resql = $db->query($sql);
331 399
 		
332
-		if ($resql && ($row = $db->fetch_object($resql))) return $row->rowid;
333
-		else return false;
400
+		if ($resql && ($row = $db->fetch_object($resql))) {
401
+			return $row->rowid;
402
+		} else {
403
+			return false;
404
+		}
334 405
 	}
335 406
 	
336 407
 	public static function getParentTitleOfLine(&$object, $i)
337 408
 	{
338
-		if ($i <= 0) return false;
409
+		if ($i <= 0) {
410
+			return false;
411
+		}
339 412
 		
340 413
 		$skip_title = 0;
341 414
 		// Je parcours les lignes précédentes
@@ -354,8 +427,7 @@  discard block
 block discarded – undo
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 ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99)
430
+			} elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99)
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 			{
@@ -502,8 +585,9 @@  discard block
 block discarded – undo
502 585
 
503 586
 					$TLineAdded[] = $object->line;
504 587
 					// Error from addline
505
-					if ($res <= 0) break;
506
-					else
588
+					if ($res <= 0) {
589
+						break;
590
+					} else
507 591
 					{
508 592
 						$object->line_from = $line;
509 593
 						// Call trigger
@@ -525,8 +609,7 @@  discard block
 block discarded – undo
525 609
 					    _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']);
526 610
 					}
527 611
 					return count($TLineAdded);
528
-				}
529
-				else
612
+				} else
530 613
 				{
531 614
 					$object->db->rollback();
532 615
 					return -1;
@@ -542,10 +625,14 @@  discard block
 block discarded – undo
542 625
 		global $langs;
543 626
 		
544 627
 		// Besoin de comparer sur les 2 formes d'écriture
545
-		if (!$key_is_id) $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad));
628
+		if (!$key_is_id) {
629
+			$TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad));
630
+		}
546 631
 		
547 632
 		$TTitle_under_search = array();
548
-		if (!empty($under_title)) $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title));
633
+		if (!empty($under_title)) {
634
+			$TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title));
635
+		}
549 636
 		
550 637
 		$TLine = array();
551 638
 		$add_line = false;
@@ -555,28 +642,37 @@  discard block
 block discarded – undo
555 642
 		{
556 643
 			if (!$under_title_found && !empty($TTitle_under_search))
557 644
 			{
558
-				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true;
559
-			}
560
-			else
645
+				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) {
646
+					$under_title_found = true;
647
+				}
648
+			} else
561 649
 			{
562 650
 				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) )))
563 651
 				{
564
-					if ($key_is_id) $level = $line->qty;
652
+					if ($key_is_id) {
653
+						$level = $line->qty;
654
+					}
565 655
 					
566 656
 					$add_line = true;
567
-					if ($withBlockLine) $TLine[] = $line;
657
+					if ($withBlockLine) {
658
+						$TLine[] = $line;
659
+					}
568 660
 					continue;
569
-				}
570
-				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
661
+				} elseif ($add_line && TSubtotal::isModSubtotalLine($line) && TSubtotal::getNiveau($line) == $level) {
662
+					// Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre
571 663
 				{
572 664
 					if ($withBlockLine) $TLine[] = $line;
665
+				}
573 666
 					break;
574 667
 				}
575 668
 				
576 669
 				if ($add_line)
577 670
 				{
578
-					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue;
579
-					else $TLine[] = $line;
671
+					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) {
672
+						continue;
673
+					} else {
674
+						$TLine[] = $line;
675
+					}
580 676
 				}
581 677
 			}
582 678
 		}
@@ -610,7 +706,9 @@  discard block
 block discarded – undo
610 706
 				
611 707
 			case 'order_supplier':
612 708
 			    $object->special_code = SELF::$module_number;
613
-			    if (empty($desc)) $desc = $label;
709
+			    if (empty($desc)) {
710
+			    	$desc = $label;
711
+			    }
614 712
 			    $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);
615 713
 			    break;
616 714
 			
@@ -620,7 +718,9 @@  discard block
 block discarded – undo
620 718
 				
621 719
 			case 'invoice_supplier':
622 720
 			    $object->special_code = SELF::$module_number;
623
-			    if (empty($desc)) $desc = $label;
721
+			    if (empty($desc)) {
722
+			    	$desc = $label;
723
+			    }
624 724
 			    $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);
625 725
 			    break;
626 726
 				
@@ -637,8 +737,11 @@  discard block
 block discarded – undo
637 737
 				break;
638 738
 		}
639 739
 		
640
-		if ($res <= 0) $object->db->rollback();
641
-		else $object->db->commit();
740
+		if ($res <= 0) {
741
+			$object->db->rollback();
742
+		} else {
743
+			$object->db->commit();
744
+		}
642 745
 		
643 746
 		return $res;
644 747
 	}
@@ -648,24 +751,20 @@  discard block
 block discarded – undo
648 751
 		global $db, $object;
649 752
 		
650 753
 		$TTitle = array();
651
-		if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {}
652
-		else {
754
+		if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} else {
653 755
 			if ($origin_line->element == 'propaldet')
654 756
 			{
655 757
 				$object = new Propal($db);
656 758
 				$object->fetch($origin_line->fk_propal);
657
-			}
658
-			else if ($origin_line->element == 'commandedet')
759
+			} else if ($origin_line->element == 'commandedet')
659 760
 			{
660 761
 				$object = new Commande($db);
661 762
 				$object->fetch($origin_line->fk_commande);
662
-			}
663
-			else if ($origin_line->element == 'facturedet')
763
+			} else if ($origin_line->element == 'facturedet')
664 764
 			{
665 765
 				$object = new Facture($db);
666 766
 				$object->fetch($origin_line->fk_facture);
667
-			}
668
-			else
767
+			} else
669 768
 			{
670 769
 				return $TTitle;
671 770
 			}
@@ -675,8 +774,11 @@  discard block
 block discarded – undo
675 774
 		$i = 0;
676 775
 		foreach ($object->lines as &$line)
677 776
 		{
678
-			if ($origin_line->id == $line->id) break;
679
-			else $i++;
777
+			if ($origin_line->id == $line->id) {
778
+				break;
779
+			} else {
780
+				$i++;
781
+			}
680 782
 		}
681 783
 		
682 784
 		$i--; // Skip la ligne d'origine
@@ -691,35 +793,43 @@  discard block
 block discarded – undo
691 793
 				if (self::isSubtotal($object->lines[$y]))
692 794
 				{
693 795
 					$next_title_lvl_to_skip = self::getNiveau($object->lines[$y]);
694
-				}
695
-				elseif (self::isTitle($object->lines[$y]))
796
+				} elseif (self::isTitle($object->lines[$y]))
696 797
 				{
697 798
 					if ($object->lines[$y]->qty == $next_title_lvl_to_skip)
698 799
 					{
699 800
 						$next_title_lvl_to_skip = 0;
700 801
 						continue;
701
-					}
702
-					else
802
+					} else
703 803
 					{
704
-						if (empty($object->lines[$y]->array_options)) $object->lines[$y]->fetch_optionals();
804
+						if (empty($object->lines[$y]->array_options)) {
805
+							$object->lines[$y]->fetch_optionals();
806
+						}
705 807
 						$TTitle[$object->lines[$y]->id] = $object->lines[$y];
706 808
 						
707
-						if ($object->lines[$y]->qty == 1) break;
809
+						if ($object->lines[$y]->qty == 1) {
810
+							break;
811
+						}
708 812
 					}
709 813
 				}
710 814
 			}
711 815
 		}
712 816
 		
713
-		if ($reverse) $TTitle = array_reverse($TTitle, true);
817
+		if ($reverse) {
818
+			$TTitle = array_reverse($TTitle, true);
819
+		}
714 820
 		
715 821
 		return $TTitle;
716 822
 	}
717 823
 	
718 824
 	public static function getNiveau(&$line)
719 825
 	{
720
-		if (self::isTitle($line)) return $line->qty;
721
-		elseif (self::isSubtotal($line)) return 100 - $line->qty;
722
-		else return 0;
826
+		if (self::isTitle($line)) {
827
+			return $line->qty;
828
+		} elseif (self::isSubtotal($line)) {
829
+			return 100 - $line->qty;
830
+		} else {
831
+			return 0;
832
+		}
723 833
 	}
724 834
 	
725 835
 	/**
@@ -744,10 +854,16 @@  discard block
 block discarded – undo
744 854
 		$objmarge->marge_droite = 10;
745 855
 		
746 856
 		$objectref = dol_sanitizeFileName($object->ref);
747
-		if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref;
748
-		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref;
749
-		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref;
750
-		elseif ($object->element == 'facturerec') return; // no PDF for facturerec
857
+		if ($object->element == 'propal') {
858
+			$dir = $conf->propal->dir_output . '/' . $objectref;
859
+		} elseif ($object->element == 'commande') {
860
+			$dir = $conf->commande->dir_output . '/' . $objectref;
861
+		} elseif ($object->element == 'facture') {
862
+			$dir = $conf->facture->dir_output . '/' . $objectref;
863
+		} elseif ($object->element == 'facturerec') {
864
+			return;
865
+		}
866
+		// no PDF for facturerec
751 867
 		else
752 868
 		{
753 869
 			setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings');
@@ -782,7 +898,9 @@  discard block
 block discarded – undo
782 898
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
783 899
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
784 900
 		$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
785
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
901
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
902
+			$pdf->SetCompression(false);
903
+		}
786 904
 
787 905
 		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite);   // Left, Top, Right
788 906
 
@@ -792,7 +910,9 @@  discard block
 block discarded – undo
792 910
 			
793 911
 		// New page
794 912
 		$pdf->AddPage();
795
-		if (! empty($tplidx)) $pdf->useTemplate($tplidx);
913
+		if (! empty($tplidx)) {
914
+			$pdf->useTemplate($tplidx);
915
+		}
796 916
 		$pagenb++;
797 917
 		
798 918
 		
@@ -848,8 +968,10 @@  discard block
 block discarded – undo
848 968
 					{
849 969
 						$TTot['TTotal_tva_multicurrency'][$tx] += $amount;
850 970
 					}	
971
+				} else {
972
+					$pdf->SetFont('','', $default_font_size - 1);
851 973
 				}
852
-				else $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
974
+				// Into loop to work with multipage
853 975
 				
854 976
 				$pdf->SetTextColor(0,0,0);
855 977
 				
@@ -871,9 +993,11 @@  discard block
 block discarded – undo
871 993
 				$pdf->startTransaction();
872 994
 				$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
873 995
 				$pageposafter=$pdf->getPage();
874
-				if ($pageposafter > $pageposbefore)	// There is a pagebreak
996
+				if ($pageposafter > $pageposbefore) {
997
+					// There is a pagebreak
875 998
 				{
876 999
 					$pdf->rollbackTransaction(true);
1000
+				}
877 1001
 					$pageposafter=$pageposbefore;
878 1002
 					//print $pageposafter.'-'.$pageposbefore;exit;
879 1003
 					$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -882,23 +1006,27 @@  discard block
 block discarded – undo
882 1006
 					$pageposafter=$pdf->getPage();
883 1007
 					$posyafter=$pdf->GetY();
884 1008
 					//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
885
-					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot)))	// There is no space left for total+free text
1009
+					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) {
1010
+						// There is no space left for total+free text
886 1011
 					{
887 1012
 						if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
888 1013
 						{
889 1014
 							$pdf->AddPage('','',true);
890
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
891
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1015
+					}
1016
+							if (! empty($tplidx)) {
1017
+								$pdf->useTemplate($tplidx);
1018
+							}
1019
+							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
1020
+								self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1021
+							}
892 1022
 							$pdf->setPage($pageposafter+1);
893 1023
 						}
894
-					}
895
-					else
1024
+					} else
896 1025
 					{
897 1026
 						// We found a page break
898 1027
 						$showpricebeforepagebreak=0;
899 1028
 					}
900
-				}
901
-				else	// No pagebreak
1029
+				} else	// No pagebreak
902 1030
 				{
903 1031
 					$pdf->commitTransaction();
904 1032
 				}
@@ -938,8 +1066,7 @@  discard block
 block discarded – undo
938 1066
 					if ($pagenb == 1)
939 1067
 					{
940 1068
 						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);
941
-					}
942
-					else
1069
+					} else
943 1070
 					{
944 1071
 						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);
945 1072
 					}
@@ -947,7 +1074,9 @@  discard block
 block discarded – undo
947 1074
 					$pagenb++;
948 1075
 					$pdf->setPage($pagenb);
949 1076
 					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
950
-					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1077
+					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
1078
+						self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1079
+					}
951 1080
 				}
952 1081
 			}
953 1082
 		}
@@ -957,8 +1086,7 @@  discard block
 block discarded – undo
957 1086
 		{
958 1087
 			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);
959 1088
 			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
960
-		}
961
-		else
1089
+		} else
962 1090
 		{
963 1091
 			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);
964 1092
 			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
@@ -972,7 +1100,9 @@  discard block
 block discarded – undo
972 1100
 		
973 1101
 		$pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file);
974 1102
 		
975
-		if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) unlink($file);
1103
+		if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) {
1104
+			unlink($file);
1105
+		}
976 1106
 	}
977 1107
 	
978 1108
 	private static function printLevel($objmarge, $pdf, $line, $curY, $posx_designation)
@@ -1015,8 +1145,7 @@  discard block
 block discarded – undo
1015 1145
 			{
1016 1146
 			    $height=pdf_getHeightForLogo($logo);
1017 1147
 			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1018
-			}
1019
-			else
1148
+			} else
1020 1149
 			{
1021 1150
 				$pdf->SetTextColor(200,0,0);
1022 1151
 				$pdf->SetFont('','B',$default_font_size - 2);
@@ -1025,8 +1154,7 @@  discard block
 block discarded – undo
1025 1154
 			}
1026 1155
 			
1027 1156
 			$posy+=35;
1028
-		}
1029
-		else
1157
+		} else
1030 1158
 		{
1031 1159
 			$text=$mysoc->name;
1032 1160
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1040,9 +1168,13 @@  discard block
 block discarded – undo
1040 1168
 		$pdf->SetXY($objmarge->marge_gauche,$posy);
1041 1169
 		
1042 1170
 		$key = 'subtotalPropalTitle';
1043
-		if ($object->element == 'commande') $key = 'subtotalCommandeTitle';
1044
-		elseif ($object->element == 'facture') $key = 'subtotalInvoiceTitle';
1045
-		elseif ($object->element == 'facturerec') $key = 'subtotalInvoiceTitle';
1171
+		if ($object->element == 'commande') {
1172
+			$key = 'subtotalCommandeTitle';
1173
+		} elseif ($object->element == 'facture') {
1174
+			$key = 'subtotalInvoiceTitle';
1175
+		} elseif ($object->element == 'facturerec') {
1176
+			$key = 'subtotalInvoiceTitle';
1177
+		}
1046 1178
 		
1047 1179
 		$pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L');
1048 1180
 		
@@ -1077,7 +1209,9 @@  discard block
 block discarded – undo
1077 1209
 		
1078 1210
 		// Force to disable hidetop and hidebottom
1079 1211
 		$hidebottom=0;
1080
-		if ($hidetop) $hidetop=-1;
1212
+		if ($hidetop) {
1213
+			$hidetop=-1;
1214
+		}
1081 1215
 
1082 1216
 		$currency = !empty($currency) ? $currency : $conf->currency;
1083 1217
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1092,7 +1226,9 @@  discard block
 block discarded – undo
1092 1226
 			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5);
1093 1227
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1094 1228
 			
1095
-			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));
1229
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1230
+				$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
+			}
1096 1232
 			
1097 1233
 			
1098 1234
 			$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
@@ -1105,8 +1241,7 @@  discard block
 block discarded – undo
1105 1241
 			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R');
1106 1242
 			
1107 1243
 			$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
1108
-		}
1109
-		else
1244
+		} else
1110 1245
 		{
1111 1246
 			$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
1112 1247
 		}
@@ -1127,10 +1262,12 @@  discard block
 block discarded – undo
1127 1262
 
1128 1263
 		// Tableau total
1129 1264
 		$col1x = 120; $col2x = 170;
1130
-		if ($objmarge->page_largeur < 210) // To work with US executive format
1265
+		if ($objmarge->page_largeur < 210) {
1266
+			// To work with US executive format
1131 1267
 		{
1132 1268
 			$col2x-=20;
1133 1269
 		}
1270
+		}
1134 1271
 		$largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x);
1135 1272
 
1136 1273
 		$useborder=0;
@@ -1152,9 +1289,11 @@  discard block
 block discarded – undo
1152 1289
 		$atleastoneratenotnull=0;
1153 1290
 		foreach($TTot['TTotal_tva'] as $tvakey => $tvaval)
1154 1291
 		{
1155
-			if ($tvakey != 0)    // On affiche pas taux 0
1292
+			if ($tvakey != 0) {
1293
+				// On affiche pas taux 0
1156 1294
 			{
1157 1295
 				$atleastoneratenotnull++;
1296
+			}
1158 1297
 
1159 1298
 				$index++;
1160 1299
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1207,9 +1346,13 @@  discard block
 block discarded – undo
1207 1346
 	 */
1208 1347
     private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1209 1348
     {
1210
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1349
+	    if (empty($hidetop) || $hidetop==-1) {
1350
+	    	$pdf->line($x, $y, $x+$l, $y);
1351
+	    }
1211 1352
 	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1212
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1353
+	    if (empty($hidebottom)) {
1354
+	    	$pdf->line($x+$l, $y+$h, $x, $y+$h);
1355
+	    }
1213 1356
 	    $pdf->line($x, $y+$h, $x, $y);
1214 1357
     }
1215 1358
 	
@@ -1218,7 +1361,9 @@  discard block
 block discarded – undo
1218 1361
 	{
1219 1362
 		global $conf;
1220 1363
 		
1221
-		if (empty($fileoutput)) $fileoutput = $file[0];
1364
+		if (empty($fileoutput)) {
1365
+			$fileoutput = $file[0];
1366
+		}
1222 1367
 		
1223 1368
 		$pdf=pdf_getInstance();
1224 1369
         if (class_exists('TCPDF'))
@@ -1228,7 +1373,9 @@  discard block
 block discarded – undo
1228 1373
         }
1229 1374
         $pdf->SetFont(pdf_getPDFFont($outputlangs));
1230 1375
 
1231
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1376
+        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
1377
+        	$pdf->SetCompression(false);
1378
+        }
1232 1379
 
1233 1380
 		
1234 1381
 		foreach($files as $file)
@@ -1244,7 +1391,9 @@  discard block
 block discarded – undo
1244 1391
 		}
1245 1392
 		
1246 1393
 		$pdf->Output($fileoutput,'F');
1247
-		if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1394
+		if (! empty($conf->global->MAIN_UMASK)) {
1395
+			@chmod($file, octdec($conf->global->MAIN_UMASK));
1396
+		}
1248 1397
 
1249 1398
 		return $pagecount;
1250 1399
 	}
@@ -1257,7 +1406,9 @@  discard block
 block discarded – undo
1257 1406
 	 */
1258 1407
 	public static function hasNcTitle(&$line)
1259 1408
 	{
1260
-		if(isset($line->has_nc_title)) return $line->has_nc_title;
1409
+		if(isset($line->has_nc_title)) {
1410
+			return $line->has_nc_title;
1411
+		}
1261 1412
 
1262 1413
 		$TTitle = self::getAllTitleFromLine($line);
1263 1414
 		foreach ($TTitle as &$line_title)
@@ -1282,7 +1433,9 @@  discard block
 block discarded – undo
1282 1433
 	public static function getTitleLabel($line)
1283 1434
 	{
1284 1435
 		$title = $line->label;
1285
-		if (empty($title)) $title = !empty($line->description) ? $line->description : $line->desc;
1436
+		if (empty($title)) {
1437
+			$title = !empty($line->description) ? $line->description : $line->desc;
1438
+		}
1286 1439
 		return $title;
1287 1440
 	}
1288 1441
 }
Please login to merge, or discard this patch.