Passed
Push — master ( 66b259...9f3b57 )
by
unknown
02:17
created
class/subtotal.class.php 1 patch
Spacing   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -5,30 +5,30 @@  discard block
 block discarded – undo
5 5
 	
6 6
 	static $module_number = 104777;
7 7
 	
8
-	static function addSubTotalLine(&$object, $label, $qty, $rang=-1) {
8
+	static function addSubTotalLine(&$object, $label, $qty, $rang = -1) {
9 9
 		
10 10
 		$res = 0;
11 11
 		
12
-		if( (float)DOL_VERSION <= 3.4 ) {
12
+		if ((float) DOL_VERSION <= 3.4) {
13 13
 			/**
14 14
 			 * @var $object Facture
15 15
 			 */
16
-			if($object->element=='facture') $res =  $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number);
16
+			if ($object->element == 'facture') $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, '', '', 0, 0, '', 'HT', 0, 9, -1, TSubtotal::$module_number);
17 17
 			/**
18 18
 			 * @var $object Propal
19 19
 			 */
20
-			else if($object->element=='propal') $res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number);
20
+			else if ($object->element == 'propal') $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, -1, TSubtotal::$module_number);
21 21
 			/**
22 22
 			 * @var $object Commande
23 23
 			 */
24
-			else if($object->element=='commande') $res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number);
24
+			else if ($object->element == 'commande') $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, 0, 0, 'HT', 0, '', '', 9, -1, TSubtotal::$module_number);
25 25
 
26 26
 		}
27 27
 		else {
28 28
 			$desc = '';
29 29
 			
30
-			$TNotElements = array ('invoice_supplier', 'order_supplier');
31
-			if ((float) DOL_VERSION < 6  || $qty==50 && !in_array($object->element, $TNotElements) ) {
30
+			$TNotElements = array('invoice_supplier', 'order_supplier');
31
+			if ((float) DOL_VERSION < 6 || $qty == 50 && !in_array($object->element, $TNotElements)) {
32 32
 				$desc = $label;
33 33
 				$label = '';
34 34
 			}
@@ -36,39 +36,39 @@  discard block
 block discarded – undo
36 36
 			/**
37 37
 			 * @var $object Facture
38 38
 			 */
39
-			if($object->element=='facture') $res =  $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label);
39
+			if ($object->element == 'facture') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, '', '', 0, 0, '', 'HT', 0, 9, $rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label);
40 40
 			/**
41 41
 			 * @var $object Facture fournisseur
42 42
 			 */
43
-			else if($object->element=='invoice_supplier') {
43
+			else if ($object->element == 'invoice_supplier') {
44 44
 			    $object->special_code = TSubtotal::$module_number;
45 45
 			    $rang = $object->line_max() + 1;
46
-			    $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
46
+			    $res = $object->addline($label, 0, 0, 0, 0, $qty, 0, 0, '', '', 0, 0, 'HT', 9, $rang);
47 47
 			}
48 48
 			/**
49 49
 			 * @var $object Propal
50 50
 			 */
51
-			else if($object->element=='propal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
51
+			else if ($object->element == 'propal') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, $rang, TSubtotal::$module_number, 0, 0, 0, $label);
52 52
 			/**
53 53
 			 * @var $object Propal Fournisseur
54 54
 			 */
55
-			else if($object->element=='supplier_proposal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
55
+			else if ($object->element == 'supplier_proposal') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, $rang, TSubtotal::$module_number, 0, 0, 0, $label);
56 56
 			
57 57
 			/**
58 58
 			 * @var $object Commande
59 59
 			 */
60
-			else if($object->element=='commande') $res =  $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label);
60
+			else if ($object->element == 'commande') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 0, 0, 'HT', 0, '', '', 9, $rang, TSubtotal::$module_number, 0, null, 0, $label);
61 61
 			/**
62 62
 			 * @var $object Commande fournisseur
63 63
 			 */
64
-			else if($object->element=='order_supplier') {
64
+			else if ($object->element == 'order_supplier') {
65 65
 			    $object->special_code = TSubtotal::$module_number;
66
-			    $res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9);
66
+			    $res = $object->addline($label, 0, $qty, 0, 0, 0, 0, 0, '', 0, 'HT', 0, 9);
67 67
 			}
68 68
 			/**
69 69
 			 * @var $object Facturerec
70 70
 			 */
71
-			else if($object->element=='facturerec') $res =  $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); 
71
+			else if ($object->element == 'facturerec') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number, $label); 
72 72
 			
73 73
 		}
74 74
 	
@@ -79,20 +79,20 @@  discard block
 block discarded – undo
79 79
 
80 80
 	public static function generateDoc(&$object)
81 81
 	{
82
-		global $conf,$langs,$db;
82
+		global $conf, $langs, $db;
83 83
 		
84 84
 		if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
85 85
 		{
86
-			$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
87
-			$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
88
-			$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
86
+			$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
87
+			$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
88
+			$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
89 89
 			
90 90
 			// Define output language
91 91
 			$outputlangs = $langs;
92 92
 			$newlang = GETPOST('lang_id', 'alpha');
93
-			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
93
+			if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
94 94
 				$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
95
-			if (! empty($newlang)) {
95
+			if (!empty($newlang)) {
96 96
 				$outputlangs = new Translate("", $conf);
97 97
 				$outputlangs->setDefaultLang($newlang);
98 98
 			}
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 			}
107 107
 			else
108 108
 			{
109
-				if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
109
+				if ($object->element != 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
110 110
 			}
111 111
 		}
112 112
 	}
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
 	 * @param type $rang_start
119 119
 	 * @param type $move_to
120 120
 	 */
121
-	public static function updateRang(&$object, $rang_start, $move_to=1)
121
+	public static function updateRang(&$object, $rang_start, $move_to = 1)
122 122
 	{
123 123
 		if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
124 124
 		
125
-		$row=new GenericObject($object->db);
125
+		$row = new GenericObject($object->db);
126 126
 		$row->table_element_line = $object->table_element_line;
127 127
 		$row->fk_element = $object->fk_element;
128 128
 		$row->id = $object->id;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		{
132 132
 			if ($line->rang < $rang_start) continue;
133 133
 			
134
-			$row->updateRangOfLine($line->id, $line->rang+$move_to);
134
+			$row->updateRangOfLine($line->id, $line->rang + $move_to);
135 135
 		}
136 136
 	}
137 137
 	
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			{
161 161
 				if ($rang_to_add != -1) self::updateRang($object, $rang_to_add);
162 162
 				
163
-				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add);
163
+				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100 - $title_niveau, $rang_to_add);
164 164
 				
