Passed
Push — master ( 17deb1...f50dd8 )
by
unknown
02:53
created
lib/subtotal.lib.php 1 patch
Braces   +63 added lines, -29 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@  discard block
 block discarded – undo
54 54
 	dol_include_once('/subtotal/class/subtotal.class.php');
55 55
 	$TTitle = TSubtotal::getAllTitleFromDocument($object);
56 56
 	$html = '';
57
-	if ($showLabel) $html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>';
57
+	if ($showLabel) {
58
+		$html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>';
59
+	}
58 60
 	$html.= '<select onChange="$(\'select[name=under_title]\').val(this.value);" name="under_title" class="under_title minwidth200"><option value="-1"></option>';
59 61
 	
60 62
 	$nbsp = '&nbsp;';
@@ -95,7 +97,9 @@  discard block
 block discarded – undo
95 97
 	$TFreeText = getTFreeText();
96 98
 	$html = '<label for="free_text">'.$langs->trans('subtotalLabelForFreeText').'</label>';
97 99
 	$html.= '<select onChange="getTFreeText($(this));" name="free_text" class="minwidth200">';
98
-	if ($withEmpty) $html.= '<option value=""></option>';
100
+	if ($withEmpty) {
101
+		$html.= '<option value=""></option>';
102
+	}
99 103
 
100 104
 	$TFreeTextContents = array();
101 105
 	foreach ($TFreeText as $id => $tab)
@@ -134,8 +138,13 @@  discard block
 block discarded – undo
134 138
 	$level = GETPOST('subtotal_level', 'int');
135 139
 	if (!empty($level))
136 140
 	{
137
-		if ($line->qty > 90) $line->qty = 100 - $level; // Si on edit une ligne sous-total
138
-		else $line->qty = $level;
141
+		if ($line->qty > 90) {
142
+			$line->qty = 100 - $level;
143
+		}
144
+		// Si on edit une ligne sous-total
145
+		else {
146
+			$line->qty = $level;
147
+		}
139 148
 	}
140 149
 	
141 150
 	$res = TSubtotal::doUpdateLine($object, $line->id, $description, 0, $line->qty, 0, '', '', 0, 9, 0, 0, 'HT', $pagebreak, 0, 1, null, 0, $label, TSubtotal::$module_number, $line->array_options);
@@ -162,13 +171,18 @@  discard block
 block discarded – undo
162 171
 			{
163 172
 				$subtotal_tva_tx = $subtotal_tva_tx_init; // ré-init car la variable peut évoluer
164 173
 					
165
-				if (!empty($showBlockExtrafields)) $line->array_options = $array_options;
166
-				if ($subtotal_tva_tx == '') $subtotal_tva_tx = $line->tva_tx;
174
+				if (!empty($showBlockExtrafields)) {
175
+					$line->array_options = $array_options;
176
+				}
177
+				if ($subtotal_tva_tx == '') {
178
+					$subtotal_tva_tx = $line->tva_tx;
179
+				}
167 180
 				if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION)
168 181
 				{
169 182
 					$subtotal_progress = $subtotal_progress_init;
170
-					if ($subtotal_progress == '') $subtotal_progress = $line->situation_percent;
171
-					else
183
+					if ($subtotal_progress == '') {
184
+						$subtotal_progress = $line->situation_percent;
185
+					} else
172 186
 					{
173 187
 						$prev_percent = $line->get_prev_progress($object->id);
174 188
 						if ($subtotal_progress < $prev_percent)
@@ -181,14 +195,21 @@  discard block
 block discarded – undo
181 195
 				
182 196
 				$res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $subtotal_tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $subtotal_progress, $line->fk_unit);
183 197
 
184
-				if ($res > 0) $success_updated_line++;
185
-				else $error_updated_line++;
198
+				if ($res > 0) {
199
+					$success_updated_line++;
200
+				} else {
201
+					$error_updated_line++;
202
+				}
186 203
 			}
187 204
 		}
188 205
 
189
-		if ($nb_progress_not_updated > 0) setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings');
206
+		if ($nb_progress_not_updated > 0) {
207
+			setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings');
208
+		}
190 209
 		
191
-		if ($success_updated_line > 0) setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line));
210
+		if ($success_updated_line > 0) {
211
+			setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line));
212
+		}
192 213
 		if ($error_updated_line > 0)
193 214
 		{
194 215
 			setEventMessage($langs->trans('subtotal_error_updated_line', $error_updated_line), 'errors');
@@ -229,15 +250,16 @@  discard block
 block discarded – undo
229 250
 	global $db,$langs,$tmp_object_nc;
230 251
 	
231 252
 	$error = 0;
232
-	if (empty($element)) $error++;
253
+	if (empty($element)) {
254
+		$error++;
255
+	}
233 256
 	
234 257
 	if (!$error)
235 258
 	{
236 259
 		if (!empty($tmp_object_nc) && $tmp_object_nc->element == $element && $tmp_object_nc->id == $elementid)
237 260
 		{
238 261
 			$object = $tmp_object_nc;
239
-		}
240
-		else
262
+		} else
241 263
 		{
242 264
 			$classname = ucfirst($element);
243 265
 			
@@ -257,8 +279,11 @@  discard block
 block discarded – undo
257 279
 			
258 280
 			$object = new $classname($db); // Propal | Commande | Facture
259 281
 			$res = $object->fetch($elementid);
260
-			if ($res < 0) $error++;
261
-			else $tmp_object_nc = $object;
282
+			if ($res < 0) {
283
+				$error++;
284
+			} else {
285
+				$tmp_object_nc = $object;
286
+			}
262 287
 		}
263 288
 	}
264 289
 	
@@ -286,21 +311,21 @@  discard block
 block discarded – undo
286 311
 						$res = doUpdate($object, $line_block, $subtotal_nc, $notrigger);
287 312
 					}
288 313
 				}
289
-			}
290
-			else
314
+			} else
291 315
 			{
292 316
 				$res = doUpdate($object, $line, $subtotal_nc, $notrigger);
293 317
 			}
294 318
 			
295 319
 			$res = $object->update_price(1);
296
-			if ($res <= 0) $error++;
320
+			if ($res <= 0) {
321
+				$error++;
322
+			}
297 323
 			
298 324
 			if (!$error)
299 325
 			{
300 326
 				setEventMessage($langs->trans('subtotal_update_nc_success'));
301 327
 				$db->commit();
302
-			}
303
-			else
328
+			} else
304 329
 			{
305 330
 				setEventMessage($langs->trans('subtotal_update_nc_error'), 'errors');
306 331
 				$db->rollback();
@@ -313,7 +338,9 @@  discard block
 block discarded – undo
313 338
 {
314 339
 	global $user;
315 340
 	
316
-	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1;
341
+	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) {
342
+		return 1;
343
+	}
317 344
 	// Update extrafield et total
318 345
 	if(! empty($subtotal_nc)) {
319 346
 		$line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = 
@@ -321,12 +348,17 @@  discard block
 block discarded – undo
321 348
 
322 349
 		$line->array_options['options_subtotal_nc'] = 1;
323 350
 
324
-		if ($line->element == 'propaldet') $res = $line->update($notrigger);
325
-		else $res = $line->update($user, $notrigger);
326
-	}
327
-	else {
351
+		if ($line->element == 'propaldet') {
352
+			$res = $line->update($notrigger);
353
+		} else {
354
+			$res = $line->update($user, $notrigger);
355
+		}
356
+	} else {
328 357
 	    if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
329
-	        if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
358
+	        if(empty($line->label)) {
359
+	        	$line->label = $line->description;
360
+	        }
361
+	        // supplier lines don't have the field label
330 362
 	        
331 363
 	        require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
332 364
 	        $extrafields=new ExtraFields($object->db);
@@ -334,7 +366,9 @@  discard block
 block discarded – undo
334 366
 	        $line->fetch_optionals($line->id,$extralabels);
335 367
 	    }
336 368
 		$line->array_options['options_subtotal_nc'] = 0;
337
-		if($object->element == 'order_supplier') $line->update($user);
369
+		if($object->element == 'order_supplier') {
370
+			$line->update($user);
371
+		}
338 372
 		$res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $notrigger);
