Passed
Pull Request — master (#2)
by
unknown
26:19
created
dolibarr/htdocs/core/modules/societe/mod_codecompta_aquarium.php 1 patch
Braces   +39 added lines, -22 removed lines patch added patch discarded remove patch
@@ -60,8 +60,12 @@  discard block
 block discarded – undo
60 60
 	function __construct()
61 61
 	{
62 62
 	    global $conf;
63
-		if (! isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411';
64
-        if (! isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401';
63
+		if (! isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') {
64
+		    $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411';
65
+		}
66
+        if (! isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') {
67
+            $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401';
68
+        }
65 69
 		$this->prefixcustomeraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER;
66 70
 	    $this->prefixsupplieraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER;
67 71
 	}
@@ -93,9 +97,13 @@  discard block
 block discarded – undo
93 97
 		$texte.=$langs->trans("ModuleCompanyCodeCustomer".$this->name,$s2)."<br>\n";
94 98
 		$texte.=$langs->trans("ModuleCompanyCodeSupplier".$this->name,$s1)."<br>\n";
95 99
 		$texte.="<br>\n";
96
-		if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_SPECIAL').' = '.yn(1)."<br>\n";
100
+		if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) {
101
+		    $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_SPECIAL').' = '.yn(1)."<br>\n";
102
+		}
97 103
 		//if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_ALPHA').' = '.yn($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)."<br>\n";
98
-		if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX))  $texte.=$langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."<br>\n";
104
+		if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) {
105
+		    $texte.=$langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."<br>\n";
106
+		}
99 107
 		$texte.= '</td>';
100 108
 		$texte.= '<td align="left">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
101 109
         $texte.= '</tr></table>';
@@ -146,13 +154,11 @@  discard block
 block discarded – undo
146 154
 		{
147 155
 			$codetouse=(! empty($societe->code_client)?$societe->code_client:'CUSTCODE');
148 156
 			$prefix = $this->prefixcustomeraccountancycode;
149
-		}
150
-		else if ($type == 'supplier')
157
+		} else if ($type == 'supplier')
151 158
 		{
152 159
 			$codetouse=(! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE');
153 160
 			$prefix = $this->prefixsupplieraccountancycode;
154
-		}
155
-		else
161
+		} else
156 162
 		{
157 163
 			$this->error = 'Bad value for parameter type';
158 164
 			return -1;
@@ -161,14 +167,20 @@  discard block
 block discarded – undo
161 167
 		//$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..';
162 168
 
163 169
 		// Remove special char if COMPANY_AQUARIUM_REMOVE_SPECIAL is set to 1 or not set (default)
164
-		if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $codetouse=preg_replace('/([^a-z0-9])/i','',$codetouse);
170
+		if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) {
171
+		    $codetouse=preg_replace('/([^a-z0-9])/i','',$codetouse);
172
+		}
165 173
 		// Remove special alpha if COMPANY_AQUARIUM_REMOVE_ALPHA is set to 1
166
-		if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA))   $codetouse=preg_replace('/([a-z])/i','',$codetouse);
174
+		if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) {
175
+		    $codetouse=preg_replace('/([a-z])/i','',$codetouse);
176
+		}
167 177
 		// Apply a regex replacement pattern on code if COMPANY_AQUARIUM_CLEAN_REGEX is set. Value must be a regex with parenthesis. The part into parenthesis is kept, the rest removed.
168
-		if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX))	// Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..';
178
+		if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) {
179
+		    // Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..';
169 180
 		{
170 181
 			$codetouse=preg_replace('/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.'/','\1\2\3',$codetouse);
171 182
 		}
183
+		}
172 184
 
173 185
 		$codetouse=$prefix.strtoupper($codetouse);
174 186
 
@@ -176,8 +188,7 @@  discard block
 block discarded – undo
176 188
 		if (! $is_dispo)
177 189
 		{
178 190
 			$this->code=$codetouse;
179
-		}
180
-		else
191
+		} else
181 192
 		{
182 193
 			// Pour retour
183 194
 			$this->code=$codetouse;
@@ -199,14 +210,22 @@  discard block
 block discarded – undo
199 210
 	function verif($db, $code, $societe, $type)
200 211
 	{
201 212
 		$sql = "SELECT ";
202
-		if ($type == 'customer') $sql.= "code_compta";
203
-		else if ($type == 'supplier') $sql.= "code_compta_fournisseur";
213
+		if ($type == 'customer') {
214
+		    $sql.= "code_compta";
215
+		} else if ($type == 'supplier') {
216
+		    $sql.= "code_compta_fournisseur";
217
+		}
204 218
 		$sql.= " FROM ".MAIN_DB_PREFIX."societe";
205 219
 		$sql.= " WHERE ";
206
-		if ($type == 'customer') $sql.= "code_compta";
207
-		else if ($type == 'supplier') $sql.= "code_compta_fournisseur";
220
+		if ($type == 'customer') {
221
+		    $sql.= "code_compta";
222
+		} else if ($type == 'supplier') {
223
+		    $sql.= "code_compta_fournisseur";
224
+		}
208 225
 		$sql.= " = '".$db->escape($code)."'";
209
-		if (! empty($societe->id)) $sql.= " AND rowid <> ".$societe->id;
226
+		if (! empty($societe->id)) {
227
+		    $sql.= " AND rowid <> ".$societe->id;
228
+		}
210 229
 
211 230
 		$resql=$db->query($sql);
212 231
 		if ($resql)
@@ -215,14 +234,12 @@  discard block
 block discarded – undo
215 234
 			{
216 235
 				dol_syslog("mod_codecompta_aquarium::verif code '".$code."' available");
217 236
 				return 1;	// Dispo
218
-			}
219
-			else
237
+			} else
220 238
 			{
221 239
 				dol_syslog("mod_codecompta_aquarium::verif code '".$code."' not available");
222 240
 				return 0;	// Non dispo
223 241
 			}
224
-		}
225
-		else
242
+		} else
226 243
 		{
227 244
 			$this->error=$db->error()." sql=".$sql;
228 245
 			return -1;		// Erreur
Please login to merge, or discard this patch.
htdocs/core/modules/security/generate/modGeneratePassStandard.class.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,9 @@
 block discarded – undo
131 131
 	 */
132 132
 	function validatePassword($password)
133 133
 	{
134
-		if (dol_strlen($password) < $this->length) return 0;
134
+		if (dol_strlen($password) < $this->length) {
135
+		    return 0;
136
+		}
135 137
 		return 1;
136 138
 	}
137 139
 }
Please login to merge, or discard this patch.
htdocs/core/modules/security/generate/modGeneratePassPerso.class.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -217,7 +217,7 @@
 block discarded – undo
217 217
 			if($c != $last){
218 218
 				$last = $c;
219 219
 				$count = 0;
220
-			}else{
220
+			} else{
221 221
 				$count++;
222 222
 			}
223 223
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/facture/doc/pdf_sponge.modules.php 1 patch
Braces   +233 added lines, -116 removed lines patch added patch discarded remove patch
@@ -144,7 +144,10 @@  discard block
 block discarded – undo
144 144
 
145 145
 		// Get source company
146 146
 		$this->emetteur=$mysoc;
147
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
147
+		if (empty($this->emetteur->country_code)) {
148
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
149
+		}
150
+		// By default, if was not defined
148 151
 
149 152
 		// Define position of columns
150 153
 		$this->posxdesc=$this->marge_gauche+1; // used for notes ans other stuff
@@ -177,9 +180,13 @@  discard block
 block discarded – undo
177 180
 	    // phpcs:enable
178 181
 	    global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
179 182
 
180
-	    if (! is_object($outputlangs)) $outputlangs=$langs;
183
+	    if (! is_object($outputlangs)) {
184
+	        $outputlangs=$langs;
185
+	    }
181 186
 	    // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
182
-	    if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
187
+	    if (! empty($conf->global->MAIN_USE_FPDF)) {
188
+	        $outputlangs->charset_output='ISO-8859-1';
189
+	    }
183 190
 
184 191
 	    // Translations
185 192
 	    $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
@@ -195,7 +202,9 @@  discard block
 block discarded – undo
195 202
 
196 203
 	        for ($i = 0 ; $i < $nblignes ; $i++)
197 204
 	        {
198
-	            if (empty($object->lines[$i]->fk_product)) continue;
205
+	            if (empty($object->lines[$i]->fk_product)) {
206
+	                continue;
207
+	            }
199 208
 
200 209
 	            $objphoto->fetch($object->lines[$i]->fk_product);
201 210
 	            //var_dump($objphoto->ref);exit;
@@ -203,8 +212,7 @@  discard block
 block discarded – undo
203 212
 	            {
204 213
 	                $pdir[0] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";
205 214
 	                $pdir[1] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
206
-	            }
207
-	            else
215
+	            } else
208 216
 	            {
209 217
 	                $pdir[0] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';				// default
210 218
 	                $pdir[1] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";	// alternative
@@ -219,18 +227,18 @@  discard block
 block discarded – undo
219 227
 
220 228
 	                    foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
221 229
 	                    {
222
-	                        if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
230
+	                        if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
231
+	                            // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
223 232
 	                        {
224 233
 	                            if ($obj['photo_vignette'])
225 234
 	                            {
226 235
 	                                $filename= $obj['photo_vignette'];
227
-	                            }
228
-	                            else
236
+	                        }
237
+	                            } else
229 238
 	                            {
230 239
 	                                $filename=$obj['photo'];
231 240
 	                            }
232
-	                        }
233
-	                        else
241
+	                        } else
234 242
 	                        {
235 243
 	                            $filename=$obj['photo'];
236 244
 	                        }
@@ -242,7 +250,9 @@  discard block
 block discarded – undo
242 250
 	                }
243 251
 	            }
244 252
 
245
-	            if ($realpath && $arephoto) $realpatharray[$i]=$realpath;
253
+	            if ($realpath && $arephoto) {
254
+	                $realpatharray[$i]=$realpath;
255
+	            }
246 256
 	        }
247 257
 	    }
248 258
 
@@ -261,8 +271,7 @@  discard block
 block discarded – undo