165 165
 				$object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas)
166 166
 				if ($rang_to_add != -1) 
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 		}
173 173
 	}
174 174
 	
175
-	public static function addTitle(&$object, $label, $level, $rang=-1)
175
+	public static function addTitle(&$object, $label, $level, $rang = -1)
176 176
 	{
177 177
 		self::addSubTotalLine($object, $label, $level, $rang);
178 178
 	}
179 179
 	
180
-	public static function addTotal(&$object, $label, $level, $rang=-1)
180
+	public static function addTotal(&$object, $label, $level, $rang = -1)
181 181
 	{
182
-		self::addSubTotalLine($object, $label, (100-$level), $rang);
182
+		self::addSubTotalLine($object, $label, (100 - $level), $rang);
183 183
 	}
184 184
 
185 185
 	/**
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * 
191 191
 	 * @return array
192 192
 	 */
193
-	public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total=false)
193
+	public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total = false)
194 194
 	{
195 195
 		$TTitle = self::getAllTitleFromDocument($object, $get_block_total);
196 196
 		
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	 * @param boolean								$return_rang_on_false	si true alors renvoi le rang où devrait ce trouver le sous-total
212 212
 	 * @return boolean
213 213
 	 */
214
-	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false)
214
+	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode = false, $return_rang_on_false = false)
215 215
 	{
216 216
 		if (empty($object->lines) || !is_array($object->lines)) return false;
217 217
 		
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		return ($return_rang_on_false) ? -1 : false;
238 238
 	}
239 239
 	
240
-	public static function getAllTitleFromDocument(&$object, $get_block_total=false)
240
+	public static function getAllTitleFromDocument(&$object, $get_block_total = false)
241 241
 	{
242 242
 		$TRes = array();
243 243
 		if (!empty($object->lines))
@@ -358,19 +358,19 @@  discard block
 block discarded – undo
358 358
 		return false;
359 359
 	}
360 360
 	
361
-	public static function isTitle(&$line, $level=-1)
361
+	public static function isTitle(&$line, $level = -1)
362 362
 	{
363 363
 		$res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9;
364
-		if($res && $level > -1) {
364
+		if ($res && $level > -1) {
365 365
 			return $line->qty == $level;
366 366
 		} else return $res;
367 367
 		
368 368
 	}
369 369
 	
370
-	public static function isSubtotal(&$line, $level=-1)
370
+	public static function isSubtotal(&$line, $level = -1)
371 371
 	{
372 372
 	    $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90;
373
-	    if($res && $level > -1) {
373
+	    if ($res && $level > -1) {
374 374
 	        return self::getNiveau($line) == $level;
375 375
 	    } else return $res;
376 376
 	}
@@ -385,43 +385,43 @@  discard block
 block discarded – undo
385 385
 		return self::isTitle($line) || self::isSubtotal($line) || self::isFreeText($line);
386 386
 	}
387 387
 
388
-	public static function getFreeTextHtml(&$line, $readonly=0)
388
+	public static function getFreeTextHtml(&$line, $readonly = 0)
389 389
 	{
390 390
 		global $conf;
391 391
 		
392 392
 		// Copie du fichier "objectline_edit.tpl.php"
393 393
 		// editeur wysiwyg
394 394
 		require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
395
-		$nbrows=ROWS_2;
396
-		if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
397
-		$enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
398
-		$toolbarname='dolibarr_details';
399
-		if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes';
400
-		$text = !empty($line->description)?$line->description:$line->label;
401
-		$doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly);
395
+		$nbrows = ROWS_2;
396
+		if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
397
+		$enable = (isset($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
398
+		$toolbarname = 'dolibarr_details';
399
+		if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname = 'dolibarr_notes';
400
+		$text = !empty($line->description) ? $line->description : $line->label;
401
+		$doleditor = new DolEditor('line-description', $text, '', 164, $toolbarname, '', false, true, $enable, $nbrows, '98%', $readonly);
402 402
 		return $doleditor->Create(1);
403 403
 	}
404 404
 	
405
-	public static function duplicateLines(&$object, $lineid, $withBlockLine=false)
405
+	public static function duplicateLines(&$object, $lineid, $withBlockLine = false)
406 406
 	{
407
-		global $db,$user,$conf;
407
+		global $db, $user, $conf;
408 408
 
409 409
 		$createRight = $user->rights->{$object->element}->creer;
410
-		if($object->element == 'facturerec' )
410
+		if ($object->element == 'facturerec')
411 411
 		{
412 412
 		    $object->statut = 0; // hack for facture rec
413 413
 		    $createRight = $user->rights->facture->creer;
414 414
 		}
415
-		elseif($object->element == 'order_supplier' )
415
+		elseif ($object->element == 'order_supplier')
416 416
 		{
417 417
 		    $createRight = $user->rights->fournisseur->commande->creer;
418 418
 		}
419
-		elseif($object->element == 'invoice_supplier' )
419
+		elseif ($object->element == 'invoice_supplier')
420 420
 		{
421 421
 		    $createRight = $user->rights->fournisseur->facture->creer;
422 422
 		}
423 423
 		
424
-		if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK))
424
+		if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK))
425 425
 		{
426 426
 			dol_include_once('/subtotal/lib/subtotal.lib.php');
427 427
 			
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 						case 'order_supplier':
455 455
 						    $object->line = $line;
456 456
 						    $object->line->fk_commande = $object->id;
457
-						    $object->line->rang = $object->line_max() +1;
457
+						    $object->line->rang = $object->line_max() + 1;
458 458
 						    $res = $object->line->insert(1);
459 459
 							break;
460 460
 							
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 					{
495 495
 						$object->line_from = $line;
496 496
 						// Call trigger
497
-						$result=$object->call_trigger('LINE_DUPLICATE',$user); // $object->line
497
+						$result = $object->call_trigger('LINE_DUPLICATE', $user); // $object->line
498 498
 						if ($result < 0)
499 499
 						{
500 500
 							$object->db->rollback();
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 		}
525 525
 	}
526 526
 	
527
-	public static function getLinesFromTitle(&$object, $key_trad, $level=1, $under_title='', $withBlockLine=false, $key_is_id=false)
527
+	public static function getLinesFromTitle(&$object, $key_trad, $level = 1, $under_title = '', $withBlockLine = false, $key_is_id = false)
528 528
 	{
529 529
 		global $langs;
530 530
 		
@@ -536,17 +536,17 @@  discard block
 block discarded – undo
536 536
 		
537 537
 		$TLine = array();
538 538
 		$add_line = false;
539
-		$under_title_found=false;
539
+		$under_title_found = false;
540 540
 		
541 541
 		foreach ($object->lines as $key => &$line)
542 542
 		{
543 543
 			if (!$under_title_found && !empty($TTitle_under_search))
544 544
 			{
545
-				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true;
545
+				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search))) $under_title_found = true;
546 546
 			}