339 373
 	}
340 374
 	
Please login to merge, or discard this patch.
class/actions_subtotal.class.php 1 patch
Braces   +374 added lines, -227 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@  discard block
 block discarded – undo
45 45
 				$value = '';
46 46
 				$sql = 'SELECT content FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text WHERE rowid = '.GETPOST('rowid');
47 47
 				$resql = $this->db->query($sql);
48
-				if ($resql && ($obj = $this->db->fetch_object($resql))) $value = $obj->content;
48
+				if ($resql && ($obj = $this->db->fetch_object($resql))) {
49
+					$value = $obj->content;
50
+				}
49 51
 			}
50 52
 			
51 53
 			?>
@@ -129,8 +131,11 @@  discard block
 block discarded – undo
129 131
 			if ($object->statut == 0  && $createRight) {
130 132
 			
131 133
 
132
-				if($object->element=='facture')$idvar = 'facid';
133
-				else $idvar='id';
134
+				if($object->element=='facture') {
135
+					$idvar = 'facid';
136
+				} else {
137
+					$idvar='id';
138
+				}
134 139
 				
135 140
 				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
136 141
 				{
@@ -138,10 +143,11 @@  discard block
 block discarded – undo
138 143
 					
139 144
 					if($action=='add_title_line') {
140 145
 						$title = GETPOST('title');
141
-						if(empty($title)) $title = $langs->trans('title');
146
+						if(empty($title)) {
147
+							$title = $langs->trans('title');
148
+						}
142 149
 						$qty = $level<1 ? 1 : $level ;
143
-					}
144
-					else if($action=='add_free_text') {
150
+					} else if($action=='add_free_text') {
145 151
 						$title = GETPOST('title');
146 152
 
147 153
 						if (empty($title)) {
@@ -153,29 +159,31 @@  discard block
 block discarded – undo
153 159
 								}
154 160
 							}
155 161
 						}
156
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
162
+						if(empty($title)) {
163
+							$title = $langs->trans('subtotalAddLineDescription');
164
+						}
157 165
 						$qty = 50;
158
-					}
159
-					else if($action=='add_subtitle_line') {
166
+					} else if($action=='add_subtitle_line') {
160 167
 						$title = GETPOST('title');
161
-						if(empty($title)) $title = $langs->trans('subtitle');
168
+						if(empty($title)) {
169
+							$title = $langs->trans('subtitle');
170
+						}
162 171
 						$qty = 2;
163
-					}
164
-					else if($action=='add_subtotal_line') {
172
+					} else if($action=='add_subtotal_line') {
165 173
 						$title = $langs->trans('SubSubTotal');
166 174
 						$qty = 98;
167
-					}
168
-					else {
175
+					} else {
169 176
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
170 177
 						$qty = $level ? 100-$level : 99;
171 178
 					}
172 179
 					dol_include_once('/subtotal/class/subtotal.class.php');
173 180
 					
174
-					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
181
+					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) {
182
+						TSubtotal::addSubtotalMissing($object, $qty);
183
+					}
175 184
 					
176 185
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
177
-				}
178
-				else if($action==='ask_deleteallline') {
186
+				} else if($action==='ask_deleteallline') {
179 187
 						$form=new Form($db);
180 188
 						
181 189
 						$lineid = GETPOST('lineid','integer');
@@ -198,8 +206,7 @@  discard block
 block discarded – undo
198 206
 					$this->printNewFormat($object, $conf, $langs, $idvar);
199 207
 				}
200 208
 			}
201
-		}
202
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
209
+		} elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
203 210
 		{
204 211
 			?>
205 212
 			<script type="text/javascript">
@@ -217,8 +224,13 @@  discard block
 block discarded – undo
217 224
      
218 225
 	function printNewFormat(&$object, &$conf, &$langs, $idvar)
219 226
 	{
220
-		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) return false;
221
-		if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) return false; // Si facture de situation
227
+		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) {
228
+			return false;
229
+		}
230
+		if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) {
231
+			return false;
232
+		}
233
+		// Si facture de situation
222 234
 		?>
223 235
 		 	<script type="text/javascript">
224 236
 				$(document).ready(function() {
@@ -504,8 +516,7 @@  discard block
 block discarded – undo
504 516
 				}
505 517
 				
506 518
 				
507
-			}	
508
-			else{
519
+			} else{
509 520
 				$substitutionarray['line_not_modsubtotal'] = true;
510 521
 				$substitutionarray['line_modsubtotal'] = 0;
511 522
 			}
@@ -563,8 +574,11 @@  discard block
 block discarded – undo
563 574
 		
564 575
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
565 576
 		
566
-		if($object->element=='facture') $idvar = 'facid';
567
-		else $idvar = 'id';
577
+		if($object->element=='facture') {
578
+			$idvar = 'facid';
579
+		} else {
580
+			$idvar = 'id';
581
+		}
568 582
 			
569 583
 		if ($action == 'updateligne' || $action == 'updateline')
570 584
 		{
@@ -594,8 +608,7 @@  discard block
 block discarded – undo
594 608
 				header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id);
595 609
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
596 610
 			}
597
-		}
598
-		else if($action === 'builddoc') {
611
+		} else if($action === 'builddoc') {
599 612
 			
600 613
 			if (
601 614
 				in_array('invoicecard',explode(':',$parameters['context']))
@@ -610,33 +623,27 @@  discard block
 block discarded – undo
610 623
 					$sessname = 'subtotal_hideInnerLines_facture';	
611 624
 					$sessname2 = 'subtotal_hidedetails_facture';
612 625
 					$sessname3 = 'subtotal_hideprices_facture';
613
-				}
614
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
626
+				} elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
615 627
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
616 628
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
617 629
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
618
-				}
619
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
630
+				} elseif(in_array('propalcard',explode(':',$parameters['context']))) {
620 631
 					$sessname = 'subtotal_hideInnerLines_propal';
621 632
 					$sessname2 = 'subtotal_hidedetails_propal';	
622 633
 					$sessname3 = 'subtotal_hideprices_propal';
623
-				}
624
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
634
+				} elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
625 635
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
626 636
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
627 637
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
628
-				}
629
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
638
+				} elseif(in_array('ordercard',explode(':',$parameters['context']))) {
630 639
 					$sessname = 'subtotal_hideInnerLines_commande';
631 640
 					$sessname2 = 'subtotal_hidedetails_commande';	
632 641
 					$sessname3 = 'subtotal_hideprices_commande';
633
-				}
634
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
642
+				} elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
635 643
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
636 644
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
637 645
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
638
-				}
639
-				else {
646
+				} else {
640 647
 					$sessname = 'subtotal_hideInnerLines_unknown';
641 648
 					$sessname2 = 'subtotal_hidedetails_unknown';
642 649
 					$sessname3 = 'subtotal_hideprices_unknown';
@@ -645,15 +652,24 @@  discard block
 block discarded – undo
645 652
 				global $hideprices;
646 653
 				
647 654
 				$hideInnerLines = (int)GETPOST('hideInnerLines');
648
-				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system
655
+				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) {
656
+					$_SESSION[$sessname] = array();
657
+				}
658
+				// prevent old system
649 659
 				$_SESSION[$sessname][$object->id] = $hideInnerLines;		