261 271
 	        {
262 272
 	            $dir = $conf->facture->dir_output;
263 273
 	            $file = $dir . "/SPECIMEN.pdf";
264
-	        }
265
-	        else
274
+	        } else
266 275
 	        {
267 276
 	            $objectref = dol_sanitizeFileName($object->ref);
268 277
 	            $dir = $conf->facture->dir_output . "/" . $objectref;
@@ -326,7 +335,9 @@  discard block
 block discarded – undo
326 335
 	            $pdf->SetCreator("Dolibarr ".DOL_VERSION);
327 336
 	            $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
328 337
 	            $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
329
-	            if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
338
+	            if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
339
+	                $pdf->SetCompression(false);
340
+	            }
330 341
 
331 342
 	            $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
332 343
 
@@ -347,7 +358,9 @@  discard block
 block discarded – undo
347 358
 
348 359
 	            // New page
349 360
 	            $pdf->AddPage();
350
-	            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
361
+	            if (! empty($tplidx)) {
362
+	                $pdf->useTemplate($tplidx);
363
+	            }
351 364
 	            $pagenb++;
352 365
 
353 366
 	            $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
@@ -359,7 +372,9 @@  discard block
 block discarded – undo
359 372
 	            $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
360 373
 	            $tab_height = 130-$top_shift;
361 374
 	            $tab_height_newpage = 150;
362
-	            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift;
375
+	            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
376
+	                $tab_height_newpage -= $top_shift;
377
+	            }
363 378
 
364 379
 	            // Incoterm
365 380
 	            $height_incoterms = 0;
@@ -394,7 +409,9 @@  discard block
 block discarded – undo
394 409
 	                    $salereparray=$object->thirdparty->getSalesRepresentatives($user);
395 410
 	                    $salerepobj=new User($this->db);
396 411
 	                    $salerepobj->fetch($salereparray[0]['id']);
397
-	                    if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
412
+	                    if (! empty($salerepobj->signature)) {
413
+	                        $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
414
+	                    }
398 415
 	                }
399 416
 	            }
400 417
 
@@ -427,8 +444,12 @@  discard block
 block discarded – undo
427 444
 	                    while ($pagenb < $pageposafternote) {
428 445
 	                        $pdf->AddPage();
429 446
 	                        $pagenb++;
430
-	                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
431
-	                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
447
+	                        if (! empty($tplidx)) {
448
+	                            $pdf->useTemplate($tplidx);
449
+	                        }
450
+	                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
451
+	                            $this->_pagehead($pdf, $object, 0, $outputlangs);
452
+	                        }
432 453
 	                        // $this->_pagefoot($pdf,$object,$outputlangs,1);
433 454
 	                        $pdf->setTopMargin($tab_top_newpage);
434 455
 	                        // The only function to edit the bottom margin of current page to set it.
@@ -444,9 +465,11 @@  discard block
 block discarded – undo
444 465
 
445 466
 	                    $posyafter = $pdf->GetY();
446 467
 
447
-	                    if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)))	// There is no space left for total+free text
468
+	                    if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20))) {
469
+	                        // There is no space left for total+free text
448 470
 	                    {
449 471
 	                        $pdf->AddPage('','',true);
472
+	                    }
450 473
 	                        $pagenb++;
451 474
 	                        $pageposafternote++;
452 475
 	                        $pdf->setPage($pageposafternote);
@@ -468,8 +491,7 @@  discard block
 block discarded – undo
468 491
 	                        if($i>$pageposbeforenote){
469 492
 	                            $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
470 493
 	                            $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note + 1);
471
-	                        }
472
-	                        else{
494
+	                        } else{
473 495
 	                            $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
474 496
 	                            $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1);
475 497
 	                        }
@@ -483,12 +505,15 @@  discard block
 block discarded – undo
483 505
 
484 506
 	                    // apply note frame to last page
485 507
 	                    $pdf->setPage($pageposafternote);
486
-	                    if (! empty($tplidx)) $pdf->useTemplate($tplidx);
487
-	                    if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
508
+	                    if (! empty($tplidx)) {
509
+	                        $pdf->useTemplate($tplidx);
510
+	                    }
511
+	                    if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
512
+	                        $this->_pagehead($pdf, $object, 0, $outputlangs);
513
+	                    }
488 514
 	                    $height_note=$posyafter-$tab_top_newpage;
489 515
 	                    $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1);
490
-	                }
491
-	                else // No pagebreak
516
+	                } else // No pagebreak
492 517
 	                {
493 518
 	                    $pdf->commitTransaction();
494 519
 	                    $posyafter = $pdf->GetY();
@@ -503,8 +528,12 @@  discard block
 block discarded – undo
503 528
 	                        $pagenb++;
504 529
 	                        $pageposafternote++;
505 530
 	                        $pdf->setPage($pageposafternote);
506
-	                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
507
-	                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
531
+	                        if (! empty($tplidx)) {
532
+	                            $pdf->useTemplate($tplidx);
533
+	                        }
534
+	                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
535
+	                            $this->_pagehead($pdf, $object, 0, $outputlangs);
536
+	                        }
508 537
 
509 538
 	                        $posyafter = $tab_top_newpage;
510 539
 	                    }
@@ -512,8 +541,7 @@  discard block
 block discarded – undo
512 541
 
513 542
 	                $tab_height = $tab_height - $height_note;
514 543
 	                $tab_top = $posyafter +6;
515
-	            }
516
-	            else
544
+	            } else
517 545
 	            {
518 546
 	                $height_note=0;
519 547
 	            }
@@ -537,7 +565,9 @@  discard block
 block discarded – undo
537 565
 
538 566
 	                // Define size of image if we need it
539 567
 	                $imglinesize=array();
540
-	                if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
568
+	                if (! empty($realpatharray[$i])) {
569
+	                    $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
570
+	                }
541 571
 
542 572
 	                $pdf->setTopMargin($tab_top_newpage);
543 573
 	                $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
@@ -550,10 +580,14 @@  discard block
 block discarded – undo
550 580
 	                if($this->getColumnStatus('photo'))
551 581
 	                {
552 582
     	                // We start with Photo of product line
553
-    	                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
583
+    	                if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) {
584
+    	                    // If photo too high, we moved completely on new page
554 585
     	                {
555 586
     	                    $pdf->AddPage('','',true);
556
-    	                    if (! empty($tplidx)) $pdf->useTemplate($tplidx);
587
+    	                }
588
+    	                    if (! empty($tplidx)) {
589
+    	                        $pdf->useTemplate($tplidx);
590
+    	                    }
557 591
     	                    $pdf->setPage($pageposbefore+1);
558 592
 
559 593
     	                    $curY = $tab_top_newpage;
@@ -574,9 +608,11 @@  discard block
 block discarded – undo
574 608
     	                $pdf->startTransaction();
575 609
     	                pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
576 610
     	                $pageposafter=$pdf->getPage();
577
-    	                if ($pageposafter > $pageposbefore)	// There is a pagebreak
611
+    	                if ($pageposafter > $pageposbefore) {
612
+    	                    // There is a pagebreak
578 613
     	                {
579 614
     	                    $pdf->rollbackTransaction(true);
615
+    	                }
580 616
     	                    $pageposafter=$pageposbefore;
581 617
     	                    //print $pageposafter.'-'.$pageposbefore;exit;
582 618
     	                    $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -584,22 +620,24 @@  discard block
 block discarded – undo
584 620
     	                    $pageposafter=$pdf->getPage();
585 621
     	                    $posyafter=$pdf->GetY();
586 622
     	                    //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
587
-    	                    if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
623
+    	                    if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
624
+    	                        // There is no space left for total+free text
588 625
     	                    {
589 626
     	                        if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
590 627
     	                        {
591 628
     	                            $pdf->AddPage('','',true);
592
-    	                            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
629
+    	                    }
630
+    	                            if (! empty($tplidx)) {
631
+    	                                $pdf->useTemplate($tplidx);
632
+    	                            }
593 633
     	                            $pdf->setPage($pageposafter+1);
594 634
     	                        }
595
-    	                    }
596
-    	                    else
635
+    	                    } else
597 636
     	                    {
598 637
     	                        // We found a page break
599 638
     	                        $showpricebeforepagebreak=0;
600 639
     	                    }
601
-    	                }
602
-    	                else	// No pagebreak
640
+    	                } else	// No pagebreak
603 641
     	                {
604 642
     	                    $pdf->commitTransaction();
605 643
     	                }
@@ -691,16 +729,24 @@  discard block
 block discarded – undo
691 729
 
692 730
 
693 731
 	                $sign=1;
694
-	                if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
732
+	                if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
733
+	                    $sign=-1;
734
+	                }
695 735
 	                // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
696 736
 	                $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
697
-	                if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation
737
+	                if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) {
738
+	                    // Compute progress from previous situation
698 739
 	                {
699 740
 	                    if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
700
-	                    else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
701 741
 	                } else {
702
-	                    if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne= $sign * $object->lines[$i]->multicurrency_total_tva;
703
-	                    else $tvaligne= $sign * $object->lines[$i]->total_tva;
742
+	                        $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
743
+	                    }
744
+	                } else {
745
+	                    if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) {
746
+	                        $tvaligne= $sign * $object->lines[$i]->multicurrency_total_tva;
747
+	                    } else {
748
+	                        $tvaligne= $sign * $object->lines[$i]->total_tva;
749
+	                    }
704 750
 	                }
705 751
 
706 752
 	                $localtax1ligne=$object->lines[$i]->total_localtax1;
@@ -710,29 +756,43 @@  discard block
 block discarded – undo
710 756
 	                $localtax1_type=$object->lines[$i]->localtax1_type;
711 757
 	                $localtax2_type=$object->lines[$i]->localtax2_type;
712 758
 
713
-	                if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
714
-	                if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
715
-	                if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
759
+	                if ($object->remise_percent) {
760
+	                    $tvaligne-=($tvaligne*$object->remise_percent)/100;
761
+	                }
762
+	                if ($object->remise_percent) {
763
+	                    $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
764
+	                }
765
+	                if ($object->remise_percent) {
766
+	                    $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
767
+	                }
716 768
 
717 769
 	                $vatrate=(string) $object->lines[$i]->tva_tx;
718 770
 
719 771
 	                // Retrieve type from database for backward compatibility with old records
720 772
 	                if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
721
-	                    && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
773
+	                    && (! empty($localtax1_rate) || ! empty($localtax2_rate))) {
774
+	                    // and there is local tax
722 775
 	                {
723 776
 	                    $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0, $object->thirdparty, $mysoc);
777
+	                }
724 778
 	                    $localtax1_type = $localtaxtmp_array[0];
725 779
 	                    $localtax2_type = $localtaxtmp_array[2];