547 547
 			else
548 548
 			{
549
-				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) )))
549
+				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))))
550 550
 				{
551 551
 					if ($key_is_id) $level = $line->qty;
552 552
 					
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 				
563 563
 				if ($add_line)
564 564
 				{
565
-					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue;
565
+					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line))) continue;
566 566
 					else $TLine[] = $line;
567 567
 				}
568 568
 			}
@@ -571,12 +571,12 @@  discard block
 block discarded – undo
571 571
 		return $TLine;
572 572
 	}
573 573
 	
574
-	public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine=false)
574
+	public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine = false)
575 575
 	{
576 576
 		return self::getLinesFromTitle($object, $lineid, '', '', $withBlockLine, true);
577 577
 	}
578 578
 	
579
-	public static function doUpdateLine(&$object, $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $type, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0, $fk_unit = null, $notrigger = 0)
579
+	public static function doUpdateLine(&$object, $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $type, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 0, $fk_unit = null, $notrigger = 0)
580 580
 	{
581 581
 		$res = 0;
582 582
 		$object->db->begin();
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 		        break;
589 589
 		        
590 590
 		    case 'supplier_proposal':
591
-		        $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options,'', $fk_unit);
591
+		        $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options, '', $fk_unit);
592 592
 		        break;
593 593
 		        
594 594
 			case 'commande':
@@ -617,9 +617,9 @@  discard block
 block discarded – undo
617 617
 				$factureRecLine->fetch($rowid);
618 618
 				$factureRecLine->array_options = $array_options;
619 619
 				$factureRecLine->insertExtraFields();
620
-				$rang=$factureRecLine->rang;
620
+				$rang = $factureRecLine->rang;
621 621
 				
622
-				$fk_product=0; $fk_remise_except=''; $pu_ttc=0;	
622
+				$fk_product = 0; $fk_remise_except = ''; $pu_ttc = 0;	
623 623
 				$res = $object->updateline($rowid, $desc, $pu, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $price_base_type, $info_bits, $fk_remise_except, $pu_ttc, $type, $rang, $special_code, $label, $fk_unit);
624 624
 				break;
625 625
 		}
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 		global $db, $object;
636 636
 		
637 637
 		$TTitle = array();