650 660
 				
651 661
 				$hidedetails= (int)GETPOST('hidedetails');
652
-				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system
662
+				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) {
663
+					$_SESSION[$sessname2] = array();
664
+				}
665
+				// prevent old system
653 666
 				$_SESSION[$sessname2][$object->id] = $hidedetails;
654 667
 				
655 668
 				$hideprices= (int)GETPOST('hideprices');
656
-				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system
669
+				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) {
670
+					$_SESSION[$sessname3] = array();
671
+				}
672
+				// prevent old system
657 673
 				$_SESSION[$sessname3][$object->id] = $hideprices;
658 674
 				
659 675
 				foreach($object->lines as &$line) {
@@ -661,8 +677,7 @@  discard block
 block discarded – undo
661 677
 					    
662 678
                         if($line->qty>=90) {
663 679
                             $line->modsubtotal_total = 1;
664
-                        }
665
-                        else{
680
+                        } else{
666 681
                             $line->modsubtotal_title = 1;
667 682
                         }
668 683
                         
@@ -671,8 +686,7 @@  discard block
 block discarded – undo
671 686
 	        	}
672 687
 	        }
673 688
 			
674
-		}
675
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
689
+		} else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
676 690
 			
677 691
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
678 692
 			
@@ -680,7 +694,9 @@  discard block
 block discarded – undo
680 694
 				/**
681 695
 				 * @var $object Facture
682 696
 				 */
683
-				if($object->element=='facture') $object->deleteline($idLine);
697
+				if($object->element=='facture') {
698
+					$object->deleteline($idLine);
699
+				}
684 700
 				/**
685 701
 				 * @var $object Facture fournisseur
686 702
 				 */
@@ -691,18 +707,25 @@  discard block
 block discarded – undo
691 707
 				/**
692 708
 				 * @var $object Propal
693 709
 				 */
694
-				else if($object->element=='propal') $object->deleteline($idLine);
710
+				else if($object->element=='propal') {
711
+					$object->deleteline($idLine);
712
+				}
695 713
 				/**
696 714
 				 * @var $object Propal Fournisseur
697 715
 				 */
698
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
716
+				else if($object->element=='supplier_proposal') {
717
+					$object->deleteline($idLine);
718
+				}
699 719
 				/**
700 720
 				 * @var $object Commande
701 721
 				 */
702 722
 				else if($object->element=='commande') 
703 723
 				{
704
-					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
705
-					else $object->deleteline($idLine);
724
+					if ((float) DOL_VERSION >= 5.0) {
725
+						$object->deleteline($user, $idLine);
726
+					} else {
727
+						$object->deleteline($idLine);
728
+					}
706 729
 				}
707 730
 				/**
708 731
 				 * @var $object Commande fournisseur
@@ -714,21 +737,26 @@  discard block
 block discarded – undo
714 737
 				/**
715 738
 				 * @var $object Facturerec
716 739
 				 */
717
-				else if($object->element=='facturerec') $object->deleteline($idLine);
740
+				else if($object->element=='facturerec') {
741
+					$object->deleteline($idLine);
742
+				}
718 743
 			}
719 744
 			
720 745
 			header('location:?id='.$object->id);
721 746
 			exit;
722 747
 			
723
-		}
724
-		else if ($action == 'duplicate')
748
+		} else if ($action == 'duplicate')
725 749
 		{
726 750
 			$lineid = GETPOST('lineid', 'int');
727 751
 			$nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true);
728 752
 			
729
-			if ($nbDuplicate > 0) setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
730
-			elseif ($nbDuplicate == 0) setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
731
-			else setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
753
+			if ($nbDuplicate > 0) {
754
+				setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
755
+			} elseif ($nbDuplicate == 0) {
756
+				setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
757
+			} else {
758
+				setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
759
+			}
732 760
 			
733 761
 			header('Location: ?id='.$object->id);
734 762
 			exit;
@@ -746,21 +774,26 @@  discard block
 block discarded – undo
746 774
 		global $conf;
747 775
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && !empty($object->table_element_line) && in_array($object->element, array('commande', 'facture', 'propal')))
748 776
 		{
749
-			if ($object->element == 'commande')
750
-				$obj = new OrderLine($object->db);
751
-			if ($object->element == 'propal')
752
-				$obj = new PropaleLigne($object->db);
753
-			if ($object->element == 'facture')
754
-				$obj = new FactureLigne($object->db);
777
+			if ($object->element == 'commande') {
778
+							$obj = new OrderLine($object->db);
779
+			}
780
+			if ($object->element == 'propal') {
781
+							$obj = new PropaleLigne($object->db);
782
+			}
783
+			if ($object->element == 'facture') {
784
+							$obj = new FactureLigne($object->db);
785
+			}
755 786
 			if (!empty($parameters['fk_element']))
756 787
 			{
757 788
 				
758 789
 				if($obj->fetch($parameters['fk_element'])){
759 790
 					$obj->id= $obj->rowid;
760
-					if (empty($obj->array_options))
761
-						$obj->fetch_optionals();
762
-					if (!empty($obj->array_options['options_subtotal_nc']))
763
-						return 1;
791
+					if (empty($obj->array_options)) {
792
+											$obj->fetch_optionals();
793
+					}
794
+					if (!empty($obj->array_options['options_subtotal_nc'])) {
795
+											return 1;
796
+					}
764 797
 				}
765 798
 			}
766 799
 		}
@@ -835,17 +868,18 @@  discard block
 block discarded – undo
835 868
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
836 869
 			if($l->rang>=$rang) {
837 870
 				//echo 'return!<br>';
838
-				if (!$return_all) return $total;
839
-				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
840
-			}
841
-			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
871
+				if (!$return_all) {
872
+					return $total;
873
+				} else {
874
+					return array($total, $total_tva, $total_ttc, $TTotal_tva);
875
+				}
876
+			} else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
842 877
 		  	{
843 878
 				$total = 0;
844 879
 				$total_tva = 0;
845 880
 				$total_ttc = 0;
846 881
 				$TTotal_tva = array();
847
-			}
848
-			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
882
+			} elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
849 883
 				$total += $l->total_ht;
850 884
 				$total_tva += $l->total_tva;
851 885
 				$TTotal_tva[$l->tva_tx] += $l->total_tva;
@@ -853,8 +887,11 @@  discard block
 block discarded – undo
853 887
 			}
854 888
 			
855 889
 		}