726 780
 	                }
727 781
 
728 782
 	                // retrieve global local tax
729
-	                if ($localtax1_type && $localtax1ligne != 0)
730
-	                    $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
731
-	                    if ($localtax2_type && $localtax2ligne != 0)
732
-	                        $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
783
+	                if ($localtax1_type && $localtax1ligne != 0) {
784
+	                	                    $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
785
+	                }
786
+	                    if ($localtax2_type && $localtax2ligne != 0) {
787
+	                    	                        $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
788
+	                    }
733 789
 
734
-	                        if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
735
-	                        if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
790
+	                        if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
791
+	                            $vatrate.='*';
792
+	                        }
793
+	                        if (! isset($this->tva[$vatrate])) {
794
+	                            $this->tva[$vatrate]=0;
795
+	                        }
736 796
 	                        $this->tva[$vatrate] += $tvaligne;
737 797
 
738 798
 	                        $nexY = max($nexY,$posYAfterImage);
@@ -756,8 +816,7 @@  discard block
 block discarded – undo
756 816
 	                            if ($pagenb == $pageposbeforeprintlines)
757 817
 	                            {
758 818
 	                                $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
759
-	                            }
760
-	                            else
819
+	                            } else
761 820
 	                            {
762 821
 	                                $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
763 822
 	                            }
@@ -765,7 +824,9 @@  discard block
 block discarded – undo
765 824
 	                            $pagenb++;
766 825
 	                            $pdf->setPage($pagenb);
767 826
 	                            $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
768
-	                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
827
+	                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
828
+	                                $this->_pagehead($pdf, $object, 0, $outputlangs);
829
+	                            }
769 830
 	                        }
770 831
 
771 832
 	                        if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
@@ -773,17 +834,20 @@  discard block
 block discarded – undo
773 834
 	                            if ($pagenb == $pageposafter)
774 835
 	                            {
775 836
 	                                $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
776
-	                            }
777
-	                            else
837
+	                            } else
778 838
 	                            {
779 839
 	                                $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
780 840
 	                            }
781 841
 	                            $this->_pagefoot($pdf,$object,$outputlangs,1);
782 842
 	                            // New page
783 843
 	                            $pdf->AddPage();
784
-	                            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
844
+	                            if (! empty($tplidx)) {
845
+	                                $pdf->useTemplate($tplidx);
846
+	                            }
785 847
 	                            $pagenb++;
786
-	                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
848
+	                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
849
+	                                $this->_pagehead($pdf, $object, 0, $outputlangs);
850
+	                            }
787 851
 	                        }
788 852
 	            }
789 853
 
@@ -792,8 +856,7 @@  discard block
 block discarded – undo
792 856
 	            {
793 857
 	                $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
794 858
 	                $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
795
-	            }
796
-	            else
859
+	            } else
797 860
 	            {
798 861
 	                $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
799 862
 	                $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -813,7 +876,9 @@  discard block
 block discarded – undo
813 876
 
814 877
 	            // Pied de page
815 878
 	            $this->_pagefoot($pdf,$object,$outputlangs);
816
-	            if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
879
+	            if (method_exists($pdf,'AliasNbPages')) {
880
+	                $pdf->AliasNbPages();
881
+	            }
817 882
 
818 883
 	            $pdf->Close();
819 884
 
@@ -825,20 +890,19 @@  discard block
 block discarded – undo
825 890
 	            global $action;
826 891
 	            $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
827 892
 
828
-	            if (! empty($conf->global->MAIN_UMASK))
829
-	                @chmod($file, octdec($conf->global->MAIN_UMASK));
893
+	            if (! empty($conf->global->MAIN_UMASK)) {
894
+	            	                @chmod($file, octdec($conf->global->MAIN_UMASK));
895
+	            }
830 896
 
831 897
 	                $this->result = array('fullpath'=>$file);
832 898
 
833 899
 	                return 1;   // No error
834
-	        }
835
-	        else
900
+	        } else
836 901
 	        {
837 902
 	            $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
838 903
 	            return 0;
839 904
 	        }
840
-	    }
841
-	    else
905
+	    } else
842 906
 	    {
843 907
 	        $this->error=$langs->transnoentities("ErrorConstantNotDefined","FAC_OUTPUTDIR");
844 908
 	        return 0;
@@ -860,21 +924,27 @@  discard block
 block discarded – undo
860 924
 		global $conf;
861 925
 
862 926
         $sign=1;
863
-        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
927
+        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
928
+            $sign=-1;
929
+        }
864 930
 
865 931
         $tab3_posx = 120;
866 932
 		$tab3_top = $posy + 8;
867 933
 		$tab3_width = 80;
868 934
 		$tab3_height = 4;
869
-		if ($this->page_largeur < 210) // To work with US executive format
935
+		if ($this->page_largeur < 210) {
936
+		    // To work with US executive format
870 937
 		{
871 938
 			$tab3_posx -= 20;
872 939
 		}
940
+		}
873 941
 
874 942
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
875 943
 
876 944
 		$title=$outputlangs->transnoentities("PaymentsAlreadyDone");
877
-		if ($object->type == 2) $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone");
945
+		if ($object->type == 2) {
946
+		    $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone");
947
+		}
878 948
 
879 949
 		$pdf->SetFont('','', $default_font_size - 3);
880 950
 		$pdf->SetXY($tab3_posx, $tab3_top - 4);
@@ -916,9 +986,13 @@  discard block
 block discarded – undo
916 986
 				$y+=3;
917 987
 				$obj = $this->db->fetch_object($resql);
918 988
 
919
-				if ($obj->type == 2) $text=$outputlangs->trans("CreditNote");
920
-				elseif ($obj->type == 3) $text=$outputlangs->trans("Deposit");
921
-				else $text=$outputlangs->trans("UnknownType");
989
+				if ($obj->type == 2) {
990
+				    $text=$outputlangs->trans("CreditNote");
991
+				} elseif ($obj->type == 3) {
992
+				    $text=$outputlangs->trans("Deposit");
993
+				} else {
994
+				    $text=$outputlangs->trans("UnknownType");
995
+				}
922 996
 
923 997
 				$invoice->fetch($obj->fk_facture_source);
924 998
 
@@ -935,8 +1009,7 @@  discard block
 block discarded – undo
935 1009
 
936 1010
 				$i++;
937 1011
 			}
938
-		}
939
-		else
1012
+		} else
940 1013
 		{
941 1014
 			$this->error=$this->db->lasterror();
942 1015
 			return -1;
@@ -976,8 +1049,7 @@  discard block
 block discarded – undo
976 1049
 
977 1050
 				$i++;
978 1051
 			}