638
-		if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {}
638
+		if (!empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {}
639 639
 		else {
640 640
 			if ($origin_line->element == 'propaldet')
641 641
 			{
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 	 */
716 716
 	public static function addRecapPage(&$parameters, &$origin_pdf)
717 717
 	{
718
-		global $user,$conf,$langs;
718
+		global $user, $conf, $langs;
719 719
 		
720 720
 		$origin_file = $parameters['file'];
721 721
 		$outputlangs = $parameters['outputlangs'];
@@ -731,21 +731,21 @@  discard block
 block discarded – undo
731 731
 		$objmarge->marge_droite = 10;
732 732
 		
733 733
 		$objectref = dol_sanitizeFileName($object->ref);
734
-		if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref;
735
-		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref;
736
-		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref;
734
+		if ($object->element == 'propal') $dir = $conf->propal->dir_output.'/'.$objectref;
735
+		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output.'/'.$objectref;
736
+		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output.'/'.$objectref;
737 737
 		elseif ($object->element == 'facturerec') return; // no PDF for facturerec
738 738
 		else
739 739
 		{
740 740
 			setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings');
741 741
 			return -1;
742 742
 		}
743
-		$file = $dir . '/' . $objectref . '_recap.pdf';
743
+		$file = $dir.'/'.$objectref.'_recap.pdf';
744 744
 
745 745
 //		$pdf=pdf_getInstance($origin_pdf->format);
746
-		$pdf=pdf_getInstance(array(210, 297)); // Format A4 Portrait
747
-		$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
748
-		$pdf->SetAutoPageBreak(1,0);
746
+		$pdf = pdf_getInstance(array(210, 297)); // Format A4 Portrait
747
+		$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
748
+		$pdf->SetAutoPageBreak(1, 0);
749 749
 	             
750 750
 		if (class_exists('TCPDF'))
751 751
 		{
@@ -754,49 +754,49 @@  discard block
 block discarded – undo
754 754
 		}
755 755
 		$pdf->SetFont(pdf_getPDFFont($outputlangs));
756 756
 		// Set path to the background PDF File
757
-		if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
757
+		if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
758 758
 		{
759 759
 			$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
760 760
 			$tplidx = $pdf->importPage(1);
761 761
 		}
762 762
 
763 763
 		$pdf->Open();
764
-		$pagenb=0;
765
-		$pdf->SetDrawColor(128,128,128);
764
+		$pagenb = 0;
765
+		$pdf->SetDrawColor(128, 128, 128);
766 766
 
767 767
 		$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
768 768
 		$pdf->SetSubject($outputlangs->transnoentities("subtotalRecap"));
769 769
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
770 770
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
771 771
 		$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
772
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
772
+		if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
773 773
 
774
-		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite);   // Left, Top, Right
774
+		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right
775 775
 
776
-		$pagenb=0;
777
-		$pdf->SetDrawColor(128,128,128);
776
+		$pagenb = 0;
777
+		$pdf->SetDrawColor(128, 128, 128);
778 778
 
779 779
 			
780 780
 		// New page
781 781
 		$pdf->AddPage();
782
-		if (! empty($tplidx)) $pdf->useTemplate($tplidx);
782
+		if (!empty($tplidx)) $pdf->useTemplate($tplidx);
783 783
 		$pagenb++;
784 784
 		
785 785
 		
786 786
 		self::pagehead($objmarge, $pdf, $object, 1, $outputlangs);
787
-		$pdf->SetFont('','', $default_font_size - 1);
788
-		$pdf->MultiCell(0, 3, '');		// Set interline to 3
789
-		$pdf->SetTextColor(0,0,0);
787
+		$pdf->SetFont('', '', $default_font_size - 1);
788
+		$pdf->MultiCell(0, 3, ''); // Set interline to 3
789
+		$pdf->SetTextColor(0, 0, 0);
790 790
 		
791
-		$heightforinfotot = 25;	// Height reserved to output the info and total part
792
-		$heightforfooter = $objmarge->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
791
+		$heightforinfotot = 25; // Height reserved to output the info and total part
792
+		$heightforfooter = $objmarge->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
793 793
 		
794 794
 		$posx_designation = 25;
795 795
 		$posx_options = 150;
796 796
 		$posx_montant = 170;
797 797
 		
798 798
 		$tab_top = 72;
799
-		$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?72:20); // TODO à vérifier
799
+		$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 72 : 20); // TODO à vérifier
800 800
 		
801 801
 		$TTot = array('total_ht' => 0, 'total_ttc' => 0, 'TTotal_tva' => array());
802 802
 		
@@ -810,14 +810,14 @@  discard block
 block discarded – undo
810 810
 			$nexY = $tab_top + 10;
811 811
 			
812 812
 			$nblignes = count($TLine);
813
-			foreach($TLine as $i => &$line)
813
+			foreach ($TLine as $i => &$line)
814 814
 			{
815 815
 				$curY = $nexY;
816 816
 				
817 817
 				if (self::getNiveau($line) == 1) 
818 818
 				{
819
-					$pdf->SetFont('','B', $default_font_size - 1);   // Into loop to work with multipage
820
-					$curY+=2;
819
+					$pdf->SetFont('', 'B', $default_font_size - 1); // Into loop to work with multipage
820
+					$curY += 2;
821 821
 					
822 822
 					$TTot['total_ht'] += $line->total_ht;
823 823
 					$TTot['total_tva'] += $line->total_tva;
@@ -836,67 +836,67 @@  discard block
 block discarded – undo
836 836
 						$TTot['TTotal_tva_multicurrency'][$tx] += $amount;
837 837
 					}	
838 838
 				}
839
-				else $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
839
+				else $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
840 840
 				
841
-				$pdf->SetTextColor(0,0,0);
841
+				$pdf->SetTextColor(0, 0, 0);
842 842
 				
843 843
 				$pdf->setTopMargin($tab_top_newpage + 10);
844
-				$pdf->setPageOrientation('', 1, $heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
845
-				$pageposbefore=$pdf->getPage();
844
+				$pdf->setPageOrientation('', 1, $heightforfooter + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
845
+				$pageposbefore = $pdf->getPage();
846 846
 				
847
-				$showpricebeforepagebreak=1;
847
+				$showpricebeforepagebreak = 1;
848 848
 				
849 849
 				$decalage = (self::getNiveau($line) - 1) * 2;
850 850
 				
851 851
 				// Print: Designation
852 852
 				$label = $line->label;
853
-				if( (float)DOL_VERSION < 6 ) {
853
+				if ((float) DOL_VERSION < 6) {
854 854
 					$label = !empty($line->label) ? $line->label : $line->desc;
855 855
 				}
856 856
 				
857 857
 				
858 858
 				$pdf->startTransaction();
859
-				$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
860
-				$pageposafter=$pdf->getPage();
859
+				$pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true);
860
+				$pageposafter = $pdf->getPage();
861 861
 				if ($pageposafter > $pageposbefore)	// There is a pagebreak
862 862
 				{
863 863
 					$pdf->rollbackTransaction(true);
864
-					$pageposafter=$pageposbefore;
864
+					$pageposafter = $pageposbefore;
865 865
 					//print $pageposafter.'-'.$pageposbefore;exit;
866
-					$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
867
-					$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
866
+					$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
867
+					$pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true);
868 868
 
869
-					$pageposafter=$pdf->getPage();
870
-					$posyafter=$pdf->GetY();
869
+					$pageposafter = $pdf->getPage();
870
+					$posyafter = $pdf->GetY();
871 871
 					//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
872
-					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot)))	// There is no space left for total+free text
872
+					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter + $heightforinfotot)))	// There is no space left for total+free text
873 873
 					{
874
-						if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
874
+						if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
875 875
 						{
876
-							$pdf->AddPage('','',true);
877
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
876
+							$pdf->AddPage('', '', true);
877
+							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
878 878
 							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
879
-							$pdf->setPage($pageposafter+1);
879
+							$pdf->setPage($pageposafter + 1);
880 880
 						}
881 881
 					}