856
-		if (!$return_all) return $total;
857
-		else return array($total, $total_tva, $total_ttc, $TTotal_tva);
890
+		if (!$return_all) {
891
+			return $total;
892
+		} else {
893
+			return array($total, $total_tva, $total_ttc, $TTotal_tva);
894
+		}
858 895
 	}
859 896
 
860 897
 	/*
@@ -922,15 +959,18 @@  discard block
 block discarded – undo
922 959
 		}
923 960
 		
924 961
 			
925
-		if($line->qty==99)
926
-			$pdf->SetFillColor(220,220,220);
927
-		elseif ($line->qty==98)
928
-			$pdf->SetFillColor(230,230,230);
929
-		else
930
-			$pdf->SetFillColor(240,240,240);
962
+		if($line->qty==99) {
963
+					$pdf->SetFillColor(220,220,220);
964
+		} elseif ($line->qty==98) {
965
+					$pdf->SetFillColor(230,230,230);
966
+		} else {
967
+					$pdf->SetFillColor(240,240,240);
968
+		}
931 969
 		
932 970
 		$style = 'B';
933
-		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
971
+		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) {
972
+			$style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
973
+		}
934 974
 		
935 975
 		$pdf->SetFont('', $style, 9);
936 976
 		
@@ -969,8 +1009,7 @@  discard block
 block discarded – undo
969 1009
 //					$line->total_tva
970 1010
 //					$line->total
971 1011
 //					$line->total_ttc
972
-				}
973
-				else
1012
+				} else
974 1013
 				{
975 1014
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
976 1015
                                         if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
@@ -987,11 +1026,14 @@  discard block
 block discarded – undo
987 1026
 			}
988 1027
 
989 1028
 			$pdf->SetXY($pdf->postotalht, $posy);
990
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1029
+			if($set_pagebreak_margin) {
1030
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1031
+			}
991 1032
 			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
992
-		}
993
-		else{
994
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1033
+		} else{
1034
+			if($set_pagebreak_margin) {
1035
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1036
+			}
995 1037
 		}
996 1038
 		
997 1039
 		$posy = $posy + $cell_height;
@@ -1023,25 +1065,40 @@  discard block
 block discarded – undo
1023 1065
 		
1024 1066
  
1025 1067
 		$style = ($line->qty==1) ? 'BU' : 'BUI';
1026
-		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
1068
+		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) {
1069
+			$style = $conf->global->SUBTOTAL_TITLE_STYLE;
1070
+		}
1027 1071
 		
1028 1072
 		if($hideInnerLines) {
1029
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
1030
-			else 
1073
+			if($line->qty==1) {
1074
+				$pdf->SetFont('', $style, 9);
1075
+			} else 
1031 1076
 			{
1032
-				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1077
+				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) {
1078
+					$style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1079
+				}
1033 1080
 				$pdf->SetFont('', $style, 9);
1034 1081
 			}
1035
-		}
1036
-		else {
1082
+		} else {
1037 1083
 
1038
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
1039
-			else $pdf->SetFont('', $style, 9);
1084
+			if($line->qty==1) {
1085
+				$pdf->SetFont('', $style, 9);
1086
+			}
1087
+			//TODO if super utile
1088
+			else {
1089
+				$pdf->SetFont('', $style, 9);
1090
+			}
1040 1091
 			
1041 1092
 		}
1042 1093
 		
1043
-		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
1044
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
1094
+		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) {
1095
+			$pdf->MultiCell($w, $h, $label, 0, 'L');
1096
+		}
1097
+		// Pas de HTML dans la chaine
1098
+		else {
1099
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true);
1100
+		}
1101
+		// et maintenant avec du HTML
1045 1102
 		
1046 1103
 		if($description && !$hidedesc) {
1047 1104
 			$posy = $pdf->GetY();
@@ -1065,8 +1122,7 @@  discard block
 block discarded – undo
1065 1122
 		
1066 1123
 		if(is_array($parameters)) {
1067 1124
 			$i = & $parameters['i'];	
1068
-		}
1069
-		else {
1125
+		} else {
1070 1126
 			$i = (int)$parameters;
1071 1127
 		}
1072 1128
 		
@@ -1088,17 +1144,14 @@  discard block
 block discarded – undo
1088 1144
 			
1089 1145
 			if((float)DOL_VERSION<=3.6) {
1090 1146
 				return '';
1091
-			}
1092
-			else if((float)DOL_VERSION>=3.8) {
1147
+			} else if((float)DOL_VERSION>=3.8) {
1093 1148
 				return 1;
1094 1149
 			}
1095 1150
 			
1096
-		}
1097
-		elseif(!empty($hideprices)) {
1151
+		} elseif(!empty($hideprices)) {
1098 1152
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1099 1153
 			return 1;
1100
-		}
1101
-		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1154
+		} elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1102 1155
 		{
1103 1156
 			$hideInnerLines = (int)GETPOST('hideInnerLines');
1104 1157
 			$hidedetails = (int)GETPOST('hidedetails');
@@ -1108,12 +1161,20 @@  discard block
 block discarded – undo
1108 1161
 			}
1109 1162
 		}
1110 1163
 		
1111
-		if(is_array($parameters)) $i = & $parameters['i'];
1112
-		else $i = (int)$parameters;
1164
+		if(is_array($parameters)) {
1165
+			$i = & $parameters['i'];
1166
+		} else {
1167
+			$i = (int)$parameters;
1168
+		}
1113 1169
 
1114
-		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)
1170
+		if (empty($object->lines[$i])) {
1171
+			return 0;
1172
+		}
1173
+		// 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)
1115 1174
 		
1116
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1175
+		if(empty($object->lines[$i]->array_options)) {
1176
+			$object->lines[$i]->fetch_optionals();
1177
+		}
1117 1178
 
1118 1179
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1119 1180
 		{
@@ -1130,8 +1191,11 @@  discard block
 block discarded – undo
1130 1191
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1131 1192
 	    global $conf, $hideprices, $hookmanager;
1132 1193
 		
1133
-		if(is_array($parameters)) $i = & $parameters['i'];
1134
-		else $i = (int)$parameters;
1194
+		if(is_array($parameters)) {
1195
+			$i = & $parameters['i'];
1196
+		} else {
1197
+			$i = (int)$parameters;
1198
+		}
1135 1199
 			
1136 1200
 		if($this->isModSubtotalLine($parameters,$object) ){
1137 1201
 			
@@ -1139,13 +1203,11 @@  discard block
 block discarded – undo
1139 1203
 			
1140 1204
 			if((float)DOL_VERSION<=3.6) {
1141 1205
 				return '';
1142
-			}
1143
-			else if((float)DOL_VERSION>=3.8) {
1206
+			} else if((float)DOL_VERSION>=3.8) {
1144 1207
 				return 1;
1145 1208
 			}
1146 1209
 			
1147
-		}
1148
-		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1210
+		} elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1149 1211
 		{
1150 1212
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1151 1213
 			{
@@ -1217,12 +1279,10 @@  discard block
 block discarded – undo
1217 1279
 			$this->error = $hookmanager->error;
1218 1280
 			$this->errors = $hookmanager->errors;
1219 1281
 			return -1;
1220
-		}
1221
-		elseif (empty($reshook))
1282
+		} elseif (empty($reshook))
1222 1283
 		{
1223 1284
 			$this->resprints .= $hookmanager->resprints;
1224
-		}
1225
-		else
1285
+		} else
1226 1286
 		{
1227 1287
 			$this->resprints = $hookmanager->resprints;
1228 1288
 
@@ -1245,14 +1305,16 @@  discard block
 block discarded – undo
1245 1305
 		
1246 1306
 			if((float)DOL_VERSION<=3.6) {
1247 1307
 				return '';
1248
-			}
1249
-			else if((float)DOL_VERSION>=3.8) {
1308
+			} else if((float)DOL_VERSION>=3.8) {
1250 1309
 				return 1;
1251 1310
 			}
1252 1311
 		}
1253 1312
 		
1254
-		if(is_array($parameters)) $i = & $parameters['i'];
1255
-		else $i = (int)$parameters;
1313
+		if(is_array($parameters)) {
1314
+			$i = & $parameters['i'];
1315
+		} else {
1316
+			$i = (int)$parameters;
1317
+		}
1256 1318
 		
1257 1319
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1258 1320
 		{
@@ -1274,14 +1336,16 @@  discard block
 block discarded – undo
1274 1336
 		
1275 1337
 			if((float)DOL_VERSION<=3.6) {
1276 1338
 				return '';
1277
-			}
1278
-			else if((float)DOL_VERSION>=3.8) {
1339
+			} else if((float)DOL_VERSION>=3.8) {
1279 1340
 				return 1;
1280 1341
 			}
1281 1342
 		}
1282 1343
 		
1283
-		if(is_array($parameters)) $i = & $parameters['i'];
1284
-		else $i = (int)$parameters;
1344
+		if(is_array($parameters)) {
1345
+			$i = & $parameters['i'];
1346
+		} else {
1347
+			$i = (int)$parameters;
1348
+		}
1285 1349
 			
1286 1350
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1287 1351
 		{
@@ -1303,13 +1367,15 @@  discard block
 block discarded – undo
1303 1367
 		
1304 1368
 			if((float)DOL_VERSION<=3.6) {
1305 1369
 				return '';
1306
-			}
1307
-			else if((float)DOL_VERSION>=3.8) {
1370
+			} else if((float)DOL_VERSION>=3.8) {
1308 1371
 				return 1;
1309 1372
 			}
1310 1373
 		}
1311
-		if(is_array($parameters)) $i = & $parameters['i'];
1312
-		else $i = (int)$parameters;
1374
+		if(is_array($parameters)) {
1375
+			$i = & $parameters['i'];
1376
+		} else {
1377
+			$i = (int)$parameters;
1378
+		}
1313 1379
 		
1314 1380
 		
1315 1381
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1356,14 +1422,16 @@  discard block
 block discarded – undo
1356 1422
 			$this->resprints = ' ';
1357 1423
 			if((float)DOL_VERSION<=3.6) {
1358 1424
 				return '';
1359
-			}
1360
-			else if((float)DOL_VERSION>=3.8) {
1425
+			} else if((float)DOL_VERSION>=3.8) {
1361 1426
 				return 1;
1362 1427
 			}
1363 1428
 		}
1364 1429
 		
1365
-		if(is_array($parameters)) $i = & $parameters['i'];
1366
-		else $i = (int)$parameters;
1430
+		if(is_array($parameters)) {
1431
+			$i = & $parameters['i'];
1432
+		} else {
1433
+			$i = (int)$parameters;
1434
+		}
1367 1435
 			
1368 1436
 		if (!empty($hideprices)
1369 1437
 				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1387,16 +1455,21 @@  discard block
 block discarded – undo
1387 1455
 			
1388 1456
 			if((float)DOL_VERSION<=3.6) {
1389 1457
 				return '';
1390
-			}
1391
-			else if((float)DOL_VERSION>=3.8) {
1458
+			} else if((float)DOL_VERSION>=3.8) {
1392 1459
 				return 1;
1393 1460
 			}
1394 1461
 		}
1395 1462
 		
1396
-		if(is_array($parameters)) $i = & $parameters['i'];
1397
-		else $i = (int)$parameters;
1463
+		if(is_array($parameters)) {
1464
+			$i = & $parameters['i'];
1465
+		} else {
1466
+			$i = (int)$parameters;
1467
+		}
1398 1468
 		
1399
-		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)
1469
+		if (empty($object->lines[$i])) {
1470
+			return 0;
1471
+		}
1472
+		// 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)
1400 1473
 
1401 1474
 		$object->lines[$i]->fetch_optionals();
1402 1475
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1442,14 +1515,16 @@  discard block
 block discarded – undo
1442 1515
 			$this->resprints = ' ';
1443 1516
 			if((float)DOL_VERSION<=3.6) {
1444 1517
 				return '';
1445
-			}
1446
-			else if((float)DOL_VERSION>=3.8) {
1518
+			} else if((float)DOL_VERSION>=3.8) {
1447 1519
 				return 1;
1448 1520
 			}
1449 1521
 		}
1450 1522
 		
1451
-		if(is_array($parameters)) $i = & $parameters['i'];
1452
-		else $i = (int)$parameters;
1523
+		if(is_array($parameters)) {
1524
+			$i = & $parameters['i'];
1525
+		} else {
1526
+			$i = (int)$parameters;
1527
+		}
1453 1528
 			
1454 1529
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1455 1530
 		{
@@ -1479,7 +1554,9 @@  discard block
 block discarded – undo
1479 1554
 				}
1480 1555
 			}
1481 1556
 			
1482
-			if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1557
+			if (!empty($TLineTitle)) {
1558
+				$TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1559
+			}
1483 1560
 		}
1484 1561
 		
1485 1562
 	}
@@ -1493,8 +1570,12 @@  discard block
 block discarded – undo
1493 1570
 		$j=0;
1494 1571
 		foreach ($TLineTitle as $k => &$line)
1495 1572
 		{
1496
-			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
1497
-			if (!empty($line_reference) && $line->qty <= $line_reference->qty) break;
1573
+			if (!empty($line_reference) && $line->rang <= $line_reference->rang) {
1574
+				continue;
1575
+			}
1576
+			if (!empty($line_reference) && $line->qty <= $line_reference->qty) {
1577
+				break;
1578
+			}
1498 1579
 			
1499 1580
 			if ($line->qty == $level)
1500 1581
 			{
@@ -1528,7 +1609,9 @@  discard block
 block discarded – undo
1528 1609
 		
1529 1610
 		$hidedetails = (int)GETPOST('hidedetails');
1530 1611
 		
1531
-		if(empty($hidedetails)) return false;
1612
+		if(empty($hidedetails)) {
1613
+			return false;
1614
+		}
1532 1615
 		
1533 1616
 		// TODO can't add VAT to document without lines... :-/
1534 1617
 		
@@ -1581,7 +1664,9 @@  discard block
 block discarded – undo
1581 1664
 						*/