979
-		}
980
-		else
1052
+		} else
981 1053
 		{
982 1054
 			$this->error=$this->db->lasterror();
983 1055
 			return -1;
@@ -1124,7 +1196,10 @@  discard block
 block discarded – undo
1124 1196
 				if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
1125 1197
 				{
1126 1198
 					$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
1127
-					if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
1199
+					if (! empty($object->fk_bank)) {
1200
+					    $bankid=$object->fk_bank;
1201
+					}
1202
+					// For backward compatibility when object->fk_account is forced with object->fk_bank
1128 1203
 					$account = new Account($this->db);
1129 1204
 					$account->fetch($bankid);
1130 1205
 
@@ -1157,7 +1232,9 @@  discard block
 block discarded – undo
1157 1232
 		global $conf,$mysoc;
1158 1233
 
1159 1234
         $sign=1;
1160
-        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
1235
+        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1236
+            $sign=-1;
1237
+        }
1161 1238
 
1162 1239
         $default_font_size = pdf_getPDFFontSize($outputlangs);
1163 1240
 
@@ -1167,10 +1244,12 @@  discard block
 block discarded – undo
1167 1244
 
1168 1245
 		// Tableau total
1169 1246
 		$col1x = 120; $col2x = 170;
1170
-		if ($this->page_largeur < 210) // To work with US executive format
1247
+		if ($this->page_largeur < 210) {
1248
+		    // To work with US executive format
1171 1249
 		{
1172 1250
 			$col2x-=20;
1173 1251
 		}
1252
+		}
1174 1253
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1175 1254
 
1176 1255
 		$useborder=0;
@@ -1197,8 +1276,7 @@  discard block
 block discarded – undo
1197 1276
 			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1198 1277
 			{
1199 1278
 				// Nothing to do
1200
-			}
1201
-			else
1279
+			} else
1202 1280
 			{
1203 1281
 			    // FIXME amount of vat not supported with multicurrency
1204 1282
 
@@ -1207,15 +1285,19 @@  discard block
 block discarded – undo
1207 1285
 				//{
1208 1286
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1209 1287
 					{
1210
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1288
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1289
+						    continue;
1290
+						}
1211 1291
 
1212 1292
 						foreach( $localtax_rate as $tvakey => $tvaval )
1213 1293
 						{
1214
-							if ($tvakey!=0)    // On affiche pas taux 0
1294
+							if ($tvakey!=0) {
1295
+							    // On affiche pas taux 0
1215 1296
 							{
1216 1297
 								//$this->atleastoneratenotnull++;
1217 1298
 
1218 1299
 								$index++;
1300
+							}
1219 1301
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1220 1302
 
1221 1303
 								$tvacompl='';
@@ -1240,17 +1322,21 @@  discard block
 block discarded – undo
1240 1322
 				//{
1241 1323
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1242 1324
 					{
1243
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1325
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1326
+						    continue;
1327
+						}
1244 1328
 
1245 1329
 						foreach( $localtax_rate as $tvakey => $tvaval )
1246 1330
 						{
1247
-							if ($tvakey!=0)    // On affiche pas taux 0
1331
+							if ($tvakey!=0) {
1332
+							    // On affiche pas taux 0
1248 1333
 							{
1249 1334
 								//$this->atleastoneratenotnull++;
1250 1335
 
1251 1336
 
1252 1337
 
1253 1338
 								$index++;
1339
+							}
1254 1340
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1255 1341
 
1256 1342
 								$tvacompl='';
@@ -1291,9 +1377,11 @@  discard block
 block discarded – undo
1291 1377
 
1292 1378
 				foreach($this->tva as $tvakey => $tvaval)
1293 1379
 				{
1294
-					if ($tvakey != 0)    // On affiche pas taux 0
1380
+					if ($tvakey != 0) {
1381
+					    // On affiche pas taux 0
1295 1382
 					{
1296 1383
 						$this->atleastoneratenotnull++;
1384
+					}
1297 1385
 
1298 1386
 						$index++;
1299 1387
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1318,15 +1406,19 @@  discard block
 block discarded – undo
1318 1406
 				//{
1319 1407
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1320 1408
 					{
1321
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1409
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1410
+						    continue;
1411
+						}
1322 1412
 
1323 1413
 						foreach( $localtax_rate as $tvakey => $tvaval )
1324 1414
 						{
1325
-							if ($tvakey != 0)    // On affiche pas taux 0
1415
+							if ($tvakey != 0) {
1416
+							    // On affiche pas taux 0
1326 1417
 							{
1327 1418
 								//$this->atleastoneratenotnull++;
1328 1419
 
1329 1420
 								$index++;
1421
+							}
1330 1422
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1331 1423
 
1332 1424
 								$tvacompl='';
@@ -1350,16 +1442,20 @@  discard block
 block discarded – undo
1350 1442
 				//{
1351 1443
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1352 1444
 					{
1353
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1445
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1446
+						    continue;
1447
+						}
1354 1448
 
1355 1449
 						foreach( $localtax_rate as $tvakey => $tvaval )
1356 1450
 						{
1357 1451
 						    // retrieve global local tax
1358
-							if ($tvakey != 0)    // On affiche pas taux 0
1452
+							if ($tvakey != 0) {
1453
+							    // On affiche pas taux 0
1359 1454
 							{
1360 1455
 								//$this->atleastoneratenotnull++;
1361 1456
 
1362 1457
 								$index++;
1458
+							}
1363 1459
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1364 1460
 
1365 1461
 								$tvacompl='';
@@ -1409,7 +1505,9 @@  discard block
 block discarded – undo
1409 1505
 		$depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
1410 1506
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
1411 1507
 		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1412
-		if ($object->paye) $resteapayer=0;
1508
+		if ($object->paye) {
1509
+		    $resteapayer=0;
1510
+		}
1413 1511
 
1414 1512
 		if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
1415 1513
 		{
@@ -1479,7 +1577,9 @@  discard block
 block discarded – undo
1479 1577
 
1480 1578
 		// Force to disable hidetop and hidebottom
1481 1579
 		$hidebottom=0;
1482
-		if ($hidetop) $hidetop=-1;
1580
+		if ($hidetop) {
1581
+		    $hidetop=-1;
1582
+		}
1483 1583
 
1484 1584
 		$currency = !empty($currency) ? $currency : $conf->currency;
1485 1585
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1495,7 +1595,9 @@  discard block
 block discarded – undo
1495 1595
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1496 1596
 
1497 1597
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1498
-			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));
1598
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1599
+			    $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));
1600
+			}
1499 1601
 		}
1500 1602
 
1501 1603
 		$pdf->SetDrawColor(128,128,128);
@@ -1507,7 +1609,9 @@  discard block
 block discarded – undo
1507 1609
 
1508 1610
 		foreach ($this->cols as $colKey => $colDef)
1509 1611
 		{
1510
-		    if(!$this->getColumnStatus($colKey)) continue;
1612
+		    if(!$this->getColumnStatus($colKey)) {
1613
+		        continue;
1614
+		    }
1511 1615
 
1512 1616
 		    // get title label
1513 1617
 		    $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
@@ -1577,16 +1681,14 @@  discard block
 block discarded – undo
1577 1681
 				{
1578 1682
 				    $height=pdf_getHeightForLogo($logo);
1579 1683
 					$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1580
-				}
1581
-				else
1684
+				} else
1582 1685
 				{
1583 1686
 					$pdf->SetTextColor(200,0,0);
1584 1687
 					$pdf->SetFont('','B',$default_font_size - 2);
1585 1688
 					$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1586 1689
 					$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1587 1690
 				}
1588
-			}
1589
-			else
1691
+			} else
1590 1692
 			{
1591 1693
 				$text=$this->emetteur->name;
1592 1694
 				$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1597,11 +1699,21 @@  discard block
 block discarded – undo
1597 1699
 		$pdf->SetXY($posx,$posy);
1598 1700
 		$pdf->SetTextColor(0,0,60);
1599 1701
 		$title=$outputlangs->transnoentities("PdfInvoiceTitle");
1600
-		if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement");
1601
-		if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir");
1602
-		if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit");
1603
-		if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProForma");
1604
-		if ($this->situationinvoice) $title=$outputlangs->transnoentities("InvoiceSituation");
1702
+		if ($object->type == 1) {
1703
+		    $title=$outputlangs->transnoentities("InvoiceReplacement");
1704
+		}
1705
+		if ($object->type == 2) {
1706
+		    $title=$outputlangs->transnoentities("InvoiceAvoir");
1707
+		}
1708
+		if ($object->type == 3) {
1709
+		    $title=$outputlangs->transnoentities("InvoiceDeposit");
1710
+		}
1711
+		if ($object->type == 4) {
1712
+		    $title=$outputlangs->transnoentities("InvoiceProForma");
1713
+		}
1714
+		if ($this->situationinvoice) {
1715
+		    $title=$outputlangs->transnoentities("InvoiceSituation");
1716
+		}
1605 1717
 		$pdf->MultiCell($w, 3, $title, '', 'R');
1606 1718
 
1607 1719
 		$pdf->SetFont('','B',$default_font_size);
@@ -1724,7 +1836,9 @@  discard block
 block discarded – undo
1724 1836
 			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1725 1837
 			$posy+=$top_shift;
1726 1838
 			$posx=$this->marge_gauche;
1727
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1839
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1840
+			    $posx=$this->page_largeur-$this->marge_droite-80;
1841
+			}
1728 1842
 
1729 1843
 			$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1730 1844
 			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
@@ -1774,11 +1888,16 @@  discard block
 block discarded – undo
1774 1888
 
1775 1889
 			// Show recipient
1776 1890
 			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1777
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1891
+			if ($this->page_largeur < 210) {
1892
+			    $widthrecbox=84;
1893
+			}
1894
+			// To work with US executive format
1778 1895
 			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1779 1896
 			$posy+=$top_shift;
1780 1897
 			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1781
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1898
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1899
+			    $posx=$this->marge_gauche;
1900
+			}
1782 1901
 
1783 1902
 			// Show recipient frame
1784 1903
 			$pdf->SetTextColor(0,0,0);
@@ -2009,12 +2128,10 @@  discard block
 block discarded – undo
2009 2128
 	    if ($reshook < 0)
2010 2129
 	    {
2011 2130
 	        setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2012
-	    }
2013
-	    elseif (empty($reshook))
2131
+	    } elseif (empty($reshook))
2014 2132
 	    {
2015 2133
 	        $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
2016
-	    }
2017
-	    else
2134
+	    } else
2018 2135
 	    {
2019 2136
 	        $this->cols = $hookmanager->resArray;
2020 2137
 	    }
Please login to merge, or discard this patch.
htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php 1 patch
Braces   +46 added lines, -40 removed lines patch added patch discarded remove patch
@@ -98,7 +98,10 @@  discard block
 block discarded – undo
98 98
 
99 99
 		// Recupere emetteur
100 100
 		$this->emetteur=$mysoc;
101
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
101
+		if (! $this->emetteur->country_code) {
102
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
103
+		}
104
+		// Par defaut, si n'etait pas defini
102 105
 	}
103 106
 
104 107
 
@@ -136,11 +139,14 @@  discard block
 block discarded – undo
136 139
 			if (! $tmpdir) {
137 140
 				unset($listofdir[$key]); continue;
138 141
 			}
139
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
140
-			else
142
+			if (! is_dir($tmpdir)) {
143
+			    $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
144
+			} else
141 145
 			{
142 146
 				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
143
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
147
+				if (count($tmpfiles)) {
148
+				    $listoffiles=array_merge($listoffiles,$tmpfiles);
149
+				}
144 150
 			}
145 151
 		}
146 152
 		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
@@ -222,7 +228,9 @@  discard block
 block discarded – undo
222 228
 		$hookmanager->initHooks(array('odtgeneration'));
223 229
 		global $action;
224 230
 
225
-		if (! is_object($outputlangs)) $outputlangs=$langs;
231
+		if (! is_object($outputlangs)) {
232
+		    $outputlangs=$langs;
233
+		}
226 234
 		$sav_charset_output=$outputlangs->charset_output;
227 235
 		$outputlangs->charset_output='UTF-8';
228 236
 
@@ -246,7 +254,9 @@  discard block
 block discarded – undo
246 254
 
247 255
 			$dir = $conf->facture->dir_output;
248 256
 			$objectref = dol_sanitizeFileName($object->ref);
249
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
257
+			if (! preg_match('/specimen/i',$objectref)) {
258
+			    $dir.= "/" . $objectref;
259
+			}
250 260
 			$file = $dir . "/" . $objectref . ".odt";
251 261
 
252 262
 			if (! file_exists($dir))
@@ -273,10 +283,11 @@  discard block
 block discarded – undo
273 283
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
274 284
 				{
275 285
 				    $format=$conf->global->MAIN_DOC_USE_TIMING;
276
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
286
+				    if ($format == '1') {
287
+				        $format='%Y%m%d%H%M%S';
288
+				    }
277 289
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
278
-				}
279
-				else
290
+				} else
280 291
 				{
281 292
 					$filename=$newfiletmp.'.'.$newfileformat;
282 293
 				}
@@ -303,9 +314,9 @@  discard block
 block discarded – undo
303 314
 				$contactobject = null;
304 315
 				if (! empty($usecontact)) {
305 316
 					// On peut utiliser le nom de la societe du contact
306
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))
307
-						$socobject = $object->contact;
308
-					else {
317
+					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
318
+											$socobject = $object->contact;
319
+					} else {
309 320
 						$socobject = $object->thirdparty;
310 321
 						// if we have a BILLING contact and we dont use it as recipient we store the contact object for later use
311 322
 						$contactobject = $object->contact;
@@ -353,8 +364,7 @@  discard block
 block discarded – undo
353 364
 						'DELIMITER_RIGHT' => '}'
354 365
 						)
355 366
 					);
356
-				}
357
-				catch (Exception $e)
367
+				} catch (Exception $e)
358 368
 				{
359 369
 					$this->error=$e->getMessage();
360 370
 					dol_syslog($e->getMessage(), LOG_INFO);
@@ -370,8 +380,7 @@  discard block
 block discarded – undo
370 380
 				// Make substitutions into odt of freetext
371 381
 				try {
372 382
 					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
373
-				}
374
-				catch (OdfException $e)
383
+				} catch (OdfException $e)
375 384
 				{
376 385
 					dol_syslog($e->getMessage(), LOG_INFO);
377 386
 				}