882 882
 					else
883 883
 					{
884 884
 						// We found a page break
885
-						$showpricebeforepagebreak=0;
885
+						$showpricebeforepagebreak = 0;
886 886
 					}
887 887
 				}
888 888
 				else	// No pagebreak
889 889
 				{
890 890
 					$pdf->commitTransaction();
891 891
 				}
892
-				$posYAfterDescription=$pdf->GetY();
892
+				$posYAfterDescription = $pdf->GetY();
893 893
 
894 894
 				$nexY = $pdf->GetY();
895
-				$pageposafter=$pdf->getPage();
895
+				$pageposafter = $pdf->getPage();
896 896
 
897 897
 				$pdf->setPage($pageposbefore);
898 898
 				$pdf->setTopMargin($objmarge->marge_haute);
899
-				$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
899
+				$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
900 900
 
901 901
 				// We suppose that a too long description or photo were moved completely on next page
902 902
 				if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
@@ -909,14 +909,14 @@  discard block
 block discarded – undo
909 909
 				if (!empty($line->total_options))
910 910
 				{
911 911
 					$pdf->SetXY($posx_options, $curY);
912
-					$pdf->MultiCell($posx_montant-$posx_options-0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0);
912
+					$pdf->MultiCell($posx_montant - $posx_options - 0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0);
913 913
 				}
914 914
 				
915 915
 				// Print: Montant
916 916
 				$pdf->SetXY($posx_montant, $curY);
917
-				$pdf->MultiCell($objmarge->page_largeur-$objmarge->marge_droite-$posx_montant-0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0);
917
+				$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant - 0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0);
918 918
 				
919
-				$nexY+=2;    // Passe espace entre les lignes
919
+				$nexY += 2; // Passe espace entre les lignes
920 920
 
921 921
 				// Detect if some page were added automatically and output _tableau for past pages
922 922
 				while ($pagenb < $pageposafter)
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
 					
934 934
 					$pagenb++;
935 935
 					$pdf->setPage($pagenb);
936
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
936
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
937 937
 					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
938 938
 				}
939 939
 			}
@@ -943,19 +943,19 @@  discard block
 block discarded – undo
943 943
 		if ($pagenb == 1)
944 944
 		{
945 945
 			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);
946
-			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
946
+			$bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
947 947
 		}
948 948
 		else
949 949
 		{
950 950
 			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);
951
-			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
951
+			$bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
952 952
 		}
953 953
 		
954 954
 		// Affiche zone totaux
955
-		$posy=self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot);
955
+		$posy = self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot);
956 956
 		
957 957
 		$pdf->Close();
958
-		$pdf->Output($file,'F');
958
+		$pdf->Output($file, 'F');
959 959
 		
960 960
 		$pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file);
961 961
 		
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
 		$level = $line->qty; // TODO à améliorer
968 968
 		
969 969
 		$pdf->SetXY($objmarge->marge_gauche, $curY);
970
-		$pdf->MultiCell($posx_designation-$objmarge->marge_gauche-0.8, 5, $level, 0, 'L', 0);
970
+		$pdf->MultiCell($posx_designation - $objmarge->marge_gauche - 0.8, 5, $level, 0, 'L', 0);
971 971
 	}
972 972
 	
973 973
 	/**
@@ -981,50 +981,50 @@  discard block
 block discarded – undo
981 981
 	 */
982 982
 	private static function pagehead(&$objmarge, &$pdf, &$object, $showdetail, $outputlangs)
983 983
 	{
984
-		global $conf,$mysoc;
984
+		global $conf, $mysoc;
985 985
 
986 986
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
987 987
 
988
-		pdf_pagehead($pdf,$outputlangs,$objmarge->page_hauteur);
988
+		pdf_pagehead($pdf, $outputlangs, $objmarge->page_hauteur);
989 989
 
990
-		$pdf->SetTextColor(0,0,60);
991
-		$pdf->SetFont('','B', $default_font_size + 3);
990
+		$pdf->SetTextColor(0, 0, 60);
991
+		$pdf->SetFont('', 'B', $default_font_size + 3);
992 992
 
993
-		$posy=$objmarge->marge_haute;
994
-		$posx=$objmarge->page_largeur-$objmarge->marge_droite-100;
993
+		$posy = $objmarge->marge_haute;
994
+		$posx = $objmarge->page_largeur - $objmarge->marge_droite - 100;
995 995
 		
996
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
996
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
997 997
 
998
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
998
+		$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
999 999
 		if ($mysoc->logo)
1000 1000
 		{
1001 1001
 			if (is_readable($logo))
1002 1002
 			{
1003
-			    $height=pdf_getHeightForLogo($logo);
1004
-			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1003
+			    $height = pdf_getHeightForLogo($logo);
1004
+			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto)
1005 1005
 			}
1006 1006
 			else
1007 1007
 			{
1008
-				$pdf->SetTextColor(200,0,0);
1009
-				$pdf->SetFont('','B',$default_font_size - 2);
1010
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1008
+				$pdf->SetTextColor(200, 0, 0);
1009
+				$pdf->SetFont('', 'B', $default_font_size - 2);
1010
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1011 1011
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1012 1012
 			}
1013 1013
 			
1014
-			$posy+=35;
1014
+			$posy += 35;
1015 1015
 		}