1582 1665
 						list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
1583 1666
 						
1584
-						if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TTotal_tva;
1667
+						if (TSubtotal::getNiveau($line) == 1) {
1668
+							$line->TTotal_tva = $TTotal_tva;
1669
+						}
1585 1670
 						$line->total_ht = $total;
1586 1671
 						$line->total_tva = $total_tva;
1587 1672
 						$line->total = $line->total_ht;
@@ -1636,8 +1721,7 @@  discard block
 block discarded – undo
1636 1721
 				    }
1637 1722
 				    
1638 1723
 					
1639
-				}
1640
-				elseif ($hidedetails)
1724
+				} elseif ($hidedetails)
1641 1725
 				{
1642 1726
 					$TLines[] = $line; //Cas où je cache uniquement les prix des produits	
1643 1727
 				}
@@ -1708,7 +1792,9 @@  discard block
 block discarded – undo
1708 1792
 				
1709 1793
 				if(!empty($hideprices)) {
1710 1794
 					foreach($object->lines as &$line) {
1711
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1795
+						if($line->fk_product_type!=9) {
1796
+							$line->fk_parent_line = -1;
1797
+						}
1712 1798
 					}
1713 1799
 				}
1714 1800
 			
@@ -1729,7 +1815,9 @@  discard block
 block discarded – undo