@@ -387,7 +396,9 @@  discard block
 block discarded – undo
387 396
 				$array_other=$this->get_substitutionarray_other($outputlangs);
388 397
 				// retrieve contact information for use in object as contact_xxx tags
389 398
 				$array_thirdparty_contact = array();
390
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
399
+				if ($usecontact && is_object($contactobject)) {
400
+				    $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
401
+				}
391 402
 
392 403
 				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal,$array_other,$array_thirdparty_contact);
393 404
 				complete_substitutions_array($tmparray, $outputlangs, $object);
@@ -400,18 +411,19 @@  discard block
 block discarded – undo
400 411
 				foreach($tmparray as $key=>$value)
401 412
 				{
402 413
 					try {
403
-						if (preg_match('/logo$/',$key)) // Image
414
+						if (preg_match('/logo$/',$key)) {
415
+						    // Image
404 416
 						{
405 417
 							//var_dump($value);exit;
406 418
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
407
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
408
-						}
409
-						else    // Text
419
+						} else {
420
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
421
+							}
422
+						} else    // Text
410 423
 						{
411 424
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
412 425
 						}
413
-					}
414
-					catch (OdfException $e)
426
+					} catch (OdfException $e)
415 427
 					{
416 428
                         dol_syslog($e->getMessage(), LOG_INFO);
417 429
 					}
@@ -422,8 +434,7 @@  discard block
 block discarded – undo
422 434
 					$foundtagforlines = 1;
423 435
 					try {
424 436
 						$listlines = $odfHandler->setSegment('lines');
425
-					}
426
-					catch(OdfException $e)
437
+					} catch(OdfException $e)
427 438
 					{
428 439
 						// We may arrive here if tags for lines not present into template
429 440
 						$foundtagforlines = 0;
@@ -443,12 +454,10 @@  discard block
 block discarded – undo
443 454
 								try
444 455
 								{
445 456
 									$listlines->setVars($key, $val, true, 'UTF-8');
446
-								}
447
-								catch(OdfException $e)
457
+								} catch(OdfException $e)
448 458
 								{
449 459
 									dol_syslog($e->getMessage(), LOG_INFO);
450
-								}
451
-								catch(SegmentException $e)
460
+								} catch(SegmentException $e)
452 461
 								{
453 462
 									dol_syslog($e->getMessage(), LOG_INFO);
454 463
 								}
@@ -457,8 +466,7 @@  discard block
 block discarded – undo
457 466
 						}
458 467
 						$odfHandler->mergeSegment($listlines);
459 468
 					}
460
-				}
461
-				catch(OdfException $e)
469
+				} catch(OdfException $e)
462 470
 				{
463 471
 					$this->error=$e->getMessage();
464 472
 					dol_syslog($this->error, LOG_WARNING);
@@ -471,8 +479,7 @@  discard block
 block discarded – undo
471 479
 				{
472 480
 					try {
473 481
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
474
-					}
475
-					catch(OdfException $e)
482
+					} catch(OdfException $e)
476 483
 					{
477 484
                         dol_syslog($e->getMessage(), LOG_INFO);
478 485
 					}
@@ -486,13 +493,12 @@  discard block
 block discarded – undo
486 493
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
487 494
 					try {
488 495
 						$odfHandler->exportAsAttachedPDF($file);
489
-					}catch (Exception $e){
496
+					} catch (Exception $e){
490 497
 						$this->error=$e->getMessage();
491 498
                         dol_syslog($e->getMessage(), LOG_INFO);
492 499
 						return -1;
493 500
 					}
494
-				}
495
-				else {
501
+				} else {
496 502
 					try {
497 503
 						$odfHandler->saveToDisk($file);
498 504
 					} catch (Exception $e) {
@@ -504,16 +510,16 @@  discard block
 block discarded – undo
504 510
 				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
505 511
 				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
506 512
 
507
-				if (! empty($conf->global->MAIN_UMASK))
508
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
513
+				if (! empty($conf->global->MAIN_UMASK)) {
514
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
515
+				}
509 516
 
510 517
 				$odfHandler=null;	// Destroy object
511 518
 
512 519
 				$this->result = array('fullpath'=>$file);
513 520
 
514 521
 				return 1;   // Success
515
-			}
516
-			else
522
+			} else
517 523
 			{
518 524
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
519 525
 				return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/facture/doc/pdf_crabe.modules.php 1 patch
Braces   +230 added lines, -117 removed lines patch added patch discarded remove patch
@@ -175,7 +175,10 @@  discard block
 block discarded – undo
175 175
 
176 176
 		// Get source company
177 177
 		$this->emetteur=$mysoc;
178
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
178
+		if (empty($this->emetteur->country_code)) {
179
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
180
+		}
181
+		// By default, if was not defined
179 182
 
180 183
 		// Define position of columns
181 184
 		$this->posxdesc=$this->marge_gauche+1;
@@ -185,8 +188,7 @@  discard block
 block discarded – undo
185 188
 			$this->posxup=118;
186 189
 			$this->posxqty=135;
187 190
 			$this->posxunit=151;
188
-		}
189
-		else
191
+		} else
190 192
 		{
191 193
 			$this->posxtva=110;
192 194
 			$this->posxup=126;
@@ -195,11 +197,15 @@  discard block
 block discarded – undo
195 197
 		$this->posxdiscount=162;
196 198
 		$this->posxprogress=126; // Only displayed for situation invoices
197 199
 		$this->postotalht=174;
198
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
200
+		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
201
+		    $this->posxtva=$this->posxup;
202
+		}
199 203
 		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
200
-		if ($this->page_largeur < 210) // To work with US executive format
204
+		if ($this->page_largeur < 210) {
205
+		    // To work with US executive format
201 206
 		{
202 207
 		    $this->posxpicture-=20;
208
+		}
203 209
 		    $this->posxtva-=20;
204 210
 		    $this->posxup-=20;
205 211
 		    $this->posxqty-=20;
@@ -235,9 +241,13 @@  discard block
 block discarded – undo
235 241
         // phpcs:enable
236 242
 		global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
237 243
 
238
-		if (! is_object($outputlangs)) $outputlangs=$langs;
244
+		if (! is_object($outputlangs)) {
245
+		    $outputlangs=$langs;
246
+		}
239 247
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
240
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
248
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
249
+		    $outputlangs->charset_output='ISO-8859-1';
250
+		}
241 251
 
242 252
 		// Load traductions files requiredby by page
243 253
 		$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
@@ -250,7 +260,9 @@  discard block
 block discarded – undo
250 260
 		{
251 261
 			for ($i = 0 ; $i < $nblignes ; $i++)
252 262
 			{
253
-				if (empty($object->lines[$i]->fk_product)) continue;
263
+				if (empty($object->lines[$i]->fk_product)) {
264
+				    continue;
265
+				}
254 266
 
255 267
 				$objphoto = new Product($this->db);
256 268
 				$objphoto->fetch($object->lines[$i]->fk_product);
@@ -267,10 +279,14 @@  discard block
 block discarded – undo
267 279
 					break;
268 280
 				}
269 281
 
270
-				if ($realpath) $realpatharray[$i]=$realpath;
282
+				if ($realpath) {
283
+				    $realpatharray[$i]=$realpath;
284
+				}
271 285
 			}
272 286
 		}
273
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
287
+		if (count($realpatharray) == 0) {
288
+		    $this->posxpicture=$this->posxtva;
289
+		}
274 290
 
275 291
 		if ($conf->facture->dir_output)
276 292
 		{
@@ -285,8 +301,7 @@  discard block
 block discarded – undo
285 301
 			{
286 302
 				$dir = $conf->facture->dir_output;
287 303
 				$file = $dir . "/SPECIMEN.pdf";
288
-			}
289
-			else
304
+			} else
290 305
 			{
291 306
 				$objectref = dol_sanitizeFileName($object->ref);
292 307
 				$dir = $conf->facture->dir_output . "/" . $objectref;
@@ -326,7 +341,9 @@  discard block
 block discarded – undo
326 341
                 $heightforinfotot = 50+(4*$nbpayments);	// Height reserved to output the info and total part and payment part
327 342
 		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
328 343
 	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
329
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
344
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
345
+	                $heightforfooter+= 6;
346
+	            }
330 347
 
331 348
                 if (class_exists('TCPDF'))
332 349
                 {
@@ -351,7 +368,9 @@  discard block
 block discarded – undo
351 368
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
352 369
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
353 370
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
354
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
371
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
372
+				    $pdf->SetCompression(false);
373
+				}
355 374
 
356 375
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
357 376
 
@@ -363,9 +382,11 @@  discard block
 block discarded – undo
363 382
 						$this->atleastonediscount++;
364 383
 					}
365 384
 				}
366
-				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))    // retreive space not used by discount
385
+				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) {
386
+				    // retreive space not used by discount
367 387
 				{
368 388
 					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
389
+				}
369 390
 					$this->posxtva+=($this->postotalht - $this->posxdiscount);
370 391
 					$this->posxup+=($this->postotalht - $this->posxdiscount);
371 392
 					$this->posxqty+=($this->postotalht - $this->posxdiscount);
@@ -391,7 +412,9 @@  discard block
 block discarded – undo
391 412
 
392 413
 				// New page
393 414
 				$pdf->AddPage();
394
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
415
+				if (! empty($tplidx)) {
416
+				    $pdf->useTemplate($tplidx);
417
+				}
395 418
 				$pagenb++;
396 419
 
397 420
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
@@ -433,7 +456,9 @@  discard block
 block discarded – undo
433 456
 						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
434 457
 						$salerepobj=new User($this->db);
435 458
 						$salerepobj->fetch($salereparray[0]['id']);
436
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
459
+						if (! empty($salerepobj->signature)) {
460
+						    $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
461
+						}
437 462
 					}
438 463
 				}
439 464
 				if ($notetoshow)
@@ -469,7 +494,9 @@  discard block
 block discarded – undo
469 494
 
470 495
 					// Define size of image if we need it
471 496
 					$imglinesize=array();
472
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
497
+					if (! empty($realpatharray[$i])) {
498
+					    $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
499
+					}
473 500
 
474 501
 					$pdf->setTopMargin($tab_top_newpage);
