Passed
Pull Request — master (#144)
by
unknown
03:07
created
core/modules/facture/doc/pdf_crabe_subtotal.modules.php 3 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
  */
39 39
 class pdf_crabe_subtotal extends ModelePDFFactures
40 40
 {
41
-    var $db;
42
-    var $name;
43
-    var $description;
44
-    var $type;
41
+	var $db;
42
+	var $name;
43
+	var $description;
44
+	var $type;
45 45
 
46
-    var $phpmin = array(4,3,0); // Minimum version of PHP required by module
47
-    var $version = 'dolibarr';
46
+	var $phpmin = array(4,3,0); // Minimum version of PHP required by module
47
+	var $version = 'dolibarr';
48 48
 
49
-    var $page_largeur;
50
-    var $page_hauteur;
51
-    var $format;
49
+	var $page_largeur;
50
+	var $page_hauteur;
51
+	var $format;
52 52
 	var $marge_gauche;
53 53
 	var	$marge_droite;
54 54
 	var	$marge_haute;
@@ -130,15 +130,15 @@  discard block
 block discarded – undo
130 130
 
131 131
 
132 132
 	/**
133
-     *  Function to build pdf onto disk
134
-     *
135
-     *  @param		Object		$object				Object to generate
136
-     *  @param		Translate	$outputlangs		Lang output object
137
-     *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
138
-     *  @param		int			$hidedetails		Do not show line details
139
-     *  @param		int			$hidedesc			Do not show desc
140
-     *  @param		int			$hideref			Do not show ref
141
-     *  @return     int         	    			1=OK, 0=KO
133
+	 *  Function to build pdf onto disk
134
+	 *
135
+	 *  @param		Object		$object				Object to generate
136
+	 *  @param		Translate	$outputlangs		Lang output object
137
+	 *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
138
+	 *  @param		int			$hidedetails		Do not show line details
139
+	 *  @param		int			$hidedesc			Do not show desc
140
+	 *  @param		int			$hideref			Do not show ref
141
+	 *  @return     int         	    			1=OK, 0=KO
142 142
 	 */
143 143
 	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
144 144
 	{
@@ -230,25 +230,25 @@  discard block
 block discarded – undo
230 230
 
231 231
 				// Create pdf instance
232 232
 				$pdf=pdf_getInstance($this->format);
233
-                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
233
+				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
234 234
 				$heightforinfotot = 50;	// Height reserved to output the info and total part
235
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
236
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
237
-                $pdf->SetAutoPageBreak(1,0);
238
-
239
-                if (class_exists('TCPDF'))
240
-                {
241
-                    $pdf->setPrintHeader(false);
242
-                    $pdf->setPrintFooter(false);
243
-                }
244
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
245
-
246
-                // Set path to the background PDF File
247
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
248
-                {
249
-				    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
250
-				    $tplidx = $pdf->importPage(1);
251
-                }
235
+				$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
236
+				$heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
237
+				$pdf->SetAutoPageBreak(1,0);
238
+
239
+				if (class_exists('TCPDF'))
240
+				{
241
+					$pdf->setPrintHeader(false);
242
+					$pdf->setPrintFooter(false);
243
+				}
244
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
245
+
246
+				// Set path to the background PDF File
247
+				if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
248
+				{
249
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
250
+					$tplidx = $pdf->importPage(1);
251
+				}
252 252
 
253 253
 				$pdf->Open();
254 254
 				$pagenb=0;
@@ -538,8 +538,8 @@  discard block
 block discarded – undo
538 538
 					// Discount on line
539 539
 					if ($object->lines[$i]->remise_percent)
540 540
 					{
541
-                        $pdf->SetXY($this->posxdiscount-2, $curY);
542
-					    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
541
+						$pdf->SetXY($this->posxdiscount-2, $curY);
542
+						$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
543 543
 						$pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
544 544
 					}
545 545
 
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 						$localtax2_type = $localtaxtmp_array[2];
578 578
 					}
579 579
 
580
-				    // retrieve global local tax
580
+					// retrieve global local tax
581 581
 					if ($localtax1_type && $localtax1ligne != 0)
582 582
 						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
583 583
 					if ($localtax2_type && $localtax2ligne != 0)
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 					}
596 596
 					else {
597 597
 						// standard
598
-                        if(!empty($tvaligne)) $this->tva[$vatrate] += $tvaligne;
598
+						if(!empty($tvaligne)) $this->tva[$vatrate] += $tvaligne;
599 599
 					}
600 600
 
601 601
 					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
@@ -713,20 +713,20 @@  discard block
 block discarded – undo
713 713
 	/**
714 714
 	 *  Show payments table
715 715
 	 *
716
-     *  @param	PDF			$pdf           Object PDF
717
-     *  @param  Object		$object         Object invoice
718
-     *  @param  int			$posy           Position y in PDF
719
-     *  @param  Translate	$outputlangs    Object langs for output
720
-     *  @return int             			<0 if KO, >0 if OK
716
+	 *  @param	PDF			$pdf           Object PDF
717
+	 *  @param  Object		$object         Object invoice
718
+	 *  @param  int			$posy           Position y in PDF
719
+	 *  @param  Translate	$outputlangs    Object langs for output
720
+	 *  @return int             			<0 if KO, >0 if OK
721 721
 	 */
722 722
 	function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
723 723
 	{
724 724
 		global $conf;
725 725
 
726
-        $sign=1;
727
-        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
726
+		$sign=1;
727
+		if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
728 728
 
729
-        $tab3_posx = 120;
729
+		$tab3_posx = 120;
730 730
 		$tab3_top = $posy + 8;
731 731
 		$tab3_width = 80;
732 732
 		$tab3_height = 4;
@@ -953,13 +953,13 @@  discard block
 block discarded – undo
953 953
 						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
954 954
 						$posy=$pdf->GetY()+1;
955 955
 
956
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
957
-			            {
956
+						if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
957
+						{
958 958
 							$pdf->SetXY($this->marge_gauche, $posy);
959 959
 							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
960 960
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
961 961
 							$posy=$pdf->GetY()+2;
962
-			            }
962
+						}
963 963
 					}
964 964
 					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
965 965
 					{
@@ -968,13 +968,13 @@  discard block
 block discarded – undo
968 968
 						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
969 969
 						$posy=$pdf->GetY()+1;
970 970
 
971
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
972
-			            {
971
+						if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
972
+						{
973 973
 							$pdf->SetXY($this->marge_gauche, $posy);
974 974
 							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
975 975
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
976 976
 							$posy=$pdf->GetY()+2;
977
-			            }
977
+						}
978 978
 					}
979 979
 				}
980 980
 			}
@@ -1016,10 +1016,10 @@  discard block
 block discarded – undo
1016 1016
 	{
1017 1017
 		global $conf,$mysoc;
1018 1018
 
1019
-        $sign=1;
1020
-        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
1019
+		$sign=1;
1020
+		if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
1021 1021
 
1022
-        $default_font_size = pdf_getPDFFontSize($outputlangs);
1022
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
1023 1023
 
1024 1024
 		$tab2_top = $posy;
1025 1025
 		$tab2_hl = 4;
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
 							}
1089 1089
 						}
1090 1090
 					}
1091
-	      		//}
1091
+		  		//}
1092 1092
 				//Local tax 2 before VAT
1093 1093
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1094 1094
 				//{
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
 							}
1181 1181
 						}
1182 1182
 					}
1183
-	      		//}
1183
+		  		//}
1184 1184
 				//Local tax 2 after VAT
1185 1185
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1186 1186
 				//{
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 
1191 1191
 						foreach( $localtax_rate as $tvakey => $tvaval )
1192 1192
 						{
1193
-						    // retrieve global local tax
1193
+							// retrieve global local tax
1194 1194
 							if ($tvakey != 0)    // On affiche pas taux 0
1195 1195
 							{
1196 1196
 								//$this->atleastoneratenotnull++;
@@ -1424,15 +1424,15 @@  discard block
 block discarded – undo
1424 1424
 
1425 1425
 		// Show Draft Watermark
1426 1426
 		if($object->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) )
1427
-        {
1428
-		      pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FACTURE_DRAFT_WATERMARK);
1429
-        }
1427
+		{
1428
+			  pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FACTURE_DRAFT_WATERMARK);
1429
+		}
1430 1430
 
1431 1431
 		$pdf->SetTextColor(0,0,60);
1432 1432
 		$pdf->SetFont('','B', $default_font_size + 3);
1433 1433
 
1434 1434
 		$posy=$this->marge_haute;
1435
-        $posx=$this->page_largeur-$this->marge_droite-100;
1435
+		$posx=$this->page_largeur-$this->marge_droite-100;
1436 1436
 
1437 1437
 		$pdf->SetXY($this->marge_gauche,$posy);
1438 1438
 
@@ -1442,7 +1442,7 @@  discard block
 block discarded – undo
1442 1442
 		{
1443 1443
 			if (is_readable($logo))
1444 1444
 			{
1445
-			    $height=pdf_getHeightForLogo($logo);
1445
+				$height=pdf_getHeightForLogo($logo);
1446 1446
 				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1447 1447
 			}
1448 1448
 			else
@@ -1633,7 +1633,7 @@  discard block
 block discarded – undo
1633 1633
 
1634 1634
 	/**
1635 1635
 	 *   	Show footer of page. Need this->emetteur object
1636
-     *
1636
+	 *
1637 1637
 	 *   	@param	PDF			$pdf     			PDF
1638 1638
 	 * 		@param	Object		$object				Object to show
1639 1639
 	 *      @param	Translate	$outputlangs		Object lang for output
Please login to merge, or discard this patch.
Spacing   +482 added lines, -482 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     var $description;
44 44
     var $type;
45 45
 
46
-    var $phpmin = array(4,3,0); // Minimum version of PHP required by module
46
+    var $phpmin = array(4, 3, 0); // Minimum version of PHP required by module
47 47
     var $version = 'dolibarr';
48 48
 
49 49
     var $page_largeur;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	var	$marge_haute;
55 55
 	var	$marge_basse;
56 56
 
57
-	var $emetteur;	// Objet societe qui emet
57
+	var $emetteur; // Objet societe qui emet
58 58
 
59 59
 
60 60
 	/**
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	function __construct($db)
66 66
 	{
67
-		global $conf,$langs,$mysoc;
67
+		global $conf, $langs, $mysoc;
68 68
 
69 69
 		$langs->load("main");
70 70
 		$langs->load("bills");
@@ -76,56 +76,56 @@  discard block
 block discarded – undo
76 76
 
77 77
 		// Dimension page pour format A4
78 78
 		$this->type = 'pdf';
79
-		$formatarray=pdf_getFormat();
79
+		$formatarray = pdf_getFormat();
80 80
 		$this->page_largeur = $formatarray['width'];
81 81
 		$this->page_hauteur = $formatarray['height'];
82
-		$this->format = array($this->page_largeur,$this->page_hauteur);
83
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
84
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
85
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
86
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
87
-
88
-		$this->option_logo = 1;                    // Affiche logo
89
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
90
-		$this->option_modereg = 1;                 // Affiche mode reglement
91
-		$this->option_condreg = 1;                 // Affiche conditions reglement
92
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
93
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
94
-		$this->option_escompte = 1;                // Affiche si il y a eu escompte
95
-		$this->option_credit_note = 1;             // Support credit notes
96
-		$this->option_freetext = 1;				   // Support add of a personalised text
97
-		$this->option_draft_watermark = 1;		   // Support add of a watermark on drafts
98
-
99
-		$this->franchise=!$mysoc->tva_assuj;
82
+		$this->format = array($this->page_largeur, $this->page_hauteur);
83
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
84
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
85
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
86
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
87
+
88
+		$this->option_logo = 1; // Affiche logo
89
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
90
+		$this->option_modereg = 1; // Affiche mode reglement
91
+		$this->option_condreg = 1; // Affiche conditions reglement
92
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
93
+		$this->option_multilang = 1; // Dispo en plusieurs langues
94
+		$this->option_escompte = 1; // Affiche si il y a eu escompte
95
+		$this->option_credit_note = 1; // Support credit notes
96
+		$this->option_freetext = 1; // Support add of a personalised text
97
+		$this->option_draft_watermark = 1; // Support add of a watermark on drafts
98
+
99
+		$this->franchise = !$mysoc->tva_assuj;
100 100
 
101 101
 		// Get source company
102
-		$this->emetteur=$mysoc;
103
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
102
+		$this->emetteur = $mysoc;
103
+		if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
104 104
 
105 105
 		// Define position of columns
106
-		$this->posxdesc=$this->marge_gauche+1;
107
-		$this->posxtva=112;
108
-		$this->posxup=126;
109
-		$this->posxqty=145;
110
-		$this->posxdiscount=162;
111
-		$this->postotalht=174;
112
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
113
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
106
+		$this->posxdesc = $this->marge_gauche + 1;
107
+		$this->posxtva = 112;
108
+		$this->posxup = 126;
109
+		$this->posxqty = 145;
110
+		$this->posxdiscount = 162;
111
+		$this->postotalht = 174;
112
+		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva = $this->posxup;
113
+		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
114 114
 		if ($this->page_largeur < 210) // To work with US executive format
115 115
 		{
116
-			$this->posxpicture-=20;
117
-			$this->posxtva-=20;
118
-			$this->posxup-=20;
119
-			$this->posxqty-=20;
120
-			$this->posxdiscount-=20;
121
-			$this->postotalht-=20;
116
+			$this->posxpicture -= 20;
117
+			$this->posxtva -= 20;
118
+			$this->posxup -= 20;
119
+			$this->posxqty -= 20;
120
+			$this->posxdiscount -= 20;
121
+			$this->postotalht -= 20;
122 122
 		}
123 123
 
124
-		$this->tva=array();
125
-		$this->localtax1=array();
126
-		$this->localtax2=array();
127
-		$this->atleastoneratenotnull=0;
128
-		$this->atleastonediscount=0;
124
+		$this->tva = array();
125
+		$this->localtax1 = array();
126
+		$this->localtax2 = array();
127
+		$this->atleastoneratenotnull = 0;
128
+		$this->atleastonediscount = 0;
129 129
 	}
130 130
 
131 131
 
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
      *  @param		int			$hideref			Do not show ref
141 141
      *  @return     int         	    			1=OK, 0=KO
142 142
 	 */
143
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
143
+	function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
144 144
 	{
145
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
145
+		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
146 146
 
147
-		if (! is_object($outputlangs)) $outputlangs=$langs;
147
+		if (!is_object($outputlangs)) $outputlangs = $langs;
148 148
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
149
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
149
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
150 150
 
151 151
 		$outputlangs->load("main");
152 152
 		$outputlangs->load("dict");
@@ -157,37 +157,37 @@  discard block
 block discarded – undo
157 157
 		$nblignes = count($object->lines);
158 158
 
159 159
 		// Loop on each lines to detect if there is at least one image to show
160
-		$realpatharray=array();
161
-		if (! empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
160
+		$realpatharray = array();
161
+		if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
162 162
 		{
163
-			for ($i = 0 ; $i < $nblignes ; $i++)
163
+			for ($i = 0; $i < $nblignes; $i++)
164 164
 			{
165 165
 				if (empty($object->lines[$i]->fk_product)) continue;
166 166
 
167 167
 				$objphoto = new Product($this->db);
168 168
 				$objphoto->fetch($object->lines[$i]->fk_product);
169 169
 
170
-				$pdir = get_exdir($object->lines[$i]->fk_product,2) . $object->lines[$i]->fk_product ."/photos/";
170
+				$pdir = get_exdir($object->lines[$i]->fk_product, 2).$object->lines[$i]->fk_product."/photos/";
171 171
 				$dir = $conf->product->dir_output.'/'.$pdir;
172 172
 
173
-				$realpath='';
174
-				foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
173
+				$realpath = '';
174
+				foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
175 175
 				{
176
-					$filename=$obj['photo'];
176
+					$filename = $obj['photo'];
177 177
 					//if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
178 178
 					$realpath = $dir.$filename;
179 179
 					break;
180 180
 				}
181 181
 
182
-				if ($realpath) $realpatharray[$i]=$realpath;
182
+				if ($realpath) $realpatharray[$i] = $realpath;
183 183
 			}
184 184
 		}
185
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
185
+		if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
186 186
 
187 187
 		if ($conf->facture->dir_output)
188 188
 		{
189 189
 			$object->fetch_thirdparty();
190
-			if(!empty($object->client) ){
190
+			if (!empty($object->client)) {
191 191
 				$object->thirdparty = $object->client;
192 192
 			}
193 193
 			$deja_regle = $object->getSommePaiement();
@@ -198,19 +198,19 @@  discard block
 block discarded – undo
198 198
 			if ($object->specimen)
199 199
 			{
200 200
 				$dir = $conf->facture->dir_output;
201
-				$file = $dir . "/SPECIMEN.pdf";
201
+				$file = $dir."/SPECIMEN.pdf";
202 202
 			}
203 203
 			else
204 204
 			{
205 205
 				$objectref = dol_sanitizeFileName($object->ref);
206
-				$dir = $conf->facture->dir_output . "/" . $objectref;
207
-				$file = $dir . "/" . $objectref . ".pdf";
206
+				$dir = $conf->facture->dir_output."/".$objectref;
207
+				$file = $dir."/".$objectref.".pdf";
208 208
 			}
209
-			if (! file_exists($dir))
209
+			if (!file_exists($dir))
210 210
 			{
211 211
 				if (dol_mkdir($dir) < 0)
212 212
 				{
213
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
213
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
214 214
 					return 0;
215 215
 				}
216 216
 			}
@@ -218,23 +218,23 @@  discard block
 block discarded – undo
218 218
 			if (file_exists($dir))
219 219
 			{
220 220
 				// Add pdfgeneration hook
221
-				if (! is_object($hookmanager))
221
+				if (!is_object($hookmanager))
222 222
 				{
223 223
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
224
-					$hookmanager=new HookManager($this->db);
224
+					$hookmanager = new HookManager($this->db);
225 225
 				}
226 226
 				$hookmanager->initHooks(array('pdfgeneration'));
227
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
227
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
228 228
 				global $action;
229
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
229
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
230 230
 
231 231
 				// Create pdf instance
232
-				$pdf=pdf_getInstance($this->format);
233
-                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
234
-				$heightforinfotot = 50;	// Height reserved to output the info and total part
235
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
236
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
237
-                $pdf->SetAutoPageBreak(1,0);
232
+				$pdf = pdf_getInstance($this->format);
233
+                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
234
+				$heightforinfotot = 50; // Height reserved to output the info and total part
235
+		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
236
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
237
+                $pdf->SetAutoPageBreak(1, 0);
238 238
 
239 239
                 if (class_exists('TCPDF'))
240 240
                 {
@@ -244,27 +244,27 @@  discard block
 block discarded – undo
244 244
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
245 245
 
246 246
                 // Set path to the background PDF File
247
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
247
+                if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
248 248
                 {
249 249
 				    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
250 250
 				    $tplidx = $pdf->importPage(1);
251 251
                 }
252 252
 
253 253
 				$pdf->Open();
254
-				$pagenb=0;
255
-				$pdf->SetDrawColor(128,128,128);
254
+				$pagenb = 0;
255
+				$pdf->SetDrawColor(128, 128, 128);
256 256
 
257 257
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
258 258
 				$pdf->SetSubject($outputlangs->transnoentities("Invoice"));
259 259
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
260 260
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
261 261
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Invoice"));
262
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
262
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
263 263
 
264
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
264
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
265 265
 
266 266
 				// Positionne $this->atleastonediscount si on a au moins une remise
267
-				for ($i = 0 ; $i < $nblignes ; $i++)
267
+				for ($i = 0; $i < $nblignes; $i++)
268 268
 				{
269 269
 					if ($object->lines[$i]->remise_percent)
270 270
 					{
@@ -273,61 +273,61 @@  discard block
 block discarded – undo
273 273
 				}
274 274
 				if (empty($this->atleastonediscount))
275 275
 				{
276
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
277
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
278
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
279
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
280
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
276
+					$this->posxpicture += ($this->postotalht - $this->posxdiscount);
277
+					$this->posxtva += ($this->postotalht - $this->posxdiscount);
278
+					$this->posxup += ($this->postotalht - $this->posxdiscount);
279
+					$this->posxqty += ($this->postotalht - $this->posxdiscount);
280
+					$this->posxdiscount += ($this->postotalht - $this->posxdiscount);
281 281
 					//$this->postotalht;
282 282
 				}
283 283
 
284 284
 				// New page
285 285
 				$pdf->AddPage();
286
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
286
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
287 287
 				$pagenb++;
288 288
 
289 289
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
290
-				$pdf->SetFont('','', $default_font_size - 1);
291
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
292
-				$pdf->SetTextColor(0,0,0);
290
+				$pdf->SetFont('', '', $default_font_size - 1);
291
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
292
+				$pdf->SetTextColor(0, 0, 0);
293 293
 
294 294
 				$tab_top = 90;
295
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
295
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
296 296
 				$tab_height = 130;
297 297
 				$tab_height_newpage = 150;
298 298
 
299 299
 				// Affiche notes
300
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
301
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
300
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
301
+				if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
302 302
 				{
303 303
 					// Get first sale rep
304 304
 					if (is_object($object->thirdparty))
305 305
 					{
306
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
307
-						$salerepobj=new User($this->db);
306
+						$salereparray = $object->thirdparty->getSalesRepresentatives($user);
307
+						$salerepobj = new User($this->db);
308 308
 						$salerepobj->fetch($salereparray[0]['id']);
309
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
309
+						if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
310 310
 					}
311 311
 				}
312 312
 				if ($notetoshow)
313 313
 				{
314 314
 					$tab_top = 88;
315 315
 
316
-					$pdf->SetFont('','', $default_font_size - 1);
317
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
316
+					$pdf->SetFont('', '', $default_font_size - 1);
317
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
318 318
 					$nexY = $pdf->GetY();
319
-					$height_note=$nexY-$tab_top;
319
+					$height_note = $nexY - $tab_top;
320 320
 
321 321
 					// Rect prend une longueur en 3eme param
322
-					$pdf->SetDrawColor(192,192,192);
323
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
322
+					$pdf->SetDrawColor(192, 192, 192);
323
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
324 324
 
325 325
 					$tab_height = $tab_height - $height_note;
326
-					$tab_top = $nexY+6;
326
+					$tab_top = $nexY + 6;
327 327
 				}
328 328
 				else
329 329
 				{
330
-					$height_note=0;
330
+					$height_note = 0;
331 331
 				}
332 332
 
333 333
 				$iniY = $tab_top + 7;
@@ -404,91 +404,91 @@  discard block
 block discarded – undo
404 404
 					}
405 405
 					
406 406
 					$curY = $nexY;
407
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
408
-					$pdf->SetTextColor(0,0,0);
407
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
408
+					$pdf->SetTextColor(0, 0, 0);
409 409
 
410 410
 					// Define size of image if we need it
411
-					$imglinesize=array();
412
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
411
+					$imglinesize = array();
412
+					if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
413 413
 
414 414
 					$pdf->setTopMargin($tab_top_newpage);
415
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
416
-					$pageposbefore=$pdf->getPage();
415
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
416
+					$pageposbefore = $pdf->getPage();
417 417
 
418
-					$showpricebeforepagebreak=1;
419
-					$posYAfterImage=0;
420
-					$posYAfterDescription=0;
418
+					$showpricebeforepagebreak = 1;
419
+					$posYAfterImage = 0;
420
+					$posYAfterDescription = 0;
421 421
 
422 422
 					// We start with Photo of product line
423
-					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
423
+					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// If photo too high, we moved completely on new page
424 424
 					{
425
-						$pdf->AddPage('','',true);
426
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
425
+						$pdf->AddPage('', '', true);
426
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
427 427
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
428
-						$pdf->setPage($pageposbefore+1);
428
+						$pdf->setPage($pageposbefore + 1);
429 429
 
430 430
 						$curY = $tab_top_newpage;
431
-						$showpricebeforepagebreak=0;
431
+						$showpricebeforepagebreak = 0;
432 432
 					}
433 433
 
434 434
 					if (isset($imglinesize['width']) && isset($imglinesize['height']))
435 435
 					{
436
-						$curX = $this->posxpicture-1;
437
-						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
436
+						$curX = $this->posxpicture - 1;
437
+						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
438 438
 						// $pdf->Image does not increase value return by getY, so we save it manually
439
-						$posYAfterImage=$curY+$imglinesize['height'];
439
+						$posYAfterImage = $curY + $imglinesize['height'];
440 440
 					}
441 441
 
442 442
 					// Description of product line
443
-					$curX = $this->posxdesc-1;
443
+					$curX = $this->posxdesc - 1;
444 444
 
445 445
 					$pdf->startTransaction();
446
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
447
-					$pageposafter=$pdf->getPage();
446
+					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
447
+					$pageposafter = $pdf->getPage();
448 448
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
449 449
 					{
450 450
 						$pdf->rollbackTransaction(true);
451
-						$pageposafter=$pageposbefore;
451
+						$pageposafter = $pageposbefore;
452 452
 						//print $pageposafter.'-'.$pageposbefore;exit;
453
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
454
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
455
-						$pageposafter=$pdf->getPage();
456
-						$posyafter=$pdf->GetY();
453
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
454
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
455
+						$pageposafter = $pdf->getPage();
456
+						$posyafter = $pdf->GetY();
457 457
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
458
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
458
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
459 459
 						{
460
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
460
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
461 461
 							{
462
-								$pdf->AddPage('','',true);
463
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
462
+								$pdf->AddPage('', '', true);
463
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
464 464
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
465
-								$pdf->setPage($pageposafter+1);
465
+								$pdf->setPage($pageposafter + 1);
466 466
 							}
467 467
 						}
468 468
 						else
469 469
 						{
470 470
 							// We found a page break
471
-							$showpricebeforepagebreak=0;
471
+							$showpricebeforepagebreak = 0;
472 472
 						}
473 473
 					}
474 474
 					else	// No pagebreak
475 475
 					{
476 476
 						$pdf->commitTransaction();
477 477
 					}
478
-					$posYAfterDescription=$pdf->GetY();
478
+					$posYAfterDescription = $pdf->GetY();
479 479
 
480 480
 					$nexY = $pdf->GetY();
481
-					$pageposafter=$pdf->getPage();
481
+					$pageposafter = $pdf->getPage();
482 482
 					$pdf->setPage($pageposbefore);
483 483
 					$pdf->setTopMargin($this->marge_haute);
484
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
484
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
485 485
 
486 486
 					// We suppose that a too long description or photo were moved completely on next page
487 487
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
488 488
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
489 489
 					}
490 490
 
491
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
491
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
492 492
 
493 493
 					// VAT Rate
494 494
 					if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 						}
502 502
 						
503 503
 						$pdf->SetXY($this->posxtva, $curY);
504
-						$pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R');
504
+						$pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 3, $vat_rate, 0, 'R');
505 505
 					}
506 506
 
507 507
 					// Unit price before discount
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 					}
513 513
 					
514 514
 					$pdf->SetXY($this->posxup, $curY);
515
-					$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
515
+					$pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0);
516 516
 
517 517
 					// Quantity
518 518
 					// Affichage de la quantité sur les lignes de total si la conf l'indique
@@ -533,14 +533,14 @@  discard block
 block discarded – undo
533 533
 					}
534 534
 					
535 535
 					$pdf->SetXY($this->posxqty, $curY);
536
-					$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R');	// Enough for 6 chars
536
+					$pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 3, $qty, 0, 'R'); // Enough for 6 chars
537 537
 
538 538
 					// Discount on line
539 539
 					if ($object->lines[$i]->remise_percent)
540 540
 					{
541
-                        $pdf->SetXY($this->posxdiscount-2, $curY);
541
+                        $pdf->SetXY($this->posxdiscount - 2, $curY);
542 542
 					    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
543
-						$pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
543
+						$pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
544 544
 					}
545 545
 
546 546
 					// Total HT line
@@ -551,40 +551,40 @@  discard block
 block discarded – undo
551 551
 					}
552 552
 					
553 553
 					$pdf->SetXY($this->postotalht, $curY);
554
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
554
+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
555 555
 
556 556
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
557
-					$tvaligne=$object->lines[$i]->total_tva;
558
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
559
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
560
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
561
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
562
-					$localtax1_type=$object->lines[$i]->localtax1_type;
563
-					$localtax2_type=$object->lines[$i]->localtax2_type;
557
+					$tvaligne = $object->lines[$i]->total_tva;
558
+					$localtax1ligne = $object->lines[$i]->total_localtax1;
559
+					$localtax2ligne = $object->lines[$i]->total_localtax2;
560
+					$localtax1_rate = $object->lines[$i]->localtax1_tx;
561
+					$localtax2_rate = $object->lines[$i]->localtax2_tx;
562
+					$localtax1_type = $object->lines[$i]->localtax1_type;
563
+					$localtax2_type = $object->lines[$i]->localtax2_type;
564 564
 
565
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
566
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
567
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
565
+					if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
566
+					if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
567
+					if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
568 568
 
569
-					$vatrate=(string) $object->lines[$i]->tva_tx;
569
+					$vatrate = (string) $object->lines[$i]->tva_tx;
570 570
 
571 571
 					// Retrieve type from database for backward compatibility with old records
572
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
573
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
572
+					if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
573
+					&& (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
574 574
 					{
575
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0, $object->thirdparty, $mysoc);
575
+						$localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
576 576
 						$localtax1_type = $localtaxtmp_array[0];
577 577
 						$localtax2_type = $localtaxtmp_array[2];
578 578
 					}
579 579
 
580 580
 				    // retrieve global local tax
581 581
 					if ($localtax1_type && $localtax1ligne != 0)
582
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
582
+						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
583 583
 					if ($localtax2_type && $localtax2ligne != 0)
584
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
584
+						$this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
585 585
 
586
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
587
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]='';
586
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
587
+					if (!isset($this->tva[$vatrate])) 				$this->tva[$vatrate] = '';
588 588
 
589 589
 					if (!empty($object->lines[$i]->TTotal_tva))
590 590
 					{
@@ -595,22 +595,22 @@  discard block
 block discarded – undo
595 595
 					}
596 596
 					else {
597 597
 						// standard
598
-                        if(!empty($tvaligne)) $this->tva[$vatrate] += $tvaligne;
598
+                        if (!empty($tvaligne)) $this->tva[$vatrate] += $tvaligne;
599 599
 					}
600 600
 
601
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
601
+					if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
602 602
 
603 603
 					// Add line
604
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
604
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
605 605
 					{
606 606
 						$pdf->setPage($pageposafter);
607
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
607
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(210, 210, 210)));
608 608
 						//$pdf->SetDrawColor(190,190,200);
609
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
609
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
610 610
 						$pdf->SetLineStyle(array('dash'=>0));
611 611
 					}
612 612
 
613
-					$nexY+=2;    // Passe espace entre les lignes
613
+					$nexY += 2; // Passe espace entre les lignes
614 614
 
615 615
 					// Detect if some page were added automatically and output _tableau for past pages
616 616
 					while ($pagenb < $pageposafter)
@@ -624,13 +624,13 @@  discard block
 block discarded – undo
624 624
 						{
625 625
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
626 626
 						}
627
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
627
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
628 628
 						$pagenb++;
629 629
 						$pdf->setPage($pagenb);
630
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
630
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
631 631
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
632 632
 					}
633
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
633
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
634 634
 					{
635 635
 						if ($pagenb == 1)
636 636
 						{
@@ -640,10 +640,10 @@  discard block
 block discarded – undo
640 640
 						{
641 641
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
642 642
 						}
643
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
643
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
644 644
 						// New page
645 645
 						$pdf->AddPage();
646
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
646
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
647 647
 						$pagenb++;
648 648
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
649 649
 					}
@@ -653,60 +653,60 @@  discard block
 block discarded – undo
653 653
 				if ($pagenb == 1)
654 654
 				{
655 655
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
656
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
656
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
657 657
 				}
658 658
 				else
659 659
 				{
660 660
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
661
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
661
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
662 662
 				}
663 663
 
664 664
 				// Affiche zone infos
665
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
665
+				$posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
666 666
 
667 667
 				if (!$conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL) {
668 668
 					// Affiche zone totaux
669
-					$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
669
+					$posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
670 670
 				}
671 671
 
672 672
 				// Affiche zone versements
673 673
 				if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
674 674
 				{
675
-					$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
675
+					$posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs);
676 676
 				}
677 677
 
678 678
 				// Pied de page
679
-				$this->_pagefoot($pdf,$object,$outputlangs);
680
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
679
+				$this->_pagefoot($pdf, $object, $outputlangs);
680
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
681 681
 
682 682
 				$pdf->Close();
683 683
 
684
-				$pdf->Output($file,'F');
684
+				$pdf->Output($file, 'F');
685 685
 
686 686
 				// Add pdfgeneration hook
687 687
 				$hookmanager->initHooks(array('pdfgeneration'));
688
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
688
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
689 689
 				global $action;
690
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
690
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
691 691
 
692
-				if (! empty($conf->global->MAIN_UMASK))
692
+				if (!empty($conf->global->MAIN_UMASK))
693 693
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
694 694
 
695
-				return 1;   // Pas d'erreur
695
+				return 1; // Pas d'erreur
696 696
 			}
697 697
 			else
698 698
 			{
699
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
699
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
700 700
 				return 0;
701 701
 			}
702 702
 		}
703 703
 		else
704 704
 		{
705
-			$this->error=$langs->trans("ErrorConstantNotDefined","FAC_OUTPUTDIR");
705
+			$this->error = $langs->trans("ErrorConstantNotDefined", "FAC_OUTPUTDIR");
706 706
 			return 0;
707 707
 		}
708
-		$this->error=$langs->trans("ErrorUnknown");
709
-		return 0;   // Erreur par defaut
708
+		$this->error = $langs->trans("ErrorUnknown");
709
+		return 0; // Erreur par defaut
710 710
 	}
711 711
 
712 712
 
@@ -723,8 +723,8 @@  discard block
 block discarded – undo
723 723
 	{
724 724
 		global $conf;
725 725
 
726
-        $sign=1;
727
-        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
726
+        $sign = 1;
727
+        if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
728 728
 
729 729
         $tab3_posx = 120;
730 730
 		$tab3_top = $posy + 8;
@@ -737,109 +737,109 @@  discard block
 block discarded – undo
737 737
 
738 738
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
739 739
 
740
-		$title=$outputlangs->transnoentities("PaymentsAlreadyDone");
741
-		if ($object->type == 2) $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone");
740
+		$title = $outputlangs->transnoentities("PaymentsAlreadyDone");
741
+		if ($object->type == 2) $title = $outputlangs->transnoentities("PaymentsBackAlreadyDone");
742 742
 
743
-		$pdf->SetFont('','', $default_font_size - 3);
743
+		$pdf->SetFont('', '', $default_font_size - 3);
744 744
 		$pdf->SetXY($tab3_posx, $tab3_top - 4);
745 745
 		$pdf->MultiCell(60, 3, $title, 0, 'L', 0);
746 746
 
747
-		$pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top);
747
+		$pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
748 748
 
749
-		$pdf->SetFont('','', $default_font_size - 4);
749
+		$pdf->SetFont('', '', $default_font_size - 4);
750 750
 		$pdf->SetXY($tab3_posx, $tab3_top);
751 751
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0);
752
-		$pdf->SetXY($tab3_posx+21, $tab3_top);
752
+		$pdf->SetXY($tab3_posx + 21, $tab3_top);
753 753
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0);
754
-		$pdf->SetXY($tab3_posx+40, $tab3_top);
754
+		$pdf->SetXY($tab3_posx + 40, $tab3_top);
755 755
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0);
756
-		$pdf->SetXY($tab3_posx+58, $tab3_top);
756
+		$pdf->SetXY($tab3_posx + 58, $tab3_top);
757 757
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0);
758 758
 
759
-		$pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height);
759
+		$pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
760 760
 
761
-		$y=0;
761
+		$y = 0;
762 762
 
763
-		$pdf->SetFont('','', $default_font_size - 4);
763
+		$pdf->SetFont('', '', $default_font_size - 4);
764 764
 
765 765
 		// Loop on each deposits and credit notes included
766 766
 		$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
767
-		$sql.= " re.description, re.fk_facture_source,";
768
-		$sql.= " f.type, f.datef";
769
-		$sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f";
770
-		$sql.= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id;
771
-		$resql=$this->db->query($sql);
767
+		$sql .= " re.description, re.fk_facture_source,";
768
+		$sql .= " f.type, f.datef";
769
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re, ".MAIN_DB_PREFIX."facture as f";
770
+		$sql .= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id;
771
+		$resql = $this->db->query($sql);
772 772
 		if ($resql)
773 773
 		{
774 774
 			$num = $this->db->num_rows($resql);
775
-			$i=0;
776
-			$invoice=new Facture($this->db);
775
+			$i = 0;
776
+			$invoice = new Facture($this->db);
777 777
 			while ($i < $num)
778 778
 			{
779
-				$y+=3;
779
+				$y += 3;
780 780
 				$obj = $this->db->fetch_object($resql);
781 781
 
782
-				if ($obj->type == 2) $text=$outputlangs->trans("CreditNote");
783
-				elseif ($obj->type == 3) $text=$outputlangs->trans("Deposit");
784
-				else $text=$outputlangs->trans("UnknownType");
782
+				if ($obj->type == 2) $text = $outputlangs->trans("CreditNote");
783
+				elseif ($obj->type == 3) $text = $outputlangs->trans("Deposit");
784
+				else $text = $outputlangs->trans("UnknownType");
785 785
 
786 786
 				$invoice->fetch($obj->fk_facture_source);
787 787
 
788
-				$pdf->SetXY($tab3_posx, $tab3_top+$y);
789
-				$pdf->MultiCell(20, 3, dol_print_date($obj->datef,'day',false,$outputlangs,true), 0, 'L', 0);
790
-				$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
788
+				$pdf->SetXY($tab3_posx, $tab3_top + $y);
789
+				$pdf->MultiCell(20, 3, dol_print_date($obj->datef, 'day', false, $outputlangs, true), 0, 'L', 0);
790
+				$pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
791 791
 				$pdf->MultiCell(20, 3, price($obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
792
-				$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
792
+				$pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
793 793
 				$pdf->MultiCell(20, 3, $text, 0, 'L', 0);
794
-				$pdf->SetXY($tab3_posx+58, $tab3_top+$y);
794
+				$pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
795 795
 				$pdf->MultiCell(20, 3, $invoice->ref, 0, 'L', 0);
796 796
 
797
-				$pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3);
797
+				$pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
798 798
 
799 799
 				$i++;
800 800
 			}
801 801
 		}
802 802
 		else
803 803
 		{
804
-			$this->error=$this->db->lasterror();
804
+			$this->error = $this->db->lasterror();
805 805
 			return -1;
806 806
 		}
807 807
 
808 808
 		// Loop on each payment
809 809
 		$sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount,";
810
-		$sql.= " cp.code";
811
-		$sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
812
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
813
-		$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
814
-		$sql.= " ORDER BY p.datep";
815
-		$resql=$this->db->query($sql);
810
+		$sql .= " cp.code";
811
+		$sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
812
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
813
+		$sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
814
+		$sql .= " ORDER BY p.datep";
815
+		$resql = $this->db->query($sql);
816 816
 		if ($resql)
817 817
 		{
818 818
 			$num = $this->db->num_rows($resql);
819
-			$i=0;
819
+			$i = 0;
820 820
 			while ($i < $num) {
821
-				$y+=3;
821
+				$y += 3;
822 822
 				$row = $this->db->fetch_object($resql);
823 823
 
824
-				$pdf->SetXY($tab3_posx, $tab3_top+$y);
825
-				$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0);
826
-				$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
824
+				$pdf->SetXY($tab3_posx, $tab3_top + $y);
825
+				$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date), 'day', false, $outputlangs, true), 0, 'L', 0);
826
+				$pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
827 827
 				$pdf->MultiCell(20, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'L', 0);
828
-				$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
829
-				$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);
828
+				$pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
829
+				$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->code);
830 830
 
831 831
 				$pdf->MultiCell(20, 3, $oper, 0, 'L', 0);
832
-				$pdf->SetXY($tab3_posx+58, $tab3_top+$y);
832
+				$pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
833 833
 				$pdf->MultiCell(30, 3, $row->num, 0, 'L', 0);
834 834
 
835
-				$pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3);
835
+				$pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
836 836
 
837 837
 				$i++;
838 838
 			}
839 839
 		}
840 840
 		else
841 841
 		{
842
-			$this->error=$this->db->lasterror();
842
+			$this->error = $this->db->lasterror();
843 843
 			return -1;
844 844
 		}
845 845
 
@@ -861,35 +861,35 @@  discard block
 block discarded – undo
861 861
 
862 862
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
863 863
 
864
-		$pdf->SetFont('','', $default_font_size - 1);
864
+		$pdf->SetFont('', '', $default_font_size - 1);
865 865
 
866 866
 		// If France, show VAT mention if not applicable
867 867
 		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
868 868
 		{
869
-			$pdf->SetFont('','B', $default_font_size - 2);
869
+			$pdf->SetFont('', 'B', $default_font_size - 2);
870 870
 			$pdf->SetXY($this->marge_gauche, $posy);
871 871
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
872 872
 
873
-			$posy=$pdf->GetY()+4;
873
+			$posy = $pdf->GetY() + 4;
874 874
 		}
875 875
 
876
-		$posxval=52;
876
+		$posxval = 52;
877 877
 
878 878
 		// Show payments conditions
879 879
 		if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement))
880 880
 		{
881
-			$pdf->SetFont('','B', $default_font_size - 2);
881
+			$pdf->SetFont('', 'B', $default_font_size - 2);
882 882
 			$pdf->SetXY($this->marge_gauche, $posy);
883 883
 			$titre = $outputlangs->transnoentities("PaymentConditions").':';
884 884
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
885 885
 
886
-			$pdf->SetFont('','', $default_font_size - 2);
886
+			$pdf->SetFont('', '', $default_font_size - 2);
887 887
 			$pdf->SetXY($posxval, $posy);
888
-			$lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
889
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
890
-			$pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
888
+			$lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
889
+			$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
890
+			$pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
891 891
 
892
-			$posy=$pdf->GetY()+3;
892
+			$posy = $pdf->GetY() + 3;
893 893
 		}
894 894
 
895 895
 		if ($object->type != 2)
@@ -908,13 +908,13 @@  discard block
 block discarded – undo
908 908
 				$outputlangs->load("errors");
909 909
 
910 910
 				$pdf->SetXY($this->marge_gauche, $posy);
911
-				$pdf->SetTextColor(200,0,0);
912
-				$pdf->SetFont('','B', $default_font_size - 2);
913
-				$this->error = $outputlangs->transnoentities("ErrorPaymentModeDefinedToWithoutSetup",$object->mode_reglement_code);
914
-				$pdf->MultiCell(80, 3, $this->error,0,'L',0);
915
-				$pdf->SetTextColor(0,0,0);
911
+				$pdf->SetTextColor(200, 0, 0);
912
+				$pdf->SetFont('', 'B', $default_font_size - 2);
913
+				$this->error = $outputlangs->transnoentities("ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
914
+				$pdf->MultiCell(80, 3, $this->error, 0, 'L', 0);
915
+				$pdf->SetTextColor(0, 0, 0);
916 916
 
917
-				$posy=$pdf->GetY()+1;
917
+				$posy = $pdf->GetY() + 1;
918 918
 			}
919 919
 
920 920
 			// Show payment mode
@@ -922,26 +922,26 @@  discard block
 block discarded – undo
922 922
 			&& $object->mode_reglement_code != 'CHQ'
923 923
 			&& $object->mode_reglement_code != 'VIR')
924 924
 			{
925
-				$pdf->SetFont('','B', $default_font_size - 2);
925
+				$pdf->SetFont('', 'B', $default_font_size - 2);
926 926
 				$pdf->SetXY($this->marge_gauche, $posy);
927 927
 				$titre = $outputlangs->transnoentities("PaymentMode").':';
928 928
 				$pdf->MultiCell(80, 5, $titre, 0, 'L');
929 929
 
930
-				$pdf->SetFont('','', $default_font_size - 2);
930
+				$pdf->SetFont('', '', $default_font_size - 2);
931 931
 				$pdf->SetXY($posxval, $posy);
932
-				$lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
933
-				$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
932
+				$lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
933
+				$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
934 934
 
935
-				$posy=$pdf->GetY()+2;
935
+				$posy = $pdf->GetY() + 2;
936 936
 			}
937 937
 
938 938
 			// Show payment mode CHQ
939 939
 			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
940 940
 			{
941 941
 				// Si mode reglement non force ou si force a CHQ
942
-				if (! empty($conf->global->FACTURE_CHQ_NUMBER))
942
+				if (!empty($conf->global->FACTURE_CHQ_NUMBER))
943 943
 				{
944
-					$diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
944
+					$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
945 945
 
946 946
 					if ($conf->global->FACTURE_CHQ_NUMBER > 0)
947 947
 					{
@@ -949,31 +949,31 @@  discard block
 block discarded – undo
949 949
 						$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
950 950
 
951 951
 						$pdf->SetXY($this->marge_gauche, $posy);
952
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
953
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
954
-						$posy=$pdf->GetY()+1;
952
+						$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
953
+						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
954
+						$posy = $pdf->GetY() + 1;
955 955
 
956 956
 			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
957 957
 			            {
958 958
 							$pdf->SetXY($this->marge_gauche, $posy);
959
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
959
+							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
960 960
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
961
-							$posy=$pdf->GetY()+2;
961
+							$posy = $pdf->GetY() + 2;
962 962
 			            }
963 963
 					}
964 964
 					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
965 965
 					{
966 966
 						$pdf->SetXY($this->marge_gauche, $posy);
967
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
968
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
969
-						$posy=$pdf->GetY()+1;
967
+						$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
968
+						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
969
+						$posy = $pdf->GetY() + 1;
970 970
 
971 971
 			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
972 972
 			            {
973 973
 							$pdf->SetXY($this->marge_gauche, $posy);
974
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
974
+							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
975 975
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
976
-							$posy=$pdf->GetY()+2;
976
+							$posy = $pdf->GetY() + 2;
977 977
 			            }
978 978
 					}
979 979
 				}
@@ -982,18 +982,18 @@  discard block
 block discarded – undo
982 982
 			// If payment mode not forced or forced to VIR, show payment with BAN
983 983
 			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
984 984
 			{
985
-				if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
985
+				if (!empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
986 986
 				{
987
-					$bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank);
987
+					$bankid = (empty($object->fk_bank) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_bank);
988 988
 					$account = new Account($this->db);
989 989
 					$account->fetch($bankid);
990 990
 
991
-					$curx=$this->marge_gauche;
992
-					$cury=$posy;
991
+					$curx = $this->marge_gauche;
992
+					$cury = $posy;
993 993
 
994
-					$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
994
+					$posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
995 995
 
996
-					$posy+=2;
996
+					$posy += 2;
997 997
 				}
998 998
 			}
999 999
 		}
@@ -1014,43 +1014,43 @@  discard block
 block discarded – undo
1014 1014
 	 */
1015 1015
 	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
1016 1016
 	{
1017
-		global $conf,$mysoc;
1017
+		global $conf, $mysoc;
1018 1018
 
1019
-        $sign=1;
1020
-        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
1019
+        $sign = 1;
1020
+        if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
1021 1021
 
1022 1022
         $default_font_size = pdf_getPDFFontSize($outputlangs);
1023 1023
 
1024 1024
 		$tab2_top = $posy;
1025 1025
 		$tab2_hl = 4;
1026
-		$pdf->SetFont('','', $default_font_size - 1);
1026
+		$pdf->SetFont('', '', $default_font_size - 1);
1027 1027
 
1028 1028
 		// Tableau total
1029 1029
 		$col1x = 120; $col2x = 170;
1030 1030
 		if ($this->page_largeur < 210) // To work with US executive format
1031 1031
 		{
1032
-			$col2x-=20;
1032
+			$col2x -= 20;
1033 1033
 		}
1034 1034
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1035 1035
 
1036
-		$useborder=0;
1036
+		$useborder = 0;
1037 1037
 		$index = 0;
1038 1038
 
1039 1039
 		// Total HT
1040
-		$pdf->SetFillColor(255,255,255);
1040
+		$pdf->SetFillColor(255, 255, 255);
1041 1041
 		$pdf->SetXY($col1x, $tab2_top + 0);
1042
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1042
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1043 1043
 		$pdf->SetXY($col2x, $tab2_top + 0);
1044
-		$pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($object->total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1);
1044
+		$pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($object->total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0, 'R', 1);
1045 1045
 
1046 1046
 		// Show VAT by rates and total
1047
-		$pdf->SetFillColor(248,248,248);
1047
+		$pdf->SetFillColor(248, 248, 248);
1048 1048
 
1049
-		$this->atleastoneratenotnull=0;
1049
+		$this->atleastoneratenotnull = 0;
1050 1050
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1051 1051
 		{
1052
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1053
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull)
1052
+			$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1053
+			if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull)
1054 1054
 			{
1055 1055
 				// Nothing to do
1056 1056
 			}
@@ -1059,29 +1059,29 @@  discard block
 block discarded – undo
1059 1059
 				//Local tax 1 before VAT
1060 1060
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1061 1061
 				//{
1062
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1062
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1063 1063
 					{
1064
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1064
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
1065 1065
 
1066
-						foreach( $localtax_rate as $tvakey => $tvaval )
1066
+						foreach ($localtax_rate as $tvakey => $tvaval)
1067 1067
 						{
1068
-							if ($tvakey!=0)    // On affiche pas taux 0
1068
+							if ($tvakey != 0)    // On affiche pas taux 0
1069 1069
 							{
1070 1070
 								//$this->atleastoneratenotnull++;
1071 1071
 
1072 1072
 								$index++;
1073 1073
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1074 1074
 
1075
-								$tvacompl='';
1076
-								if (preg_match('/\*/',$tvakey))
1075
+								$tvacompl = '';
1076
+								if (preg_match('/\*/', $tvakey))
1077 1077
 								{
1078
-									$tvakey=str_replace('*','',$tvakey);
1078
+									$tvakey = str_replace('*', '', $tvakey);
1079 1079
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1080 1080
 								}
1081 1081
 
1082
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1083
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1084
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1082
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1083
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1084
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1085 1085
 
1086 1086
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1087 1087
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1092,13 +1092,13 @@  discard block
 block discarded – undo
1092 1092
 				//Local tax 2 before VAT
1093 1093
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1094 1094
 				//{
1095
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1095
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1096 1096
 					{
1097
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1097
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
1098 1098
 
1099
-						foreach( $localtax_rate as $tvakey => $tvaval )
1099
+						foreach ($localtax_rate as $tvakey => $tvaval)
1100 1100
 						{
1101
-							if ($tvakey!=0)    // On affiche pas taux 0
1101
+							if ($tvakey != 0)    // On affiche pas taux 0
1102 1102
 							{
1103 1103
 								//$this->atleastoneratenotnull++;
1104 1104
 
@@ -1107,15 +1107,15 @@  discard block
 block discarded – undo
1107 1107
 								$index++;
1108 1108
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1109 1109
 
1110
-								$tvacompl='';
1111
-								if (preg_match('/\*/',$tvakey))
1110
+								$tvacompl = '';
1111
+								if (preg_match('/\*/', $tvakey))
1112 1112
 								{
1113
-									$tvakey=str_replace('*','',$tvakey);
1113
+									$tvakey = str_replace('*', '', $tvakey);
1114 1114
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1115 1115
 								}
1116
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1117
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1118
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1116
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1117
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1118
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1119 1119
 
1120 1120
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1121 1121
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
 					}
1126 1126
 				//}
1127 1127
 				// VAT
1128
-				foreach($this->tva as $tvakey => $tvaval)
1128
+				foreach ($this->tva as $tvakey => $tvaval)
1129 1129
 				{
1130 1130
 					if ($tvakey > 0)    // On affiche pas taux 0
1131 1131
 					{
@@ -1134,15 +1134,15 @@  discard block
 block discarded – undo
1134 1134
 						$index++;
1135 1135
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1136 1136
 
1137
-						$tvacompl='';
1138
-						if (preg_match('/\*/',$tvakey))
1137
+						$tvacompl = '';
1138
+						if (preg_match('/\*/', $tvakey))
1139 1139
 						{
1140
-							$tvakey=str_replace('*','',$tvakey);
1140
+							$tvakey = str_replace('*', '', $tvakey);
1141 1141
 							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1142 1142
 						}
1143
-						$totalvat =$outputlangs->transnoentities("TotalVAT").' ';
1144
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
1145
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1143
+						$totalvat = $outputlangs->transnoentities("TotalVAT").' ';
1144
+						$totalvat .= vatrate($tvakey, 1).$tvacompl;
1145
+						$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1146 1146
 
1147 1147
 						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1148 1148
 						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1152,11 +1152,11 @@  discard block
 block discarded – undo
1152 1152
 				//Local tax 1 after VAT
1153 1153
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1154 1154
 				//{
1155
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1155
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1156 1156
 					{
1157
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1157
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1158 1158
 
1159
-						foreach( $localtax_rate as $tvakey => $tvaval )
1159
+						foreach ($localtax_rate as $tvakey => $tvaval)
1160 1160
 						{
1161 1161
 							if ($tvakey != 0)    // On affiche pas taux 0
1162 1162
 							{
@@ -1165,16 +1165,16 @@  discard block
 block discarded – undo
1165 1165
 								$index++;
1166 1166
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1167 1167
 
1168
-								$tvacompl='';
1169
-								if (preg_match('/\*/',$tvakey))
1168
+								$tvacompl = '';
1169
+								if (preg_match('/\*/', $tvakey))
1170 1170
 								{
1171
-									$tvakey=str_replace('*','',$tvakey);
1171
+									$tvakey = str_replace('*', '', $tvakey);
1172 1172
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1173 1173
 								}
1174
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1175
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1174
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1175
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1176 1176
 
1177
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1177
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1178 1178
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1179 1179
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1180 1180
 							}
@@ -1184,11 +1184,11 @@  discard block
 block discarded – undo
1184 1184
 				//Local tax 2 after VAT
1185 1185
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1186 1186
 				//{
1187
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1187
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1188 1188
 					{
1189
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1189
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1190 1190
 
1191
-						foreach( $localtax_rate as $tvakey => $tvaval )
1191
+						foreach ($localtax_rate as $tvakey => $tvaval)
1192 1192
 						{
1193 1193
 						    // retrieve global local tax
1194 1194
 							if ($tvakey != 0)    // On affiche pas taux 0
@@ -1198,16 +1198,16 @@  discard block
 block discarded – undo
1198 1198
 								$index++;
1199 1199
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1200 1200
 
1201
-								$tvacompl='';
1202
-								if (preg_match('/\*/',$tvakey))
1201
+								$tvacompl = '';
1202
+								if (preg_match('/\*/', $tvakey))
1203 1203
 								{
1204
-									$tvakey=str_replace('*','',$tvakey);
1204
+									$tvakey = str_replace('*', '', $tvakey);
1205 1205
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1206 1206
 								}
1207
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1207
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1208 1208
 
1209
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1210
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1209
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1210
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1211 1211
 
1212 1212
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1213 1213
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1221,7 +1221,7 @@  discard block
 block discarded – undo
1221 1221
 				{
1222 1222
 					$index++;
1223 1223
 					$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1224
-					$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1);
1224
+					$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1);
1225 1225
 
1226 1226
 					$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1227 1227
 					$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1);
@@ -1230,29 +1230,29 @@  discard block
 block discarded – undo
1230 1230
 				// Total TTC
1231 1231
 				$index++;
1232 1232
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1233
-				$pdf->SetTextColor(0,0,60);
1234
-				$pdf->SetFillColor(224,224,224);
1235
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1233
+				$pdf->SetTextColor(0, 0, 60);
1234
+				$pdf->SetFillColor(224, 224, 224);
1235
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1236 1236
 
1237 1237
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1238 1238
 				$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1239 1239
 			}
1240 1240
 		}
1241 1241
 
1242
-		$pdf->SetTextColor(0,0,0);
1242
+		$pdf->SetTextColor(0, 0, 0);
1243 1243
 
1244
-		$creditnoteamount=$object->getSumCreditNotesUsed();
1245
-		$depositsamount=$object->getSumDepositsUsed();
1244
+		$creditnoteamount = $object->getSumCreditNotesUsed();
1245
+		$depositsamount = $object->getSumDepositsUsed();
1246 1246
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
1247 1247
 		$resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1248
-		if ($object->paye) $resteapayer=0;
1248
+		if ($object->paye) $resteapayer = 0;
1249 1249
 
1250 1250
 		if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0)
1251 1251
 		{
1252 1252
 			// Already paid + Deposits
1253 1253
 			$index++;
1254 1254
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1255
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0);
1255
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0);
1256 1256
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1257 1257
 			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount, 0, $outputlangs), 0, 'R', 0);
1258 1258
 
@@ -1261,7 +1261,7 @@  discard block
 block discarded – undo
1261 1261
 			{
1262 1262
 				$index++;
1263 1263
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1264
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0);
1264
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0);
1265 1265
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1266 1266
 				$pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0);
1267 1267
 			}
@@ -1270,26 +1270,26 @@  discard block
 block discarded – undo
1270 1270
 			if ($object->close_code == 'discount_vat')
1271 1271
 			{
1272 1272
 				$index++;
1273
-				$pdf->SetFillColor(255,255,255);
1273
+				$pdf->SetFillColor(255, 255, 255);
1274 1274
 
1275 1275
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1276
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1);
1276
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1);
1277 1277
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1278 1278
 				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1);
1279 1279
 
1280
-				$resteapayer=0;
1280
+				$resteapayer = 0;
1281 1281
 			}
1282 1282
 
1283 1283
 			$index++;
1284
-			$pdf->SetTextColor(0,0,60);
1285
-			$pdf->SetFillColor(224,224,224);
1284
+			$pdf->SetTextColor(0, 0, 60);
1285
+			$pdf->SetFillColor(224, 224, 224);
1286 1286
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1287
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1287
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1288 1288
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1289 1289
 			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1290 1290
 
1291
-			$pdf->SetFont('','', $default_font_size - 1);
1292
-			$pdf->SetTextColor(0,0,0);
1291
+			$pdf->SetFont('', '', $default_font_size - 1);
1292
+			$pdf->SetTextColor(0, 0, 0);
1293 1293
 		}
1294 1294
 
1295 1295
 		$index++;
@@ -1308,47 +1308,47 @@  discard block
 block discarded – undo
1308 1308
 	 *   @param		int			$hidebottom		Hide bottom bar of array
1309 1309
 	 *   @return	void
1310 1310
 	 */
1311
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
1311
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
1312 1312
 	{
1313 1313
 		global $conf;
1314 1314
 
1315 1315
 		// Force to disable hidetop and hidebottom
1316
-		$hidebottom=0;
1317
-		if ($hidetop) $hidetop=-1;
1316
+		$hidebottom = 0;
1317
+		if ($hidetop) $hidetop = -1;
1318 1318
 
1319 1319
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1320 1320
 
1321 1321
 		// Amount in (at tab_top - 1)
1322
-		$pdf->SetTextColor(0,0,0);
1323
-		$pdf->SetFont('','', $default_font_size - 2);
1322
+		$pdf->SetTextColor(0, 0, 0);
1323
+		$pdf->SetFont('', '', $default_font_size - 2);
1324 1324
 
1325 1325
 		if (empty($hidetop))
1326 1326
 		{
1327
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
1328
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1327
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
1328
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1329 1329
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1330 1330
 
1331 1331
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1332
-			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1332
+			if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1333 1333
 		}
1334 1334
 
1335
-		$pdf->SetDrawColor(128,128,128);
1336
-		$pdf->SetFont('','', $default_font_size - 1);
1335
+		$pdf->SetDrawColor(128, 128, 128);
1336
+		$pdf->SetFont('', '', $default_font_size - 1);
1337 1337
 
1338 1338
 		// Output Rect
1339
-		$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
1339
+		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
1340 1340
 
1341 1341
 		if (empty($hidetop))
1342 1342
 		{
1343
-			$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line prend une position y en 2eme param et 4eme param
1343
+			$pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line prend une position y en 2eme param et 4eme param
1344 1344
 
1345
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
1346
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1345
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1346
+			$pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1347 1347
 		}
1348 1348
 
1349
-		if (! empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
1349
+		if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
1350 1350
 		{
1351
-			$pdf->line($this->posxpicture-1, $tab_top, $this->posxpicture-1, $tab_top + $tab_height);
1351
+			$pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1352 1352
 			if (empty($hidetop))
1353 1353
 			{
1354 1354
 				//$pdf->SetXY($this->posxpicture-1, $tab_top+1);
@@ -1358,35 +1358,35 @@  discard block
 block discarded – undo
1358 1358
 
1359 1359
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1360 1360
 		{
1361
-			$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
1361
+			$pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1362 1362
 			if (empty($hidetop))
1363 1363
 			{
1364
-				$pdf->SetXY($this->posxtva-3, $tab_top+1);
1365
-				$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1364
+				$pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1365
+				$pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
1366 1366
 			}
1367 1367
 		}
1368 1368
 
1369
-		$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
1369
+		$pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1370 1370
 		if (empty($hidetop))
1371 1371
 		{
1372
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
1373
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1372
+			$pdf->SetXY($this->posxup - 1, $tab_top + 1);
1373
+			$pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
1374 1374
 		}
1375 1375
 
1376
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1376
+		$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1377 1377
 		if (empty($hidetop))
1378 1378
 		{
1379
-			$pdf->SetXY($this->posxqty-1, $tab_top+1);
1380
-			$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1379
+			$pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1380
+			$pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1381 1381
 		}
1382 1382
 
1383
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1383
+		$pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1384 1384
 		if (empty($hidetop))
1385 1385
 		{
1386 1386
 			if ($this->atleastonediscount)
1387 1387
 			{
1388
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1389
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1388
+				$pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1389
+				$pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
1390 1390
 			}
1391 1391
 		}
1392 1392
 		if ($this->atleastonediscount)
@@ -1395,8 +1395,8 @@  discard block
 block discarded – undo
1395 1395
 		}
1396 1396
 		if (empty($hidetop))
1397 1397
 		{
1398
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
1399
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1398
+			$pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1399
+			$pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
1400 1400
 		}
1401 1401
 	}
1402 1402
 
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
 	 */
1412 1412
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1413 1413
 	{
1414
-		global $conf,$langs;
1414
+		global $conf, $langs;
1415 1415
 
1416 1416
 		$outputlangs->load("main");
1417 1417
 		$outputlangs->load("bills");
@@ -1420,127 +1420,127 @@  discard block
 block discarded – undo
1420 1420
 
1421 1421
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1422 1422
 
1423
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1423
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1424 1424
 
1425 1425
 		// Show Draft Watermark
1426
-		if($object->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) )
1426
+		if ($object->statut == 0 && (!empty($conf->global->FACTURE_DRAFT_WATERMARK)))
1427 1427
         {
1428
-		      pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FACTURE_DRAFT_WATERMARK);
1428
+		      pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
1429 1429
         }
1430 1430
 
1431
-		$pdf->SetTextColor(0,0,60);
1432
-		$pdf->SetFont('','B', $default_font_size + 3);
1431
+		$pdf->SetTextColor(0, 0, 60);
1432
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1433 1433
 
1434
-		$posy=$this->marge_haute;
1435
-        $posx=$this->page_largeur-$this->marge_droite-100;
1434
+		$posy = $this->marge_haute;
1435
+        $posx = $this->page_largeur - $this->marge_droite - 100;
1436 1436
 
1437
-		$pdf->SetXY($this->marge_gauche,$posy);
1437
+		$pdf->SetXY($this->marge_gauche, $posy);
1438 1438
 
1439 1439
 		// Logo
1440
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1440
+		$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1441 1441
 		if ($this->emetteur->logo)
1442 1442
 		{
1443 1443
 			if (is_readable($logo))
1444 1444
 			{
1445
-			    $height=pdf_getHeightForLogo($logo);
1446
-				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1445
+			    $height = pdf_getHeightForLogo($logo);
1446
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1447 1447
 			}
1448 1448
 			else
1449 1449
 			{
1450
-				$pdf->SetTextColor(200,0,0);
1451
-				$pdf->SetFont('','B',$default_font_size - 2);
1452
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1450
+				$pdf->SetTextColor(200, 0, 0);
1451
+				$pdf->SetFont('', 'B', $default_font_size - 2);
1452
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1453 1453
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1454 1454
 			}
1455 1455
 		}
1456 1456
 		else
1457 1457
 		{
1458
-			$text=$this->emetteur->name;
1458
+			$text = $this->emetteur->name;
1459 1459
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1460 1460
 		}
1461 1461
 
1462
-		$pdf->SetFont('','B', $default_font_size + 3);
1463
-		$pdf->SetXY($posx,$posy);
1464
-		$pdf->SetTextColor(0,0,60);
1465
-		$title=$outputlangs->transnoentities("Invoice");
1466
-		if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement");
1467
-		if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir");
1468
-		if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit");
1469
-		if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProFormat");
1462
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1463
+		$pdf->SetXY($posx, $posy);
1464
+		$pdf->SetTextColor(0, 0, 60);
1465
+		$title = $outputlangs->transnoentities("Invoice");
1466
+		if ($object->type == 1) $title = $outputlangs->transnoentities("InvoiceReplacement");
1467
+		if ($object->type == 2) $title = $outputlangs->transnoentities("InvoiceAvoir");
1468
+		if ($object->type == 3) $title = $outputlangs->transnoentities("InvoiceDeposit");
1469
+		if ($object->type == 4) $title = $outputlangs->transnoentities("InvoiceProFormat");
1470 1470
 		$pdf->MultiCell(100, 3, $title, '', 'R');
1471 1471
 
1472
-		$pdf->SetFont('','B',$default_font_size);
1472
+		$pdf->SetFont('', 'B', $default_font_size);
1473 1473
 
1474
-		$posy+=5;
1475
-		$pdf->SetXY($posx,$posy);
1476
-		$pdf->SetTextColor(0,0,60);
1477
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1474
+		$posy += 5;
1475
+		$pdf->SetXY($posx, $posy);
1476
+		$pdf->SetTextColor(0, 0, 60);
1477
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1478 1478
 
1479
-		$posy+=1;
1480
-		$pdf->SetFont('','', $default_font_size - 2);
1479
+		$posy += 1;
1480
+		$pdf->SetFont('', '', $default_font_size - 2);
1481 1481
 
1482 1482
 		if ($object->ref_client)
1483 1483
 		{
1484
-			$posy+=4;
1485
-			$pdf->SetXY($posx,$posy);
1486
-			$pdf->SetTextColor(0,0,60);
1487
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1484
+			$posy += 4;
1485
+			$pdf->SetXY($posx, $posy);
1486
+			$pdf->SetTextColor(0, 0, 60);
1487
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1488 1488
 		}
1489 1489
 
1490
-		$objectidnext=$object->getIdReplacingInvoice('validated');
1490
+		$objectidnext = $object->getIdReplacingInvoice('validated');
1491 1491
 		if ($object->type == 0 && $objectidnext)
1492 1492
 		{
1493
-			$objectreplacing=new Facture($this->db);
1493
+			$objectreplacing = new Facture($this->db);
1494 1494
 			$objectreplacing->fetch($objectidnext);
1495 1495
 
1496
-			$posy+=3;
1497
-			$pdf->SetXY($posx,$posy);
1498
-			$pdf->SetTextColor(0,0,60);
1496
+			$posy += 3;
1497
+			$pdf->SetXY($posx, $posy);
1498
+			$pdf->SetTextColor(0, 0, 60);
1499 1499
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R');
1500 1500
 		}
1501 1501
 		if ($object->type == 1)
1502 1502
 		{
1503
-			$objectreplaced=new Facture($this->db);
1503
+			$objectreplaced = new Facture($this->db);
1504 1504
 			$objectreplaced->fetch($object->fk_facture_source);
1505 1505
 
1506
-			$posy+=4;
1507
-			$pdf->SetXY($posx,$posy);
1508
-			$pdf->SetTextColor(0,0,60);
1506
+			$posy += 4;
1507
+			$pdf->SetXY($posx, $posy);
1508
+			$pdf->SetTextColor(0, 0, 60);
1509 1509
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
1510 1510
 		}
1511 1511
 		if ($object->type == 2)
1512 1512
 		{
1513
-			$objectreplaced=new Facture($this->db);
1513
+			$objectreplaced = new Facture($this->db);
1514 1514
 			$objectreplaced->fetch($object->fk_facture_source);
1515 1515
 
1516
-			$posy+=3;
1517
-			$pdf->SetXY($posx,$posy);
1518
-			$pdf->SetTextColor(0,0,60);
1516
+			$posy += 3;
1517
+			$pdf->SetXY($posx, $posy);
1518
+			$pdf->SetTextColor(0, 0, 60);
1519 1519
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
1520 1520
 		}
1521 1521
 
1522
-		$posy+=4;
1523
-		$pdf->SetXY($posx,$posy);
1524
-		$pdf->SetTextColor(0,0,60);
1525
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateInvoice")." : " . dol_print_date($object->date,"day",false,$outputlangs), '', 'R');
1522
+		$posy += 4;
1523
+		$pdf->SetXY($posx, $posy);
1524
+		$pdf->SetTextColor(0, 0, 60);
1525
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateInvoice")." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R');
1526 1526
 
1527 1527
 		if ($object->type != 2)
1528 1528
 		{
1529
-			$posy+=3;
1530
-			$pdf->SetXY($posx,$posy);
1531
-			$pdf->SetTextColor(0,0,60);
1532
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEcheance")." : " . dol_print_date($object->date_lim_reglement,"day",false,$outputlangs,true), '', 'R');
1529
+			$posy += 3;
1530
+			$pdf->SetXY($posx, $posy);
1531
+			$pdf->SetTextColor(0, 0, 60);
1532
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEcheance")." : ".dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'R');
1533 1533
 		}
1534 1534
 
1535 1535
 		if ($object->thirdparty->code_client)
1536 1536
 		{
1537
-			$posy+=3;
1538
-			$pdf->SetXY($posx,$posy);
1539
-			$pdf->SetTextColor(0,0,60);
1540
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1537
+			$posy += 3;
1538
+			$pdf->SetXY($posx, $posy);
1539
+			$pdf->SetTextColor(0, 0, 60);
1540
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1541 1541
 		}
1542 1542
 
1543
-		$posy+=1;
1543
+		$posy += 1;
1544 1544
 
1545 1545
 		// Show list of linked objects
1546 1546
 		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
@@ -1551,84 +1551,84 @@  discard block
 block discarded – undo
1551 1551
 			$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
1552 1552
 
1553 1553
 			// Show sender
1554
-			$posy=42;
1555
-			$posx=$this->marge_gauche;
1556
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1557
-			$hautcadre=40;
1554
+			$posy = 42;
1555
+			$posx = $this->marge_gauche;
1556
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1557
+			$hautcadre = 40;
1558 1558
 
1559 1559
 			// Show sender frame
1560
-			$pdf->SetTextColor(0,0,0);
1561
-			$pdf->SetFont('','', $default_font_size - 2);
1562
-			$pdf->SetXY($posx,$posy-5);
1563
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1564
-			$pdf->SetXY($posx,$posy);
1565
-			$pdf->SetFillColor(230,230,230);
1560
+			$pdf->SetTextColor(0, 0, 0);
1561
+			$pdf->SetFont('', '', $default_font_size - 2);
1562
+			$pdf->SetXY($posx, $posy - 5);
1563
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1564
+			$pdf->SetXY($posx, $posy);
1565
+			$pdf->SetFillColor(230, 230, 230);
1566 1566
 			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1567
-			$pdf->SetTextColor(0,0,60);
1567
+			$pdf->SetTextColor(0, 0, 60);
1568 1568
 
1569 1569
 			// Show sender name
1570
-			$pdf->SetXY($posx+2,$posy+3);
1571
-			$pdf->SetFont('','B', $default_font_size);
1570
+			$pdf->SetXY($posx + 2, $posy + 3);
1571
+			$pdf->SetFont('', 'B', $default_font_size);
1572 1572
 			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1573
-			$posy=$pdf->getY();
1573
+			$posy = $pdf->getY();
1574 1574
 
1575 1575
 			// Show sender information
1576
-			$pdf->SetXY($posx+2,$posy);
1577
-			$pdf->SetFont('','', $default_font_size - 1);
1576
+			$pdf->SetXY($posx + 2, $posy);
1577
+			$pdf->SetFont('', '', $default_font_size - 1);
1578 1578
 			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1579 1579
 
1580 1580
 
1581 1581
 
1582 1582
 			// If BILLING contact defined on invoice, we use it
1583
-			$usecontact=false;
1584
-			$arrayidcontact=$object->getIdContact('external','BILLING');
1583
+			$usecontact = false;
1584
+			$arrayidcontact = $object->getIdContact('external', 'BILLING');
1585 1585
 			if (count($arrayidcontact) > 0)
1586 1586
 			{
1587
-				$usecontact=true;
1588
-				$result=$object->fetch_contact($arrayidcontact[0]);
1587
+				$usecontact = true;
1588
+				$result = $object->fetch_contact($arrayidcontact[0]);
1589 1589
 			}
1590 1590
 
1591 1591
 			// Recipient name
1592
-			if (! empty($usecontact))
1592
+			if (!empty($usecontact))
1593 1593
 			{
1594 1594
 				// On peut utiliser le nom de la societe du contact
1595
-				if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1595
+				if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1596 1596
 				else $socname = $object->thirdparty->name;
1597
-				$carac_client_name=$outputlangs->convToOutputCharset($socname);
1597
+				$carac_client_name = $outputlangs->convToOutputCharset($socname);
1598 1598
 			}
1599 1599
 			else
1600 1600
 			{
1601
-				$carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name);
1601
+				$carac_client_name = $outputlangs->convToOutputCharset($object->thirdparty->name);
1602 1602
 			}
1603 1603
 
1604
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target');
1604
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target');
1605 1605
 
1606 1606
 			// Show recipient
1607
-			$widthrecbox=100;
1608
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1609
-			$posy=42;
1610
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1611
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1607
+			$widthrecbox = 100;
1608
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1609
+			$posy = 42;
1610
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1611
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1612 1612
 
1613 1613
 			// Show recipient frame
1614
-			$pdf->SetTextColor(0,0,0);
1615
-			$pdf->SetFont('','', $default_font_size - 2);
1616
-			$pdf->SetXY($posx+2,$posy-5);
1617
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1614
+			$pdf->SetTextColor(0, 0, 0);
1615
+			$pdf->SetFont('', '', $default_font_size - 2);
1616
+			$pdf->SetXY($posx + 2, $posy - 5);
1617
+			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1618 1618
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1619 1619
 
1620 1620
 			// Show recipient name
1621
-			$pdf->SetXY($posx+2,$posy+3);
1622
-			$pdf->SetFont('','B', $default_font_size);
1621
+			$pdf->SetXY($posx + 2, $posy + 3);
1622
+			$pdf->SetFont('', 'B', $default_font_size);
1623 1623
 			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1624 1624
 
1625 1625
 			// Show recipient information
1626
-			$pdf->SetFont('','', $default_font_size - 1);
1627
-			$pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
1626
+			$pdf->SetFont('', '', $default_font_size - 1);
1627
+			$pdf->SetXY($posx + 2, $posy + 4 + (dol_nboflines_bis($carac_client_name, 50) * 4));
1628 1628
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1629 1629
 		}
1630 1630
 
1631
-		$pdf->SetTextColor(0,0,0);
1631
+		$pdf->SetTextColor(0, 0, 0);
1632 1632
 	}
1633 1633
 
1634 1634
 	/**
@@ -1640,11 +1640,11 @@  discard block
 block discarded – undo
1640 1640
 	 *      @param	int			$hidefreetext		1=Hide free text
1641 1641
 	 *      @return	int								Return height of bottom margin including footer text
1642 1642
 	 */
1643
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1643
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1644 1644
 	{
1645
-		$showdetails=0;
1646
-		$free_text = (float)DOL_VERSION > 3.8 ? 'INVOICE_FREE_TEXT' : 'FACTURE_FREE_TEXT';
1647
-		return pdf_pagefoot($pdf,$outputlangs,$free_text,$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1645
+		$showdetails = 0;
1646
+		$free_text = (float) DOL_VERSION > 3.8 ? 'INVOICE_FREE_TEXT' : 'FACTURE_FREE_TEXT';
1647
+		return pdf_pagefoot($pdf, $outputlangs, $free_text, $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1648 1648
 	}
1649 1649
 
1650 1650
 }
Please login to merge, or discard this patch.
Braces   +204 added lines, -98 removed lines patch added patch discarded remove patch
@@ -100,7 +100,10 @@  discard block
 block discarded – undo
100 100
 
101 101
 		// Get source company
102 102
 		$this->emetteur=$mysoc;
103
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
103
+		if (empty($this->emetteur->country_code)) {
104
+			$this->emetteur->country_code=substr($langs->defaultlang,-2);
105
+		}
106
+		// By default, if was not defined
104 107
 
105 108
 		// Define position of columns
106 109
 		$this->posxdesc=$this->marge_gauche+1;
@@ -109,11 +112,15 @@  discard block
 block discarded – undo
109 112
 		$this->posxqty=145;
110 113
 		$this->posxdiscount=162;
111 114
 		$this->postotalht=174;
112
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
115
+		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
116
+			$this->posxtva=$this->posxup;
117
+		}
113 118
 		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
114
-		if ($this->page_largeur < 210) // To work with US executive format
119
+		if ($this->page_largeur < 210) {
120
+			// To work with US executive format
115 121
 		{
116 122
 			$this->posxpicture-=20;
123
+		}
117 124
 			$this->posxtva-=20;
118 125
 			$this->posxup-=20;
119 126
 			$this->posxqty-=20;
@@ -144,9 +151,13 @@  discard block
 block discarded – undo
144 151
 	{
145 152
 		global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
146 153
 
147
-		if (! is_object($outputlangs)) $outputlangs=$langs;
154
+		if (! is_object($outputlangs)) {
155
+			$outputlangs=$langs;
156
+		}
148 157
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
149
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
158
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
159
+			$outputlangs->charset_output='ISO-8859-1';
160
+		}
150 161
 
151 162
 		$outputlangs->load("main");
152 163
 		$outputlangs->load("dict");
@@ -162,7 +173,9 @@  discard block
 block discarded – undo
162 173
 		{
163 174
 			for ($i = 0 ; $i < $nblignes ; $i++)
164 175
 			{
165
-				if (empty($object->lines[$i]->fk_product)) continue;
176
+				if (empty($object->lines[$i]->fk_product)) {
177
+					continue;
178
+				}
166 179
 
167 180
 				$objphoto = new Product($this->db);
168 181
 				$objphoto->fetch($object->lines[$i]->fk_product);
@@ -179,10 +192,14 @@  discard block
 block discarded – undo
179 192
 					break;
180 193
 				}
181 194
 
182
-				if ($realpath) $realpatharray[$i]=$realpath;
195
+				if ($realpath) {
196
+					$realpatharray[$i]=$realpath;
197
+				}
183 198
 			}
184 199
 		}
185
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
200
+		if (count($realpatharray) == 0) {
201
+			$this->posxpicture=$this->posxtva;
202
+		}
186 203
 
187 204
 		if ($conf->facture->dir_output)
188 205
 		{
@@ -199,8 +216,7 @@  discard block
 block discarded – undo
199 216
 			{
200 217
 				$dir = $conf->facture->dir_output;
201 218
 				$file = $dir . "/SPECIMEN.pdf";
202
-			}
203
-			else
219
+			} else
204 220
 			{
205 221
 				$objectref = dol_sanitizeFileName($object->ref);
206 222
 				$dir = $conf->facture->dir_output . "/" . $objectref;
@@ -259,7 +275,9 @@  discard block
 block discarded – undo
259 275
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
260 276
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
261 277
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Invoice"));
262
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
278
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
279
+					$pdf->SetCompression(false);
280
+				}
263 281
 
264 282
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
265 283
 
@@ -283,7 +301,9 @@  discard block
 block discarded – undo
283 301
 
284 302
 				// New page
285 303
 				$pdf->AddPage();
286
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
304
+				if (! empty($tplidx)) {
305
+					$pdf->useTemplate($tplidx);
306
+				}
287 307
 				$pagenb++;
288 308
 
289 309
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
@@ -306,7 +326,9 @@  discard block
 block discarded – undo
306 326
 						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
307 327
 						$salerepobj=new User($this->db);
308 328
 						$salerepobj->fetch($salereparray[0]['id']);
309
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
329
+						if (! empty($salerepobj->signature)) {
330
+							$notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
331
+						}
310 332
 					}
311 333
 				}
312 334
 				if ($notetoshow)
@@ -324,8 +346,7 @@  discard block
 block discarded – undo
324 346
 
325 347
 					$tab_height = $tab_height - $height_note;
326 348
 					$tab_top = $nexY+6;
327
-				}
328
-				else
349
+				} else
329 350
 				{
330 351
 					$height_note=0;
331 352
 				}
@@ -409,7 +430,9 @@  discard block
 block discarded – undo
409 430
 
410 431
 					// Define size of image if we need it
411 432
 					$imglinesize=array();
412
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
433
+					if (! empty($realpatharray[$i])) {
434
+						$imglinesize=pdf_getSizeForImage($realpatharray[$i]);
435
+					}
413 436
 
414 437
 					$pdf->setTopMargin($tab_top_newpage);
415 438
 					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
@@ -420,11 +443,17 @@  discard block
 block discarded – undo
420 443
 					$posYAfterDescription=0;
421 444
 
422 445
 					// We start with Photo of product line
423
-					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
446
+					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) {
447
+						// If photo too high, we moved completely on new page
424 448
 					{
425 449
 						$pdf->AddPage('','',true);
426
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
427
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
450
+					}
451
+						if (! empty($tplidx)) {
452
+							$pdf->useTemplate($tplidx);
453
+						}
454
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
455
+							$this->_pagehead($pdf, $object, 0, $outputlangs);
456
+						}
428 457
 						$pdf->setPage($pageposbefore+1);
429 458
 
430 459
 						$curY = $tab_top_newpage;
@@ -445,9 +474,11 @@  discard block
 block discarded – undo
445 474
 					$pdf->startTransaction();
446 475
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
447 476
 					$pageposafter=$pdf->getPage();
448
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
477
+					if ($pageposafter > $pageposbefore) {
478
+						// There is a pagebreak
449 479
 					{
450 480
 						$pdf->rollbackTransaction(true);
481
+					}
451 482
 						$pageposafter=$pageposbefore;
452 483
 						//print $pageposafter.'-'.$pageposbefore;exit;
453 484
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -455,23 +486,27 @@  discard block
 block discarded – undo
455 486
 						$pageposafter=$pdf->getPage();
456 487
 						$posyafter=$pdf->GetY();
457 488
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
458
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
489
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
490
+							// There is no space left for total+free text
459 491
 						{
460 492
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
461 493
 							{
462 494
 								$pdf->AddPage('','',true);
463
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
464
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
495
+						}
496
+								if (! empty($tplidx)) {
497
+									$pdf->useTemplate($tplidx);
498
+								}
499
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
500
+									$this->_pagehead($pdf, $object, 0, $outputlangs);
501
+								}
465 502
 								$pdf->setPage($pageposafter+1);
466 503
 							}
467
-						}
468
-						else
504
+						} else
469 505
 						{
470 506
 							// We found a page break
471 507
 							$showpricebeforepagebreak=0;
472 508
 						}
473
-					}
474
-					else	// No pagebreak
509
+					} else	// No pagebreak
475 510
 					{
476 511
 						$pdf->commitTransaction();
477 512
 					}
@@ -562,29 +597,43 @@  discard block
 block discarded – undo
562 597
 					$localtax1_type=$object->lines[$i]->localtax1_type;
563 598
 					$localtax2_type=$object->lines[$i]->localtax2_type;
564 599
 
565
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
566
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
567
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
600
+					if ($object->remise_percent) {
601
+						$tvaligne-=($tvaligne*$object->remise_percent)/100;
602
+					}
603
+					if ($object->remise_percent) {
604
+						$localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
605
+					}
606
+					if ($object->remise_percent) {
607
+						$localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
608
+					}
568 609
 
569 610
 					$vatrate=(string) $object->lines[$i]->tva_tx;
570 611
 
571 612
 					// Retrieve type from database for backward compatibility with old records
572 613
 					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
573
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
614
+					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) {
615
+						// and there is local tax
574 616
 					{
575 617
 						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0, $object->thirdparty, $mysoc);
618
+					}
576 619
 						$localtax1_type = $localtaxtmp_array[0];
577 620
 						$localtax2_type = $localtaxtmp_array[2];
578 621
 					}
579 622
 
580 623
 				    // retrieve global local tax
581
-					if ($localtax1_type && $localtax1ligne != 0)
582
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
583
-					if ($localtax2_type && $localtax2ligne != 0)
584
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
624
+					if ($localtax1_type && $localtax1ligne != 0) {
625
+											$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
626
+					}
627
+					if ($localtax2_type && $localtax2ligne != 0) {
628
+											$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
629
+					}
585 630
 
586
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
587
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]='';
631
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
632
+						$vatrate.='*';
633
+					}
634
+					if (! isset($this->tva[$vatrate])) {
635
+						$this->tva[$vatrate]='';
636
+					}
588 637
 
589 638
 					if (!empty($object->lines[$i]->TTotal_tva))
590 639
 					{
@@ -592,13 +641,16 @@  discard block
 block discarded – undo
592 641
 						{
593 642
 							$this->tva[$vatrate] += $tvaligne;
594 643
 						}
595
-					}
596
-					else {
644
+					} else {
597 645
 						// standard
598
-                        if(!empty($tvaligne)) $this->tva[$vatrate] += $tvaligne;
646
+                        if(!empty($tvaligne)) {
647
+                        	$this->tva[$vatrate] += $tvaligne;
648
+                        }
599 649
 					}
600 650
 
601
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
651
+					if ($posYAfterImage > $posYAfterDescription) {
652
+						$nexY=$posYAfterImage;
653
+					}
602 654
 
603 655
 					// Add line
604 656
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
@@ -619,8 +671,7 @@  discard block
 block discarded – undo
619 671
 						if ($pagenb == 1)
620 672
 						{
621 673
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
622
-						}
623
-						else
674
+						} else
624 675
 						{
625 676
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
626 677
 						}
@@ -628,24 +679,29 @@  discard block
 block discarded – undo
628 679
 						$pagenb++;
629 680
 						$pdf->setPage($pagenb);
630 681
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
631
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
682
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
683
+							$this->_pagehead($pdf, $object, 0, $outputlangs);
684
+						}
632 685
 					}
633 686
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
634 687
 					{
635 688
 						if ($pagenb == 1)
636 689
 						{
637 690
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
638
-						}
639
-						else
691
+						} else
640 692
 						{
641 693
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
642 694
 						}
643 695
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
644 696
 						// New page
645 697
 						$pdf->AddPage();
646
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
698
+						if (! empty($tplidx)) {
699
+							$pdf->useTemplate($tplidx);
700
+						}
647 701
 						$pagenb++;
648
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
702
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
703
+							$this->_pagehead($pdf, $object, 0, $outputlangs);
704
+						}
649 705
 					}
650 706
 				}
651 707
 
@@ -654,8 +710,7 @@  discard block
 block discarded – undo
654 710
 				{
655 711
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
656 712
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
657
-				}
658
-				else
713
+				} else
659 714
 				{
660 715
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
661 716
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -677,7 +732,9 @@  discard block
 block discarded – undo
677 732
 
678 733
 				// Pied de page
679 734
 				$this->_pagefoot($pdf,$object,$outputlangs);
680
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
735
+				if (method_exists($pdf,'AliasNbPages')) {
736
+					$pdf->AliasNbPages();
737
+				}
681 738
 
682 739
 				$pdf->Close();
683 740
 
@@ -689,18 +746,17 @@  discard block
 block discarded – undo
689 746
 				global $action;
690 747
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
691 748
 
692
-				if (! empty($conf->global->MAIN_UMASK))
693
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
749
+				if (! empty($conf->global->MAIN_UMASK)) {
750
+								@chmod($file, octdec($conf->global->MAIN_UMASK));
751
+				}
694 752
 
695 753
 				return 1;   // Pas d'erreur
696
-			}
697
-			else
754
+			} else
698 755
 			{
699 756
 				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
700 757
 				return 0;
701 758
 			}
702
-		}
703
-		else
759
+		} else
704 760
 		{
705 761
 			$this->error=$langs->trans("ErrorConstantNotDefined","FAC_OUTPUTDIR");
706 762
 			return 0;
@@ -724,21 +780,27 @@  discard block
 block discarded – undo
724 780
 		global $conf;
725 781
 
726 782
         $sign=1;
727
-        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
783
+        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
784
+        	$sign=-1;
785
+        }
728 786
 
729 787
         $tab3_posx = 120;
730 788
 		$tab3_top = $posy + 8;
731 789
 		$tab3_width = 80;
732 790
 		$tab3_height = 4;
733
-		if ($this->page_largeur < 210) // To work with US executive format
791
+		if ($this->page_largeur < 210) {
792
+			// To work with US executive format
734 793
 		{
735 794
 			$tab3_posx -= 20;
736 795
 		}
796
+		}
737 797
 
738 798
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
739 799
 
740 800
 		$title=$outputlangs->transnoentities("PaymentsAlreadyDone");
741
-		if ($object->type == 2) $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone");
801
+		if ($object->type == 2) {
802
+			$title=$outputlangs->transnoentities("PaymentsBackAlreadyDone");
803
+		}
742 804
 
743 805
 		$pdf->SetFont('','', $default_font_size - 3);
744 806
 		$pdf->SetXY($tab3_posx, $tab3_top - 4);
@@ -779,9 +841,13 @@  discard block
 block discarded – undo
779 841
 				$y+=3;
780 842
 				$obj = $this->db->fetch_object($resql);
781 843
 
782
-				if ($obj->type == 2) $text=$outputlangs->trans("CreditNote");
783
-				elseif ($obj->type == 3) $text=$outputlangs->trans("Deposit");
784
-				else $text=$outputlangs->trans("UnknownType");
844
+				if ($obj->type == 2) {
845
+					$text=$outputlangs->trans("CreditNote");
846
+				} elseif ($obj->type == 3) {
847
+					$text=$outputlangs->trans("Deposit");
848
+				} else {
849
+					$text=$outputlangs->trans("UnknownType");
850
+				}
785 851
 
786 852
 				$invoice->fetch($obj->fk_facture_source);
787 853
 
@@ -798,8 +864,7 @@  discard block
 block discarded – undo
798 864
 
799 865
 				$i++;
800 866
 			}
801
-		}
802
-		else
867
+		} else
803 868
 		{
804 869
 			$this->error=$this->db->lasterror();
805 870
 			return -1;
@@ -836,8 +901,7 @@  discard block
 block discarded – undo
836 901
 
837 902
 				$i++;
838 903
 			}
839
-		}
840
-		else
904
+		} else
841 905
 		{
842 906
 			$this->error=$this->db->lasterror();
843 907
 			return -1;
@@ -1017,7 +1081,9 @@  discard block
 block discarded – undo
1017 1081
 		global $conf,$mysoc;
1018 1082
 
1019 1083
         $sign=1;
1020
-        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
1084
+        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1085
+        	$sign=-1;
1086
+        }
1021 1087
 
1022 1088
         $default_font_size = pdf_getPDFFontSize($outputlangs);
1023 1089
 
@@ -1027,10 +1093,12 @@  discard block
 block discarded – undo
1027 1093
 
1028 1094
 		// Tableau total
1029 1095
 		$col1x = 120; $col2x = 170;
1030
-		if ($this->page_largeur < 210) // To work with US executive format
1096
+		if ($this->page_largeur < 210) {
1097
+			// To work with US executive format
1031 1098
 		{
1032 1099
 			$col2x-=20;
1033 1100
 		}
1101
+		}
1034 1102
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1035 1103
 
1036 1104
 		$useborder=0;
@@ -1053,23 +1121,26 @@  discard block
 block discarded – undo
1053 1121
 			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull)
1054 1122
 			{
1055 1123
 				// Nothing to do
1056
-			}
1057
-			else
1124
+			} else
1058 1125
 			{
1059 1126
 				//Local tax 1 before VAT
1060 1127
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1061 1128
 				//{
1062 1129
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1063 1130
 					{
1064
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1131
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1132
+							continue;
1133
+						}
1065 1134
 
1066 1135
 						foreach( $localtax_rate as $tvakey => $tvaval )
1067 1136
 						{
1068
-							if ($tvakey!=0)    // On affiche pas taux 0
1137
+							if ($tvakey!=0) {
1138
+								// On affiche pas taux 0
1069 1139
 							{
1070 1140
 								//$this->atleastoneratenotnull++;
1071 1141
 
1072 1142
 								$index++;
1143
+							}
1073 1144
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1074 1145
 
1075 1146
 								$tvacompl='';
@@ -1094,17 +1165,21 @@  discard block
 block discarded – undo
1094 1165
 				//{
1095 1166
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1096 1167
 					{
1097
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1168
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1169
+							continue;
1170
+						}
1098 1171
 
1099 1172
 						foreach( $localtax_rate as $tvakey => $tvaval )
1100 1173
 						{
1101
-							if ($tvakey!=0)    // On affiche pas taux 0
1174
+							if ($tvakey!=0) {
1175
+								// On affiche pas taux 0
1102 1176
 							{
1103 1177
 								//$this->atleastoneratenotnull++;
1104 1178
 
1105 1179
 
1106 1180
 
1107 1181
 								$index++;
1182
+							}
1108 1183
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1109 1184
 
1110 1185
 								$tvacompl='';
@@ -1127,9 +1202,11 @@  discard block
 block discarded – undo
1127 1202
 				// VAT
1128 1203
 				foreach($this->tva as $tvakey => $tvaval)
1129 1204
 				{
1130
-					if ($tvakey > 0)    // On affiche pas taux 0
1205
+					if ($tvakey > 0) {
1206
+						// On affiche pas taux 0
1131 1207
 					{
1132 1208
 						$this->atleastoneratenotnull++;
1209
+					}
1133 1210
 
1134 1211
 						$index++;
1135 1212
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1154,15 +1231,19 @@  discard block
 block discarded – undo
1154 1231
 				//{
1155 1232
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1156 1233
 					{
1157
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1234
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1235
+							continue;
1236
+						}
1158 1237
 
1159 1238
 						foreach( $localtax_rate as $tvakey => $tvaval )
1160 1239
 						{
1161
-							if ($tvakey != 0)    // On affiche pas taux 0
1240
+							if ($tvakey != 0) {
1241
+								// On affiche pas taux 0
1162 1242
 							{
1163 1243
 								//$this->atleastoneratenotnull++;
1164 1244
 
1165 1245
 								$index++;
1246
+							}
1166 1247
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1167 1248
 
1168 1249
 								$tvacompl='';
@@ -1186,16 +1267,20 @@  discard block
 block discarded – undo
1186 1267
 				//{
1187 1268
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1188 1269
 					{
1189
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1270
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1271
+							continue;
1272
+						}
1190 1273
 
1191 1274
 						foreach( $localtax_rate as $tvakey => $tvaval )
1192 1275
 						{
1193 1276
 						    // retrieve global local tax
1194
-							if ($tvakey != 0)    // On affiche pas taux 0
1277
+							if ($tvakey != 0) {
1278
+								// On affiche pas taux 0
1195 1279
 							{
1196 1280
 								//$this->atleastoneratenotnull++;
1197 1281
 
1198 1282
 								$index++;
1283
+							}
1199 1284
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1200 1285
 
1201 1286
 								$tvacompl='';
@@ -1245,7 +1330,9 @@  discard block
 block discarded – undo
1245 1330
 		$depositsamount=$object->getSumDepositsUsed();
1246 1331
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
1247 1332
 		$resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1248
-		if ($object->paye) $resteapayer=0;
1333
+		if ($object->paye) {
1334
+			$resteapayer=0;
1335
+		}
1249 1336
 
1250 1337
 		if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0)
1251 1338
 		{
@@ -1314,7 +1401,9 @@  discard block
 block discarded – undo
1314 1401
 
1315 1402
 		// Force to disable hidetop and hidebottom
1316 1403
 		$hidebottom=0;
1317
-		if ($hidetop) $hidetop=-1;
1404
+		if ($hidetop) {
1405
+			$hidetop=-1;
1406
+		}
1318 1407
 
1319 1408
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1320 1409
 
@@ -1329,7 +1418,9 @@  discard block
 block discarded – undo
1329 1418
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1330 1419
 
1331 1420
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1332
-			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1421
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1422
+				$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1423
+			}
1333 1424
 		}
1334 1425
 
1335 1426
 		$pdf->SetDrawColor(128,128,128);
@@ -1444,16 +1535,14 @@  discard block
 block discarded – undo
1444 1535
 			{
1445 1536
 			    $height=pdf_getHeightForLogo($logo);
1446 1537
 				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1447
-			}
1448
-			else
1538
+			} else
1449 1539
 			{
1450 1540
 				$pdf->SetTextColor(200,0,0);
1451 1541
 				$pdf->SetFont('','B',$default_font_size - 2);
1452 1542
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1453 1543
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1454 1544
 			}
1455
-		}
1456
-		else
1545
+		} else
1457 1546
 		{
1458 1547
 			$text=$this->emetteur->name;
1459 1548
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1463,10 +1552,18 @@  discard block
 block discarded – undo
1463 1552
 		$pdf->SetXY($posx,$posy);
1464 1553
 		$pdf->SetTextColor(0,0,60);
1465 1554
 		$title=$outputlangs->transnoentities("Invoice");
1466
-		if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement");
1467
-		if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir");
1468
-		if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit");
1469
-		if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProFormat");
1555
+		if ($object->type == 1) {
1556
+			$title=$outputlangs->transnoentities("InvoiceReplacement");
1557
+		}
1558
+		if ($object->type == 2) {
1559
+			$title=$outputlangs->transnoentities("InvoiceAvoir");
1560
+		}
1561
+		if ($object->type == 3) {
1562
+			$title=$outputlangs->transnoentities("InvoiceDeposit");
1563
+		}
1564
+		if ($object->type == 4) {
1565
+			$title=$outputlangs->transnoentities("InvoiceProFormat");
1566
+		}
1470 1567
 		$pdf->MultiCell(100, 3, $title, '', 'R');
1471 1568
 
1472 1569
 		$pdf->SetFont('','B',$default_font_size);
@@ -1553,7 +1650,9 @@  discard block
 block discarded – undo
1553 1650
 			// Show sender
1554 1651
 			$posy=42;
1555 1652
 			$posx=$this->marge_gauche;
1556
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1653
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1654
+				$posx=$this->page_largeur-$this->marge_droite-80;
1655
+			}
1557 1656
 			$hautcadre=40;
1558 1657
 
1559 1658
 			// Show sender frame
@@ -1592,11 +1691,13 @@  discard block
 block discarded – undo
1592 1691
 			if (! empty($usecontact))
1593 1692
 			{
1594 1693
 				// On peut utiliser le nom de la societe du contact
1595
-				if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1596
-				else $socname = $object->thirdparty->name;
1694
+				if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1695
+					$socname = $object->contact->socname;
1696
+				} else {
1697
+					$socname = $object->thirdparty->name;
1698
+				}
1597 1699
 				$carac_client_name=$outputlangs->convToOutputCharset($socname);
1598
-			}
1599
-			else
1700
+			} else
1600 1701
 			{
1601 1702
 				$carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name);
1602 1703
 			}
@@ -1605,10 +1706,15 @@  discard block
 block discarded – undo
1605 1706
 
1606 1707
 			// Show recipient
1607 1708
 			$widthrecbox=100;
1608
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1709
+			if ($this->page_largeur < 210) {
1710
+				$widthrecbox=84;
1711
+			}
1712
+			// To work with US executive format
1609 1713
 			$posy=42;
1610 1714
 			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1611
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1715
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1716
+				$posx=$this->marge_gauche;
1717
+			}
1612 1718
 
1613 1719
 			// Show recipient frame
1614 1720
 			$pdf->SetTextColor(0,0,0);
Please login to merge, or discard this patch.
core/modules/commande/doc/pdf_einstein_subtotal.modules.php 3 patches
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -38,23 +38,23 @@  discard block
 block discarded – undo
38 38
  */
39 39
 class pdf_einstein_subtotal extends ModelePDFCommandes
40 40
 {
41
-    var $db;
42
-    var $name;
43
-    var $description;
44
-    var $type;
41
+	var $db;
42
+	var $name;
43
+	var $description;
44
+	var $type;
45 45
 
46
-    var $phpmin = array(4,3,0); // Minimum version of PHP required by module
47
-    var $version = 'dolibarr';
46
+	var $phpmin = array(4,3,0); // Minimum version of PHP required by module
47
+	var $version = 'dolibarr';
48 48
 
49
-    var $page_largeur;
50
-    var $page_hauteur;
51
-    var $format;
49
+	var $page_largeur;
50
+	var $page_hauteur;
51
+	var $format;
52 52
 	var $marge_gauche;
53 53
 	var	$marge_droite;
54 54
 	var	$marge_haute;
55 55
 	var	$marge_basse;
56 56
 
57
-    var $emetteur;	// Objet societe qui emet
57
+	var $emetteur;	// Objet societe qui emet
58 58
 
59 59
 
60 60
 	/**
@@ -129,15 +129,15 @@  discard block
 block discarded – undo
129 129
 	}
130 130
 
131 131
 	/**
132
-     *  Function to build pdf onto disk
133
-     *
134
-     *  @param		Object		$object				Object to generate
135
-     *  @param		Translate	$outputlangs		Lang output object
136
-     *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
137
-     *  @param		int			$hidedetails		Do not show line details
138
-     *  @param		int			$hidedesc			Do not show desc
139
-     *  @param		int			$hideref			Do not show ref
140
-     *  @return     int             			1=OK, 0=KO
132
+	 *  Function to build pdf onto disk
133
+	 *
134
+	 *  @param		Object		$object				Object to generate
135
+	 *  @param		Translate	$outputlangs		Lang output object
136
+	 *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
137
+	 *  @param		int			$hidedetails		Do not show line details
138
+	 *  @param		int			$hidedesc			Do not show desc
139
+	 *  @param		int			$hideref			Do not show ref
140
+	 *  @return     int             			1=OK, 0=KO
141 141
 	 */
142 142
 	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
143 143
 	{
@@ -159,13 +159,13 @@  discard block
 block discarded – undo
159 159
 
160 160
 		if ($conf->commande->dir_output)
161 161
 		{
162
-            $object->fetch_thirdparty();
162
+			$object->fetch_thirdparty();
163 163
 			if(!empty($object->client) ){
164 164
 				$object->thirdparty = $object->client;
165 165
 			}
166
-            $deja_regle = "";
166
+			$deja_regle = "";
167 167
 
168
-            // Definition of $dir and $file
168
+			// Definition of $dir and $file
169 169
 			if ($object->specimen)
170 170
 			{
171 171
 				$dir = $conf->commande->dir_output;
@@ -204,22 +204,22 @@  discard block
 block discarded – undo
204 204
 				$pdf=pdf_getInstance($this->format);
205 205
 				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
206 206
 				$heightforinfotot = 50;	// Height reserved to output the info and total part
207
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
208
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
209
-                $pdf->SetAutoPageBreak(1,0);
210
-
211
-                if (class_exists('TCPDF'))
212
-                {
213
-                    $pdf->setPrintHeader(false);
214
-                    $pdf->setPrintFooter(false);
215
-                }
216
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
217
-                // Set path to the background PDF File
218
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
219
-                {
220
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
221
-                    $tplidx = $pdf->importPage(1);
222
-                }
207
+				$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
208
+				$heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
209
+				$pdf->SetAutoPageBreak(1,0);
210
+
211
+				if (class_exists('TCPDF'))
212
+				{
213
+					$pdf->setPrintHeader(false);
214
+					$pdf->setPrintFooter(false);
215
+				}
216
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
217
+				// Set path to the background PDF File
218
+				if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
219
+				{
220
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
221
+					$tplidx = $pdf->importPage(1);
222
+				}
223 223
 
224 224
 				$pdf->Open();
225 225
 				$pagenb=0;
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 						$localtax2_type = $localtaxtmp_array[2];
524 524
 					}
525 525
 
526
-				    // retrieve global local tax
526
+					// retrieve global local tax
527 527
 					if ($localtax1_type && $localtax1ligne != 0)
528 528
 						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
529 529
 					if ($localtax2_type && $localtax2ligne != 0)
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 					}
542 542
 					else {
543 543
 						// standard
544
-                        if(!empty($tvaligne)) $this->tva[$vatrate] += $tvaligne;
544
+						if(!empty($tvaligne)) $this->tva[$vatrate] += $tvaligne;
545 545
 					}
546 546
 
547 547
 					// Add line
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 
656 656
 	/**
657 657
 	 *  Show payments table
658
-     *
658
+	 *
659 659
 	 *  @param	PDF			$pdf     		Object PDF
660 660
 	 *  @param  Object		$object			Object order
661 661
 	 *	@param	int			$posy			Position y in PDF
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 
685 685
 		$pdf->SetFont('','', $default_font_size - 1);
686 686
 
687
-        // If France, show VAT mention if not applicable
687
+		// If France, show VAT mention if not applicable
688 688
 		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
689 689
 		{
690 690
 			$pdf->SetFont('','B', $default_font_size - 2);
@@ -713,8 +713,8 @@  discard block
 block discarded – undo
713 713
 			$posy=$pdf->GetY()+3;
714 714
 		}
715 715
 
716
-        // Check a payment mode is defined
717
-        /* Not used with orders
716
+		// Check a payment mode is defined
717
+		/* Not used with orders
718 718
 		if (empty($object->mode_reglement_code)
719 719
         	&& ! $conf->global->FACTURE_CHQ_NUMBER
720 720
         	&& ! $conf->global->FACTURE_RIB_NUMBER)
@@ -740,10 +740,10 @@  discard block
 block discarded – undo
740 740
             $posy=$pdf->GetY()+1;
741 741
 		}*/
742 742
 
743
-	    // Show planed date of delivery
744
-        if (! empty($object->date_livraison))
743
+		// Show planed date of delivery
744
+		if (! empty($object->date_livraison))
745 745
 		{
746
-            $outputlangs->load("sendings");
746
+			$outputlangs->load("sendings");
747 747
 			$pdf->SetFont('','B', $default_font_size - 2);
748 748
 			$pdf->SetXY($this->marge_gauche, $posy);
749 749
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
@@ -753,9 +753,9 @@  discard block
 block discarded – undo
753 753
 			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
754 754
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
755 755
 
756
-            $posy=$pdf->GetY()+1;
756
+			$posy=$pdf->GetY()+1;
757 757
 		}
758
-        elseif ($object->availability_code || $object->availability)    // Show availability conditions
758
+		elseif ($object->availability_code || $object->availability)    // Show availability conditions
759 759
 		{
760 760
 			$pdf->SetFont('','B', $default_font_size - 2);
761 761
 			$pdf->SetXY($this->marge_gauche, $posy);
@@ -771,70 +771,70 @@  discard block
 block discarded – undo
771 771
 			$posy=$pdf->GetY()+1;
772 772
 		}
773 773
 
774
-      	// Show payment mode
775
-        if ($object->mode_reglement_code
776
-        	 && $object->mode_reglement_code != 'CHQ'
777
-           	 && $object->mode_reglement_code != 'VIR')
778
-           	 {
779
-	            $pdf->SetFont('','B', $default_font_size - 2);
780
-	            $pdf->SetXY($this->marge_gauche, $posy);
781
-	            $titre = $outputlangs->transnoentities("PaymentMode").':';
782
-	            $pdf->MultiCell(80, 5, $titre, 0, 'L');
774
+	  	// Show payment mode
775
+		if ($object->mode_reglement_code
776
+			 && $object->mode_reglement_code != 'CHQ'
777
+		   	 && $object->mode_reglement_code != 'VIR')
778
+		   	 {
779
+				$pdf->SetFont('','B', $default_font_size - 2);
780
+				$pdf->SetXY($this->marge_gauche, $posy);
781
+				$titre = $outputlangs->transnoentities("PaymentMode").':';
782
+				$pdf->MultiCell(80, 5, $titre, 0, 'L');
783 783
 
784 784
 				$pdf->SetFont('','', $default_font_size - 2);
785
-	            $pdf->SetXY($posxval, $posy);
786
-	            $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
787
-	            $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
785
+				$pdf->SetXY($posxval, $posy);
786
+				$lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
787
+				$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
788 788
 
789
-	            $posy=$pdf->GetY()+2;
790
-           	 }
789
+				$posy=$pdf->GetY()+2;
790
+		   	 }
791 791
 
792 792
 		// Show payment mode CHQ
793
-        if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
794
-        {
795
-        	// Si mode reglement non force ou si force a CHQ
796
-	        if (! empty($conf->global->FACTURE_CHQ_NUMBER))
797
-	        {
798
-	            if ($conf->global->FACTURE_CHQ_NUMBER > 0)
799
-	            {
800
-	                $account = new Account($this->db);
801
-	                $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
802
-
803
-	                $pdf->SetXY($this->marge_gauche, $posy);
804
-	                $pdf->SetFont('','B', $default_font_size - 3);
805
-	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
806
-		            $posy=$pdf->GetY()+1;
807
-
808
-		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
809
-		            {
810
-		                $pdf->SetXY($this->marge_gauche, $posy);
811
-		                $pdf->SetFont('','', $default_font_size - 3);
812
-		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
813
-			            $posy=$pdf->GetY()+2;
814
-		            }
815
-	            }
816
-	            if ($conf->global->FACTURE_CHQ_NUMBER == -1)
817
-	            {
818
-	                $pdf->SetXY($this->marge_gauche, $posy);
819
-	                $pdf->SetFont('','B', $default_font_size - 3);
820
-	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
821
-		            $posy=$pdf->GetY()+1;
822
-
823
-		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
824
-		            {
825
-			            $pdf->SetXY($this->marge_gauche, $posy);
826
-		                $pdf->SetFont('','', $default_font_size - 3);
827
-		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
828
-			            $posy=$pdf->GetY()+2;
829
-		            }
830
-	            }
831
-	        }
793
+		if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
794
+		{
795
+			// Si mode reglement non force ou si force a CHQ
796
+			if (! empty($conf->global->FACTURE_CHQ_NUMBER))
797
+			{
798
+				if ($conf->global->FACTURE_CHQ_NUMBER > 0)
799
+				{
800
+					$account = new Account($this->db);
801
+					$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
802
+
803
+					$pdf->SetXY($this->marge_gauche, $posy);
804
+					$pdf->SetFont('','B', $default_font_size - 3);
805
+					$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
806
+					$posy=$pdf->GetY()+1;
807
+
808
+					if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
809
+					{
810
+						$pdf->SetXY($this->marge_gauche, $posy);
811
+						$pdf->SetFont('','', $default_font_size - 3);
812
+						$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
813
+						$posy=$pdf->GetY()+2;
814
+					}
815
+				}
816
+				if ($conf->global->FACTURE_CHQ_NUMBER == -1)
817
+				{
818
+					$pdf->SetXY($this->marge_gauche, $posy);
819
+					$pdf->SetFont('','B', $default_font_size - 3);
820
+					$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
821
+					$posy=$pdf->GetY()+1;
822
+
823
+					if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
824
+					{
825
+						$pdf->SetXY($this->marge_gauche, $posy);
826
+						$pdf->SetFont('','', $default_font_size - 3);
827
+						$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
828
+						$posy=$pdf->GetY()+2;
829
+					}
830
+				}
831
+			}
832 832
 		}
833 833
 
834
-        // If payment mode not forced or forced to VIR, show payment with BAN
835
-        if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
836
-        {
837
-        	if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
834
+		// If payment mode not forced or forced to VIR, show payment with BAN
835
+		if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
836
+		{
837
+			if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
838 838
 			{
839 839
 				$bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank);
840 840
 				$account = new Account($this->db);
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
 
848 848
 				$posy+=2;
849 849
 			}
850
-        }
850
+		}
851 851
 
852 852
 		return $posy;
853 853
 	}
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 	 */
866 866
 	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
867 867
 	{
868
-	    global $conf,$mysoc;
868
+		global $conf,$mysoc;
869 869
 
870 870
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
871 871
 
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 		$pdf->SetFont('','', $default_font_size - 1);
875 875
 
876 876
 		// Tableau total
877
-        $col1x = 120; $col2x = 170;
877
+		$col1x = 120; $col2x = 170;
878 878
 		if ($this->page_largeur < 210) // To work with US executive format
879 879
 		{
880 880
 			$col2x-=20;
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 							}
936 936
 						}
937 937
 					}
938
-	      		//}
938
+		  		//}
939 939
 				//Local tax 2 before VAT
940 940
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
941 941
 				//{
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 							}
1027 1027
 						}
1028 1028
 					}
1029
-	      		//}
1029
+		  		//}
1030 1030
 				//Local tax 2 after VAT
1031 1031
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1032 1032
 				//{
@@ -1075,8 +1075,8 @@  discard block
 block discarded – undo
1075 1075
 
1076 1076
 		$pdf->SetTextColor(0,0,0);
1077 1077
 
1078
-        $creditnoteamount=0;
1079
-        $depositsamount=0;
1078
+		$creditnoteamount=0;
1079
+		$depositsamount=0;
1080 1080
 		//$creditnoteamount=$object->getSumCreditNotesUsed();
1081 1081
 		//$depositsamount=$object->getSumDepositsUsed();
1082 1082
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 		// Show Draft Watermark
1231 1231
 		if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
1232 1232
 		{
1233
-            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
1233
+			pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
1234 1234
 		}
1235 1235
 
1236 1236
 		$pdf->SetTextColor(0,0,60);
@@ -1247,8 +1247,8 @@  discard block
 block discarded – undo
1247 1247
 		{
1248 1248
 			if (is_readable($logo))
1249 1249
 			{
1250
-			    $height=pdf_getHeightForLogo($logo);
1251
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1250
+				$height=pdf_getHeightForLogo($logo);
1251
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1252 1252
 			}
1253 1253
 			else
1254 1254
 			{
@@ -1386,7 +1386,7 @@  discard block
 block discarded – undo
1386 1386
 
1387 1387
 	/**
1388 1388
 	 *   	Show footer of page. Need this->emetteur object
1389
-     *
1389
+	 *
1390 1390
 	 *   	@param	PDF			$pdf     			PDF
1391 1391
 	 * 		@param	Object		$object				Object to show
1392 1392
 	 *      @param	Translate	$outputlangs		Object lang for output
Please login to merge, or discard this patch.
Spacing   +384 added lines, -384 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  *	\brief      Fichier de la classe permettant de generer les commandes au modele Einstein
27 27
  */
28 28
 
29
-require_once DOL_DOCUMENT_ROOT .'/core/modules/commande/modules_commande.php';
29
+require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
30 30
 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
31 31
 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
32 32
 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     var $description;
44 44
     var $type;
45 45
 
46
-    var $phpmin = array(4,3,0); // Minimum version of PHP required by module
46
+    var $phpmin = array(4, 3, 0); // Minimum version of PHP required by module
47 47
     var $version = 'dolibarr';
48 48
 
49 49
     var $page_largeur;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	var	$marge_haute;
55 55
 	var	$marge_basse;
56 56
 
57
-    var $emetteur;	// Objet societe qui emet
57
+    var $emetteur; // Objet societe qui emet
58 58
 
59 59
 
60 60
 	/**
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	function __construct($db)
66 66
 	{
67
-		global $conf,$langs,$mysoc;
67
+		global $conf, $langs, $mysoc;
68 68
 
69 69
 		$langs->load("main");
70 70
 		$langs->load("bills");
@@ -76,56 +76,56 @@  discard block
 block discarded – undo
76 76
 
77 77
 		// Dimension page pour format A4
78 78
 		$this->type = 'pdf';
79
-		$formatarray=pdf_getFormat();
79
+		$formatarray = pdf_getFormat();
80 80
 		$this->page_largeur = $formatarray['width'];
81 81
 		$this->page_hauteur = $formatarray['height'];
82
-		$this->format = array($this->page_largeur,$this->page_hauteur);
83
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
84
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
85
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
86
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
87
-
88
-		$this->option_logo = 1;                    // Affiche logo
89
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
90
-		$this->option_modereg = 1;                 // Affiche mode reglement
91
-		$this->option_condreg = 1;                 // Affiche conditions reglement
92
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
93
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
94
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
95
-		$this->option_credit_note = 0;             // Support credit notes
96
-		$this->option_freetext = 1;				   // Support add of a personalised text
97
-		$this->option_draft_watermark = 1;		   // Support add of a watermark on drafts
98
-
99
-		$this->franchise=!$mysoc->tva_assuj;
82
+		$this->format = array($this->page_largeur, $this->page_hauteur);
83
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
84
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
85
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
86
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
87
+
88
+		$this->option_logo = 1; // Affiche logo
89
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
90
+		$this->option_modereg = 1; // Affiche mode reglement
91
+		$this->option_condreg = 1; // Affiche conditions reglement
92
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
93
+		$this->option_multilang = 1; // Dispo en plusieurs langues
94
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
95
+		$this->option_credit_note = 0; // Support credit notes
96
+		$this->option_freetext = 1; // Support add of a personalised text
97
+		$this->option_draft_watermark = 1; // Support add of a watermark on drafts
98
+
99
+		$this->franchise = !$mysoc->tva_assuj;
100 100
 
101 101
 		// Get source company
102
-		$this->emetteur=$mysoc;
103
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
102
+		$this->emetteur = $mysoc;
103
+		if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
104 104
 
105 105
 		// Define position of columns
106
-		$this->posxdesc=$this->marge_gauche+1;
107
-		$this->posxtva=112;
108
-		$this->posxup=126;
109
-		$this->posxqty=145;
110
-		$this->posxdiscount=162;
111
-		$this->postotalht=174;
112
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
113
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
106
+		$this->posxdesc = $this->marge_gauche + 1;
107
+		$this->posxtva = 112;
108
+		$this->posxup = 126;
109
+		$this->posxqty = 145;
110
+		$this->posxdiscount = 162;
111
+		$this->postotalht = 174;
112
+		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva = $this->posxup;
113
+		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
114 114
 		if ($this->page_largeur < 210) // To work with US executive format
115 115
 		{
116
-			$this->posxpicture-=20;
117
-			$this->posxtva-=20;
118
-			$this->posxup-=20;
119
-			$this->posxqty-=20;
120
-			$this->posxdiscount-=20;
121
-			$this->postotalht-=20;
116
+			$this->posxpicture -= 20;
117
+			$this->posxtva -= 20;
118
+			$this->posxup -= 20;
119
+			$this->posxqty -= 20;
120
+			$this->posxdiscount -= 20;
121
+			$this->postotalht -= 20;
122 122
 		}
123 123
 
124
-		$this->tva=array();
125
-		$this->localtax1=array();
126
-		$this->localtax2=array();
127
-		$this->atleastoneratenotnull=0;
128
-		$this->atleastonediscount=0;
124
+		$this->tva = array();
125
+		$this->localtax1 = array();
126
+		$this->localtax2 = array();
127
+		$this->atleastoneratenotnull = 0;
128
+		$this->atleastonediscount = 0;
129 129
 	}
130 130
 
131 131
 	/**
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
      *  @param		int			$hideref			Do not show ref
140 140
      *  @return     int             			1=OK, 0=KO
141 141
 	 */
142
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
142
+	function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
143 143
 	{
144
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager;
144
+		global $user, $langs, $conf, $mysoc, $db, $hookmanager;
145 145
 
146
-		if (! is_object($outputlangs)) $outputlangs=$langs;
146
+		if (!is_object($outputlangs)) $outputlangs = $langs;
147 147
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
148
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
148
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
149 149
 
150 150
 		$outputlangs->load("main");
151 151
 		$outputlangs->load("dict");
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		if ($conf->commande->dir_output)
161 161
 		{
162 162
             $object->fetch_thirdparty();
163
-			if(!empty($object->client) ){
163
+			if (!empty($object->client)) {
164 164
 				$object->thirdparty = $object->client;
165 165
 			}
166 166
             $deja_regle = "";
@@ -169,20 +169,20 @@  discard block
 block discarded – undo
169 169
 			if ($object->specimen)
170 170
 			{
171 171
 				$dir = $conf->commande->dir_output;
172
-				$file = $dir . "/SPECIMEN.pdf";
172
+				$file = $dir."/SPECIMEN.pdf";
173 173
 			}
174 174
 			else
175 175
 			{
176 176
 				$objectref = dol_sanitizeFileName($object->ref);
177
-				$dir = $conf->commande->dir_output . "/" . $objectref;
178
-				$file = $dir . "/" . $objectref . ".pdf";
177
+				$dir = $conf->commande->dir_output."/".$objectref;
178
+				$file = $dir."/".$objectref.".pdf";
179 179
 			}
180 180
 
181
-			if (! file_exists($dir))
181
+			if (!file_exists($dir))
182 182
 			{
183 183
 				if (dol_mkdir($dir) < 0)
184 184
 				{
185
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
185
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
186 186
 					return 0;
187 187
 				}
188 188
 			}
@@ -190,23 +190,23 @@  discard block
 block discarded – undo
190 190
 			if (file_exists($dir))
191 191
 			{
192 192
 				// Add pdfgeneration hook
193
-				if (! is_object($hookmanager))
193
+				if (!is_object($hookmanager))
194 194
 				{
195 195
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
196
-					$hookmanager=new HookManager($this->db);
196
+					$hookmanager = new HookManager($this->db);
197 197
 				}
198 198
 				$hookmanager->initHooks(array('pdfgeneration'));
199
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
199
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
200 200
 				global $action;
201
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
201
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
202 202
 
203 203
 				// Create pdf instance
204
-				$pdf=pdf_getInstance($this->format);
205
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
206
-				$heightforinfotot = 50;	// Height reserved to output the info and total part
207
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
208
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
209
-                $pdf->SetAutoPageBreak(1,0);
204
+				$pdf = pdf_getInstance($this->format);
205
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
206
+				$heightforinfotot = 50; // Height reserved to output the info and total part
207
+		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
208
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
209
+                $pdf->SetAutoPageBreak(1, 0);
210 210
 
211 211
                 if (class_exists('TCPDF'))
212 212
                 {
@@ -215,27 +215,27 @@  discard block
 block discarded – undo
215 215
                 }
216 216
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
217 217
                 // Set path to the background PDF File
218
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
218
+                if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
219 219
                 {
220 220
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
221 221
                     $tplidx = $pdf->importPage(1);
222 222
                 }
223 223
 
224 224
 				$pdf->Open();
225
-				$pagenb=0;
226
-				$pdf->SetDrawColor(128,128,128);
225
+				$pagenb = 0;
226
+				$pdf->SetDrawColor(128, 128, 128);
227 227
 
228 228
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
229 229
 				$pdf->SetSubject($outputlangs->transnoentities("Order"));
230 230
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
231 231
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
232 232
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order"));
233
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
233
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
234 234
 
235
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
235
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
236 236
 
237 237
 				// Positionne $this->atleastonediscount si on a au moins une remise
238
-				for ($i = 0 ; $i < $nblignes ; $i++)
238
+				for ($i = 0; $i < $nblignes; $i++)
239 239
 				{
240 240
 					if ($object->lines[$i]->remise_percent)
241 241
 					{
@@ -244,61 +244,61 @@  discard block
 block discarded – undo
244 244
 				}
245 245
 				if (empty($this->atleastonediscount))
246 246
 				{
247
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
248
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
249
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
250
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
251
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
247
+					$this->posxpicture += ($this->postotalht - $this->posxdiscount);
248
+					$this->posxtva += ($this->postotalht - $this->posxdiscount);
249
+					$this->posxup += ($this->postotalht - $this->posxdiscount);
250
+					$this->posxqty += ($this->postotalht - $this->posxdiscount);
251
+					$this->posxdiscount += ($this->postotalht - $this->posxdiscount);
252 252
 					//$this->postotalht;
253 253
 				}
254 254
 
255 255
 				// New page
256 256
 				$pdf->AddPage();
257
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
257
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
258 258
 				$pagenb++;
259 259
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
260
-				$pdf->SetFont('','', $default_font_size - 1);
261
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
262
-				$pdf->SetTextColor(0,0,0);
260
+				$pdf->SetFont('', '', $default_font_size - 1);
261
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
262
+				$pdf->SetTextColor(0, 0, 0);
263 263
 
264 264
 
265 265
 				$tab_top = 90;
266
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
266
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
267 267
 				$tab_height = 130;
268 268
 				$tab_height_newpage = 150;
269 269
 
270 270
 				// Affiche notes
271
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
272
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
271
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
272
+				if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
273 273
 				{
274 274
 					// Get first sale rep
275 275
 					if (is_object($object->thirdparty))
276 276
 					{
277
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
278
-						$salerepobj=new User($this->db);
277
+						$salereparray = $object->thirdparty->getSalesRepresentatives($user);
278
+						$salerepobj = new User($this->db);
279 279
 						$salerepobj->fetch($salereparray[0]['id']);
280
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
280
+						if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
281 281
 					}
282 282
 				}
283 283
 				if ($notetoshow)
284 284
 				{
285 285
 					$tab_top = 88;
286 286
 
287
-					$pdf->SetFont('','', $default_font_size - 1);
288
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
287
+					$pdf->SetFont('', '', $default_font_size - 1);
288
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
289 289
 					$nexY = $pdf->GetY();
290
-					$height_note=$nexY-$tab_top;
290
+					$height_note = $nexY - $tab_top;
291 291
 
292 292
 					// Rect prend une longueur en 3eme param
293
-					$pdf->SetDrawColor(192,192,192);
294
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
293
+					$pdf->SetDrawColor(192, 192, 192);
294
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
295 295
 
296 296
 					$tab_height = $tab_height - $height_note;
297
-					$tab_top = $nexY+6;
297
+					$tab_top = $nexY + 6;
298 298
 				}
299 299
 				else
300 300
 				{
301
-					$height_note=0;
301
+					$height_note = 0;
302 302
 				}
303 303
 
304 304
 				$iniY = $tab_top + 7;
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 				$TStack = array();
313 313
 
314 314
 				// Loop on each lines
315
-				for ($i = 0 ; $i < $nblignes ; $i++)
315
+				for ($i = 0; $i < $nblignes; $i++)
316 316
 				{
317 317
 					$package_qty = $TStack[count($TStack) - 1]['package_qty'];
318 318
 					$inPackage = count($TStack) > 0;
@@ -376,44 +376,44 @@  discard block
 block discarded – undo
376 376
 					}
377 377
 					
378 378
 					$curY = $nexY;
379
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
380
-					$pdf->SetTextColor(0,0,0);
379
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
380
+					$pdf->SetTextColor(0, 0, 0);
381 381
 
382 382
 					$pdf->setTopMargin($tab_top_newpage);
383
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
384
-					$pageposbefore=$pdf->getPage();
383
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
384
+					$pageposbefore = $pdf->getPage();
385 385
 
386 386
 					// Description of product line
387
-					$curX = $this->posxdesc-1;
387
+					$curX = $this->posxdesc - 1;
388 388
 
389
-					$showpricebeforepagebreak=1;
389
+					$showpricebeforepagebreak = 1;
390 390
 
391 391
 					$pdf->startTransaction();
392
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
393
-					$pageposafter=$pdf->getPage();
392
+					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
393
+					$pageposafter = $pdf->getPage();
394 394
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
395 395
 					{
396 396
 						$pdf->rollbackTransaction(true);
397
-						$pageposafter=$pageposbefore;
397
+						$pageposafter = $pageposbefore;
398 398
 						//print $pageposafter.'-'.$pageposbefore;exit;
399
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
400
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
401
-						$pageposafter=$pdf->getPage();
402
-						$posyafter=$pdf->GetY();
403
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
399
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
400
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
401
+						$pageposafter = $pdf->getPage();
402
+						$posyafter = $pdf->GetY();
403
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
404 404
 						{
405
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
405
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
406 406
 							{
407
-								$pdf->AddPage('','',true);
408
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
407
+								$pdf->AddPage('', '', true);
408
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
409 409
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
410
-								$pdf->setPage($pageposafter+1);
410
+								$pdf->setPage($pageposafter + 1);
411 411
 							}
412 412
 						}
413 413
 						else
414 414
 						{
415 415
 							// We found a page break
416
-							$showpricebeforepagebreak=0;
416
+							$showpricebeforepagebreak = 0;
417 417
 						}
418 418
 					}
419 419
 					else	// No pagebreak
@@ -422,17 +422,17 @@  discard block
 block discarded – undo
422 422
 					}
423 423
 
424 424
 					$nexY = $pdf->GetY();
425
-					$pageposafter=$pdf->getPage();
425
+					$pageposafter = $pdf->getPage();
426 426
 					$pdf->setPage($pageposbefore);
427 427
 					$pdf->setTopMargin($this->marge_haute);
428
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
428
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
429 429
 
430 430
 					// We suppose that a too long description is moved completely on next page
431 431
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
432 432
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
433 433
 					}
434 434
 
435
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
435
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
436 436
 
437 437
 					// VAT Rate
438 438
 					if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 						}
446 446
 
447 447
 						$pdf->SetXY($this->posxtva, $curY);
448
-						$pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R');
448
+						$pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 3, $vat_rate, 0, 'R');
449 449
 					}
450 450
 
451 451
 					// Unit price before discount
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 					}
457 457
 
458 458
 					$pdf->SetXY($this->posxup, $curY);
459
-					$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
459
+					$pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0);
460 460
 
461 461
 					// Booléen pour déterminer s'il s'agit d'une ligne de titre ou non
462 462
 					$isTitle = false;
@@ -478,14 +478,14 @@  discard block
 block discarded – undo
478 478
 					}
479 479
 					
480 480
 					$pdf->SetXY($this->posxqty, $curY);
481
-					$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R');	// Enough for 6 chars
481
+					$pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 3, $qty, 0, 'R'); // Enough for 6 chars
482 482
 
483 483
 					// Discount on line
484 484
 					if ($object->lines[$i]->remise_percent)
485 485
 					{
486
-						$pdf->SetXY($this->posxdiscount-2, $curY);
486
+						$pdf->SetXY($this->posxdiscount - 2, $curY);
487 487
 						$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
488
-						$pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
488
+						$pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
489 489
 					}
490 490
 
491 491
 					// Total HT line
@@ -496,41 +496,41 @@  discard block
 block discarded – undo
496 496
 					}
497 497
 
498 498
 					$pdf->SetXY($this->postotalht, $curY);
499
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
499
+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
500 500
 
501 501
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
502
-					$tvaligne=doubleval($object->lines[$i]->total_tva);
502
+					$tvaligne = doubleval($object->lines[$i]->total_tva);
503 503
 
504
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
505
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
506
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
507
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
508
-					$localtax1_type=$object->lines[$i]->localtax1_type;
509
-					$localtax2_type=$object->lines[$i]->localtax2_type;
504
+					$localtax1ligne = $object->lines[$i]->total_localtax1;
505
+					$localtax2ligne = $object->lines[$i]->total_localtax2;
506
+					$localtax1_rate = $object->lines[$i]->localtax1_tx;
507
+					$localtax2_rate = $object->lines[$i]->localtax2_tx;
508
+					$localtax1_type = $object->lines[$i]->localtax1_type;
509
+					$localtax2_type = $object->lines[$i]->localtax2_type;
510 510
 
511
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
512
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
513
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
511
+					if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
512
+					if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
513
+					if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
514 514
 
515
-					$vatrate=(string) $object->lines[$i]->tva_tx;
515
+					$vatrate = (string) $object->lines[$i]->tva_tx;
516 516
 					
517 517
 					// Retrieve type from database for backward compatibility with old records
518
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
519
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
518
+					if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
519
+					&& (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
520 520
 					{
521
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
521
+						$localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
522 522
 						$localtax1_type = $localtaxtmp_array[0];
523 523
 						$localtax2_type = $localtaxtmp_array[2];
524 524
 					}
525 525
 
526 526
 				    // retrieve global local tax
527 527
 					if ($localtax1_type && $localtax1ligne != 0)
528
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
528
+						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
529 529
 					if ($localtax2_type && $localtax2ligne != 0)
530
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
530
+						$this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
531 531
 
532
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
533
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
532
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
533
+					if (!isset($this->tva[$vatrate])) 				$this->tva[$vatrate] = 0;
534 534
 					
535 535
 					if (!empty($object->lines[$i]->TTotal_tva))
536 536
 					{
@@ -541,20 +541,20 @@  discard block
 block discarded – undo
541 541
 					}
542 542
 					else {
543 543
 						// standard
544
-                        if(!empty($tvaligne)) $this->tva[$vatrate] += $tvaligne;
544
+                        if (!empty($tvaligne)) $this->tva[$vatrate] += $tvaligne;
545 545
 					}
546 546
 
547 547
 					// Add line
548
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
548
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
549 549
 					{
550 550
 						$pdf->setPage($pageposafter);
551
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
551
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(210, 210, 210)));
552 552
 						//$pdf->SetDrawColor(190,190,200);
553
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
553
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
554 554
 						$pdf->SetLineStyle(array('dash'=>0));
555 555
 					}
556 556
 
557
-					$nexY+=2;    // Passe espace entre les lignes
557
+					$nexY += 2; // Passe espace entre les lignes
558 558
 
559 559
 					// Detect if some page were added automatically and output _tableau for past pages
560 560
 					while ($pagenb < $pageposafter)
@@ -568,13 +568,13 @@  discard block
 block discarded – undo
568 568
 						{
569 569
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
570 570
 						}
571
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
571
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
572 572
 						$pagenb++;
573 573
 						$pdf->setPage($pagenb);
574
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
574
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
575 575
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
576 576
 					}
577
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
577
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
578 578
 					{
579 579
 						if ($pagenb == 1)
580 580
 						{
@@ -584,10 +584,10 @@  discard block
 block discarded – undo
584 584
 						{
585 585
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
586 586
 						}
587
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
587
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
588 588
 						// New page
589 589
 						$pdf->AddPage();
590
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
590
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
591 591
 						$pagenb++;
592 592
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
593 593
 					}
@@ -597,60 +597,60 @@  discard block
 block discarded – undo
597 597
 				if ($pagenb == 1)
598 598
 				{
599 599
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
600
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
600
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
601 601
 				}
602 602
 				else
603 603
 				{
604 604
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
605
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
605
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
606 606
 				}
607 607
 
608 608
 				// Affiche zone infos
609
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
609
+				$posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
610 610
 
611 611
 				if (!$conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL) {
612 612
 					// Affiche zone totaux
613
-					$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
613
+					$posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
614 614
 				}
615 615
 
616 616
 				// Affiche zone versements
617 617
 				if ($deja_regle)
618 618
 				{
619
-					$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
619
+					$posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs);
620 620
 				}
621 621
 
622 622
 				// Pied de page
623
-				$this->_pagefoot($pdf,$object,$outputlangs);
624
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
623
+				$this->_pagefoot($pdf, $object, $outputlangs);
624
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
625 625
 
626 626
 				$pdf->Close();
627 627
 
628
-				$pdf->Output($file,'F');
628
+				$pdf->Output($file, 'F');
629 629
 
630 630
 				// Add pdfgeneration hook
631 631
 				$hookmanager->initHooks(array('pdfgeneration'));
632
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
632
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
633 633
 				global $action;
634
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
634
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
635 635
 
636
-				if (! empty($conf->global->MAIN_UMASK))
636
+				if (!empty($conf->global->MAIN_UMASK))
637 637
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
638 638
 
639
-				return 1;   // Pas d'erreur
639
+				return 1; // Pas d'erreur
640 640
 			}
641 641
 			else
642 642
 			{
643
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
643
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
644 644
 				return 0;
645 645
 			}
646 646
 		}
647 647
 		else
648 648
 		{
649
-			$this->error=$langs->trans("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
649
+			$this->error = $langs->trans("ErrorConstantNotDefined", "COMMANDE_OUTPUTDIR");
650 650
 			return 0;
651 651
 		}
652
-		$this->error=$langs->trans("ErrorUnknown");
653
-		return 0;   // Erreur par defaut
652
+		$this->error = $langs->trans("ErrorUnknown");
653
+		return 0; // Erreur par defaut
654 654
 	}
655 655
 
656 656
 	/**
@@ -682,35 +682,35 @@  discard block
 block discarded – undo
682 682
 		global $conf;
683 683
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
684 684
 
685
-		$pdf->SetFont('','', $default_font_size - 1);
685
+		$pdf->SetFont('', '', $default_font_size - 1);
686 686
 
687 687
         // If France, show VAT mention if not applicable
688 688
 		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
689 689
 		{
690
-			$pdf->SetFont('','B', $default_font_size - 2);
690
+			$pdf->SetFont('', 'B', $default_font_size - 2);
691 691
 			$pdf->SetXY($this->marge_gauche, $posy);
692 692
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
693 693
 
694
-			$posy=$pdf->GetY()+4;
694
+			$posy = $pdf->GetY() + 4;
695 695
 		}
696 696
 
697
-		$posxval=52;
697
+		$posxval = 52;
698 698
 
699 699
 		// Show payments conditions
700 700
 		if ($object->cond_reglement_code || $object->cond_reglement)
701 701
 		{
702
-			$pdf->SetFont('','B', $default_font_size - 2);
702
+			$pdf->SetFont('', 'B', $default_font_size - 2);
703 703
 			$pdf->SetXY($this->marge_gauche, $posy);
704 704
 			$titre = $outputlangs->transnoentities("PaymentConditions").':';
705 705
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
706 706
 
707
-			$pdf->SetFont('','', $default_font_size - 2);
707
+			$pdf->SetFont('', '', $default_font_size - 2);
708 708
 			$pdf->SetXY($posxval, $posy);
709
-			$lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
710
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
711
-			$pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
709
+			$lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
710
+			$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
711
+			$pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
712 712
 
713
-			$posy=$pdf->GetY()+3;
713
+			$posy = $pdf->GetY() + 3;
714 714
 		}
715 715
 
716 716
         // Check a payment mode is defined
@@ -741,34 +741,34 @@  discard block
 block discarded – undo
741 741
 		}*/
742 742
 
743 743
 	    // Show planed date of delivery
744
-        if (! empty($object->date_livraison))
744
+        if (!empty($object->date_livraison))
745 745
 		{
746 746
             $outputlangs->load("sendings");
747
-			$pdf->SetFont('','B', $default_font_size - 2);
747
+			$pdf->SetFont('', 'B', $default_font_size - 2);
748 748
 			$pdf->SetXY($this->marge_gauche, $posy);
749 749
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
750 750
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
751
-			$pdf->SetFont('','', $default_font_size - 2);
751
+			$pdf->SetFont('', '', $default_font_size - 2);
752 752
 			$pdf->SetXY($posxval, $posy);
753
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
753
+			$dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
754 754
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
755 755
 
756
-            $posy=$pdf->GetY()+1;
756
+            $posy = $pdf->GetY() + 1;
757 757
 		}
758 758
         elseif ($object->availability_code || $object->availability)    // Show availability conditions
759 759
 		{
760
-			$pdf->SetFont('','B', $default_font_size - 2);
760
+			$pdf->SetFont('', 'B', $default_font_size - 2);
761 761
 			$pdf->SetXY($this->marge_gauche, $posy);
762 762
 			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
763 763
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
764
-			$pdf->SetTextColor(0,0,0);
765
-			$pdf->SetFont('','', $default_font_size - 2);
764
+			$pdf->SetTextColor(0, 0, 0);
765
+			$pdf->SetFont('', '', $default_font_size - 2);
766 766
 			$pdf->SetXY($posxval, $posy);
767
-			$lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset(isset($object->availability)?$object->availability:'');
768
-			$lib_availability=str_replace('\n',"\n",$lib_availability);
767
+			$lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : '');
768
+			$lib_availability = str_replace('\n', "\n", $lib_availability);
769 769
 			$pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
770 770
 
771
-			$posy=$pdf->GetY()+1;
771
+			$posy = $pdf->GetY() + 1;
772 772
 		}
773 773
 
774 774
       	// Show payment mode
@@ -776,24 +776,24 @@  discard block
 block discarded – undo
776 776
         	 && $object->mode_reglement_code != 'CHQ'
777 777
            	 && $object->mode_reglement_code != 'VIR')
778 778
            	 {
779
-	            $pdf->SetFont('','B', $default_font_size - 2);
779
+	            $pdf->SetFont('', 'B', $default_font_size - 2);
780 780
 	            $pdf->SetXY($this->marge_gauche, $posy);
781 781
 	            $titre = $outputlangs->transnoentities("PaymentMode").':';
782 782
 	            $pdf->MultiCell(80, 5, $titre, 0, 'L');
783 783
 
784
-				$pdf->SetFont('','', $default_font_size - 2);
784
+				$pdf->SetFont('', '', $default_font_size - 2);
785 785
 	            $pdf->SetXY($posxval, $posy);
786
-	            $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
787
-	            $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
786
+	            $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
787
+	            $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
788 788
 
789
-	            $posy=$pdf->GetY()+2;
789
+	            $posy = $pdf->GetY() + 2;
790 790
            	 }
791 791
 
792 792
 		// Show payment mode CHQ
793 793
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
794 794
         {
795 795
         	// Si mode reglement non force ou si force a CHQ
796
-	        if (! empty($conf->global->FACTURE_CHQ_NUMBER))
796
+	        if (!empty($conf->global->FACTURE_CHQ_NUMBER))
797 797
 	        {
798 798
 	            if ($conf->global->FACTURE_CHQ_NUMBER > 0)
799 799
 	            {
@@ -801,31 +801,31 @@  discard block
 block discarded – undo
801 801
 	                $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
802 802
 
803 803
 	                $pdf->SetXY($this->marge_gauche, $posy);
804
-	                $pdf->SetFont('','B', $default_font_size - 3);
805
-	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
806
-		            $posy=$pdf->GetY()+1;
804
+	                $pdf->SetFont('', 'B', $default_font_size - 3);
805
+	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
806
+		            $posy = $pdf->GetY() + 1;
807 807
 
808 808
 		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
809 809
 		            {
810 810
 		                $pdf->SetXY($this->marge_gauche, $posy);
811
-		                $pdf->SetFont('','', $default_font_size - 3);
811
+		                $pdf->SetFont('', '', $default_font_size - 3);
812 812
 		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
813
-			            $posy=$pdf->GetY()+2;
813
+			            $posy = $pdf->GetY() + 2;
814 814
 		            }
815 815
 	            }
816 816
 	            if ($conf->global->FACTURE_CHQ_NUMBER == -1)
817 817
 	            {
818 818
 	                $pdf->SetXY($this->marge_gauche, $posy);
819
-	                $pdf->SetFont('','B', $default_font_size - 3);
820
-	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
821
-		            $posy=$pdf->GetY()+1;
819
+	                $pdf->SetFont('', 'B', $default_font_size - 3);
820
+	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
821
+		            $posy = $pdf->GetY() + 1;
822 822
 
823 823
 		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
824 824
 		            {
825 825
 			            $pdf->SetXY($this->marge_gauche, $posy);
826
-		                $pdf->SetFont('','', $default_font_size - 3);
826
+		                $pdf->SetFont('', '', $default_font_size - 3);
827 827
 		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
828
-			            $posy=$pdf->GetY()+2;
828
+			            $posy = $pdf->GetY() + 2;
829 829
 		            }
830 830
 	            }
831 831
 	        }
@@ -834,18 +834,18 @@  discard block
 block discarded – undo
834 834
         // If payment mode not forced or forced to VIR, show payment with BAN
835 835
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
836 836
         {
837
-        	if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
837
+        	if (!empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
838 838
 			{
839
-				$bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank);
839
+				$bankid = (empty($object->fk_bank) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_bank);
840 840
 				$account = new Account($this->db);
841 841
 				$account->fetch($bankid);
842 842
 
843
-				$curx=$this->marge_gauche;
844
-				$cury=$posy;
843
+				$curx = $this->marge_gauche;
844
+				$cury = $posy;
845 845
 
846
-				$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
846
+				$posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
847 847
 
848
-				$posy+=2;
848
+				$posy += 2;
849 849
 			}
850 850
         }
851 851
 
@@ -865,41 +865,41 @@  discard block
 block discarded – undo
865 865
 	 */
866 866
 	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
867 867
 	{
868
-	    global $conf,$mysoc;
868
+	    global $conf, $mysoc;
869 869
 
870 870
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
871 871
 
872 872
 		$tab2_top = $posy;
873 873
 		$tab2_hl = 4;
874
-		$pdf->SetFont('','', $default_font_size - 1);
874
+		$pdf->SetFont('', '', $default_font_size - 1);
875 875
 
876 876
 		// Tableau total
877 877
         $col1x = 120; $col2x = 170;
878 878
 		if ($this->page_largeur < 210) // To work with US executive format
879 879
 		{
880
-			$col2x-=20;
880
+			$col2x -= 20;
881 881
 		}
882 882
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
883 883
 
884
-		$useborder=0;
884
+		$useborder = 0;
885 885
 		$index = 0;
886 886
 
887 887
 		// Total HT
888
-		$pdf->SetFillColor(255,255,255);
888
+		$pdf->SetFillColor(255, 255, 255);
889 889
 		$pdf->SetXY($col1x, $tab2_top + 0);
890
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
890
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
891 891
 
892 892
 		$pdf->SetXY($col2x, $tab2_top + 0);
893
-		$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
893
+		$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
894 894
 
895 895
 		// Show VAT by rates and total
896
-		$pdf->SetFillColor(248,248,248);
896
+		$pdf->SetFillColor(248, 248, 248);
897 897
 
898
-		$this->atleastoneratenotnull=0;
898
+		$this->atleastoneratenotnull = 0;
899 899
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
900 900
 		{
901
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
902
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull)
901
+			$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
902
+			if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull)
903 903
 			{
904 904
 				// Nothing to do
905 905
 			}
@@ -908,27 +908,27 @@  discard block
 block discarded – undo
908 908
 				//Local tax 1 before VAT
909 909
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
910 910
 				//{
911
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
911
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
912 912
 					{
913
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
914
-						foreach( $localtax_rate as $tvakey => $tvaval )
913
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
914
+						foreach ($localtax_rate as $tvakey => $tvaval)
915 915
 						{
916
-							if ($tvakey!=0)    // On affiche pas taux 0
916
+							if ($tvakey != 0)    // On affiche pas taux 0
917 917
 							{
918 918
 								//$this->atleastoneratenotnull++;
919 919
 
920 920
 								$index++;
921 921
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
922 922
 
923
-								$tvacompl='';
924
-								if (preg_match('/\*/',$tvakey))
923
+								$tvacompl = '';
924
+								if (preg_match('/\*/', $tvakey))
925 925
 								{
926
-									$tvakey=str_replace('*','',$tvakey);
926
+									$tvakey = str_replace('*', '', $tvakey);
927 927
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
928 928
 								}
929
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
930
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
931
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
929
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
930
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
931
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
932 932
 
933 933
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
934 934
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -939,12 +939,12 @@  discard block
 block discarded – undo
939 939
 				//Local tax 2 before VAT
940 940
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
941 941
 				//{
942
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
942
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
943 943
 					{
944
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
945
-						foreach( $localtax_rate as $tvakey => $tvaval )
944
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
945
+						foreach ($localtax_rate as $tvakey => $tvaval)
946 946
 						{
947
-							if ($tvakey!=0)    // On affiche pas taux 0
947
+							if ($tvakey != 0)    // On affiche pas taux 0
948 948
 							{
949 949
 								//$this->atleastoneratenotnull++;
950 950
 
@@ -953,15 +953,15 @@  discard block
 block discarded – undo
953 953
 								$index++;
954 954
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
955 955
 
956
-								$tvacompl='';
957
-								if (preg_match('/\*/',$tvakey))
956
+								$tvacompl = '';
957
+								if (preg_match('/\*/', $tvakey))
958 958
 								{
959
-									$tvakey=str_replace('*','',$tvakey);
959
+									$tvakey = str_replace('*', '', $tvakey);
960 960
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
961 961
 								}
962
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
963
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
964
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
962
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
963
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
964
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
965 965
 
966 966
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
967 967
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
 					}
972 972
 				//}
973 973
 				// VAT
974
-				foreach($this->tva as $tvakey => $tvaval)
974
+				foreach ($this->tva as $tvakey => $tvaval)
975 975
 				{
976 976
 					if ($tvakey > 0)    // On affiche pas taux 0
977 977
 					{
@@ -980,15 +980,15 @@  discard block
 block discarded – undo
980 980
 						$index++;
981 981
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
982 982
 
983
-						$tvacompl='';
984
-						if (preg_match('/\*/',$tvakey))
983
+						$tvacompl = '';
984
+						if (preg_match('/\*/', $tvakey))
985 985
 						{
986
-							$tvakey=str_replace('*','',$tvakey);
986
+							$tvakey = str_replace('*', '', $tvakey);
987 987
 							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
988 988
 						}
989
-						$totalvat =$outputlangs->transnoentities("TotalVAT").' ';
990
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
991
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
989
+						$totalvat = $outputlangs->transnoentities("TotalVAT").' ';
990
+						$totalvat .= vatrate($tvakey, 1).$tvacompl;
991
+						$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
992 992
 
993 993
 						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
994 994
 						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -998,11 +998,11 @@  discard block
 block discarded – undo
998 998
 				//Local tax 1 after VAT
999 999
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1000 1000
 				//{
1001
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1001
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1002 1002
 					{
1003
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1003
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1004 1004
 
1005
-						foreach( $localtax_rate as $tvakey => $tvaval )
1005
+						foreach ($localtax_rate as $tvakey => $tvaval)
1006 1006
 						{
1007 1007
 							if ($tvakey != 0)    // On affiche pas taux 0
1008 1008
 							{
@@ -1011,16 +1011,16 @@  discard block
 block discarded – undo
1011 1011
 								$index++;
1012 1012
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1013 1013
 
1014
-								$tvacompl='';
1015
-								if (preg_match('/\*/',$tvakey))
1014
+								$tvacompl = '';
1015
+								if (preg_match('/\*/', $tvakey))
1016 1016
 								{
1017
-									$tvakey=str_replace('*','',$tvakey);
1017
+									$tvakey = str_replace('*', '', $tvakey);
1018 1018
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1019 1019
 								}
1020
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1020
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1021 1021
 
1022
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1023
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1022
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1023
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1024 1024
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1025 1025
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1026 1026
 							}
@@ -1030,11 +1030,11 @@  discard block
 block discarded – undo
1030 1030
 				//Local tax 2 after VAT
1031 1031
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1032 1032
 				//{
1033
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1033
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1034 1034
 					{
1035
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1035
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1036 1036
 
1037
-						foreach( $localtax_rate as $tvakey => $tvaval )
1037
+						foreach ($localtax_rate as $tvakey => $tvaval)
1038 1038
 						{
1039 1039
 							if ($tvakey != 0)    // On affiche pas taux 0
1040 1040
 							{
@@ -1043,16 +1043,16 @@  discard block
 block discarded – undo
1043 1043
 								$index++;
1044 1044
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1045 1045
 
1046
-								$tvacompl='';
1047
-								if (preg_match('/\*/',$tvakey))
1046
+								$tvacompl = '';
1047
+								if (preg_match('/\*/', $tvakey))
1048 1048
 								{
1049
-									$tvakey=str_replace('*','',$tvakey);
1049
+									$tvakey = str_replace('*', '', $tvakey);
1050 1050
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1051 1051
 								}
1052
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1052
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1053 1053
 
1054
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1055
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1054
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1055
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1056 1056
 
1057 1057
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1058 1058
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1064,24 +1064,24 @@  discard block
 block discarded – undo
1064 1064
 				// Total TTC
1065 1065
 				$index++;
1066 1066
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1067
-				$pdf->SetTextColor(0,0,60);
1068
-				$pdf->SetFillColor(224,224,224);
1069
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1067
+				$pdf->SetTextColor(0, 0, 60);
1068
+				$pdf->SetFillColor(224, 224, 224);
1069
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1070 1070
 
1071 1071
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1072 1072
 				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1073 1073
 			}
1074 1074
 		}
1075 1075
 
1076
-		$pdf->SetTextColor(0,0,0);
1076
+		$pdf->SetTextColor(0, 0, 0);
1077 1077
 
1078
-        $creditnoteamount=0;
1079
-        $depositsamount=0;
1078
+        $creditnoteamount = 0;
1079
+        $depositsamount = 0;
1080 1080
 		//$creditnoteamount=$object->getSumCreditNotesUsed();
1081 1081
 		//$depositsamount=$object->getSumDepositsUsed();
1082 1082
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
1083 1083
 		$resteapayer = price2num(doubleval($object->total_ttc) - doubleval($deja_regle) - $creditnoteamount - $depositsamount, 'MT');
1084
-		if (! empty($object->paye)) $resteapayer=0;
1084
+		if (!empty($object->paye)) $resteapayer = 0;
1085 1085
 
1086 1086
 		if ($deja_regle > 0)
1087 1087
 		{
@@ -1089,21 +1089,21 @@  discard block
 block discarded – undo
1089 1089
 			$index++;
1090 1090
 
1091 1091
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1092
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1092
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1093 1093
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1094 1094
 			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1095 1095
 
1096 1096
 			$index++;
1097
-			$pdf->SetTextColor(0,0,60);
1098
-			$pdf->SetFillColor(224,224,224);
1097
+			$pdf->SetTextColor(0, 0, 60);
1098
+			$pdf->SetFillColor(224, 224, 224);
1099 1099
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1100
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1100
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1101 1101
 
1102 1102
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1103 1103
 			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1104 1104
 
1105
-			$pdf->SetFont('','', $default_font_size - 1);
1106
-			$pdf->SetTextColor(0,0,0);
1105
+			$pdf->SetFont('', '', $default_font_size - 1);
1106
+			$pdf->SetTextColor(0, 0, 0);
1107 1107
 		}
1108 1108
 
1109 1109
 		$index++;
@@ -1122,75 +1122,75 @@  discard block
 block discarded – undo
1122 1122
 	 *   @param		int			$hidebottom		Hide bottom bar of array
1123 1123
 	 *   @return	void
1124 1124
 	 */
1125
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
1125
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
1126 1126
 	{
1127 1127
 		global $conf;
1128 1128
 
1129 1129
 		// Force to disable hidetop and hidebottom
1130
-		$hidebottom=0;
1131
-		if ($hidetop) $hidetop=-1;
1130
+		$hidebottom = 0;
1131
+		if ($hidetop) $hidetop = -1;
1132 1132
 
1133 1133
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1134 1134
 
1135 1135
 		// Amount in (at tab_top - 1)
1136
-		$pdf->SetTextColor(0,0,0);
1137
-		$pdf->SetFont('','', $default_font_size - 2);
1136
+		$pdf->SetTextColor(0, 0, 0);
1137
+		$pdf->SetFont('', '', $default_font_size - 2);
1138 1138
 
1139 1139
 		if (empty($hidetop))
1140 1140
 		{
1141
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
1142
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1141
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
1142
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1143 1143
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1144 1144
 
1145 1145
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1146
-			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1146
+			if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1147 1147
 		}
1148 1148
 
1149
-		$pdf->SetDrawColor(128,128,128);
1150
-		$pdf->SetFont('','', $default_font_size - 1);
1149
+		$pdf->SetDrawColor(128, 128, 128);
1150
+		$pdf->SetFont('', '', $default_font_size - 1);
1151 1151
 
1152 1152
 		// Output Rect
1153
-		$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
1153
+		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
1154 1154
 
1155 1155
 		if (empty($hidetop))
1156 1156
 		{
1157
-			$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line prend une position y en 2eme param et 4eme param
1157
+			$pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line prend une position y en 2eme param et 4eme param
1158 1158
 
1159
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
1160
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1159
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1160
+			$pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1161 1161
 		}
1162 1162
 
1163 1163
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1164 1164
 		{
1165
-			$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
1165
+			$pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1166 1166
 			if (empty($hidetop))
1167 1167
 			{
1168
-				$pdf->SetXY($this->posxtva-3, $tab_top+1);
1169
-				$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1168
+				$pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1169
+				$pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
1170 1170
 			}
1171 1171
 		}
1172 1172
 
1173
-		$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
1173
+		$pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1174 1174
 		if (empty($hidetop))
1175 1175
 		{
1176
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
1177
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1176
+			$pdf->SetXY($this->posxup - 1, $tab_top + 1);
1177
+			$pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
1178 1178
 		}
1179 1179
 
1180
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1180
+		$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1181 1181
 		if (empty($hidetop))
1182 1182
 		{
1183
-			$pdf->SetXY($this->posxqty-1, $tab_top+1);
1184
-			$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1183
+			$pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1184
+			$pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1185 1185
 		}
1186 1186
 
1187
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1187
+		$pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1188 1188
 		if (empty($hidetop))
1189 1189
 		{
1190 1190
 			if ($this->atleastonediscount)
1191 1191
 			{
1192
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1193
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1192
+				$pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1193
+				$pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
1194 1194
 			}
1195 1195
 		}
1196 1196
 
@@ -1200,8 +1200,8 @@  discard block
 block discarded – undo
1200 1200
 		}
1201 1201
 		if (empty($hidetop))
1202 1202
 		{
1203
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
1204
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1203
+			$pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1204
+			$pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
1205 1205
 		}
1206 1206
 	}
1207 1207
 
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
 	 */
1217 1217
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1218 1218
 	{
1219
-		global $conf,$langs,$hookmanager;
1219
+		global $conf, $langs, $hookmanager;
1220 1220
 
1221 1221
 		$outputlangs->load("main");
1222 1222
 		$outputlangs->load("bills");
@@ -1225,75 +1225,75 @@  discard block
 block discarded – undo
1225 1225
 		$outputlangs->load("orders");
1226 1226
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1227 1227
 
1228
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1228
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1229 1229
 
1230 1230
 		// Show Draft Watermark
1231
-		if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
1231
+		if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
1232 1232
 		{
1233
-            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
1233
+            pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
1234 1234
 		}
1235 1235
 
1236
-		$pdf->SetTextColor(0,0,60);
1237
-		$pdf->SetFont('','B', $default_font_size + 3);
1236
+		$pdf->SetTextColor(0, 0, 60);
1237
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1238 1238
 
1239
-		$posy=$this->marge_haute;
1240
-		$posx=$this->page_largeur-$this->marge_droite-100;
1239
+		$posy = $this->marge_haute;
1240
+		$posx = $this->page_largeur - $this->marge_droite - 100;
1241 1241
 
1242
-		$pdf->SetXY($this->marge_gauche,$posy);
1242
+		$pdf->SetXY($this->marge_gauche, $posy);
1243 1243
 
1244 1244
 		// Logo
1245
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1245
+		$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1246 1246
 		if ($this->emetteur->logo)
1247 1247
 		{
1248 1248
 			if (is_readable($logo))
1249 1249
 			{
1250
-			    $height=pdf_getHeightForLogo($logo);
1251
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1250
+			    $height = pdf_getHeightForLogo($logo);
1251
+			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1252 1252
 			}
1253 1253
 			else
1254 1254
 			{
1255
-				$pdf->SetTextColor(200,0,0);
1256
-				$pdf->SetFont('','B', $default_font_size -2);
1257
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1255
+				$pdf->SetTextColor(200, 0, 0);
1256
+				$pdf->SetFont('', 'B', $default_font_size - 2);
1257
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1258 1258
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1259 1259
 			}
1260 1260
 		}
1261 1261
 		else
1262 1262
 		{
1263
-			$text=$this->emetteur->name;
1263
+			$text = $this->emetteur->name;
1264 1264
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1265 1265
 		}
1266 1266
 
1267
-		$pdf->SetFont('','B', $default_font_size + 3);
1268
-		$pdf->SetXY($posx,$posy);
1269
-		$pdf->SetTextColor(0,0,60);
1270
-		$title=$outputlangs->transnoentities("Order");
1267
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1268
+		$pdf->SetXY($posx, $posy);
1269
+		$pdf->SetTextColor(0, 0, 60);
1270
+		$title = $outputlangs->transnoentities("Order");
1271 1271
 		$pdf->MultiCell(100, 3, $title, '', 'R');
1272 1272
 
1273
-		$pdf->SetFont('','B',$default_font_size);
1273
+		$pdf->SetFont('', 'B', $default_font_size);
1274 1274
 
1275
-		$posy+=5;
1276
-		$pdf->SetXY($posx,$posy);
1277
-		$pdf->SetTextColor(0,0,60);
1278
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1275
+		$posy += 5;
1276
+		$pdf->SetXY($posx, $posy);
1277
+		$pdf->SetTextColor(0, 0, 60);
1278
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1279 1279
 
1280
-		$posy+=1;
1281
-		$pdf->SetFont('','', $default_font_size - 1);
1280
+		$posy += 1;
1281
+		$pdf->SetFont('', '', $default_font_size - 1);
1282 1282
 
1283 1283
 		if ($object->ref_client)
1284 1284
 		{
1285
-			$posy+=5;
1286
-			$pdf->SetXY($posx,$posy);
1287
-			$pdf->SetTextColor(0,0,60);
1288
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1285
+			$posy += 5;
1286
+			$pdf->SetXY($posx, $posy);
1287
+			$pdf->SetTextColor(0, 0, 60);
1288
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1289 1289
 		}
1290 1290
 
1291
-		$posy+=4;
1292
-		$pdf->SetXY($posx,$posy);
1293
-		$pdf->SetTextColor(0,0,60);
1294
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
1291
+		$posy += 4;
1292
+		$pdf->SetXY($posx, $posy);
1293
+		$pdf->SetTextColor(0, 0, 60);
1294
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "%d %b %Y", false, $outputlangs, true), '', 'R');
1295 1295
 
1296
-		$posy+=2;
1296
+		$posy += 2;
1297 1297
 
1298 1298
 		// Show list of linked objects
1299 1299
 		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
@@ -1304,84 +1304,84 @@  discard block
 block discarded – undo
1304 1304
 			$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
1305 1305
 
1306 1306
 			// Show sender
1307
-			$posy=42;
1308
-			$posx=$this->marge_gauche;
1309
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1310
-			$hautcadre=40;
1307
+			$posy = 42;
1308
+			$posx = $this->marge_gauche;
1309
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1310
+			$hautcadre = 40;
1311 1311
 
1312 1312
 			// Show sender frame
1313
-			$pdf->SetTextColor(0,0,0);
1314
-			$pdf->SetFont('','', $default_font_size - 2);
1315
-			$pdf->SetXY($posx,$posy-5);
1316
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1317
-			$pdf->SetXY($posx,$posy);
1318
-			$pdf->SetFillColor(230,230,230);
1313
+			$pdf->SetTextColor(0, 0, 0);
1314
+			$pdf->SetFont('', '', $default_font_size - 2);
1315
+			$pdf->SetXY($posx, $posy - 5);
1316
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1317
+			$pdf->SetXY($posx, $posy);
1318
+			$pdf->SetFillColor(230, 230, 230);
1319 1319
 			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1320
-			$pdf->SetTextColor(0,0,60);
1320
+			$pdf->SetTextColor(0, 0, 60);
1321 1321
 
1322 1322
 			// Show sender name
1323
-			$pdf->SetXY($posx+2,$posy+3);
1324
-			$pdf->SetFont('','B', $default_font_size);
1323
+			$pdf->SetXY($posx + 2, $posy + 3);
1324
+			$pdf->SetFont('', 'B', $default_font_size);
1325 1325
 			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1326
-			$posy=$pdf->getY();
1326
+			$posy = $pdf->getY();
1327 1327
 
1328 1328
 			// Show sender information
1329
-			$pdf->SetXY($posx+2,$posy);
1330
-			$pdf->SetFont('','', $default_font_size - 1);
1329
+			$pdf->SetXY($posx + 2, $posy);
1330
+			$pdf->SetFont('', '', $default_font_size - 1);
1331 1331
 			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1332 1332
 
1333 1333
 
1334 1334
 
1335 1335
 			// If CUSTOMER contact defined on order, we use it
1336
-			$usecontact=false;
1337
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1336
+			$usecontact = false;
1337
+			$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1338 1338
 			if (count($arrayidcontact) > 0)
1339 1339
 			{
1340
-				$usecontact=true;
1341
-				$result=$object->fetch_contact($arrayidcontact[0]);
1340
+				$usecontact = true;
1341
+				$result = $object->fetch_contact($arrayidcontact[0]);
1342 1342
 			}
1343 1343
 
1344 1344
 			// Recipient name
1345
-			if (! empty($usecontact))
1345
+			if (!empty($usecontact))
1346 1346
 			{
1347 1347
 				// On peut utiliser le nom de la societe du contact
1348
-				if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1348
+				if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1349 1349
 				else $socname = $object->thirdparty->name;
1350
-				$carac_client_name=$outputlangs->convToOutputCharset($socname);
1350
+				$carac_client_name = $outputlangs->convToOutputCharset($socname);
1351 1351
 			}
1352 1352
 			else
1353 1353
 			{
1354
-				$carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name);
1354
+				$carac_client_name = $outputlangs->convToOutputCharset($object->thirdparty->name);
1355 1355
 			}
1356 1356
 
1357
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target');
1357
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target');
1358 1358
 
1359 1359
 			// Show recipient
1360
-			$widthrecbox=100;
1361
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1362
-			$posy=42;
1363
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1364
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1360
+			$widthrecbox = 100;
1361
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1362
+			$posy = 42;
1363
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1364
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1365 1365
 
1366 1366
 			// Show recipient frame
1367
-			$pdf->SetTextColor(0,0,0);
1368
-			$pdf->SetFont('','', $default_font_size - 2);
1369
-			$pdf->SetXY($posx+2,$posy-5);
1370
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1367
+			$pdf->SetTextColor(0, 0, 0);
1368
+			$pdf->SetFont('', '', $default_font_size - 2);
1369
+			$pdf->SetXY($posx + 2, $posy - 5);
1370
+			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1371 1371
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1372 1372
 
1373 1373
 			// Show recipient name
1374
-			$pdf->SetXY($posx+2,$posy+3);
1375
-			$pdf->SetFont('','B', $default_font_size);
1374
+			$pdf->SetXY($posx + 2, $posy + 3);
1375
+			$pdf->SetFont('', 'B', $default_font_size);
1376 1376
 			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1377 1377
 
1378 1378
 			// Show recipient information
1379
-			$pdf->SetFont('','', $default_font_size - 1);
1380
-			$pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
1379
+			$pdf->SetFont('', '', $default_font_size - 1);
1380
+			$pdf->SetXY($posx + 2, $posy + 4 + (dol_nboflines_bis($carac_client_name, 50) * 4));
1381 1381
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1382 1382
 		}
1383 1383
 
1384
-		$pdf->SetTextColor(0,0,0);
1384
+		$pdf->SetTextColor(0, 0, 0);
1385 1385
 	}
1386 1386
 
1387 1387
 	/**
@@ -1393,11 +1393,11 @@  discard block
 block discarded – undo
1393 1393
 	 *      @param	int			$hidefreetext		1=Hide free text
1394 1394
 	 *      @return	int								Return height of bottom margin including footer text
1395 1395
 	 */
1396
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1396
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1397 1397
 	{
1398
-		$showdetails=0;
1399
-		$free_text = (float)DOL_VERSION > 3.8 ? 'ORDER_FREE_TEXT' : 'COMMANDE_FREE_TEXT';
1400
-		return pdf_pagefoot($pdf,$outputlangs,$free_text,$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1398
+		$showdetails = 0;
1399
+		$free_text = (float) DOL_VERSION > 3.8 ? 'ORDER_FREE_TEXT' : 'COMMANDE_FREE_TEXT';
1400
+		return pdf_pagefoot($pdf, $outputlangs, $free_text, $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1401 1401
 	}
1402 1402
 
1403 1403
 }
Please login to merge, or discard this patch.
Braces   +150 added lines, -77 removed lines patch added patch discarded remove patch
@@ -100,7 +100,10 @@  discard block
 block discarded – undo
100 100
 
101 101
 		// Get source company
102 102
 		$this->emetteur=$mysoc;
103
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
103
+		if (empty($this->emetteur->country_code)) {
104
+			$this->emetteur->country_code=substr($langs->defaultlang,-2);
105
+		}
106
+		// By default, if was not defined
104 107
 
105 108
 		// Define position of columns
106 109
 		$this->posxdesc=$this->marge_gauche+1;
@@ -109,11 +112,15 @@  discard block
 block discarded – undo
109 112
 		$this->posxqty=145;
110 113
 		$this->posxdiscount=162;
111 114
 		$this->postotalht=174;
112
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
115
+		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
116
+			$this->posxtva=$this->posxup;
117
+		}
113 118
 		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
114
-		if ($this->page_largeur < 210) // To work with US executive format
119
+		if ($this->page_largeur < 210) {
120
+			// To work with US executive format
115 121
 		{
116 122
 			$this->posxpicture-=20;
123
+		}
117 124
 			$this->posxtva-=20;
118 125
 			$this->posxup-=20;
119 126
 			$this->posxqty-=20;
@@ -143,9 +150,13 @@  discard block
 block discarded – undo
143 150
 	{
144 151
 		global $user,$langs,$conf,$mysoc,$db,$hookmanager;
145 152
 
146
-		if (! is_object($outputlangs)) $outputlangs=$langs;
153
+		if (! is_object($outputlangs)) {
154
+			$outputlangs=$langs;
155
+		}
147 156
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
148
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
157
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
158
+			$outputlangs->charset_output='ISO-8859-1';
159
+		}
149 160
 
150 161
 		$outputlangs->load("main");
151 162
 		$outputlangs->load("dict");
@@ -170,8 +181,7 @@  discard block
 block discarded – undo
170 181
 			{
171 182
 				$dir = $conf->commande->dir_output;
172 183
 				$file = $dir . "/SPECIMEN.pdf";
173
-			}
174
-			else
184
+			} else
175 185
 			{
176 186
 				$objectref = dol_sanitizeFileName($object->ref);
177 187
 				$dir = $conf->commande->dir_output . "/" . $objectref;
@@ -230,7 +240,9 @@  discard block
 block discarded – undo
230 240
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
231 241
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
232 242
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order"));
233
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
243
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
244
+					$pdf->SetCompression(false);
245
+				}
234 246
 
235 247
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
236 248
 
@@ -254,7 +266,9 @@  discard block
 block discarded – undo
254 266
 
255 267
 				// New page
256 268
 				$pdf->AddPage();
257
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
269
+				if (! empty($tplidx)) {
270
+					$pdf->useTemplate($tplidx);
271
+				}
258 272
 				$pagenb++;
259 273
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
260 274
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -277,7 +291,9 @@  discard block
 block discarded – undo
277 291
 						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
278 292
 						$salerepobj=new User($this->db);
279 293
 						$salerepobj->fetch($salereparray[0]['id']);
280
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
294
+						if (! empty($salerepobj->signature)) {
295
+							$notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
296
+						}
281 297
 					}
282 298
 				}
283 299
 				if ($notetoshow)
@@ -295,8 +311,7 @@  discard block
 block discarded – undo
295 311
 
296 312
 					$tab_height = $tab_height - $height_note;
297 313
 					$tab_top = $nexY+6;
298
-				}
299
-				else
314
+				} else
300 315
 				{
301 316
 					$height_note=0;
302 317
 				}
@@ -391,32 +406,38 @@  discard block
 block discarded – undo
391 406
 					$pdf->startTransaction();
392 407
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
393 408
 					$pageposafter=$pdf->getPage();
394
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
409
+					if ($pageposafter > $pageposbefore) {
410
+						// There is a pagebreak
395 411
 					{
396 412
 						$pdf->rollbackTransaction(true);
413
+					}
397 414
 						$pageposafter=$pageposbefore;
398 415
 						//print $pageposafter.'-'.$pageposbefore;exit;
399 416
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
400 417
 						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
401 418
 						$pageposafter=$pdf->getPage();
402 419
 						$posyafter=$pdf->GetY();
403
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
420
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
421
+							// There is no space left for total+free text
404 422
 						{
405 423
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
406 424
 							{
407 425
 								$pdf->AddPage('','',true);
408
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
409
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
426
+						}
427
+								if (! empty($tplidx)) {
428
+									$pdf->useTemplate($tplidx);
429
+								}
430
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
431
+									$this->_pagehead($pdf, $object, 0, $outputlangs);
432
+								}
410 433
 								$pdf->setPage($pageposafter+1);
411 434
 							}
412
-						}
413
-						else
435
+						} else
414 436
 						{
415 437
 							// We found a page break
416 438
 							$showpricebeforepagebreak=0;
417 439
 						}
418
-					}
419
-					else	// No pagebreak
440
+					} else	// No pagebreak
420 441
 					{
421 442
 						$pdf->commitTransaction();
422 443
 					}
@@ -508,29 +529,43 @@  discard block
 block discarded – undo
508 529
 					$localtax1_type=$object->lines[$i]->localtax1_type;
509 530
 					$localtax2_type=$object->lines[$i]->localtax2_type;
510 531
 
511
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
512
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
513
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
532
+					if ($object->remise_percent) {
533
+						$tvaligne-=($tvaligne*$object->remise_percent)/100;
534
+					}
535
+					if ($object->remise_percent) {
536
+						$localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
537
+					}
538
+					if ($object->remise_percent) {
539
+						$localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
540
+					}
514 541
 
515 542
 					$vatrate=(string) $object->lines[$i]->tva_tx;
516 543
 					
517 544
 					// Retrieve type from database for backward compatibility with old records
518 545
 					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
519
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
546
+					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) {
547
+						// and there is local tax
520 548
 					{
521 549
 						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
550
+					}
522 551
 						$localtax1_type = $localtaxtmp_array[0];
523 552
 						$localtax2_type = $localtaxtmp_array[2];
524 553
 					}
525 554
 
526 555
 				    // retrieve global local tax
527
-					if ($localtax1_type && $localtax1ligne != 0)
528
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
529
-					if ($localtax2_type && $localtax2ligne != 0)
530
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
556
+					if ($localtax1_type && $localtax1ligne != 0) {
557
+											$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
558
+					}
559
+					if ($localtax2_type && $localtax2ligne != 0) {
560
+											$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
561
+					}
531 562
 
532
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
533
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
563
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
564
+						$vatrate.='*';
565
+					}
566
+					if (! isset($this->tva[$vatrate])) {
567
+						$this->tva[$vatrate]=0;
568
+					}
534 569
 					
535 570
 					if (!empty($object->lines[$i]->TTotal_tva))
536 571
 					{
@@ -538,10 +573,11 @@  discard block
 block discarded – undo
538 573
 						{
539 574
 							$this->tva[$vatrate] += $tvaligne;
540 575
 						}
541
-					}
542
-					else {
576
+					} else {
543 577
 						// standard
544
-                        if(!empty($tvaligne)) $this->tva[$vatrate] += $tvaligne;
578
+                        if(!empty($tvaligne)) {
579
+                        	$this->tva[$vatrate] += $tvaligne;
580
+                        }
545 581
 					}
546 582
 
547 583
 					// Add line
@@ -563,8 +599,7 @@  discard block
 block discarded – undo
563 599
 						if ($pagenb == 1)
564 600
 						{
565 601
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
566
-						}
567
-						else
602
+						} else
568 603
 						{
569 604
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
570 605
 						}
@@ -572,24 +607,29 @@  discard block
 block discarded – undo
572 607
 						$pagenb++;
573 608
 						$pdf->setPage($pagenb);
574 609
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
575
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
610
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
611
+							$this->_pagehead($pdf, $object, 0, $outputlangs);
612
+						}
576 613
 					}
577 614
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
578 615
 					{
579 616
 						if ($pagenb == 1)
580 617
 						{
581 618
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
582
-						}
583
-						else
619
+						} else
584 620
 						{
585 621
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
586 622
 						}
587 623
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
588 624
 						// New page
589 625
 						$pdf->AddPage();
590
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
626
+						if (! empty($tplidx)) {
627
+							$pdf->useTemplate($tplidx);
628
+						}
591 629
 						$pagenb++;
592
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
630
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
631
+							$this->_pagehead($pdf, $object, 0, $outputlangs);
632
+						}
593 633
 					}
594 634
 				}
595 635
 
@@ -598,8 +638,7 @@  discard block
 block discarded – undo
598 638
 				{
599 639
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
600 640
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
601
-				}
602
-				else
641
+				} else
603 642
 				{
604 643
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
605 644
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -621,7 +660,9 @@  discard block
 block discarded – undo
621 660
 
622 661
 				// Pied de page
623 662
 				$this->_pagefoot($pdf,$object,$outputlangs);
624
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
663
+				if (method_exists($pdf,'AliasNbPages')) {
664
+					$pdf->AliasNbPages();
665
+				}
625 666
 
626 667
 				$pdf->Close();
627 668
 
@@ -633,18 +674,17 @@  discard block
 block discarded – undo
633 674
 				global $action;
634 675
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
635 676
 
636
-				if (! empty($conf->global->MAIN_UMASK))
637
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
677
+				if (! empty($conf->global->MAIN_UMASK)) {
678
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
679
+				}
638 680
 
639 681
 				return 1;   // Pas d'erreur
640
-			}
641
-			else
682
+			} else
642 683
 			{
643 684
 				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
644 685
 				return 0;
645 686
 			}
646
-		}
647
-		else
687
+		} else
648 688
 		{
649 689
 			$this->error=$langs->trans("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
650 690
 			return 0;
@@ -754,10 +794,11 @@  discard block
 block discarded – undo
754 794
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
755 795
 
756 796
             $posy=$pdf->GetY()+1;
757
-		}
758
-        elseif ($object->availability_code || $object->availability)    // Show availability conditions
797
+		} elseif ($object->availability_code || $object->availability) {
798
+        	// Show availability conditions
759 799
 		{
760 800
 			$pdf->SetFont('','B', $default_font_size - 2);
801
+        }
761 802
 			$pdf->SetXY($this->marge_gauche, $posy);
762 803
 			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
763 804
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
@@ -875,10 +916,12 @@  discard block
 block discarded – undo
875 916
 
876 917
 		// Tableau total
877 918
         $col1x = 120; $col2x = 170;
878
-		if ($this->page_largeur < 210) // To work with US executive format
919
+		if ($this->page_largeur < 210) {
920
+			// To work with US executive format
879 921
 		{
880 922
 			$col2x-=20;
881 923
 		}
924
+		}
882 925
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
883 926
 
884 927
 		$useborder=0;
@@ -902,22 +945,25 @@  discard block
 block discarded – undo
902 945
 			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull)
903 946
 			{
904 947
 				// Nothing to do
905
-			}
906
-			else
948
+			} else
907 949
 			{
908 950
 				//Local tax 1 before VAT
909 951
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
910 952
 				//{
911 953
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
912 954
 					{
913
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
955
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
956
+							continue;
957
+						}
914 958
 						foreach( $localtax_rate as $tvakey => $tvaval )
915 959
 						{
916
-							if ($tvakey!=0)    // On affiche pas taux 0
960
+							if ($tvakey!=0) {
961
+								// On affiche pas taux 0
917 962
 							{
918 963
 								//$this->atleastoneratenotnull++;
919 964
 
920 965
 								$index++;
966
+							}
921 967
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
922 968
 
923 969
 								$tvacompl='';
@@ -941,16 +987,20 @@  discard block
 block discarded – undo
941 987
 				//{
942 988
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
943 989
 					{
944
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
990
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
991
+							continue;
992
+						}
945 993
 						foreach( $localtax_rate as $tvakey => $tvaval )
946 994
 						{
947
-							if ($tvakey!=0)    // On affiche pas taux 0
995
+							if ($tvakey!=0) {
996
+								// On affiche pas taux 0
948 997
 							{
949 998
 								//$this->atleastoneratenotnull++;
950 999
 
951 1000
 
952 1001
 
953 1002
 								$index++;
1003
+							}
954 1004
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
955 1005
 
956 1006
 								$tvacompl='';
@@ -973,9 +1023,11 @@  discard block
 block discarded – undo
973 1023
 				// VAT
974 1024
 				foreach($this->tva as $tvakey => $tvaval)
975 1025
 				{
976
-					if ($tvakey > 0)    // On affiche pas taux 0
1026
+					if ($tvakey > 0) {
1027
+						// On affiche pas taux 0
977 1028
 					{
978 1029
 						$this->atleastoneratenotnull++;
1030
+					}
979 1031
 
980 1032
 						$index++;
981 1033
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1000,15 +1052,19 @@  discard block
 block discarded – undo
1000 1052
 				//{
1001 1053
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1002 1054
 					{
1003
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1055
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1056
+							continue;
1057
+						}
1004 1058
 
1005 1059
 						foreach( $localtax_rate as $tvakey => $tvaval )
1006 1060
 						{
1007
-							if ($tvakey != 0)    // On affiche pas taux 0
1061
+							if ($tvakey != 0) {
1062
+								// On affiche pas taux 0
1008 1063
 							{
1009 1064
 								//$this->atleastoneratenotnull++;
1010 1065
 
1011 1066
 								$index++;
1067
+							}
1012 1068
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1013 1069
 
1014 1070
 								$tvacompl='';
@@ -1032,15 +1088,19 @@  discard block
 block discarded – undo
1032 1088
 				//{
1033 1089
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1034 1090
 					{
1035
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1091
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1092
+							continue;
1093
+						}
1036 1094
 
1037 1095
 						foreach( $localtax_rate as $tvakey => $tvaval )
1038 1096
 						{
1039
-							if ($tvakey != 0)    // On affiche pas taux 0
1097
+							if ($tvakey != 0) {
1098
+								// On affiche pas taux 0
1040 1099
 							{
1041 1100
 								//$this->atleastoneratenotnull++;
1042 1101
 
1043 1102
 								$index++;
1103
+							}
1044 1104
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1045 1105
 
1046 1106
 								$tvacompl='';
@@ -1081,7 +1141,9 @@  discard block
 block discarded – undo
1081 1141
 		//$depositsamount=$object->getSumDepositsUsed();
1082 1142
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
1083 1143
 		$resteapayer = price2num(doubleval($object->total_ttc) - doubleval($deja_regle) - $creditnoteamount - $depositsamount, 'MT');
1084
-		if (! empty($object->paye)) $resteapayer=0;
1144
+		if (! empty($object->paye)) {
1145
+			$resteapayer=0;
1146
+		}
1085 1147
 
1086 1148
 		if ($deja_regle > 0)
1087 1149
 		{
@@ -1128,7 +1190,9 @@  discard block
 block discarded – undo
1128 1190
 
1129 1191
 		// Force to disable hidetop and hidebottom
1130 1192
 		$hidebottom=0;
1131
-		if ($hidetop) $hidetop=-1;
1193
+		if ($hidetop) {
1194
+			$hidetop=-1;
1195
+		}
1132 1196
 
1133 1197
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1134 1198
 
@@ -1143,7 +1207,9 @@  discard block
 block discarded – undo
1143 1207
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1144 1208
 
1145 1209
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1146
-			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1210
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1211
+				$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1212
+			}
1147 1213
 		}
1148 1214
 
1149 1215
 		$pdf->SetDrawColor(128,128,128);
@@ -1249,16 +1315,14 @@  discard block
 block discarded – undo
1249 1315
 			{
1250 1316
 			    $height=pdf_getHeightForLogo($logo);
1251 1317
 			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1252
-			}
1253
-			else
1318
+			} else
1254 1319
 			{
1255 1320
 				$pdf->SetTextColor(200,0,0);
1256 1321
 				$pdf->SetFont('','B', $default_font_size -2);
1257 1322
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1258 1323
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1259 1324
 			}
1260
-		}
1261
-		else
1325
+		} else
1262 1326
 		{
1263 1327
 			$text=$this->emetteur->name;
1264 1328
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1306,7 +1370,9 @@  discard block
 block discarded – undo
1306 1370
 			// Show sender
1307 1371
 			$posy=42;
1308 1372
 			$posx=$this->marge_gauche;
1309
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1373
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1374
+				$posx=$this->page_largeur-$this->marge_droite-80;
1375
+			}
1310 1376
 			$hautcadre=40;
1311 1377
 
1312 1378
 			// Show sender frame
@@ -1345,11 +1411,13 @@  discard block
 block discarded – undo
1345 1411
 			if (! empty($usecontact))
1346 1412
 			{
1347 1413
 				// On peut utiliser le nom de la societe du contact
1348
-				if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1349
-				else $socname = $object->thirdparty->name;
1414
+				if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1415
+					$socname = $object->contact->socname;
1416
+				} else {
1417
+					$socname = $object->thirdparty->name;
1418
+				}
1350 1419
 				$carac_client_name=$outputlangs->convToOutputCharset($socname);
1351
-			}
1352
-			else
1420
+			} else
1353 1421
 			{
1354 1422
 				$carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name);
1355 1423
 			}
@@ -1358,10 +1426,15 @@  discard block
 block discarded – undo
1358 1426
 
1359 1427
 			// Show recipient
1360 1428
 			$widthrecbox=100;
1361
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1429
+			if ($this->page_largeur < 210) {
1430
+				$widthrecbox=84;
1431
+			}
1432
+			// To work with US executive format
1362 1433
 			$posy=42;
1363 1434
 			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1364
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1435
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1436
+				$posx=$this->marge_gauche;
1437
+			}
1365 1438
 
1366 1439
 			// Show recipient frame
1367 1440
 			$pdf->SetTextColor(0,0,0);
Please login to merge, or discard this patch.
core/triggers/interface_90_modSubtotal_subtotaltrigger.class.php 3 patches
Indentation   +612 added lines, -612 removed lines patch added patch discarded remove patch
@@ -36,68 +36,68 @@  discard block
 block discarded – undo
36 36
 class Interfacesubtotaltrigger
37 37
 {
38 38
 
39
-    private $db;
40
-
41
-    /**
42
-     * Constructor
43
-     *
44
-     * 	@param		DoliDB		$db		Database handler
45
-     */
46
-    public function __construct($db)
47
-    {
48
-        $this->db = $db;
49
-
50
-        $this->name = preg_replace('/^Interface/i', '', get_class($this));
51
-        $this->family = "demo";
52
-        $this->description = "Triggers of this module are empty functions."
53
-            . "They have no effect."
54
-            . "They are provided for tutorial purpose only.";
55
-        // 'development', 'experimental', 'dolibarr' or version
56
-        $this->version = 'development';
57
-        $this->picto = 'titre@titre';
58
-    }
59
-
60
-    /**
61
-     * Trigger name
62
-     *
63
-     * 	@return		string	Name of trigger file
64
-     */
65
-    public function getName()
66
-    {
67
-        return $this->name;
68
-    }
69
-
70
-    /**
71
-     * Trigger description
72
-     *
73
-     * 	@return		string	Description of trigger file
74
-     */
75
-    public function getDesc()
76
-    {
77
-        return $this->description;
78
-    }
79
-
80
-    /**
81
-     * Trigger version
82
-     *
83
-     * 	@return		string	Version of trigger file
84
-     */
85
-    public function getVersion()
86
-    {
87
-        global $langs;
88
-        $langs->load("admin");
89
-
90
-        if ($this->version == 'development') {
91
-            return $langs->trans("Development");
92
-        } elseif ($this->version == 'experimental')
93
-
94
-                return $langs->trans("Experimental");
95
-        elseif ($this->version == 'dolibarr') return DOL_VERSION;
96
-        elseif ($this->version) return $this->version;
97
-        else {
98
-            return $langs->trans("Unknown");
99
-        }
100
-    }
39
+	private $db;
40
+
41
+	/**
42
+	 * Constructor
43
+	 *
44
+	 * 	@param		DoliDB		$db		Database handler
45
+	 */
46
+	public function __construct($db)
47
+	{
48
+		$this->db = $db;
49
+
50
+		$this->name = preg_replace('/^Interface/i', '', get_class($this));
51
+		$this->family = "demo";
52
+		$this->description = "Triggers of this module are empty functions."
53
+			. "They have no effect."
54
+			. "They are provided for tutorial purpose only.";
55
+		// 'development', 'experimental', 'dolibarr' or version
56
+		$this->version = 'development';
57
+		$this->picto = 'titre@titre';
58
+	}
59
+
60
+	/**
61
+	 * Trigger name
62
+	 *
63
+	 * 	@return		string	Name of trigger file
64
+	 */
65
+	public function getName()
66
+	{
67
+		return $this->name;
68
+	}
69
+
70
+	/**
71
+	 * Trigger description
72
+	 *
73
+	 * 	@return		string	Description of trigger file
74
+	 */
75
+	public function getDesc()
76
+	{
77
+		return $this->description;
78
+	}
79
+
80
+	/**
81
+	 * Trigger version
82
+	 *
83
+	 * 	@return		string	Version of trigger file
84
+	 */
85
+	public function getVersion()
86
+	{
87
+		global $langs;
88
+		$langs->load("admin");
89
+
90
+		if ($this->version == 'development') {
91
+			return $langs->trans("Development");
92
+		} elseif ($this->version == 'experimental')
93
+
94
+				return $langs->trans("Experimental");
95
+		elseif ($this->version == 'dolibarr') return DOL_VERSION;
96
+		elseif ($this->version) return $this->version;
97
+		else {
98
+			return $langs->trans("Unknown");
99
+		}
100
+	}
101 101
 	
102 102
 	public function addToBegin(&$parent, &$object, $rang)
103 103
 	{
@@ -147,27 +147,27 @@  discard block
 block discarded – undo
147 147
 		}
148 148
 	}
149 149
 	
150
-    /**
151
-     * Function called when a Dolibarrr business event is done.
152
-     * All functions "run_trigger" are triggered if file
153
-     * is inside directory core/triggers
154
-     *
155
-     * 	@param		string		$action		Event action code
156
-     * 	@param		Object		$object		Object
157
-     * 	@param		User		$user		Object user
158
-     * 	@param		Translate	$langs		Object langs
159
-     * 	@param		conf		$conf		Object conf
160
-     * 	@return		int						<0 if KO, 0 if no triggered ran, >0 if OK
161
-     */
162
-    public function run_trigger($action, $object, $user, $langs, $conf)
163
-    {
164
-        // Put here code you want to execute when a Dolibarr business events occurs.
165
-        // Data and type of action are stored into $object and $action
166
-        // Users
167
-        dol_include_once('/subtotal/class/subtotal.class.php');
168
-        $langs->load('subtotal@subtotal');
169
-
170
-        if (!empty($conf->global->SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE) && in_array($action, array('LINEPROPAL_INSERT', 'LINEORDER_INSERT', 'LINEBILL_INSERT')))
150
+	/**
151
+	 * Function called when a Dolibarrr business event is done.
152
+	 * All functions "run_trigger" are triggered if file
153
+	 * is inside directory core/triggers
154
+	 *
155
+	 * 	@param		string		$action		Event action code
156
+	 * 	@param		Object		$object		Object
157
+	 * 	@param		User		$user		Object user
158
+	 * 	@param		Translate	$langs		Object langs
159
+	 * 	@param		conf		$conf		Object conf
160
+	 * 	@return		int						<0 if KO, 0 if no triggered ran, >0 if OK
161
+	 */
162
+	public function run_trigger($action, $object, $user, $langs, $conf)
163
+	{
164
+		// Put here code you want to execute when a Dolibarr business events occurs.
165
+		// Data and type of action are stored into $object and $action
166
+		// Users
167
+		dol_include_once('/subtotal/class/subtotal.class.php');
168
+		$langs->load('subtotal@subtotal');
169
+
170
+		if (!empty($conf->global->SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE) && in_array($action, array('LINEPROPAL_INSERT', 'LINEORDER_INSERT', 'LINEBILL_INSERT')))
171 171
 		{
172 172
 			$rang = GETPOST('under_title', 'int'); // Rang du titre
173 173
 			if ($rang > 0)
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
 						$parent = new Facture($this->db);
186 186
 						$parent->fetch($object->fk_facture);
187 187
 						break;
188
-                    case 'LINEBILL_SUPPLIER_CREATE':
189
-                        $parent = new FactureFournisseur($this->db);
190
-                        $parent->fetch($object->fk_facture_fourn);
188
+					case 'LINEBILL_SUPPLIER_CREATE':
189
+						$parent = new FactureFournisseur($this->db);
190
+						$parent->fetch($object->fk_facture_fourn);
191 191
 					default:
192 192
 						$parent = $object;
193 193
 						break;
@@ -201,77 +201,77 @@  discard block
 block discarded – undo
201 201
 		}
202 202
         
203 203
 		
204
-        if ($action == 'LINEBILL_INSERT' || $action == 'LINEBILL_SUPPLIER_CREATE')
204
+		if ($action == 'LINEBILL_INSERT' || $action == 'LINEBILL_SUPPLIER_CREATE')
205 205
 		{
206
-		    $is_supplier = $action == 'LINEBILL_SUPPLIER_CREATE' ? true : false;
207
-            /** @var bool $subtotal_skip Permet d'éviter de faire du traitement en double sur les titres est sous-totaux car ils ont automatiquement le bon rang, il ne faut donc pas faire un addline pour en suite update le rang ici */
208
-		    global $subtotal_skip;
209
-
210
-		    if ($subtotal_skip)
211
-            {
212
-                $subtotal_skip = false;
213
-            }
214
-		    else
215
-            {
216
-			    $subtotal_add_title_bloc_from_orderstoinvoice = GETPOST('subtotal_add_title_bloc_from_orderstoinvoice');
217
-			    if (!empty($subtotal_add_title_bloc_from_orderstoinvoice))
218
-			    {
219
-				    global $subtotal_current_rang, $subtotal_bloc_previous_fk_commande, $subtotal_bloc_already_add_title, $subtotal_bloc_already_add_st;
206
+			$is_supplier = $action == 'LINEBILL_SUPPLIER_CREATE' ? true : false;
207
+			/** @var bool $subtotal_skip Permet d'éviter de faire du traitement en double sur les titres est sous-totaux car ils ont automatiquement le bon rang, il ne faut donc pas faire un addline pour en suite update le rang ici */
208
+			global $subtotal_skip;
209
+
210
+			if ($subtotal_skip)
211
+			{
212
+				$subtotal_skip = false;
213
+			}
214
+			else
215
+			{
216
+				$subtotal_add_title_bloc_from_orderstoinvoice = GETPOST('subtotal_add_title_bloc_from_orderstoinvoice');
217
+				if (!empty($subtotal_add_title_bloc_from_orderstoinvoice))
218
+				{
219
+					global $subtotal_current_rang, $subtotal_bloc_previous_fk_commande, $subtotal_bloc_already_add_title, $subtotal_bloc_already_add_st;
220 220
 				    
221
-				    $current_fk_commande = TSubtotal::getOrderIdFromLineId($this->db, $object->origin_id, $is_supplier);
222
-				    $last_fk_commandedet = TSubtotal::getLastLineOrderId($this->db, $current_fk_commande, $is_supplier);
223
-
224
-				    if (!$is_supplier){
225
-				        $facture = new Facture($this->db);
226
-				        $ret = $facture->fetch($object->fk_facture);
227
-                    }
228
-				    else
229
-                    {
230
-				        $facture = new FactureFournisseur($this->db);
231
-				        $ret = $facture->fetch($object->fk_facture_fourn);
232
-                    }
233
-
234
-				    if ($ret > 0 && !$subtotal_bloc_already_add_st)
235
-				    {
236
-					    $rang = !empty($subtotal_current_rang) ? $subtotal_current_rang : $object->rang;
237
-					    // Si le fk_commande courrant est différent alors on change de commande => ajout d'un titre
238
-					    if ($current_fk_commande != $subtotal_bloc_previous_fk_commande ) {
239
-                            if (!$is_supplier) $commande = new Commande($this->db);
240
-                            else $commande = new CommandeFournisseur($this->db);
241
-                            $commande->fetch($current_fk_commande);
242
-
243
-                            $label = $conf->global->SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE;
244
-                            if (empty($label)) {
245
-                                $label = 'Commande [__REFORDER__]';
246
-                                if (!$is_supplier) $label .= ' - Référence client : [__REFCUSTOMER__]';
247
-                            }
248
-                            $label = str_replace(array('__REFORDER__', '__REFCUSTOMER__'), array($commande->ref, $commande->ref_client), $label);
249
-
250
-                            if(!empty($current_fk_commande)) {
251
-                                $subtotal_skip = true;
252
-                                TSubtotal::addTitle($facture, $label, 1, $rang);
253
-                                $rang++;
254
-                            }
255
-                        }
256
-
257
-                        $object->rang = $rang;
258
-					    $facture->updateRangOfLine($object->id, $rang);
259
-					    $rang++;
260
-					    // Est-ce qu'il s'agit de la dernière ligne de la commande d'origine ? Si oui alors on ajout un sous-total
261
-                            if ($last_fk_commandedet === (int) $object->origin_id && !empty($current_fk_commande))
262
-					    {
263
-                            $subtotal_skip = true;
264
-                            $subtotal_bloc_already_add_st = 1;
265
-                            TSubtotal::addTotal($facture, $langs->trans('SubTotal'), 1, $rang);
266
-                            $subtotal_bloc_already_add_st = 0;
267
-                            $rang++;
268
-					    }
269
-				    }
270
-
271
-				    $subtotal_bloc_previous_fk_commande = $current_fk_commande;
272
-				    $subtotal_current_rang = $rang;
273
-			    }
274
-		    }
221
+					$current_fk_commande = TSubtotal::getOrderIdFromLineId($this->db, $object->origin_id, $is_supplier);
222
+					$last_fk_commandedet = TSubtotal::getLastLineOrderId($this->db, $current_fk_commande, $is_supplier);
223
+
224
+					if (!$is_supplier){
225
+						$facture = new Facture($this->db);
226
+						$ret = $facture->fetch($object->fk_facture);
227
+					}
228
+					else
229
+					{
230
+						$facture = new FactureFournisseur($this->db);
231
+						$ret = $facture->fetch($object->fk_facture_fourn);
232
+					}
233
+
234
+					if ($ret > 0 && !$subtotal_bloc_already_add_st)
235
+					{
236
+						$rang = !empty($subtotal_current_rang) ? $subtotal_current_rang : $object->rang;
237
+						// Si le fk_commande courrant est différent alors on change de commande => ajout d'un titre
238
+						if ($current_fk_commande != $subtotal_bloc_previous_fk_commande ) {
239
+							if (!$is_supplier) $commande = new Commande($this->db);
240
+							else $commande = new CommandeFournisseur($this->db);
241
+							$commande->fetch($current_fk_commande);
242
+
243
+							$label = $conf->global->SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE;
244
+							if (empty($label)) {
245
+								$label = 'Commande [__REFORDER__]';
246
+								if (!$is_supplier) $label .= ' - Référence client : [__REFCUSTOMER__]';
247
+							}
248
+							$label = str_replace(array('__REFORDER__', '__REFCUSTOMER__'), array($commande->ref, $commande->ref_client), $label);
249
+
250
+							if(!empty($current_fk_commande)) {
251
+								$subtotal_skip = true;
252
+								TSubtotal::addTitle($facture, $label, 1, $rang);
253
+								$rang++;
254
+							}
255
+						}
256
+
257
+						$object->rang = $rang;
258
+						$facture->updateRangOfLine($object->id, $rang);
259
+						$rang++;
260
+						// Est-ce qu'il s'agit de la dernière ligne de la commande d'origine ? Si oui alors on ajout un sous-total
261
+							if ($last_fk_commandedet === (int) $object->origin_id && !empty($current_fk_commande))
262
+						{
263
+							$subtotal_skip = true;
264
+							$subtotal_bloc_already_add_st = 1;
265
+							TSubtotal::addTotal($facture, $langs->trans('SubTotal'), 1, $rang);
266
+							$subtotal_bloc_already_add_st = 0;
267
+							$rang++;
268
+						}
269
+					}
270
+
271
+					$subtotal_bloc_previous_fk_commande = $current_fk_commande;
272
+					$subtotal_current_rang = $rang;
273
+				}
274
+			}
275 275
 		
276 276
 		}
277 277
 		
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 		
287 287
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && in_array($action, array('LINEPROPAL_INSERT', 'LINEPROPAL_UPDATE', 'LINEORDER_INSERT', 'LINEORDER_UPDATE', 'LINEBILL_INSERT', 'LINEBILL_UPDATE', 'LINEBILL_SUPPLIER_CREATE', 'LINEBILL_SUPPLIER_UPDATE')))
288 288
 		{
289
-            if(! function_exists('_updateLineNC')) dol_include_once('/subtotal/lib/subtotal.lib.php');
289
+			if(! function_exists('_updateLineNC')) dol_include_once('/subtotal/lib/subtotal.lib.php');
290 290
 
291 291
 			$doli_action = GETPOST('action');
292 292
 			$set = GETPOST('set');
@@ -352,173 +352,173 @@  discard block
 block discarded – undo
352 352
 		}
353 353
 		
354 354
         
355
-        if ($action == 'USER_LOGIN') {
356
-            dol_syslog(
357
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
358
-            );
359
-        } elseif ($action == 'USER_UPDATE_SESSION') {
360
-            // Warning: To increase performances, this action is triggered only if
361
-            // constant MAIN_ACTIVATE_UPDATESESSIONTRIGGER is set to 1.
362
-            dol_syslog(
363
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
364
-            );
365
-        } elseif ($action == 'USER_CREATE') {
366
-            dol_syslog(
367
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
368
-            );
369
-        } elseif ($action == 'USER_CREATE_FROM_CONTACT') {
370
-            dol_syslog(
371
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
372
-            );
373
-        } elseif ($action == 'USER_MODIFY') {
374
-            dol_syslog(
375
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
376
-            );
377
-        } elseif ($action == 'USER_NEW_PASSWORD') {
378
-            dol_syslog(
379
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
380
-            );
381
-        } elseif ($action == 'USER_ENABLEDISABLE') {
382
-            dol_syslog(
383
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
384
-            );
385
-        } elseif ($action == 'USER_DELETE') {
386
-            dol_syslog(
387
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
388
-            );
389
-        } elseif ($action == 'USER_LOGOUT') {
390
-            dol_syslog(
391
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
392
-            );
393
-        } elseif ($action == 'USER_SETINGROUP') {
394
-            dol_syslog(
395
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
396
-            );
397
-        } elseif ($action == 'USER_REMOVEFROMGROUP') {
398
-            dol_syslog(
399
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
400
-            );
401
-        }
402
-
403
-        // Groups
404
-        elseif ($action == 'GROUP_CREATE') {
405
-            dol_syslog(
406
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
407
-            );
408
-        } elseif ($action == 'GROUP_MODIFY') {
409
-            dol_syslog(
410
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
411
-            );
412
-        } elseif ($action == 'GROUP_DELETE') {
413
-            dol_syslog(
414
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
415
-            );
416
-        }
417
-
418
-        // Companies
419
-        elseif ($action == 'COMPANY_CREATE') {
420
-            dol_syslog(
421
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
422
-            );
423
-        } elseif ($action == 'COMPANY_MODIFY') {
424
-            dol_syslog(
425
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
426
-            );
427
-        } elseif ($action == 'COMPANY_DELETE') {
428
-            dol_syslog(
429
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
430
-            );
431
-        }
432
-
433
-        // Contacts
434
-        elseif ($action == 'CONTACT_CREATE') {
435
-            dol_syslog(
436
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
437
-            );
438
-        } elseif ($action == 'CONTACT_MODIFY') {
439
-            dol_syslog(
440
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
441
-            );
442
-        } elseif ($action == 'CONTACT_DELETE') {
443
-            dol_syslog(
444
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
445
-            );
446
-        }
447
-
448
-        // Products
449
-        elseif ($action == 'PRODUCT_CREATE') {
450
-            dol_syslog(
451
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
452
-            );
453
-        } elseif ($action == 'PRODUCT_MODIFY') {
454
-            dol_syslog(
455
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
456
-            );
457
-        } elseif ($action == 'PRODUCT_DELETE') {
458
-            dol_syslog(
459
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
460
-            );
461
-        }
462
-
463
-        // Customer orders
464
-        elseif ($action == 'ORDER_CREATE') {
465
-            dol_syslog(
466
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
467
-            );
468
-        } elseif ($action == 'ORDER_VALIDATE') {
469
-            dol_syslog(
470
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
471
-            );
472
-        } elseif ($action == 'ORDER_DELETE') {
473
-            dol_syslog(
474
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
475
-            );
476
-        } elseif ($action == 'ORDER_BUILDDOC') {
477
-            dol_syslog(
478
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
479
-            );
480
-        } elseif ($action == 'ORDER_SENTBYMAIL') {
481
-            dol_syslog(
482
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
483
-            );
484
-        } elseif ($action == 'LINEORDER_INSERT') {
485
-            dol_syslog(
486
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
487
-            );
488
-        } elseif ($action == 'LINEORDER_DELETE') {
489
-            dol_syslog(
490
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
491
-            );
492
-        }
493
-
494
-        // Supplier orders
495
-        elseif ($action == 'ORDER_SUPPLIER_CREATE') {
496
-            dol_syslog(
497
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
498
-            );
499
-        } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') {
500
-            dol_syslog(
501
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
502
-            );
503
-        } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') {
504
-            dol_syslog(
505
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
506
-            );
507
-        } elseif ($action == 'SUPPLIER_ORDER_BUILDDOC') {
508
-            dol_syslog(
509
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
510
-            );
511
-        }
512
-
513
-        // Proposals
514
-        elseif ($action == 'PROPAL_CREATE') {
515
-            dol_syslog(
516
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
517
-            );
518
-        } elseif (in_array($action, array('PROPAL_CLONE', 'ORDER_CLONE', 'BILL_CLONE'))) {
519
-            dol_syslog(
520
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
521
-            );
355
+		if ($action == 'USER_LOGIN') {
356
+			dol_syslog(
357
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
358
+			);
359
+		} elseif ($action == 'USER_UPDATE_SESSION') {
360
+			// Warning: To increase performances, this action is triggered only if
361
+			// constant MAIN_ACTIVATE_UPDATESESSIONTRIGGER is set to 1.
362
+			dol_syslog(
363
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
364
+			);
365
+		} elseif ($action == 'USER_CREATE') {
366
+			dol_syslog(
367
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
368
+			);
369
+		} elseif ($action == 'USER_CREATE_FROM_CONTACT') {
370
+			dol_syslog(
371
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
372
+			);
373
+		} elseif ($action == 'USER_MODIFY') {
374
+			dol_syslog(
375
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
376
+			);
377
+		} elseif ($action == 'USER_NEW_PASSWORD') {
378
+			dol_syslog(
379
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
380
+			);
381
+		} elseif ($action == 'USER_ENABLEDISABLE') {
382
+			dol_syslog(
383
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
384
+			);
385
+		} elseif ($action == 'USER_DELETE') {
386
+			dol_syslog(
387
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
388
+			);
389
+		} elseif ($action == 'USER_LOGOUT') {
390
+			dol_syslog(
391
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
392
+			);
393
+		} elseif ($action == 'USER_SETINGROUP') {
394
+			dol_syslog(
395
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
396
+			);
397
+		} elseif ($action == 'USER_REMOVEFROMGROUP') {
398
+			dol_syslog(
399
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
400
+			);
401
+		}
402
+
403
+		// Groups
404
+		elseif ($action == 'GROUP_CREATE') {
405
+			dol_syslog(
406
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
407
+			);
408
+		} elseif ($action == 'GROUP_MODIFY') {
409
+			dol_syslog(
410
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
411
+			);
412
+		} elseif ($action == 'GROUP_DELETE') {
413
+			dol_syslog(
414
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
415
+			);
416
+		}
417
+
418
+		// Companies
419
+		elseif ($action == 'COMPANY_CREATE') {
420
+			dol_syslog(
421
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
422
+			);
423
+		} elseif ($action == 'COMPANY_MODIFY') {
424
+			dol_syslog(
425
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
426
+			);
427
+		} elseif ($action == 'COMPANY_DELETE') {
428
+			dol_syslog(
429
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
430
+			);
431
+		}
432
+
433
+		// Contacts
434
+		elseif ($action == 'CONTACT_CREATE') {
435
+			dol_syslog(
436
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
437
+			);
438
+		} elseif ($action == 'CONTACT_MODIFY') {
439
+			dol_syslog(
440
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
441
+			);
442
+		} elseif ($action == 'CONTACT_DELETE') {
443
+			dol_syslog(
444
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
445
+			);
446
+		}
447
+
448
+		// Products
449
+		elseif ($action == 'PRODUCT_CREATE') {
450
+			dol_syslog(
451
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
452
+			);
453
+		} elseif ($action == 'PRODUCT_MODIFY') {
454
+			dol_syslog(
455
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
456
+			);
457
+		} elseif ($action == 'PRODUCT_DELETE') {
458
+			dol_syslog(
459
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
460
+			);
461
+		}
462
+
463
+		// Customer orders
464
+		elseif ($action == 'ORDER_CREATE') {
465
+			dol_syslog(
466
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
467
+			);
468
+		} elseif ($action == 'ORDER_VALIDATE') {
469
+			dol_syslog(
470
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
471
+			);
472
+		} elseif ($action == 'ORDER_DELETE') {
473
+			dol_syslog(
474
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
475
+			);
476
+		} elseif ($action == 'ORDER_BUILDDOC') {
477
+			dol_syslog(
478
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
479
+			);
480
+		} elseif ($action == 'ORDER_SENTBYMAIL') {
481
+			dol_syslog(
482
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
483
+			);
484
+		} elseif ($action == 'LINEORDER_INSERT') {
485
+			dol_syslog(
486
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
487
+			);
488
+		} elseif ($action == 'LINEORDER_DELETE') {
489
+			dol_syslog(
490
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
491
+			);
492
+		}
493
+
494
+		// Supplier orders
495
+		elseif ($action == 'ORDER_SUPPLIER_CREATE') {
496
+			dol_syslog(
497
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
498
+			);
499
+		} elseif ($action == 'ORDER_SUPPLIER_VALIDATE') {
500
+			dol_syslog(
501
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
502
+			);
503
+		} elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') {
504
+			dol_syslog(
505
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
506
+			);
507
+		} elseif ($action == 'SUPPLIER_ORDER_BUILDDOC') {
508
+			dol_syslog(
509
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
510
+			);
511
+		}
512
+
513
+		// Proposals
514
+		elseif ($action == 'PROPAL_CREATE') {
515
+			dol_syslog(
516
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
517
+			);
518
+		} elseif (in_array($action, array('PROPAL_CLONE', 'ORDER_CLONE', 'BILL_CLONE'))) {
519
+			dol_syslog(
520
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
521
+			);
522 522
 			
523 523
 			$doli_action = GETPOST('action');
524 524
 
@@ -551,296 +551,296 @@  discard block
 block discarded – undo
551 551
 				if (!empty($line)) $object->update_price(1);
552 552
 			}
553 553
 			
554
-        } elseif ($action == 'PROPAL_MODIFY') {
555
-            dol_syslog(
556
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
557
-            );
558
-        } elseif ($action == 'PROPAL_VALIDATE') {
559
-            dol_syslog(
560
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
561
-            );
562
-        } elseif ($action == 'PROPAL_BUILDDOC') {
563
-            dol_syslog(
564
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
565
-            );
566
-        } elseif ($action == 'PROPAL_SENTBYMAIL') {
567
-            dol_syslog(
568
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
569
-            );
570
-        } elseif ($action == 'PROPAL_CLOSE_SIGNED') {
571
-            dol_syslog(
572
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
573
-            );
574
-        } elseif ($action == 'PROPAL_CLOSE_REFUSED') {
575
-            dol_syslog(
576
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
577
-            );
578
-        } elseif ($action == 'PROPAL_DELETE') {
579
-            dol_syslog(
580
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
581
-            );
582
-        } elseif ($action == 'LINEPROPAL_INSERT') {
583
-            dol_syslog(
584
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
585
-            );
586
-        } elseif ($action == 'LINEPROPAL_MODIFY') {
587
-            dol_syslog(
588
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
589
-            );
590
-        } elseif ($action == 'LINEPROPAL_DELETE') {
591
-            dol_syslog(
592
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
593
-            );
594
-        }
595
-
596
-        // Contracts
597
-        elseif ($action == 'CONTRACT_CREATE') {
598
-            dol_syslog(
599
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
600
-            );
601
-        } elseif ($action == 'CONTRACT_MODIFY') {
602
-            dol_syslog(
603
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
604
-            );
605
-        } elseif ($action == 'CONTRACT_ACTIVATE') {
606
-            dol_syslog(
607
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
608
-            );
609
-        } elseif ($action == 'CONTRACT_CANCEL') {
610
-            dol_syslog(
611
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
612
-            );
613
-        } elseif ($action == 'CONTRACT_CLOSE') {
614
-            dol_syslog(
615
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
616
-            );
617
-        } elseif ($action == 'CONTRACT_DELETE') {
618
-            dol_syslog(
619
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
620
-            );
621
-        }
554
+		} elseif ($action == 'PROPAL_MODIFY') {
555
+			dol_syslog(
556
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
557
+			);
558
+		} elseif ($action == 'PROPAL_VALIDATE') {
559
+			dol_syslog(
560
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
561
+			);
562
+		} elseif ($action == 'PROPAL_BUILDDOC') {
563
+			dol_syslog(
564
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
565
+			);
566
+		} elseif ($action == 'PROPAL_SENTBYMAIL') {
567
+			dol_syslog(
568
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
569
+			);
570
+		} elseif ($action == 'PROPAL_CLOSE_SIGNED') {
571
+			dol_syslog(
572
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
573
+			);
574
+		} elseif ($action == 'PROPAL_CLOSE_REFUSED') {
575
+			dol_syslog(
576
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
577
+			);
578
+		} elseif ($action == 'PROPAL_DELETE') {
579
+			dol_syslog(
580
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
581
+			);
582
+		} elseif ($action == 'LINEPROPAL_INSERT') {
583
+			dol_syslog(
584
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
585
+			);
586
+		} elseif ($action == 'LINEPROPAL_MODIFY') {
587
+			dol_syslog(
588
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
589
+			);
590
+		} elseif ($action == 'LINEPROPAL_DELETE') {
591
+			dol_syslog(
592
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
593
+			);
594
+		}
595
+
596
+		// Contracts
597
+		elseif ($action == 'CONTRACT_CREATE') {
598
+			dol_syslog(
599
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
600
+			);
601
+		} elseif ($action == 'CONTRACT_MODIFY') {
602
+			dol_syslog(
603
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
604
+			);
605
+		} elseif ($action == 'CONTRACT_ACTIVATE') {
606
+			dol_syslog(
607
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
608
+			);
609
+		} elseif ($action == 'CONTRACT_CANCEL') {
610
+			dol_syslog(
611
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
612
+			);
613
+		} elseif ($action == 'CONTRACT_CLOSE') {
614
+			dol_syslog(
615
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
616
+			);
617
+		} elseif ($action == 'CONTRACT_DELETE') {
618
+			dol_syslog(
619
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
620
+			);
621
+		}
622 622
 
623 623
 		elseif ($action == 'BILL_MODIFY') {
624
-            dol_syslog(
625
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
626
-            );
627
-
628
-
629
-            global $conf;
630
-
631
-            if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
632
-            {
633
-                $object->situation_final = 1;
634
-                foreach($object->lines as $i => $line) {
635
-                    if(!TSubtotal::isModSubtotalLine($line) && $line->situation_percent != 100){
636
-                        $object->situation_final = 0;
637
-                        break;
638
-                    }
639
-                }
640
-                // ne pas utiliser $object->setFinal ne peut pas marcher
641
-                $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET situation_final = ' . $object->situation_final . ' where rowid = ' . $object->id;
642
-                $resql=$object->db->query($sql);
643
-            }
644
-
645
-
646
-        } elseif ($action == 'BILL_VALIDATE') {
647
-            dol_syslog(
648
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
649
-            );
650
-        } elseif ($action == 'BILL_BUILDDOC') {
651
-            dol_syslog(
652
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
653
-            );
654
-        } elseif ($action == 'BILL_SENTBYMAIL') {
655
-            dol_syslog(
656
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
657
-            );
658
-        } elseif ($action == 'BILL_CANCEL') {
659
-            dol_syslog(
660
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
661
-            );
662
-        } elseif ($action == 'BILL_DELETE') {
663
-            dol_syslog(
664
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
665
-            );
666
-        } elseif ($action == 'LINEBILL_INSERT') {
624
+			dol_syslog(
625
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
626
+			);
627
+
628
+
629
+			global $conf;
630
+
631
+			if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
632
+			{
633
+				$object->situation_final = 1;
634
+				foreach($object->lines as $i => $line) {
635
+					if(!TSubtotal::isModSubtotalLine($line) && $line->situation_percent != 100){
636
+						$object->situation_final = 0;
637
+						break;
638
+					}
639
+				}
640
+				// ne pas utiliser $object->setFinal ne peut pas marcher
641
+				$sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET situation_final = ' . $object->situation_final . ' where rowid = ' . $object->id;
642
+				$resql=$object->db->query($sql);
643
+			}
644
+
645
+
646
+		} elseif ($action == 'BILL_VALIDATE') {
647
+			dol_syslog(
648
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
649
+			);
650
+		} elseif ($action == 'BILL_BUILDDOC') {
651
+			dol_syslog(
652
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
653
+			);
654
+		} elseif ($action == 'BILL_SENTBYMAIL') {
655
+			dol_syslog(
656
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
657
+			);
658
+		} elseif ($action == 'BILL_CANCEL') {
659
+			dol_syslog(
660
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
661
+			);
662
+		} elseif ($action == 'BILL_DELETE') {
663
+			dol_syslog(
664
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
665
+			);
666
+		} elseif ($action == 'LINEBILL_INSERT') {
667 667
 				
668
-        	dol_syslog(
669
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
670
-            );
671
-        } elseif ($action == 'LINEBILL_DELETE') {
672
-            dol_syslog(
673
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
674
-            );
675
-        }
676
-
677
-        // Payments
678
-        elseif ($action == 'PAYMENT_CUSTOMER_CREATE') {
679
-            dol_syslog(
680
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
681
-            );
682
-        } elseif ($action == 'PAYMENT_SUPPLIER_CREATE') {
683
-            dol_syslog(
684
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
685
-            );
686
-        } elseif ($action == 'PAYMENT_ADD_TO_BANK') {
687
-            dol_syslog(
688
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
689
-            );
690
-        } elseif ($action == 'PAYMENT_DELETE') {
691
-            dol_syslog(
692
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
693
-            );
694
-        }
695
-
696
-        // Interventions
697
-        elseif ($action == 'FICHEINTER_CREATE') {
698
-            dol_syslog(
699
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
700
-            );
701
-        } elseif ($action == 'FICHEINTER_MODIFY') {
702
-            dol_syslog(
703
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
704
-            );
705
-        } elseif ($action == 'FICHEINTER_VALIDATE') {
706
-            dol_syslog(
707
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
708
-            );
709
-        } elseif ($action == 'FICHEINTER_DELETE') {
710
-            dol_syslog(
711
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
712
-            );
713
-        }
714
-
715
-        // Members
716
-        elseif ($action == 'MEMBER_CREATE') {
717
-            dol_syslog(
718
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
719
-            );
720
-        } elseif ($action == 'MEMBER_VALIDATE') {
721
-            dol_syslog(
722
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
723
-            );
724
-        } elseif ($action == 'MEMBER_SUBSCRIPTION') {
725
-            dol_syslog(
726
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
727
-            );
728
-        } elseif ($action == 'MEMBER_MODIFY') {
729
-            dol_syslog(
730
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
731
-            );
732
-        } elseif ($action == 'MEMBER_NEW_PASSWORD') {
733
-            dol_syslog(
734
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
735
-            );
736
-        } elseif ($action == 'MEMBER_RESILIATE') {
737
-            dol_syslog(
738
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
739
-            );
740
-        } elseif ($action == 'MEMBER_DELETE') {
741
-            dol_syslog(
742
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
743
-            );
744
-        }
745
-
746
-        // Categories
747
-        elseif ($action == 'CATEGORY_CREATE') {
748
-            dol_syslog(
749
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
750
-            );
751
-        } elseif ($action == 'CATEGORY_MODIFY') {
752
-            dol_syslog(
753
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
754
-            );
755
-        } elseif ($action == 'CATEGORY_DELETE') {
756
-            dol_syslog(
757
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
758
-            );
759
-        }
760
-
761
-        // Projects
762
-        elseif ($action == 'PROJECT_CREATE') {
763
-            dol_syslog(
764
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
765
-            );
766
-        } elseif ($action == 'PROJECT_MODIFY') {
767
-            dol_syslog(
768
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
769
-            );
770
-        } elseif ($action == 'PROJECT_DELETE') {
771
-            dol_syslog(
772
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
773
-            );
774
-        }
775
-
776
-        // Project tasks
777
-        elseif ($action == 'TASK_CREATE') {
778
-            dol_syslog(
779
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
780
-            );
781
-        } elseif ($action == 'TASK_MODIFY') {
782
-            dol_syslog(
783
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
784
-            );
785
-        } elseif ($action == 'TASK_DELETE') {
786
-            dol_syslog(
787
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
788
-            );
789
-        }
790
-
791
-        // Task time spent
792
-        elseif ($action == 'TASK_TIMESPENT_CREATE') {
793
-            dol_syslog(
794
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
795
-            );
796
-        } elseif ($action == 'TASK_TIMESPENT_MODIFY') {
797
-            dol_syslog(
798
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
799
-            );
800
-        } elseif ($action == 'TASK_TIMESPENT_DELETE') {
801
-            dol_syslog(
802
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
803
-            );
804
-        }
805
-
806
-        // Shipping
807
-        elseif ($action == 'SHIPPING_CREATE') {
808
-            dol_syslog(
809
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
810
-            );
811
-        } elseif ($action == 'SHIPPING_MODIFY') {
812
-            dol_syslog(
813
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
814
-            );
815
-        } elseif ($action == 'SHIPPING_VALIDATE') {
816
-            dol_syslog(
817
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
818
-            );
819
-        } elseif ($action == 'SHIPPING_SENTBYMAIL') {
820
-            dol_syslog(
821
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
822
-            );
823
-        } elseif ($action == 'SHIPPING_DELETE') {
824
-            dol_syslog(
825
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
826
-            );
827
-        } elseif ($action == 'SHIPPING_BUILDDOC') {
828
-            dol_syslog(
829
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
830
-            );
831
-        }
832
-
833
-        // File
834
-        elseif ($action == 'FILE_UPLOAD') {
835
-            dol_syslog(
836
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
837
-            );
838
-        } elseif ($action == 'FILE_DELETE') {
839
-            dol_syslog(
840
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
841
-            );
842
-        }
843
-
844
-        return 0;
845
-    }
668
+			dol_syslog(
669
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
670
+			);
671
+		} elseif ($action == 'LINEBILL_DELETE') {
672
+			dol_syslog(
673
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
674
+			);
675
+		}
676
+
677
+		// Payments
678
+		elseif ($action == 'PAYMENT_CUSTOMER_CREATE') {
679
+			dol_syslog(
680
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
681
+			);
682
+		} elseif ($action == 'PAYMENT_SUPPLIER_CREATE') {
683
+			dol_syslog(
684
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
685
+			);
686
+		} elseif ($action == 'PAYMENT_ADD_TO_BANK') {
687
+			dol_syslog(
688
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
689
+			);
690
+		} elseif ($action == 'PAYMENT_DELETE') {
691
+			dol_syslog(
692
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
693
+			);
694
+		}
695
+
696
+		// Interventions
697
+		elseif ($action == 'FICHEINTER_CREATE') {
698
+			dol_syslog(
699
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
700
+			);
701
+		} elseif ($action == 'FICHEINTER_MODIFY') {
702
+			dol_syslog(
703
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
704
+			);
705
+		} elseif ($action == 'FICHEINTER_VALIDATE') {
706
+			dol_syslog(
707
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
708
+			);
709
+		} elseif ($action == 'FICHEINTER_DELETE') {
710
+			dol_syslog(
711
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
712
+			);
713
+		}
714
+
715
+		// Members
716
+		elseif ($action == 'MEMBER_CREATE') {
717
+			dol_syslog(
718
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
719
+			);
720
+		} elseif ($action == 'MEMBER_VALIDATE') {
721
+			dol_syslog(
722
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
723
+			);
724
+		} elseif ($action == 'MEMBER_SUBSCRIPTION') {
725
+			dol_syslog(
726
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
727
+			);
728
+		} elseif ($action == 'MEMBER_MODIFY') {
729
+			dol_syslog(
730
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
731
+			);
732
+		} elseif ($action == 'MEMBER_NEW_PASSWORD') {
733
+			dol_syslog(
734
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
735
+			);
736
+		} elseif ($action == 'MEMBER_RESILIATE') {
737
+			dol_syslog(
738
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
739
+			);
740
+		} elseif ($action == 'MEMBER_DELETE') {
741
+			dol_syslog(
742
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
743
+			);
744
+		}
745
+
746
+		// Categories
747
+		elseif ($action == 'CATEGORY_CREATE') {
748
+			dol_syslog(
749
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
750
+			);
751
+		} elseif ($action == 'CATEGORY_MODIFY') {
752
+			dol_syslog(
753
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
754
+			);
755
+		} elseif ($action == 'CATEGORY_DELETE') {
756
+			dol_syslog(
757
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
758
+			);
759
+		}
760
+
761
+		// Projects
762
+		elseif ($action == 'PROJECT_CREATE') {
763
+			dol_syslog(
764
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
765
+			);
766
+		} elseif ($action == 'PROJECT_MODIFY') {
767
+			dol_syslog(
768
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
769
+			);
770
+		} elseif ($action == 'PROJECT_DELETE') {
771
+			dol_syslog(
772
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
773
+			);
774
+		}
775
+
776
+		// Project tasks
777
+		elseif ($action == 'TASK_CREATE') {
778
+			dol_syslog(
779
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
780
+			);
781
+		} elseif ($action == 'TASK_MODIFY') {
782
+			dol_syslog(
783
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
784
+			);
785
+		} elseif ($action == 'TASK_DELETE') {
786
+			dol_syslog(
787
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
788
+			);
789
+		}
790
+
791
+		// Task time spent
792
+		elseif ($action == 'TASK_TIMESPENT_CREATE') {
793
+			dol_syslog(
794
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
795
+			);
796
+		} elseif ($action == 'TASK_TIMESPENT_MODIFY') {
797
+			dol_syslog(
798
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
799
+			);
800
+		} elseif ($action == 'TASK_TIMESPENT_DELETE') {
801
+			dol_syslog(
802
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
803
+			);
804
+		}
805
+
806
+		// Shipping
807
+		elseif ($action == 'SHIPPING_CREATE') {
808
+			dol_syslog(
809
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
810
+			);
811
+		} elseif ($action == 'SHIPPING_MODIFY') {
812
+			dol_syslog(
813
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
814
+			);
815
+		} elseif ($action == 'SHIPPING_VALIDATE') {
816
+			dol_syslog(
817
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
818
+			);
819
+		} elseif ($action == 'SHIPPING_SENTBYMAIL') {
820
+			dol_syslog(
821
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
822
+			);
823
+		} elseif ($action == 'SHIPPING_DELETE') {
824
+			dol_syslog(
825
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
826
+			);
827
+		} elseif ($action == 'SHIPPING_BUILDDOC') {
828
+			dol_syslog(
829
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
830
+			);
831
+		}
832
+
833
+		// File
834
+		elseif ($action == 'FILE_UPLOAD') {
835
+			dol_syslog(
836
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
837
+			);
838
+		} elseif ($action == 'FILE_DELETE') {
839
+			dol_syslog(
840
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
841
+			);
842
+		}
843
+
844
+		return 0;
845
+	}
846 846
 }
Please login to merge, or discard this patch.
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
 			if ($object->id != $line->id && $line->rang > $rang)
108 108
 			{
109 109
 				// Update du rang de toutes les lignes suivant mon titre
110
-				$parent->updateRangOfLine($line->id, $line->rang+1);
110
+				$parent->updateRangOfLine($line->id, $line->rang + 1);
111 111
 			}
112 112
 		}
113 113
 		
114 114
 		// Update du rang de la ligne fraichement ajouté pour la déplacer sous mon titre
115
-		$parent->updateRangOfLine($object->id, $rang+1);
116
-		$object->rang = $rang+1;
115
+		$parent->updateRangOfLine($object->id, $rang + 1);
116
+		$object->rang = $rang + 1;
117 117
 	}
118 118
 	
119 119
 	public function addToEnd(&$parent, &$object, $rang)
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 			
137 137
 			if ($subtotal_line_found)
138 138
 			{
139
-				$parent->updateRangOfLine($line->id, $line->rang+1);
139
+				$parent->updateRangOfLine($line->id, $line->rang + 1);
140 140
 			}
141 141
 		}
142 142
 		
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 				    $current_fk_commande = TSubtotal::getOrderIdFromLineId($this->db, $object->origin_id, $is_supplier);
222 222
 				    $last_fk_commandedet = TSubtotal::getLastLineOrderId($this->db, $current_fk_commande, $is_supplier);
223 223
 
224
-				    if (!$is_supplier){
224
+				    if (!$is_supplier) {
225 225
 				        $facture = new Facture($this->db);
226 226
 				        $ret = $facture->fetch($object->fk_facture);
227 227
                     }
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 				    {
236 236
 					    $rang = !empty($subtotal_current_rang) ? $subtotal_current_rang : $object->rang;
237 237
 					    // Si le fk_commande courrant est différent alors on change de commande => ajout d'un titre
238
-					    if ($current_fk_commande != $subtotal_bloc_previous_fk_commande ) {
238
+					    if ($current_fk_commande != $subtotal_bloc_previous_fk_commande) {
239 239
                             if (!$is_supplier) $commande = new Commande($this->db);
240 240
                             else $commande = new CommandeFournisseur($this->db);
241 241
                             $commande->fetch($current_fk_commande);
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
                             }
248 248
                             $label = str_replace(array('__REFORDER__', '__REFCUSTOMER__'), array($commande->ref, $commande->ref_client), $label);
249 249
 
250
-                            if(!empty($current_fk_commande)) {
250
+                            if (!empty($current_fk_commande)) {
251 251
                                 $subtotal_skip = true;
252 252
                                 TSubtotal::addTitle($facture, $label, 1, $rang);
253 253
                                 $rang++;
@@ -286,14 +286,14 @@  discard block
 block discarded – undo
286 286
 		
287 287
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && in_array($action, array('LINEPROPAL_INSERT', 'LINEPROPAL_UPDATE', 'LINEORDER_INSERT', 'LINEORDER_UPDATE', 'LINEBILL_INSERT', 'LINEBILL_UPDATE', 'LINEBILL_SUPPLIER_CREATE', 'LINEBILL_SUPPLIER_UPDATE')))
288 288
 		{
289
-            if(! function_exists('_updateLineNC')) dol_include_once('/subtotal/lib/subtotal.lib.php');
289
+            if (!function_exists('_updateLineNC')) dol_include_once('/subtotal/lib/subtotal.lib.php');
290 290
 
291 291
 			$doli_action = GETPOST('action');
292 292
 			$set = GETPOST('set');
293
-			if ( (in_array($doli_action, array('updateligne', 'updateline', 'addline', 'add', 'create', 'setstatut')) || $set == 'defaultTVA') && !TSubtotal::isTitle($object) && !TSubtotal::isSubtotal($object) && in_array($object->element, array('propaldet', 'commandedet', 'facturedet')))
293
+			if ((in_array($doli_action, array('updateligne', 'updateline', 'addline', 'add', 'create', 'setstatut')) || $set == 'defaultTVA') && !TSubtotal::isTitle($object) && !TSubtotal::isSubtotal($object) && in_array($object->element, array('propaldet', 'commandedet', 'facturedet')))
294 294
 			{
295 295
 				 dol_syslog(
296
-					"[SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS] Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". object=".$object->element." id=" . $object->id
296
+					"[SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS] Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". object=".$object->element." id=".$object->id
297 297
 				);
298 298
 				 
299 299
 				$TTitle = TSubtotal::getAllTitleFromLine($object);
@@ -313,9 +313,9 @@  discard block
 block discarded – undo
313 313
 				}
314 314
 
315 315
 				// $object correspond à la ligne ajoutée
316
-				if(empty($object->array_options)) $object->fetch_optionals();
316
+				if (empty($object->array_options)) $object->fetch_optionals();
317 317
 
318
-				if(! empty($object->array_options['options_subtotal_nc'])) {
318
+				if (!empty($object->array_options['options_subtotal_nc'])) {
319 319
 					$object->total_ht = $object->total_tva = $object->total_ttc = $object->total_localtax1 = $object->total_localtax2 = 
320 320
 							$object->multicurrency_total_ht = $object->multicurrency_total_tva = $object->multicurrency_total_ttc = 0;
321 321
 
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
 
328 328
 				// Correction d'un bug lors de la création d'une commande depuis une propale qui a, au moins, une ligne NC
329 329
 				$parent_element = '';
330
-				if($object->element == 'propaldet') $parent_element = 'propal';
331
-				if($object->element == 'commandedet') $parent_element = 'commande';
332
-				if($object->element == 'facturedet') $parent_element = 'facture';
330
+				if ($object->element == 'propaldet') $parent_element = 'propal';
331
+				if ($object->element == 'commandedet') $parent_element = 'commande';
332
+				if ($object->element == 'facturedet') $parent_element = 'facture';
333 333
 
334
-				if(! empty($parent_element) && ! empty($object->array_options['options_subtotal_nc'])) {
334
+				if (!empty($parent_element) && !empty($object->array_options['options_subtotal_nc'])) {
335 335
 					_updateLineNC($parent_element, $object->{'fk_'.$parent_element}, $object->id, $object->array_options['options_subtotal_nc'], 1);
336 336
 				}
337 337
 			}
@@ -339,12 +339,12 @@  discard block
 block discarded – undo
339 339
 		
340 340
 		// Les lignes libres (y compris les sous-totaux) créées à partir d'une facture modèle n'ont pas la TVA de la ligne du modèle mais la TVA par défaut
341 341
 		if ($action == 'BILL_CREATE' && $object->fac_rec > 0) {
342
-			dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
342
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
343 343
 
344 344
 			$object->fetch_lines(); // Lignes pas rajoutées à $object->lines par les appels à addline();
345 345
 
346
-			foreach($object->lines as &$line) {
347
-				if(TSubtotal::isSubtotal($line) && ! empty($line->tva_tx)) {
346
+			foreach ($object->lines as &$line) {
347
+				if (TSubtotal::isSubtotal($line) && !empty($line->tva_tx)) {
348 348
 					$line->tva_tx = 0;
349 349
 					$line->update();
350 350
 				}
@@ -354,170 +354,170 @@  discard block
 block discarded – undo
354 354
         
355 355
         if ($action == 'USER_LOGIN') {
356 356
             dol_syslog(
357
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
357
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
358 358
             );
359 359
         } elseif ($action == 'USER_UPDATE_SESSION') {
360 360
             // Warning: To increase performances, this action is triggered only if
361 361
             // constant MAIN_ACTIVATE_UPDATESESSIONTRIGGER is set to 1.
362 362
             dol_syslog(
363
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
363
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
364 364
             );
365 365
         } elseif ($action == 'USER_CREATE') {
366 366
             dol_syslog(
367
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
367
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
368 368
             );
369 369
         } elseif ($action == 'USER_CREATE_FROM_CONTACT') {
370 370
             dol_syslog(
371
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
371
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
372 372
             );
373 373
         } elseif ($action == 'USER_MODIFY') {
374 374
             dol_syslog(
375
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
375
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
376 376
             );
377 377
         } elseif ($action == 'USER_NEW_PASSWORD') {
378 378
             dol_syslog(
379
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
379
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
380 380
             );
381 381
         } elseif ($action == 'USER_ENABLEDISABLE') {
382 382
             dol_syslog(
383
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
383
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
384 384
             );
385 385
         } elseif ($action == 'USER_DELETE') {
386 386
             dol_syslog(
387
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
387
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
388 388
             );
389 389
         } elseif ($action == 'USER_LOGOUT') {
390 390
             dol_syslog(
391
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
391
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
392 392
             );
393 393
         } elseif ($action == 'USER_SETINGROUP') {
394 394
             dol_syslog(
395
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
395
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
396 396
             );
397 397
         } elseif ($action == 'USER_REMOVEFROMGROUP') {
398 398
             dol_syslog(
399
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
399
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
400 400
             );
401 401
         }
402 402
 
403 403
         // Groups
404 404
         elseif ($action == 'GROUP_CREATE') {
405 405
             dol_syslog(
406
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
406
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
407 407
             );
408 408
         } elseif ($action == 'GROUP_MODIFY') {
409 409
             dol_syslog(
410
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
410
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
411 411
             );
412 412
         } elseif ($action == 'GROUP_DELETE') {
413 413
             dol_syslog(
414
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
414
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
415 415
             );
416 416
         }
417 417
 
418 418
         // Companies
419 419
         elseif ($action == 'COMPANY_CREATE') {
420 420
             dol_syslog(
421
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
421
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
422 422
             );
423 423
         } elseif ($action == 'COMPANY_MODIFY') {
424 424
             dol_syslog(
425
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
425
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
426 426
             );
427 427
         } elseif ($action == 'COMPANY_DELETE') {
428 428
             dol_syslog(
429
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
429
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
430 430
             );
431 431
         }
432 432
 
433 433
         // Contacts
434 434
         elseif ($action == 'CONTACT_CREATE') {
435 435
             dol_syslog(
436
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
436
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
437 437
             );
438 438
         } elseif ($action == 'CONTACT_MODIFY') {
439 439
             dol_syslog(
440
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
440
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
441 441
             );
442 442
         } elseif ($action == 'CONTACT_DELETE') {
443 443
             dol_syslog(
444
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
444
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
445 445
             );
446 446
         }
447 447
 
448 448
         // Products
449 449
         elseif ($action == 'PRODUCT_CREATE') {
450 450
             dol_syslog(
451
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
451
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
452 452
             );
453 453
         } elseif ($action == 'PRODUCT_MODIFY') {
454 454
             dol_syslog(
455
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
455
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
456 456
             );
457 457
         } elseif ($action == 'PRODUCT_DELETE') {
458 458
             dol_syslog(
459
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
459
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
460 460
             );
461 461
         }
462 462
 
463 463
         // Customer orders
464 464
         elseif ($action == 'ORDER_CREATE') {
465 465
             dol_syslog(
466
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
466
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
467 467
             );
468 468
         } elseif ($action == 'ORDER_VALIDATE') {
469 469
             dol_syslog(
470
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
470
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
471 471
             );
472 472
         } elseif ($action == 'ORDER_DELETE') {
473 473
             dol_syslog(
474
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
474
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
475 475
             );
476 476
         } elseif ($action == 'ORDER_BUILDDOC') {
477 477
             dol_syslog(
478
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
478
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
479 479
             );
480 480
         } elseif ($action == 'ORDER_SENTBYMAIL') {
481 481
             dol_syslog(
482
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
482
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
483 483
             );
484 484
         } elseif ($action == 'LINEORDER_INSERT') {
485 485
             dol_syslog(
486
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
486
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
487 487
             );
488 488
         } elseif ($action == 'LINEORDER_DELETE') {
489 489
             dol_syslog(
490
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
490
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
491 491
             );
492 492
         }
493 493
 
494 494
         // Supplier orders
495 495
         elseif ($action == 'ORDER_SUPPLIER_CREATE') {
496 496
             dol_syslog(
497
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
497
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
498 498
             );
499 499
         } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') {
500 500
             dol_syslog(
501
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
501
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
502 502
             );
503 503
         } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') {
504 504
             dol_syslog(
505
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
505
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
506 506
             );
507 507
         } elseif ($action == 'SUPPLIER_ORDER_BUILDDOC') {
508 508
             dol_syslog(
509
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
509
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
510 510
             );
511 511
         }
512 512
 
513 513
         // Proposals
514 514
         elseif ($action == 'PROPAL_CREATE') {
515 515
             dol_syslog(
516
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
516
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
517 517
             );
518 518
         } elseif (in_array($action, array('PROPAL_CLONE', 'ORDER_CLONE', 'BILL_CLONE'))) {
519 519
             dol_syslog(
520
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
520
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
521 521
             );
522 522
 			
523 523
 			$doli_action = GETPOST('action');
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 			if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && in_array($doli_action, array('confirm_clone')))
526 526
 			{
527 527
 				dol_syslog(
528
-					"[SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS] Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". object=".$object->element." id=" . $object->id
528
+					"[SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS] Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". object=".$object->element." id=".$object->id
529 529
 				);
530 530
 				
531 531
 				// En fonction de l'objet et de la version, les lignes conservent l'id de l'objet d'origine
@@ -553,76 +553,76 @@  discard block
 block discarded – undo
553 553
 			
554 554
         } elseif ($action == 'PROPAL_MODIFY') {
555 555
             dol_syslog(
556
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
556
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
557 557
             );
558 558
         } elseif ($action == 'PROPAL_VALIDATE') {
559 559
             dol_syslog(
560
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
560
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
561 561
             );
562 562
         } elseif ($action == 'PROPAL_BUILDDOC') {
563 563
             dol_syslog(
564
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
564
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
565 565
             );
566 566
         } elseif ($action == 'PROPAL_SENTBYMAIL') {
567 567
             dol_syslog(
568
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
568
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
569 569
             );
570 570
         } elseif ($action == 'PROPAL_CLOSE_SIGNED') {
571 571
             dol_syslog(
572
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
572
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
573 573
             );
574 574
         } elseif ($action == 'PROPAL_CLOSE_REFUSED') {
575 575
             dol_syslog(
576
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
576
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
577 577
             );
578 578
         } elseif ($action == 'PROPAL_DELETE') {
579 579
             dol_syslog(
580
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
580
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
581 581
             );
582 582
         } elseif ($action == 'LINEPROPAL_INSERT') {
583 583
             dol_syslog(
584
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
584
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
585 585
             );
586 586
         } elseif ($action == 'LINEPROPAL_MODIFY') {
587 587
             dol_syslog(
588
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
588
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
589 589
             );
590 590
         } elseif ($action == 'LINEPROPAL_DELETE') {
591 591
             dol_syslog(
592
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
592
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
593 593
             );
594 594
         }
595 595
 
596 596
         // Contracts
597 597
         elseif ($action == 'CONTRACT_CREATE') {
598 598
             dol_syslog(
599
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
599
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
600 600
             );
601 601
         } elseif ($action == 'CONTRACT_MODIFY') {
602 602
             dol_syslog(
603
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
603
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
604 604
             );
605 605
         } elseif ($action == 'CONTRACT_ACTIVATE') {
606 606
             dol_syslog(
607
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
607
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
608 608
             );
609 609
         } elseif ($action == 'CONTRACT_CANCEL') {
610 610
             dol_syslog(
611
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
611
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
612 612
             );
613 613
         } elseif ($action == 'CONTRACT_CLOSE') {
614 614
             dol_syslog(
615
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
615
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
616 616
             );
617 617
         } elseif ($action == 'CONTRACT_DELETE') {
618 618
             dol_syslog(
619
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
619
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
620 620
             );
621 621
         }
622 622
 
623 623
 		elseif ($action == 'BILL_MODIFY') {
624 624
             dol_syslog(
625
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
625
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
626 626
             );
627 627
 
628 628
 
@@ -631,213 +631,213 @@  discard block
 block discarded – undo
631 631
             if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
632 632
             {
633 633
                 $object->situation_final = 1;
634
-                foreach($object->lines as $i => $line) {
635
-                    if(!TSubtotal::isModSubtotalLine($line) && $line->situation_percent != 100){
634
+                foreach ($object->lines as $i => $line) {
635
+                    if (!TSubtotal::isModSubtotalLine($line) && $line->situation_percent != 100) {
636 636
                         $object->situation_final = 0;
637 637
                         break;
638 638
                     }
639 639
                 }
640 640
                 // ne pas utiliser $object->setFinal ne peut pas marcher
641
-                $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET situation_final = ' . $object->situation_final . ' where rowid = ' . $object->id;
642
-                $resql=$object->db->query($sql);
641
+                $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET situation_final = '.$object->situation_final.' where rowid = '.$object->id;
642
+                $resql = $object->db->query($sql);
643 643
             }
644 644
 
645 645
 
646 646
         } elseif ($action == 'BILL_VALIDATE') {
647 647
             dol_syslog(
648
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
648
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
649 649
             );
650 650
         } elseif ($action == 'BILL_BUILDDOC') {
651 651
             dol_syslog(
652
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
652
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
653 653
             );
654 654
         } elseif ($action == 'BILL_SENTBYMAIL') {
655 655
             dol_syslog(
656
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
656
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
657 657
             );
658 658
         } elseif ($action == 'BILL_CANCEL') {
659 659
             dol_syslog(
660
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
660
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
661 661
             );
662 662
         } elseif ($action == 'BILL_DELETE') {
663 663
             dol_syslog(
664
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
664
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
665 665
             );
666 666
         } elseif ($action == 'LINEBILL_INSERT') {
667 667
 				
668 668
         	dol_syslog(
669
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
669
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
670 670
             );
671 671
         } elseif ($action == 'LINEBILL_DELETE') {
672 672
             dol_syslog(
673
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
673
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
674 674
             );
675 675
         }
676 676
 
677 677
         // Payments
678 678
         elseif ($action == 'PAYMENT_CUSTOMER_CREATE') {
679 679
             dol_syslog(
680
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
680
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
681 681
             );
682 682
         } elseif ($action == 'PAYMENT_SUPPLIER_CREATE') {
683 683
             dol_syslog(
684
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
684
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
685 685
             );
686 686
         } elseif ($action == 'PAYMENT_ADD_TO_BANK') {
687 687
             dol_syslog(
688
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
688
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
689 689
             );
690 690
         } elseif ($action == 'PAYMENT_DELETE') {
691 691
             dol_syslog(
692
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
692
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
693 693
             );
694 694
         }
695 695
 
696 696
         // Interventions
697 697
         elseif ($action == 'FICHEINTER_CREATE') {
698 698
             dol_syslog(
699
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
699
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
700 700
             );
701 701
         } elseif ($action == 'FICHEINTER_MODIFY') {
702 702
             dol_syslog(
703
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
703
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
704 704
             );
705 705
         } elseif ($action == 'FICHEINTER_VALIDATE') {
706 706
             dol_syslog(
707
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
707
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
708 708
             );
709 709
         } elseif ($action == 'FICHEINTER_DELETE') {
710 710
             dol_syslog(
711
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
711
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
712 712
             );
713 713
         }
714 714
 
715 715
         // Members
716 716
         elseif ($action == 'MEMBER_CREATE') {
717 717
             dol_syslog(
718
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
718
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
719 719
             );
720 720
         } elseif ($action == 'MEMBER_VALIDATE') {
721 721
             dol_syslog(
722
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
722
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
723 723
             );
724 724
         } elseif ($action == 'MEMBER_SUBSCRIPTION') {
725 725
             dol_syslog(
726
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
726
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
727 727
             );
728 728
         } elseif ($action == 'MEMBER_MODIFY') {
729 729
             dol_syslog(
730
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
730
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
731 731
             );
732 732
         } elseif ($action == 'MEMBER_NEW_PASSWORD') {
733 733
             dol_syslog(
734
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
734
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
735 735
             );
736 736
         } elseif ($action == 'MEMBER_RESILIATE') {
737 737
             dol_syslog(
738
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
738
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
739 739
             );
740 740
         } elseif ($action == 'MEMBER_DELETE') {
741 741
             dol_syslog(
742
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
742
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
743 743
             );
744 744
         }
745 745
 
746 746
         // Categories
747 747
         elseif ($action == 'CATEGORY_CREATE') {
748 748
             dol_syslog(
749
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
749
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
750 750
             );
751 751
         } elseif ($action == 'CATEGORY_MODIFY') {
752 752
             dol_syslog(
753
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
753
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
754 754
             );
755 755
         } elseif ($action == 'CATEGORY_DELETE') {
756 756
             dol_syslog(
757
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
757
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
758 758
             );
759 759
         }
760 760
 
761 761
         // Projects
762 762
         elseif ($action == 'PROJECT_CREATE') {
763 763
             dol_syslog(
764
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
764
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
765 765
             );
766 766
         } elseif ($action == 'PROJECT_MODIFY') {
767 767
             dol_syslog(
768
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
768
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
769 769
             );
770 770
         } elseif ($action == 'PROJECT_DELETE') {
771 771
             dol_syslog(
772
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
772
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
773 773
             );
774 774
         }
775 775
 
776 776
         // Project tasks
777 777
         elseif ($action == 'TASK_CREATE') {
778 778
             dol_syslog(
779
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
779
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
780 780
             );
781 781
         } elseif ($action == 'TASK_MODIFY') {
782 782
             dol_syslog(
783
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
783
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
784 784
             );
785 785
         } elseif ($action == 'TASK_DELETE') {
786 786
             dol_syslog(
787
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
787
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
788 788
             );
789 789
         }
790 790
 
791 791
         // Task time spent
792 792
         elseif ($action == 'TASK_TIMESPENT_CREATE') {
793 793
             dol_syslog(
794
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
794
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
795 795
             );
796 796
         } elseif ($action == 'TASK_TIMESPENT_MODIFY') {
797 797
             dol_syslog(
798
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
798
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
799 799
             );
800 800
         } elseif ($action == 'TASK_TIMESPENT_DELETE') {
801 801
             dol_syslog(
802
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
802
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
803 803
             );
804 804
         }
805 805
 
806 806
         // Shipping
807 807
         elseif ($action == 'SHIPPING_CREATE') {
808 808
             dol_syslog(
809
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
809
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
810 810
             );
811 811
         } elseif ($action == 'SHIPPING_MODIFY') {
812 812
             dol_syslog(
813
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
813
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
814 814
             );
815 815
         } elseif ($action == 'SHIPPING_VALIDATE') {
816 816
             dol_syslog(
817
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
817
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
818 818
             );
819 819
         } elseif ($action == 'SHIPPING_SENTBYMAIL') {
820 820
             dol_syslog(
821
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
821
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
822 822
             );
823 823
         } elseif ($action == 'SHIPPING_DELETE') {
824 824
             dol_syslog(
825
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
825
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
826 826
             );
827 827
         } elseif ($action == 'SHIPPING_BUILDDOC') {
828 828
             dol_syslog(
829
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
829
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
830 830
             );
831 831
         }
832 832
 
833 833
         // File
834 834
         elseif ($action == 'FILE_UPLOAD') {
835 835
             dol_syslog(
836
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
836
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
837 837
             );
838 838
         } elseif ($action == 'FILE_DELETE') {
839 839
             dol_syslog(
840
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
840
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
841 841
             );
842 842
         }
843 843
 
Please login to merge, or discard this patch.
Braces   +80 added lines, -38 removed lines patch added patch discarded remove patch
@@ -89,12 +89,14 @@  discard block
 block discarded – undo
89 89
 
90 90
         if ($this->version == 'development') {
91 91
             return $langs->trans("Development");
92
-        } elseif ($this->version == 'experimental')
93
-
92
+        } elseif ($this->version == 'experimental') {
93
+        
94 94
                 return $langs->trans("Experimental");
95
-        elseif ($this->version == 'dolibarr') return DOL_VERSION;
96
-        elseif ($this->version) return $this->version;
97
-        else {
95
+        } elseif ($this->version == 'dolibarr') {
96
+        	return DOL_VERSION;
97
+        } elseif ($this->version) {
98
+        	return $this->version;
99
+        } else {
98 100
             return $langs->trans("Unknown");
99 101
         }
100 102
     }
@@ -122,14 +124,18 @@  discard block
 block discarded – undo
122 124
 		$subtotal_line_found = false;
123 125
 		foreach ($parent->lines as $k => &$line)
124 126
 		{
125
-			if ($line->rang < $rang) continue;
126
-			elseif ($line->rang == $rang) // Je suis sur la ligne de titre où je souhaite ajouter ma nouvelle ligne en fin de bloc
127
+			if ($line->rang < $rang) {
128
+				continue;
129
+			} elseif ($line->rang == $rang) {
130
+				// Je suis sur la ligne de titre où je souhaite ajouter ma nouvelle ligne en fin de bloc
127 131
 			{
128 132
 				$title_level = $line->qty;
129 133
 			}
130
-			elseif (!$subtotal_line_found && $title_level > -1 && ($line->qty == 100 - $title_level)) // Le level de mon titre a été trouvé avant, donc maintenant je vais m'arrêter jusqu'à trouver un sous-total
134
+			} elseif (!$subtotal_line_found && $title_level > -1 && ($line->qty == 100 - $title_level)) {
135
+				// Le level de mon titre a été trouvé avant, donc maintenant je vais m'arrêter jusqu'à trouver un sous-total
131 136
 			{
132 137
 				$subtotal_line_found = true;
138
+			}
133 139
 				$rang = $line->rang;
134 140
 			}
135 141
 			
@@ -193,8 +199,11 @@  discard block
 block discarded – undo
193 199
 						break;
194 200
 				}
195 201
 				
196
-				if (!empty($conf->global->SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK)) $this->addToEnd($parent, $object, $rang);
197
-				else $this->addToBegin($parent, $object, $rang);
202
+				if (!empty($conf->global->SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK)) {
203
+					$this->addToEnd($parent, $object, $rang);
204
+				} else {
205
+					$this->addToBegin($parent, $object, $rang);
206
+				}
198 207
 				
199 208
 			}
200 209
 			
@@ -210,8 +219,7 @@  discard block
 block discarded – undo
210 219
 		    if ($subtotal_skip)
211 220
             {
212 221
                 $subtotal_skip = false;
213
-            }
214
-		    else
222
+            } else
215 223
             {
216 224
 			    $subtotal_add_title_bloc_from_orderstoinvoice = GETPOST('subtotal_add_title_bloc_from_orderstoinvoice');
217 225
 			    if (!empty($subtotal_add_title_bloc_from_orderstoinvoice))
@@ -224,8 +232,7 @@  discard block
 block discarded – undo
224 232
 				    if (!$is_supplier){
225 233
 				        $facture = new Facture($this->db);
226 234
 				        $ret = $facture->fetch($object->fk_facture);
227
-                    }
228
-				    else
235
+                    } else
229 236
                     {
230 237
 				        $facture = new FactureFournisseur($this->db);
231 238
 				        $ret = $facture->fetch($object->fk_facture_fourn);
@@ -236,14 +243,19 @@  discard block
 block discarded – undo
236 243
 					    $rang = !empty($subtotal_current_rang) ? $subtotal_current_rang : $object->rang;
237 244
 					    // Si le fk_commande courrant est différent alors on change de commande => ajout d'un titre
238 245
 					    if ($current_fk_commande != $subtotal_bloc_previous_fk_commande ) {
239
-                            if (!$is_supplier) $commande = new Commande($this->db);
240
-                            else $commande = new CommandeFournisseur($this->db);
246
+                            if (!$is_supplier) {
247
+                            	$commande = new Commande($this->db);
248
+                            } else {
249
+                            	$commande = new CommandeFournisseur($this->db);
250
+                            }
241 251
                             $commande->fetch($current_fk_commande);
242 252
 
243 253
                             $label = $conf->global->SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE;
244 254
                             if (empty($label)) {
245 255
                                 $label = 'Commande [__REFORDER__]';
246
-                                if (!$is_supplier) $label .= ' - Référence client : [__REFCUSTOMER__]';
256
+                                if (!$is_supplier) {
257
+                                	$label .= ' - Référence client : [__REFCUSTOMER__]';
258
+                                }
247 259
                             }
248 260
                             $label = str_replace(array('__REFORDER__', '__REFCUSTOMER__'), array($commande->ref, $commande->ref_client), $label);
249 261
 
@@ -286,7 +298,9 @@  discard block
 block discarded – undo
286 298
 		
287 299
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && in_array($action, array('LINEPROPAL_INSERT', 'LINEPROPAL_UPDATE', 'LINEORDER_INSERT', 'LINEORDER_UPDATE', 'LINEBILL_INSERT', 'LINEBILL_UPDATE', 'LINEBILL_SUPPLIER_CREATE', 'LINEBILL_SUPPLIER_UPDATE')))
288 300
 		{
289
-            if(! function_exists('_updateLineNC')) dol_include_once('/subtotal/lib/subtotal.lib.php');
301
+            if(! function_exists('_updateLineNC')) {
302
+            	dol_include_once('/subtotal/lib/subtotal.lib.php');
303
+            }
290 304
 
291 305
 			$doli_action = GETPOST('action');
292 306
 			$set = GETPOST('set');
@@ -304,32 +318,50 @@  discard block
 block discarded – undo
304 318
 						$object->total_ht = $object->total_tva = $object->total_ttc = $object->total_localtax1 = $object->total_localtax2 = 
305 319
 							$object->multicurrency_total_ht = $object->multicurrency_total_tva = $object->multicurrency_total_ttc = 0;
306 320
 
307
-						if ($object->element == 'propal') $res = $object->update(1);
308
-						else $res = $object->update($user, 1);
321
+						if ($object->element == 'propal') {
322
+							$res = $object->update(1);
323
+						} else {
324
+							$res = $object->update($user, 1);
325
+						}
309 326
 						
310
-						if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success'));
327
+						if ($res > 0) {
328
+							setEventMessage($langs->trans('subtotal_update_nc_success'));
329
+						}
311 330
 						break;
312 331
 					}
313 332
 				}
314 333
 
315 334
 				// $object correspond à la ligne ajoutée
316
-				if(empty($object->array_options)) $object->fetch_optionals();
335
+				if(empty($object->array_options)) {
336
+					$object->fetch_optionals();
337
+				}
317 338
 
318 339
 				if(! empty($object->array_options['options_subtotal_nc'])) {
319 340
 					$object->total_ht = $object->total_tva = $object->total_ttc = $object->total_localtax1 = $object->total_localtax2 = 
320 341
 							$object->multicurrency_total_ht = $object->multicurrency_total_tva = $object->multicurrency_total_ttc = 0;
321 342
 
322
-					if ($object->element == 'propaldet') $res = $object->update(1);
323
-					else $res = $object->update($user, 1);
343
+					if ($object->element == 'propaldet') {
344
+						$res = $object->update(1);
345
+					} else {
346
+						$res = $object->update($user, 1);
347
+					}
324 348
 
325
-					if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success'));
349
+					if ($res > 0) {
350
+						setEventMessage($langs->trans('subtotal_update_nc_success'));
351
+					}
326 352
 				}
327 353
 
328 354
 				// Correction d'un bug lors de la création d'une commande depuis une propale qui a, au moins, une ligne NC
329 355
 				$parent_element = '';
330
-				if($object->element == 'propaldet') $parent_element = 'propal';
331
-				if($object->element == 'commandedet') $parent_element = 'commande';
332
-				if($object->element == 'facturedet') $parent_element = 'facture';
356
+				if($object->element == 'propaldet') {
357
+					$parent_element = 'propal';
358
+				}
359
+				if($object->element == 'commandedet') {
360
+					$parent_element = 'commande';
361
+				}
362
+				if($object->element == 'facturedet') {
363
+					$parent_element = 'facture';
364
+				}
333 365
 
334 366
 				if(! empty($parent_element) && ! empty($object->array_options['options_subtotal_nc'])) {
335 367
 					_updateLineNC($parent_element, $object->{'fk_'.$parent_element}, $object->id, $object->array_options['options_subtotal_nc'], 1);
@@ -529,26 +561,38 @@  discard block
 block discarded – undo
529 561
 				);
530 562
 				
531 563
 				// En fonction de l'objet et de la version, les lignes conservent l'id de l'objet d'origine
532
-				if (method_exists($object, 'fetch_lines')) $object->fetch_lines();
533
-				else $object->fetch($object->id);
564
+				if (method_exists($object, 'fetch_lines')) {
565
+					$object->fetch_lines();
566
+				} else {
567
+					$object->fetch($object->id);
568
+				}
534 569
 			
535 570
 				foreach ($object->lines as &$line)
536 571
 				{
537
-					if (empty($line->array_options)) $line->fetch_optionals();
572
+					if (empty($line->array_options)) {
573
+						$line->fetch_optionals();
574
+					}
538 575
 					
539 576
 					if (!TSubtotal::isModSubtotalLine($line) && !empty($line->array_options['options_subtotal_nc']))
540 577
 					{
541 578
 						$line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = 
542 579
 							$line->multicurrency_total_ht = $line->multicurrency_total_tva = $line->multicurrency_total_ttc = 0;
543 580
 
544
-						if ($line->element == 'propaldet') $res = $line->update(1);
545
-						else $res = $line->update($user, 1);
581
+						if ($line->element == 'propaldet') {
582
+							$res = $line->update(1);
583
+						} else {
584
+							$res = $line->update($user, 1);
585
+						}
546 586
 						
547
-						if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success'));
587
+						if ($res > 0) {
588
+							setEventMessage($langs->trans('subtotal_update_nc_success'));
589
+						}
548 590
 					}
549 591
 				}
550 592
 				
551
-				if (!empty($line)) $object->update_price(1);
593
+				if (!empty($line)) {
594
+					$object->update_price(1);
595
+				}
552 596
 			}
553 597
 			
554 598
         } elseif ($action == 'PROPAL_MODIFY') {
@@ -618,9 +662,7 @@  discard block
 block discarded – undo
618 662
             dol_syslog(
619 663
                 "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
620 664
             );
621
-        }
622
-
623
-		elseif ($action == 'BILL_MODIFY') {
665
+        } elseif ($action == 'BILL_MODIFY') {
624 666
             dol_syslog(
625 667
                 "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
626 668
             );
Please login to merge, or discard this patch.
class/subtotal.class.php 3 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -34,15 +34,15 @@  discard block
 block discarded – undo
34 34
 			}
35 35
 
36 36
 			if($object->element=='facture')
37
-            {
38
-                /** @var Facture $object */
39
-                $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
-            }
37
+			{
38
+				/** @var Facture $object */
39
+				$res =  $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label);
40
+			}
41 41
 			elseif($object->element=='invoice_supplier') {
42
-                /** @var FactureFournisseur $object */
43
-			    $object->special_code = TSubtotal::$module_number;
44
-                if( (float)DOL_VERSION < 6 ) $rang = $object->line_max() + 1;
45
-			    $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
42
+				/** @var FactureFournisseur $object */
43
+				$object->special_code = TSubtotal::$module_number;
44
+				if( (float)DOL_VERSION < 6 ) $rang = $object->line_max() + 1;
45
+				$res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
46 46
 			}
47 47
 			/**
48 48
 			 * @var $object Propal
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 			 * @var $object Commande fournisseur
62 62
 			 */
63 63
 			else if($object->element=='order_supplier') {
64
-			    $object->special_code = TSubtotal::$module_number;
65
-			    $res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9);
64
+				$object->special_code = TSubtotal::$module_number;
65
+				$res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9);
66 66
 			}
67 67
 			/**
68 68
 			 * @var $object Facturerec
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
 	{
323 323
 		if (empty($fk_commande)) return false;
324 324
 
325
-        $table = 'commandedet';
326
-        if ($supplier) $table = 'commande_fournisseurdet';
325
+		$table = 'commandedet';
326
+		if ($supplier) $table = 'commande_fournisseurdet';
327 327
 
328 328
 		$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$table.' WHERE fk_commande = '.$fk_commande.' ORDER BY rang DESC LIMIT 1';
329 329
 		$resql = $db->query($sql);
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 		{
344 344
 			if ($line->rang >= $rang) continue; // Tout ce qui ce trouve en dessous j'ignore, nous voulons uniquement ce qui ce trouve au dessus
345 345
 
346
-            if (self::isTitle($line))
346
+			if (self::isTitle($line))
347 347
 			{
348 348
 				if ($skip_title)
349 349
 				{
@@ -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, $object->element, $line->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, $object->element, $line->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,12 +465,12 @@  discard block
 block discarded – undo
465 465
 							break;
466 466
 							
467 467
 						case 'order_supplier':
468
-						    $object->line = $line;
469
-						    $object->line->origin = $object->element;
470
-						    $object->line->origin_id = $line->id;
471
-						    $object->line->fk_commande = $object->id;
472
-						    $object->line->rang = $object->line_max() +1;
473
-						    $res = $object->line->insert(1);
468
+							$object->line = $line;
469
+							$object->line->origin = $object->element;
470
+							$object->line->origin_id = $line->id;
471
+							$object->line->fk_commande = $object->id;
472
+							$object->line->rang = $object->line_max() +1;
473
+							$res = $object->line->insert(1);
474 474
 							break;
475 475
 							
476 476
 						case 'facture':
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
 					$object->db->commit();
524 524
 					foreach ($TLineAdded as &$line)
525 525
 					{
526
-					    // ç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
527
-					    _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']);
526
+						// ç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
527
+						_updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']);
528 528
 					}
529 529
 					return count($TLineAdded);
530 530
 				}
@@ -598,33 +598,33 @@  discard block
 block discarded – undo
598 598
 		
599 599
 		switch ($object->element) 
600 600
 		{
601
-		    case 'propal':
602
-		        $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);
603
-		        break;
601
+			case 'propal':
602
+				$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);
603
+				break;
604 604
 		        
605
-		    case 'supplier_proposal':
606
-		        $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);
607
-		        break;
605
+			case 'supplier_proposal':
606
+				$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);
607
+				break;
608 608
 		        
609 609
 			case 'commande':
610 610
 				$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);
611 611
 				break;
612 612
 				
613 613
 			case 'order_supplier':
614
-			    $object->special_code = SELF::$module_number;
615
-			    if (empty($desc)) $desc = $label;
616
-			    $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit);
617
-			    break;
614
+				$object->special_code = SELF::$module_number;
615
+				if (empty($desc)) $desc = $label;
616
+				$res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit);
617
+				break;
618 618
 			
619 619
 			case 'facture':
620 620
 				$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);
621 621
 				break;
622 622
 				
623 623
 			case 'invoice_supplier':
624
-			    $object->special_code = SELF::$module_number;
625
-			    if (empty($desc)) $desc = $label;
626
-			    $res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit);
627
-			    break;
624
+				$object->special_code = SELF::$module_number;
625
+				if (empty($desc)) $desc = $label;
626
+				$res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit);
627
+				break;
628 628
 				
629 629
 			case 'facturerec':
630 630
 				// Add extrafields and get rang
@@ -1015,8 +1015,8 @@  discard block
 block discarded – undo
1015 1015
 		{
1016 1016
 			if (is_readable($logo))
1017 1017
 			{
1018
-			    $height=pdf_getHeightForLogo($logo);
1019
-			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1018
+				$height=pdf_getHeightForLogo($logo);
1019
+				$pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1020 1020
 			}
1021 1021
 			else
1022 1022
 			{
@@ -1207,13 +1207,13 @@  discard block
 block discarded – undo
1207 1207
 	 * @param	int		$hidebottom		Hide bottom
1208 1208
 	 * @return	void
1209 1209
 	 */
1210
-    private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1211
-    {
1212
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1213
-	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1214
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1215
-	    $pdf->line($x, $y+$h, $x, $y);
1216
-    }
1210
+	private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1211
+	{
1212
+		if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1213
+		$pdf->line($x+$l, $y, $x+$l, $y+$h);
1214
+		if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1215
+		$pdf->line($x, $y+$h, $x, $y);
1216
+	}
1217 1217
 	
1218 1218
 	
1219 1219
 	public static function concat(&$outputlangs, $files, $fileoutput='')
@@ -1223,14 +1223,14 @@  discard block
 block discarded – undo
1223 1223
 		if (empty($fileoutput)) $fileoutput = $file[0];
1224 1224
 		
1225 1225
 		$pdf=pdf_getInstance();
1226
-        if (class_exists('TCPDF'))
1227
-        {
1228
-            $pdf->setPrintHeader(false);
1229
-            $pdf->setPrintFooter(false);
1230
-        }
1231
-        $pdf->SetFont(pdf_getPDFFont($outputlangs));
1226
+		if (class_exists('TCPDF'))
1227
+		{
1228
+			$pdf->setPrintHeader(false);
1229
+			$pdf->setPrintFooter(false);
1230
+		}
1231
+		$pdf->SetFont(pdf_getPDFFont($outputlangs));
1232 1232
 
1233
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1233
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1234 1234
 
1235 1235
 		
1236 1236
 		foreach($files as $file)
Please login to merge, or discard this patch.
Spacing   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -5,69 +5,69 @@  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
 			}
35 35
 
36
-			if($object->element=='facture')
36
+			if ($object->element == 'facture')
37 37
             {
38 38
                 /** @var Facture $object */
39
-                $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
+                $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
-			elseif($object->element=='invoice_supplier') {
41
+			elseif ($object->element == 'invoice_supplier') {
42 42
                 /** @var FactureFournisseur $object */
43 43
 			    $object->special_code = TSubtotal::$module_number;
44
-                if( (float)DOL_VERSION < 6 ) $rang = $object->line_max() + 1;
45
-			    $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
44
+                if ((float) DOL_VERSION < 6) $rang = $object->line_max() + 1;
45
+			    $res = $object->addline($label, 0, 0, 0, 0, $qty, 0, 0, '', '', 0, 0, 'HT', 9, $rang);
46 46
 			}
47 47
 			/**
48 48
 			 * @var $object Propal
49 49
 			 */
50
-			else if($object->element=='propal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
50
+			else if ($object->element == 'propal') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, $rang, TSubtotal::$module_number, 0, 0, 0, $label);
51 51
 			/**
52 52
 			 * @var $object Propal Fournisseur
53 53
 			 */
54
-			else if($object->element=='supplier_proposal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
54
+			else if ($object->element == 'supplier_proposal') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, $rang, TSubtotal::$module_number, 0, 0, 0, $label);
55 55
 			
56 56
 			/**
57 57
 			 * @var $object Commande
58 58
 			 */
59
-			else if($object->element=='commande') $res =  $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label);
59
+			else if ($object->element == 'commande') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 0, 0, 'HT', 0, '', '', 9, $rang, TSubtotal::$module_number, 0, null, 0, $label);
60 60
 			/**
61 61
 			 * @var $object Commande fournisseur
62 62
 			 */
63
-			else if($object->element=='order_supplier') {
63
+			else if ($object->element == 'order_supplier') {
64 64
 			    $object->special_code = TSubtotal::$module_number;
65
-			    $res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9);
65
+			    $res = $object->addline($label, 0, $qty, 0, 0, 0, 0, 0, '', 0, 'HT', 0, 9);
66 66
 			}
67 67
 			/**
68 68
 			 * @var $object Facturerec
69 69
 			 */
70
-			else if($object->element=='facturerec') $res =  $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); 
70
+			else if ($object->element == 'facturerec') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number, $label); 
71 71
 			
72 72
 		}
73 73
 	
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
 
79 79
 	public static function generateDoc(&$object)
80 80
 	{
81
-		global $conf,$langs,$db;
81
+		global $conf, $langs, $db;
82 82
 		
83 83
 		if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
84 84
 		{
85
-			$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
86
-			$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
87
-			$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
85
+			$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
86
+			$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
87
+			$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
88 88
 			
89 89
 			// Define output language
90 90
 			$outputlangs = $langs;
91 91
 			$newlang = GETPOST('lang_id', 'alpha');
92
-			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
92
+			if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
93 93
 				$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
94
-			if (! empty($newlang)) {
94
+			if (!empty($newlang)) {
95 95
 				$outputlangs = new Translate("", $conf);
96 96
 				$outputlangs->setDefaultLang($newlang);
97 97
 			}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 			}
106 106
 			else
107 107
 			{
108
-				if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
108
+				if ($object->element != 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
109 109
 			}
110 110
 		}
111 111
 	}
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 	 * @param type $rang_start
118 118
 	 * @param type $move_to
119 119
 	 */
120
-	public static function updateRang(&$object, $rang_start, $move_to=1)
120
+	public static function updateRang(&$object, $rang_start, $move_to = 1)
121 121
 	{
122 122
 		if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
123 123
 		
124
-		$row=new GenericObject($object->db);
124
+		$row = new GenericObject($object->db);
125 125
 		$row->table_element_line = $object->table_element_line;
126 126
 		$row->fk_element = $object->fk_element;
127 127
 		$row->id = $object->id;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		{
131 131
 			if ($line->rang < $rang_start) continue;
132 132
 			
133
-			$row->updateRangOfLine($line->id, $line->rang+$move_to);
133
+			$row->updateRangOfLine($line->id, $line->rang + $move_to);
134 134
 		}
135 135
 	}
136 136
 	
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			{
160 160
 				if ($rang_to_add != -1) self::updateRang($object, $rang_to_add);
161 161
 				
162
-				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add);
162
+				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100 - $title_niveau, $rang_to_add);
163 163
 				
164 164
 				$object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas)
165 165
 				if ($rang_to_add != -1) 
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
 		}
172 172
 	}
173 173
 	
174
-	public static function addTitle(&$object, $label, $level, $rang=-1)
174
+	public static function addTitle(&$object, $label, $level, $rang = -1)
175 175
 	{
176 176
 		self::addSubTotalLine($object, $label, $level, $rang);
177 177
 	}
178 178
 	
179
-	public static function addTotal(&$object, $label, $level, $rang=-1)
179
+	public static function addTotal(&$object, $label, $level, $rang = -1)
180 180
 	{
181
-		return self::addSubTotalLine($object, $label, (100-$level), $rang);
181
+		return self::addSubTotalLine($object, $label, (100 - $level), $rang);
182 182
 	}
183 183
 
184 184
 	/**
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * 
190 190
 	 * @return array
191 191
 	 */
192
-	public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total=false)
192
+	public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total = false)
193 193
 	{
194 194
 		$TTitle = self::getAllTitleFromDocument($object, $get_block_total);
195 195
 		
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 * @param boolean								$return_rang_on_false	si true alors renvoi le rang où devrait ce trouver le sous-total
211 211
 	 * @return boolean
212 212
 	 */
213
-	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false)
213
+	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode = false, $return_rang_on_false = false)
214 214
 	{
215 215
 		if (empty($object->lines) || !is_array($object->lines)) return false;
216 216
 		
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		return ($return_rang_on_false) ? -1 : false;
237 237
 	}
238 238
 	
239
-	public static function getAllTitleFromDocument(&$object, $get_block_total=false)
239
+	public static function getAllTitleFromDocument(&$object, $get_block_total = false)
240 240
 	{
241 241
 		$TRes = array();
242 242
 		if (!empty($object->lines))
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 		$skip_title = 0;
340 340
 		$TLineReverse = array_reverse($object->lines);
341 341
 
342
-		foreach($TLineReverse as $line)
342
+		foreach ($TLineReverse as $line)
343 343
 		{
344 344
 			if ($line->rang >= $rang) continue; // Tout ce qui ce trouve en dessous j'ignore, nous voulons uniquement ce qui ce trouve au dessus
345 345
 
@@ -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))
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 						    $object->line->origin = $object->element;
470 470
 						    $object->line->origin_id = $line->id;
471 471
 						    $object->line->fk_commande = $object->id;
472
-						    $object->line->rang = $object->line_max() +1;
472
+						    $object->line->rang = $object->line_max() + 1;
473 473
 						    $res = $object->line->insert(1);
474 474
 							break;
475 475
 							
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 					{
510 510
 						$object->line_from = $line;
511 511
 						// Call trigger
512
-						$result=$object->call_trigger('LINE_DUPLICATE',$user); // $object->line
512
+						$result = $object->call_trigger('LINE_DUPLICATE', $user); // $object->line
513 513
 						if ($result < 0)
514 514
 						{
515 515
 							$object->db->rollback();
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 		}
540 540
 	}
541 541
 	
542
-	public static function getLinesFromTitle(&$object, $key_trad, $level=1, $under_title='', $withBlockLine=false, $key_is_id=false)
542
+	public static function getLinesFromTitle(&$object, $key_trad, $level = 1, $under_title = '', $withBlockLine = false, $key_is_id = false)
543 543
 	{
544 544
 		global $langs;
545 545
 		
@@ -551,17 +551,17 @@  discard block
 block discarded – undo
551 551
 		
552 552
 		$TLine = array();
553 553
 		$add_line = false;
554
-		$under_title_found=false;
554
+		$under_title_found = false;
555 555
 		
556 556
 		foreach ($object->lines as $key => &$line)
557 557
 		{
558 558
 			if (!$under_title_found && !empty($TTitle_under_search))
559 559
 			{
560
-				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true;
560
+				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search))) $under_title_found = true;
561 561
 			}
562 562
 			else
563 563
 			{
564
-				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) )))
564
+				if (($key_is_id && $line->id == $key_trad) || (!$key_is_id && $line->product_type == 9 && $line->qty == $level && (in_array($line->desc, $TTitle_search) || in_array($line->label, $TTitle_search))))
565 565
 				{
566 566
 					if ($key_is_id) $level = $line->qty;
567 567
 					
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 				
578 578
 				if ($add_line)
579 579
 				{
580
-					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue;
580
+					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line))) continue;
581 581
 					else $TLine[] = $line;
582 582
 				}
583 583
 			}
@@ -586,12 +586,12 @@  discard block
 block discarded – undo
586 586
 		return $TLine;
587 587
 	}
588 588
 	
589
-	public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine=false)
589
+	public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine = false)
590 590
 	{
591 591
 		return self::getLinesFromTitle($object, $lineid, '', '', $withBlockLine, true);
592 592
 	}
593 593
 	
594
-	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)
594
+	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)
595 595
 	{
596 596
 		$res = 0;
597 597
 		$object->db->begin();
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 		        break;
604 604
 		        
605 605
 		    case 'supplier_proposal':
606
-		        $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);
606
+		        $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);
607 607
 		        break;
608 608
 		        
609 609
 			case 'commande':
@@ -632,9 +632,9 @@  discard block
 block discarded – undo
632 632
 				$factureRecLine->fetch($rowid);
633 633
 				$factureRecLine->array_options = $array_options;
634 634
 				$factureRecLine->insertExtraFields();
635
-				$rang=$factureRecLine->rang;
635
+				$rang = $factureRecLine->rang;
636 636
 				
637
-				$fk_product=0; $fk_remise_except=''; $pu_ttc=0;	
637
+				$fk_product = 0; $fk_remise_except = ''; $pu_ttc = 0;	
638 638
 				$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);
639 639
 				break;
640 640
 		}
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 		global $db, $object;
651 651
 		
652 652
 		$TTitle = array();
653
-		if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {}
653
+		if (!empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {}
654 654
 		else {
655 655
 			if ($origin_line->element == 'propaldet')
656 656
 			{
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 	 */
731 731
 	public static function addRecapPage(&$parameters, &$origin_pdf)
732 732
 	{
733
-		global $user,$conf,$langs;
733
+		global $user, $conf, $langs;
734 734
 		
735 735
 		$origin_file = $parameters['file'];
736 736
 		$outputlangs = $parameters['outputlangs'];
@@ -746,21 +746,21 @@  discard block
 block discarded – undo
746 746
 		$objmarge->marge_droite = 10;
747 747
 		
748 748
 		$objectref = dol_sanitizeFileName($object->ref);
749
-		if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref;
750
-		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref;
751
-		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref;
749
+		if ($object->element == 'propal') $dir = $conf->propal->dir_output.'/'.$objectref;
750
+		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output.'/'.$objectref;
751
+		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output.'/'.$objectref;
752 752
 		elseif ($object->element == 'facturerec') return; // no PDF for facturerec
753 753
 		else
754 754
 		{
755 755
 			setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings');
756 756
 			return -1;
757 757
 		}
758
-		$file = $dir . '/' . $objectref . '_recap.pdf';
758
+		$file = $dir.'/'.$objectref.'_recap.pdf';
759 759
 
760 760
 //		$pdf=pdf_getInstance($origin_pdf->format);
761
-		$pdf=pdf_getInstance(array(210, 297)); // Format A4 Portrait
762
-		$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
763
-		$pdf->SetAutoPageBreak(1,0);
761
+		$pdf = pdf_getInstance(array(210, 297)); // Format A4 Portrait
762
+		$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
763
+		$pdf->SetAutoPageBreak(1, 0);
764 764
 	             
765 765
 		if (class_exists('TCPDF'))
766 766
 		{
@@ -769,49 +769,49 @@  discard block
 block discarded – undo
769 769
 		}
770 770
 		$pdf->SetFont(pdf_getPDFFont($outputlangs));
771 771
 		// Set path to the background PDF File
772
-		if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
772
+		if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
773 773
 		{
774 774
 			$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
775 775
 			$tplidx = $pdf->importPage(1);
776 776
 		}
777 777
 
778 778
 		$pdf->Open();
779
-		$pagenb=0;
780
-		$pdf->SetDrawColor(128,128,128);
779
+		$pagenb = 0;
780
+		$pdf->SetDrawColor(128, 128, 128);
781 781
 
782 782
 		$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
783 783
 		$pdf->SetSubject($outputlangs->transnoentities("subtotalRecap"));
784 784
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
785 785
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
786 786
 		$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
787
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
787
+		if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
788 788
 
789
-		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite);   // Left, Top, Right
789
+		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right
790 790
 
791
-		$pagenb=0;
792
-		$pdf->SetDrawColor(128,128,128);
791
+		$pagenb = 0;
792
+		$pdf->SetDrawColor(128, 128, 128);
793 793
 
794 794
 			
795 795
 		// New page
796 796
 		$pdf->AddPage();
797
-		if (! empty($tplidx)) $pdf->useTemplate($tplidx);
797
+		if (!empty($tplidx)) $pdf->useTemplate($tplidx);
798 798
 		$pagenb++;
799 799
 		
800 800
 		
801 801
 		self::pagehead($objmarge, $pdf, $object, 1, $outputlangs);
802
-		$pdf->SetFont('','', $default_font_size - 1);
803
-		$pdf->MultiCell(0, 3, '');		// Set interline to 3
804
-		$pdf->SetTextColor(0,0,0);
802
+		$pdf->SetFont('', '', $default_font_size - 1);
803
+		$pdf->MultiCell(0, 3, ''); // Set interline to 3
804
+		$pdf->SetTextColor(0, 0, 0);
805 805
 		
806
-		$heightforinfotot = 25;	// Height reserved to output the info and total part
807
-		$heightforfooter = $objmarge->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
806
+		$heightforinfotot = 25; // Height reserved to output the info and total part
807
+		$heightforfooter = $objmarge->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
808 808
 		
809 809
 		$posx_designation = 25;
810 810
 		$posx_options = 150;
811 811
 		$posx_montant = 170;
812 812
 		
813 813
 		$tab_top = 72;
814
-		$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?72:20); // TODO à vérifier
814
+		$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 72 : 20); // TODO à vérifier
815 815
 		
816 816
 		$TTot = array('total_ht' => 0, 'total_ttc' => 0, 'TTotal_tva' => array());
817 817
 		
@@ -825,14 +825,14 @@  discard block
 block discarded – undo
825 825
 			$nexY = $tab_top + 10;
826 826
 			
827 827
 			$nblignes = count($TLine);
828
-			foreach($TLine as $i => &$line)
828
+			foreach ($TLine as $i => &$line)
829 829
 			{
830 830
 				$curY = $nexY;
831 831
 				
832 832
 				if (self::getNiveau($line) == 1) 
833 833
 				{
834
-					$pdf->SetFont('','B', $default_font_size - 1);   // Into loop to work with multipage
835
-					$curY+=2;
834
+					$pdf->SetFont('', 'B', $default_font_size - 1); // Into loop to work with multipage
835
+					$curY += 2;
836 836
 					
837 837
 					$TTot['total_ht'] += $line->total_ht;
838 838
 					$TTot['total_tva'] += $line->total_tva;
@@ -851,67 +851,67 @@  discard block
 block discarded – undo
851 851
 						$TTot['TTotal_tva_multicurrency'][$tx] += $amount;
852 852
 					}	
853 853
 				}
854
-				else $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
854
+				else $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
855 855
 				
856
-				$pdf->SetTextColor(0,0,0);
856
+				$pdf->SetTextColor(0, 0, 0);
857 857
 				
858 858
 				$pdf->setTopMargin($tab_top_newpage + 10);
859
-				$pdf->setPageOrientation('', 1, $heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
860
-				$pageposbefore=$pdf->getPage();
859
+				$pdf->setPageOrientation('', 1, $heightforfooter + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
860
+				$pageposbefore = $pdf->getPage();
861 861
 				
862
-				$showpricebeforepagebreak=1;
862
+				$showpricebeforepagebreak = 1;
863 863
 				
864 864
 				$decalage = (self::getNiveau($line) - 1) * 2;
865 865
 				
866 866
 				// Print: Designation
867 867
 				$label = $line->label;
868
-				if( (float)DOL_VERSION < 6 ) {
868
+				if ((float) DOL_VERSION < 6) {
869 869
 					$label = !empty($line->label) ? $line->label : $line->desc;
870 870
 				}
871 871
 				
872 872
 				
873 873
 				$pdf->startTransaction();
874
-				$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
875
-				$pageposafter=$pdf->getPage();
874
+				$pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true);
875
+				$pageposafter = $pdf->getPage();
876 876
 				if ($pageposafter > $pageposbefore)	// There is a pagebreak
877 877
 				{
878 878
 					$pdf->rollbackTransaction(true);
879
-					$pageposafter=$pageposbefore;
879
+					$pageposafter = $pageposbefore;
880 880
 					//print $pageposafter.'-'.$pageposbefore;exit;
881
-					$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
882
-					$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
881
+					$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
882
+					$pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true);
883 883
 
884
-					$pageposafter=$pdf->getPage();
885
-					$posyafter=$pdf->GetY();
884
+					$pageposafter = $pdf->getPage();
885
+					$posyafter = $pdf->GetY();
886 886
 					//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
887
-					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot)))	// There is no space left for total+free text
887
+					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter + $heightforinfotot)))	// There is no space left for total+free text
888 888
 					{
889
-						if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
889
+						if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
890 890
 						{
891
-							$pdf->AddPage('','',true);
892
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
891
+							$pdf->AddPage('', '', true);
892
+							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
893 893
 							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
894
-							$pdf->setPage($pageposafter+1);
894
+							$pdf->setPage($pageposafter + 1);
895 895
 						}
896 896
 					}
897 897
 					else
898 898
 					{
899 899
 						// We found a page break
900
-						$showpricebeforepagebreak=0;
900
+						$showpricebeforepagebreak = 0;
901 901
 					}
902 902
 				}
903 903
 				else	// No pagebreak
904 904
 				{
905 905
 					$pdf->commitTransaction();
906 906
 				}
907
-				$posYAfterDescription=$pdf->GetY();
907
+				$posYAfterDescription = $pdf->GetY();
908 908
 
909 909
 				$nexY = $pdf->GetY();
910
-				$pageposafter=$pdf->getPage();
910
+				$pageposafter = $pdf->getPage();
911 911
 
912 912
 				$pdf->setPage($pageposbefore);
913 913
 				$pdf->setTopMargin($objmarge->marge_haute);
914
-				$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
914
+				$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
915 915
 
916 916
 				// We suppose that a too long description or photo were moved completely on next page
917 917
 				if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
@@ -924,14 +924,14 @@  discard block
 block discarded – undo
924 924
 				if (!empty($line->total_options))
925 925
 				{
926 926
 					$pdf->SetXY($posx_options, $curY);
927
-					$pdf->MultiCell($posx_montant-$posx_options-0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0);
927
+					$pdf->MultiCell($posx_montant - $posx_options - 0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0);
928 928
 				}
929 929
 				
930 930
 				// Print: Montant
931 931
 				$pdf->SetXY($posx_montant, $curY);
932
-				$pdf->MultiCell($objmarge->page_largeur-$objmarge->marge_droite-$posx_montant-0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0);
932
+				$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant - 0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0);
933 933
 				
934
-				$nexY+=2;    // Passe espace entre les lignes
934
+				$nexY += 2; // Passe espace entre les lignes
935 935
 
936 936
 				// Detect if some page were added automatically and output _tableau for past pages
937 937
 				while ($pagenb < $pageposafter)
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
 					
949 949
 					$pagenb++;
950 950
 					$pdf->setPage($pagenb);
951
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
951
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
952 952
 					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
953 953
 				}
954 954
 			}
@@ -958,19 +958,19 @@  discard block
 block discarded – undo
958 958
 		if ($pagenb == 1)
959 959
 		{
960 960
 			self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
961
-			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
961
+			$bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
962 962
 		}
963 963
 		else
964 964
 		{
965 965
 			self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
966
-			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
966
+			$bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
967 967
 		}
968 968
 		
969 969
 		// Affiche zone totaux
970
-		$posy=self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot);
970
+		$posy = self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot);
971 971
 		
972 972
 		$pdf->Close();
973
-		$pdf->Output($file,'F');
973
+		$pdf->Output($file, 'F');
974 974
 		
975 975
 		$pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file);
976 976
 		
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 		$level = $line->qty; // TODO à améliorer
983 983
 		
984 984
 		$pdf->SetXY($objmarge->marge_gauche, $curY);
985
-		$pdf->MultiCell($posx_designation-$objmarge->marge_gauche-0.8, 5, $level, 0, 'L', 0);
985
+		$pdf->MultiCell($posx_designation - $objmarge->marge_gauche - 0.8, 5, $level, 0, 'L', 0);
986 986
 	}
987 987
 	
988 988
 	/**
@@ -996,50 +996,50 @@  discard block
 block discarded – undo
996 996
 	 */
997 997
 	private static function pagehead(&$objmarge, &$pdf, &$object, $showdetail, $outputlangs)
998 998
 	{
999
-		global $conf,$mysoc;
999
+		global $conf, $mysoc;
1000 1000
 
1001 1001
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1002 1002
 
1003
-		pdf_pagehead($pdf,$outputlangs,$objmarge->page_hauteur);
1003
+		pdf_pagehead($pdf, $outputlangs, $objmarge->page_hauteur);
1004 1004
 
1005
-		$pdf->SetTextColor(0,0,60);
1006
-		$pdf->SetFont('','B', $default_font_size + 3);
1005
+		$pdf->SetTextColor(0, 0, 60);
1006
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1007 1007
 
1008
-		$posy=$objmarge->marge_haute;
1009
-		$posx=$objmarge->page_largeur-$objmarge->marge_droite-100;
1008
+		$posy = $objmarge->marge_haute;
1009
+		$posx = $objmarge->page_largeur - $objmarge->marge_droite - 100;
1010 1010
 		
1011
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
1011
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
1012 1012
 
1013
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
1013
+		$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
1014 1014
 		if ($mysoc->logo)
1015 1015
 		{
1016 1016
 			if (is_readable($logo))
1017 1017
 			{
1018
-			    $height=pdf_getHeightForLogo($logo);
1019
-			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1018
+			    $height = pdf_getHeightForLogo($logo);
1019
+			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto)
1020 1020
 			}
1021 1021
 			else
1022 1022
 			{
1023
-				$pdf->SetTextColor(200,0,0);
1024
-				$pdf->SetFont('','B',$default_font_size - 2);
1025
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1023
+				$pdf->SetTextColor(200, 0, 0);
1024
+				$pdf->SetFont('', 'B', $default_font_size - 2);
1025
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1026 1026
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1027 1027
 			}
1028 1028
 			
1029
-			$posy+=35;
1029
+			$posy += 35;
1030 1030
 		}
1031 1031
 		else
1032 1032
 		{
1033
-			$text=$mysoc->name;
1033
+			$text = $mysoc->name;
1034 1034
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1035 1035
 			
1036
-			$posy+=15;
1036
+			$posy += 15;
1037 1037
 		}
1038 1038
 		
1039 1039
 		
1040
-		$pdf->SetTextColor(0,0,0);
1041
-		$pdf->SetFont('','B', $default_font_size + 2);
1042
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
1040
+		$pdf->SetTextColor(0, 0, 0);
1041
+		$pdf->SetFont('', 'B', $default_font_size + 2);
1042
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
1043 1043
 		
1044 1044
 		$key = 'subtotalPropalTitle';
1045 1045
 		if ($object->element == 'commande') $key = 'subtotalCommandeTitle';
@@ -1048,14 +1048,14 @@  discard block
 block discarded – undo
1048 1048
 		
1049 1049
 		$pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L');
1050 1050
 		
1051
-		$pdf->SetFont('','', $default_font_size);
1052
-		$pdf->SetXY($objmarge->page_largeur-$objmarge->marge_droite-40,$posy);
1051
+		$pdf->SetFont('', '', $default_font_size);
1052
+		$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - 40, $posy);
1053 1053
 		$pdf->MultiCell(40, 4, dol_print_date($object->date, 'daytext'), '', 'R');
1054 1054
 		
1055 1055
 		$posy += 8;
1056 1056
 			
1057
-		$pdf->SetFont('','B', $default_font_size + 2);
1058
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
1057
+		$pdf->SetFont('', 'B', $default_font_size + 2);
1058
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
1059 1059
 		$pdf->MultiCell(70, 4, $outputlangs->transnoentities('subtotalRecapLot'), '', 'L');
1060 1060
 		
1061 1061
 	}
@@ -1073,44 +1073,44 @@  discard block
 block discarded – undo
1073 1073
 	 *   @param		string		$currency		Currency code
1074 1074
 	 *   @return	void
1075 1075
 	 */
1076
-	private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1076
+	private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1077 1077
 	{
1078 1078
 		global $conf;
1079 1079
 		
1080 1080
 		// Force to disable hidetop and hidebottom
1081
-		$hidebottom=0;
1082
-		if ($hidetop) $hidetop=-1;
1081
+		$hidebottom = 0;
1082
+		if ($hidetop) $hidetop = -1;
1083 1083
 
1084 1084
 		$currency = !empty($currency) ? $currency : $conf->currency;
1085 1085
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1086 1086
 
1087 1087
 		// Amount in (at tab_top - 1)
1088
-		$pdf->SetTextColor(0,0,0);
1089
-		$pdf->SetFont('','',$default_font_size);
1088
+		$pdf->SetTextColor(0, 0, 0);
1089
+		$pdf->SetFont('', '', $default_font_size);
1090 1090
 
1091 1091
 		if (empty($hidetop))
1092 1092
 		{
1093
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1094
-			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5);
1093
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1094
+			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4.5);
1095 1095
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1096 1096
 			
1097
-			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1097
+			if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur - $objmarge->marge_droite - $objmarge->marge_gauche, 8, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1098 1098
 			
1099 1099
 			
1100
-			$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
1100
+			$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
1101 1101
 
1102
-			$pdf->SetXY($posx_designation, $tab_top+2);
1103
-			$pdf->MultiCell($posx_options - $posx_designation,2, $outputlangs->transnoentities("Designation"),'','L');
1104
-			$pdf->SetXY($posx_options, $tab_top+2);
1105
-			$pdf->MultiCell($posx_montant - $posx_options,2, $outputlangs->transnoentities("Options"),'','R');
1106
-			$pdf->SetXY($posx_montant, $tab_top+2);
1107
-			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R');
1102
+			$pdf->SetXY($posx_designation, $tab_top + 2);
1103
+			$pdf->MultiCell($posx_options - $posx_designation, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1104
+			$pdf->SetXY($posx_options, $tab_top + 2);
1105
+			$pdf->MultiCell($posx_montant - $posx_options, 2, $outputlangs->transnoentities("Options"), '', 'R');
1106
+			$pdf->SetXY($posx_montant, $tab_top + 2);
1107
+			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant, 2, $outputlangs->transnoentities("Amount"), '', 'R');
1108 1108
 			
1109
-			$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
1109
+			$pdf->line($objmarge->marge_gauche, $tab_top + 8, $objmarge->page_largeur - $objmarge->marge_droite, $tab_top + 8); // line prend une position y en 2eme param et 4eme param
1110 1110
 		}
1111 1111
 		else
1112 1112
 		{
1113
-			$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
1113
+			$pdf->line($objmarge->marge_gauche, $tab_top - 2, $objmarge->page_largeur - $objmarge->marge_droite, $tab_top - 2); // line prend une position y en 2eme param et 4eme param
1114 1114
 		}
1115 1115
 		
1116 1116
 	}
@@ -1119,29 +1119,29 @@  discard block
 block discarded – undo
1119 1119
 	{
1120 1120
 		global $conf;
1121 1121
 		
1122
-		$pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur-$objmarge->marge_droite, $posy);	// line prend une position y en 2eme param et 4eme param
1122
+		$pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur - $objmarge->marge_droite, $posy); // line prend une position y en 2eme param et 4eme param
1123 1123
 		
1124 1124
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1125 1125
 		
1126
-		$tab2_top = $posy+2;
1126
+		$tab2_top = $posy + 2;
1127 1127
 		$tab2_hl = 4;
1128
-		$pdf->SetFont('','', $default_font_size - 1);
1128
+		$pdf->SetFont('', '', $default_font_size - 1);
1129 1129
 
1130 1130
 		// Tableau total
1131 1131
 		$col1x = 120; $col2x = 170;
1132 1132
 		if ($objmarge->page_largeur < 210) // To work with US executive format
1133 1133
 		{
1134
-			$col2x-=20;
1134
+			$col2x -= 20;
1135 1135
 		}
1136 1136
 		$largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x);
1137 1137
 
1138
-		$useborder=0;
1138
+		$useborder = 0;
1139 1139
 		$index = 0;
1140 1140
 
1141 1141
 		// Total HT
1142
-		$pdf->SetFillColor(255,255,255);
1142
+		$pdf->SetFillColor(255, 255, 255);
1143 1143
 		$pdf->SetXY($col1x, $tab2_top + 0);
1144
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1144
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1145 1145
 
1146 1146
 		// $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1) ? $TTot['multicurrency_total_ht'] : $TTot['total_ht'];
1147 1147
 		$total_ht = $TTot['total_ht'];
@@ -1149,10 +1149,10 @@  discard block
 block discarded – undo
1149 1149
 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht, 0, $outputlangs), 0, 'R', 1);
1150 1150
 
1151 1151
 		// Show VAT by rates and total
1152
-		$pdf->SetFillColor(248,248,248);
1152
+		$pdf->SetFillColor(248, 248, 248);
1153 1153
 		
1154
-		$atleastoneratenotnull=0;
1155
-		foreach($TTot['TTotal_tva'] as $tvakey => $tvaval)
1154
+		$atleastoneratenotnull = 0;
1155
+		foreach ($TTot['TTotal_tva'] as $tvakey => $tvaval)
1156 1156
 		{
1157 1157
 			if ($tvakey != 0)    // On affiche pas taux 0
1158 1158
 			{
@@ -1161,15 +1161,15 @@  discard block
 block discarded – undo
1161 1161
 				$index++;
1162 1162
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1163 1163
 
1164
-				$tvacompl='';
1165
-				if (preg_match('/\*/',$tvakey))
1164
+				$tvacompl = '';
1165
+				if (preg_match('/\*/', $tvakey))
1166 1166
 				{
1167
-					$tvakey=str_replace('*','',$tvakey);
1167
+					$tvakey = str_replace('*', '', $tvakey);
1168 1168
 					$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1169 1169
 				}
1170
-				$totalvat =$outputlangs->transnoentities("TotalVAT").' ';
1171
-				$totalvat.=vatrate($tvakey,1).$tvacompl;
1172
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1170
+				$totalvat = $outputlangs->transnoentities("TotalVAT").' ';
1171
+				$totalvat .= vatrate($tvakey, 1).$tvacompl;
1172
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1173 1173
 
1174 1174
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1175 1175
 				$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1179,16 +1179,16 @@  discard block
 block discarded – undo
1179 1179
 		// Total TTC
1180 1180
 		$index++;
1181 1181
 		$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1182
-		$pdf->SetTextColor(0,0,60);
1183
-		$pdf->SetFillColor(224,224,224);
1184
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1182
+		$pdf->SetTextColor(0, 0, 60);
1183
+		$pdf->SetFillColor(224, 224, 224);
1184
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1185 1185
 
1186 1186
 		// $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $TTot['multicurrency_total_ttc'] : $TTot['total_ttc'];
1187 1187
 		$total_ttc = $TTot['total_ttc'];
1188 1188
 		$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1189 1189
 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1190 1190
 
1191
-		$pdf->SetTextColor(0,0,0);
1191
+		$pdf->SetTextColor(0, 0, 0);
1192 1192
 				
1193 1193
 		$index++;
1194 1194
 		return ($tab2_top + ($tab2_hl * $index));
@@ -1207,22 +1207,22 @@  discard block
 block discarded – undo
1207 1207
 	 * @param	int		$hidebottom		Hide bottom
1208 1208
 	 * @return	void
1209 1209
 	 */
1210
-    private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1210
+    private static function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0)
1211 1211
     {
1212
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1213
-	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1214
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1215
-	    $pdf->line($x, $y+$h, $x, $y);
1212
+	    if (empty($hidetop) || $hidetop == -1) $pdf->line($x, $y, $x + $l, $y);
1213
+	    $pdf->line($x + $l, $y, $x + $l, $y + $h);
1214
+	    if (empty($hidebottom)) $pdf->line($x + $l, $y + $h, $x, $y + $h);
1215
+	    $pdf->line($x, $y + $h, $x, $y);
1216 1216
     }
1217 1217
 	
1218 1218
 	
1219
-	public static function concat(&$outputlangs, $files, $fileoutput='')
1219
+	public static function concat(&$outputlangs, $files, $fileoutput = '')
1220 1220
 	{
1221 1221
 		global $conf;
1222 1222
 		
1223 1223
 		if (empty($fileoutput)) $fileoutput = $file[0];
1224 1224
 		
1225
-		$pdf=pdf_getInstance();
1225
+		$pdf = pdf_getInstance();
1226 1226
         if (class_exists('TCPDF'))
1227 1227
         {
1228 1228
             $pdf->setPrintHeader(false);
@@ -1230,10 +1230,10 @@  discard block
 block discarded – undo
1230 1230
         }
1231 1231
         $pdf->SetFont(pdf_getPDFFont($outputlangs));
1232 1232
 
1233
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1233
+        if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1234 1234
 
1235 1235
 		
1236
-		foreach($files as $file)
1236
+		foreach ($files as $file)
1237 1237
 		{
1238 1238
 			$pagecount = $pdf->setSourceFile($file);
1239 1239
 			for ($i = 1; $i <= $pagecount; $i++)
@@ -1245,8 +1245,8 @@  discard block
 block discarded – undo
1245 1245
 			}
1246 1246
 		}
1247 1247
 		
1248
-		$pdf->Output($fileoutput,'F');
1249
-		if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1248
+		$pdf->Output($fileoutput, 'F');
1249
+		if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1250 1250
 
1251 1251
 		return $pagecount;
1252 1252
 	}
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
 	 */
1260 1260
 	public static function hasNcTitle(&$line)
1261 1261
 	{
1262
-		if(isset($line->has_nc_title)) return $line->has_nc_title;
1262
+		if (isset($line->has_nc_title)) return $line->has_nc_title;
1263 1263
 
1264 1264
 		$TTitle = self::getAllTitleFromLine($line);
1265 1265
 		foreach ($TTitle as &$line_title)
Please login to merge, or discard this patch.
Braces   +296 added lines, -143 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');
@@ -37,26 +42,33 @@  discard block
 block discarded – undo
37 42
             {
38 43
                 /** @var Facture $object */
39 44
                 $res =  $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label);
40
-            }
41
-			elseif($object->element=='invoice_supplier') {
45
+            } elseif($object->element=='invoice_supplier') {
42 46
                 /** @var FactureFournisseur $object */
43 47
 			    $object->special_code = TSubtotal::$module_number;
44
-                if( (float)DOL_VERSION < 6 ) $rang = $object->line_max() + 1;
48
+                if( (float)DOL_VERSION < 6 ) {
49
+                	$rang = $object->line_max() + 1;
50
+                }
45 51
 			    $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
46 52
 			}
47 53
 			/**
48 54
 			 * @var $object Propal
49 55
 			 */
50
-			else if($object->element=='propal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
56
+			else if($object->element=='propal') {
57
+				$res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
58
+			}
51 59
 			/**
52 60
 			 * @var $object Propal Fournisseur
53 61
 			 */
54
-			else if($object->element=='supplier_proposal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
62
+			else if($object->element=='supplier_proposal') {
63
+				$res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
64
+			}
55 65
 			
56 66
 			/**
57 67
 			 * @var $object Commande
58 68
 			 */
59
-			else if($object->element=='commande') $res =  $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label);
69
+			else if($object->element=='commande') {
70
+				$res =  $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label);
71
+			}
60 72
 			/**
61 73
 			 * @var $object Commande fournisseur
62 74
 			 */
@@ -67,7 +79,9 @@  discard block
 block discarded – undo
67 79
 			/**
68 80
 			 * @var $object Facturerec
69 81
 			 */
70
-			else if($object->element=='facturerec') $res =  $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); 
82
+			else if($object->element=='facturerec') {
83
+				$res =  $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label);
84
+			}
71 85
 			
72 86
 		}
73 87
 	
@@ -89,8 +103,9 @@  discard block
 block discarded – undo
89 103
 			// Define output language
90 104
 			$outputlangs = $langs;
91 105
 			$newlang = GETPOST('lang_id', 'alpha');
92
-			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
93
-				$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
106
+			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
107
+							$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
108
+			}
94 109
 			if (! empty($newlang)) {
95 110
 				$outputlangs = new Translate("", $conf);
96 111
 				$outputlangs->setDefaultLang($newlang);
@@ -99,13 +114,18 @@  discard block
 block discarded – undo
99 114
 			$ret = $object->fetch($object->id); // Reload to get new records
100 115
 			if ((float) DOL_VERSION <= 3.6)
101 116
 			{
102
-				if ($object->element == 'propal') propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
103
-				elseif ($object->element == 'commande') commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
104
-				elseif ($object->element == 'facture') facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
105
-			}
106
-			else
117
+				if ($object->element == 'propal') {
118
+					propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
119
+				} elseif ($object->element == 'commande') {
120
+					commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
121
+				} elseif ($object->element == 'facture') {
122
+					facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
123
+				}
124
+			} else
107 125
 			{
108
-				if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
126
+				if ($object->element!= 'facturerec') {
127
+					$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
128
+				}
109 129
 			}
110 130
 		}
111 131
 	}
@@ -119,7 +139,9 @@  discard block
 block discarded – undo
119 139
 	 */
120 140
 	public static function updateRang(&$object, $rang_start, $move_to=1)
121 141
 	{
122
-		if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
142
+		if (!class_exists('GenericObject')) {
143
+			require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
144
+		}
123 145
 		
124 146
 		$row=new GenericObject($object->db);
125 147
 		$row->table_element_line = $object->table_element_line;
@@ -128,7 +150,9 @@  discard block
 block discarded – undo
128 150
 		
129 151
 		foreach ($object->lines as &$line)
130 152
 		{
131
-			if ($line->rang < $rang_start) continue;
153
+			if ($line->rang < $rang_start) {
154
+				continue;
155
+			}
132 156
 			
133 157
 			$row->updateRangOfLine($line->id, $line->rang+$move_to);
134 158
 		}
@@ -151,21 +175,28 @@  discard block
 block discarded – undo
151 175
 		foreach ($TTitle_reverse as $k => $title_line)
152 176
 		{
153 177
 			$title_niveau = self::getNiveau($title_line);
154
-			if ($title_niveau < $level_new_title) break;
178
+			if ($title_niveau < $level_new_title) {
179
+				break;
180
+			}
155 181
 			
156 182
 			$rang_to_add = self::titleHasTotalLine($object, $title_line, true, true);
157 183
 			
158 184
 			if (is_numeric($rang_to_add)) 
159 185
 			{
160
-				if ($rang_to_add != -1) self::updateRang($object, $rang_to_add);
186
+				if ($rang_to_add != -1) {
187
+					self::updateRang($object, $rang_to_add);
188
+				}
161 189
 				
162 190
 				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add);
163 191
 				
164 192
 				$object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas)
165 193
 				if ($rang_to_add != -1) 
166 194
 				{
167
-					if (method_exists($object, 'fetch_lines')) $object->fetch_lines();
168
-					else $object->fetch($object->id);
195
+					if (method_exists($object, 'fetch_lines')) {
196
+						$object->fetch_lines();
197
+					} else {
198
+						$object->fetch($object->id);
199
+					}
169 200
 				}
170 201
 			}
171 202
 		}
@@ -195,7 +226,9 @@  discard block
 block discarded – undo
195 226
 		
196 227
 		foreach ($TTitle as $k => $title_line)
197 228
 		{
198
-			if (self::titleHasTotalLine($object, $title_line)) unset($TTitle[$k]);
229
+			if (self::titleHasTotalLine($object, $title_line)) {
230
+				unset($TTitle[$k]);
231
+			}
199 232
 		}
200 233
 		
201 234
 		return $TTitle;
@@ -212,23 +245,41 @@  discard block
 block discarded – undo
212 245
 	 */
213 246
 	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false)
214 247
 	{
215
-		if (empty($object->lines) || !is_array($object->lines)) return false;
248
+		if (empty($object->lines) || !is_array($object->lines)) {
249
+			return false;
250
+		}
216 251
 		
217 252
 		$title_niveau = self::getNiveau($title_line);
218 253
 		foreach ($object->lines as &$line)
219 254
 		{
220
-			if ($line->rang <= $title_line->rang) continue;
221
-			if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) return false; // Oups on croise un titre d'un niveau inférieur ou égale (exemple : je croise un titre niveau 2 alors que je suis sur un titre de niveau 3) pas lieu de continuer car un nouveau bloc commence
222
-			if (!self::isSubtotal($line)) continue;
255
+			if ($line->rang <= $title_line->rang) {
256
+				continue;
257
+			}
258
+			if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) {
259
+				return false;
260
+			}
261
+			// Oups on croise un titre d'un niveau inférieur ou égale (exemple : je croise un titre niveau 2 alors que je suis sur un titre de niveau 3) pas lieu de continuer car un nouveau bloc commence
262
+			if (!self::isSubtotal($line)) {
263
+				continue;
264
+			}
223 265
 			
224 266
 			$subtotal_niveau = self::getNiveau($line);
225 267
 			
226 268
 			// Comparaison du niveau de la ligne de sous-total avec celui du titre
227
-			if ($subtotal_niveau == $title_niveau) return true; // niveau égale => Ok mon titre a un sous-total
228
-			elseif ($subtotal_niveau < $title_niveau) // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3)
269
+			if ($subtotal_niveau == $title_niveau) {
270
+				return true;
271
+			}
272
+			// niveau égale => Ok mon titre a un sous-total
273
+			elseif ($subtotal_niveau < $title_niveau) {
274
+				// niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3)
229 275
 			{
230
-				if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; // mode strict niveau pas égale donc faux
231
-				else return true; // mode libre => OK je considère que mon titre à un sous-total
276
+				if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false;
277
+			}
278
+			// mode strict niveau pas égale donc faux
279
+				else {
280
+					return true;
281
+				}
282
+				// mode libre => OK je considère que mon titre à un sous-total
232 283
 			}
233 284
 		}
234 285
 		
@@ -276,16 +327,19 @@  discard block
 block discarded – undo
276 327
 		
277 328
 		foreach ($object->lines as &$l)
278 329
 		{
279
-			if ($l->rang <= $line->rang) continue;
280
-			elseif (self::isSubtotal($l) && self::getNiveau($l) <= self::getNiveau($line)) break;
281
-			elseif ($breakOnTitle && self::isTitle($l) && self::getNiveau($l) <= self::getNiveau($line)) break;
330
+			if ($l->rang <= $line->rang) {
331
+				continue;
332
+			} elseif (self::isSubtotal($l) && self::getNiveau($l) <= self::getNiveau($line)) {
333
+				break;
334
+			} elseif ($breakOnTitle && self::isTitle($l) && self::getNiveau($l) <= self::getNiveau($line)) {
335
+				break;
336
+			}
282 337
 			
283 338
 			if (!empty($l->array_options['options_subtotal_nc']))
284 339
 			{
285 340
 				$tabprice = calcul_price_total($l->qty, $l->subprice, $l->remise_percent, $l->tva_tx, $l->localtax1_tx, $l->localtax2_tx, 0, 'HT', $l->info_bits, $l->product_type);
286 341
 				$TTot['total_options'] += $tabprice[0]; // total ht
287
-			}
288
-			else
342
+			} else
289 343
 			{
290 344
 				$TTot['total_pa_ht'] += $l->pa_ht * $l->qty;
291 345
 				$TTot['total_subprice'] += $l->subprice * $l->qty;
@@ -306,42 +360,61 @@  discard block
 block discarded – undo
306 360
 
307 361
 	public static function getOrderIdFromLineId(&$db, $fk_commandedet, $supplier = false)
308 362
 	{
309
-		if (empty($fk_commandedet)) return false;
363
+		if (empty($fk_commandedet)) {
364
+			return false;
365
+		}
310 366
 
311 367
 		$table = 'commandedet';
312
-		if ($supplier) $table = 'commande_fournisseurdet';
368
+		if ($supplier) {
369
+			$table = 'commande_fournisseurdet';
370
+		}
313 371
 
314 372
 		$sql = 'SELECT fk_commande FROM '.MAIN_DB_PREFIX.$table.' WHERE rowid = '.$fk_commandedet;
315 373
 		$resql = $db->query($sql);
316 374
 
317
-		if ($resql && ($row = $db->fetch_object($resql))) return $row->fk_commande;
318
-		else return false;
375
+		if ($resql && ($row = $db->fetch_object($resql))) {
376
+			return $row->fk_commande;
377
+		} else {
378
+			return false;
379
+		}
319 380
 	}
320 381
 	
321 382
 	public static function getLastLineOrderId(&$db, $fk_commande, $supplier = false)
322 383
 	{
323
-		if (empty($fk_commande)) return false;
384
+		if (empty($fk_commande)) {
385
+			return false;
386
+		}
324 387
 
325 388
         $table = 'commandedet';
326
-        if ($supplier) $table = 'commande_fournisseurdet';
389
+        if ($supplier) {
390
+        	$table = 'commande_fournisseurdet';
391
+        }
327 392
 
328 393
 		$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$table.' WHERE fk_commande = '.$fk_commande.' ORDER BY rang DESC LIMIT 1';
329 394
 		$resql = $db->query($sql);
330 395
 		
331
-		if ($resql && ($row = $db->fetch_object($resql))) return (int) $row->rowid;
332
-		else return false;
396
+		if ($resql && ($row = $db->fetch_object($resql))) {
397
+			return (int) $row->rowid;
398
+		} else {
399
+			return false;
400
+		}
333 401
 	}
334 402
 	
335 403
 	public static function getParentTitleOfLine(&$object, $rang)
336 404
 	{
337
-		if ($rang <= 0) return false;
405
+		if ($rang <= 0) {
406
+			return false;
407
+		}
338 408
 		
339 409
 		$skip_title = 0;
340 410
 		$TLineReverse = array_reverse($object->lines);
341 411
 
342 412
 		foreach($TLineReverse as $line)
343 413
 		{
344
-			if ($line->rang >= $rang) continue; // Tout ce qui ce trouve en dessous j'ignore, nous voulons uniquement ce qui ce trouve au dessus
414
+			if ($line->rang >= $rang) {
415
+				continue;
416
+			}
417
+			// Tout ce qui ce trouve en dessous j'ignore, nous voulons uniquement ce qui ce trouve au dessus
345 418
 
346 419
             if (self::isTitle($line))
347 420
 			{
@@ -354,8 +427,7 @@  discard block
 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 (self::isSubtotal($line))
430
+			} elseif (self::isSubtotal($line))
359 431
 			{
360 432
 				// Il s'agit d'un sous-total, ça veut dire que le prochain titre théoriquement doit être ignorer (je travail avec un incrément au cas ou je croise plusieurs sous-totaux)
361 433
 				$skip_title++;
@@ -370,7 +442,9 @@  discard block
 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
 			{
@@ -504,8 +587,9 @@  discard block
 block discarded – undo
504 587
 
505 588
 					$TLineAdded[] = $object->line;
506 589
 					// Error from addline
507
-					if ($res <= 0) break;
508
-					else
590
+					if ($res <= 0) {
591
+						break;
592
+					} else
509 593
 					{
510 594
 						$object->line_from = $line;
511 595
 						// Call trigger
@@ -527,8 +611,7 @@  discard block
 block discarded – undo
527 611
 					    _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']);
528 612
 					}
529 613
 					return count($TLineAdded);
530
-				}
531
-				else
614
+				} else
532 615
 				{
533 616
 					$object->db->rollback();
534 617
 					return -1;
@@ -544,10 +627,14 @@  discard block
 block discarded – undo
544 627
 		global $langs;
545 628
 		
546 629
 		// Besoin de comparer sur les 2 formes d'écriture
547
-		if (!$key_is_id) $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad));
630
+		if (!$key_is_id) {
631
+			$TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad));
632
+		}
548 633
 		
549 634
 		$TTitle_under_search = array();
550
-		if (!empty($under_title)) $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title));
635
+		if (!empty($under_title)) {
636
+			$TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title));
637
+		}
551 638
 		
552 639
 		$TLine = array();
553 640
 		$add_line = false;
@@ -557,28 +644,37 @@  discard block
 block discarded – undo
557 644
 		{
558 645
 			if (!$under_title_found && !empty($TTitle_under_search))
559 646
 			{
560
-				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true;
561
-			}
562
-			else
647
+				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) {
648
+					$under_title_found = true;
649
+				}
650
+			} else
563 651
 			{
564 652
 				if ( ($key_is_id && $line->id == $key_trad) || (!$key_is_id && $line->product_type == 9 && $line->qty == $level && (in_array($line->desc, $TTitle_search) || in_array($line->label, $TTitle_search) )))
565 653
 				{
566
-					if ($key_is_id) $level = $line->qty;
654
+					if ($key_is_id) {
655
+						$level = $line->qty;
656
+					}
567 657
 					
568 658
 					$add_line = true;
569
-					if ($withBlockLine) $TLine[] = $line;
659
+					if ($withBlockLine) {
660
+						$TLine[] = $line;
661
+					}
570 662
 					continue;
571
-				}
572
-				elseif ($add_line && TSubtotal::isModSubtotalLine($line) && TSubtotal::getNiveau($line) == $level) // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre
663
+				} elseif ($add_line && TSubtotal::isModSubtotalLine($line) && TSubtotal::getNiveau($line) == $level) {
664
+					// Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre
573 665
 				{
574 666
 					if ($withBlockLine) $TLine[] = $line;
667
+				}
575 668
 					break;
576 669
 				}
577 670
 				
578 671
 				if ($add_line)
579 672
 				{
580
-					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue;
581
-					else $TLine[] = $line;
673
+					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) {
674
+						continue;
675
+					} else {
676
+						$TLine[] = $line;
677
+					}
582 678
 				}
583 679
 			}
584 680
 		}
@@ -612,7 +708,9 @@  discard block
 block discarded – undo
612 708
 				
613 709
 			case 'order_supplier':
614 710
 			    $object->special_code = SELF::$module_number;
615
-			    if (empty($desc)) $desc = $label;
711
+			    if (empty($desc)) {
712
+			    	$desc = $label;
713
+			    }
616 714
 			    $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit);
617 715
 			    break;
618 716
 			
@@ -622,7 +720,9 @@  discard block
 block discarded – undo
622 720
 				
623 721
 			case 'invoice_supplier':
624 722
 			    $object->special_code = SELF::$module_number;
625
-			    if (empty($desc)) $desc = $label;
723
+			    if (empty($desc)) {
724
+			    	$desc = $label;
725
+			    }
626 726
 			    $res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit);
627 727
 			    break;
628 728
 				
@@ -639,8 +739,11 @@  discard block
 block discarded – undo
639 739
 				break;
640 740
 		}
641 741
 		
642
-		if ($res <= 0) $object->db->rollback();
643
-		else $object->db->commit();
742
+		if ($res <= 0) {
743
+			$object->db->rollback();
744
+		} else {
745
+			$object->db->commit();
746
+		}
644 747
 		
645 748
 		return $res;
646 749
 	}
@@ -650,24 +753,20 @@  discard block
 block discarded – undo
650 753
 		global $db, $object;
651 754
 		
652 755
 		$TTitle = array();
653
-		if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {}
654
-		else {
756
+		if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} else {
655 757
 			if ($origin_line->element == 'propaldet')
656 758
 			{
657 759
 				$object = new Propal($db);
658 760
 				$object->fetch($origin_line->fk_propal);
659
-			}
660
-			else if ($origin_line->element == 'commandedet')
761
+			} else if ($origin_line->element == 'commandedet')
661 762
 			{
662 763
 				$object = new Commande($db);
663 764
 				$object->fetch($origin_line->fk_commande);
664
-			}
665
-			else if ($origin_line->element == 'facturedet')
765
+			} else if ($origin_line->element == 'facturedet')
666 766
 			{
667 767
 				$object = new Facture($db);
668 768
 				$object->fetch($origin_line->fk_facture);
669
-			}
670
-			else
769
+			} else
671 770
 			{
672 771
 				return $TTitle;
673 772
 			}
@@ -677,8 +776,11 @@  discard block
 block discarded – undo
677 776
 		$i = 0;
678 777
 		foreach ($object->lines as &$line)
679 778
 		{
680
-			if ($origin_line->id == $line->id) break;
681
-			else $i++;
779
+			if ($origin_line->id == $line->id) {
780
+				break;
781
+			} else {
782
+				$i++;
783
+			}
682 784
 		}
683 785
 		
684 786
 		$i--; // Skip la ligne d'origine
@@ -693,35 +795,43 @@  discard block
 block discarded – undo
693 795
 				if (self::isSubtotal($object->lines[$y]))
694 796
 				{
695 797
 					$next_title_lvl_to_skip = self::getNiveau($object->lines[$y]);
696
-				}
697
-				elseif (self::isTitle($object->lines[$y]))
798
+				} elseif (self::isTitle($object->lines[$y]))
698 799
 				{
699 800
 					if ($object->lines[$y]->qty == $next_title_lvl_to_skip)
700 801
 					{
701 802
 						$next_title_lvl_to_skip = 0;
702 803
 						continue;
703
-					}
704
-					else
804
+					} else
705 805
 					{
706
-						if (empty($object->lines[$y]->array_options)) $object->lines[$y]->fetch_optionals();
806
+						if (empty($object->lines[$y]->array_options)) {
807
+							$object->lines[$y]->fetch_optionals();
808
+						}
707 809
 						$TTitle[$object->lines[$y]->id] = $object->lines[$y];
708 810
 						
709
-						if ($object->lines[$y]->qty == 1) break;
811
+						if ($object->lines[$y]->qty == 1) {
812
+							break;
813
+						}
710 814
 					}
711 815
 				}
712 816
 			}
713 817
 		}
714 818
 		
715
-		if ($reverse) $TTitle = array_reverse($TTitle, true);
819
+		if ($reverse) {
820
+			$TTitle = array_reverse($TTitle, true);
821
+		}
716 822
 		
717 823
 		return $TTitle;
718 824
 	}
719 825
 	
720 826
 	public static function getNiveau(&$line)
721 827
 	{
722
-		if (self::isTitle($line)) return $line->qty;
723
-		elseif (self::isSubtotal($line)) return 100 - $line->qty;
724
-		else return 0;
828
+		if (self::isTitle($line)) {
829
+			return $line->qty;
830
+		} elseif (self::isSubtotal($line)) {
831
+			return 100 - $line->qty;
832
+		} else {
833
+			return 0;
834
+		}
725 835
 	}
726 836
 	
727 837
 	/**
@@ -746,10 +856,16 @@  discard block
 block discarded – undo
746 856
 		$objmarge->marge_droite = 10;
747 857
 		
748 858
 		$objectref = dol_sanitizeFileName($object->ref);
749
-		if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref;
750
-		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref;
751
-		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref;
752
-		elseif ($object->element == 'facturerec') return; // no PDF for facturerec
859
+		if ($object->element == 'propal') {
860
+			$dir = $conf->propal->dir_output . '/' . $objectref;
861
+		} elseif ($object->element == 'commande') {
862
+			$dir = $conf->commande->dir_output . '/' . $objectref;
863
+		} elseif ($object->element == 'facture') {
864
+			$dir = $conf->facture->dir_output . '/' . $objectref;
865
+		} elseif ($object->element == 'facturerec') {
866
+			return;
867
+		}
868
+		// no PDF for facturerec
753 869
 		else
754 870
 		{
755 871
 			setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings');
@@ -784,7 +900,9 @@  discard block
 block discarded – undo
784 900
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
785 901
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
786 902
 		$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
787
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
903
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
904
+			$pdf->SetCompression(false);
905
+		}
788 906
 
789 907
 		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite);   // Left, Top, Right
790 908
 
@@ -794,7 +912,9 @@  discard block
 block discarded – undo
794 912
 			
795 913
 		// New page
796 914
 		$pdf->AddPage();
797
-		if (! empty($tplidx)) $pdf->useTemplate($tplidx);
915
+		if (! empty($tplidx)) {
916
+			$pdf->useTemplate($tplidx);
917
+		}
798 918
 		$pagenb++;
799 919
 		
800 920
 		
@@ -850,8 +970,10 @@  discard block
 block discarded – undo
850 970
 					{
851 971
 						$TTot['TTotal_tva_multicurrency'][$tx] += $amount;
852 972
 					}	
973
+				} else {
974
+					$pdf->SetFont('','', $default_font_size - 1);
853 975
 				}
854
-				else $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
976
+				// Into loop to work with multipage
855 977
 				
856 978
 				$pdf->SetTextColor(0,0,0);
857 979
 				
@@ -873,9 +995,11 @@  discard block
 block discarded – undo
873 995
 				$pdf->startTransaction();
874 996
 				$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
875 997
 				$pageposafter=$pdf->getPage();
876
-				if ($pageposafter > $pageposbefore)	// There is a pagebreak
998
+				if ($pageposafter > $pageposbefore) {
999
+					// There is a pagebreak
877 1000
 				{
878 1001
 					$pdf->rollbackTransaction(true);
1002
+				}
879 1003
 					$pageposafter=$pageposbefore;
880 1004
 					//print $pageposafter.'-'.$pageposbefore;exit;
881 1005
 					$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -884,23 +1008,27 @@  discard block
 block discarded – undo
884 1008
 					$pageposafter=$pdf->getPage();
885 1009
 					$posyafter=$pdf->GetY();
886 1010
 					//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
887
-					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot)))	// There is no space left for total+free text
1011
+					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) {
1012
+						// There is no space left for total+free text
888 1013
 					{
889 1014
 						if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
890 1015
 						{
891 1016
 							$pdf->AddPage('','',true);
892
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
893
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1017
+					}
1018
+							if (! empty($tplidx)) {
1019
+								$pdf->useTemplate($tplidx);
1020
+							}
1021
+							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
1022
+								self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1023
+							}
894 1024
 							$pdf->setPage($pageposafter+1);
895 1025
 						}
896
-					}
897
-					else
1026
+					} else
898 1027
 					{
899 1028
 						// We found a page break
900 1029
 						$showpricebeforepagebreak=0;
901 1030
 					}
902
-				}
903
-				else	// No pagebreak
1031
+				} else	// No pagebreak
904 1032
 				{
905 1033
 					$pdf->commitTransaction();
906 1034
 				}
@@ -940,8 +1068,7 @@  discard block
 block discarded – undo
940 1068
 					if ($pagenb == 1)
941 1069
 					{
942 1070
 						self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
943
-					}
944
-					else
1071
+					} else
945 1072
 					{
946 1073
 						self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
947 1074
 					}
@@ -949,7 +1076,9 @@  discard block
 block discarded – undo
949 1076
 					$pagenb++;
950 1077
 					$pdf->setPage($pagenb);
951 1078
 					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
952
-					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1079
+					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
1080
+						self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1081
+					}
953 1082
 				}
954 1083
 			}
955 1084
 		}
@@ -959,8 +1088,7 @@  discard block
 block discarded – undo
959 1088
 		{
960 1089
 			self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
961 1090
 			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
962
-		}
963
-		else
1091
+		} else
964 1092
 		{
965 1093
 			self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
966 1094
 			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
@@ -974,7 +1102,9 @@  discard block
 block discarded – undo
974 1102
 		
975 1103
 		$pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file);
976 1104
 		
977
-		if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) unlink($file);
1105
+		if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) {
1106
+			unlink($file);
1107
+		}
978 1108
 	}
979 1109
 	
980 1110
 	private static function printLevel($objmarge, $pdf, $line, $curY, $posx_designation)
@@ -1017,8 +1147,7 @@  discard block
 block discarded – undo
1017 1147
 			{
1018 1148
 			    $height=pdf_getHeightForLogo($logo);
1019 1149
 			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1020
-			}
1021
-			else
1150
+			} else
1022 1151
 			{
1023 1152
 				$pdf->SetTextColor(200,0,0);
1024 1153
 				$pdf->SetFont('','B',$default_font_size - 2);
@@ -1027,8 +1156,7 @@  discard block
 block discarded – undo
1027 1156
 			}
1028 1157
 			
1029 1158
 			$posy+=35;
1030
-		}
1031
-		else
1159
+		} else
1032 1160
 		{
1033 1161
 			$text=$mysoc->name;
1034 1162
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1042,9 +1170,13 @@  discard block
 block discarded – undo
1042 1170
 		$pdf->SetXY($objmarge->marge_gauche,$posy);
1043 1171
 		
1044 1172
 		$key = 'subtotalPropalTitle';
1045
-		if ($object->element == 'commande') $key = 'subtotalCommandeTitle';
1046
-		elseif ($object->element == 'facture') $key = 'subtotalInvoiceTitle';
1047
-		elseif ($object->element == 'facturerec') $key = 'subtotalInvoiceTitle';
1173
+		if ($object->element == 'commande') {
1174
+			$key = 'subtotalCommandeTitle';
1175
+		} elseif ($object->element == 'facture') {
1176
+			$key = 'subtotalInvoiceTitle';
1177
+		} elseif ($object->element == 'facturerec') {
1178
+			$key = 'subtotalInvoiceTitle';
1179
+		}
1048 1180
 		
1049 1181
 		$pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L');
1050 1182
 		
@@ -1079,7 +1211,9 @@  discard block
 block discarded – undo
1079 1211
 		
1080 1212
 		// Force to disable hidetop and hidebottom
1081 1213
 		$hidebottom=0;
1082
-		if ($hidetop) $hidetop=-1;
1214
+		if ($hidetop) {
1215
+			$hidetop=-1;
1216
+		}
1083 1217
 
1084 1218
 		$currency = !empty($currency) ? $currency : $conf->currency;
1085 1219
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1094,7 +1228,9 @@  discard block
 block discarded – undo
1094 1228
 			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5);
1095 1229
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1096 1230
 			
1097
-			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1231
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1232
+				$pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1233
+			}
1098 1234
 			
1099 1235
 			
1100 1236
 			$pdf->line($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top);	// line prend une position y en 2eme param et 4eme param
@@ -1107,8 +1243,7 @@  discard block
 block discarded – undo
1107 1243
 			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R');
1108 1244
 			
1109 1245
 			$pdf->line($objmarge->marge_gauche, $tab_top+8, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top+8);	// line prend une position y en 2eme param et 4eme param
1110
-		}
1111
-		else
1246
+		} else
1112 1247
 		{
1113 1248
 			$pdf->line($objmarge->marge_gauche, $tab_top-2, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top-2);	// line prend une position y en 2eme param et 4eme param
1114 1249
 		}
@@ -1129,10 +1264,12 @@  discard block
 block discarded – undo
1129 1264
 
1130 1265
 		// Tableau total
1131 1266
 		$col1x = 120; $col2x = 170;
1132
-		if ($objmarge->page_largeur < 210) // To work with US executive format
1267
+		if ($objmarge->page_largeur < 210) {
1268
+			// To work with US executive format
1133 1269
 		{
1134 1270
 			$col2x-=20;
1135 1271
 		}
1272
+		}
1136 1273
 		$largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x);
1137 1274
 
1138 1275
 		$useborder=0;
@@ -1154,9 +1291,11 @@  discard block
 block discarded – undo
1154 1291
 		$atleastoneratenotnull=0;
1155 1292
 		foreach($TTot['TTotal_tva'] as $tvakey => $tvaval)
1156 1293
 		{
1157
-			if ($tvakey != 0)    // On affiche pas taux 0
1294
+			if ($tvakey != 0) {
1295
+				// On affiche pas taux 0
1158 1296
 			{
1159 1297
 				$atleastoneratenotnull++;
1298
+			}
1160 1299
 
1161 1300
 				$index++;
1162 1301
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1209,9 +1348,13 @@  discard block
 block discarded – undo
1209 1348
 	 */
1210 1349
     private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1211 1350
     {
1212
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1351
+	    if (empty($hidetop) || $hidetop==-1) {
1352
+	    	$pdf->line($x, $y, $x+$l, $y);
1353
+	    }
1213 1354
 	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1214
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1355
+	    if (empty($hidebottom)) {
1356
+	    	$pdf->line($x+$l, $y+$h, $x, $y+$h);
1357
+	    }
1215 1358
 	    $pdf->line($x, $y+$h, $x, $y);
1216 1359
     }
1217 1360
 	
@@ -1220,7 +1363,9 @@  discard block
 block discarded – undo
1220 1363
 	{
1221 1364
 		global $conf;
1222 1365
 		
1223
-		if (empty($fileoutput)) $fileoutput = $file[0];
1366
+		if (empty($fileoutput)) {
1367
+			$fileoutput = $file[0];
1368
+		}
1224 1369
 		
1225 1370
 		$pdf=pdf_getInstance();
1226 1371
         if (class_exists('TCPDF'))
@@ -1230,7 +1375,9 @@  discard block
 block discarded – undo
1230 1375
         }
1231 1376
         $pdf->SetFont(pdf_getPDFFont($outputlangs));
1232 1377
 
1233
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1378
+        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
1379
+        	$pdf->SetCompression(false);
1380
+        }
1234 1381
 
1235 1382
 		
1236 1383
 		foreach($files as $file)
@@ -1246,7 +1393,9 @@  discard block
 block discarded – undo
1246 1393
 		}
1247 1394
 		
1248 1395
 		$pdf->Output($fileoutput,'F');
1249
-		if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1396
+		if (! empty($conf->global->MAIN_UMASK)) {
1397
+			@chmod($file, octdec($conf->global->MAIN_UMASK));
1398
+		}
1250 1399
 
1251 1400
 		return $pagecount;
1252 1401
 	}
@@ -1259,7 +1408,9 @@  discard block
 block discarded – undo
1259 1408
 	 */
1260 1409
 	public static function hasNcTitle(&$line)
1261 1410
 	{
1262
-		if(isset($line->has_nc_title)) return $line->has_nc_title;
1411
+		if(isset($line->has_nc_title)) {
1412
+			return $line->has_nc_title;
1413
+		}
1263 1414
 
1264 1415
 		$TTitle = self::getAllTitleFromLine($line);
1265 1416
 		foreach ($TTitle as &$line_title)
@@ -1284,7 +1435,9 @@  discard block
 block discarded – undo
1284 1435
 	public static function getTitleLabel($line)
1285 1436
 	{
1286 1437
 		$title = $line->label;
1287
-		if (empty($title)) $title = !empty($line->description) ? $line->description : $line->desc;
1438
+		if (empty($title)) {
1439
+			$title = !empty($line->description) ? $line->description : $line->desc;
1440
+		}
1288 1441
 		return $title;
1289 1442
 	}
1290 1443
 }
Please login to merge, or discard this patch.
admin/subtotal_setup.php 3 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 // Dolibarr environment
29 29
 $res = @include("../../main.inc.php"); // From htdocs directory
30 30
 if (! $res) {
31
-    $res = @include("../../../main.inc.php"); // From "custom" directory
31
+	$res = @include("../../../main.inc.php"); // From "custom" directory
32 32
 }
33 33
 
34 34
 // Libraries
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 // Access control
41 41
 if (! $user->admin) {
42
-    accessforbidden();
42
+	accessforbidden();
43 43
 }
44 44
 
45 45
 // Parameters
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
 // Configuration header
97 97
 $head = subtotalAdminPrepareHead();
98 98
 dol_fiche_head(
99
-    $head,
100
-    'settings',
101
-    $langs->trans("Module104777Name"),
102
-    -1,
103
-    "subtotal@subtotal"
99
+	$head,
100
+	'settings',
101
+	$langs->trans("Module104777Name"),
102
+	-1,
103
+	"subtotal@subtotal"
104 104
 );
105 105
 
106 106
 showParameters();
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
 	print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_BLOCK');
170 170
 	print '</td></tr>';
171 171
 
172
-    $var=!$var;
173
-    print '<tr '.$bc[$var].'>';
174
-    print '<td>'.$langs->trans("SUBTOTAL_ALLOW_DUPLICATE_LINE").'</td>';
175
-    print '<td align="center" width="20">&nbsp;</td>';
176
-    print '<td align="center" width="300">';
177
-    print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_LINE');
178
-    print '</td></tr>';
172
+	$var=!$var;
173
+	print '<tr '.$bc[$var].'>';
174
+	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_DUPLICATE_LINE").'</td>';
175
+	print '<td align="center" width="20">&nbsp;</td>';
176
+	print '<td align="center" width="300">';
177
+	print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_LINE');
178
+	print '</td></tr>';
179 179
 	
180 180
 	$var=!$var;
181 181
 	print '<tr '.$bc[$var].'>';
@@ -272,12 +272,12 @@  discard block
 block discarded – undo
272 272
 		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
273 273
 		print '<input type="hidden" name="action" value="set_SUBTOTAL_TFIELD_TO_KEEP_WITH_NC">';
274 274
 		$TField = array(
275
-		    'pdf_getlineqty' => $langs->trans('Qty'), 
276
-		    'pdf_getlinevatrate' => $langs->trans('VAT'), 
277
-		    'pdf_getlineupexcltax' => $langs->trans('PriceUHT'), 
278
-		    'pdf_getlinetotalexcltax' => $langs->trans('TotalHT'), 
279
-		    'pdf_getlineunit' => $langs->trans('Unit'),
280
-		    'pdf_getlineremisepercent' => $langs->trans('Discount')
275
+			'pdf_getlineqty' => $langs->trans('Qty'), 
276
+			'pdf_getlinevatrate' => $langs->trans('VAT'), 
277
+			'pdf_getlineupexcltax' => $langs->trans('PriceUHT'), 
278
+			'pdf_getlinetotalexcltax' => $langs->trans('TotalHT'), 
279
+			'pdf_getlineunit' => $langs->trans('Unit'),
280
+			'pdf_getlineremisepercent' => $langs->trans('Discount')
281 281
 		);
282 282
 		print $html->multiselectarray('SUBTOTAL_TFIELD_TO_KEEP_WITH_NC', $TField, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC), 0, 0, '', 0, 0, 'style="min-width:100px"');
283 283
 		print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -27,37 +27,37 @@  discard block
 block discarded – undo
27 27
 // Change this following line to use the correct relative path (../, ../../, etc)
28 28
 // Dolibarr environment
29 29
 $res = @include("../../main.inc.php"); // From htdocs directory
30
-if (! $res) {
30
+if (!$res) {
31 31
     $res = @include("../../../main.inc.php"); // From "custom" directory
32 32
 }
33 33
 
34 34
 // Libraries
35
-require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
35
+require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
36 36
 require_once '../lib/subtotal.lib.php';
37 37
 
38 38
 $langs->load("subtotal@subtotal");
39 39
 
40 40
 // Access control
41
-if (! $user->admin) {
41
+if (!$user->admin) {
42 42
     accessforbidden();
43 43
 }
44 44
 
45 45
 // Parameters
46 46
 $action = GETPOST('action', 'alpha');
47 47
 
48
-if($action=='save') {
48
+if ($action == 'save') {
49 49
 	
50
-	foreach($_REQUEST['TDivers'] as $name=>$param) {
50
+	foreach ($_REQUEST['TDivers'] as $name=>$param) {
51 51
 		
52
-		dolibarr_set_const($db, $name, $param,'chaine', 0, '', $conf->entity);
52
+		dolibarr_set_const($db, $name, $param, 'chaine', 0, '', $conf->entity);
53 53
 		
54 54
 	}
55 55
 	
56 56
 }
57 57
 
58
-if (preg_match('/set_(.*)/',$action,$reg))
58
+if (preg_match('/set_(.*)/', $action, $reg))
59 59
 {
60
-	$code=$reg[1];
60
+	$code = $reg[1];
61 61
 	$value = GETPOST($code);
62 62
 	if (in_array($code, array(
63 63
 		'SUBTOTAL_TFIELD_TO_KEEP_WITH_NC'
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 
89 89
 
90 90
 
91
-llxHeader('','Gestion de sous-total, à propos','');
91
+llxHeader('', 'Gestion de sous-total, à propos', '');
92 92
 
93
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
94
-print_fiche_titre('Gestion de subtotal',$linkback,'setup');
93
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
94
+print_fiche_titre('Gestion de subtotal', $linkback, 'setup');
95 95
 
96 96
 // Configuration header
97 97
 $head = subtotalAdminPrepareHead();
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 showParameters();
107 107
 
108 108
 function showParameters() {
109
-	global $db,$conf,$langs,$bc;
109
+	global $db, $conf, $langs, $bc;
110 110
 	
111
-	$html=new Form($db);
111
+	$html = new Form($db);
112 112
 	
113
-	$var=false;
113
+	$var = false;
114 114
 	print '<table class="noborder" width="100%">';
115 115
 	print '<tr class="liste_titre">';
116 116
 	print '<td>'.$langs->trans("Parameters").'</td>'."\n";
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
119 119
 	print '</tr>';
120 120
 	
121
-	$var=!$var;
121
+	$var = !$var;
122 122
 	print '<tr '.$bc[$var].'>';
123 123
 	print '<td>'.$langs->trans("SUBTOTAL_USE_NEW_FORMAT").'</td>';
124 124
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 	print ajax_constantonoff('SUBTOTAL_USE_NEW_FORMAT');
127 127
 	print '</td></tr>';
128 128
 	
129
-	if((float)DOL_VERSION>=3.8)
129
+	if ((float) DOL_VERSION >= 3.8)
130 130
 	{
131
-		$var=!$var;
131
+		$var = !$var;
132 132
 		print '<tr '.$bc[$var].'>';
133 133
 		print '<td>'.$langs->trans("SUBTOTAL_USE_NUMEROTATION").'</td>';
134 134
 		print '<td align="center" width="20">&nbsp;</td>';
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 		print '</td></tr>';	
138 138
 	}
139 139
 	
140
-	$var=!$var;
140
+	$var = !$var;
141 141
 	print '<tr '.$bc[$var].'>';
142 142
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_ADD_BLOCK").'</td>';
143 143
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	print ajax_constantonoff('SUBTOTAL_ALLOW_ADD_BLOCK');
146 146
 	print '</td></tr>';
147 147
 	
148
-	$var=!$var;
148
+	$var = !$var;
149 149
 	print '<tr '.$bc[$var].'>';
150 150
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_EDIT_BLOCK").'</td>';
151 151
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	print ajax_constantonoff('SUBTOTAL_ALLOW_EDIT_BLOCK');
154 154
 	print '</td></tr>';
155 155
 	
156
-	$var=!$var;
156
+	$var = !$var;
157 157
 	print '<tr '.$bc[$var].'>';
158 158
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_REMOVE_BLOCK").'</td>';
159 159
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	print ajax_constantonoff('SUBTOTAL_ALLOW_REMOVE_BLOCK');
162 162
 	print '</td></tr>';
163 163
 	
164
-	$var=!$var;
164
+	$var = !$var;
165 165
 	print '<tr '.$bc[$var].'>';
166 166
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_DUPLICATE_BLOCK").'</td>';
167 167
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_BLOCK');
170 170
 	print '</td></tr>';
171 171
 
172
-    $var=!$var;
172
+    $var = !$var;
173 173
     print '<tr '.$bc[$var].'>';
174 174
     print '<td>'.$langs->trans("SUBTOTAL_ALLOW_DUPLICATE_LINE").'</td>';
175 175
     print '<td align="center" width="20">&nbsp;</td>';
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
     print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_LINE');
178 178
     print '</td></tr>';
179 179
 	
180
-	$var=!$var;
180
+	$var = !$var;
181 181
 	print '<tr '.$bc[$var].'>';
182 182
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE").'</td>';
183 183
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	print ajax_constantonoff('SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE');
186 186
 	print '</td></tr>';
187 187
 	
188
-	$var=!$var;
188
+	$var = !$var;
189 189
 	print '<tr '.$bc[$var].'>';
190 190
 	print '<td>'.$langs->trans("SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK").'</td>';
191 191
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	print ajax_constantonoff('SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK');
194 194
 	print '</td></tr>';
195 195
 
196
-	$var=!$var;
196
+	$var = !$var;
197 197
 	print '<tr '.$bc[$var].'>';
198 198
 	print '<td>'.$html->textwithpicto($langs->trans("SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE"), $langs->trans("SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE_info")).'</td>';
199 199
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	print '</form>';
207 207
 	print '</td></tr>';
208 208
 	
209
-	$var=!$var;
209
+	$var = !$var;
210 210
 	print '<tr '.$bc[$var].'>';
211 211
 	print '<td>'.$langs->trans("SUBTOTAL_TITLE_STYLE").'</td>';
212 212
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	print '</form>';
220 220
 	print '</td></tr>';
221 221
 	
222
-	$var=!$var;
222
+	$var = !$var;
223 223
 	print '<tr '.$bc[$var].'>';
224 224
 	print '<td>'.$langs->trans("SUBTOTAL_SUBTOTAL_STYLE").'</td>';
225 225
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	print '</form>';
233 233
 	print '</td></tr>';
234 234
 	
235
-	$var=!$var;
235
+	$var = !$var;
236 236
 	print '<tr '.$bc[$var].'>';
237 237
 	print '<td>'.$langs->trans("SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES", $langs->transnoentitiesnoconv('HideInnerLines')).'</td>';
238 238
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	print ajax_constantonoff('SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES');
241 241
 	print '</td></tr>';
242 242
 	
243
-	$var=!$var;
243
+	$var = !$var;
244 244
 	print '<tr '.$bc[$var].'>';
245 245
 	print '<td>'.$langs->trans("SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES", $langs->transnoentitiesnoconv('HideInnerLines')).'</td>';
246 246
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	
251 251
 	if ((double) DOL_VERSION >= 4.0)
252 252
 	{
253
-		$var=!$var;
253
+		$var = !$var;
254 254
 		print '<tr '.$bc[$var].'>';
255 255
 		print '<td>'.$langs->trans("SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS").'</td>';
256 256
 		print '<td align="center" width="20">&nbsp;</td>';
@@ -258,12 +258,12 @@  discard block
 block discarded – undo
258 258
 		print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
259 259
 		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
260 260
 		print '<input type="hidden" name="action" value="set_SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS">';
261
-		print $html->selectyesno("SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS",$conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS,1);
261
+		print $html->selectyesno("SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS", $conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS, 1);
262 262
 		print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
263 263
 		print '</form>';
264 264
 		print '</td></tr>';
265 265
 		
266
-		$var=!$var;
266
+		$var = !$var;
267 267
 		print '<tr '.$bc[$var].'>';
268 268
 		print '<td>'.$langs->trans("SUBTOTAL_TFIELD_TO_KEEP_WITH_NC").'</td>';
269 269
 		print '<td align="center" width="20">&nbsp;</td>';
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 		print '</td></tr>';
286 286
 	}
287 287
 	
288
-	$var=!$var;
288
+	$var = !$var;
289 289
 	print '<tr '.$bc[$var].'>';
290 290
 	print '<td>'.$langs->trans('SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE').'</td>';
291 291
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	print ajax_constantonoff('SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE');
294 294
 	print '</td></tr>';
295 295
 	
296
-	$var=!$var;
296
+	$var = !$var;
297 297
 	print '<tr '.$bc[$var].'>';
298 298
 	print '<td>'.$langs->trans('SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE').'</td>';
299 299
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	print ajax_constantonoff('SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE');
302 302
 	print '</td></tr>';
303 303
 
304
-	$var=!$var;
304
+	$var = !$var;
305 305
 	print '<tr '.$bc[$var].'>';
306 306
 	print '<td>'.$langs->trans("SUBTOTAL_LIST_OF_EXTRAFIELDS_PROPALDET").'</td>';
307 307
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	print '</form>';
317 317
 	print '</td></tr>';
318 318
 
319
-	$var=!$var;
319
+	$var = !$var;
320 320
 	print '<tr '.$bc[$var].'>';
321 321
 	print '<td>'.$langs->trans("SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET").'</td>';
322 322
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 	print '</form>';
332 332
 	print '</td></tr>';
333 333
 
334
-	$var=!$var;
334
+	$var = !$var;
335 335
 	print '<tr '.$bc[$var].'>';
336 336
 	print '<td>'.$langs->trans("SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET").'</td>';
337 337
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	
353 353
 	
354 354
 	
355
-	$var=false;
355
+	$var = false;
356 356
 	print '<table class="noborder" width="100%">';
357 357
 	print '<tr class="liste_titre">';
358 358
 	print '<td>'.$langs->trans("RecapGeneration").'</td>'."\n";
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
361 361
 	print '</tr>';
362 362
 	
363
-	$var=!$var;
363
+	$var = !$var;
364 364
 	print '<tr '.$bc[$var].'>';
365 365
 	print '<td>'.$langs->trans('SUBTOTAL_KEEP_RECAP_FILE').'</td>';
366 366
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	print ajax_constantonoff('SUBTOTAL_KEEP_RECAP_FILE');
369 369
 	print '</td></tr>';
370 370
 	
371
-	$var=!$var;
371
+	$var = !$var;
372 372
 	print '<tr '.$bc[$var].'>';
373 373
 	print '<td>'.$langs->trans('SUBTOTAL_PROPAL_ADD_RECAP').'</td>';
374 374
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	print ajax_constantonoff('SUBTOTAL_PROPAL_ADD_RECAP');
377 377
 	print '</td></tr>';
378 378
 	
379
-	$var=!$var;
379
+	$var = !$var;
380 380
 	print '<tr '.$bc[$var].'>';
381 381
 	print '<td>'.$langs->trans('SUBTOTAL_COMMANDE_ADD_RECAP').'</td>';
382 382
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 	print '</td></tr>';
386 386
 	
387 387
 	
388
-	$var=!$var;
388
+	$var = !$var;
389 389
 	print '<tr '.$bc[$var].'>';
390 390
 	print '<td>'.$langs->trans('SUBTOTAL_INVOICE_ADD_RECAP').'</td>';
391 391
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 				<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
418 418
 					<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
419 419
 					<input type="hidden" name="action" value="set_SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY" />
420
-					<?php echo $html->selectyesno("SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY",$conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY,1); ?>
420
+					<?php echo $html->selectyesno("SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY", $conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY, 1); ?>
421 421
 					<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
422 422
 				</form>
423 423
 			</td>
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 				<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
430 430
 					<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
431 431
 					<input type="hidden" name="action" value="set_SUBTOTAL_HIDE_DOCUMENT_TOTAL" />
432
-					<?php echo $html->selectyesno("SUBTOTAL_HIDE_DOCUMENT_TOTAL",$conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL,1); ?>
432
+					<?php echo $html->selectyesno("SUBTOTAL_HIDE_DOCUMENT_TOTAL", $conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL, 1); ?>
433 433
 					<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
434 434
 				</form>
435 435
 			</td>				
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 					<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
443 443
 						<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
444 444
 						<input type="hidden" name="action" value="set_SUBTOTAL_SHOW_QTY_ON_TITLES" />
445
-						<?php echo $html->selectyesno("SUBTOTAL_SHOW_QTY_ON_TITLES",$conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES,1); ?>
445
+						<?php echo $html->selectyesno("SUBTOTAL_SHOW_QTY_ON_TITLES", $conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES, 1); ?>
446 446
 						<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
447 447
 					</form>
448 448
 				</td>				
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 					<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
455 455
 						<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
456 456
 						<input type="hidden" name="action" value="set_SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES" />
457
-						<?php echo $html->selectyesno("SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES",$conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES,1); ?>
457
+						<?php echo $html->selectyesno("SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES", $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES, 1); ?>
458 458
 						<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
459 459
 					</form>
460 460
 				</td>				
Please login to merge, or discard this patch.
Braces   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -64,16 +64,19 @@
 block discarded – undo
64 64
 		, 'SUBTOTAL_LIST_OF_EXTRAFIELDS_PROPALDET'
65 65
 		, 'SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET'
66 66
 		, 'SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET'
67
-	))) $value = implode(',', $value);
67
+	))) {
68
+		$value = implode(',', $value);
69
+	}
68 70
 
69 71
 	if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
70 72
 	{
71
-		if ($code == 'SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS' && $value == 1) _createExtraComprisNonCompris();
73
+		if ($code == 'SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS' && $value == 1) {
74
+			_createExtraComprisNonCompris();
75
+		}
72 76
 		
73 77
 		header("Location: ".$_SERVER["PHP_SELF"]);
74 78
 		exit;
75
-	}
76
-	else
79
+	} else
77 80
 	{
78 81
 		dol_print_error($db);
79 82
 	}
Please login to merge, or discard this patch.
class/actions_subtotal.class.php 3 patches
Indentation   +337 added lines, -337 removed lines patch added patch discarded remove patch
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	 * @return     void
102 102
 	 */
103 103
     
104
-    var $module_number = 104777;
104
+	var $module_number = 104777;
105 105
     
106
-    function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
107
-    {
108
-      	global $langs,$db,$user, $conf;
106
+	function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
107
+	{
108
+	  	global $langs,$db,$user, $conf;
109 109
 		
110 110
 		$langs->load('subtotal@subtotal');
111 111
 		
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
 				$createRight = $user->rights->facture->creer;
121 121
 			} elseif($object->element == 'order_supplier' )
122 122
 			{
123
-			    $createRight = $user->rights->fournisseur->commande->creer;
123
+				$createRight = $user->rights->fournisseur->commande->creer;
124 124
 			} elseif($object->element == 'invoice_supplier' )
125 125
 			{
126
-			    $createRight = $user->rights->fournisseur->facture->creer;
126
+				$createRight = $user->rights->fournisseur->facture->creer;
127 127
 			}
128 128
 			elseif($object->element == 'shipping')
129 129
 			{
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 					
178 178
 					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
179 179
 					
180
-	    			TSubtotal::addSubTotalLine($object, $title, $qty);
180
+					TSubtotal::addSubTotalLine($object, $title, $qty);
181 181
 				}
182 182
 				else if($action==='ask_deleteallline') {
183 183
 						$form=new Form($db);
@@ -399,36 +399,36 @@  discard block
 block discarded – undo
399 399
 		$TContext = explode(':',$parameters['context']);
400 400
 		if (
401 401
 				in_array('invoicecard',$TContext)
402
-		        || in_array('invoicesuppliercard',$TContext)
402
+				|| in_array('invoicesuppliercard',$TContext)
403 403
 				|| in_array('propalcard',$TContext)
404 404
 				|| in_array('ordercard',$TContext)
405
-		        || in_array('ordersuppliercard',$TContext)
405
+				|| in_array('ordersuppliercard',$TContext)
406 406
 				|| in_array('invoicereccard',$TContext)
407 407
 			)
408
-	        {	
409
-	            $hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
410
-	            $hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
408
+			{	
409
+				$hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
410
+				$hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
411 411
 				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
412 412
 				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
413 413
 				
414 414
 				$var=false;
415
-		     	$out.= '<tr '.$bc[$var].'>
415
+			 	$out.= '<tr '.$bc[$var].'>
416 416
 		     			<td colspan="4" align="right">
417 417
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
418 418
 		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
419 419
 		     			</td>
420 420
 		     			</tr>';
421 421
 				
422
-		     	$var=!$var;
423
-		     	$out.= '<tr '.$bc[$var].'>
422
+			 	$var=!$var;
423
+			 	$out.= '<tr '.$bc[$var].'>
424 424
 		     			<td colspan="4" align="right">
425 425
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
426 426
 		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
427 427
 		     			</td>
428 428
 		     			</tr>';
429 429
 		     	
430
-		     	$var=!$var;
431
-		     	$out.= '<tr '.$bc[$var].'>
430
+			 	$var=!$var;
431
+			 	$out.= '<tr '.$bc[$var].'>
432 432
 		     			<td colspan="4" align="right">
433 433
 		     				<label for="hideprices">'.$langs->trans('SubTotalhidePrice').'</label>
434 434
 		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
@@ -440,9 +440,9 @@  discard block
 block discarded – undo
440 440
 				if ( 
441 441
 					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
442 442
 					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
443
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
443
+					|| (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
444 444
 					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
445
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
445
+					|| (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
446 446
 					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
447 447
 				)
448 448
 				{
@@ -461,19 +461,19 @@  discard block
 block discarded – undo
461 461
 			}
462 462
 			
463 463
 		
464
-        return 1;
464
+		return 1;
465 465
 	} 
466 466
 	 
467
-    function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
468
-    {
467
+	function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
468
+	{
469 469
 		
470
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
471
-        {
470
+		if (in_array('invoicecard',explode(':',$parameters['context'])))
471
+		{
472 472
         	
473
-        }
473
+		}
474 474
 		
475
-        return 0;
476
-    }
475
+		return 0;
476
+	}
477 477
 	
478 478
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
479 479
 		global $conf;
@@ -484,14 +484,14 @@  discard block
 block discarded – undo
484 484
 			$object = &$parameters['object'];
485 485
 			$substitutionarray = &$parameters['substitutionarray'];
486 486
 			
487
-            $substitutionarray['line_not_modsubtotal'] = true;
488
-            $substitutionarray['line_modsubtotal'] = false;
489
-            $substitutionarray['line_modsubtotal_total'] = false;
490
-            $substitutionarray['line_modsubtotal_title'] = false;
487
+			$substitutionarray['line_not_modsubtotal'] = true;
488
+			$substitutionarray['line_modsubtotal'] = false;
489
+			$substitutionarray['line_modsubtotal_total'] = false;
490
+			$substitutionarray['line_modsubtotal_title'] = false;
491 491
 
492 492
 			if($line->product_type == 9 && $line->special_code == $this->module_number) {
493 493
 				$substitutionarray['line_modsubtotal'] = 1;	
494
-                $substitutionarray['line_not_modsubtotal'] = false;
494
+				$substitutionarray['line_not_modsubtotal'] = false;
495 495
 				
496 496
 				$substitutionarray['line_price_ht']
497 497
 					 = $substitutionarray['line_price_vat'] 
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 					$substitutionarray['line_modsubtotal_total'] = true;
506 506
 					
507 507
 					//list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
508
-                    $TInfo = $this->getTotalLineFromObject($object, $line, '', 1);
508
+					$TInfo = $this->getTotalLineFromObject($object, $line, '', 1);
509 509
 
510 510
 					$substitutionarray['line_price_ht'] = price($TInfo[0]);
511 511
 					$substitutionarray['line_price_vat'] = price($TInfo[1]);
@@ -529,11 +529,11 @@  discard block
 block discarded – undo
529 529
 	
530 530
 		if (
531 531
 				in_array('invoicecard',explode(':',$parameters['context']))
532
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
532
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
533 533
 				|| in_array('propalcard',explode(':',$parameters['context']))
534
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
534
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
535 535
 				|| in_array('ordercard',explode(':',$parameters['context']))
536
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
536
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
537 537
 				|| in_array('invoicereccard',explode(':',$parameters['context']))
538 538
 		) {
539 539
 			
@@ -612,20 +612,20 @@  discard block
 block discarded – undo
612 612
 				in_array('invoicecard',explode(':',$parameters['context']))
613 613
 				|| in_array('propalcard',explode(':',$parameters['context']))
614 614
 				|| in_array('ordercard',explode(':',$parameters['context']))
615
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
616
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
617
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
615
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
616
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
617
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
618 618
 			)
619
-	        {								
619
+			{								
620 620
 				if(in_array('invoicecard',explode(':',$parameters['context']))) {
621 621
 					$sessname = 'subtotal_hideInnerLines_facture';	
622 622
 					$sessname2 = 'subtotal_hidedetails_facture';
623 623
 					$sessname3 = 'subtotal_hideprices_facture';
624 624
 				}
625 625
 				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
626
-				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
627
-				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
628
-				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
626
+					$sessname = 'subtotal_hideInnerLines_facture_fournisseur';
627
+					$sessname2 = 'subtotal_hidedetails_facture_fournisseur';
628
+					$sessname3 = 'subtotal_hideprices_facture_fournisseur';
629 629
 				}
630 630
 				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
631 631
 					$sessname = 'subtotal_hideInnerLines_propal';
@@ -633,9 +633,9 @@  discard block
 block discarded – undo
633 633
 					$sessname3 = 'subtotal_hideprices_propal';
634 634
 				}
635 635
 				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
636
-				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
637
-				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
638
-				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
636
+					$sessname = 'subtotal_hideInnerLines_supplier_proposal';
637
+					$sessname2 = 'subtotal_hidedetails_supplier_proposal';
638
+					$sessname3 = 'subtotal_hideprices_supplier_proposal';
639 639
 				}
640 640
 				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
641 641
 					$sessname = 'subtotal_hideInnerLines_commande';
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
 					$sessname3 = 'subtotal_hideprices_commande';
644 644
 				}
645 645
 				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
646
-				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
647
-				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
648
-				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
646
+					$sessname = 'subtotal_hideInnerLines_commande_fournisseur';
647
+					$sessname2 = 'subtotal_hidedetails_commande_fournisseur';
648
+					$sessname3 = 'subtotal_hideprices_commande_fournisseur';
649 649
 				}
650 650
 				else {
651 651
 					$sessname = 'subtotal_hideInnerLines_unknown';
@@ -670,17 +670,17 @@  discard block
 block discarded – undo
670 670
 				foreach($object->lines as &$line) {
671 671
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
672 672
 					    
673
-                        if($line->qty>=90) {
674
-                            $line->modsubtotal_total = 1;
675
-                        }
676
-                        else{
677
-                            $line->modsubtotal_title = 1;
678
-                        }
673
+						if($line->qty>=90) {
674
+							$line->modsubtotal_total = 1;
675
+						}
676
+						else{
677
+							$line->modsubtotal_title = 1;
678
+						}
679 679
                         
680 680
 						$line->total_ht = $this->getTotalLineFromObject($object, $line, '');
681 681
 					}
682
-	        	}
683
-	        }
682
+				}
683
+			}
684 684
 			
685 685
 		}
686 686
 		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 				 */
698 698
 				else if($object->element=='invoice_supplier')
699 699
 				{
700
-				    $object->deleteline($idLine);
700
+					$object->deleteline($idLine);
701 701
 				}
702 702
 				/**
703 703
 				 * @var $object Propal
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 				 */
721 721
 				else if($object->element=='order_supplier')
722 722
 				{
723
-				    $object->deleteline($idLine);
723
+					$object->deleteline($idLine);
724 724
 				}
725 725
 				/**
726 726
 				 * @var $object Facturerec
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 		
796 796
 		foreach($object->lines as $l) {
797 797
 		
798
-		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
798
+			$lid = (!empty($l->rowid) ? $l->rowid : $l->id);
799 799
 			if($lid == $lineid) {
800 800
 
801 801
 				$found = true;
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 			
805 805
 			if($found) {
806 806
 				
807
-			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
807
+				$Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
808 808
 				
809 809
 				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
810 810
 					break; // end of story
@@ -845,39 +845,39 @@  discard block
 block discarded – undo
845 845
 		foreach($TLineReverse as $l)
846 846
 		{
847 847
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
848
-            if ($l->rang>=$rang) continue;
849
-            if (!empty($title_break) && $title_break->id == $l->id) break;
850
-            elseif (!TSubtotal::isModSubtotalLine($l))
851
-            {
852
-                // TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
853
-                if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
854
-                {
855
-                    if ($l->situation_percent > 0)
856
-                    {
857
-                        $prev_progress = 0;
858
-                        $progress = 1;
859
-                        if (method_exists($l, 'get_prev_progress'))
860
-                        {
861
-                            $prev_progress = $l->get_prev_progress($object->id);
862
-                            $progress = ($l->situation_percent - $prev_progress) / 100;
863
-                        }
864
-
865
-                        $result = $sign * ($l->total_ht / ($l->situation_percent / 100)) * $progress;
866
-                        $total+= $result;
867
-                        // TODO check si les 3 lignes du dessous sont corrects
868
-                        $total_tva += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
869
-                        $TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
870
-                        $total_ttc += $sign * ($l->total_tva / ($l->total_ttc / 100)) * $progress;
871
-                    }
872
-                }
873
-                else
874
-                {
875
-                    $total += $l->total_ht;
876
-                    $total_tva += $l->total_tva;
877
-                    $TTotal_tva[$l->tva_tx] += $l->total_tva;
878
-                    $total_ttc += $l->total_ttc;
879
-                }
880
-            }
848
+			if ($l->rang>=$rang) continue;
849
+			if (!empty($title_break) && $title_break->id == $l->id) break;
850
+			elseif (!TSubtotal::isModSubtotalLine($l))
851
+			{
852
+				// TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
853
+				if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
854
+				{
855
+					if ($l->situation_percent > 0)
856
+					{
857
+						$prev_progress = 0;
858
+						$progress = 1;
859
+						if (method_exists($l, 'get_prev_progress'))
860
+						{
861
+							$prev_progress = $l->get_prev_progress($object->id);
862
+							$progress = ($l->situation_percent - $prev_progress) / 100;
863
+						}
864
+
865
+						$result = $sign * ($l->total_ht / ($l->situation_percent / 100)) * $progress;
866
+						$total+= $result;
867
+						// TODO check si les 3 lignes du dessous sont corrects
868
+						$total_tva += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
869
+						$TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
870
+						$total_ttc += $sign * ($l->total_tva / ($l->total_ttc / 100)) * $progress;
871
+					}
872
+				}
873
+				else
874
+				{
875
+					$total += $l->total_ht;
876
+					$total_tva += $l->total_tva;
877
+					$TTotal_tva[$l->tva_tx] += $l->total_tva;
878
+					$total_ttc += $l->total_ttc;
879
+				}
880
+			}
881 881
 		}
882 882
 		if (!$return_all) return $total;
883 883
 		else return array($total, $total_tva, $total_ttc, $TTotal_tva);
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 		if(method_exists('Closure','bind')) {
916 916
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
917 917
 			$sweetsThief = function ($pdf) {
918
-		    		return $pdf->bMargin ;
918
+					return $pdf->bMargin ;
919 919
 			};
920 920
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
921 921
 	
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 					$TTotal_tva = $TInfo[3];
987 987
 					$total_to_print = price($TInfo[0]);
988 988
 
989
-                    $line->total_ht = $TInfo[0];
989
+					$line->total_ht = $TInfo[0];
990 990
 					$line->total = $TInfo[0];
991 991
 					if (!TSubtotal::isModSubtotalLine($line)) $line->total_tva = $TInfo[1];
992 992
 					$line->total_ttc = $TInfo[2];
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 	}
1144 1144
 	
1145 1145
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1146
-	    global $conf, $hideprices, $hookmanager;
1146
+		global $conf, $hideprices, $hookmanager;
1147 1147
 		
1148 1148
 		if(is_array($parameters)) $i = & $parameters['i'];
1149 1149
 		else $i = (int)$parameters;
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
 			}
1183 1183
 		}
1184 1184
 		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1185
-		    $this->resprints = price($object->lines[$i]->total_ht);
1185
+			$this->resprints = price($object->lines[$i]->total_ht);
1186 1186
 		}
1187 1187
 		
1188 1188
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
 	}
1312 1312
 	
1313 1313
 	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1314
-	    global $conf,$hideprices,$hookmanager;
1314
+		global $conf,$hideprices,$hookmanager;
1315 1315
 
1316 1316
 		if(is_array($parameters)) $i = & $parameters['i'];
1317 1317
 		else $i = (int)$parameters;
@@ -1319,18 +1319,18 @@  discard block
 block discarded – undo
1319 1319
 		if($this->isModSubtotalLine($parameters,$object) ) {
1320 1320
 			$this->resprints = ' ';
1321 1321
 
1322
-            $line = $object->lines[$i];
1322
+			$line = $object->lines[$i];
1323 1323
 
1324
-            // On récupère les montants du bloc pour les afficher dans la ligne de sous-total
1325
-            if(TSubtotal::isSubtotal($line)) {
1326
-                $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1324
+			// On récupère les montants du bloc pour les afficher dans la ligne de sous-total
1325
+			if(TSubtotal::isSubtotal($line)) {
1326
+				$parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1327 1327
 
1328
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1329
-                if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1330
-                    $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1331
-                    $this->resprints = price($TTotal['total_unit_subprice']);
1332
-                }
1333
-            }
1328
+				if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1329
+				if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1330
+					$TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1331
+					$this->resprints = price($TTotal['total_unit_subprice']);
1332
+				}
1333
+			}
1334 1334
 		
1335 1335
 			if((float)DOL_VERSION<=3.6) {
1336 1336
 				return '';
@@ -1346,58 +1346,58 @@  discard block
 block discarded – undo
1346 1346
 		(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))
1347 1347
 		)
1348 1348
 		{
1349
-		    // alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1350
-		    if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1351
-		    {
1352
-		        $this->resprints = ' ';
1349
+			// alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1350
+			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1351
+			{
1352
+				$this->resprints = ' ';
1353 1353
 		        
1354
-		        // currentcontext à modifier celon l'appel
1355
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1356
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1354
+				// currentcontext à modifier celon l'appel
1355
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1356
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1357 1357
 		        
1358
-		    }
1358
+			}
1359 1359
 		}
1360 1360
 		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1361 1361
 		else if (!empty($hideprices))
1362 1362
 		{
1363 1363
 		    
1364
-		    // Check if a title exist for this line && if the title have subtotal
1365
-		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1366
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1367
-		    {
1364
+			// Check if a title exist for this line && if the title have subtotal
1365
+			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1366
+			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1367
+			{
1368 1368
 		        
1369
-		        $this->resprints = ' ';
1369
+				$this->resprints = ' ';
1370 1370
 		        
1371
-		        // currentcontext à modifier celon l'appel
1372
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1373
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1374
-		    }
1371
+				// currentcontext à modifier celon l'appel
1372
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1373
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1374
+			}
1375 1375
 		}
1376 1376
 		
1377 1377
 		return 0;
1378 1378
 	}
1379 1379
 	
1380 1380
 	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1381
-	    global $conf,$hideprices,$hookmanager;
1381
+		global $conf,$hideprices,$hookmanager;
1382 1382
 
1383
-        if(is_array($parameters)) $i = & $parameters['i'];
1384
-        else $i = (int) $parameters;
1383
+		if(is_array($parameters)) $i = & $parameters['i'];
1384
+		else $i = (int) $parameters;
1385 1385
 
1386 1386
 		if($this->isModSubtotalLine($parameters,$object) ) {
1387 1387
 			$this->resprints = ' ';
1388 1388
 
1389
-            $line = $object->lines[$i];
1389
+			$line = $object->lines[$i];
1390 1390
 
1391
-            // Affichage de la remise 
1392
-            if(TSubtotal::isSubtotal($line)) {
1393
-                $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1391
+			// Affichage de la remise 
1392
+			if(TSubtotal::isSubtotal($line)) {
1393
+				$parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1394 1394
 
1395
-                if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1396
-                if(! empty($parentTitle->array_options['options_show_reduc'])) {
1397
-                    $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1398
-                    $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
1399
-                }
1400
-            }
1395
+				if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1396
+				if(! empty($parentTitle->array_options['options_show_reduc'])) {
1397
+					$TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1398
+					$this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
1399
+				}
1400
+			}
1401 1401
 		
1402 1402
 			if((float)DOL_VERSION<=3.6) {
1403 1403
 				return '';
@@ -1407,15 +1407,15 @@  discard block
 block discarded – undo
1407 1407
 			}
1408 1408
 		}
1409 1409
 		elseif (!empty($hideprices)
1410
-		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1411
-		        )
1412
-		    {
1413
-		        if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1414
-		        {
1415
-		            $this->resprints = ' ';
1416
-		            return 1;
1417
-		        }
1418
-		    }
1410
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1411
+				)
1412
+			{
1413
+				if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1414
+				{
1415
+					$this->resprints = ' ';
1416
+					return 1;
1417
+				}
1418
+			}
1419 1419
 		
1420 1420
 		return 0;
1421 1421
 	}
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
 	}
1452 1452
 	
1453 1453
 	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1454
-	    global $conf,$hideprices,$hookmanager;
1454
+		global $conf,$hideprices,$hookmanager;
1455 1455
 	    
1456 1456
 		if($this->isModSubtotalLine($parameters,$object) ){
1457 1457
 			$this->resprints = ' ';
@@ -1476,31 +1476,31 @@  discard block
 block discarded – undo
1476 1476
 		(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))
1477 1477
 		)
1478 1478
 		{
1479
-		    // alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1480
-		    if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1481
-		    {
1482
-		        $this->resprints = ' ';
1479
+			// alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1480
+			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1481
+			{
1482
+				$this->resprints = ' ';
1483 1483
 		        
1484
-		        // currentcontext à modifier celon l'appel
1485
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1486
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1487
-		    }
1484
+				// currentcontext à modifier celon l'appel
1485
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1486
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1487
+			}
1488 1488
 		}
1489 1489
 		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1490 1490
 		else if (!empty($hideprices))
1491 1491
 		{
1492 1492
 		    
1493
-		    // Check if a title exist for this line && if the title have subtotal
1494
-		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1495
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1496
-		    {
1493
+			// Check if a title exist for this line && if the title have subtotal
1494
+			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1495
+			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1496
+			{
1497 1497
 		        
1498
-		        $this->resprints = ' ';
1498
+				$this->resprints = ' ';
1499 1499
 		        
1500
-		        // currentcontext à modifier celon l'appel
1501
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1502
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1503
-		    }
1500
+				// currentcontext à modifier celon l'appel
1501
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1502
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1503
+			}
1504 1504
 		}
1505 1505
 		
1506 1506
 		return 0;
@@ -1624,33 +1624,33 @@  discard block
 block discarded – undo
1624 1624
 		
1625 1625
 		$this->add_numerotation($object);	
1626 1626
 		
1627
-        foreach($object->lines as $k => &$l) {
1628
-            if(TSubtotal::isSubtotal($l)) {
1629
-                $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1630
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1631
-                if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_reduc'])) {
1632
-                    $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1633
-                }
1634
-            }
1627
+		foreach($object->lines as $k => &$l) {
1628
+			if(TSubtotal::isSubtotal($l)) {
1629
+				$parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1630
+				if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1631
+				if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_reduc'])) {
1632
+					$l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1633
+				}
1634
+			}
1635 1635
 
1636 1636
 
1637
-            // Pas de hook sur les colonnes du PDF expédition, on unset les bonnes variables
1638
-            if(($object->element == 'shipping' || $object->element == 'delivery') && $this->isModSubtotalLine($k, $object))
1637
+			// Pas de hook sur les colonnes du PDF expédition, on unset les bonnes variables
1638
+			if(($object->element == 'shipping' || $object->element == 'delivery') && $this->isModSubtotalLine($k, $object))
1639 1639
 			{
1640 1640
 				$l->qty = $l->qty_asked;
1641 1641
 				unset($l->qty_asked, $l->qty_shipped, $l->volume, $l->weight);
1642 1642
 			}
1643
-        }
1643
+		}
1644 1644
 
1645 1645
 		$hideInnerLines = (int)GETPOST('hideInnerLines');
1646 1646
 		$hidedetails = (int)GETPOST('hidedetails');
1647 1647
 
1648 1648
 		if ($hideInnerLines) { // si c une ligne de titre
1649
-	    	$fk_parent_line=0;
1649
+			$fk_parent_line=0;
1650 1650
 			$TLines =array();
1651 1651
 		
1652 1652
 			$original_count=count($object->lines);
1653
-		    $TTvas = array(); // tableau de tva
1653
+			$TTvas = array(); // tableau de tva
1654 1654
 		    
1655 1655
 			foreach($object->lines as $k=>&$line) 
1656 1656
 			{
@@ -1691,48 +1691,48 @@  discard block
 block discarded – undo
1691 1691
 			
1692 1692
 				if ($hideInnerLines)
1693 1693
 				{
1694
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1695
-				    {
1696
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1694
+					if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1695
+					{
1696
+						if($line->tva_tx != '0.000' && $line->product_type!=9){
1697 1697
 				            
1698
-    				        // on remplit le tableau de tva pour substituer les lignes cachées
1699
-    				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1700
-    				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1701
-    				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1702
-    				    }
1703
-    					if($line->product_type==9 && $line->rowid>0)
1704
-    					{
1705
-    					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1706
-    					    // génère des lignes d'affichage des montants HT soumis à tva
1707
-    					    $nbtva = count($TTvas);
1708
-    					    if(!empty($nbtva)){
1709
-    					        foreach ($TTvas as $tx =>$val){
1710
-    					            $l = clone $line;
1711
-    					            $l->product_type = 1;
1712
-    					            $l->special_code = '';
1713
-    					            $l->qty = 1;
1714
-    					            $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1715
-    					            $l->tva_tx = $tx;
1716
-    					            $l->total_ht = $val['total_ht'];
1717
-    					            $l->total_tva = $val['total_tva'];
1718
-    					            $l->total = $line->total_ht;
1719
-    					            $l->total_ttc = $val['total_ttc'];
1720
-    					            $TLines[] = $l;
1721
-    					            array_shift($TTvas);
1722
-    					       }
1723
-    					    }
1698
+							// on remplit le tableau de tva pour substituer les lignes cachées
1699
+							$TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1700
+							$TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1701
+							$TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1702
+						}
1703
+						if($line->product_type==9 && $line->rowid>0)
1704
+						{
1705
+							//Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1706
+							// génère des lignes d'affichage des montants HT soumis à tva
1707
+							$nbtva = count($TTvas);
1708
+							if(!empty($nbtva)){
1709
+								foreach ($TTvas as $tx =>$val){
1710
+									$l = clone $line;
1711
+									$l->product_type = 1;
1712
+									$l->special_code = '';
1713
+									$l->qty = 1;
1714
+									$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1715
+									$l->tva_tx = $tx;
1716
+									$l->total_ht = $val['total_ht'];
1717
+									$l->total_tva = $val['total_tva'];
1718
+									$l->total = $line->total_ht;
1719
+									$l->total_ttc = $val['total_ttc'];
1720
+									$TLines[] = $l;
1721
+									array_shift($TTvas);
1722
+							   }
1723
+							}
1724 1724
     					    
1725
-    					    // ajoute la ligne de sous-total
1726
-    					    $TLines[] = $line; 
1727
-    					}
1728
-				    } else {
1725
+							// ajoute la ligne de sous-total
1726
+							$TLines[] = $line; 
1727
+						}
1728
+					} else {
1729 1729
 				        
1730
-				        if($line->product_type==9 && $line->rowid>0)
1731
-				        {
1732
-				            // ajoute la ligne de sous-total
1733
-				            $TLines[] = $line; 
1734
-				        }
1735
-				    }
1730
+						if($line->product_type==9 && $line->rowid>0)
1731
+						{
1732
+							// ajoute la ligne de sous-total
1733
+							$TLines[] = $line; 
1734
+						}
1735
+					}
1736 1736
 				    
1737 1737
 					
1738 1738
 				}
@@ -1757,20 +1757,20 @@  discard block
 block discarded – undo
1757 1757
 			$nbtva = count($TTvas);
1758 1758
 			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1759 1759
 			{
1760
-			    foreach ($TTvas as $tx =>$val){
1761
-			        $l = clone $line;
1762
-			        $l->product_type = 1;
1763
-			        $l->special_code = '';
1764
-			        $l->qty = 1;
1765
-			        $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1766
-			        $l->tva_tx = $tx;
1767
-			        $l->total_ht = $val['total_ht'];
1768
-			        $l->total_tva = $val['total_tva'];
1769
-			        $l->total = $line->total_ht;
1770
-			        $l->total_ttc = $val['total_ttc'];
1771
-			        $TLines[] = $l;
1772
-			        array_shift($TTvas);
1773
-			    }
1760
+				foreach ($TTvas as $tx =>$val){
1761
+					$l = clone $line;
1762
+					$l->product_type = 1;
1763
+					$l->special_code = '';
1764
+					$l->qty = 1;
1765
+					$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1766
+					$l->tva_tx = $tx;
1767
+					$l->total_ht = $val['total_ht'];
1768
+					$l->total_tva = $val['total_tva'];
1769
+					$l->total = $line->total_ht;
1770
+					$l->total_ttc = $val['total_ttc'];
1771
+					$TLines[] = $l;
1772
+					array_shift($TTvas);
1773
+				}
1774 1774
 			}
1775 1775
 			
1776 1776
 			global $nblignes;
@@ -1782,7 +1782,7 @@  discard block
 block discarded – undo
1782 1782
 				$this->resprints = '';
1783 1783
 				return 0;
1784 1784
 			}
1785
-	    }
1785
+		}
1786 1786
 		
1787 1787
 		return 0;
1788 1788
 	}
@@ -1974,11 +1974,11 @@  discard block
 block discarded – undo
1974 1974
 		}
1975 1975
 		elseif($object->element == 'order_supplier' )
1976 1976
 		{
1977
-		    $createRight = $user->rights->fournisseur->commande->creer;
1977
+			$createRight = $user->rights->fournisseur->commande->creer;
1978 1978
 		}
1979 1979
 		elseif($object->element == 'invoice_supplier' )
1980 1980
 		{
1981
-		    $createRight = $user->rights->fournisseur->facture->creer;
1981
+			$createRight = $user->rights->fournisseur->facture->creer;
1982 1982
 		}
1983 1983
 		elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
1984 1984
 		{
@@ -2007,27 +2007,27 @@  discard block
 block discarded – undo
2007 2007
 			$line = $originline;
2008 2008
 		}
2009 2009
  		if($object->element=='facture')$idvar = 'facid';
2010
-        else $idvar='id';
2010
+		else $idvar='id';
2011 2011
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
2012 2012
 			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE) && $object->element !== 'invoice_supplier')
2013
-            {
2014
-                if(!(TSubtotal::isModSubtotalLine($line)) && ( $line->fk_prev_id === null ) && !($action == "editline" && GETPOST('lineid') == $line->id)) {
2015
-                    echo '<a name="duplicate-'.$line->id.'" href="' . $_SERVER['PHP_SELF'] . '?' . $idvar . '=' . $object->id . '&action=duplicate&lineid=' . $line->id . '"><i class="fa fa-clone" aria-hidden="true"></i></a>';
2013
+			{
2014
+				if(!(TSubtotal::isModSubtotalLine($line)) && ( $line->fk_prev_id === null ) && !($action == "editline" && GETPOST('lineid') == $line->id)) {
2015
+					echo '<a name="duplicate-'.$line->id.'" href="' . $_SERVER['PHP_SELF'] . '?' . $idvar . '=' . $object->id . '&action=duplicate&lineid=' . $line->id . '"><i class="fa fa-clone" aria-hidden="true"></i></a>';
2016 2016
 
2017
-                    ?>
2017
+					?>
2018 2018
                         <script type="text/javascript">
2019 2019
                             $(document).ready(function() {
2020 2020
                                 $("a[name='duplicate-<?php echo $line->id; ?>']").prependTo($('#row-<?php echo $line->id; ?>').find('.linecoledit'));
2021 2021
                             });
2022 2022
                         </script>
2023 2023
                     <?php
2024
-                }
2024
+				}
2025 2025
 
2026
-            }
2026
+			}
2027 2027
 			return 0;
2028 2028
 		}
2029 2029
 		else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) 
2030
-        {
2030
+		{
2031 2031
 
2032 2032
 
2033 2033
 			if((float)DOL_VERSION <= 3.4)
@@ -2075,7 +2075,7 @@  discard block
 block discarded – undo
2075 2075
 			//var_dump($line);
2076 2076
             
2077 2077
 			// HTML 5 data for js
2078
-            $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2078
+			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2079 2079
             
2080 2080
 			
2081 2081
 			?>
@@ -2137,8 +2137,8 @@  discard block
 block discarded – undo
2137 2137
 						}
2138 2138
 						
2139 2139
 						if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
2140
-						    $line->label = !empty($line->description) ? $line->description : $line->desc;
2141
-						    $line->description = '';
2140
+							$line->label = !empty($line->description) ? $line->description : $line->desc;
2141
+							$line->description = '';
2142 2142
 						}
2143 2143
 						$newlabel = $line->label;
2144 2144
 						if($line->label=='' && !$isFreeText) {
@@ -2172,38 +2172,38 @@  discard block
 block discarded – undo
2172 2172
 						
2173 2173
 
2174 2174
 						echo '<div class="subtotal_underline" style="margin-left:24px; line-height: 25px;">';
2175
-                        echo '<div>';
2176
-                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2177
-                        echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2178
-                        echo '</div>';
2179
-
2180
-                        if (TSubtotal::isTitle($line))
2181
-                        {
2182
-                            $form = new Form($db);
2183
-                            echo '<div>';
2184
-                            echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2185
-                            echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2186
-                            if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2187
-                            echo '</select>';
2188
-                            echo '</div>';
2189
-
2190
-                            if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
2191
-                            {
2192
-                                echo '<div>';
2193
-                                echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%';
2194
-                                echo '</div>';
2195
-                            }
2196
-                            echo '<div>';
2197
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2198
-                            echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2199
-                            echo '</div>';
2200
-
2201
-                            echo '<div>';
2202
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2203
-                            echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2204
-                            echo '</div>';
2205
-                        }
2206
-                        else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2175
+						echo '<div>';
2176
+						echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2177
+						echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2178
+						echo '</div>';
2179
+
2180
+						if (TSubtotal::isTitle($line))
2181
+						{
2182
+							$form = new Form($db);
2183
+							echo '<div>';
2184
+							echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2185
+							echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2186
+							if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2187
+							echo '</select>';
2188
+							echo '</div>';
2189
+
2190
+							if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
2191
+							{
2192
+								echo '<div>';
2193
+								echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%';
2194
+								echo '</div>';
2195
+							}
2196
+							echo '<div>';
2197
+							echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2198
+							echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2199
+							echo '</div>';
2200
+
2201
+							echo '<div>';
2202
+							echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2203
+							echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2204
+							echo '</div>';
2205
+						}
2206
+						else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2207 2207
 						echo '</div>';
2208 2208
 
2209 2209
 						if (TSubtotal::isTitle($line))
@@ -2743,17 +2743,17 @@  discard block
 block discarded – undo
2743 2743
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2744 2744
 		{
2745 2745
 		    
2746
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2747
-		    {
2748
-		        foreach ($object->lines as $line)
2749
-		        {
2750
-		            // fetch optionals attributes and labels
2751
-		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2752
-		            $extrafields=new ExtraFields($this->db);
2753
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2754
-		            $line->fetch_optionals($line->id,$extralabels);
2755
-		        }
2756
-		    }
2746
+			if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2747
+			{
2748
+				foreach ($object->lines as $line)
2749
+				{
2750
+					// fetch optionals attributes and labels
2751
+					require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2752
+					$extrafields=new ExtraFields($this->db);
2753
+					$extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2754
+					$line->fetch_optionals($line->id,$extralabels);
2755
+				}
2756
+			}
2757 2757
 		    
2758 2758
 			$TSubNc = array();
2759 2759
 			foreach ($object->lines as &$l)
@@ -2844,80 +2844,80 @@  discard block
 block discarded – undo
2844 2844
 	{
2845 2845
 		dol_include_once('/subtotal/class/subtotal.class.php');
2846 2846
 
2847
-	    $line = &$parameters['line'];
2847
+		$line = &$parameters['line'];
2848 2848
 	    
2849
-	    $ThtmlData['data-id']           = $line->id;
2850
-	    $ThtmlData['data-product_type'] = $line->product_type;
2851
-	    $ThtmlData['data-qty']          = 0; //$line->qty;
2852
-	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2849
+		$ThtmlData['data-id']           = $line->id;
2850
+		$ThtmlData['data-product_type'] = $line->product_type;
2851
+		$ThtmlData['data-qty']          = 0; //$line->qty;
2852
+		$ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2853 2853
 	    
2854
-	    if(TSubtotal::isTitle($line)){
2855
-	        $ThtmlData['data-issubtotal'] = 'title';
2856
-	    }elseif(TSubtotal::isSubtotal($line)){
2857
-	        $ThtmlData['data-issubtotal'] = 'subtotal';
2858
-	    }
2859
-	    else{
2860
-	        $ThtmlData['data-issubtotal'] = 'freetext';
2861
-	    }
2854
+		if(TSubtotal::isTitle($line)){
2855
+			$ThtmlData['data-issubtotal'] = 'title';
2856
+		}elseif(TSubtotal::isSubtotal($line)){
2857
+			$ThtmlData['data-issubtotal'] = 'subtotal';
2858
+		}
2859
+		else{
2860
+			$ThtmlData['data-issubtotal'] = 'freetext';
2861
+		}
2862 2862
 	    
2863 2863
 	    
2864
-	    // Change or add data  from hooks
2865
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2864
+		// Change or add data  from hooks
2865
+		$parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2866 2866
 	    
2867
-	    // hook 
2868
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2869
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2870
-	    if ($reshook>0)
2871
-	    {
2872
-	        $ThtmlData = $hookmanager->resArray;
2873
-	    }
2874
-
2875
-	    return $this->implodeHtmlData($ThtmlData);
2867
+		// hook 
2868
+		$reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2869
+		if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2870
+		if ($reshook>0)
2871
+		{
2872
+			$ThtmlData = $hookmanager->resArray;
2873
+		}
2874
+
2875
+		return $this->implodeHtmlData($ThtmlData);
2876 2876
 	
2877 2877
 	}
2878 2878
 	
2879 2879
 	
2880 2880
 	function implodeHtmlData($ThtmlData = array())
2881 2881
 	{
2882
-	    $data = '';
2883
-	    foreach($ThtmlData as $k => $h )
2884
-	    {
2885
-	        if(is_array($h))
2886
-	        {
2887
-	            $h = json_encode($h);
2888
-	        }
2882
+		$data = '';
2883
+		foreach($ThtmlData as $k => $h )
2884
+		{
2885
+			if(is_array($h))
2886
+			{
2887
+				$h = json_encode($h);
2888
+			}
2889 2889
 	        
2890
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2891
-	    }
2890
+			$data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2891
+		}
2892 2892
 	    
2893
-	    return $data;
2893
+		return $data;
2894 2894
 	}
2895 2895
 	
2896 2896
 	function _ajax_block_order_js($object)
2897 2897
 	{
2898
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2898
+		global $conf,$tagidfortablednd,$filepath,$langs;
2899 2899
 	    
2900
-	    /*
2900
+		/*
2901 2901
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2902 2902
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2903 2903
 	     */
2904 2904
 	    
2905
-	    $id=$object->id;
2906
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2907
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2905
+		$id=$object->id;
2906
+		$nboflines=(isset($object->lines)?count($object->lines):0);
2907
+		$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2908 2908
 	    
2909
-	    $id=$object->id;
2910
-	    $fk_element=$object->fk_element;
2911
-	    $table_element_line=$object->table_element_line;
2912
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2913
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2914
-	    $filepath=(empty($filepath)?'':$filepath);
2909
+		$id=$object->id;
2910
+		$fk_element=$object->fk_element;
2911
+		$table_element_line=$object->table_element_line;
2912
+		$nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2913
+		$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2914
+		$filepath=(empty($filepath)?'':$filepath);
2915 2915
 	    
2916 2916
 	    
2917
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2918
-	    {
2917
+		if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2918
+		{
2919 2919
 	        
2920
-	        ?>
2920
+			?>
2921 2921
 		
2922 2922
 		
2923 2923
 			<script type="text/javascript">
Please login to merge, or discard this patch.
Spacing   +490 added lines, -490 removed lines patch added patch discarded remove patch
@@ -16,17 +16,17 @@  discard block
 block discarded – undo
16 16
 		
17 17
 		global $type_element, $where;
18 18
 		
19
-		$contexts = explode(':',$parameters['context']);
19
+		$contexts = explode(':', $parameters['context']);
20 20
 		
21
-		if(in_array('consumptionthirdparty',$contexts) && in_array($type_element, array('propal', 'order', 'invoice', 'supplier_order', 'supplier_invoice', 'supplier_proposal'))) {
21
+		if (in_array('consumptionthirdparty', $contexts) && in_array($type_element, array('propal', 'order', 'invoice', 'supplier_order', 'supplier_invoice', 'supplier_proposal'))) {
22 22
 			$mod_num = TSubtotal::$module_number;
23 23
 			
24 24
 			// Not a title (can't use TSubtotal class methods in sql)
25
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty > 9)';
25
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty > 9)';
26 26
 			// Not a subtotal (can't use TSubtotal class methods in sql)
27
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty < 90)';
27
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty < 90)';
28 28
 			// Not a free line text (can't use TSubtotal class methods in sql)
29
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty != 50)';
29
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty != 50)';
30 30
 			
31 31
 		}
32 32
 		
@@ -105,47 +105,47 @@  discard block
 block discarded – undo
105 105
     
106 106
     function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
107 107
     {
108
-      	global $langs,$db,$user, $conf;
108
+      	global $langs, $db, $user, $conf;
109 109
 		
110 110
 		$langs->load('subtotal@subtotal');
111 111
 		
112
-		$contexts = explode(':',$parameters['context']);
112
+		$contexts = explode(':', $parameters['context']);
113 113
 		
114
-		if(in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('invoicereccard',$contexts) || in_array('expeditioncard',$contexts)) {
114
+		if (in_array('ordercard', $contexts) || in_array('ordersuppliercard', $contexts) || in_array('propalcard', $contexts) || in_array('supplier_proposalcard', $contexts) || in_array('invoicecard', $contexts) || in_array('invoicesuppliercard', $contexts) || in_array('invoicereccard', $contexts) || in_array('expeditioncard', $contexts)) {
115 115
 			
116 116
 			$createRight = $user->rights->{$object->element}->creer;
117
-			if($object->element == 'facturerec' )
117
+			if ($object->element == 'facturerec')
118 118
 			{
119 119
 				$object->statut = 0; // hack for facture rec
120 120
 				$createRight = $user->rights->facture->creer;
121
-			} elseif($object->element == 'order_supplier' )
121
+			} elseif ($object->element == 'order_supplier')
122 122
 			{
123 123
 			    $createRight = $user->rights->fournisseur->commande->creer;
124
-			} elseif($object->element == 'invoice_supplier' )
124
+			} elseif ($object->element == 'invoice_supplier')
125 125
 			{
126 126
 			    $createRight = $user->rights->fournisseur->facture->creer;
127 127
 			}
128
-			elseif($object->element == 'shipping')
128
+			elseif ($object->element == 'shipping')
129 129
 			{
130 130
 				$createRight = true; // No rights management for shipments
131 131
 			}
132 132
 			
133
-			if ($object->statut == 0  && $createRight) {
133
+			if ($object->statut == 0 && $createRight) {
134 134
 			
135 135
 
136
-				if($object->element=='facture')$idvar = 'facid';
137
-				else $idvar='id';
136
+				if ($object->element == 'facture')$idvar = 'facid';
137
+				else $idvar = 'id';
138 138
 				
139
-				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
139
+				if (in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')))
140 140
 				{
141 141
 					$level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT
142 142
 					
143
-					if($action=='add_title_line') {
143
+					if ($action == 'add_title_line') {
144 144
 						$title = GETPOST('title');
145
-						if(empty($title)) $title = $langs->trans('title');
146
-						$qty = $level<1 ? 1 : $level ;
145
+						if (empty($title)) $title = $langs->trans('title');
146
+						$qty = $level < 1 ? 1 : $level;
147 147
 					}
148
-					else if($action=='add_free_text') {
148
+					else if ($action == 'add_free_text') {
149 149
 						$title = GETPOST('title');
150 150
 
151 151
 						if (empty($title)) {
@@ -157,21 +157,21 @@  discard block
 block discarded – undo
157 157
 								}
158 158
 							}
159 159
 						}
160
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
160
+						if (empty($title)) $title = $langs->trans('subtotalAddLineDescription');
161 161
 						$qty = 50;
162 162
 					}
163
-					else if($action=='add_subtitle_line') {
163
+					else if ($action == 'add_subtitle_line') {
164 164
 						$title = GETPOST('title');
165
-						if(empty($title)) $title = $langs->trans('subtitle');
165
+						if (empty($title)) $title = $langs->trans('subtitle');
166 166
 						$qty = 2;
167 167
 					}
168
-					else if($action=='add_subtotal_line') {
168
+					else if ($action == 'add_subtotal_line') {
169 169
 						$title = $langs->trans('SubSubTotal');
170 170
 						$qty = 98;
171 171
 					}
172 172
 					else {
173 173
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
174
-						$qty = $level ? 100-$level : 99;
174
+						$qty = $level ? 100 - $level : 99;
175 175
 					}
176 176
 					dol_include_once('/subtotal/class/subtotal.class.php');
177 177
 					
@@ -179,15 +179,15 @@  discard block
 block discarded – undo
179 179
 					
180 180
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
181 181
 				}
182
-				else if($action==='ask_deleteallline') {
183
-						$form=new Form($db);
182
+				else if ($action === 'ask_deleteallline') {
183
+						$form = new Form($db);
184 184
 
185
-						$lineid = GETPOST('lineid','integer');
185
+						$lineid = GETPOST('lineid', 'integer');
186 186
 						$TIdForGroup = $this->getArrayOfLineForAGroup($object, $lineid);
187 187
 					
188 188
 						$nbLines = count($TIdForGroup);
189 189
 					
190
-						$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines',$nbLines), 'confirm_delete_all_lines','',0,1);
190
+						$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines', $nbLines), 'confirm_delete_all_lines', '', 0, 1);
191 191
 						print $formconfirm;
192 192
 				}
193 193
 
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
 				}
198 198
 
199 199
 				
200
-				if($object->element != 'shipping' && $action!='editline') {
200
+				if ($object->element != 'shipping' && $action != 'editline') {
201 201
 					// New format is for 3.8
202 202
 					$this->printNewFormat($object, $conf, $langs, $idvar);
203 203
 				}
204 204
 			}
205 205
 		}
206
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts) || in_array('orderstoinvoicesupplier',$contexts))
206
+		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice', $contexts) || in_array('orderstoinvoicesupplier', $contexts))
207 207
 		{
208 208
 			?>
209 209
 			<script type="text/javascript">
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 				$(document).ready(function() {
229 229
 					$('div.fiche div.tabsAction').append('<br />');
230 230
 					
231
-					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_title_line" rel="add_title_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddTitle' )?></a></div>');
231
+					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_title_line" rel="add_title_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddTitle')?></a></div>');
232 232
 					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_total_line" rel="add_total_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddSubTotal')?></a></div>');
233 233
 					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_free_text" rel="add_free_text" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddFreeText')?></a></div>');
234 234
 
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
 						$('body').append(dialog_html);
280 280
 
281 281
 						<?php 
282
-						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME)?'ckeditor':$conf->global->FCKEDITOR_EDITORNAME;
283
-						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
284
-						if($editorConf && in_array($editorTool,array('textarea','ckeditor'))){ 
282
+						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME) ? 'ckeditor' : $conf->global->FCKEDITOR_EDITORNAME;
283
+						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
284
+						if ($editorConf && in_array($editorTool, array('textarea', 'ckeditor'))) { 
285 285
 						?>
286 286
 						if (action == 'addTitle' || action == 'addFreeTxt')
287 287
 						{
@@ -396,62 +396,62 @@  discard block
 block discarded – undo
396 396
 		global $conf, $langs, $bc;
397 397
 			
398 398
 		$action = GETPOST('action');	
399
-		$TContext = explode(':',$parameters['context']);
399
+		$TContext = explode(':', $parameters['context']);
400 400
 		if (
401
-				in_array('invoicecard',$TContext)
402
-		        || in_array('invoicesuppliercard',$TContext)
403
-				|| in_array('propalcard',$TContext)
404
-				|| in_array('ordercard',$TContext)
405
-		        || in_array('ordersuppliercard',$TContext)
406
-				|| in_array('invoicereccard',$TContext)
401
+				in_array('invoicecard', $TContext)
402
+		        || in_array('invoicesuppliercard', $TContext)
403
+				|| in_array('propalcard', $TContext)
404
+				|| in_array('ordercard', $TContext)
405
+		        || in_array('ordersuppliercard', $TContext)
406
+				|| in_array('invoicereccard', $TContext)
407 407
 			)
408 408
 	        {	
409
-	            $hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
410
-	            $hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
411
-				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
412
-				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
409
+	            $hideInnerLines = isset($_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
410
+	            $hidedetails = isset($_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
411
+				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED) ? $conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED : 0;
412
+				$hideprices = isset($_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
413 413
 				
414
-				$var=false;
415
-		     	$out.= '<tr '.$bc[$var].'>
414
+				$var = false;
415
+		     	$out .= '<tr '.$bc[$var].'>
416 416
 		     			<td colspan="4" align="right">
417 417
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
418
-		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
418
+		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(($hideInnerLines) ? 'checked="checked"' : '').' />
419 419
 		     			</td>
420 420
 		     			</tr>';
421 421
 				
422
-		     	$var=!$var;
423
-		     	$out.= '<tr '.$bc[$var].'>
422
+		     	$var = !$var;
423
+		     	$out .= '<tr '.$bc[$var].'>
424 424
 		     			<td colspan="4" align="right">
425 425
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
426
-		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
426
+		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(($hidedetails) ? 'checked="checked"' : '').' />
427 427
 		     			</td>
428 428
 		     			</tr>';
429 429
 		     	
430
-		     	$var=!$var;
431
-		     	$out.= '<tr '.$bc[$var].'>
430
+		     	$var = !$var;
431
+		     	$out .= '<tr '.$bc[$var].'>
432 432
 		     			<td colspan="4" align="right">
433 433
 		     				<label for="hideprices">'.$langs->trans('SubTotalhidePrice').'</label>
434
-		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
434
+		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(($hideprices) ? 'checked="checked"' : '').' />
435 435
 		     			</td>
436 436
 		     			</tr>';
437 437
 		     	
438 438
 		     	
439 439
 				 
440 440
 				if ( 
441
-					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
442
-					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
443
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
444
-					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
445
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
446
-					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
441
+					(in_array('propalcard', $TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
442
+					|| (in_array('ordercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
443
+				    || (in_array('ordersuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
444
+					|| (in_array('invoicecard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
445
+				    || (in_array('invoicesuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
446
+					|| (in_array('invoicereccard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
447 447
 				)
448 448
 				{
449
-					$var=!$var;
450
-					$out.= '
449
+					$var = !$var;
450
+					$out .= '
451 451
 						<tr '.$bc[$var].'>
452 452
 							<td colspan="4" align="right">
453 453
 								<label for="subtotal_add_recap">'.$langs->trans('subtotal_add_recap').'</label>
454
-								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.( GETPOST('subtotal_add_recap') ? 'checked="checked"' : '' ).' />
454
+								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.(GETPOST('subtotal_add_recap') ? 'checked="checked"' : '').' />
455 455
 							</td>
456 456
 						</tr>';
457 457
 				}
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
     function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
468 468
     {
469 469
 		
470
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
470
+    	if (in_array('invoicecard', explode(':', $parameters['context'])))
471 471
         {
472 472
         	
473 473
         }
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
479 479
 		global $conf;
480 480
 		
481
-		if($action === 'builddoc') {
481
+		if ($action === 'builddoc') {
482 482
 			
483 483
 			$line = &$parameters['line'];
484 484
 			$object = &$parameters['object'];
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
             $substitutionarray['line_modsubtotal_total'] = false;
490 490
             $substitutionarray['line_modsubtotal_title'] = false;
491 491
 
492
-			if($line->product_type == 9 && $line->special_code == $this->module_number) {
492
+			if ($line->product_type == 9 && $line->special_code == $this->module_number) {
493 493
 				$substitutionarray['line_modsubtotal'] = 1;	
494 494
                 $substitutionarray['line_not_modsubtotal'] = false;
495 495
 				
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 					 = $substitutionarray['line_up'] 
502 502
 					 = '';
503 503
 				
504
-				if($line->qty>90) {
504
+				if ($line->qty > 90) {
505 505
 					$substitutionarray['line_modsubtotal_total'] = true;
506 506
 					
507 507
 					//list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 				
517 517
 				
518 518
 			}	
519
-			else{
519
+			else {
520 520
 				$substitutionarray['line_not_modsubtotal'] = true;
521 521
 				$substitutionarray['line_modsubtotal'] = 0;
522 522
 			}
@@ -528,29 +528,29 @@  discard block
 block discarded – undo
528 528
 	function createFrom($parameters, &$object, $action, $hookmanager) {
529 529
 	
530 530
 		if (
531
-				in_array('invoicecard',explode(':',$parameters['context']))
532
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
533
-				|| in_array('propalcard',explode(':',$parameters['context']))
534
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
535
-				|| in_array('ordercard',explode(':',$parameters['context']))
536
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
537
-				|| in_array('invoicereccard',explode(':',$parameters['context']))
531
+				in_array('invoicecard', explode(':', $parameters['context']))
532
+		        || in_array('invoicesuppliercard', explode(':', $parameters['context']))
533
+				|| in_array('propalcard', explode(':', $parameters['context']))
534
+		        || in_array('supplier_proposalcard', explode(':', $parameters['context']))
535
+				|| in_array('ordercard', explode(':', $parameters['context']))
536
+		        || in_array('ordersuppliercard', explode(':', $parameters['context']))
537
+				|| in_array('invoicereccard', explode(':', $parameters['context']))
538 538
 		) {
539 539
 			
540 540
 			global $db;
541 541
 			
542 542
 			$objFrom = $parameters['objFrom'];
543 543
 			
544
-			foreach($objFrom->lines as $k=> &$lineOld) {
544
+			foreach ($objFrom->lines as $k=> &$lineOld) {
545 545
 				
546
-					if($lineOld->product_type == 9 && $lineOld->info_bits > 0 ) {
546
+					if ($lineOld->product_type == 9 && $lineOld->info_bits > 0) {
547 547
 							
548 548
 							$line = & $object->lines[$k];
549 549
 				
550 550
 							$idLine = (int) ($line->id ? $line->id : $line->rowid); 
551 551
 				
552 552
 							$db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element."
553
-							SET info_bits=".(int)$lineOld->info_bits."
553
+							SET info_bits=".(int) $lineOld->info_bits."
554 554
 							WHERE rowid = ".$idLine."
555 555
 							");
556 556
 						
@@ -566,15 +566,15 @@  discard block
 block discarded – undo
566 566
 	
567 567
 	function doActions($parameters, &$object, $action, $hookmanager)
568 568
 	{
569
-		global $db, $conf, $langs,$user;
569
+		global $db, $conf, $langs, $user;
570 570
 		
571 571
 		dol_include_once('/subtotal/class/subtotal.class.php');
572 572
 		dol_include_once('/subtotal/lib/subtotal.lib.php');
573
-		require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
573
+		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
574 574
 		
575 575
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
576 576
 		
577
-		if($object->element=='facture') $idvar = 'facid';
577
+		if ($object->element == 'facture') $idvar = 'facid';
578 578
 		else $idvar = 'id';
579 579
 			
580 580
 		if ($action == 'updateligne' || $action == 'updateline')
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 				if ($line->id == $lineid && TSubtotal::isModSubtotalLine($line))
588 588
 				{
589 589
 					$found = true;
590
-					if(TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
590
+					if (TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
591 591
 						$extrafieldsline = new ExtraFields($db);
592 592
 						$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
593 593
 						$extrafieldsline->setOptionalsFromPost($extralabelsline, $line);
@@ -606,43 +606,43 @@  discard block
 block discarded – undo
606 606
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
607 607
 			}
608 608
 		}
609
-		else if($action === 'builddoc') {
609
+		else if ($action === 'builddoc') {
610 610
 			
611 611
 			if (
612
-				in_array('invoicecard',explode(':',$parameters['context']))
613
-				|| in_array('propalcard',explode(':',$parameters['context']))
614
-				|| in_array('ordercard',explode(':',$parameters['context']))
615
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
616
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
617
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
612
+				in_array('invoicecard', explode(':', $parameters['context']))
613
+				|| in_array('propalcard', explode(':', $parameters['context']))
614
+				|| in_array('ordercard', explode(':', $parameters['context']))
615
+			    || in_array('ordersuppliercard', explode(':', $parameters['context']))
616
+			    || in_array('invoicesuppliercard', explode(':', $parameters['context']))
617
+			    || in_array('supplier_proposalcard', explode(':', $parameters['context']))
618 618
 			)
619 619
 	        {								
620
-				if(in_array('invoicecard',explode(':',$parameters['context']))) {
620
+				if (in_array('invoicecard', explode(':', $parameters['context']))) {
621 621
 					$sessname = 'subtotal_hideInnerLines_facture';	
622 622
 					$sessname2 = 'subtotal_hidedetails_facture';
623 623
 					$sessname3 = 'subtotal_hideprices_facture';
624 624
 				}
625
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
625
+				elseif (in_array('invoicesuppliercard', explode(':', $parameters['context']))) {
626 626
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
627 627
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
628 628
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
629 629
 				}
630
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
630
+				elseif (in_array('propalcard', explode(':', $parameters['context']))) {
631 631
 					$sessname = 'subtotal_hideInnerLines_propal';
632 632
 					$sessname2 = 'subtotal_hidedetails_propal';	
633 633
 					$sessname3 = 'subtotal_hideprices_propal';
634 634
 				}
635
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
635
+				elseif (in_array('supplier_proposalcard', explode(':', $parameters['context']))) {
636 636
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
637 637
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
638 638
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
639 639
 				}
640
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
640
+				elseif (in_array('ordercard', explode(':', $parameters['context']))) {
641 641
 					$sessname = 'subtotal_hideInnerLines_commande';
642 642
 					$sessname2 = 'subtotal_hidedetails_commande';	
643 643
 					$sessname3 = 'subtotal_hideprices_commande';
644 644
 				}
645
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
645
+				elseif (in_array('ordersuppliercard', explode(':', $parameters['context']))) {
646 646
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
647 647
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
648 648
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
@@ -655,25 +655,25 @@  discard block
 block discarded – undo
655 655
 					
656 656
 				global $hideprices;
657 657
 				
658
-				$hideInnerLines = (int)GETPOST('hideInnerLines');
659
-				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system
658
+				$hideInnerLines = (int) GETPOST('hideInnerLines');
659
+				if (!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id])) $_SESSION[$sessname] = array(); // prevent old system
660 660
 				$_SESSION[$sessname][$object->id] = $hideInnerLines;		
661 661
 				
662
-				$hidedetails= (int)GETPOST('hidedetails');
663
-				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system
662
+				$hidedetails = (int) GETPOST('hidedetails');
663
+				if (!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id])) $_SESSION[$sessname2] = array(); // prevent old system
664 664
 				$_SESSION[$sessname2][$object->id] = $hidedetails;
665 665
 				
666
-				$hideprices= (int)GETPOST('hideprices');
667
-				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system
666
+				$hideprices = (int) GETPOST('hideprices');
667
+				if (!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id])) $_SESSION[$sessname3] = array(); // prevent old system
668 668
 				$_SESSION[$sessname3][$object->id] = $hideprices;
669 669
 				
670
-				foreach($object->lines as &$line) {
670
+				foreach ($object->lines as &$line) {
671 671
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
672 672
 					    
673
-                        if($line->qty>=90) {
673
+                        if ($line->qty >= 90) {
674 674
                             $line->modsubtotal_total = 1;
675 675
                         }
676
-                        else{
676
+                        else {
677 677
                             $line->modsubtotal_title = 1;
678 678
                         }
679 679
                         
@@ -683,34 +683,34 @@  discard block
 block discarded – undo
683 683
 	        }
684 684
 			
685 685
 		}
686
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
686
+		else if ($action === 'confirm_delete_all_lines' && GETPOST('confirm') == 'yes') {
687 687
 			
688 688
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
689 689
 			
690
-			foreach($Tab as $idLine) {
690
+			foreach ($Tab as $idLine) {
691 691
 				/**
692 692
 				 * @var $object Facture
693 693
 				 */
694
-				if($object->element=='facture') $object->deleteline($idLine);
694
+				if ($object->element == 'facture') $object->deleteline($idLine);
695 695
 				/**
696 696
 				 * @var $object Facture fournisseur
697 697
 				 */
698
-				else if($object->element=='invoice_supplier')
698
+				else if ($object->element == 'invoice_supplier')
699 699
 				{
700 700
 				    $object->deleteline($idLine);
701 701
 				}
702 702
 				/**
703 703
 				 * @var $object Propal
704 704
 				 */
705
-				else if($object->element=='propal') $object->deleteline($idLine);
705
+				else if ($object->element == 'propal') $object->deleteline($idLine);
706 706
 				/**
707 707
 				 * @var $object Propal Fournisseur
708 708
 				 */
709
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
709
+				else if ($object->element == 'supplier_proposal') $object->deleteline($idLine);
710 710
 				/**
711 711
 				 * @var $object Commande
712 712
 				 */
713
-				else if($object->element=='commande') 
713
+				else if ($object->element == 'commande') 
714 714
 				{
715 715
 					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
716 716
 					else $object->deleteline($idLine);
@@ -718,18 +718,18 @@  discard block
 block discarded – undo
718 718
 				/**
719 719
 				 * @var $object Commande fournisseur
720 720
 				 */
721
-				else if($object->element=='order_supplier')
721
+				else if ($object->element == 'order_supplier')
722 722
 				{
723 723
 				    $object->deleteline($idLine);
724 724
 				}
725 725
 				/**
726 726
 				 * @var $object Facturerec
727 727
 				 */
728
-				else if($object->element=='facturerec') $object->deleteline($idLine);
728
+				else if ($object->element == 'facturerec') $object->deleteline($idLine);
729 729
 				/**
730 730
 				 * @var $object Expedition
731 731
 				 */
732
-				else if($object->element=='shipping') $object->deleteline($user, $idLine);
732
+				else if ($object->element == 'shipping') $object->deleteline($user, $idLine);
733 733
 			}
734 734
 			
735 735
 			header('location:?id='.$object->id);
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 		return 0;
753 753
 	}
754 754
 	
755
-	function formAddObjectLine ($parameters, &$object, &$action, $hookmanager) {
755
+	function formAddObjectLine($parameters, &$object, &$action, $hookmanager) {
756 756
 		return 0;
757 757
 	}
758 758
 	
@@ -770,8 +770,8 @@  discard block
 block discarded – undo
770 770
 			if (!empty($parameters['fk_element']))
771 771
 			{
772 772
 				
773
-				if($obj->fetch($parameters['fk_element'])){
774
-					$obj->id= $obj->rowid;
773
+				if ($obj->fetch($parameters['fk_element'])) {
774
+					$obj->id = $obj->rowid;
775 775
 					if (empty($obj->array_options))
776 776
 						$obj->fetch_optionals();
777 777
 					if (!empty($obj->array_options['options_subtotal_nc']))
@@ -791,22 +791,22 @@  discard block
 block discarded – undo
791 791
 		
792 792
 		$found = false;
793 793
 
794
-		$Tab= array();
794
+		$Tab = array();
795 795
 		
796
-		foreach($object->lines as $l) {
796
+		foreach ($object->lines as $l) {
797 797
 		
798 798
 		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
799
-			if($lid == $lineid) {
799
+			if ($lid == $lineid) {
800 800
 
801 801
 				$found = true;
802 802
 				$qty_line = $l->qty;
803 803
 			}
804 804
 			
805
-			if($found) {
805
+			if ($found) {
806 806
 				
807 807
 			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
808 808
 				
809
-				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
809
+				if ($l->special_code == $this->module_number && (($l->qty == 99 && $qty_line == 1) || ($l->qty == 98 && $qty_line == 2))) {
810 810
 					break; // end of story
811 811
 				}
812 812
 			}
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 		
820 820
 	}
821 821
 
822
-	function getTotalLineFromObject(&$object, &$line, $use_level=false, $return_all=0) {
822
+	function getTotalLineFromObject(&$object, &$line, $use_level = false, $return_all = 0) {
823 823
 		global $conf;
824 824
 
825 825
 		$rang = $line->rang;
@@ -832,8 +832,8 @@  discard block
 block discarded – undo
832 832
 		$total_ttc = 0;
833 833
 		$TTotal_tva = array();
834 834
 		
835
-		$sign=1;
836
-		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
835
+		$sign = 1;
836
+		if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
837 837
 		
838 838
 		if (GETPOST('action') == 'builddoc') $builddoc = true;
839 839
 		else $builddoc = false;
@@ -842,15 +842,15 @@  discard block
 block discarded – undo
842 842
 
843 843
 		$TLineReverse = array_reverse($object->lines);
844 844
 
845
-		foreach($TLineReverse as $l)
845
+		foreach ($TLineReverse as $l)
846 846
 		{
847 847
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
848
-            if ($l->rang>=$rang) continue;
848
+            if ($l->rang >= $rang) continue;
849 849
             if (!empty($title_break) && $title_break->id == $l->id) break;
850 850
             elseif (!TSubtotal::isModSubtotalLine($l))
851 851
             {
852 852
                 // TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
853
-                if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
853
+                if ($builddoc && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
854 854
                 {
855 855
                     if ($l->situation_percent > 0)
856 856
                     {
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
                         }
864 864
 
865 865
                         $result = $sign * ($l->total_ht / ($l->situation_percent / 100)) * $progress;
866
-                        $total+= $result;
866
+                        $total += $result;
867 867
                         // TODO check si les 3 lignes du dessous sont corrects
868 868
                         $total_tva += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
869 869
                         $TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
@@ -894,10 +894,10 @@  discard block
 block discarded – undo
894 894
 	 * @param $w            float               width
895 895
 	 * @param $h            float               height
896 896
 	 */
897
-	function pdf_add_total(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
898
-		global $conf,$subtotal_last_title_posy;
897
+	function pdf_add_total(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
898
+		global $conf, $subtotal_last_title_posy;
899 899
 
900
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
900
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
901 901
 		if (!empty($conf->global->SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES) && $hideInnerLines && !empty($subtotal_last_title_posy))
902 902
 		{
903 903
 			$posy = $subtotal_last_title_posy;
@@ -906,40 +906,40 @@  discard block
 block discarded – undo
906 906
 		
907 907
 		$hidePriceOnSubtotalLines = (int) GETPOST('hide_price_on_subtotal_lines');
908 908
 
909
-		if($object->element == 'shipping' || $object->element == 'delivery')
909
+		if ($object->element == 'shipping' || $object->element == 'delivery')
910 910
 		{
911 911
 			$hidePriceOnSubtotalLines = 1;
912 912
 		}
913 913
 		
914 914
 		$set_pagebreak_margin = false;
915
-		if(method_exists('Closure','bind')) {
915
+		if (method_exists('Closure', 'bind')) {
916 916
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
917
-			$sweetsThief = function ($pdf) {
918
-		    		return $pdf->bMargin ;
917
+			$sweetsThief = function($pdf) {
918
+		    		return $pdf->bMargin;
919 919
 			};
920 920
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
921 921
 	
922
-			$bMargin  = $sweetsThief($pdf);
922
+			$bMargin = $sweetsThief($pdf);
923 923
 	
924
-			$pdf->SetAutoPageBreak( false );
924
+			$pdf->SetAutoPageBreak(false);
925 925
 
926 926
 			$set_pagebreak_margin = true;			
927 927
 		}
928 928
 		
929 929
 			
930
-		if($line->qty==99)
931
-			$pdf->SetFillColor(220,220,220);
932
-		elseif ($line->qty==98)
933
-			$pdf->SetFillColor(230,230,230);
930
+		if ($line->qty == 99)
931
+			$pdf->SetFillColor(220, 220, 220);
932
+		elseif ($line->qty == 98)
933
+			$pdf->SetFillColor(230, 230, 230);
934 934
 		else
935
-			$pdf->SetFillColor(240,240,240);
935
+			$pdf->SetFillColor(240, 240, 240);
936 936
 		
937 937
 		$style = 'B';
938 938
 		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
939 939
 		
940 940
 		$pdf->SetFont('', $style, 9);
941 941
 		
942
-		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R',true);
942
+		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R', true);
943 943
 //		var_dump($bMargin);
944 944
 		$pageAfter = $pdf->getPage();
945 945
 		
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
 			
968 968
 			
969 969
 			
970
-			if($total_to_print !== '') {
970
+			if ($total_to_print !== '') {
971 971
 				
972 972
 				if (GETPOST('hideInnerLines'))
973 973
 				{
@@ -994,11 +994,11 @@  discard block
 block discarded – undo
994 994
 			}
995 995
 
996 996
 			$pdf->SetXY($pdf->postotalht, $posy);
997
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
998
-			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
997
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
998
+			$pdf->MultiCell($pdf->page_largeur - $pdf->marge_droite - $pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
999 999
 		}
1000
-		else{
1001
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1000
+		else {
1001
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
1002 1002
 		}
1003 1003
 		
1004 1004
 		$posy = $posy + $cell_height;
@@ -1018,22 +1018,22 @@  discard block
 block discarded – undo
1018 1018
 	 * @param $w            float               width
1019 1019
 	 * @param $h            float               height
1020 1020
 	 */
1021
-	function pdf_add_title(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
1021
+	function pdf_add_title(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
1022 1022
 		
1023
-		global $db,$conf,$subtotal_last_title_posy;
1023
+		global $db, $conf, $subtotal_last_title_posy;
1024 1024
 		
1025 1025
 		$subtotal_last_title_posy = $posy;
1026
-		$pdf->SetXY ($posx, $posy);
1026
+		$pdf->SetXY($posx, $posy);
1027 1027
 		
1028
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1028
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1029 1029
 		
1030 1030
 		
1031 1031
  
1032
-		$style = ($line->qty==1) ? 'BU' : 'BUI';
1032
+		$style = ($line->qty == 1) ? 'BU' : 'BUI';
1033 1033
 		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
1034 1034
 		
1035
-		if($hideInnerLines) {
1036
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
1035
+		if ($hideInnerLines) {
1036
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9);
1037 1037
 			else 
1038 1038
 			{
1039 1039
 				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
@@ -1042,44 +1042,44 @@  discard block
 block discarded – undo
1042 1042
 		}
1043 1043
 		else {
1044 1044
 
1045
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
1045
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9); //TODO if super utile
1046 1046
 			else $pdf->SetFont('', $style, 9);
1047 1047
 			
1048 1048
 		}
1049 1049
 		
1050 1050
 		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) $pdf->MultiCell($w, $h, $label, 0, 'L'); // Pas de HTML dans la chaine
1051
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
1051
+		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J', true); // et maintenant avec du HTML
1052 1052
 		
1053
-		if($description && !$hidedesc) {
1053
+		if ($description && !$hidedesc) {
1054 1054
 			$posy = $pdf->GetY();
1055 1055
 			
1056 1056
 			$pdf->SetFont('', '', 8);
1057 1057
 			
1058
-			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J',true);
1058
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J', true);
1059 1059
 
1060 1060
 		}
1061 1061
 		
1062 1062
 	}
1063 1063
 
1064
-	function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='') {
1064
+	function pdf_writelinedesc_ref($parameters = array(), &$object, &$action = '') {
1065 1065
 	// ultimate PDF hook O_o
1066 1066
 		
1067
-		return $this->pdf_writelinedesc($parameters,$object,$action);
1067
+		return $this->pdf_writelinedesc($parameters, $object, $action);
1068 1068
 		
1069 1069
 	}
1070 1070
 
1071 1071
 	function isModSubtotalLine(&$parameters, &$object) {
1072 1072
 		
1073
-		if(is_array($parameters)) {
1073
+		if (is_array($parameters)) {
1074 1074
 			$i = & $parameters['i'];	
1075 1075
 		}
1076 1076
 		else {
1077
-			$i = (int)$parameters;
1077
+			$i = (int) $parameters;
1078 1078
 		}
1079 1079
 
1080 1080
 		$line = $object->lines[$i];
1081 1081
 
1082
-		if($object->element == 'shipping' || $object->element == 'delivery')
1082
+		if ($object->element == 'shipping' || $object->element == 'delivery')
1083 1083
 		{
1084 1084
 			dol_include_once('/commande/class/commande.class.php');
1085 1085
 			$line = new OrderLine($object->db);
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
 		}
1088 1088
 		
1089 1089
 
1090
-		if($line->special_code == $this->module_number && $line->product_type == 9) {
1090
+		if ($line->special_code == $this->module_number && $line->product_type == 9) {
1091 1091
 			return true;
1092 1092
 		}
1093 1093
 		
@@ -1095,42 +1095,42 @@  discard block
 block discarded – undo
1095 1095
 		
1096 1096
 	}
1097 1097
 
1098
-	function pdf_getlineqty($parameters=array(), &$object, &$action='') {
1099
-		global $conf,$hideprices;
1098
+	function pdf_getlineqty($parameters = array(), &$object, &$action = '') {
1099
+		global $conf, $hideprices;
1100 1100
 
1101
-		if($this->isModSubtotalLine($parameters,$object) ){
1101
+		if ($this->isModSubtotalLine($parameters, $object)) {
1102 1102
 			$this->resprints = ' ';
1103 1103
 			
1104
-			if((float)DOL_VERSION<=3.6) {
1104
+			if ((float) DOL_VERSION <= 3.6) {
1105 1105
 				return '';
1106 1106
 			}
1107
-			else if((float)DOL_VERSION>=3.8) {
1107
+			else if ((float) DOL_VERSION >= 3.8) {
1108 1108
 				return 1;
1109 1109
 			}
1110 1110
 			
1111 1111
 		}
1112
-		elseif(!empty($hideprices)) {
1112
+		elseif (!empty($hideprices)) {
1113 1113
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1114 1114
 			return 1;
1115 1115
 		}
1116 1116
 		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1117 1117
 		{
1118
-			$hideInnerLines = (int)GETPOST('hideInnerLines');
1119
-			$hidedetails = (int)GETPOST('hidedetails');
1118
+			$hideInnerLines = (int) GETPOST('hideInnerLines');
1119
+			$hidedetails = (int) GETPOST('hidedetails');
1120 1120
 			if (empty($hideInnerLines) && !empty($hidedetails))
1121 1121
 			{
1122 1122
 				$this->resprints = $object->lines[$parameters['i']]->qty;
1123 1123
 			}
1124 1124
 		}
1125 1125
 		
1126
-		if(is_array($parameters)) $i = & $parameters['i'];
1127
-		else $i = (int)$parameters;
1126
+		if (is_array($parameters)) $i = & $parameters['i'];
1127
+		else $i = (int) $parameters;
1128 1128
 
1129 1129
 		if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1130 1130
 		
1131
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1131
+		if (empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1132 1132
 
1133
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1133
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1134 1134
 		{
1135 1135
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1136 1136
 			{
@@ -1142,20 +1142,20 @@  discard block
 block discarded – undo
1142 1142
 		return 0;
1143 1143
 	}
1144 1144
 	
1145
-	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1145
+	function pdf_getlinetotalexcltax($parameters = array(), &$object, &$action = '') {
1146 1146
 	    global $conf, $hideprices, $hookmanager;
1147 1147
 		
1148
-		if(is_array($parameters)) $i = & $parameters['i'];
1149
-		else $i = (int)$parameters;
1148
+		if (is_array($parameters)) $i = & $parameters['i'];
1149
+		else $i = (int) $parameters;
1150 1150
 			
1151
-		if($this->isModSubtotalLine($parameters,$object) ){
1151
+		if ($this->isModSubtotalLine($parameters, $object)) {
1152 1152
 			
1153 1153
 			$this->resprints = ' ';
1154 1154
 			
1155
-			if((float)DOL_VERSION<=3.6) {
1155
+			if ((float) DOL_VERSION <= 3.6) {
1156 1156
 				return '';
1157 1157
 			}
1158
-			else if((float)DOL_VERSION>=3.8) {
1158
+			else if ((float) DOL_VERSION >= 3.8) {
1159 1159
 				return 1;
1160 1160
 			}
1161 1161
 			
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
 				}
1182 1182
 			}
1183 1183
 		}
1184
-		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1184
+		if ((int) GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) {
1185 1185
 		    $this->resprints = price($object->lines[$i]->total_ht);
1186 1186
 		}
1187 1187
 		
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
 		{
1207 1207
 			// Check if a title exist for this line && if the title have subtotal
1208 1208
 			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1209
-			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1209
+			if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1210 1210
 			{
1211 1211
 
1212 1212
 				$this->resprints = ' ';
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
 	 */
1227 1227
 	private function callHook(&$object, &$hookmanager, $action, $params, $defaultReturn = 1)
1228 1228
 	{
1229
-		$reshook=$hookmanager->executeHooks('subtotalHidePrices',$params, $object, $action);
1229
+		$reshook = $hookmanager->executeHooks('subtotalHidePrices', $params, $object, $action);
1230 1230
 		if ($reshook < 0)
1231 1231
 		{
1232 1232
 			$this->error = $hookmanager->error;
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
 			$this->resprints = $hookmanager->resprints;
1243 1243
 
1244 1244
 			// override return (use  $this->results['overrideReturn'] or $this->resArray['overrideReturn'] in other module action_xxxx.class.php )
1245
-			if(isset($hookmanager->resArray['overrideReturn']))
1245
+			if (isset($hookmanager->resArray['overrideReturn']))
1246 1246
 			{
1247 1247
 				return $hookmanager->resArray['overrideReturn'];
1248 1248
 			}
@@ -1251,25 +1251,25 @@  discard block
 block discarded – undo
1251 1251
 		return $defaultReturn;
1252 1252
 	}
1253 1253
 	
1254
-	function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='') {
1254
+	function pdf_getlinetotalwithtax($parameters = array(), &$object, &$action = '') {
1255 1255
 		global $conf;
1256 1256
 		
1257
-		if($this->isModSubtotalLine($parameters,$object) ){
1257
+		if ($this->isModSubtotalLine($parameters, $object)) {
1258 1258
 			
1259 1259
 			$this->resprints = ' ';
1260 1260
 		
1261
-			if((float)DOL_VERSION<=3.6) {
1261
+			if ((float) DOL_VERSION <= 3.6) {
1262 1262
 				return '';
1263 1263
 			}
1264
-			else if((float)DOL_VERSION>=3.8) {
1264
+			else if ((float) DOL_VERSION >= 3.8) {
1265 1265
 				return 1;
1266 1266
 			}
1267 1267
 		}
1268 1268
 		
1269
-		if(is_array($parameters)) $i = & $parameters['i'];
1270
-		else $i = (int)$parameters;
1269
+		if (is_array($parameters)) $i = & $parameters['i'];
1270
+		else $i = (int) $parameters;
1271 1271
 		
1272
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1272
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) 
1273 1273
 		{
1274 1274
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1275 1275
 			{
@@ -1281,24 +1281,24 @@  discard block
 block discarded – undo
1281 1281
 		return 0;
1282 1282
 	}
1283 1283
 	
1284
-	function pdf_getlineunit($parameters=array(), &$object, &$action='') {
1284
+	function pdf_getlineunit($parameters = array(), &$object, &$action = '') {
1285 1285
 		global $conf;
1286 1286
 		
1287
-		if($this->isModSubtotalLine($parameters,$object) ){
1287
+		if ($this->isModSubtotalLine($parameters, $object)) {
1288 1288
 			$this->resprints = ' ';
1289 1289
 		
1290
-			if((float)DOL_VERSION<=3.6) {
1290
+			if ((float) DOL_VERSION <= 3.6) {
1291 1291
 				return '';
1292 1292
 			}
1293
-			else if((float)DOL_VERSION>=3.8) {
1293
+			else if ((float) DOL_VERSION >= 3.8) {
1294 1294
 				return 1;
1295 1295
 			}
1296 1296
 		}
1297 1297
 		
1298
-		if(is_array($parameters)) $i = & $parameters['i'];
1299
-		else $i = (int)$parameters;
1298
+		if (is_array($parameters)) $i = & $parameters['i'];
1299
+		else $i = (int) $parameters;
1300 1300
 			
1301
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1301
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1302 1302
 		{
1303 1303
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1304 1304
 			{
@@ -1310,32 +1310,32 @@  discard block
 block discarded – undo
1310 1310
 		return 0;
1311 1311
 	}
1312 1312
 	
1313
-	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1314
-	    global $conf,$hideprices,$hookmanager;
1313
+	function pdf_getlineupexcltax($parameters = array(), &$object, &$action = '') {
1314
+	    global $conf, $hideprices, $hookmanager;
1315 1315
 
1316
-		if(is_array($parameters)) $i = & $parameters['i'];
1317
-		else $i = (int)$parameters;
1316
+		if (is_array($parameters)) $i = & $parameters['i'];
1317
+		else $i = (int) $parameters;
1318 1318
 
1319
-		if($this->isModSubtotalLine($parameters,$object) ) {
1319
+		if ($this->isModSubtotalLine($parameters, $object)) {
1320 1320
 			$this->resprints = ' ';
1321 1321
 
1322 1322
             $line = $object->lines[$i];
1323 1323
 
1324 1324
             // On récupère les montants du bloc pour les afficher dans la ligne de sous-total
1325
-            if(TSubtotal::isSubtotal($line)) {
1325
+            if (TSubtotal::isSubtotal($line)) {
1326 1326
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1327 1327
 
1328
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1329
-                if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1328
+                if (is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1329
+                if (!empty($parentTitle->array_options['options_show_total_ht'])) {
1330 1330
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1331 1331
                     $this->resprints = price($TTotal['total_unit_subprice']);
1332 1332
                 }
1333 1333
             }
1334 1334
 		
1335
-			if((float)DOL_VERSION<=3.6) {
1335
+			if ((float) DOL_VERSION <= 3.6) {
1336 1336
 				return '';
1337 1337
 			}
1338
-			else if((float)DOL_VERSION>=3.8) {
1338
+			else if ((float) DOL_VERSION >= 3.8) {
1339 1339
 				return 1;
1340 1340
 			}
1341 1341
 		}
@@ -1363,7 +1363,7 @@  discard block
 block discarded – undo
1363 1363
 		    
1364 1364
 		    // Check if a title exist for this line && if the title have subtotal
1365 1365
 		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1366
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1366
+		    if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1367 1367
 		    {
1368 1368
 		        
1369 1369
 		        $this->resprints = ' ';
@@ -1377,37 +1377,37 @@  discard block
 block discarded – undo
1377 1377
 		return 0;
1378 1378
 	}
1379 1379
 	
1380
-	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1381
-	    global $conf,$hideprices,$hookmanager;
1380
+	function pdf_getlineremisepercent($parameters = array(), &$object, &$action = '') {
1381
+	    global $conf, $hideprices, $hookmanager;
1382 1382
 
1383
-        if(is_array($parameters)) $i = & $parameters['i'];
1383
+        if (is_array($parameters)) $i = & $parameters['i'];
1384 1384
         else $i = (int) $parameters;
1385 1385
 
1386
-		if($this->isModSubtotalLine($parameters,$object) ) {
1386
+		if ($this->isModSubtotalLine($parameters, $object)) {
1387 1387
 			$this->resprints = ' ';
1388 1388
 
1389 1389
             $line = $object->lines[$i];
1390 1390
 
1391 1391
             // Affichage de la remise 
1392
-            if(TSubtotal::isSubtotal($line)) {
1392
+            if (TSubtotal::isSubtotal($line)) {
1393 1393
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1394 1394
 
1395
-                if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1396
-                if(! empty($parentTitle->array_options['options_show_reduc'])) {
1395
+                if (empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1396
+                if (!empty($parentTitle->array_options['options_show_reduc'])) {
1397 1397
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1398
-                    $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
1398
+                    $this->resprints = price((1 - $TTotal['total_ht'] / $TTotal['total_subprice']) * 100, 0, '', 1, 2, 2).'%';
1399 1399
                 }
1400 1400
             }
1401 1401
 		
1402
-			if((float)DOL_VERSION<=3.6) {
1402
+			if ((float) DOL_VERSION <= 3.6) {
1403 1403
 				return '';
1404 1404
 			}
1405
-			else if((float)DOL_VERSION>=3.8) {
1405
+			else if ((float) DOL_VERSION >= 3.8) {
1406 1406
 				return 1;
1407 1407
 			}
1408 1408
 		}
1409 1409
 		elseif (!empty($hideprices)
1410
-		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1410
+		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1411 1411
 		        )
1412 1412
 		    {
1413 1413
 		        if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1420,24 +1420,24 @@  discard block
 block discarded – undo
1420 1420
 		return 0;
1421 1421
 	}
1422 1422
 	
1423
-	function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') {
1424
-		global $conf,$hideprices;
1423
+	function pdf_getlineupwithtax($parameters = array(), &$object, &$action = '') {
1424
+		global $conf, $hideprices;
1425 1425
 		
1426
-		if($this->isModSubtotalLine($parameters,$object) ){
1426
+		if ($this->isModSubtotalLine($parameters, $object)) {
1427 1427
 			$this->resprints = ' ';
1428
-			if((float)DOL_VERSION<=3.6) {
1428
+			if ((float) DOL_VERSION <= 3.6) {
1429 1429
 				return '';
1430 1430
 			}
1431
-			else if((float)DOL_VERSION>=3.8) {
1431
+			else if ((float) DOL_VERSION >= 3.8) {
1432 1432
 				return 1;
1433 1433
 			}
1434 1434
 		}
1435 1435
 		
1436
-		if(is_array($parameters)) $i = & $parameters['i'];
1437
-		else $i = (int)$parameters;
1436
+		if (is_array($parameters)) $i = & $parameters['i'];
1437
+		else $i = (int) $parameters;
1438 1438
 			
1439 1439
 		if (!empty($hideprices)
1440
-				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1440
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1441 1441
 		)
1442 1442
 		{
1443 1443
 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1450,22 +1450,22 @@  discard block
 block discarded – undo
1450 1450
 		return 0;
1451 1451
 	}
1452 1452
 	
1453
-	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1454
-	    global $conf,$hideprices,$hookmanager;
1453
+	function pdf_getlinevatrate($parameters = array(), &$object, &$action = '') {
1454
+	    global $conf, $hideprices, $hookmanager;
1455 1455
 	    
1456
-		if($this->isModSubtotalLine($parameters,$object) ){
1456
+		if ($this->isModSubtotalLine($parameters, $object)) {
1457 1457
 			$this->resprints = ' ';
1458 1458
 			
1459
-			if((float)DOL_VERSION<=3.6) {
1459
+			if ((float) DOL_VERSION <= 3.6) {
1460 1460
 				return '';
1461 1461
 			}
1462
-			else if((float)DOL_VERSION>=3.8) {
1462
+			else if ((float) DOL_VERSION >= 3.8) {
1463 1463
 				return 1;
1464 1464
 			}
1465 1465
 		}
1466 1466
 		
1467
-		if(is_array($parameters)) $i = & $parameters['i'];
1468
-		else $i = (int)$parameters;
1467
+		if (is_array($parameters)) $i = & $parameters['i'];
1468
+		else $i = (int) $parameters;
1469 1469
 		
1470 1470
 		if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1471 1471
 
@@ -1492,7 +1492,7 @@  discard block
 block discarded – undo
1492 1492
 		    
1493 1493
 		    // Check if a title exist for this line && if the title have subtotal
1494 1494
 		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1495
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1495
+		    if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1496 1496
 		    {
1497 1497
 		        
1498 1498
 		        $this->resprints = ' ';
@@ -1506,23 +1506,23 @@  discard block
 block discarded – undo
1506 1506
 		return 0;
1507 1507
 	}
1508 1508
 		
1509
-	function pdf_getlineprogress($parameters=array(), &$object, &$action) {
1509
+	function pdf_getlineprogress($parameters = array(), &$object, &$action) {
1510 1510
 		global $conf;
1511 1511
 		
1512
-		if($this->isModSubtotalLine($parameters,$object) ){
1512
+		if ($this->isModSubtotalLine($parameters, $object)) {
1513 1513
 			$this->resprints = ' ';
1514
-			if((float)DOL_VERSION<=3.6) {
1514
+			if ((float) DOL_VERSION <= 3.6) {
1515 1515
 				return '';
1516 1516
 			}
1517
-			else if((float)DOL_VERSION>=3.8) {
1517
+			else if ((float) DOL_VERSION >= 3.8) {
1518 1518
 				return 1;
1519 1519
 			}
1520 1520
 		}
1521 1521
 		
1522
-		if(is_array($parameters)) $i = & $parameters['i'];
1523
-		else $i = (int)$parameters;
1522
+		if (is_array($parameters)) $i = & $parameters['i'];
1523
+		else $i = (int) $parameters;
1524 1524
 			
1525
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1525
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1526 1526
 		{
1527 1527
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1528 1528
 			{
@@ -1537,12 +1537,12 @@  discard block
 block discarded – undo
1537 1537
 	function add_numerotation(&$object) {
1538 1538
 		global $conf;
1539 1539
 		
1540
-		if(!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1540
+		if (!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1541 1541
 		
1542 1542
 			$TLevelTitre = array();
1543 1543
 			$prevlevel = 0;
1544 1544
 		
1545
-			foreach($object->lines as $k=>&$line) 
1545
+			foreach ($object->lines as $k=>&$line) 
1546 1546
 			{
1547 1547
 				if ($line->id > 0 && $this->isModSubtotalLine($k, $object) && $line->qty <= 10)
1548 1548
 				{
@@ -1556,12 +1556,12 @@  discard block
 block discarded – undo
1556 1556
 	}
1557 1557
 
1558 1558
 	// TODO ne gère pas encore la numération des lignes "Totaux"
1559
-	private function formatNumerotation(&$TLineTitle, $line_reference='', $level=1, $prefix_num=0)
1559
+	private function formatNumerotation(&$TLineTitle, $line_reference = '', $level = 1, $prefix_num = 0)
1560 1560
 	{
1561 1561
 		$TTitle = array();
1562 1562
 		
1563
-		$i=1;
1564
-		$j=0;
1563
+		$i = 1;
1564
+		$j = 0;
1565 1565
 		foreach ($TLineTitle as $k => &$line)
1566 1566
 		{
1567 1567
 			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
 			{
1572 1572
 				$TTitle[$j]['numerotation'] = ($prefix_num == 0) ? $i : $prefix_num.'.'.$i;
1573 1573
 				//var_dump('Prefix == '.$prefix_num.' // '.$line->desc.' ==> numerotation == '.$TTitle[$j]['numerotation'].'   ###    '.$line->qty .'=='. $level);
1574
-				if (empty($line->label) && (float)DOL_VERSION < 6)
1574
+				if (empty($line->label) && (float) DOL_VERSION < 6)
1575 1575
 				{
1576 1576
 					$line->label = !empty($line->desc) ? $line->desc : $line->description;
1577 1577
 					$line->desc = $line->description = '';
@@ -1597,26 +1597,26 @@  discard block
 block discarded – undo
1597 1597
 	
1598 1598
 	function setDocTVA(&$pdf, &$object) {
1599 1599
 		
1600
-		$hidedetails = (int)GETPOST('hidedetails');
1600
+		$hidedetails = (int) GETPOST('hidedetails');
1601 1601
 		
1602
-		if(empty($hidedetails)) return false;
1602
+		if (empty($hidedetails)) return false;
1603 1603
 		
1604 1604
 		// TODO can't add VAT to document without lines... :-/
1605 1605
 		
1606 1606
 		return true;
1607 1607
 	}
1608 1608
 	
1609
-	function beforePDFCreation($parameters=array(), &$object, &$action)
1609
+	function beforePDFCreation($parameters = array(), &$object, &$action)
1610 1610
 	{
1611 1611
 		/**
1612 1612
 		 * @var $pdf    TCPDF
1613 1613
 		 */
1614
-		global $pdf,$conf, $langs;
1614
+		global $pdf, $conf, $langs;
1615 1615
 
1616 1616
 		// var_dump($object->lines);
1617 1617
 		dol_include_once('/subtotal/class/subtotal.class.php');
1618 1618
 
1619
-		foreach($parameters as $key=>$value) {
1619
+		foreach ($parameters as $key=>$value) {
1620 1620
 			${$key} = $value;
1621 1621
 		}
1622 1622
 		
@@ -1624,43 +1624,43 @@  discard block
 block discarded – undo
1624 1624
 		
1625 1625
 		$this->add_numerotation($object);	
1626 1626
 		
1627
-        foreach($object->lines as $k => &$l) {
1628
-            if(TSubtotal::isSubtotal($l)) {
1627
+        foreach ($object->lines as $k => &$l) {
1628
+            if (TSubtotal::isSubtotal($l)) {
1629 1629
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1630
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1631
-                if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_reduc'])) {
1632
-                    $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1630
+                if (is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1631
+                if (!empty($parentTitle->id) && !empty($parentTitle->array_options['options_show_reduc'])) {
1632
+                    $l->remise_percent = 100; // Affichage de la réduction sur la ligne de sous-total
1633 1633
                 }
1634 1634
             }
1635 1635
 
1636 1636
 
1637 1637
             // Pas de hook sur les colonnes du PDF expédition, on unset les bonnes variables
1638
-            if(($object->element == 'shipping' || $object->element == 'delivery') && $this->isModSubtotalLine($k, $object))
1638
+            if (($object->element == 'shipping' || $object->element == 'delivery') && $this->isModSubtotalLine($k, $object))
1639 1639
 			{
1640 1640
 				$l->qty = $l->qty_asked;
1641 1641
 				unset($l->qty_asked, $l->qty_shipped, $l->volume, $l->weight);
1642 1642
 			}
1643 1643
         }
1644 1644
 
1645
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1646
-		$hidedetails = (int)GETPOST('hidedetails');
1645
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1646
+		$hidedetails = (int) GETPOST('hidedetails');
1647 1647
 
1648 1648
 		if ($hideInnerLines) { // si c une ligne de titre
1649
-	    	$fk_parent_line=0;
1650
-			$TLines =array();
1649
+	    	$fk_parent_line = 0;
1650
+			$TLines = array();
1651 1651
 		
1652
-			$original_count=count($object->lines);
1652
+			$original_count = count($object->lines);
1653 1653
 		    $TTvas = array(); // tableau de tva
1654 1654
 		    
1655
-			foreach($object->lines as $k=>&$line) 
1655
+			foreach ($object->lines as $k=>&$line) 
1656 1656
 			{
1657 1657
 			    
1658
-				if($line->product_type==9 && $line->rowid>0) 
1658
+				if ($line->product_type == 9 && $line->rowid > 0) 
1659 1659
 				{
1660 1660
 					$fk_parent_line = $line->rowid;
1661 1661
 					
1662 1662
 					// Fix tk7201 - si on cache le détail, la TVA est renseigné au niveau du sous-total, l'erreur c'est s'il y a plusieurs sous-totaux pour les même lignes, ça va faire la somme
1663
-					if(TSubtotal::isSubtotal($line)) 
1663
+					if (TSubtotal::isSubtotal($line)) 
1664 1664
 					{
1665 1665
 						/*$total = $this->getTotalLineFromObject($object, $line, '');
1666 1666
 						
@@ -1691,22 +1691,22 @@  discard block
 block discarded – undo
1691 1691
 			
1692 1692
 				if ($hideInnerLines)
1693 1693
 				{
1694
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1694
+				    if (!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1695 1695
 				    {
1696
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1696
+				        if ($line->tva_tx != '0.000' && $line->product_type != 9) {
1697 1697
 				            
1698 1698
     				        // on remplit le tableau de tva pour substituer les lignes cachées
1699 1699
     				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1700 1700
     				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1701 1701
     				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1702 1702
     				    }
1703
-    					if($line->product_type==9 && $line->rowid>0)
1703
+    					if ($line->product_type == 9 && $line->rowid > 0)
1704 1704
     					{
1705 1705
     					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1706 1706
     					    // génère des lignes d'affichage des montants HT soumis à tva
1707 1707
     					    $nbtva = count($TTvas);
1708
-    					    if(!empty($nbtva)){
1709
-    					        foreach ($TTvas as $tx =>$val){
1708
+    					    if (!empty($nbtva)) {
1709
+    					        foreach ($TTvas as $tx =>$val) {
1710 1710
     					            $l = clone $line;
1711 1711
     					            $l->product_type = 1;
1712 1712
     					            $l->special_code = '';
@@ -1727,7 +1727,7 @@  discard block
 block discarded – undo
1727 1727
     					}
1728 1728
 				    } else {
1729 1729
 				        
1730
-				        if($line->product_type==9 && $line->rowid>0)
1730
+				        if ($line->product_type == 9 && $line->rowid > 0)
1731 1731
 				        {
1732 1732
 				            // ajoute la ligne de sous-total
1733 1733
 				            $TLines[] = $line; 
@@ -1755,9 +1755,9 @@  discard block
 block discarded – undo
1755 1755
 			
1756 1756
 			// cas incongru où il y aurait des produits en dessous du dernier sous-total
1757 1757
 			$nbtva = count($TTvas);
1758
-			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1758
+			if (!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1759 1759
 			{
1760
-			    foreach ($TTvas as $tx =>$val){
1760
+			    foreach ($TTvas as $tx =>$val) {
1761 1761
 			        $l = clone $line;
1762 1762
 			        $l->product_type = 1;
1763 1763
 			        $l->special_code = '';
@@ -1774,11 +1774,11 @@  discard block
 block discarded – undo
1774 1774
 			}
1775 1775
 			
1776 1776
 			global $nblignes;
1777
-			$nblignes=count($TLines);
1777
+			$nblignes = count($TLines);
1778 1778
 
1779 1779
 			$object->lines = $TLines;
1780 1780
 			
1781
-			if($i>count($object->lines)) {
1781
+			if ($i > count($object->lines)) {
1782 1782
 				$this->resprints = '';
1783 1783
 				return 0;
1784 1784
 			}
@@ -1787,55 +1787,55 @@  discard block
 block discarded – undo
1787 1787
 		return 0;
1788 1788
 	}
1789 1789
 
1790
-	function pdf_writelinedesc($parameters=array(), &$object, &$action)
1790
+	function pdf_writelinedesc($parameters = array(), &$object, &$action)
1791 1791
 	{
1792 1792
 		/**
1793 1793
 		 * @var $pdf    TCPDF
1794 1794
 		 */
1795
-		global $pdf,$conf;
1795
+		global $pdf, $conf;
1796 1796
 
1797
-		foreach($parameters as $key=>$value) {
1797
+		foreach ($parameters as $key=>$value) {
1798 1798
 			${$key} = $value;
1799 1799
 		}
1800 1800
 		
1801
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1802
-		$hidedetails = (int)GETPOST('hidedetails');
1801
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1802
+		$hidedetails = (int) GETPOST('hidedetails');
1803 1803
 		
1804
-		if($this->isModSubtotalLine($parameters,$object) ){			
1804
+		if ($this->isModSubtotalLine($parameters, $object)) {			
1805 1805
 		
1806 1806
 				global $hideprices;
1807 1807
 				
1808
-				if(!empty($hideprices)) {
1809
-					foreach($object->lines as &$line) {
1810
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1808
+				if (!empty($hideprices)) {
1809
+					foreach ($object->lines as &$line) {
1810
+						if ($line->fk_product_type != 9) $line->fk_parent_line = -1;	
1811 1811
 					}
1812 1812
 				}
1813 1813
 			
1814 1814
 				$line = &$object->lines[$i];
1815 1815
 
1816
-				if($object->element == 'delivery' && ! empty($object->commande->expeditions[$line->fk_origin_line])) unset($object->commande->expeditions[$line->fk_origin_line]);
1816
+				if ($object->element == 'delivery' && !empty($object->commande->expeditions[$line->fk_origin_line])) unset($object->commande->expeditions[$line->fk_origin_line]);
1817 1817
 
1818
-				if($line->info_bits>0) { // PAGE BREAK
1818
+				if ($line->info_bits > 0) { // PAGE BREAK
1819 1819
 					$pdf->addPage();
1820 1820
 					$posy = $pdf->GetY();
1821 1821
 				}
1822 1822
 				
1823 1823
 				$label = $line->label;
1824
-				$description= !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1824
+				$description = !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1825 1825
 				
1826
-				if(empty($label)) {
1826
+				if (empty($label)) {
1827 1827
 					$label = $description;
1828
-					$description='';
1828
+					$description = '';
1829 1829
 				}
1830 1830
 
1831
-				if($line->qty>90) {
1831
+				if ($line->qty > 90) {
1832 1832
 					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1833 1833
 					
1834 1834
 					$pageBefore = $pdf->getPage();
1835
-					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1835
+					$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1836 1836
 					$pageAfter = $pdf->getPage();	
1837 1837
 
1838
-					if($pageAfter>$pageBefore) {
1838
+					if ($pageAfter > $pageBefore) {
1839 1839
 						//print "ST $pageAfter>$pageBefore<br>";
1840 1840
 						$pdf->rollbackTransaction(true);
1841 1841
 						$pdf->addPage('', '', true);
@@ -1846,9 +1846,9 @@  discard block
 block discarded – undo
1846 1846
 					}
1847 1847
 
1848 1848
 					// On delivery PDF, we don't want quantities to appear and there are no hooks => setting text color to background color;
1849
-					if($object->element == 'delivery')
1849
+					if ($object->element == 'delivery')
1850 1850
 					{
1851
-						switch($line->qty)
1851
+						switch ($line->qty)
1852 1852
 						{
1853 1853
 							case 99:
1854 1854
 								$grey = 220;
@@ -1871,7 +1871,7 @@  discard block
 block discarded – undo
1871 1871
 				else if ($line->qty < 10) {
1872 1872
 					$pageBefore = $pdf->getPage();
1873 1873
 
1874
-					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
1874
+					$this->pdf_add_title($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h); 
1875 1875
 					$pageAfter = $pdf->getPage();	
1876 1876
 
1877 1877
 					
@@ -1887,9 +1887,9 @@  discard block
 block discarded – undo
1887 1887
 					}
1888 1888
 				*/
1889 1889
 
1890
-					if($object->element == 'delivery')
1890
+					if ($object->element == 'delivery')
1891 1891
 					{
1892
-						$pdf->SetTextColor(255,255,255);
1892
+						$pdf->SetTextColor(255, 255, 255);
1893 1893
 					}
1894 1894
 
1895 1895
 					$posy = $pdf->GetY();
@@ -1952,9 +1952,9 @@  discard block
 block discarded – undo
1952 1952
 	 * @param $hookmanager  HookManager
1953 1953
 	 * @return int
1954 1954
 	 */
1955
-	function printObjectLine ($parameters, &$object, &$action, $hookmanager){
1955
+	function printObjectLine($parameters, &$object, &$action, $hookmanager) {
1956 1956
 		
1957
-		global $conf,$langs,$user,$db,$bc;
1957
+		global $conf, $langs, $user, $db, $bc;
1958 1958
 		
1959 1959
 		$num = &$parameters['num'];
1960 1960
 		$line = &$parameters['line'];
@@ -1962,33 +1962,33 @@  discard block
 block discarded – undo
1962 1962
 		
1963 1963
 		$var = &$parameters['var'];
1964 1964
 
1965
-		$contexts = explode(':',$parameters['context']);
1966
-		if($parameters['currentcontext'] === 'paiementcard') return 0;
1965
+		$contexts = explode(':', $parameters['context']);
1966
+		if ($parameters['currentcontext'] === 'paiementcard') return 0;
1967 1967
 		$originline = null;
1968 1968
 
1969 1969
 		$createRight = $user->rights->{$object->element}->creer;
1970
-		if($object->element == 'facturerec' )
1970
+		if ($object->element == 'facturerec')
1971 1971
 		{
1972 1972
 			$object->statut = 0; // hack for facture rec
1973 1973
 			$createRight = $user->rights->facture->creer;
1974 1974
 		}
1975
-		elseif($object->element == 'order_supplier' )
1975
+		elseif ($object->element == 'order_supplier')
1976 1976
 		{
1977 1977
 		    $createRight = $user->rights->fournisseur->commande->creer;
1978 1978
 		}
1979
-		elseif($object->element == 'invoice_supplier' )
1979
+		elseif ($object->element == 'invoice_supplier')
1980 1980
 		{
1981 1981
 		    $createRight = $user->rights->fournisseur->facture->creer;
1982 1982
 		}
1983
-		elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
1983
+		elseif ($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
1984 1984
 		{
1985 1985
 			// H4cK 4n0nYm0u$-style : $line n'est pas un objet instancié mais provient d'un fetch_object d'une requête SQL
1986 1986
 			$line->id = $line->rowid;
1987 1987
 			$line->product_type = $line->type;
1988 1988
 		}
1989
-		elseif($object->element == 'shipping' || $object->element == 'delivery')
1989
+		elseif ($object->element == 'shipping' || $object->element == 'delivery')
1990 1990
 		{
1991
-			if(empty($line->origin_line_id) && ! empty($line->fk_origin_line))
1991
+			if (empty($line->origin_line_id) && !empty($line->fk_origin_line))
1992 1992
 			{
1993 1993
 				$line->origin_line_id = $line->fk_origin_line;
1994 1994
 			}
@@ -1996,9 +1996,9 @@  discard block
 block discarded – undo
1996 1996
 			$originline = new OrderLine($db);
1997 1997
 			$originline->fetch($line->fk_origin_line);
1998 1998
 
1999
-			foreach(get_object_vars($line) as $property => $value)
1999
+			foreach (get_object_vars($line) as $property => $value)
2000 2000
 			{
2001
-				if(empty($originline->{ $property }))
2001
+				if (empty($originline->{ $property }))
2002 2002
 				{
2003 2003
 					$originline->{ $property } = $value;
2004 2004
 				}
@@ -2006,13 +2006,13 @@  discard block
 block discarded – undo
2006 2006
 
2007 2007
 			$line = $originline;
2008 2008
 		}
2009
- 		if($object->element=='facture')$idvar = 'facid';
2010
-        else $idvar='id';
2011
-		if($line->special_code!=$this->module_number || $line->product_type!=9) {
2012
-			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE) && $object->element !== 'invoice_supplier')
2009
+ 		if ($object->element == 'facture')$idvar = 'facid';
2010
+        else $idvar = 'id';
2011
+		if ($line->special_code != $this->module_number || $line->product_type != 9) {
2012
+			if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE) && $object->element !== 'invoice_supplier')
2013 2013
             {
2014
-                if(!(TSubtotal::isModSubtotalLine($line)) && ( $line->fk_prev_id === null ) && !($action == "editline" && GETPOST('lineid') == $line->id)) {
2015
-                    echo '<a name="duplicate-'.$line->id.'" href="' . $_SERVER['PHP_SELF'] . '?' . $idvar . '=' . $object->id . '&action=duplicate&lineid=' . $line->id . '"><i class="fa fa-clone" aria-hidden="true"></i></a>';
2014
+                if (!(TSubtotal::isModSubtotalLine($line)) && ($line->fk_prev_id === null) && !($action == "editline" && GETPOST('lineid') == $line->id)) {
2015
+                    echo '<a name="duplicate-'.$line->id.'" href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'"><i class="fa fa-clone" aria-hidden="true"></i></a>';
2016 2016
 
2017 2017
                     ?>
2018 2018
                         <script type="text/javascript">
@@ -2026,11 +2026,11 @@  discard block
 block discarded – undo
2026 2026
             }
2027 2027
 			return 0;
2028 2028
 		}
2029
-		else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) 
2029
+		else if (in_array('invoicecard', $contexts) || in_array('invoicesuppliercard', $contexts) || in_array('propalcard', $contexts) || in_array('supplier_proposalcard', $contexts) || in_array('ordercard', $contexts) || in_array('ordersuppliercard', $contexts) || in_array('invoicereccard', $contexts)) 
2030 2030
         {
2031 2031
 
2032 2032
 
2033
-			if((float)DOL_VERSION <= 3.4)
2033
+			if ((float) DOL_VERSION <= 3.4)
2034 2034
 			{
2035 2035
 				?>
2036 2036
 				<script type="text/javascript">
@@ -2054,22 +2054,22 @@  discard block
 block discarded – undo
2054 2054
 				<?php
2055 2055
 			}
2056 2056
 			
2057
-			if(empty($line->description)) $line->description = $line->desc;
2057
+			if (empty($line->description)) $line->description = $line->desc;
2058 2058
 			
2059 2059
 			$colspan = 5;
2060
-			if($object->element == 'facturerec' ) $colspan = 3;
2061
-			if($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2062
-			if($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
2063
-			if($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2064
-			if(!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
2060
+			if ($object->element == 'facturerec') $colspan = 3;
2061
+			if ($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2062
+			if ($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4 : $colspan = 7;
2063
+			if ($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2064
+			if (!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
2065 2065
 				$colspan++; // Colonne PU Devise
2066 2066
 			}
2067
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
2068
-			if(!empty($conf->margin->enabled)) $colspan++;
2069
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
2070
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
2071
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
2072
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
2067
+			if ($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
2068
+			if (!empty($conf->margin->enabled)) $colspan++;
2069
+			if (!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
2070
+			if (!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
2071
+			if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
2072
+			if (!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
2073 2073
 					
2074 2074
 			/* Titre */
2075 2075
 			//var_dump($line);
@@ -2079,39 +2079,39 @@  discard block
 block discarded – undo
2079 2079
             
2080 2080
 			
2081 2081
 			?>
2082
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2082
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2083 2083
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2084 2084
 					{
2085
-						if($line->qty==99) print 'background:#adadcf';
2086
-						else if($line->qty==98) print 'background:#ddddff;';
2087
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2088
-						else if($line->qty==1) print 'background:#adadcf;';
2089
-						else if($line->qty==2) print 'background:#ddddff;';
2090
-						else if($line->qty==50) print '';
2085
+						if ($line->qty == 99) print 'background:#adadcf';
2086
+						else if ($line->qty == 98) print 'background:#ddddff;';
2087
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
2088
+						else if ($line->qty == 1) print 'background:#adadcf;';
2089
+						else if ($line->qty == 2) print 'background:#ddddff;';
2090
+						else if ($line->qty == 50) print '';
2091 2091
 						else print 'background:#eeeeff;';
2092 2092
 
2093 2093
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2094 2094
 					}
2095 2095
 					else 
2096 2096
 					{
2097
-						if($line->qty==99) print 'background:#ddffdd';
2098
-						else if($line->qty==98) print 'background:#ddddff;';
2099
-						else if($line->qty==2) print 'background:#eeeeff; ';
2100
-						else if($line->qty==50) print '';
2101
-						else print 'background:#eeffee;' ;
2097
+						if ($line->qty == 99) print 'background:#ddffdd';
2098
+						else if ($line->qty == 98) print 'background:#ddddff;';
2099
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
2100
+						else if ($line->qty == 50) print '';
2101
+						else print 'background:#eeffee;';
2102 2102
 					}
2103 2103
 
2104 2104
 			?>;">
2105 2105
 
2106
-				<?php if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
2106
+				<?php if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
2107 2107
 				<td class="linecolnum"><?php echo $i + 1; ?></td>
2108 2108
 				<?php } ?>
2109 2109
 
2110
-				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2111
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
2110
+				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
2111
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
2112 2112
 
2113
-						$params=array('line'=>$line);
2114
-						$reshook=$hookmanager->executeHooks('formEditProductOptions',$params,$object,$action);
2113
+						$params = array('line'=>$line);
2114
+						$reshook = $hookmanager->executeHooks('formEditProductOptions', $params, $object, $action);
2115 2115
 						
2116 2116
 						echo '<div id="line_'.$line->id.'"></div>'; // Imitation Dolibarr
2117 2117
 						echo '<input type="hidden" value="'.$line->id.'" name="lineid">';
@@ -2119,7 +2119,7 @@  discard block
 block discarded – undo
2119 2119
 						echo '<input id="product_id" type="hidden" value="'.$line->fk_product.'" name="type">';
2120 2120
 						echo '<input id="special_code" type="hidden" value="'.$line->special_code.'" name="type">';
2121 2121
 
2122
-						$isFreeText=false;
2122
+						$isFreeText = false;
2123 2123
 						if (TSubtotal::isTitle($line))
2124 2124
 						{
2125 2125
 							$qty_displayed = $line->qty;
@@ -2141,13 +2141,13 @@  discard block
 block discarded – undo
2141 2141
 						    $line->description = '';
2142 2142
 						}
2143 2143
 						$newlabel = $line->label;
2144
-						if($line->label=='' && !$isFreeText) {
2145
-							if(TSubtotal::isSubtotal($line)) {
2144
+						if ($line->label == '' && !$isFreeText) {
2145
+							if (TSubtotal::isSubtotal($line)) {
2146 2146
 								$newlabel = $line->description.' '.$this->getTitle($object, $line);
2147
-								$line->description='';
2148
-							} elseif( (float)DOL_VERSION < 6 ) {
2149
-								$newlabel= $line->description;
2150
-								$line->description='';
2147
+								$line->description = '';
2148
+							} elseif ((float) DOL_VERSION < 6) {
2149
+								$newlabel = $line->description;
2150
+								$line->description = '';
2151 2151
 							}
2152 2152
 						}
2153 2153
 
@@ -2156,10 +2156,10 @@  discard block
 block discarded – undo
2156 2156
 						
2157 2157
 						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2158 2158
 						
2159
-						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
2159
+						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)))
2160 2160
 						{
2161 2161
 							$select = '<select name="subtotal_level">';
2162
-							for ($j=1; $j<10; $j++)
2162
+							for ($j = 1; $j < 10; $j++)
2163 2163
 							{
2164 2164
 								if (!empty($readonlyForSituation)) {
2165 2165
 									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
@@ -2173,7 +2173,7 @@  discard block
 block discarded – undo
2173 2173
 
2174 2174
 						echo '<div class="subtotal_underline" style="margin-left:24px; line-height: 25px;">';
2175 2175
                         echo '<div>';
2176
-                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2176
+                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '').' />&nbsp;';
2177 2177
                         echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2178 2178
                         echo '</div>';
2179 2179
 
@@ -2194,12 +2194,12 @@  discard block
 block discarded – undo
2194 2194
                                 echo '</div>';
2195 2195
                             }
2196 2196
                             echo '<div>';
2197
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2197
+                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '').' />&nbsp;';
2198 2198
                             echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2199 2199
                             echo '</div>';
2200 2200
 
2201 2201
                             echo '<div>';
2202
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2202
+                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '').' />&nbsp;';
2203 2203
                             echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2204 2204
                             echo '</div>';
2205 2205
                         }
@@ -2209,7 +2209,7 @@  discard block
 block discarded – undo
2209 2209
 						if (TSubtotal::isTitle($line))
2210 2210
 						{
2211 2211
 							// WYSIWYG editor
2212
-							require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
2212
+							require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
2213 2213
 							$nbrows = ROWS_2;
2214 2214
 							$cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
2215 2215
 							if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
@@ -2251,25 +2251,25 @@  discard block
 block discarded – undo
2251 2251
 
2252 2252
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2253 2253
 						 {
2254
-							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
2254
+							if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
2255 2255
 							{
2256
-								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2256
+								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
2257 2257
 								
2258 2258
 								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2259
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2259
+								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
2260 2260
 							}
2261 2261
 						 }
2262 2262
 						 else 
2263 2263
 						 {
2264
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2265
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2264
+							if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
2265
+							else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2266 2266
 						 }
2267 2267
 						 
2268 2268
 						 
2269 2269
 						 // Get display styles and apply them
2270 2270
 						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2271
-						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2272
-						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2271
+						 $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2272
+						 $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2273 2273
 						 
2274 2274
 						 if (empty($line->label)) {
2275 2275
 							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
@@ -2277,16 +2277,16 @@  discard block
 block discarded – undo
2277 2277
 						 } 
2278 2278
 						 else {
2279 2279
 
2280
-							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2280
+							if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2281 2281
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2282 2282
 							}
2283
-							else{
2283
+							else {
2284 2284
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
2285 2285
 							}
2286 2286
 
2287 2287
 						 } 
2288
-						if($line->qty>90) print ' : ';
2289
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2288
+						if ($line->qty > 90) print ' : ';
2289
+						if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2290 2290
 
2291 2291
 						 
2292 2292
 
@@ -2295,7 +2295,7 @@  discard block
 block discarded – undo
2295 2295
 			?></td>
2296 2296
 					 
2297 2297
 			<?php
2298
-				if($line->qty>90) {
2298
+				if ($line->qty > 90) {
2299 2299
 					/* Total */
2300 2300
 					$total_line = $this->getTotalLineFromObject($object, $line, '');
2301 2301
 					echo '<td class="linecolht nowrap" align="right" style="font-weight:bold;" rel="subtotal_total">'.price($total_line).'</td>';
@@ -2314,7 +2314,7 @@  discard block
 block discarded – undo
2314 2314
 				<?php
2315 2315
 				if ($action != 'selectlines') {
2316 2316
 				
2317
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
2317
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
2318 2318
 						?>
2319 2319
 						<input id="savelinebutton" class="button" type="submit" name="save" value="<?php echo $langs->trans('Save') ?>" />
2320 2320
 						<br />
@@ -2330,13 +2330,13 @@  discard block
 block discarded – undo
2330 2330
 						<?php
2331 2331
 						
2332 2332
 					}
2333
-					else{
2334
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2333
+					else {
2334
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2335 2335
 						{
2336
-							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2336
+							if (TSubtotal::isTitle($line) && ($line->fk_prev_id === null)) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'.img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2337 2337
 						}
2338 2338
 
2339
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
2339
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
2340 2340
 						{
2341 2341
 							echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=editline&lineid='.$line->id.'">'.img_edit().'</a>';
2342 2342
 						}								
@@ -2351,7 +2351,7 @@  discard block
 block discarded – undo
2351 2351
 				<?php
2352 2352
 
2353 2353
 				if ($action != 'editline' && $action != 'selectlines') {
2354
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2354
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2355 2355
 						{
2356 2356
 
2357 2357
 							if ($line->fk_prev_id === null)
@@ -2359,12 +2359,12 @@  discard block
 block discarded – undo
2359 2359
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteline&lineid='.$line->id.'">'.img_delete().'</a>';
2360 2360
 							}
2361 2361
 
2362
-							if(TSubtotal::isTitle($line) && ($line->fk_prev_id === null) )
2362
+							if (TSubtotal::isTitle($line) && ($line->fk_prev_id === null))
2363 2363
 							{
2364 2364
 								if ((float) DOL_VERSION >= 8.0) {
2365 2365
 									$img_delete = img_delete($langs->trans('deleteWithAllLines'), ' class="pictodelete pictodeleteallline"');
2366 2366
 								} elseif ((float) DOL_VERSION >= 3.8) {
2367
-									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal',' class="pictodelete" ');
2367
+									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal', ' class="pictodelete" ');
2368 2368
 								} else {
2369 2369
 									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
2370 2370
 								}
@@ -2374,7 +2374,7 @@  discard block
 block discarded – undo
2374 2374
 								/* Depuis la 8.0, les icônes "standard" utilisent FontAwesome et sont préconfigurées selon la clé de l'image
2375 2375
 								 * Impossible d'en customiser par exemple la couleur, même en utilisant img_picto() directement
2376 2376
 								 */
2377
-								if((float) DOL_VERSION >= 8.0) {
2377
+								if ((float) DOL_VERSION >= 8.0) {
2378 2378
 								?>
2379 2379
 								<script>
2380 2380
 									$(document).ready(function () {
@@ -2390,7 +2390,7 @@  discard block
 block discarded – undo
2390 2390
 			</td>
2391 2391
 			
2392 2392
 			<?php 
2393
-			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2393
+			if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2394 2394
 			{
2395 2395
 				echo '<td class="subtotal_nc">';
2396 2396
 				echo '<input id="subtotal_nc-'.$line->id.'" class="subtotal_nc_chkbx" data-lineid="'.$line->id.'" type="checkbox" name="subtotal_nc" value="1" '.(!empty($line->array_options['options_subtotal_nc']) ? 'checked="checked"' : '').' />';
@@ -2401,12 +2401,12 @@  discard block
 block discarded – undo
2401 2401
 			<td align="center" class="linecolmove tdlineupdown">
2402 2402
 			</td>
2403 2403
 			<?php } else { ?>
2404
-			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0  && $createRight ))?' class="tdlineupdown"':''); ?>></td>
2404
+			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0 && $createRight)) ? ' class="tdlineupdown"' : ''); ?>></td>
2405 2405
 			<?php } ?>
2406 2406
 
2407 2407
 
2408
-			<?php  if($action == 'selectlines'){ // dolibarr 8 ?>
2409
-			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
2408
+			<?php  if ($action == 'selectlines') { // dolibarr 8 ?>
2409
+			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i + 1; ?>]" value="<?php echo $line->id; ?>" ></td>
2410 2410
 			<?php } ?>
2411 2411
 
2412 2412
 			</tr>
@@ -2414,29 +2414,29 @@  discard block
 block discarded – undo
2414 2414
 			
2415 2415
 			
2416 2416
 			// Affichage des extrafields à la Dolibarr (car sinon non affiché sur les titres)
2417
-			if(TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2417
+			if (TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2418 2418
 				
2419
-				require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
2419
+				require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
2420 2420
 				
2421 2421
 				// Extrafields
2422 2422
 				$extrafieldsline = new ExtraFields($db);
2423 2423
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2424 2424
 				
2425
-				$colspan+=3; $mode = 'view';
2426
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2425
+				$colspan += 3; $mode = 'view';
2426
+				if ($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2427 2427
 				
2428 2428
 				$ex_element = $line->element;
2429 2429
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
2430
-				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ','colspan'=>$colspan));
2430
+				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ', 'colspan'=>$colspan));
2431 2431
 				$isExtraSelected = false;
2432
-				foreach($line->array_options as $option) {
2433
-					if(!empty($option) && $option != "-1") {
2432
+				foreach ($line->array_options as $option) {
2433
+					if (!empty($option) && $option != "-1") {
2434 2434
 						$isExtraSelected = true;
2435 2435
 						break;
2436 2436
 					}
2437 2437
 				}
2438 2438
 				
2439
-				if($mode === 'edit') {
2439
+				if ($mode === 'edit') {
2440 2440
 					?>
2441 2441
 					<script>
2442 2442
 						$(document).ready(function(){
@@ -2444,7 +2444,7 @@  discard block
 block discarded – undo
2444 2444
 							var all_tr_extrafields = $("tr.tr_extrafield_title");
2445 2445
 							<?php 
2446 2446
 							// Si un extrafield est rempli alors on affiche directement les extrafields
2447
-							if(!$isExtraSelected) {
2447
+							if (!$isExtraSelected) {
2448 2448
 								echo 'all_tr_extrafields.hide();';
2449 2449
 								echo 'var trad = "'.$langs->trans('showExtrafields').'";';
2450 2450
 								echo 'var extra = 0;';
@@ -2483,61 +2483,61 @@  discard block
 block discarded – undo
2483 2483
 			return 1;	
2484 2484
 			
2485 2485
 		}
2486
-		elseif(($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2486
+		elseif (($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2487 2487
 		{
2488 2488
 			$colspan = 4;
2489 2489
 
2490 2490
 			// HTML 5 data for js
2491 2491
 			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2492 2492
 ?>
2493
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2493
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2494 2494
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2495 2495
 					{
2496
-						if($line->qty==99) print 'background:#adadcf';
2497
-						else if($line->qty==98) print 'background:#ddddff;';
2498
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2499
-						else if($line->qty==1) print 'background:#adadcf;';
2500
-						else if($line->qty==2) print 'background:#ddddff;';
2501
-						else if($line->qty==50) print '';
2496
+						if ($line->qty == 99) print 'background:#adadcf';
2497
+						else if ($line->qty == 98) print 'background:#ddddff;';
2498
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
2499
+						else if ($line->qty == 1) print 'background:#adadcf;';
2500
+						else if ($line->qty == 2) print 'background:#ddddff;';
2501
+						else if ($line->qty == 50) print '';
2502 2502
 						else print 'background:#eeeeff;';
2503 2503
 
2504 2504
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2505 2505
 					}
2506 2506
 					else
2507 2507
 					{
2508
-						if($line->qty==99) print 'background:#ddffdd';
2509
-						else if($line->qty==98) print 'background:#ddddff;';
2510
-						else if($line->qty==2) print 'background:#eeeeff; ';
2511
-						else if($line->qty==50) print '';
2512
-						else print 'background:#eeffee;' ;
2508
+						if ($line->qty == 99) print 'background:#ddffdd';
2509
+						else if ($line->qty == 98) print 'background:#ddddff;';
2510
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
2511
+						else if ($line->qty == 50) print '';
2512
+						else print 'background:#eeffee;';
2513 2513
 					}
2514 2514
 
2515 2515
 			?>;">
2516 2516
 
2517
-				<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2517
+				<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
2518 2518
 
2519 2519
 
2520 2520
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2521 2521
 						 {
2522
-							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2522
+							if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2523 2523
 							{
2524
-								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2524
+								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
2525 2525
 
2526 2526
 								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2527
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2527
+								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
2528 2528
 							}
2529 2529
 						 }
2530 2530
 						 else
2531 2531
 						 {
2532
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2533
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2532
+							if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
2533
+							else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2534 2534
 						 }
2535 2535
 
2536 2536
 
2537 2537
 						 // Get display styles and apply them
2538 2538
 						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2539
-						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2540
-						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2539
+						 $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2540
+						 $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2541 2541
 
2542 2542
 						 if (empty($line->label)) {
2543 2543
 							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
@@ -2545,22 +2545,22 @@  discard block
 block discarded – undo
2545 2545
 						 }
2546 2546
 						 else {
2547 2547
 
2548
-							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2548
+							if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2549 2549
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2550 2550
 							}
2551
-							else{
2551
+							else {
2552 2552
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2553 2553
 							}
2554 2554
 
2555 2555
 						 }
2556 2556
 						//if($line->qty>90) print ' : ';
2557
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2557
+						if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2558 2558
 
2559 2559
 			?>
2560 2560
 				</td>
2561 2561
 				 <td colspan="<?php echo $colspan; ?>">
2562 2562
 <?php
2563
-						if(in_array('expeditioncard', $contexts) && $action == 'create')
2563
+						if (in_array('expeditioncard', $contexts) && $action == 'create')
2564 2564
 						{
2565 2565
 							$fk_entrepot = GETPOST('entrepot_id', 'int');
2566 2566
 ?>
@@ -2587,100 +2587,100 @@  discard block
 block discarded – undo
2587 2587
 			$shipment_static = new Expedition($db);
2588 2588
 			$warehousestatic = new Entrepot($db);
2589 2589
 			$extrafieldsline = new ExtraFields($db);
2590
-			$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2590
+			$extralabelslines = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2591 2591
 
2592 2592
 			$colspan = 4;
2593
-			if($object->origin && $object->origin_id > 0) $colspan++;
2594
-			if(! empty($conf->stock->enabled)) $colspan++;
2595
-			if(! empty($conf->productbatch->enabled)) $colspan++;
2596
-			if($object->statut == 0) $colspan++;
2597
-			if($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) $colspan++;
2593
+			if ($object->origin && $object->origin_id > 0) $colspan++;
2594
+			if (!empty($conf->stock->enabled)) $colspan++;
2595
+			if (!empty($conf->productbatch->enabled)) $colspan++;
2596
+			if ($object->statut == 0) $colspan++;
2597
+			if ($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) $colspan++;
2598 2598
 
2599
-			if($object->element == 'delivery') $colspan = 2;
2599
+			if ($object->element == 'delivery') $colspan = 2;
2600 2600
 
2601 2601
 			print '<!-- origin line id = '.$line->origin_line_id.' -->'; // id of order line
2602 2602
 
2603 2603
 			// HTML 5 data for js
2604 2604
 			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2605 2605
 			?>
2606
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2606
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2607 2607
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2608 2608
 					{
2609
-						if($line->qty==99) print 'background:#adadcf';
2610
-						else if($line->qty==98) print 'background:#ddddff;';
2611
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2612
-						else if($line->qty==1) print 'background:#adadcf;';
2613
-						else if($line->qty==2) print 'background:#ddddff;';
2614
-						else if($line->qty==50) print '';
2609
+						if ($line->qty == 99) print 'background:#adadcf';
2610
+						else if ($line->qty == 98) print 'background:#ddddff;';
2611
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
2612
+						else if ($line->qty == 1) print 'background:#adadcf;';
2613
+						else if ($line->qty == 2) print 'background:#ddddff;';
2614
+						else if ($line->qty == 50) print '';
2615 2615
 						else print 'background:#eeeeff;';
2616 2616
 
2617 2617
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2618 2618
 					}
2619 2619
 					else 
2620 2620
 					{
2621
-						if($line->qty==99) print 'background:#ddffdd';
2622
-						else if($line->qty==98) print 'background:#ddddff;';
2623
-						else if($line->qty==2) print 'background:#eeeeff; ';
2624
-						else if($line->qty==50) print '';
2625
-						else print 'background:#eeffee;' ;
2621
+						if ($line->qty == 99) print 'background:#ddffdd';
2622
+						else if ($line->qty == 98) print 'background:#ddddff;';
2623
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
2624
+						else if ($line->qty == 50) print '';
2625
+						else print 'background:#eeffee;';
2626 2626
 					}
2627 2627
 
2628 2628
 			?>;">
2629 2629
 
2630 2630
 			<?php
2631 2631
 			// #
2632
-			if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
2632
+			if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER))
2633 2633
 			{
2634
-				print '<td align="center">'.($i+1).'</td>';
2634
+				print '<td align="center">'.($i + 1).'</td>';
2635 2635
 			}
2636 2636
 			?>
2637 2637
 
2638
-			<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2638
+			<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
2639 2639
 
2640 2640
 
2641 2641
 			if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2642 2642
 			{
2643
-				if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2643
+				if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2644 2644
 				{
2645
-					echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2645
+					echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
2646 2646
 
2647 2647
 					if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2648
-					else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2648
+					else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
2649 2649
 				}
2650 2650
 			}
2651 2651
 			else
2652 2652
 			{
2653
-				if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2654
-				else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2653
+				if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
2654
+				else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2655 2655
 			}
2656 2656
 
2657 2657
 
2658 2658
 			// Get display styles and apply them
2659 2659
 			$titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2660
-			$titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2661
-			$titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2660
+			$titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2661
+			$titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2662 2662
 
2663 2663
 			if (empty($line->label)) {
2664 2664
 				if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2665 2665
 				else print  $line->description;
2666 2666
 			}
2667 2667
 			else {
2668
-				if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2668
+				if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2669 2669
 					print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2670 2670
 				}
2671
-				else{
2671
+				else {
2672 2672
 					print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2673 2673
 				}
2674 2674
 			}
2675 2675
 			//if($line->qty>90) print ' : ';
2676
-			if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2676
+			if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2677 2677
 
2678 2678
 			?>
2679 2679
 				</td>
2680 2680
 				<td colspan="<?php echo $colspan; ?>">&nbsp;</td>
2681 2681
 			<?php
2682 2682
 
2683
-			if ($object->element == 'shipping' && $object->statut == 0 && ! empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2683
+			if ($object->element == 'shipping' && $object->statut == 0 && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2684 2684
 			{
2685 2685
 				print '<td class="linecoldelete nowrap" width="10">';
2686 2686
 
@@ -2689,12 +2689,12 @@  discard block
 block discarded – undo
2689 2689
 					echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=deleteline&amp;lineid='.$line->id.'">'.img_delete().'</a>';
2690 2690
 				}
2691 2691
 
2692
-				if(TSubtotal::isTitle($line) && ($line->fk_prev_id === null) )
2692
+				if (TSubtotal::isTitle($line) && ($line->fk_prev_id === null))
2693 2693
 				{
2694 2694
 					if ((float) DOL_VERSION >= 8.0) {
2695 2695
 						$img_delete = img_delete($langs->trans('deleteWithAllLines'), ' class="pictodelete pictodeleteallline"');
2696 2696
 					} elseif ((float) DOL_VERSION >= 3.8) {
2697
-						$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal',' class="pictodelete" ');
2697
+						$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal', ' class="pictodelete" ');
2698 2698
 					} else {
2699 2699
 						$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
2700 2700
 					}
@@ -2704,7 +2704,7 @@  discard block
 block discarded – undo
2704 2704
 					/* Depuis la 8.0, les icônes "standard" utilisent FontAwesome et sont préconfigurées selon la clé de l'image
2705 2705
 					 * Impossible d'en customiser par exemple la couleur, même en utilisant img_picto() directement
2706 2706
 					 */
2707
-					if((float) DOL_VERSION >= 8.0) {
2707
+					if ((float) DOL_VERSION >= 8.0) {
2708 2708
 						?>
2709 2709
 							<script>
2710 2710
 								$(document).ready(function () {
@@ -2722,11 +2722,11 @@  discard block
 block discarded – undo
2722 2722
 			print "</tr>";
2723 2723
 
2724 2724
 			// Display lines extrafields
2725
-			if ($object->element == 'shipping' && ! empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE) && is_array($extralabelslines) && count($extralabelslines)>0) {
2725
+			if ($object->element == 'shipping' && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE) && is_array($extralabelslines) && count($extralabelslines) > 0) {
2726 2726
 				$line = new ExpeditionLigne($db);
2727 2727
 				$line->fetch_optionals($line->id);
2728 2728
 				print '<tr class="oddeven">';
2729
-				print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan),$i);
2729
+				print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan), $i);
2730 2730
 			}
2731 2731
 
2732 2732
 			return 1;
@@ -2738,20 +2738,20 @@  discard block
 block discarded – undo
2738 2738
 
2739 2739
 	
2740 2740
 	function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) {
2741
-		global $conf,$langs;
2741
+		global $conf, $langs;
2742 2742
 		 
2743 2743
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2744 2744
 		{
2745 2745
 		    
2746
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2746
+		    if ($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2747 2747
 		    {
2748 2748
 		        foreach ($object->lines as $line)
2749 2749
 		        {
2750 2750
 		            // fetch optionals attributes and labels
2751 2751
 		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2752
-		            $extrafields=new ExtraFields($this->db);
2753
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2754
-		            $line->fetch_optionals($line->id,$extralabels);
2752
+		            $extrafields = new ExtraFields($this->db);
2753
+		            $extralabels = $extrafields->fetch_name_optionals_label($object->table_element_line, true);
2754
+		            $line->fetch_optionals($line->id, $extralabels);
2755 2755
 		        }
2756 2756
 		    }
2757 2757
 		    
@@ -2851,23 +2851,23 @@  discard block
 block discarded – undo
2851 2851
 	    $ThtmlData['data-qty']          = 0; //$line->qty;
2852 2852
 	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2853 2853
 	    
2854
-	    if(TSubtotal::isTitle($line)){
2854
+	    if (TSubtotal::isTitle($line)) {
2855 2855
 	        $ThtmlData['data-issubtotal'] = 'title';
2856
-	    }elseif(TSubtotal::isSubtotal($line)){
2856
+	    }elseif (TSubtotal::isSubtotal($line)) {
2857 2857
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2858 2858
 	    }
2859
-	    else{
2859
+	    else {
2860 2860
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2861 2861
 	    }
2862 2862
 	    
2863 2863
 	    
2864 2864
 	    // Change or add data  from hooks
2865
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2865
+	    $parameters = array_replace($parameters, array('ThtmlData' => $ThtmlData));
2866 2866
 	    
2867 2867
 	    // hook 
2868
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2868
+	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2869 2869
 	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2870
-	    if ($reshook>0)
2870
+	    if ($reshook > 0)
2871 2871
 	    {
2872 2872
 	        $ThtmlData = $hookmanager->resArray;
2873 2873
 	    }
@@ -2880,14 +2880,14 @@  discard block
 block discarded – undo
2880 2880
 	function implodeHtmlData($ThtmlData = array())
2881 2881
 	{
2882 2882
 	    $data = '';
2883
-	    foreach($ThtmlData as $k => $h )
2883
+	    foreach ($ThtmlData as $k => $h)
2884 2884
 	    {
2885
-	        if(is_array($h))
2885
+	        if (is_array($h))
2886 2886
 	        {
2887 2887
 	            $h = json_encode($h);
2888 2888
 	        }
2889 2889
 	        
2890
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2890
+	        $data .= $k.'="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2891 2891
 	    }
2892 2892
 	    
2893 2893
 	    return $data;
@@ -2895,26 +2895,26 @@  discard block
 block discarded – undo
2895 2895
 	
2896 2896
 	function _ajax_block_order_js($object)
2897 2897
 	{
2898
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2898
+	    global $conf, $tagidfortablednd, $filepath, $langs;
2899 2899
 	    
2900 2900
 	    /*
2901 2901
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2902 2902
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2903 2903
 	     */
2904 2904
 	    
2905
-	    $id=$object->id;
2906
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2907
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2905
+	    $id = $object->id;
2906
+	    $nboflines = (isset($object->lines) ?count($object->lines) : 0);
2907
+	    $forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1;
2908 2908
 	    
2909
-	    $id=$object->id;
2910
-	    $fk_element=$object->fk_element;
2911
-	    $table_element_line=$object->table_element_line;
2912
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2913
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2914
-	    $filepath=(empty($filepath)?'':$filepath);
2909
+	    $id = $object->id;
2910
+	    $fk_element = $object->fk_element;
2911
+	    $table_element_line = $object->table_element_line;
2912
+	    $nboflines = (isset($object->lines) ?count($object->lines) : (empty($nboflines) ? 0 : $nboflines));
2913
+	    $tagidfortablednd = (empty($tagidfortablednd) ? 'tablelines' : $tagidfortablednd);
2914
+	    $filepath = (empty($filepath) ? '' : $filepath);
2915 2915
 	    
2916 2916
 	    
2917
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2917
+	    if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1)
2918 2918
 	    {
2919 2919
 	        
2920 2920
 	        ?>
@@ -2932,7 +2932,7 @@  discard block
 block discarded – undo
2932 2932
 				moveBlockCol.disableSelection(); // prevent selection
2933 2933
 <?php if ($object->statut == 0) { ?>
2934 2934
 				// apply some graphical stuff
2935
-				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png',2);  ?>)');
2935
+				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png', 2); ?>)');
2936 2936
 				moveBlockCol.css("background-repeat","no-repeat");
2937 2937
 				moveBlockCol.css("background-position","center center");
2938 2938
 				moveBlockCol.css("cursor","move");
Please login to merge, or discard this patch.
Braces   +533 added lines, -314 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@  discard block
 block discarded – undo
45 45
 				$value = '';
46 46
 				$sql = 'SELECT content FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text WHERE rowid = '.GETPOST('rowid');
47 47
 				$resql = $this->db->query($sql);
48
-				if ($resql && ($obj = $this->db->fetch_object($resql))) $value = $obj->content;
48
+				if ($resql && ($obj = $this->db->fetch_object($resql))) {
49
+					$value = $obj->content;
50
+				}
49 51
 			}
50 52
 			
51 53
 			?>
@@ -124,8 +126,7 @@  discard block
 block discarded – undo
124 126
 			} elseif($object->element == 'invoice_supplier' )
125 127
 			{
126 128
 			    $createRight = $user->rights->fournisseur->facture->creer;
127
-			}
128
-			elseif($object->element == 'shipping')
129
+			} elseif($object->element == 'shipping')
129 130
 			{
130 131
 				$createRight = true; // No rights management for shipments
131 132
 			}
@@ -133,8 +134,11 @@  discard block
 block discarded – undo
133 134
 			if ($object->statut == 0  && $createRight) {
134 135
 			
135 136
 
136
-				if($object->element=='facture')$idvar = 'facid';
137
-				else $idvar='id';
137
+				if($object->element=='facture') {
138
+					$idvar = 'facid';
139
+				} else {
140
+					$idvar='id';
141
+				}
138 142
 				
139 143
 				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
140 144
 				{
@@ -142,10 +146,11 @@  discard block
 block discarded – undo
142 146
 					
143 147
 					if($action=='add_title_line') {
144 148
 						$title = GETPOST('title');
145
-						if(empty($title)) $title = $langs->trans('title');
149
+						if(empty($title)) {
150
+							$title = $langs->trans('title');
151
+						}
146 152
 						$qty = $level<1 ? 1 : $level ;
147
-					}
148
-					else if($action=='add_free_text') {
153
+					} else if($action=='add_free_text') {
149 154
 						$title = GETPOST('title');
150 155
 
151 156
 						if (empty($title)) {
@@ -157,29 +162,31 @@  discard block
 block discarded – undo
157 162
 								}
158 163
 							}
159 164
 						}
160
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
165
+						if(empty($title)) {
166
+							$title = $langs->trans('subtotalAddLineDescription');
167
+						}
161 168
 						$qty = 50;
162
-					}
163
-					else if($action=='add_subtitle_line') {
169
+					} else if($action=='add_subtitle_line') {
164 170
 						$title = GETPOST('title');
165
-						if(empty($title)) $title = $langs->trans('subtitle');
171
+						if(empty($title)) {
172
+							$title = $langs->trans('subtitle');
173
+						}
166 174
 						$qty = 2;
167
-					}
168
-					else if($action=='add_subtotal_line') {
175
+					} else if($action=='add_subtotal_line') {
169 176
 						$title = $langs->trans('SubSubTotal');
170 177
 						$qty = 98;
171
-					}
172
-					else {
178
+					} else {
173 179
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
174 180
 						$qty = $level ? 100-$level : 99;
175 181
 					}
176 182
 					dol_include_once('/subtotal/class/subtotal.class.php');
177 183
 					
178
-					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
184
+					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) {
185
+						TSubtotal::addSubtotalMissing($object, $qty);
186
+					}
179 187
 					
180 188
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
181
-				}
182
-				else if($action==='ask_deleteallline') {
189
+				} else if($action==='ask_deleteallline') {
183 190
 						$form=new Form($db);
184 191
 
185 192
 						$lineid = GETPOST('lineid','integer');
@@ -202,8 +209,7 @@  discard block
 block discarded – undo
202 209
 					$this->printNewFormat($object, $conf, $langs, $idvar);
203 210
 				}
204 211
 			}
205
-		}
206
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts) || in_array('orderstoinvoicesupplier',$contexts))
212
+		} elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts) || in_array('orderstoinvoicesupplier',$contexts))
207 213
 		{
208 214
 			?>
209 215
 			<script type="text/javascript">
@@ -221,8 +227,13 @@  discard block
 block discarded – undo
221 227
      
222 228
 	function printNewFormat(&$object, &$conf, &$langs, $idvar)
223 229
 	{
224
-		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) return false;
225
-		if ($line->fk_prev_id != null && !empty($line->fk_prev_id)) return false; // Si facture de situation
230
+		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) {
231
+			return false;
232
+		}
233
+		if ($line->fk_prev_id != null && !empty($line->fk_prev_id)) {
234
+			return false;
235
+		}
236
+		// Si facture de situation
226 237
 		?>
227 238
 		 	<script type="text/javascript">
228 239
 				$(document).ready(function() {
@@ -515,8 +526,7 @@  discard block
 block discarded – undo
515 526
 				}
516 527
 				
517 528
 				
518
-			}	
519
-			else{
529
+			} else{
520 530
 				$substitutionarray['line_not_modsubtotal'] = true;
521 531
 				$substitutionarray['line_modsubtotal'] = 0;
522 532
 			}
@@ -574,8 +584,11 @@  discard block
 block discarded – undo
574 584
 		
575 585
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
576 586
 		
577
-		if($object->element=='facture') $idvar = 'facid';
578
-		else $idvar = 'id';
587
+		if($object->element=='facture') {
588
+			$idvar = 'facid';
589
+		} else {
590
+			$idvar = 'id';
591
+		}
579 592
 			
580 593
 		if ($action == 'updateligne' || $action == 'updateline')
581 594
 		{
@@ -605,8 +618,7 @@  discard block
 block discarded – undo
605 618
 				header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id);
606 619
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
607 620
 			}
608
-		}
609
-		else if($action === 'builddoc') {
621
+		} else if($action === 'builddoc') {
610 622
 			
611 623
 			if (
612 624
 				in_array('invoicecard',explode(':',$parameters['context']))
@@ -621,33 +633,27 @@  discard block
 block discarded – undo
621 633
 					$sessname = 'subtotal_hideInnerLines_facture';	
622 634
 					$sessname2 = 'subtotal_hidedetails_facture';
623 635
 					$sessname3 = 'subtotal_hideprices_facture';
624
-				}
625
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
636
+				} elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
626 637
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
627 638
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
628 639
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
629
-				}
630
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
640
+				} elseif(in_array('propalcard',explode(':',$parameters['context']))) {
631 641
 					$sessname = 'subtotal_hideInnerLines_propal';
632 642
 					$sessname2 = 'subtotal_hidedetails_propal';	
633 643
 					$sessname3 = 'subtotal_hideprices_propal';
634
-				}
635
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
644
+				} elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
636 645
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
637 646
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
638 647
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
639
-				}
640
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
648
+				} elseif(in_array('ordercard',explode(':',$parameters['context']))) {
641 649
 					$sessname = 'subtotal_hideInnerLines_commande';
642 650
 					$sessname2 = 'subtotal_hidedetails_commande';	
643 651
 					$sessname3 = 'subtotal_hideprices_commande';
644
-				}
645
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
652
+				} elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
646 653
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
647 654
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
648 655
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
649
-				}
650
-				else {
656
+				} else {
651 657
 					$sessname = 'subtotal_hideInnerLines_unknown';
652 658
 					$sessname2 = 'subtotal_hidedetails_unknown';
653 659
 					$sessname3 = 'subtotal_hideprices_unknown';
@@ -656,15 +662,24 @@  discard block
 block discarded – undo
656 662
 				global $hideprices;
657 663
 				
658 664
 				$hideInnerLines = (int)GETPOST('hideInnerLines');
659
-				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system
665
+				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) {
666
+					$_SESSION[$sessname] = array();
667
+				}
668
+				// prevent old system
660 669
 				$_SESSION[$sessname][$object->id] = $hideInnerLines;		
661 670
 				
662 671
 				$hidedetails= (int)GETPOST('hidedetails');
663
-				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system
672
+				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) {
673
+					$_SESSION[$sessname2] = array();
674
+				}
675
+				// prevent old system
664 676
 				$_SESSION[$sessname2][$object->id] = $hidedetails;
665 677
 				
666 678
 				$hideprices= (int)GETPOST('hideprices');
667
-				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system
679
+				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) {
680
+					$_SESSION[$sessname3] = array();
681
+				}
682
+				// prevent old system
668 683
 				$_SESSION[$sessname3][$object->id] = $hideprices;
669 684
 				
670 685
 				foreach($object->lines as &$line) {
@@ -672,8 +687,7 @@  discard block
 block discarded – undo
672 687
 					    
673 688
                         if($line->qty>=90) {
674 689
                             $line->modsubtotal_total = 1;
675
-                        }
676
-                        else{
690
+                        } else{
677 691
                             $line->modsubtotal_title = 1;
678 692
                         }
679 693
                         
@@ -682,8 +696,7 @@  discard block
 block discarded – undo
682 696
 	        	}
683 697
 	        }
684 698
 			
685
-		}
686
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
699
+		} else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
687 700
 			
688 701
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
689 702
 			
@@ -691,7 +704,9 @@  discard block
 block discarded – undo
691 704
 				/**
692 705
 				 * @var $object Facture
693 706
 				 */
694
-				if($object->element=='facture') $object->deleteline($idLine);
707
+				if($object->element=='facture') {
708
+					$object->deleteline($idLine);
709
+				}
695 710
 				/**
696 711
 				 * @var $object Facture fournisseur
697 712
 				 */
@@ -702,18 +717,25 @@  discard block
 block discarded – undo
702 717
 				/**
703 718
 				 * @var $object Propal
704 719
 				 */
705
-				else if($object->element=='propal') $object->deleteline($idLine);
720
+				else if($object->element=='propal') {
721
+					$object->deleteline($idLine);
722
+				}
706 723
 				/**
707 724
 				 * @var $object Propal Fournisseur
708 725
 				 */
709
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
726
+				else if($object->element=='supplier_proposal') {
727
+					$object->deleteline($idLine);
728
+				}
710 729
 				/**
711 730
 				 * @var $object Commande
712 731
 				 */
713 732
 				else if($object->element=='commande') 
714 733
 				{
715
-					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
716
-					else $object->deleteline($idLine);
734
+					if ((float) DOL_VERSION >= 5.0) {
735
+						$object->deleteline($user, $idLine);
736
+					} else {
737
+						$object->deleteline($idLine);
738
+					}
717 739
 				}
718 740
 				/**
719 741
 				 * @var $object Commande fournisseur
@@ -725,25 +747,32 @@  discard block
 block discarded – undo
725 747
 				/**
726 748
 				 * @var $object Facturerec
727 749
 				 */
728
-				else if($object->element=='facturerec') $object->deleteline($idLine);
750
+				else if($object->element=='facturerec') {
751
+					$object->deleteline($idLine);
752
+				}
729 753
 				/**
730 754
 				 * @var $object Expedition
731 755
 				 */
732
-				else if($object->element=='shipping') $object->deleteline($user, $idLine);
756
+				else if($object->element=='shipping') {
757
+					$object->deleteline($user, $idLine);
758
+				}
733 759
 			}
734 760
 			
735 761
 			header('location:?id='.$object->id);
736 762
 			exit;
737 763
 			
738
-		}
739
-		else if ($action == 'duplicate')
764
+		} else if ($action == 'duplicate')
740 765
 		{
741 766
 			$lineid = GETPOST('lineid', 'int');
742 767
 			$nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true);
743 768
 			
744
-			if ($nbDuplicate > 0) setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
745
-			elseif ($nbDuplicate == 0) setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
746
-			else setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
769
+			if ($nbDuplicate > 0) {
770
+				setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
771
+			} elseif ($nbDuplicate == 0) {
772
+				setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
773
+			} else {
774
+				setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
775
+			}
747 776
 			
748 777
 			header('Location: ?id='.$object->id);
749 778
 			exit;
@@ -761,21 +790,26 @@  discard block
 block discarded – undo
761 790
 		global $conf;
762 791
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && !empty($object->table_element_line) && in_array($object->element, array('commande', 'facture', 'propal')))
763 792
 		{
764
-			if ($object->element == 'commande')
765
-				$obj = new OrderLine($object->db);
766
-			if ($object->element == 'propal')
767
-				$obj = new PropaleLigne($object->db);
768
-			if ($object->element == 'facture')
769
-				$obj = new FactureLigne($object->db);
793
+			if ($object->element == 'commande') {
794
+							$obj = new OrderLine($object->db);
795
+			}
796
+			if ($object->element == 'propal') {
797
+							$obj = new PropaleLigne($object->db);
798
+			}
799
+			if ($object->element == 'facture') {
800
+							$obj = new FactureLigne($object->db);
801
+			}
770 802
 			if (!empty($parameters['fk_element']))
771 803
 			{
772 804
 				
773 805
 				if($obj->fetch($parameters['fk_element'])){
774 806
 					$obj->id= $obj->rowid;
775
-					if (empty($obj->array_options))
776
-						$obj->fetch_optionals();
777
-					if (!empty($obj->array_options['options_subtotal_nc']))
778
-						return 1;
807
+					if (empty($obj->array_options)) {
808
+											$obj->fetch_optionals();
809
+					}
810
+					if (!empty($obj->array_options['options_subtotal_nc'])) {
811
+											return 1;
812
+					}
779 813
 				}
780 814
 			}
781 815
 		}
@@ -833,10 +867,15 @@  discard block
 block discarded – undo
833 867
 		$TTotal_tva = array();
834 868
 		
835 869
 		$sign=1;
836
-		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
870
+		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
871
+			$sign=-1;
872
+		}
837 873
 		
838
-		if (GETPOST('action') == 'builddoc') $builddoc = true;
839
-		else $builddoc = false;
874
+		if (GETPOST('action') == 'builddoc') {
875
+			$builddoc = true;
876
+		} else {
877
+			$builddoc = false;
878
+		}
840 879
 		
841 880
 		dol_include_once('/subtotal/class/subtotal.class.php');
842 881
 
@@ -845,9 +884,12 @@  discard block
 block discarded – undo
845 884
 		foreach($TLineReverse as $l)
846 885
 		{
847 886
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
848
-            if ($l->rang>=$rang) continue;
849
-            if (!empty($title_break) && $title_break->id == $l->id) break;
850
-            elseif (!TSubtotal::isModSubtotalLine($l))
887
+            if ($l->rang>=$rang) {
888
+            	continue;
889
+            }
890
+            if (!empty($title_break) && $title_break->id == $l->id) {
891
+            	break;
892
+            } elseif (!TSubtotal::isModSubtotalLine($l))
851 893
             {
852 894
                 // TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
853 895
                 if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
@@ -869,8 +911,7 @@  discard block
 block discarded – undo
869 911
                         $TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
870 912
                         $total_ttc += $sign * ($l->total_tva / ($l->total_ttc / 100)) * $progress;
871 913
                     }
872
-                }
873
-                else
914
+                } else
874 915
                 {
875 916
                     $total += $l->total_ht;
876 917
                     $total_tva += $l->total_tva;
@@ -879,8 +920,11 @@  discard block
 block discarded – undo
879 920
                 }
880 921
             }
881 922
 		}
882
-		if (!$return_all) return $total;
883
-		else return array($total, $total_tva, $total_ttc, $TTotal_tva);
923
+		if (!$return_all) {
924
+			return $total;
925
+		} else {
926
+			return array($total, $total_tva, $total_ttc, $TTotal_tva);
927
+		}
884 928
 	}
885 929
 
886 930
 	/**
@@ -927,15 +971,18 @@  discard block
 block discarded – undo
927 971
 		}
928 972
 		
929 973
 			
930
-		if($line->qty==99)
931
-			$pdf->SetFillColor(220,220,220);
932
-		elseif ($line->qty==98)
933
-			$pdf->SetFillColor(230,230,230);
934
-		else
935
-			$pdf->SetFillColor(240,240,240);
974
+		if($line->qty==99) {
975
+					$pdf->SetFillColor(220,220,220);
976
+		} elseif ($line->qty==98) {
977
+					$pdf->SetFillColor(230,230,230);
978
+		} else {
979
+					$pdf->SetFillColor(240,240,240);
980
+		}
936 981
 		
937 982
 		$style = 'B';
938
-		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
983
+		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) {
984
+			$style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
985
+		}
939 986
 		
940 987
 		$pdf->SetFont('', $style, 9);
941 988
 		
@@ -977,8 +1024,7 @@  discard block
 block discarded – undo
977 1024
 //					$line->total_tva
978 1025
 //					$line->total
979 1026
 //					$line->total_ttc
980
-				}
981
-				else
1027
+				} else
982 1028
 				{
983 1029
 					//					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
984 1030
 					
@@ -988,17 +1034,22 @@  discard block
 block discarded – undo
988 1034
 
989 1035
                     $line->total_ht = $TInfo[0];
990 1036
 					$line->total = $TInfo[0];
991
-					if (!TSubtotal::isModSubtotalLine($line)) $line->total_tva = $TInfo[1];
1037
+					if (!TSubtotal::isModSubtotalLine($line)) {
1038
+						$line->total_tva = $TInfo[1];
1039
+					}
992 1040
 					$line->total_ttc = $TInfo[2];
993 1041
 				}
994 1042
 			}
995 1043
 
996 1044
 			$pdf->SetXY($pdf->postotalht, $posy);
997
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1045
+			if($set_pagebreak_margin) {
1046
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1047
+			}
998 1048
 			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
999
-		}
1000
-		else{
1001
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1049
+		} else{
1050
+			if($set_pagebreak_margin) {
1051
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1052
+			}
1002 1053
 		}
1003 1054
 		
1004 1055
 		$posy = $posy + $cell_height;
@@ -1030,25 +1081,40 @@  discard block
 block discarded – undo
1030 1081
 		
1031 1082
  
1032 1083
 		$style = ($line->qty==1) ? 'BU' : 'BUI';
1033
-		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
1084
+		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) {
1085
+			$style = $conf->global->SUBTOTAL_TITLE_STYLE;
1086
+		}
1034 1087
 		
1035 1088
 		if($hideInnerLines) {
1036
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
1037
-			else 
1089
+			if($line->qty==1) {
1090
+				$pdf->SetFont('', $style, 9);
1091
+			} else 
1038 1092
 			{
1039
-				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1093
+				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) {
1094
+					$style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1095
+				}
1040 1096
 				$pdf->SetFont('', $style, 9);
1041 1097
 			}
1042
-		}
1043
-		else {
1098
+		} else {
1044 1099
 
1045
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
1046
-			else $pdf->SetFont('', $style, 9);
1100
+			if($line->qty==1) {
1101
+				$pdf->SetFont('', $style, 9);
1102
+			}
1103
+			//TODO if super utile
1104
+			else {
1105
+				$pdf->SetFont('', $style, 9);
1106
+			}
1047 1107
 			
1048 1108
 		}
1049 1109
 		
1050
-		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) $pdf->MultiCell($w, $h, $label, 0, 'L'); // Pas de HTML dans la chaine
1051
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
1110
+		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) {
1111
+			$pdf->MultiCell($w, $h, $label, 0, 'L');
1112
+		}
1113
+		// Pas de HTML dans la chaine
1114
+		else {
1115
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true);
1116
+		}
1117
+		// et maintenant avec du HTML
1052 1118
 		
1053 1119
 		if($description && !$hidedesc) {
1054 1120
 			$posy = $pdf->GetY();
@@ -1072,8 +1138,7 @@  discard block
 block discarded – undo
1072 1138
 		
1073 1139
 		if(is_array($parameters)) {
1074 1140
 			$i = & $parameters['i'];	
1075
-		}
1076
-		else {
1141
+		} else {
1077 1142
 			$i = (int)$parameters;
1078 1143
 		}
1079 1144
 
@@ -1103,17 +1168,14 @@  discard block
 block discarded – undo
1103 1168
 			
1104 1169
 			if((float)DOL_VERSION<=3.6) {
1105 1170
 				return '';
1106
-			}
1107
-			else if((float)DOL_VERSION>=3.8) {
1171
+			} else if((float)DOL_VERSION>=3.8) {
1108 1172
 				return 1;
1109 1173
 			}
1110 1174
 			
1111
-		}
1112
-		elseif(!empty($hideprices)) {
1175
+		} elseif(!empty($hideprices)) {
1113 1176
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1114 1177
 			return 1;
1115
-		}
1116
-		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1178
+		} elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1117 1179
 		{
1118 1180
 			$hideInnerLines = (int)GETPOST('hideInnerLines');
1119 1181
 			$hidedetails = (int)GETPOST('hidedetails');
@@ -1123,12 +1185,20 @@  discard block
 block discarded – undo
1123 1185
 			}
1124 1186
 		}
1125 1187
 		
1126
-		if(is_array($parameters)) $i = & $parameters['i'];
1127
-		else $i = (int)$parameters;
1188
+		if(is_array($parameters)) {
1189
+			$i = & $parameters['i'];
1190
+		} else {
1191
+			$i = (int)$parameters;
1192
+		}
1128 1193
 
1129
-		if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1194
+		if (empty($object->lines[$i])) {
1195
+			return 0;
1196
+		}
1197
+		// hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1130 1198
 		
1131
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1199
+		if(empty($object->lines[$i]->array_options)) {
1200
+			$object->lines[$i]->fetch_optionals();
1201
+		}
1132 1202
 
1133 1203
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1134 1204
 		{
@@ -1145,8 +1215,11 @@  discard block
 block discarded – undo
1145 1215
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1146 1216
 	    global $conf, $hideprices, $hookmanager;
1147 1217
 		
1148
-		if(is_array($parameters)) $i = & $parameters['i'];
1149
-		else $i = (int)$parameters;
1218
+		if(is_array($parameters)) {
1219
+			$i = & $parameters['i'];
1220
+		} else {
1221
+			$i = (int)$parameters;
1222
+		}
1150 1223
 			
1151 1224
 		if($this->isModSubtotalLine($parameters,$object) ){
1152 1225
 			
@@ -1154,13 +1227,11 @@  discard block
 block discarded – undo
1154 1227
 			
1155 1228
 			if((float)DOL_VERSION<=3.6) {
1156 1229
 				return '';
1157
-			}
1158
-			else if((float)DOL_VERSION>=3.8) {
1230
+			} else if((float)DOL_VERSION>=3.8) {
1159 1231
 				return 1;
1160 1232
 			}
1161 1233
 			
1162
-		}
1163
-		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1234
+		} elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1164 1235
 		{
1165 1236
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1166 1237
 			{
@@ -1232,12 +1303,10 @@  discard block
 block discarded – undo
1232 1303
 			$this->error = $hookmanager->error;
1233 1304
 			$this->errors = $hookmanager->errors;
1234 1305
 			return -1;
1235
-		}
1236
-		elseif (empty($reshook))
1306
+		} elseif (empty($reshook))
1237 1307
 		{
1238 1308
 			$this->resprints .= $hookmanager->resprints;
1239
-		}
1240
-		else
1309
+		} else
1241 1310
 		{
1242 1311
 			$this->resprints = $hookmanager->resprints;
1243 1312
 
@@ -1260,14 +1329,16 @@  discard block
 block discarded – undo
1260 1329
 		
1261 1330
 			if((float)DOL_VERSION<=3.6) {
1262 1331
 				return '';
1263
-			}
1264
-			else if((float)DOL_VERSION>=3.8) {
1332
+			} else if((float)DOL_VERSION>=3.8) {
1265 1333
 				return 1;
1266 1334
 			}
1267 1335
 		}
1268 1336
 		
1269
-		if(is_array($parameters)) $i = & $parameters['i'];
1270
-		else $i = (int)$parameters;
1337
+		if(is_array($parameters)) {
1338
+			$i = & $parameters['i'];
1339
+		} else {
1340
+			$i = (int)$parameters;
1341
+		}
1271 1342
 		
1272 1343
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1273 1344
 		{
@@ -1289,14 +1360,16 @@  discard block
 block discarded – undo
1289 1360
 		
1290 1361
 			if((float)DOL_VERSION<=3.6) {
1291 1362
 				return '';
1292
-			}
1293
-			else if((float)DOL_VERSION>=3.8) {
1363
+			} else if((float)DOL_VERSION>=3.8) {
1294 1364
 				return 1;
1295 1365
 			}
1296 1366
 		}
1297 1367
 		
1298
-		if(is_array($parameters)) $i = & $parameters['i'];
1299
-		else $i = (int)$parameters;
1368
+		if(is_array($parameters)) {
1369
+			$i = & $parameters['i'];
1370
+		} else {
1371
+			$i = (int)$parameters;
1372
+		}
1300 1373
 			
1301 1374
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1302 1375
 		{
@@ -1313,8 +1386,11 @@  discard block
 block discarded – undo
1313 1386
 	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1314 1387
 	    global $conf,$hideprices,$hookmanager;
1315 1388
 
1316
-		if(is_array($parameters)) $i = & $parameters['i'];
1317
-		else $i = (int)$parameters;
1389
+		if(is_array($parameters)) {
1390
+			$i = & $parameters['i'];
1391
+		} else {
1392
+			$i = (int)$parameters;
1393
+		}
1318 1394
 
1319 1395
 		if($this->isModSubtotalLine($parameters,$object) ) {
1320 1396
 			$this->resprints = ' ';
@@ -1325,7 +1401,9 @@  discard block
 block discarded – undo
1325 1401
             if(TSubtotal::isSubtotal($line)) {
1326 1402
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1327 1403
 
1328
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1404
+                if(is_object($parentTitle) && empty($parentTitle->array_options)) {
1405
+                	$parentTitle->fetch_optionals();
1406
+                }
1329 1407
                 if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1330 1408
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1331 1409
                     $this->resprints = price($TTotal['total_unit_subprice']);
@@ -1334,8 +1412,7 @@  discard block
 block discarded – undo
1334 1412
 		
1335 1413
 			if((float)DOL_VERSION<=3.6) {
1336 1414
 				return '';
1337
-			}
1338
-			else if((float)DOL_VERSION>=3.8) {
1415
+			} else if((float)DOL_VERSION>=3.8) {
1339 1416
 				return 1;
1340 1417
 			}
1341 1418
 		}
@@ -1380,8 +1457,11 @@  discard block
 block discarded – undo
1380 1457
 	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1381 1458
 	    global $conf,$hideprices,$hookmanager;
1382 1459
 
1383
-        if(is_array($parameters)) $i = & $parameters['i'];
1384
-        else $i = (int) $parameters;
1460
+        if(is_array($parameters)) {
1461
+        	$i = & $parameters['i'];
1462
+        } else {
1463
+        	$i = (int) $parameters;
1464
+        }
1385 1465
 
1386 1466
 		if($this->isModSubtotalLine($parameters,$object) ) {
1387 1467
 			$this->resprints = ' ';
@@ -1392,7 +1472,9 @@  discard block
 block discarded – undo
1392 1472
             if(TSubtotal::isSubtotal($line)) {
1393 1473
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1394 1474
 
1395
-                if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1475
+                if(empty($parentTitle->array_options)) {
1476
+                	$parentTitle->fetch_optionals();
1477
+                }
1396 1478
                 if(! empty($parentTitle->array_options['options_show_reduc'])) {
1397 1479
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1398 1480
                     $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
@@ -1401,12 +1483,10 @@  discard block
 block discarded – undo
1401 1483
 		
1402 1484
 			if((float)DOL_VERSION<=3.6) {
1403 1485
 				return '';
1404
-			}
1405
-			else if((float)DOL_VERSION>=3.8) {
1486
+			} else if((float)DOL_VERSION>=3.8) {
1406 1487
 				return 1;
1407 1488
 			}
1408
-		}
1409
-		elseif (!empty($hideprices)
1489
+		} elseif (!empty($hideprices)
1410 1490
 		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1411 1491
 		        )
1412 1492
 		    {
@@ -1427,14 +1507,16 @@  discard block
 block discarded – undo
1427 1507
 			$this->resprints = ' ';
1428 1508
 			if((float)DOL_VERSION<=3.6) {
1429 1509
 				return '';
1430
-			}
1431
-			else if((float)DOL_VERSION>=3.8) {
1510
+			} else if((float)DOL_VERSION>=3.8) {
1432 1511
 				return 1;
1433 1512
 			}
1434 1513
 		}
1435 1514
 		
1436
-		if(is_array($parameters)) $i = & $parameters['i'];
1437
-		else $i = (int)$parameters;
1515
+		if(is_array($parameters)) {
1516
+			$i = & $parameters['i'];
1517
+		} else {
1518
+			$i = (int)$parameters;
1519
+		}
1438 1520
 			
1439 1521
 		if (!empty($hideprices)
1440 1522
 				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1458,16 +1540,21 @@  discard block
 block discarded – undo
1458 1540
 			
1459 1541
 			if((float)DOL_VERSION<=3.6) {
1460 1542
 				return '';
1461
-			}
1462
-			else if((float)DOL_VERSION>=3.8) {
1543
+			} else if((float)DOL_VERSION>=3.8) {
1463 1544
 				return 1;
1464 1545
 			}
1465 1546
 		}
1466 1547
 		
1467
-		if(is_array($parameters)) $i = & $parameters['i'];
1468
-		else $i = (int)$parameters;
1548
+		if(is_array($parameters)) {
1549
+			$i = & $parameters['i'];
1550
+		} else {
1551
+			$i = (int)$parameters;
1552
+		}
1469 1553
 		
1470
-		if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1554
+		if (empty($object->lines[$i])) {
1555
+			return 0;
1556
+		}
1557
+		// hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1471 1558
 
1472 1559
 		$object->lines[$i]->fetch_optionals();
1473 1560
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1513,14 +1600,16 @@  discard block
 block discarded – undo
1513 1600
 			$this->resprints = ' ';
1514 1601
 			if((float)DOL_VERSION<=3.6) {
1515 1602
 				return '';
1516
-			}
1517
-			else if((float)DOL_VERSION>=3.8) {
1603
+			} else if((float)DOL_VERSION>=3.8) {
1518 1604
 				return 1;
1519 1605
 			}
1520 1606
 		}
1521 1607
 		
1522
-		if(is_array($parameters)) $i = & $parameters['i'];
1523
-		else $i = (int)$parameters;
1608
+		if(is_array($parameters)) {
1609
+			$i = & $parameters['i'];
1610
+		} else {
1611
+			$i = (int)$parameters;
1612
+		}
1524 1613
 			
1525 1614
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1526 1615
 		{
@@ -1550,7 +1639,9 @@  discard block
 block discarded – undo
1550 1639
 				}
1551 1640
 			}
1552 1641
 			
1553
-			if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1642
+			if (!empty($TLineTitle)) {
1643
+				$TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1644
+			}
1554 1645
 		}
1555 1646
 		
1556 1647
 	}
@@ -1564,8 +1655,12 @@  discard block
 block discarded – undo
1564 1655
 		$j=0;
1565 1656
 		foreach ($TLineTitle as $k => &$line)
1566 1657
 		{
1567
-			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
1568
-			if (!empty($line_reference) && $line->qty <= $line_reference->qty) break;
1658
+			if (!empty($line_reference) && $line->rang <= $line_reference->rang) {
1659
+				continue;
1660
+			}
1661
+			if (!empty($line_reference) && $line->qty <= $line_reference->qty) {
1662
+				break;
1663
+			}
1569 1664
 			
1570 1665
 			if ($line->qty == $level)
1571 1666
 			{
@@ -1599,7 +1694,9 @@  discard block
 block discarded – undo
1599 1694
 		
1600 1695
 		$hidedetails = (int)GETPOST('hidedetails');
1601 1696
 		
1602
-		if(empty($hidedetails)) return false;
1697
+		if(empty($hidedetails)) {
1698
+			return false;
1699
+		}
1603 1700
 		
1604 1701
 		// TODO can't add VAT to document without lines... :-/
1605 1702
 		
@@ -1627,7 +1724,9 @@  discard block
 block discarded – undo
1627 1724
         foreach($object->lines as $k => &$l) {
1628 1725
             if(TSubtotal::isSubtotal($l)) {
1629 1726
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1630
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1727
+                if(is_object($parentTitle) && empty($parentTitle->array_options)) {
1728
+                	$parentTitle->fetch_optionals();
1729
+                }
1631 1730
                 if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_reduc'])) {
1632 1731
                     $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1633 1732
                 }
@@ -1671,7 +1770,9 @@  discard block
 block discarded – undo
1671 1770
 						
1672 1771
 						$TInfo = $this->getTotalLineFromObject($object, $line, '', 1);
1673 1772
 
1674
-						if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TInfo[3];
1773
+						if (TSubtotal::getNiveau($line) == 1) {
1774
+							$line->TTotal_tva = $TInfo[3];
1775
+						}
1675 1776
 						$line->total_ht = $TInfo[0];
1676 1777
 						$line->total_tva = $TInfo[1];
1677 1778
 						$line->total = $line->total_ht;
@@ -1735,8 +1836,7 @@  discard block
 block discarded – undo
1735 1836
 				    }
1736 1837
 				    
1737 1838
 					
1738
-				}
1739
-				elseif ($hidedetails)
1839
+				} elseif ($hidedetails)
1740 1840
 				{
1741 1841
 					$TLines[] = $line; //Cas où je cache uniquement les prix des produits	
1742 1842
 				}
@@ -1807,13 +1907,17 @@  discard block
 block discarded – undo
1807 1907
 				
1808 1908
 				if(!empty($hideprices)) {
1809 1909
 					foreach($object->lines as &$line) {
1810
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1910
+						if($line->fk_product_type!=9) {
1911
+							$line->fk_parent_line = -1;
1912
+						}
1811 1913
 					}
1812 1914
 				}
1813 1915
 			
1814 1916
 				$line = &$object->lines[$i];
1815 1917
 
1816
-				if($object->element == 'delivery' && ! empty($object->commande->expeditions[$line->fk_origin_line])) unset($object->commande->expeditions[$line->fk_origin_line]);
1918
+				if($object->element == 'delivery' && ! empty($object->commande->expeditions[$line->fk_origin_line])) {
1919
+					unset($object->commande->expeditions[$line->fk_origin_line]);
1920
+				}
1817 1921
 
1818 1922
 				if($line->info_bits>0) { // PAGE BREAK
1819 1923
 					$pdf->addPage();
@@ -1829,7 +1933,9 @@  discard block
 block discarded – undo
1829 1933
 				}
1830 1934
 
1831 1935
 				if($line->qty>90) {
1832
-					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1936
+					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) {
1937
+						$label .= ' '.$this->getTitle($object, $line);
1938
+					}
1833 1939
 					
1834 1940
 					$pageBefore = $pdf->getPage();
1835 1941
 					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
@@ -1867,8 +1973,7 @@  discard block
 block discarded – undo
1867 1973
 				
1868 1974
 					$posy = $pdf->GetY();
1869 1975
 					return 1;
1870
-				}	
1871
-				else if ($line->qty < 10) {
1976
+				} else if ($line->qty < 10) {
1872 1977
 					$pageBefore = $pdf->getPage();
1873 1978
 
1874 1979
 					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
@@ -1898,8 +2003,7 @@  discard block
 block discarded – undo
1898 2003
 //	if($line->rowid==47) exit;
1899 2004
 			
1900 2005
 			return 0;
1901
-		}
1902
-		elseif (empty($object->lines[$parameters['i']]))
2006
+		} elseif (empty($object->lines[$parameters['i']]))
1903 2007
 		{
1904 2008
 			$this->resprints = -1;
1905 2009
 		}
@@ -1932,7 +2036,9 @@  discard block
 block discarded – undo
1932 2036
 		
1933 2037
 		foreach ($object->lines as $line)
1934 2038
 		{
1935
-			if ($line->id == $currentLine->id) break;
2039
+			if ($line->id == $currentLine->id) {
2040
+				break;
2041
+			}
1936 2042
 			
1937 2043
 			$qty_search = 100 - $currentLine->qty;
1938 2044
 			
@@ -1963,7 +2069,9 @@  discard block
 block discarded – undo
1963 2069
 		$var = &$parameters['var'];
1964 2070
 
1965 2071
 		$contexts = explode(':',$parameters['context']);
1966
-		if($parameters['currentcontext'] === 'paiementcard') return 0;
2072
+		if($parameters['currentcontext'] === 'paiementcard') {
2073
+			return 0;
2074
+		}
1967 2075
 		$originline = null;
1968 2076
 
1969 2077
 		$createRight = $user->rights->{$object->element}->creer;
@@ -1971,22 +2079,18 @@  discard block
 block discarded – undo
1971 2079
 		{
1972 2080
 			$object->statut = 0; // hack for facture rec
1973 2081
 			$createRight = $user->rights->facture->creer;
1974
-		}
1975
-		elseif($object->element == 'order_supplier' )
2082
+		} elseif($object->element == 'order_supplier' )
1976 2083
 		{
1977 2084
 		    $createRight = $user->rights->fournisseur->commande->creer;
1978
-		}
1979
-		elseif($object->element == 'invoice_supplier' )
2085
+		} elseif($object->element == 'invoice_supplier' )
1980 2086
 		{
1981 2087
 		    $createRight = $user->rights->fournisseur->facture->creer;
1982
-		}
1983
-		elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
2088
+		} elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
1984 2089
 		{
1985 2090
 			// H4cK 4n0nYm0u$-style : $line n'est pas un objet instancié mais provient d'un fetch_object d'une requête SQL
1986 2091
 			$line->id = $line->rowid;
1987 2092
 			$line->product_type = $line->type;
1988
-		}
1989
-		elseif($object->element == 'shipping' || $object->element == 'delivery')
2093
+		} elseif($object->element == 'shipping' || $object->element == 'delivery')
1990 2094
 		{
1991 2095
 			if(empty($line->origin_line_id) && ! empty($line->fk_origin_line))
1992 2096
 			{
@@ -2006,8 +2110,11 @@  discard block
 block discarded – undo
2006 2110
 
2007 2111
 			$line = $originline;
2008 2112
 		}
2009
- 		if($object->element=='facture')$idvar = 'facid';
2010
-        else $idvar='id';
2113
+ 		if($object->element=='facture') {
2114
+ 			$idvar = 'facid';
2115
+ 		} else {
2116
+        	$idvar='id';
2117
+        }
2011 2118
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
2012 2119
 			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE) && $object->element !== 'invoice_supplier')
2013 2120
             {
@@ -2025,8 +2132,7 @@  discard block
 block discarded – undo
2025 2132
 
2026 2133
             }
2027 2134
 			return 0;
2028
-		}
2029
-		else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) 
2135
+		} else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) 
2030 2136
         {
2031 2137
 
2032 2138
 
@@ -2054,22 +2160,44 @@  discard block
 block discarded – undo
2054 2160
 				<?php
2055 2161
 			}
2056 2162
 			
2057
-			if(empty($line->description)) $line->description = $line->desc;
2163
+			if(empty($line->description)) {
2164
+				$line->description = $line->desc;
2165
+			}
2058 2166
 			
2059 2167
 			$colspan = 5;
2060
-			if($object->element == 'facturerec' ) $colspan = 3;
2061
-			if($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2062
-			if($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
2063
-			if($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2168
+			if($object->element == 'facturerec' ) {
2169
+				$colspan = 3;
2170
+			}
2171
+			if($object->element == 'order_supplier') {
2172
+				(float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2173
+			}
2174
+			if($object->element == 'invoice_supplier') {
2175
+				(float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
2176
+			}
2177
+			if($object->element == 'supplier_proposal') {
2178
+				(float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2179
+			}
2064 2180
 			if(!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
2065 2181
 				$colspan++; // Colonne PU Devise
2066 2182
 			}
2067
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
2068
-			if(!empty($conf->margin->enabled)) $colspan++;
2069
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
2070
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
2071
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
2072
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
2183
+			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) {
2184
+				$colspan++;
2185
+			}
2186
+			if(!empty($conf->margin->enabled)) {
2187
+				$colspan++;
2188
+			}
2189
+			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) {
2190
+				$colspan++;
2191
+			}
2192
+			if(!empty($conf->global->DISPLAY_MARK_RATES)) {
2193
+				$colspan++;
2194
+			}
2195
+			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) {
2196
+				$colspan++;
2197
+			}
2198
+			if(!empty($conf->global->PRODUCT_USE_UNITS)) {
2199
+				$colspan++;
2200
+			}
2073 2201
 					
2074 2202
 			/* Titre */
2075 2203
 			//var_dump($line);
@@ -2082,23 +2210,36 @@  discard block
 block discarded – undo
2082 2210
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2083 2211
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2084 2212
 					{
2085
-						if($line->qty==99) print 'background:#adadcf';
2086
-						else if($line->qty==98) print 'background:#ddddff;';
2087
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2088
-						else if($line->qty==1) print 'background:#adadcf;';
2089
-						else if($line->qty==2) print 'background:#ddddff;';
2090
-						else if($line->qty==50) print '';
2091
-						else print 'background:#eeeeff;';
2213
+						if($line->qty==99) {
2214
+							print 'background:#adadcf';
2215
+						} else if($line->qty==98) {
2216
+							print 'background:#ddddff;';
2217
+						} else if($line->qty<=97 && $line->qty>=91) {
2218
+							print 'background:#eeeeff;';
2219
+						} else if($line->qty==1) {
2220
+							print 'background:#adadcf;';
2221
+						} else if($line->qty==2) {
2222
+							print 'background:#ddddff;';
2223
+						} else if($line->qty==50) {
2224
+							print '';
2225
+						} else {
2226
+							print 'background:#eeeeff;';
2227
+						}
2092 2228
 
2093 2229
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2094
-					}
2095
-					else 
2230
+					} else 
2096 2231
 					{
2097
-						if($line->qty==99) print 'background:#ddffdd';
2098
-						else if($line->qty==98) print 'background:#ddddff;';
2099
-						else if($line->qty==2) print 'background:#eeeeff; ';
2100
-						else if($line->qty==50) print '';
2101
-						else print 'background:#eeffee;' ;
2232
+						if($line->qty==99) {
2233
+							print 'background:#ddffdd';
2234
+						} else if($line->qty==98) {
2235
+							print 'background:#ddddff;';
2236
+						} else if($line->qty==2) {
2237
+							print 'background:#eeeeff; ';
2238
+						} else if($line->qty==50) {
2239
+							print '';
2240
+						} else {
2241
+							print 'background:#eeffee;' ;
2242
+						}
2102 2243
 					}
2103 2244
 
2104 2245
 			?>;">
@@ -2125,13 +2266,11 @@  discard block
 block discarded – undo
2125 2266
 							$qty_displayed = $line->qty;
2126 2267
 							print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
2127 2268
 							
2128
-						}
2129
-						else if (TSubtotal::isSubtotal($line))
2269
+						} else if (TSubtotal::isSubtotal($line))
2130 2270
 						{
2131 2271
 							$qty_displayed = 100 - $line->qty;
2132 2272
 							print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
2133
-						}
2134
-						else
2273
+						} else
2135 2274
 						{
2136 2275
 							$isFreeText = true;
2137 2276
 						}
@@ -2152,9 +2291,13 @@  discard block
 block discarded – undo
2152 2291
 						}
2153 2292
 
2154 2293
 						$readonlyForSituation = '';
2155
-						if (!empty($line->fk_prev_id) && $line->fk_prev_id != null) $readonlyForSituation = 'readonly';
2294
+						if (!empty($line->fk_prev_id) && $line->fk_prev_id != null) {
2295
+							$readonlyForSituation = 'readonly';
2296
+						}
2156 2297
 						
2157
-						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2298
+						if (!$isFreeText) {
2299
+							echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2300
+						}
2158 2301
 						
2159 2302
 						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
2160 2303
 						{
@@ -2162,8 +2305,12 @@  discard block
 block discarded – undo
2162 2305
 							for ($j=1; $j<10; $j++)
2163 2306
 							{
2164 2307
 								if (!empty($readonlyForSituation)) {
2165
-									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2166
-								} else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2308
+									if ($qty_displayed == $j) {
2309
+										$select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2310
+									}
2311
+								} else {
2312
+									$select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2313
+								}
2167 2314
 							}
2168 2315
 							$select .= '</select>&nbsp;';
2169 2316
 
@@ -2183,7 +2330,9 @@  discard block
 block discarded – undo
2183 2330
                             echo '<div>';
2184 2331
                             echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2185 2332
                             echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2186
-                            if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2333
+                            if (empty($readonlyForSituation)) {
2334
+                            	echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2335
+                            }
2187 2336
                             echo '</select>';
2188 2337
                             echo '</div>';
2189 2338
 
@@ -2202,8 +2351,9 @@  discard block
 block discarded – undo
2202 2351
                             echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2203 2352
                             echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2204 2353
                             echo '</div>';
2354
+                        } else if ($isFreeText) {
2355
+                        	echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2205 2356
                         }
2206
-                        else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2207 2357
 						echo '</div>';
2208 2358
 
2209 2359
 						if (TSubtotal::isTitle($line))
@@ -2224,9 +2374,13 @@  discard block
 block discarded – undo
2224 2374
 							$doleditor->Create();
2225 2375
 
2226 2376
 							$TKey = null;
2227
-							if ($line->element == 'propaldet') $TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_PROPALDET);
2228
-							elseif ($line->element == 'commandedet') $TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET);
2229
-							elseif ($line->element == 'facturedet') $TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET);
2377
+							if ($line->element == 'propaldet') {
2378
+								$TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_PROPALDET);
2379
+							} elseif ($line->element == 'commandedet') {
2380
+								$TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET);
2381
+							} elseif ($line->element == 'facturedet') {
2382
+								$TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET);
2383
+							}
2230 2384
 							// TODO ajouter la partie fournisseur
2231 2385
 
2232 2386
 							if (!empty($TKey))
@@ -2246,8 +2400,7 @@  discard block
 block discarded – undo
2246 2400
 							}
2247 2401
 						}
2248 2402
 						
2249
-					}
2250
-					else {
2403
+					} else {
2251 2404
 
2252 2405
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2253 2406
 						 {
@@ -2255,14 +2408,19 @@  discard block
 block discarded – undo
2255 2408
 							{
2256 2409
 								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2257 2410
 								
2258
-								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2259
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2411
+								if (TSubtotal::isTitle($line)) {
2412
+									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2413
+								} else {
2414
+									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2415
+								}
2260 2416
 							}
2261
-						 }
2262
-						 else 
2417
+						 } else 
2263 2418
 						 {
2264
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2265
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2419
+							if($line->qty<=1) {
2420
+								print img_picto('', 'subtotal@subtotal');
2421
+							} else if($line->qty==2) {
2422
+								print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2423
+							}
2266 2424
 						 }
2267 2425
 						 
2268 2426
 						 
@@ -2272,21 +2430,26 @@  discard block
 block discarded – undo
2272 2430
 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2273 2431
 						 
2274 2432
 						 if (empty($line->label)) {
2275
-							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2276
-							else print  $line->description;
2277
-						 } 
2278
-						 else {
2433
+							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2434
+								print  $line->description.' '.$this->getTitle($object, $line);
2435
+							} else {
2436
+								print  $line->description;
2437
+							}
2438
+						 } else {
2279 2439
 
2280 2440
 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2281 2441
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2282
-							}
2283
-							else{
2442
+							} else{
2284 2443
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
2285 2444
 							}
2286 2445
 
2287 2446
 						 } 
2288
-						if($line->qty>90) print ' : ';
2289
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2447
+						if($line->qty>90) {
2448
+							print ' : ';
2449
+						}
2450
+						if($line->info_bits > 0) {
2451
+							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2452
+						}
2290 2453
 
2291 2454
 						 
2292 2455
 
@@ -2329,11 +2492,12 @@  discard block
 block discarded – undo
2329 2492
 						</script>
2330 2493
 						<?php
2331 2494
 						
2332
-					}
2333
-					else{
2495
+					} else{
2334 2496
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2335 2497
 						{
2336
-							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2498
+							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) {
2499
+								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2500
+							}
2337 2501
 						}
2338 2502
 
2339 2503
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
@@ -2423,7 +2587,9 @@  discard block
 block discarded – undo
2423 2587
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2424 2588
 				
2425 2589
 				$colspan+=3; $mode = 'view';
2426
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2590
+				if($action === 'editline' && $line->rowid == GETPOST('lineid')) {
2591
+					$mode = 'edit';
2592
+				}
2427 2593
 				
2428 2594
 				$ex_element = $line->element;
2429 2595
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
@@ -2482,8 +2648,7 @@  discard block
 block discarded – undo
2482 2648
 			
2483 2649
 			return 1;	
2484 2650
 			
2485
-		}
2486
-		elseif(($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2651
+		} elseif(($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2487 2652
 		{
2488 2653
 			$colspan = 4;
2489 2654
 
@@ -2493,23 +2658,36 @@  discard block
 block discarded – undo
2493 2658
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2494 2659
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2495 2660
 					{
2496
-						if($line->qty==99) print 'background:#adadcf';
2497
-						else if($line->qty==98) print 'background:#ddddff;';
2498
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2499
-						else if($line->qty==1) print 'background:#adadcf;';
2500
-						else if($line->qty==2) print 'background:#ddddff;';
2501
-						else if($line->qty==50) print '';
2502
-						else print 'background:#eeeeff;';
2661
+						if($line->qty==99) {
2662
+							print 'background:#adadcf';
2663
+						} else if($line->qty==98) {
2664
+							print 'background:#ddddff;';
2665
+						} else if($line->qty<=97 && $line->qty>=91) {
2666
+							print 'background:#eeeeff;';
2667
+						} else if($line->qty==1) {
2668
+							print 'background:#adadcf;';
2669
+						} else if($line->qty==2) {
2670
+							print 'background:#ddddff;';
2671
+						} else if($line->qty==50) {
2672
+							print '';
2673
+						} else {
2674
+							print 'background:#eeeeff;';
2675
+						}
2503 2676
 
2504 2677
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2505
-					}
2506
-					else
2678
+					} else
2507 2679
 					{
2508
-						if($line->qty==99) print 'background:#ddffdd';
2509
-						else if($line->qty==98) print 'background:#ddddff;';
2510
-						else if($line->qty==2) print 'background:#eeeeff; ';
2511
-						else if($line->qty==50) print '';
2512
-						else print 'background:#eeffee;' ;
2680
+						if($line->qty==99) {
2681
+							print 'background:#ddffdd';
2682
+						} else if($line->qty==98) {
2683
+							print 'background:#ddddff;';
2684
+						} else if($line->qty==2) {
2685
+							print 'background:#eeeeff; ';
2686
+						} else if($line->qty==50) {
2687
+							print '';
2688
+						} else {
2689
+							print 'background:#eeffee;' ;
2690
+						}
2513 2691
 					}
2514 2692
 
2515 2693
 			?>;">
@@ -2523,14 +2701,19 @@  discard block
 block discarded – undo
2523 2701
 							{
2524 2702
 								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2525 2703
 
2526
-								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2527
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2704
+								if (TSubtotal::isTitle($line)) {
2705
+									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2706
+								} else {
2707
+									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2708
+								}
2528 2709
 							}
2529
-						 }
2530
-						 else
2710
+						 } else
2531 2711
 						 {
2532
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2533
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2712
+							if($line->qty<=1) {
2713
+								print img_picto('', 'subtotal@subtotal');
2714
+							} else if($line->qty==2) {
2715
+								print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2716
+							}
2534 2717
 						 }
2535 2718
 
2536 2719
 
@@ -2540,21 +2723,24 @@  discard block
 block discarded – undo
2540 2723
 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2541 2724
 
2542 2725
 						 if (empty($line->label)) {
2543
-							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2544
-							else print  $line->description;
2545
-						 }
2546
-						 else {
2726
+							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2727
+								print  $line->description.' '.$this->getTitle($object, $line);
2728
+							} else {
2729
+								print  $line->description;
2730
+							}
2731
+						 } else {
2547 2732
 
2548 2733
 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2549 2734
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2550
-							}
2551
-							else{
2735
+							} else{
2552 2736
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2553 2737
 							}
2554 2738
 
2555 2739
 						 }
2556 2740
 						//if($line->qty>90) print ' : ';
2557
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2741
+						if($line->info_bits > 0) {
2742
+							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2743
+						}
2558 2744
 
2559 2745
 			?>
2560 2746
 				</td>
@@ -2577,8 +2763,7 @@  discard block
 block discarded – undo
2577 2763
 			</tr>
2578 2764
 <?php
2579 2765
 			return 1;
2580
-		}
2581
-		elseif ($object->element == 'shipping' || $object->element == 'delivery')
2766
+		} elseif ($object->element == 'shipping' || $object->element == 'delivery')
2582 2767
 		{
2583 2768
 			global $form;
2584 2769
 
@@ -2590,13 +2775,25 @@  discard block
 block discarded – undo
2590 2775
 			$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2591 2776
 
2592 2777
 			$colspan = 4;
2593
-			if($object->origin && $object->origin_id > 0) $colspan++;
2594
-			if(! empty($conf->stock->enabled)) $colspan++;
2595
-			if(! empty($conf->productbatch->enabled)) $colspan++;
2596
-			if($object->statut == 0) $colspan++;
2597
-			if($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) $colspan++;
2778
+			if($object->origin && $object->origin_id > 0) {
2779
+				$colspan++;
2780
+			}
2781
+			if(! empty($conf->stock->enabled)) {
2782
+				$colspan++;
2783
+			}
2784
+			if(! empty($conf->productbatch->enabled)) {
2785
+				$colspan++;
2786
+			}
2787
+			if($object->statut == 0) {
2788
+				$colspan++;
2789
+			}
2790
+			if($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) {
2791
+				$colspan++;
2792
+			}
2598 2793
 
2599
-			if($object->element == 'delivery') $colspan = 2;
2794
+			if($object->element == 'delivery') {
2795
+				$colspan = 2;
2796
+			}
2600 2797
 
2601 2798
 			print '<!-- origin line id = '.$line->origin_line_id.' -->'; // id of order line
2602 2799
 
@@ -2606,23 +2803,36 @@  discard block
 block discarded – undo
2606 2803
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2607 2804
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2608 2805
 					{
2609
-						if($line->qty==99) print 'background:#adadcf';
2610
-						else if($line->qty==98) print 'background:#ddddff;';
2611
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2612
-						else if($line->qty==1) print 'background:#adadcf;';
2613
-						else if($line->qty==2) print 'background:#ddddff;';
2614
-						else if($line->qty==50) print '';
2615
-						else print 'background:#eeeeff;';
2806
+						if($line->qty==99) {
2807
+							print 'background:#adadcf';
2808
+						} else if($line->qty==98) {
2809
+							print 'background:#ddddff;';
2810
+						} else if($line->qty<=97 && $line->qty>=91) {
2811
+							print 'background:#eeeeff;';
2812
+						} else if($line->qty==1) {
2813
+							print 'background:#adadcf;';
2814
+						} else if($line->qty==2) {
2815
+							print 'background:#ddddff;';
2816
+						} else if($line->qty==50) {
2817
+							print '';
2818
+						} else {
2819
+							print 'background:#eeeeff;';
2820
+						}
2616 2821
 
2617 2822
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2618
-					}
2619
-					else 
2823
+					} else 
2620 2824
 					{
2621
-						if($line->qty==99) print 'background:#ddffdd';
2622
-						else if($line->qty==98) print 'background:#ddddff;';
2623
-						else if($line->qty==2) print 'background:#eeeeff; ';
2624
-						else if($line->qty==50) print '';
2625
-						else print 'background:#eeffee;' ;
2825
+						if($line->qty==99) {
2826
+							print 'background:#ddffdd';
2827
+						} else if($line->qty==98) {
2828
+							print 'background:#ddddff;';
2829
+						} else if($line->qty==2) {
2830
+							print 'background:#eeeeff; ';
2831
+						} else if($line->qty==50) {
2832
+							print '';
2833
+						} else {
2834
+							print 'background:#eeffee;' ;
2835
+						}
2626 2836
 					}
2627 2837
 
2628 2838
 			?>;">
@@ -2644,14 +2854,19 @@  discard block
 block discarded – undo
2644 2854
 				{
2645 2855
 					echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2646 2856
 
2647
-					if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2648
-					else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2857
+					if (TSubtotal::isTitle($line)) {
2858
+						print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2859
+					} else {
2860
+						print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2861
+					}
2649 2862
 				}
2650
-			}
2651
-			else
2863
+			} else
2652 2864
 			{
2653
-				if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2654
-				else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2865
+				if($line->qty<=1) {
2866
+					print img_picto('', 'subtotal@subtotal');
2867
+				} else if($line->qty==2) {
2868
+					print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2869
+				}
2655 2870
 			}
2656 2871
 
2657 2872
 
@@ -2661,19 +2876,22 @@  discard block
 block discarded – undo
2661 2876
 			$titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2662 2877
 
2663 2878
 			if (empty($line->label)) {
2664
-				if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2665
-				else print  $line->description;
2666
-			}
2667
-			else {
2879
+				if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2880
+					print  $line->description.' '.$this->getTitle($object, $line);
2881
+				} else {
2882
+					print  $line->description;
2883
+				}
2884
+			} else {
2668 2885
 				if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2669 2886
 					print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2670
-				}
2671
-				else{
2887
+				} else{
2672 2888
 					print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2673 2889
 				}
2674 2890
 			}
2675 2891
 			//if($line->qty>90) print ' : ';
2676
-			if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2892
+			if($line->info_bits > 0) {
2893
+				echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2894
+			}
2677 2895
 
2678 2896
 			?>
2679 2897
 				</td>
@@ -2853,10 +3071,9 @@  discard block
 block discarded – undo
2853 3071
 	    
2854 3072
 	    if(TSubtotal::isTitle($line)){
2855 3073
 	        $ThtmlData['data-issubtotal'] = 'title';
2856
-	    }elseif(TSubtotal::isSubtotal($line)){
3074
+	    } elseif(TSubtotal::isSubtotal($line)){
2857 3075
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2858
-	    }
2859
-	    else{
3076
+	    } else{
2860 3077
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2861 3078
 	    }
2862 3079
 	    
@@ -2866,7 +3083,9 @@  discard block
 block discarded – undo
2866 3083
 	    
2867 3084
 	    // hook 
2868 3085
 	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2869
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
3086
+	    if ($reshook < 0) {
3087
+	    	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
3088
+	    }
2870 3089
 	    if ($reshook>0)
2871 3090
 	    {
2872 3091
 	        $ThtmlData = $hookmanager->resArray;
Please login to merge, or discard this patch.