1729 1815
 				
1730 1816
 				if($line->qty>90) {
1731 1817
 					
1732
-					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1818
+					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) {
1819
+						$label .= ' '.$this->getTitle($object, $line);
1820
+					}
1733 1821
 					
1734 1822
 					$pageBefore = $pdf->getPage();
1735 1823
 					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
@@ -1747,8 +1835,7 @@  discard block
 block discarded – undo
1747 1835
 				
1748 1836
 					$posy = $pdf->GetY();
1749 1837
 					return 1;
1750
-				}	
1751
-				else if ($line->qty < 10) {
1838
+				} else if ($line->qty < 10) {
1752 1839
 					$pageBefore = $pdf->getPage();
1753 1840
 
1754 1841
 					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
@@ -1772,8 +1859,7 @@  discard block
 block discarded – undo
1772 1859
 //	if($line->rowid==47) exit;
1773 1860
 			
1774 1861
 			return 0;
1775
-		}
1776
-		elseif (empty($object->lines[$parameters['i']]))
1862
+		} elseif (empty($object->lines[$parameters['i']]))
1777 1863
 		{
1778 1864
 			$this->resprints = -1;
1779 1865
 		}
@@ -1806,7 +1892,9 @@  discard block
 block discarded – undo
1806 1892
 		
1807 1893
 		foreach ($object->lines as $line)
1808 1894
 		{
1809
-			if ($line->id == $currentLine->id) break;
1895
+			if ($line->id == $currentLine->id) {
1896
+				break;
1897
+			}
1810 1898
 			
1811 1899
 			$qty_search = 100 - $currentLine->qty;
1812 1900
 			
@@ -1843,23 +1931,23 @@  discard block
 block discarded – undo
1843 1931
 		{
1844 1932
 			$object->statut = 0; // hack for facture rec
1845 1933
 			$createRight = $user->rights->facture->creer;
1846
-		}
1847
-		elseif($object->element == 'order_supplier' )
1934
+		} elseif($object->element == 'order_supplier' )
1848 1935
 		{
1849 1936
 		    $createRight = $user->rights->fournisseur->commande->creer;
1850
-		}
1851
-		elseif($object->element == 'invoice_supplier' )
1937
+		} elseif($object->element == 'invoice_supplier' )
1852 1938
 		{
1853 1939
 		    $createRight = $user->rights->fournisseur->facture->creer;
1854 1940
 		}
1855 1941
 		
1856 1942
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1857 1943
 			null;
1858
-		}	
1859
-		else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) 
1944
+		} else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) 
1860 1945
         {
1861
-			if($object->element=='facture')$idvar = 'facid';
1862
-			else $idvar='id';
1946
+			if($object->element=='facture') {
1947
+				$idvar = 'facid';
1948
+			} else {
1949
+				$idvar='id';
1950
+			}
1863 1951
 			
1864 1952
 			if((float)DOL_VERSION <= 3.4)
1865 1953
 			{
@@ -1885,20 +1973,44 @@  discard block
 block discarded – undo
1885 1973
 				<?php
1886 1974
 			}
1887 1975
 			
1888
-			if(empty($line->description)) $line->description = $line->desc;
1976
+			if(empty($line->description)) {
1977
+				$line->description = $line->desc;
1978
+			}
1889 1979
 			
1890 1980
 			$colspan = 5;
1891
-			if($object->element == 'facturerec' ) $colspan = 3;
1892
-			if($object->element == 'order_supplier') $colspan = 3;
1893
-			if($object->element == 'invoice_supplier') $colspan = 4;
1894
-			if($object->element == 'supplier_proposal') $colspan = 4;
1895
-			if(!empty($conf->multicurrency->enabled)) $colspan+=2;
1896
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1897
-			if(!empty($conf->margin->enabled)) $colspan++;
1898
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1899
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1900
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1901
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1981
+			if($object->element == 'facturerec' ) {
1982
+				$colspan = 3;
1983
+			}
1984
+			if($object->element == 'order_supplier') {
1985
+				$colspan = 3;
1986
+			}
1987
+			if($object->element == 'invoice_supplier') {
1988
+				$colspan = 4;
1989
+			}
1990
+			if($object->element == 'supplier_proposal') {
1991
+				$colspan = 4;
1992
+			}
1993
+			if(!empty($conf->multicurrency->enabled)) {
1994
+				$colspan+=2;
1995
+			}
1996
+			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) {
1997
+				$colspan++;
1998
+			}
1999
+			if(!empty($conf->margin->enabled)) {
2000
+				$colspan++;
2001
+			}
2002
+			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) {
2003
+				$colspan++;
2004
+			}
2005
+			if(!empty($conf->global->DISPLAY_MARK_RATES)) {
2006
+				$colspan++;
2007
+			}
2008
+			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) {
2009
+				$colspan++;
2010
+			}
2011
+			if(!empty($conf->global->PRODUCT_USE_UNITS)) {
2012
+				$colspan++;
2013
+			}
1902 2014
 					
1903 2015
 			/* Titre */
1904 2016
 			//var_dump($line);
@@ -1911,23 +2023,36 @@  discard block
 block discarded – undo
1911 2023
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1912 2024
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
1913 2025
 					{
1914
-						if($line->qty==99) print 'background:#adadcf';
1915
-						else if($line->qty==98) print 'background:#ddddff;';
1916
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
1917
-						else if($line->qty==1) print 'background:#adadcf;';
1918
-						else if($line->qty==2) print 'background:#ddddff;';
1919
-						else if($line->qty==50) print '';
1920
-						else print 'background:#eeeeff;';
2026
+						if($line->qty==99) {
2027
+							print 'background:#adadcf';
2028
+						} else if($line->qty==98) {
2029
+							print 'background:#ddddff;';
2030
+						} else if($line->qty<=97 && $line->qty>=91) {
2031
+							print 'background:#eeeeff;';
2032
+						} else if($line->qty==1) {
2033
+							print 'background:#adadcf;';
2034
+						} else if($line->qty==2) {
2035
+							print 'background:#ddddff;';
2036
+						} else if($line->qty==50) {
2037
+							print '';
2038
+						} else {
2039
+							print 'background:#eeeeff;';
2040
+						}
1921 2041
 
1922 2042
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
1923
-					}
1924
-					else 
2043
+					} else 
1925 2044
 					{
1926
-						if($line->qty==99) print 'background:#ddffdd';
1927
-						else if($line->qty==98) print 'background:#ddddff;';
1928
-						else if($line->qty==2) print 'background:#eeeeff; ';
1929
-						else if($line->qty==50) print '';
1930
-						else print 'background:#eeffee;' ;
2045
+						if($line->qty==99) {
2046
+							print 'background:#ddffdd';
2047
+						} else if($line->qty==98) {
2048
+							print 'background:#ddddff;';
2049
+						} else if($line->qty==2) {
2050
+							print 'background:#eeeeff; ';
2051
+						} else if($line->qty==50) {
2052
+							print '';
2053
+						} else {
2054
+							print 'background:#eeffee;' ;
2055
+						}
1931 2056
 					}