475 502
 					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
@@ -480,11 +507,17 @@  discard block
 block discarded – undo
480 507
 					$posYAfterDescription=0;
481 508
 
482 509
 					// We start with Photo of product line
483
-					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
510
+					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) {
511
+					    // If photo too high, we moved completely on new page
484 512
 					{
485 513
 						$pdf->AddPage('','',true);
486
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
487
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
514
+					}
515
+						if (! empty($tplidx)) {
516
+						    $pdf->useTemplate($tplidx);
517
+						}
518
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
519
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
520
+						}
488 521
 						$pdf->setPage($pageposbefore+1);
489 522
 
490 523
 						$curY = $tab_top_newpage;
@@ -505,9 +538,11 @@  discard block
 block discarded – undo
505 538
 					$pdf->startTransaction();
506 539
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX-$progress_width,3,$curX,$curY,$hideref,$hidedesc);
507 540
 					$pageposafter=$pdf->getPage();
508
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
541
+					if ($pageposafter > $pageposbefore) {
542
+					    // There is a pagebreak
509 543
 					{
510 544
 						$pdf->rollbackTransaction(true);
545
+					}
511 546
 						$pageposafter=$pageposbefore;
512 547
 						//print $pageposafter.'-'.$pageposbefore;exit;
513 548
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -515,23 +550,27 @@  discard block
 block discarded – undo
515 550
 						$pageposafter=$pdf->getPage();
516 551
 						$posyafter=$pdf->GetY();
517 552
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
518
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
553
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
554
+						    // There is no space left for total+free text
519 555
 						{
520 556
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
521 557
 							{
522 558
 								$pdf->AddPage('','',true);
523
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
524
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
559
+						}
560
+								if (! empty($tplidx)) {
561
+								    $pdf->useTemplate($tplidx);
562
+								}
563
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
564
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
565
+								}
525 566
 								$pdf->setPage($pageposafter+1);
526 567
 							}
527
-						}
528
-						else
568
+						} else
529 569
 						{
530 570
 							// We found a page break
531 571
 							$showpricebeforepagebreak=0;
532 572
 						}
533
-					}
534
-					else	// No pagebreak
573
+					} else	// No pagebreak
535 574
 					{
536 575
 						$pdf->commitTransaction();
537 576
 					}
@@ -571,12 +610,10 @@  discard block
 block discarded – undo
571 610
 					if ($this->situationinvoice)
572 611
 					{
573 612
 						$pdf->MultiCell($this->posxprogress-$this->posxqty-0.8, 4, $qty, 0, 'R');
574
-					}
575
-					else if($conf->global->PRODUCT_USE_UNITS)
613
+					} else if($conf->global->PRODUCT_USE_UNITS)
576 614
 					{
577 615
 						$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
578
-					}
579
-					else
616
+					} else
580 617
 					{
581 618
 						$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
582 619
 					}
@@ -589,12 +626,10 @@  discard block
 block discarded – undo
589 626
 						if($conf->global->PRODUCT_USE_UNITS)
590 627
 						{
591 628
 							$pdf->MultiCell($this->posxunit-$this->posxprogress-1, 3, $progress, 0, 'R');
592
-						}
593
-						else if ($this->atleastonediscount)
629
+						} else if ($this->atleastonediscount)
594 630
 						{
595 631
 							$pdf->MultiCell($this->posxdiscount-$this->posxprogress-1, 3, $progress, 0, 'R');
596
-						}
597
-						else
632
+						} else
598 633
 						{
599 634
 							$pdf->MultiCell($this->postotalht-$this->posxprogress-1, 3, $progress, 0, 'R');
600 635
 						}
@@ -623,16 +658,24 @@  discard block
 block discarded – undo
623 658
 
624 659
 
625 660
 					$sign=1;
626
-					if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
661
+					if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
662
+					    $sign=-1;
663
+					}
627 664
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
628 665
 					$prev_progress = $object->lines[$i]->get_prev_progress($object->id);
629
-					if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation
666
+					if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) {
667
+					    // Compute progress from previous situation
630 668
 					{
631 669
 						if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
632
-						else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
633 670
 					} else {
634
-						if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne= $sign * $object->lines[$i]->multicurrency_total_tva;
635
-						else $tvaligne= $sign * $object->lines[$i]->total_tva;
671
+						    $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
672
+						}
673
+					} else {
674
+						if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) {
675
+						    $tvaligne= $sign * $object->lines[$i]->multicurrency_total_tva;
676
+						} else {
677
+						    $tvaligne= $sign * $object->lines[$i]->total_tva;
678
+						}
636 679
 					}
637 680
 
638 681
 					$localtax1ligne=$object->lines[$i]->total_localtax1;
@@ -642,32 +685,48 @@  discard block
 block discarded – undo
642 685
 					$localtax1_type=$object->lines[$i]->localtax1_type;
643 686
 					$localtax2_type=$object->lines[$i]->localtax2_type;
644 687
 
645
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
646
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
647
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
688
+					if ($object->remise_percent) {
689
+					    $tvaligne-=($tvaligne*$object->remise_percent)/100;
690
+					}
691
+					if ($object->remise_percent) {
692
+					    $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
693
+					}
694
+					if ($object->remise_percent) {
695
+					    $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
696
+					}
648 697
 
649 698
 					$vatrate=(string) $object->lines[$i]->tva_tx;
650 699
 
651 700
 					// Retrieve type from database for backward compatibility with old records
652 701
 					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
653
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
702
+					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) {
703
+					    // and there is local tax
654 704
 					{
655 705
 						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0, $object->thirdparty, $mysoc);
706
+					}
656 707
 						$localtax1_type = $localtaxtmp_array[0];
657 708
 						$localtax2_type = $localtaxtmp_array[2];
658 709
 					}
659 710
 
660 711
 				    // retrieve global local tax
661
-					if ($localtax1_type && $localtax1ligne != 0)
662
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
663
-					if ($localtax2_type && $localtax2ligne != 0)
664
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
712
+					if ($localtax1_type && $localtax1ligne != 0) {
713
+											$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
714
+					}
715
+					if ($localtax2_type && $localtax2ligne != 0) {
716
+											$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
717
+					}
665 718
 
666
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
667
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
719
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
720
+					    $vatrate.='*';
721
+					}
722
+					if (! isset($this->tva[$vatrate])) {
723
+					    $this->tva[$vatrate]=0;
724
+					}
668 725
 					$this->tva[$vatrate] += $tvaligne;
669 726
 
670
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
727
+					if ($posYAfterImage > $posYAfterDescription) {
728
+					    $nexY=$posYAfterImage;
729
+					}
671 730
 
672 731
 					// Add line
673 732
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
@@ -688,8 +747,7 @@  discard block
 block discarded – undo
688 747
 						if ($pagenb == 1)
689 748
 						{
690 749
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
691
-						}
692
-						else
750
+						} else
693 751
 						{
694 752
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
695 753
 						}
@@ -697,24 +755,29 @@  discard block
 block discarded – undo
697 755
 						$pagenb++;
698 756
 						$pdf->setPage($pagenb);
699 757
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
700
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
758
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
759
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
760
+						}
701 761
 					}
702 762
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
703 763
 					{
704 764
 						if ($pagenb == 1)
705 765
 						{
706 766
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
707
-						}
708
-						else
767
+						} else
709 768
 						{
710 769
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
711 770
 						}
712 771
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
713 772
 						// New page
714 773
 						$pdf->AddPage();
715
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
774
+						if (! empty($tplidx)) {
775
+						    $pdf->useTemplate($tplidx);
776
+						}
716 777
 						$pagenb++;
717
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
778
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
779
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
780
+						}
718 781
 					}
719 782
 				}
720 783
 
@@ -723,8 +786,7 @@  discard block
 block discarded – undo
723 786
 				{
724 787
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
725 788
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
726
-				}
727
-				else
789
+				} else
728 790
 				{
729 791
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
730 792
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -744,7 +806,9 @@  discard block
 block discarded – undo
744 806
 
745 807
 				// Pied de page
746 808
 				$this->_pagefoot($pdf,$object,$outputlangs);
747
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
809
+				if (method_exists($pdf,'AliasNbPages')) {
810
+				    $pdf->AliasNbPages();
811
+				}
748 812
 
749 813
 				$pdf->Close();
750 814
 
@@ -756,20 +820,19 @@  discard block
 block discarded – undo
756 820
 				global $action;
757 821
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
758 822
 
759
-				if (! empty($conf->global->MAIN_UMASK))
760
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
823
+				if (! empty($conf->global->MAIN_UMASK)) {
824
+								@chmod($file, octdec($conf->global->MAIN_UMASK));
825
+				}
761 826
 
762 827
 				$this->result = array('fullpath'=>$file);
763 828
 
764 829
 				return 1;   // No error
765
-			}
766
-			else
830
+			} else
767 831
 			{
768 832
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
769 833
 				return 0;
770 834
 			}
771
-		}
772
-		else
835
+		} else
773 836
 		{
774 837
 			$this->error=$langs->transnoentities("ErrorConstantNotDefined","FAC_OUTPUTDIR");
775 838
 			return 0;
@@ -793,21 +856,27 @@  discard block
 block discarded – undo
793 856
 		global $conf;
794 857
 
795 858
         $sign=1;
796
-        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
859
+        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
860
+            $sign=-1;
861
+        }
797 862
 
798 863
         $tab3_posx = 120;
799 864
 		$tab3_top = $posy + 8;
800 865
 		$tab3_width = 80;
801 866
 		$tab3_height = 4;
802
-		if ($this->page_largeur < 210) // To work with US executive format
867
+		if ($this->page_largeur < 210) {
868
+		    // To work with US executive format
803 869
 		{
804 870
 			$tab3_posx -= 20;
805 871
 		}
872
+		}
806 873
 
807 874
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
808 875
 
809 876
 		$title=$outputlangs->transnoentities("PaymentsAlreadyDone");
810
-		if ($object->type == 2) $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone");
877
+		if ($object->type == 2) {
878
+		    $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone");
879
+		}
811 880
 
812 881
 		$pdf->SetFont('','', $default_font_size - 3);
813 882
 		$pdf->SetXY($tab3_posx, $tab3_top - 4);
@@ -849,10 +918,15 @@  discard block
 block discarded – undo
849 918
 				$y+=3;
850 919
 				$obj = $this->db->fetch_object($resql);
851 920
 