1016 1016
 		else
1017 1017
 		{
1018
-			$text=$mysoc->name;
1018
+			$text = $mysoc->name;
1019 1019
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1020 1020
 			
1021
-			$posy+=15;
1021
+			$posy += 15;
1022 1022
 		}
1023 1023
 		
1024 1024
 		
1025
-		$pdf->SetTextColor(0,0,0);
1026
-		$pdf->SetFont('','B', $default_font_size + 2);
1027
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
1025
+		$pdf->SetTextColor(0, 0, 0);
1026
+		$pdf->SetFont('', 'B', $default_font_size + 2);
1027
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
1028 1028
 		
1029 1029
 		$key = 'subtotalPropalTitle';
1030 1030
 		if ($object->element == 'commande') $key = 'subtotalCommandeTitle';
@@ -1033,14 +1033,14 @@  discard block
 block discarded – undo
1033 1033
 		
1034 1034
 		$pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L');
1035 1035
 		
1036
-		$pdf->SetFont('','', $default_font_size);
1037
-		$pdf->SetXY($objmarge->page_largeur-$objmarge->marge_droite-40,$posy);
1036
+		$pdf->SetFont('', '', $default_font_size);
1037
+		$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - 40, $posy);
1038 1038
 		$pdf->MultiCell(40, 4, dol_print_date($object->date, 'daytext'), '', 'R');
1039 1039
 		
1040 1040
 		$posy += 8;
1041 1041
 			
1042
-		$pdf->SetFont('','B', $default_font_size + 2);
1043
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
1042
+		$pdf->SetFont('', 'B', $default_font_size + 2);
1043
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
1044 1044
 		$pdf->MultiCell(70, 4, $outputlangs->transnoentities('subtotalRecapLot'), '', 'L');
1045 1045
 		
1046 1046
 	}
@@ -1058,44 +1058,44 @@  discard block
 block discarded – undo
1058 1058
 	 *   @param		string		$currency		Currency code
1059 1059
 	 *   @return	void
1060 1060
 	 */
1061
-	private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1061
+	private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1062 1062
 	{
1063 1063
 		global $conf;
1064 1064
 		
1065 1065
 		// Force to disable hidetop and hidebottom
1066
-		$hidebottom=0;
1067
-		if ($hidetop) $hidetop=-1;
1066
+		$hidebottom = 0;
1067
+		if ($hidetop) $hidetop = -1;
1068 1068
 
1069 1069
 		$currency = !empty($currency) ? $currency : $conf->currency;
1070 1070
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1071 1071
 
1072 1072
 		// Amount in (at tab_top - 1)
1073
-		$pdf->SetTextColor(0,0,0);
1074
-		$pdf->SetFont('','',$default_font_size);
1073
+		$pdf->SetTextColor(0, 0, 0);
1074
+		$pdf->SetFont('', '', $default_font_size);
1075 1075
 
1076 1076
 		if (empty($hidetop))
1077 1077
 		{
1078
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1079
-			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5);
1078
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1079
+			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4.5);
1080 1080
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1081 1081
 			
1082
-			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));
1082
+			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));
1083 1083
 			
1084 1084
 			
1085
-			$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
1085
+			$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
1086 1086
 
1087
-			$pdf->SetXY($posx_designation, $tab_top+2);
1088
-			$pdf->MultiCell($posx_options - $posx_designation,2, $outputlangs->transnoentities("Designation"),'','L');
1089
-			$pdf->SetXY($posx_options, $tab_top+2);
1090
-			$pdf->MultiCell($posx_montant - $posx_options,2, $outputlangs->transnoentities("Options"),'','R');
1091
-			$pdf->SetXY($posx_montant, $tab_top+2);
1092
-			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R');
1087
+			$pdf->SetXY($posx_designation, $tab_top + 2);
1088
+			$pdf->MultiCell($posx_options - $posx_designation, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1089
+			$pdf->SetXY($posx_options, $tab_top + 2);
1090
+			$pdf->MultiCell($posx_montant - $posx_options, 2, $outputlangs->transnoentities("Options"), '', 'R');
1091
+			$pdf->SetXY($posx_montant, $tab_top + 2);
1092
+			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant, 2, $outputlangs->transnoentities("Amount"), '', 'R');
1093 1093
 			
1094
-			$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
1094
+			$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
1095 1095
 		}
1096 1096
 		else
1097 1097
 		{
1098
-			$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
1098
+			$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
1099 1099
 		}
1100 1100
 		
1101 1101
 	}
@@ -1104,29 +1104,29 @@  discard block
 block discarded – undo
1104 1104
 	{
1105 1105
 		global $conf;
1106 1106
 		
1107
-		$pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur-$objmarge->marge_droite, $posy);	// line prend une position y en 2eme param et 4eme param
1107
+		$pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur - $objmarge->marge_droite, $posy); // line prend une position y en 2eme param et 4eme param
1108 1108
 		