1932 2057
 
1933 2058
 			?>;">
@@ -1950,13 +2075,11 @@  discard block
 block discarded – undo
1950 2075
 							$qty_displayed = $line->qty;
1951 2076
 							print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
1952 2077
 							
1953
-						}
1954
-						else if (TSubtotal::isSubtotal($line))
2078
+						} else if (TSubtotal::isSubtotal($line))
1955 2079
 						{
1956 2080
 							$qty_displayed = 100 - $line->qty;
1957 2081
 							print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
1958
-						}
1959
-						else
2082
+						} else
1960 2083
 						{
1961 2084
 							$isFreeText = true;
1962 2085
 						}
@@ -1977,9 +2100,13 @@  discard block
 block discarded – undo
1977 2100
 						}
1978 2101
 
1979 2102
 						$readonlyForSituation = '';
1980
-						if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) $readonlyForSituation = 'readonly';
2103
+						if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) {
2104
+							$readonlyForSituation = 'readonly';
2105
+						}
1981 2106
 						
1982
-						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2107
+						if (!$isFreeText) {
2108
+							echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2109
+						}
1983 2110
 						
1984 2111
 						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
1985 2112
 						{
@@ -1987,8 +2114,12 @@  discard block
 block discarded – undo
1987 2114
 							for ($j=1; $j<10; $j++)
1988 2115
 							{
1989 2116
 								if (!empty($readonlyForSituation)) {
1990
-									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
1991
-								} else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2117
+									if ($qty_displayed == $j) {
2118
+										$select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2119
+									}
2120
+								} else {
2121
+									$select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2122
+								}
1992 2123
 							}
1993 2124
 							$select .= '</select>&nbsp;';
1994 2125
 
@@ -2004,15 +2135,18 @@  discard block
 block discarded – undo
2004 2135
 								$form = new Form($db);
2005 2136
 								echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2006 2137
 								echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2007
-								if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2138
+								if (empty($readonlyForSituation)) {
2139
+									echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2140
+								}
2008 2141
 								echo '</select>&nbsp;&nbsp;';
2009 2142
 								
2010 2143
 								if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
2011 2144
 								{
2012 2145
 									echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%';
2013 2146
 								}
2147
+							} else if ($isFreeText) {
2148
+								echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2014 2149
 							}
2015
-							else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2016 2150
 						echo '</div>';
2017 2151
 
2018 2152
 						if($line->qty<10) {
@@ -2032,8 +2166,7 @@  discard block
 block discarded – undo
2032 2166
 							$doleditor->Create();
2033 2167
 						}
2034 2168
 						
2035
-					}
2036
-					else {
2169
+					} else {
2037 2170
 
2038 2171
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2039 2172
 						 {
@@ -2041,14 +2174,19 @@  discard block
 block discarded – undo
2041 2174
 							{
2042 2175
 								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2043 2176
 								
2044
-								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2045
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2177
+								if (TSubtotal::isTitle($line)) {
2178
+									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2179
+								} else {
2180
+									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2181
+								}
2046 2182
 							}
2047
-						 }
2048
-						 else 
2183
+						 } else 
2049 2184
 						 {
2050
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2051
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2185
+							if($line->qty<=1) {
2186
+								print img_picto('', 'subtotal@subtotal');
2187
+							} else if($line->qty==2) {
2188
+								print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2189
+							}
2052 2190
 						 }
2053 2191
 						 
2054 2192
 						 
@@ -2058,21 +2196,26 @@  discard block
 block discarded – undo
2058 2196
 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2059 2197
 						 
2060 2198
 						 if (empty($line->label)) {
2061
-							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2062
-							else print  $line->description;
2063
-						 } 
2064
-						 else {
2199
+							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2200
+								print  $line->description.' '.$this->getTitle($object, $line);
2201
+							} else {
2202
+								print  $line->description;
2203
+							}
2204
+						 } else {
2065 2205
 
2066 2206
 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2067 2207
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2068
-							}
2069
-							else{
2208
+							} else{
2070 2209
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
2071 2210
 							}
2072 2211
 
2073 2212
 						 } 
2074
-						if($line->qty>90) print ' : ';
2075
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2213
+						if($line->qty>90) {
2214
+							print ' : ';
2215
+						}
2216
+						if($line->info_bits > 0) {
2217
+							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2218
+						}
2076 2219
 
2077 2220
 						 
2078 2221
 
@@ -2109,11 +2252,12 @@  discard block
 block discarded – undo
2109 2252
 						</script>
2110 2253
 						<?php
2111 2254
 						
2112
-					}
2113
-					else{
2255
+					} else{
2114 2256
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2115 2257
 						{
2116
-							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>';
2258
+							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) {
2259
+								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2260
+							}
2117 2261
 						}
2118 2262
 
2119 2263
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
@@ -2182,7 +2326,9 @@  discard block
 block discarded – undo
2182 2326
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2183 2327
 				
2184 2328
 				$colspan+=3; $mode = 'view';
2185
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2329
+				if($action === 'editline' && $line->rowid == GETPOST('lineid')) {
2330
+					$mode = 'edit';
2331
+				}
2186 2332
 				
2187 2333
 				$ex_element = $line->element;
2188 2334
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
@@ -2364,10 +2510,9 @@  discard block
 block discarded – undo
2364 2510
 	    
2365 2511
 	    if(TSubtotal::isTitle($line)){
2366 2512
 	        $ThtmlData['data-issubtotal'] = 'title';
2367
-	    }elseif(TSubtotal::isSubtotal($line)){
2513
+	    } elseif(TSubtotal::isSubtotal($line)){
2368 2514
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2369
-	    }
2370
-	    else{
2515
+	    } else{
2371 2516
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2372 2517
 	    }
2373 2518
 	    
@@ -2377,7 +2522,9 @@  discard block
 block discarded – undo
2377 2522
 	    
2378 2523
 	    // hook 
2379 2524
 	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2380
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2525
+	    if ($reshook < 0) {
2526
+	    	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2527
+	    }
2381 2528
 	    if ($reshook>0)