852
-				if ($obj->type == 2) $text=$outputlangs->transnoentities("CreditNote");
853
-				elseif ($obj->type == 3) $text=$outputlangs->transnoentities("Deposit");
854
-				elseif ($obj->type == 0) $text=$outputlangs->transnoentities("ExcessReceived");
855
-				else $text=$outputlangs->transnoentities("UnknownType");
921
+				if ($obj->type == 2) {
922
+				    $text=$outputlangs->transnoentities("CreditNote");
923
+				} elseif ($obj->type == 3) {
924
+				    $text=$outputlangs->transnoentities("Deposit");
925
+				} elseif ($obj->type == 0) {
926
+				    $text=$outputlangs->transnoentities("ExcessReceived");
927
+				} else {
928
+				    $text=$outputlangs->transnoentities("UnknownType");
929
+				}
856 930
 
857 931
 				$invoice->fetch($obj->fk_facture_source);
858 932
 
@@ -869,8 +943,7 @@  discard block
 block discarded – undo
869 943
 
870 944
 				$i++;
871 945
 			}
872
-		}
873
-		else
946
+		} else
874 947
 		{
875 948
 			$this->error=$this->db->lasterror();
876 949
 			return -1;
@@ -910,8 +983,7 @@  discard block
 block discarded – undo
910 983
 
911 984
 				$i++;
912 985
 			}
