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