2382 2529
 	    {
2383 2530
 	        $ThtmlData = $hookmanager->resArray;
Please login to merge, or discard this patch.
script/maj_subtotal_nc.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,9 @@  discard block
 block discarded – undo
13 13
 $sql = 'SELECT rowid';
14 14
 $sql .= ' FROM '.MAIN_DB_PREFIX.'propal';
15 15
 $sql .= ' WHERE total_ht + tva != total';
16
-if(! empty($limit)) $sql .= ' LIMIT '.$limit;
16
+if(! empty($limit)) {
17
+	$sql .= ' LIMIT '.$limit;
18
+}
17 19
 
18 20
 $resql = $db->query($sql);
19 21
 if($resql) {
@@ -24,7 +26,9 @@  discard block
 block discarded – undo
24 26
 		$propal->fetch($obj->rowid);
25 27
 
26 28
 		foreach($propal->lines as &$l) {
27
-			if(empty($l->array_options)) $l->fetch_optionals();
29
+			if(empty($l->array_options)) {
30
+				$l->fetch_optionals();
31
+			}
28 32
 			if(! empty($l->array_options['options_subtotal_nc']) && ! TSubtotal::isModSubtotalLine($l)) {
29 33
 				_updateLineNC($propal->element, $propal->id, $l->id, $l->array_options['options_subtotal_nc']);
30 34
 			}
Please login to merge, or discard this patch.
core/triggers/interface_90_modSubtotal_subtotaltrigger.class.php 1 patch
Braces   +70 added lines, -31 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
 			
@@ -192,8 +198,11 @@  discard block
 block discarded – undo
192 198
 						break;
193 199
 				}
194 200
 				
195
-				if (!empty($conf->global->SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK)) $this->addToEnd($parent, $object, $rang);
196
-				else $this->addToBegin($parent, $object, $rang);
201
+				if (!empty($conf->global->SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK)) {
202
+					$this->addToEnd($parent, $object, $rang);
203
+				} else {
204
+					$this->addToBegin($parent, $object, $rang);
205
+				}
197 206
 				
198 207
 			}
199 208
 			
@@ -221,7 +230,9 @@  discard block
 block discarded – undo
221 230
 						$commande->fetch($current_fk_commande);
222 231
 						
223 232
 						$label = $conf->global->SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE;
224
-						if (empty($label)) $label = 'Commande [__REFORDER__] - Référence client : [__REFCUSTOMER__]';
233
+						if (empty($label)) {
234
+							$label = 'Commande [__REFORDER__] - Référence client : [__REFCUSTOMER__]';
235
+						}
225 236
 						$label = str_replace(array('__REFORDER__', '__REFCUSTOMER__'), array($commande->ref, $commande->ref_client), $label);
226 237
 						
227 238
 						TSubtotal::addTitle($facture, $label, 1, $rang);
@@ -272,32 +283,50 @@  discard block
 block discarded – undo
272 283
 						$object->total_ht = $object->total_tva = $object->total_ttc = $object->total_localtax1 = $object->total_localtax2 = 
273 284
 							$object->multicurrency_total_ht = $object->multicurrency_total_tva = $object->multicurrency_total_ttc = 0;
274 285
 
275
-						if ($object->element == 'propal') $res = $object->update(1);
276
-						else $res = $object->update($user, 1);
286
+						if ($object->element == 'propal') {
287
+							$res = $object->update(1);
288
+						} else {
289
+							$res = $object->update($user, 1);
290
+						}
277 291
 						
278
-						if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success'));
292
+						if ($res > 0) {
293
+							setEventMessage($langs->trans('subtotal_update_nc_success'));
294
+						}
279 295
 						break;
280 296
 					}
281 297
 				}
282 298
 
283 299
 				// $object correspond à la ligne ajoutée
284
-				if(empty($object->array_options)) $object->fetch_optionals();
300
+				if(empty($object->array_options)) {
301
+					$object->fetch_optionals();
302
+				}
285 303
 
286 304
 				if(! empty($object->array_options['options_subtotal_nc'])) {
287 305
 					$object->total_ht = $object->total_tva = $object->total_ttc = $object->total_localtax1 = $object->total_localtax2 = 
288 306
 							$object->multicurrency_total_ht = $object->multicurrency_total_tva = $object->multicurrency_total_ttc = 0;
289 307
 
290
-					if ($object->element == 'propaldet') $res = $object->update(1);
291
-					else $res = $object->update($user, 1);
308
+					if ($object->element == 'propaldet') {
309
+						$res = $object->update(1);
310
+					} else {
311
+						$res = $object->update($user, 1);
312
+					}
292 313
 
293
-					if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success'));
314
+					if ($res > 0) {
315
+						setEventMessage($langs->trans('subtotal_update_nc_success'));
316
+					}
294 317
 				}
295 318
 
296 319
 				// Correction d'un bug lors de la création d'une commande depuis une propale qui a, au moins, une ligne NC
297 320
 				$parent_element = '';
298
-				if($object->element == 'propaldet') $parent_element = 'propal';
299
-				if($object->element == 'commandedet') $parent_element = 'commande';
300
-				if($object->element == 'facturedet') $parent_element = 'facture';
321
+				if($object->element == 'propaldet') {
322
+					$parent_element = 'propal';
323
+				}
324
+				if($object->element == 'commandedet') {
325
+					$parent_element = 'commande';
326
+				}
327
+				if($object->element == 'facturedet') {
328
+					$parent_element = 'facture';
329
+				}
301 330
 
302 331
 				if(! empty($parent_element) && ! empty($object->array_options['options_subtotal_nc'])) {
303 332
 					_updateLineNC($parent_element, $object->{'fk_'.$parent_element}, $object->id, $object->array_options['options_subtotal_nc'], 1);
@@ -497,26 +526,38 @@  discard block
 block discarded – undo
497 526
 				);
498 527
 				
499 528
 				// En fonction de l'objet et de la version, les lignes conservent l'id de l'objet d'origine
500
-				if (method_exists($object, 'fetch_lines')) $object->fetch_lines();
501
-				else $object->fetch($object->id);
529
+				if (method_exists($object, 'fetch_lines')) {
530
+					$object->fetch_lines();
531
+				} else {
532
+					$object->fetch($object->id);
533
+				}
502 534
 			
503 535
 				foreach ($object->lines as &$line)
504 536
 				{
505
-					if (empty($line->array_options)) $line->fetch_optionals();
537
+					if (empty($line->array_options)) {
538
+						$line->fetch_optionals();
539
+					}
506 540
 					
507 541
 					if (!TSubtotal::isModSubtotalLine($line) && !empty($line->array_options['options_subtotal_nc']))
508 542
 					{
509 543
 						$line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = 
510 544
 							$line->multicurrency_total_ht = $line->multicurrency_total_tva = $line->multicurrency_total_ttc = 0;
511 545
 
512
-						if ($line->element == 'propaldet') $res = $line->update(1);
513
-						else $res = $line->update($user, 1);
546
+						if ($line->element == 'propaldet') {
547
+							$res = $line->update(1);
548
+						} else {
549
+							$res = $line->update($user, 1);
550
+						}
514 551
 						
515
-						if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success'));
552
+						if ($res > 0) {
553
+							setEventMessage($langs->trans('subtotal_update_nc_success'));
554
+						}
516 555
 					}
517 556
 				}
518 557
 				
519
-				if (!empty($line)) $object->update_price(1);
558
+				if (!empty($line)) {
559
+					$object->update_price(1);
560
+				}
520 561
 			}
521 562
 			
522 563
         } elseif ($action == 'PROPAL_MODIFY') {
@@ -586,9 +627,7 @@  discard block
 block discarded – undo
586 627
             dol_syslog(
587 628
                 "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
588 629
             );
589
-        }
590
-
591
-		elseif ($action == 'BILL_MODIFY') {
630
+        } elseif ($action == 'BILL_MODIFY') {
592 631
             dol_syslog(
593 632
                 "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
594 633
             );
Please login to merge, or discard this patch.