1109 1109
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1110 1110
 		
1111
-		$tab2_top = $posy+2;
1111
+		$tab2_top = $posy + 2;
1112 1112
 		$tab2_hl = 4;
1113
-		$pdf->SetFont('','', $default_font_size - 1);
1113
+		$pdf->SetFont('', '', $default_font_size - 1);
1114 1114
 
1115 1115
 		// Tableau total
1116 1116
 		$col1x = 120; $col2x = 170;
1117 1117
 		if ($objmarge->page_largeur < 210) // To work with US executive format
1118 1118
 		{
1119
-			$col2x-=20;
1119
+			$col2x -= 20;
1120 1120
 		}
1121 1121
 		$largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x);
1122 1122
 
1123
-		$useborder=0;
1123
+		$useborder = 0;
1124 1124
 		$index = 0;
1125 1125
 
1126 1126
 		// Total HT
1127
-		$pdf->SetFillColor(255,255,255);
1127
+		$pdf->SetFillColor(255, 255, 255);
1128 1128
 		$pdf->SetXY($col1x, $tab2_top + 0);
1129
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1129
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1130 1130
 
1131 1131
 		// $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1) ? $TTot['multicurrency_total_ht'] : $TTot['total_ht'];
1132 1132
 		$total_ht = $TTot['total_ht'];
@@ -1134,10 +1134,10 @@  discard block
 block discarded – undo
1134 1134
 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht, 0, $outputlangs), 0, 'R', 1);
1135 1135
 
1136 1136
 		// Show VAT by rates and total
1137
-		$pdf->SetFillColor(248,248,248);
1137
+		$pdf->SetFillColor(248, 248, 248);
1138 1138
 		
1139
-		$atleastoneratenotnull=0;
1140
-		foreach($TTot['TTotal_tva'] as $tvakey => $tvaval)
1139
+		$atleastoneratenotnull = 0;
1140
+		foreach ($TTot['TTotal_tva'] as $tvakey => $tvaval)
1141 1141
 		{
1142 1142
 			if ($tvakey != 0)    // On affiche pas taux 0
1143 1143
 			{
@@ -1146,15 +1146,15 @@  discard block
 block discarded – undo
1146 1146
 				$index++;
1147 1147
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1148 1148
 
1149
-				$tvacompl='';
1150
-				if (preg_match('/\*/',$tvakey))
1149
+				$tvacompl = '';
1150
+				if (preg_match('/\*/', $tvakey))
1151 1151
 				{
1152
-					$tvakey=str_replace('*','',$tvakey);
1152
+					$tvakey = str_replace('*', '', $tvakey);
1153 1153
 					$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1154 1154
 				}
1155
-				$totalvat =$outputlangs->transnoentities("TotalVAT").' ';
1156
-				$totalvat.=vatrate($tvakey,1).$tvacompl;
1157
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1155
+				$totalvat = $outputlangs->transnoentities("TotalVAT").' ';
1156
+				$totalvat .= vatrate($tvakey, 1).$tvacompl;
1157
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1158 1158
 
1159 1159
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1160 1160
 				$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1164,16 +1164,16 @@  discard block
 block discarded – undo
1164 1164
 		// Total TTC
1165 1165
 		$index++;
1166 1166
 		$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1167
-		$pdf->SetTextColor(0,0,60);
1168
-		$pdf->SetFillColor(224,224,224);
1169
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1167
+		$pdf->SetTextColor(0, 0, 60);
1168
+		$pdf->SetFillColor(224, 224, 224);
1169
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1170 1170
 
1171 1171
 		// $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $TTot['multicurrency_total_ttc'] : $TTot['total_ttc'];
1172 1172
 		$total_ttc = $TTot['total_ttc'];
1173 1173
 		$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1174 1174
 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1175 1175
 
1176
-		$pdf->SetTextColor(0,0,0);
1176
+		$pdf->SetTextColor(0, 0, 0);
1177 1177
 				
1178 1178
 		$index++;
1179 1179
 		return ($tab2_top + ($tab2_hl * $index));
@@ -1192,22 +1192,22 @@  discard block
 block discarded – undo
1192 1192
 	 * @param	int		$hidebottom		Hide bottom
1193 1193
 	 * @return	void
1194 1194
 	 */
1195
-    private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1195
+    private static function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0)
1196 1196
     {
1197
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1198
-	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1199
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1200
-	    $pdf->line($x, $y+$h, $x, $y);
1197
+	    if (empty($hidetop) || $hidetop == -1) $pdf->line($x, $y, $x + $l, $y);
1198
+	    $pdf->line($x + $l, $y, $x + $l, $y + $h);
1199
+	    if (empty($hidebottom)) $pdf->line($x + $l, $y + $h, $x, $y + $h);
1200
+	    $pdf->line($x, $y + $h, $x, $y);
1201 1201
     }
1202 1202
 	
1203 1203
 	
1204
-	public static function concat(&$outputlangs, $files, $fileoutput='')
1204
+	public static function concat(&$outputlangs, $files, $fileoutput = '')
1205 1205
 	{
1206 1206
 		global $conf;
1207 1207
 		
1208 1208
 		if (empty($fileoutput)) $fileoutput = $file[0];
1209 1209
 		
1210
-		$pdf=pdf_getInstance();
1210
+		$pdf = pdf_getInstance();
1211 1211
         if (class_exists('TCPDF'))
1212 1212
         {
1213 1213
             $pdf->setPrintHeader(false);
@@ -1215,10 +1215,10 @@  discard block
 block discarded – undo
1215 1215
         }
1216 1216
         $pdf->SetFont(pdf_getPDFFont($outputlangs));
1217 1217
 
1218
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1218
+        if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1219 1219
 
1220 1220
 		
1221
-		foreach($files as $file)
1221
+		foreach ($files as $file)
1222 1222
 		{
1223 1223
 			$pagecount = $pdf->setSourceFile($file);
1224 1224
 			for ($i = 1; $i <= $pagecount; $i++)
@@ -1230,8 +1230,8 @@  discard block
 block discarded – undo
1230 1230
 			}
1231 1231
 		}
1232 1232
 		
1233
-		$pdf->Output($fileoutput,'F');
1234
-		if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1233
+		$pdf->Output($fileoutput, 'F');
1234
+		if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1235 1235
 
1236 1236
 		return $pagecount;
1237 1237
 	}
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
 	 */