913
-		}
914
-		else
986
+		} else
915 987
 		{
916 988
 			$this->error=$this->db->lasterror();
917 989
 			return -1;
@@ -1060,7 +1132,10 @@  discard block
 block discarded – undo
1060 1132
 				if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
1061 1133
 				{
1062 1134
 					$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
1063
-					if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
1135
+					if (! empty($object->fk_bank)) {
1136
+					    $bankid=$object->fk_bank;
1137
+					}
1138
+					// For backward compatibility when object->fk_account is forced with object->fk_bank
1064 1139
 					$account = new Account($this->db);
1065 1140
 					$account->fetch($bankid);
1066 1141
 
@@ -1095,7 +1170,9 @@  discard block
 block discarded – undo
1095 1170
 		global $conf,$mysoc;
1096 1171
 
1097 1172
         $sign=1;
1098
-        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
1173
+        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1174
+            $sign=-1;
1175
+        }
1099 1176
 
1100 1177
         $default_font_size = pdf_getPDFFontSize($outputlangs);
1101 1178
 
@@ -1105,10 +1182,12 @@  discard block
 block discarded – undo
1105 1182
 
1106 1183
 		// Tableau total
1107 1184
 		$col1x = 120; $col2x = 170;
1108
-		if ($this->page_largeur < 210) // To work with US executive format
1185
+		if ($this->page_largeur < 210) {
1186
+		    // To work with US executive format
1109 1187
 		{
1110 1188
 			$col2x-=20;
1111 1189
 		}
1190
+		}
1112 1191
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1113 1192
 
1114 1193
 		$useborder=0;
@@ -1135,8 +1214,7 @@  discard block
 block discarded – undo
1135 1214
 			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1136 1215
 			{
1137 1216
 				// Nothing to do
1138
-			}
1139
-			else
1217
+			} else
1140 1218
 			{
1141 1219
 			    // FIXME amount of vat not supported with multicurrency
1142 1220
 
@@ -1145,15 +1223,19 @@  discard block
 block discarded – undo
1145 1223
 				//{
1146 1224
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1147 1225
 					{
1148
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1226
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1227
+						    continue;
1228
+						}
1149 1229
 
1150 1230
 						foreach( $localtax_rate as $tvakey => $tvaval )
1151 1231
 						{
1152
-							if ($tvakey!=0)    // On affiche pas taux 0
1232
+							if ($tvakey!=0) {
1233
+							    // On affiche pas taux 0
1153 1234
 							{
1154 1235
 								//$this->atleastoneratenotnull++;
1155 1236
 
1156 1237
 								$index++;
1238
+							}
1157 1239
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1158 1240
 
1159 1241
 								$tvacompl='';
@@ -1178,17 +1260,21 @@  discard block
 block discarded – undo
1178 1260
 				//{
1179 1261
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1180 1262
 					{
1181
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1263
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1264
+						    continue;
1265
+						}
1182 1266
 
1183 1267
 						foreach( $localtax_rate as $tvakey => $tvaval )
1184 1268
 						{
1185
-							if ($tvakey!=0)    // On affiche pas taux 0
1269
+							if ($tvakey!=0) {
1270
+							    // On affiche pas taux 0
1186 1271
 							{
1187 1272
 								//$this->atleastoneratenotnull++;
1188 1273
 
1189 1274
 
1190 1275
 
1191 1276
 								$index++;
1277
+							}
1192 1278
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1193 1279
 
1194 1280
 								$tvacompl='';
@@ -1229,9 +1315,11 @@  discard block
 block discarded – undo
1229 1315
 
1230 1316
 				foreach($this->tva as $tvakey => $tvaval)
1231 1317
 				{
1232
-					if ($tvakey != 0)    // On affiche pas taux 0
1318
+					if ($tvakey != 0) {
1319
+					    // On affiche pas taux 0
1233 1320
 					{
1234 1321
 						$this->atleastoneratenotnull++;
1322
+					}
1235 1323
 
1236 1324
 						$index++;
1237 1325
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1256,15 +1344,19 @@  discard block
 block discarded – undo
1256 1344
 				//{
1257 1345
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1258 1346
 					{
1259
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1347
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1348
+						    continue;
1349
+						}
1260 1350
 
1261 1351
 						foreach( $localtax_rate as $tvakey => $tvaval )
1262 1352
 						{
1263
-							if ($tvakey != 0)    // On affiche pas taux 0
1353
+							if ($tvakey != 0) {
1354
+							    // On affiche pas taux 0
1264 1355
 							{
1265 1356
 								//$this->atleastoneratenotnull++;
1266 1357
 
1267 1358
 								$index++;
1359
+							}
1268 1360
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1269 1361
 
1270 1362
 								$tvacompl='';
@@ -1288,16 +1380,20 @@  discard block
 block discarded – undo
1288 1380
 				//{
1289 1381
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1290 1382
 					{
1291
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1383
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1384
+						    continue;
1385
+						}
1292 1386
 
1293 1387
 						foreach( $localtax_rate as $tvakey => $tvaval )
1294 1388
 						{
1295 1389
 						    // retrieve global local tax
1296
-							if ($tvakey != 0)    // On affiche pas taux 0
1390
+							if ($tvakey != 0) {
1391
+							    // On affiche pas taux 0
1297 1392
 							{
1298 1393
 								//$this->atleastoneratenotnull++;
1299 1394
 
1300 1395
 								$index++;
1396
+							}
1301 1397
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1302 1398
 
1303 1399
 								$tvacompl='';
@@ -1346,7 +1442,9 @@  discard block
 block discarded – undo
1346 1442
 		$depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
1347 1443
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
1348 1444
 		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1349
-		if ($object->paye) $resteapayer=0;
1445
+		if ($object->paye) {
1446
+		    $resteapayer=0;
1447
+		}
1350 1448
 
1351 1449
 		if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
1352 1450
 		{
@@ -1417,7 +1515,9 @@  discard block
 block discarded – undo
1417 1515
 
1418 1516
 		// Force to disable hidetop and hidebottom
1419 1517
 		$hidebottom=0;
1420
-		if ($hidetop) $hidetop=-1;
1518
+		if ($hidetop) {
1519
+		    $hidetop=-1;
1520
+		}
1421 1521
 
1422 1522
 		$currency = !empty($currency) ? $currency : $conf->currency;
1423 1523
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1433,7 +1533,9 @@  discard block
 block discarded – undo
1433 1533
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1434 1534
 
1435 1535
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1436
-			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1536
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1537
+			    $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1538
+			}
1437 1539
 		}
1438 1540
 
1439 1541
 		$pdf->SetDrawColor(128,128,128);
@@ -1485,12 +1587,10 @@  discard block
 block discarded – undo
1485 1587
 			if($this->situationinvoice)
1486 1588
 			{
1487 1589
 				$pdf->MultiCell($this->posxprogress-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1488
-			}
1489
-			else if($conf->global->PRODUCT_USE_UNITS)
1590
+			} else if($conf->global->PRODUCT_USE_UNITS)
1490 1591
 			{
1491 1592
 				$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1492
-			}
1493
-			else
1593
+			} else
1494 1594
 			{
1495 1595
 				$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1496 1596
 			}
@@ -1506,12 +1606,10 @@  discard block
 block discarded – undo
1506 1606
 				if($conf->global->PRODUCT_USE_UNITS)
1507 1607
 				{
1508 1608
 					$pdf->MultiCell($this->posxunit-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C');
1509
-				}
1510
-				else if ($this->atleastonediscount)
1609
+				} else if ($this->atleastonediscount)
1511 1610
 				{
1512 1611
 					$pdf->MultiCell($this->posxdiscount-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C');
1513
-				}
1514
-				else
1612
+				} else
1515 1613
 				{
1516 1614
 					$pdf->MultiCell($this->postotalht-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C');
1517 1615
 				}
@@ -1604,16 +1702,14 @@  discard block
 block discarded – undo
1604 1702
 				{
1605 1703
 				    $height=pdf_getHeightForLogo($logo);
1606 1704
 					$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1607
-				}
1608
-				else
1705
+				} else
1609 1706
 				{
1610 1707
 					$pdf->SetTextColor(200,0,0);
1611 1708
 					$pdf->SetFont('','B',$default_font_size - 2);
1612 1709
 					$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1613 1710
 					$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1614 1711
 				}
1615
-			}
1616
-			else
1712
+			} else
1617 1713
 			{
1618 1714
 				$text=$this->emetteur->name;
1619 1715
 				$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1624,11 +1720,21 @@  discard block
 block discarded – undo
1624 1720
 		$pdf->SetXY($posx,$posy);
1625 1721
 		$pdf->SetTextColor(0,0,60);
1626 1722
 		$title=$outputlangs->transnoentities("PdfInvoiceTitle");
1627
-		if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement");
1628
-		if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir");
1629
-		if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit");
1630
-		if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProForma");
1631
-		if ($this->situationinvoice) $title=$outputlangs->transnoentities("InvoiceSituation");
1723
+		if ($object->type == 1) {
1724
+		    $title=$outputlangs->transnoentities("InvoiceReplacement");
1725
+		}
1726
+		if ($object->type == 2) {
1727
+		    $title=$outputlangs->transnoentities("InvoiceAvoir");
1728
+		}
1729
+		if ($object->type == 3) {
1730
+		    $title=$outputlangs->transnoentities("InvoiceDeposit");
1731
+		}
1732
+		if ($object->type == 4) {
1733
+		    $title=$outputlangs->transnoentities("InvoiceProForma");
1734
+		}
1735
+		if ($this->situationinvoice) {
1736
+		    $title=$outputlangs->transnoentities("InvoiceSituation");
1737
+		}
1632 1738
 		$pdf->MultiCell($w, 3, $title, '', 'R');
1633 1739
 
1634 1740
 		$pdf->SetFont('','B',$default_font_size);
@@ -1751,7 +1857,9 @@  discard block
 block discarded – undo
1751 1857
 			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1752 1858
 			$posy+=$top_shift;
1753 1859
 			$posx=$this->marge_gauche;
1754
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1860
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1861
+			    $posx=$this->page_largeur-$this->marge_droite-80;
1862
+			}
1755 1863
 
1756 1864
 			$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1757 1865
 			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
@@ -1803,11 +1911,16 @@  discard block
 block discarded – undo
1803 1911
 
1804 1912
 			// Show recipient
1805 1913
 			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1806
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1914
+			if ($this->page_largeur < 210) {
1915
+			    $widthrecbox=84;
1916
+			}
1917
+			// To work with US executive format
1807 1918
 			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1808 1919
 			$posy+=$top_shift;
1809 1920
 			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1810
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1921
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1922
+			    $posx=$this->marge_gauche;
1923
+			}
1811 1924
 
1812 1925
 			// Show recipient frame
1813 1926
 			$pdf->SetTextColor(0,0,0);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/facture/mod_facture_mars.php 1 patch
Braces   +37 added lines, -17 removed lines patch added patch discarded remove patch
@@ -155,10 +155,15 @@  discard block
 block discarded – undo
155 155
 
156 156
 		$prefix=$this->prefixinvoice;
157 157
 
158
-		if ($invoice->type == 1) $prefix=$this->prefixreplacement;
159
-		else if ($invoice->type == 2) $prefix=$this->prefixcreditnote;
160
-		else if ($invoice->type == 3) $prefix=$this->prefixdeposit;
161
-		else $prefix=$this->prefixinvoice;
158
+		if ($invoice->type == 1) {
159
+		    $prefix=$this->prefixreplacement;
160
+		} else if ($invoice->type == 2) {
161
+		    $prefix=$this->prefixcreditnote;
162
+		} else if ($invoice->type == 3) {
163
+		    $prefix=$this->prefixdeposit;
164
+		} else {
165
+		    $prefix=$this->prefixinvoice;
166
+		}
162 167
 
163 168
 		// D'abord on recupere la valeur max
164 169
 		$posindice=8;
@@ -172,18 +177,25 @@  discard block
 block discarded – undo
172 177
 		if ($resql)
173 178
 		{
174 179
 			$obj = $db->fetch_object($resql);
175
-			if ($obj) $max = intval($obj->max);
176
-			else $max=0;
177
-		}
178
-		else
180
+			if ($obj) {
181
+			    $max = intval($obj->max);
182
+			} else {
183
+			    $max=0;
184
+			}
185
+		} else
179 186
 		{
180 187
 			return -1;
181 188
 		}
182 189
 
183 190
 		if ($mode == 'last')
184 191
 		{
185
-    		if ($max >= (pow(10, 4) - 1)) $num=$max;	// If counter > 9999, we do not format on 4 chars, we take number as it is
186
-    		else $num = sprintf("%04s",$max);
192
+    		if ($max >= (pow(10, 4) - 1)) {
193
+    		    $num=$max;
194
+    		}
195
+    		// If counter > 9999, we do not format on 4 chars, we take number as it is
196
+    		else {
197
+    		    $num = sprintf("%04s",$max);
198
+    		}
187 199
 
188 200
             $ref='';
189 201
             $sql = "SELECT ref as ref";
@@ -196,24 +208,32 @@  discard block
 block discarded – undo
196 208
             if ($resql)
197 209
             {
198 210
                 $obj = $db->fetch_object($resql);
199
-                if ($obj) $ref = $obj->ref;
211
+                if ($obj) {
212
+                    $ref = $obj->ref;
213
+                }
214
+            } else {
215
+                dol_print_error($db);
200 216
             }
201
-            else dol_print_error($db);
202 217
 
203 218
             return $ref;
204
-		}
205
-		else if ($mode == 'next')
219
+		} else if ($mode == 'next')
206 220
 		{
207 221
 			$date=$invoice->date;	// This is invoice date (not creation date)
208 222
     		$yymm = strftime("%y%m",$date);
209 223
 
210
-    		if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
211
-    		else $num = sprintf("%04s",$max+1);
224
+    		if ($max >= (pow(10, 4) - 1)) {
225
+    		    $num=$max+1;
226
+    		}
227
+    		// If counter > 9999, we do not format on 4 chars, we take number as it is
228
+    		else {
229
+    		    $num = sprintf("%04s",$max+1);
230
+    		}
212 231
 
213 232
     		dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num);
214 233
     		return $prefix.$yymm."-".$num;
234
+		} else {
235
+		    dol_print_error('','Bad parameter for getNextValue');
215 236
 		}
216
-		else dol_print_error('','Bad parameter for getNextValue');
217 237
 	}
218 238
 
219 239
 	/**
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/facture/mod_facture_mercure.php 1 patch
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -150,10 +150,13 @@  discard block
 block discarded – undo
150 150
         	{
151 151
         		$mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
152 152
         	}
153
+        } else if (is_object($invoice) && $invoice->type == 2) {
154
+            $mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT;
155
+        } else if (is_object($invoice) && $invoice->type == 3) {
156
+            $mask=$conf->global->FACTURE_MERCURE_MASK_DEPOSIT;
157
+        } else {
158
+            $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
153 159
         }
154
-        else if (is_object($invoice) && $invoice->type == 2) $mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT;
155
-        else if (is_object($invoice) && $invoice->type == 3) $mask=$conf->global->FACTURE_MERCURE_MASK_DEPOSIT;
156
-        else $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
157 160
         if (! $mask)
158 161
         {
159 162
             $this->error='NotConfigured';
@@ -168,7 +171,9 @@  discard block
 block discarded – undo
168 171
     	$entity = getEntity('invoicenumber', 1, $invoice);
169 172
 
170 173
     	$numFinal=get_next_value($db,$mask,'facture','ref',$where,$objsoc,$invoice->date,$mode,false,null,$entity);
171
-    	if (! preg_match('/([0-9])+/',$numFinal)) $this->error = $numFinal;
174
+    	if (! preg_match('/([0-9])+/',$numFinal)) {
175
+    	    $this->error = $numFinal;
176
+    	}
172 177
 
173 178
     	return  $numFinal;
174 179
     }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/facture/mod_facture_terre.php 1 patch
Braces   +35 added lines, -16 removed lines patch added patch discarded remove patch
@@ -171,9 +171,13 @@  discard block
 block discarded – undo
171 171
 	{
172 172
 		global $db;
173 173
 
174
-		if ($invoice->type == 2) $prefix=$this->prefixcreditnote;
175
-		else if ($invoice->type == 3) $prefix=$this->prefixdeposit;
176
-		else $prefix=$this->prefixinvoice;
174
+		if ($invoice->type == 2) {
175
+		    $prefix=$this->prefixcreditnote;
176
+		} else if ($invoice->type == 3) {
177
+		    $prefix=$this->prefixdeposit;
178
+		} else {
179
+		    $prefix=$this->prefixinvoice;
180
+		}
177 181
 
178 182
 		// D'abord on recupere la valeur max
179 183
 		$posindice=8;
@@ -187,18 +191,25 @@  discard block
 block discarded – undo
187 191
 		if ($resql)
188 192
 		{
189 193
 			$obj = $db->fetch_object($resql);
190
-			if ($obj) $max = intval($obj->max);
191
-			else $max=0;
192
-		}
193
-		else
194
+			if ($obj) {
195
+			    $max = intval($obj->max);
196
+			} else {
197
+			    $max=0;
198
+			}
199
+		} else
194 200
 		{
195 201
 			return -1;
196 202
 		}
197 203
 
198 204
 		if ($mode == 'last')
199 205
 		{
200
-    		if ($max >= (pow(10, 4) - 1)) $num=$max;	// If counter > 9999, we do not format on 4 chars, we take number as it is
201
-    		else $num = sprintf("%04s",$max);
206
+    		if ($max >= (pow(10, 4) - 1)) {
207
+    		    $num=$max;
208
+    		}
209
+    		// If counter > 9999, we do not format on 4 chars, we take number as it is
210
+    		else {
211
+    		    $num = sprintf("%04s",$max);
212
+    		}
202 213
 
203 214
             $ref='';
204 215
             $sql = "SELECT ref as ref";
@@ -211,24 +222,32 @@  discard block
 block discarded – undo
211 222
             if ($resql)
212 223
             {
213 224
                 $obj = $db->fetch_object($resql);
214
-                if ($obj) $ref = $obj->ref;
225
+                if ($obj) {
226
+                    $ref = $obj->ref;
227
+                }
228
+            } else {
229
+                dol_print_error($db);
215 230
             }
216
-            else dol_print_error($db);
217 231
 
218 232
             return $ref;
219
-		}
220
-		else if ($mode == 'next')
233
+		} else if ($mode == 'next')
221 234
 		{
222 235
 			$date=$invoice->date;	// This is invoice date (not creation date)
223 236
     		$yymm = strftime("%y%m",$date);
224 237
 
225
-    		if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
226
-    		else $num = sprintf("%04s",$max+1);
238
+    		if ($max >= (pow(10, 4) - 1)) {
239
+    		    $num=$max+1;
240
+    		}
241
+    		// If counter > 9999, we do not format on 4 chars, we take number as it is
242
+    		else {
243
+    		    $num = sprintf("%04s",$max+1);
244
+    		}
227 245
 
228 246
     		dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num);
229 247
     		return $prefix.$yymm."-".$num;
248
+		} else {
249
+		    dol_print_error('','Bad parameter for getNextValue');
230 250
 		}
231
-		else dol_print_error('','Bad parameter for getNextValue');
232 251
 	}
233 252
 
234 253
 	/**
Please login to merge, or discard this patch.