1245 1245
 	public static function hasNcTitle(&$line)
1246 1246
 	{
1247
-		if(isset($line->has_nc_title)) return $line->has_nc_title;
1247
+		if (isset($line->has_nc_title)) return $line->has_nc_title;
1248 1248
 
1249 1249
 		$TTitle = self::getAllTitleFromLine($line);
1250 1250
 		foreach ($TTitle as &$line_title)
Please login to merge, or discard this patch.
core/modules/modSubtotal.class.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * 	\ingroup	titre
24 24
  * 	\brief		Description and activation file for module titre
25 25
  */
26
-include_once DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php";
26
+include_once DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php";
27 27
 
28 28
 /**
29 29
  * Description and activation class for module titre
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $this->version = '3.1.7';
67 67
         // Key used in llx_const table to save module status enabled/disabled
68 68
         // (where MYMODULE is value of property name of module in uppercase)
69
-        $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
69
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
70 70
         // Where to store the module in setup page
71 71
         // (0=common,1=interface,2=others,3=very specific)
72 72
         $this->special = 2;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
         // List of modules id that must be enabled if this module is enabled
126 126
         $this->depends = array();
127 127
 
128
-		$this->conflictwith=array('modMilestone');
128
+		$this->conflictwith = array('modMilestone');
129 129
         // List of modules id to disable if this one is disabled
130 130
         $this->requiredby = array();
131 131
         // Minimum version of PHP required by module
@@ -190,20 +190,20 @@  discard block
 block discarded – undo
190 190
         // 'categories_x'		to add a tab in category view
191 191
         // (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
192 192
         // Dictionnaries
193
-        if (! isset($conf->subtotal->enabled)) {
194
-            $conf->subtotal=new stdClass();
193
+        if (!isset($conf->subtotal->enabled)) {
194
+            $conf->subtotal = new stdClass();
195 195
             $conf->subtotal->enabled = 0;
196 196
         }
197 197
         $this->dictionaries = array(
198 198
 			'langs'=>'subtotal@subtotal',
199
-            'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'),		// List of tables we want to see into dictonnary editor
200
-            'tablib'=>array($langs->trans('subtotalFreeLineDictionary')),													// Label of tables
201
-            'tabsql'=>array('SELECT f.rowid as rowid, f.label, f.content, f.entity, f.active FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text as f WHERE f.entity='.$conf->entity),	// Request to select fields
202
-            'tabsqlsort'=>array('label ASC'),																					// Sort order
203
-            'tabfield'=>array('label,content'),							// List of fields (result of select to show dictionary)
204
-            'tabfieldvalue'=>array('label,content'),						// List of fields (list of fields to edit a record)
205
-            'tabfieldinsert'=>array('label,content,entity'),					// List of fields (list of fields for insert)
206
-            'tabrowid'=>array('rowid'),											// Name of columns with primary key (try to always name it 'rowid')
199
+            'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'), // List of tables we want to see into dictonnary editor
200
+            'tablib'=>array($langs->trans('subtotalFreeLineDictionary')), // Label of tables
201
+            'tabsql'=>array('SELECT f.rowid as rowid, f.label, f.content, f.entity, f.active FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text as f WHERE f.entity='.$conf->entity), // Request to select fields
202
+            'tabsqlsort'=>array('label ASC'), // Sort order
203
+            'tabfield'=>array('label,content'), // List of fields (result of select to show dictionary)
204
+            'tabfieldvalue'=>array('label,content'), // List of fields (list of fields to edit a record)
205
+            'tabfieldinsert'=>array('label,content,entity'), // List of fields (list of fields for insert)
206
+            'tabrowid'=>array('rowid'), // Name of columns with primary key (try to always name it 'rowid')
207 207
             'tabcond'=>array($conf->subtotal->enabled)	
208 208
 		);
209 209
         /* Example:
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 	
479 479
         $extra = new ExtraFields($db); // propaldet, commandedet, facturedet
480 480
         $TElementType = array('propaldet', 'commandedet', 'facturedet', 'supplier_proposaldet', 'commande_fournisseurdet', 'facture_fourn_det');
481
-        foreach($TElementType as $element_type) {
481
+        foreach ($TElementType as $element_type) {
482 482
             $extra->addExtraField('show_total_ht', 'Afficher le Total HT sur le sous-total', 'int', 0, 10, $element_type, 0, 0, '', unserialize('a:1:{s:7:"options";a:1:{s:0:"";N;}}'), 0, '', 0, 1);
483 483
             $extra->addExtraField('show_reduc', 'Afficher la réduction sur le sous-total', 'int', 0, 10, $element_type, 0, 0, '', unserialize('a:1:{s:7:"options";a:1:{s:0:"";N;}}'), 0, '', 0, 1);
484 484
         }
Please login to merge, or discard this patch.