Completed
Push — master ( f50dd8...4e6d28 )
by
unknown
12s queued 11s
created
lib/subtotal.lib.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -41,21 +41,21 @@  discard block
 block discarded – undo
41 41
     $head[$h][2] = 'about';
42 42
     $h++;
43 43
 
44
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel=false);
44
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel = false);
45 45
 
46 46
     return $head;
47 47
 }
48 48
 
49
-function getHtmlSelectTitle(&$object, $showLabel=false)
49
+function getHtmlSelectTitle(&$object, $showLabel = false)
50 50
 {
51 51
 	global $langs;
52 52
 	
53
-	require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
53
+	require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
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>';
58
-	$html.= '<select onChange="$(\'select[name=under_title]\').val(this.value);" name="under_title" class="under_title minwidth200"><option value="-1"></option>';
57
+	if ($showLabel) $html .= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>';
58
+	$html .= '<select onChange="$(\'select[name=under_title]\').val(this.value);" name="under_title" class="under_title minwidth200"><option value="-1"></option>';
59 59
 	
60 60
 	$nbsp = '&nbsp;';
61 61
 	foreach ($TTitle as &$line)
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
 function getTFreeText()
72 72
 {
73
-	global $db,$conf;
73
+	global $db, $conf;
74 74
 	
75 75
 	$TFreeText = array();
76 76
 	
@@ -88,19 +88,19 @@  discard block
 block discarded – undo
88 88
 	return $TFreeText;
89 89
 }
90 90
 
91
-function getHtmlSelectFreeText($withEmpty=true)
91
+function getHtmlSelectFreeText($withEmpty = true)
92 92
 {
93 93
 	global $langs;
94 94
 	
95 95
 	$TFreeText = getTFreeText();
96 96
 	$html = '<label for="free_text">'.$langs->trans('subtotalLabelForFreeText').'</label>';
97
-	$html.= '<select onChange="getTFreeText($(this));" name="free_text" class="minwidth200">';
98
-	if ($withEmpty) $html.= '<option value=""></option>';
97
+	$html .= '<select onChange="getTFreeText($(this));" name="free_text" class="minwidth200">';
98
+	if ($withEmpty) $html .= '<option value=""></option>';
99 99
 
100 100
 	$TFreeTextContents = array();
101 101
 	foreach ($TFreeText as $id => $tab)
102 102
 	{
103
-		$html.= '<option value="'.$id.'">'.$tab->label.'</option>';
103
+		$html .= '<option value="'.$id.'">'.$tab->label.'</option>';
104 104
 		$TFreeTextContents[$id] = $tab->content;
105 105
 	}
106 106
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 function _updateSubtotalLine(&$object, &$line)
129 129
 {
130 130
 	$label = GETPOST('line-title');
131
-	$description = ($line->qty>90) ? '' : GETPOST('line-description');
131
+	$description = ($line->qty > 90) ? '' : GETPOST('line-description');
132 132
 	$pagebreak = (int) GETPOST('line-pagebreak');
133 133
     $showTotalHT = (int) GETPOST('line-showTotalHT');
134 134
     $showReduc = (int) GETPOST('line-showReduc');
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
 function _updateSubtotalBloc($object, $line)
151 151
 {
152
-	global $conf,$langs;
152
+	global $conf, $langs;
153 153
 	
154 154
 	$subtotal_tva_tx = $subtotal_tva_tx_init = GETPOST('subtotal_tva_tx', 'int');
155 155
 	$subtotal_progress = $subtotal_progress_init = GETPOST('subtotal_progress', 'int');
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
  * @param	$lineid			= title lineid
229 229
  * @param	$subtotal_nc	0 = "Compris" prise en compte des totaux des lignes; 1 = "Non compris" non prise en compte des totaux du bloc; null = update de toutes les lignes 
230 230
  */
231
-function _updateLineNC($element, $elementid, $lineid, $subtotal_nc=null, $notrigger = 0)
231
+function _updateLineNC($element, $elementid, $lineid, $subtotal_nc = null, $notrigger = 0)
232 232
 {
233
-	global $db,$langs,$tmp_object_nc;
233
+	global $db, $langs, $tmp_object_nc;
234 234
 	
235 235
 	$error = 0;
236 236
 	if (empty($element)) $error++;
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	{
271 271
 		foreach ($object->lines as &$l)
272 272
 		{
273
-			if($l->id == $lineid) {
273
+			if ($l->id == $lineid) {
274 274
 				$line = $l;
275 275
 				break;
276 276
 			}
@@ -280,12 +280,12 @@  discard block
 block discarded – undo
280 280
 		{
281 281
 			$db->begin();
282 282
 			
283
-			if(TSubtotal::isModSubtotalLine($line))
283
+			if (TSubtotal::isModSubtotalLine($line))
284 284
 			{
285
-				if(TSubtotal::isTitle($line)) {
285
+				if (TSubtotal::isTitle($line)) {
286 286
 					// Update le contenu du titre (ainsi que le titre lui même)
287 287
 					$TTitleBlock = TSubtotal::getLinesFromTitleId($object, $lineid, true);
288
-					foreach($TTitleBlock as &$line_block)
288
+					foreach ($TTitleBlock as &$line_block)
289 289
 					{
290 290
 						$res = doUpdate($object, $line_block, $subtotal_nc, $notrigger);
291 291
 					}
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	
320 320
 	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1;
321 321
 	// Update extrafield et total
322
-	if(! empty($subtotal_nc)) {
322
+	if (!empty($subtotal_nc)) {
323 323
 		$line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = 
324 324
 			$line->multicurrency_total_ht = $line->multicurrency_total_tva = $line->multicurrency_total_ttc = 0;
325 325
 
@@ -329,16 +329,16 @@  discard block
 block discarded – undo
329 329
 		else $res = $line->update($user, $notrigger);
330 330
 	}
331 331
 	else {
332
-	    if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
333
-	        if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
332
+	    if (in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
333
+	        if (empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
334 334
 	        
335 335
 	        require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
336
-	        $extrafields=new ExtraFields($object->db);
337
-	        $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
338
-	        $line->fetch_optionals($line->id,$extralabels);
336
+	        $extrafields = new ExtraFields($object->db);
337
+	        $extralabels = $extrafields->fetch_name_optionals_label($object->table_element_line, true);
338
+	        $line->fetch_optionals($line->id, $extralabels);
339 339
 	    }
340 340
 		$line->array_options['options_subtotal_nc'] = 0;
341
-		if($object->element == 'order_supplier') $line->update($user);
341
+		if ($object->element == 'order_supplier') $line->update($user);
342 342
 		$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);
343 343
 	}
344 344
 	
Please login to merge, or discard this patch.
core/modules/modSubtotal.class.php 1 patch
Spacing   +15 added lines, -15 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.1';
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;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             // Set this to relative path of css if module has its own css file
97 97
             //'css' => '/titre/css/mycss.css.php',
98 98
             // Set here all hooks context managed by module
99
-            'hooks' => array('invoicecard', 'invoicesuppliercard','propalcard', 'supplier_proposalcard', 'ordercard', 'ordersuppliercard','odtgeneration','orderstoinvoice','admin','invoicereccard','consumptionthirdparty')
99
+            'hooks' => array('invoicecard', 'invoicesuppliercard', 'propalcard', 'supplier_proposalcard', 'ordercard', 'ordersuppliercard', 'odtgeneration', 'orderstoinvoice', 'admin', 'invoicereccard', 'consumptionthirdparty')
100 100
             // Set here all workflow context managed by module
101 101
             //'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE'))
102 102
         );
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         // List of modules id that must be enabled if this module is enabled
114 114
         $this->depends = array();
115 115
 
116
-		$this->conflictwith=array('modMilestone');
116
+		$this->conflictwith = array('modMilestone');
117 117
         // List of modules id to disable if this one is disabled
118 118
         $this->requiredby = array();
119 119
         // Minimum version of PHP required by module
@@ -178,20 +178,20 @@  discard block
 block discarded – undo
178 178
         // 'categories_x'		to add a tab in category view
179 179
         // (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
180 180
         // Dictionnaries
181
-        if (! isset($conf->subtotal->enabled)) {
182
-            $conf->subtotal=new stdClass();
181
+        if (!isset($conf->subtotal->enabled)) {
182
+            $conf->subtotal = new stdClass();
183 183
             $conf->subtotal->enabled = 0;
184 184
         }
185 185
         $this->dictionaries = array(
186 186
 			'langs'=>'subtotal@subtotal',
187
-            'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'),		// List of tables we want to see into dictonnary editor
188
-            'tablib'=>array($langs->trans('subtotalFreeLineDictionary')),													// Label of tables
189
-            '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
190
-            'tabsqlsort'=>array('label ASC'),																					// Sort order
191
-            'tabfield'=>array('label,content'),							// List of fields (result of select to show dictionary)
192
-            'tabfieldvalue'=>array('label,content'),						// List of fields (list of fields to edit a record)
193
-            'tabfieldinsert'=>array('label,content,entity'),					// List of fields (list of fields for insert)
194
-            'tabrowid'=>array('rowid'),											// Name of columns with primary key (try to always name it 'rowid')
187
+            'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'), // List of tables we want to see into dictonnary editor
188
+            'tablib'=>array($langs->trans('subtotalFreeLineDictionary')), // Label of tables
189
+            '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
190
+            'tabsqlsort'=>array('label ASC'), // Sort order
191
+            'tabfield'=>array('label,content'), // List of fields (result of select to show dictionary)
192
+            'tabfieldvalue'=>array('label,content'), // List of fields (list of fields to edit a record)
193
+            'tabfieldinsert'=>array('label,content,entity'), // List of fields (list of fields for insert)
194
+            'tabrowid'=>array('rowid'), // Name of columns with primary key (try to always name it 'rowid')
195 195
             'tabcond'=>array($conf->subtotal->enabled)	
196 196
 		);
197 197
         /* Example:
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	
467 467
         $extra = new ExtraFields($db); // propaldet, commandedet, facturedet
468 468
         $TElementType = array('propaldet', 'commandedet', 'facturedet', 'supplier_proposaldet', 'commande_fournisseurdet', 'facture_fourn_det');
469
-        foreach($TElementType as $element_type) {
469
+        foreach ($TElementType as $element_type) {
470 470
             $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);
471 471
             $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);
472 472
         }
Please login to merge, or discard this patch.
class/actions_subtotal.class.php 1 patch
Spacing   +409 added lines, -409 removed lines patch added patch discarded remove patch
@@ -16,17 +16,17 @@  discard block
 block discarded – undo
16 16
 		
17 17
 		global $type_element, $where;
18 18
 		
19
-		$contexts = explode(':',$parameters['context']);
19
+		$contexts = explode(':', $parameters['context']);
20 20
 		
21
-		if(in_array('consumptionthirdparty',$contexts) && in_array($type_element, array('propal', 'order', 'invoice', 'supplier_order', 'supplier_invoice', 'supplier_proposal'))) {
21
+		if (in_array('consumptionthirdparty', $contexts) && in_array($type_element, array('propal', 'order', 'invoice', 'supplier_order', 'supplier_invoice', 'supplier_proposal'))) {
22 22
 			$mod_num = TSubtotal::$module_number;
23 23
 			
24 24
 			// Not a title (can't use TSubtotal class methods in sql)
25
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty > 9)';
25
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty > 9)';
26 26
 			// Not a subtotal (can't use TSubtotal class methods in sql)
27
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty < 90)';
27
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty < 90)';
28 28
 			// Not a free line text (can't use TSubtotal class methods in sql)
29
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty != 50)';
29
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty != 50)';
30 30
 			
31 31
 		}
32 32
 		
@@ -105,43 +105,43 @@  discard block
 block discarded – undo
105 105
     
106 106
     function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
107 107
     {
108
-      	global $langs,$db,$user, $conf;
108
+      	global $langs, $db, $user, $conf;
109 109
 		
110 110
 		$langs->load('subtotal@subtotal');
111 111
 		
112
-		$contexts = explode(':',$parameters['context']);
112
+		$contexts = explode(':', $parameters['context']);
113 113
 		
114
-		if(in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('invoicereccard',$contexts)) {
114
+		if (in_array('ordercard', $contexts) || in_array('ordersuppliercard', $contexts) || in_array('propalcard', $contexts) || in_array('supplier_proposalcard', $contexts) || in_array('invoicecard', $contexts) || in_array('invoicesuppliercard', $contexts) || in_array('invoicereccard', $contexts)) {
115 115
 			
116 116
 			$createRight = $user->rights->{$object->element}->creer;
117
-			if($object->element == 'facturerec' )
117
+			if ($object->element == 'facturerec')
118 118
 			{
119 119
 				$object->statut = 0; // hack for facture rec
120 120
 				$createRight = $user->rights->facture->creer;
121
-			} elseif($object->element == 'order_supplier' )
121
+			} elseif ($object->element == 'order_supplier')
122 122
 			{
123 123
 			    $createRight = $user->rights->fournisseur->commande->creer;
124
-			} elseif($object->element == 'invoice_supplier' )
124
+			} elseif ($object->element == 'invoice_supplier')
125 125
 			{
126 126
 			    $createRight = $user->rights->fournisseur->facture->creer;
127 127
 			}
128 128
 			
129
-			if ($object->statut == 0  && $createRight) {
129
+			if ($object->statut == 0 && $createRight) {
130 130
 			
131 131
 
132
-				if($object->element=='facture')$idvar = 'facid';
133
-				else $idvar='id';
132
+				if ($object->element == 'facture')$idvar = 'facid';
133
+				else $idvar = 'id';
134 134
 				
135
-				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
135
+				if (in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')))
136 136
 				{
137 137
 					$level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT
138 138
 					
139
-					if($action=='add_title_line') {
139
+					if ($action == 'add_title_line') {
140 140
 						$title = GETPOST('title');
141
-						if(empty($title)) $title = $langs->trans('title');
142
-						$qty = $level<1 ? 1 : $level ;
141
+						if (empty($title)) $title = $langs->trans('title');
142
+						$qty = $level < 1 ? 1 : $level;
143 143
 					}
144
-					else if($action=='add_free_text') {
144
+					else if ($action == 'add_free_text') {
145 145
 						$title = GETPOST('title');
146 146
 
147 147
 						if (empty($title)) {
@@ -153,21 +153,21 @@  discard block
 block discarded – undo
153 153
 								}
154 154
 							}
155 155
 						}
156
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
156
+						if (empty($title)) $title = $langs->trans('subtotalAddLineDescription');
157 157
 						$qty = 50;
158 158
 					}
159
-					else if($action=='add_subtitle_line') {
159
+					else if ($action == 'add_subtitle_line') {
160 160
 						$title = GETPOST('title');
161
-						if(empty($title)) $title = $langs->trans('subtitle');
161
+						if (empty($title)) $title = $langs->trans('subtitle');
162 162
 						$qty = 2;
163 163
 					}
164
-					else if($action=='add_subtotal_line') {
164
+					else if ($action == 'add_subtotal_line') {
165 165
 						$title = $langs->trans('SubSubTotal');
166 166
 						$qty = 98;
167 167
 					}
168 168
 					else {
169 169
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
170
-						$qty = $level ? 100-$level : 99;
170
+						$qty = $level ? 100 - $level : 99;
171 171
 					}
172 172
 					dol_include_once('/subtotal/class/subtotal.class.php');
173 173
 					
@@ -175,15 +175,15 @@  discard block
 block discarded – undo
175 175
 					
176 176
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
177 177
 				}
178
-				else if($action==='ask_deleteallline') {
179
-						$form=new Form($db);
178
+				else if ($action === 'ask_deleteallline') {
179
+						$form = new Form($db);
180 180
 						
181
-						$lineid = GETPOST('lineid','integer');
181
+						$lineid = GETPOST('lineid', 'integer');
182 182
 						$TIdForGroup = $this->getArrayOfLineForAGroup($object, $lineid);
183 183
 					
184 184
 						$nbLines = count($TIdForGroup);
185 185
 					
186
-						$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines',$nbLines), 'confirm_delete_all_lines','',0,1);
186
+						$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines', $nbLines), 'confirm_delete_all_lines', '', 0, 1);
187 187
 						print $formconfirm;
188 188
 				}
189 189
 
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 				}
194 194
 
195 195
 				
196
-				if($action!='editline') {
196
+				if ($action != 'editline') {
197 197
 					// New format is for 3.8
198 198
 					$this->printNewFormat($object, $conf, $langs, $idvar);
199 199
 				}
200 200
 			}
201 201
 		}
202
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
202
+		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice', $contexts))
203 203
 		{
204 204
 			?>
205 205
 			<script type="text/javascript">
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 				$(document).ready(function() {
225 225
 					$('div.fiche div.tabsAction').append('<br />');
226 226
 					
227
-					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_title_line" rel="add_title_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddTitle' )?></a></div>');
227
+					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_title_line" rel="add_title_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddTitle')?></a></div>');
228 228
 					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_total_line" rel="add_total_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddSubTotal')?></a></div>');
229 229
 					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_free_text" rel="add_free_text" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddFreeText')?></a></div>');
230 230
 
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 						$('body').append(dialog_html);
276 276
 
277 277
 						<?php 
278
-						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME)?'ckeditor':$conf->global->FCKEDITOR_EDITORNAME;
279
-						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
280
-						if($editorConf && in_array($editorTool,array('textarea','ckeditor'))){ 
278
+						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME) ? 'ckeditor' : $conf->global->FCKEDITOR_EDITORNAME;
279
+						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
280
+						if ($editorConf && in_array($editorTool, array('textarea', 'ckeditor'))) { 
281 281
 						?>
282 282
 						if (action == 'addTitle' || action == 'addFreeTxt')
283 283
 						{
@@ -392,62 +392,62 @@  discard block
 block discarded – undo
392 392
 		global $conf, $langs, $bc;
393 393
 			
394 394
 		$action = GETPOST('action');	
395
-		$TContext = explode(':',$parameters['context']);
395
+		$TContext = explode(':', $parameters['context']);
396 396
 		if (
397
-				in_array('invoicecard',$TContext)
398
-		        || in_array('invoicesuppliercard',$TContext)
399
-				|| in_array('propalcard',$TContext)
400
-				|| in_array('ordercard',$TContext)
401
-		        || in_array('ordersuppliercard',$TContext)
402
-				|| in_array('invoicereccard',$TContext)
397
+				in_array('invoicecard', $TContext)
398
+		        || in_array('invoicesuppliercard', $TContext)
399
+				|| in_array('propalcard', $TContext)
400
+				|| in_array('ordercard', $TContext)
401
+		        || in_array('ordersuppliercard', $TContext)
402
+				|| in_array('invoicereccard', $TContext)
403 403
 			)
404 404
 	        {	
405
-	            $hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
406
-	            $hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
407
-				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
408
-				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
405
+	            $hideInnerLines = isset($_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
406
+	            $hidedetails = isset($_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
407
+				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED) ? $conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED : 0;
408
+				$hideprices = isset($_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
409 409
 				
410
-				$var=false;
411
-		     	$out.= '<tr '.$bc[$var].'>
410
+				$var = false;
411
+		     	$out .= '<tr '.$bc[$var].'>
412 412
 		     			<td colspan="4" align="right">
413 413
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
414
-		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
414
+		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(($hideInnerLines) ? 'checked="checked"' : '').' />
415 415
 		     			</td>
416 416
 		     			</tr>';
417 417
 				
418
-		     	$var=!$var;
419
-		     	$out.= '<tr '.$bc[$var].'>
418
+		     	$var = !$var;
419
+		     	$out .= '<tr '.$bc[$var].'>
420 420
 		     			<td colspan="4" align="right">
421 421
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
422
-		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
422
+		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(($hidedetails) ? 'checked="checked"' : '').' />
423 423
 		     			</td>
424 424
 		     			</tr>';
425 425
 		     	
426
-		     	$var=!$var;
427
-		     	$out.= '<tr '.$bc[$var].'>
426
+		     	$var = !$var;
427
+		     	$out .= '<tr '.$bc[$var].'>
428 428
 		     			<td colspan="4" align="right">
429 429
 		     				<label for="hideprices">'.$langs->trans('SubTotalhidePrice').'</label>
430
-		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
430
+		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(($hideprices) ? 'checked="checked"' : '').' />
431 431
 		     			</td>
432 432
 		     			</tr>';
433 433
 		     	
434 434
 		     	
435 435
 				 
436 436
 				if ( 
437
-					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
438
-					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
439
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
440
-					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
441
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
442
-					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
437
+					(in_array('propalcard', $TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
438
+					|| (in_array('ordercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
439
+				    || (in_array('ordersuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
440
+					|| (in_array('invoicecard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
441
+				    || (in_array('invoicesuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
442
+					|| (in_array('invoicereccard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
443 443
 				)
444 444
 				{
445
-					$var=!$var;
446
-					$out.= '
445
+					$var = !$var;
446
+					$out .= '
447 447
 						<tr '.$bc[$var].'>
448 448
 							<td colspan="4" align="right">
449 449
 								<label for="subtotal_add_recap">'.$langs->trans('subtotal_add_recap').'</label>
450
-								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.( GETPOST('subtotal_add_recap') ? 'checked="checked"' : '' ).' />
450
+								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.(GETPOST('subtotal_add_recap') ? 'checked="checked"' : '').' />
451 451
 							</td>
452 452
 						</tr>';
453 453
 				}
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
     function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
464 464
     {
465 465
 		
466
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
466
+    	if (in_array('invoicecard', explode(':', $parameters['context'])))
467 467
         {
468 468
         	
469 469
         }
@@ -474,13 +474,13 @@  discard block
 block discarded – undo
474 474
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
475 475
 		global $conf;
476 476
 		
477
-		if($action === 'builddoc') {
477
+		if ($action === 'builddoc') {
478 478
 			
479 479
 			$line = &$parameters['line'];
480 480
 			$object = &$parameters['object'];
481 481
 			$substitutionarray = &$parameters['substitutionarray'];
482 482
 			
483
-			if($line->product_type == 9 && $line->special_code == $this->module_number) {
483
+			if ($line->product_type == 9 && $line->special_code == $this->module_number) {
484 484
 				$substitutionarray['line_modsubtotal'] = 1;	
485 485
 				
486 486
 				$substitutionarray['line_price_ht']
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 					 = $substitutionarray['line_up'] 
492 492
 					 = '';
493 493
 				
494
-				if($line->qty>90) {
494
+				if ($line->qty > 90) {
495 495
 					$substitutionarray['line_modsubtotal_total'] = true;
496 496
 					
497 497
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 				
506 506
 				
507 507
 			}	
508
-			else{
508
+			else {
509 509
 				$substitutionarray['line_not_modsubtotal'] = true;
510 510
 				$substitutionarray['line_modsubtotal'] = 0;
511 511
 			}
@@ -517,29 +517,29 @@  discard block
 block discarded – undo
517 517
 	function createFrom($parameters, &$object, $action, $hookmanager) {
518 518
 	
519 519
 		if (
520
-				in_array('invoicecard',explode(':',$parameters['context']))
521
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
522
-				|| in_array('propalcard',explode(':',$parameters['context']))
523
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
524
-				|| in_array('ordercard',explode(':',$parameters['context']))
525
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
526
-				|| in_array('invoicereccard',explode(':',$parameters['context']))
520
+				in_array('invoicecard', explode(':', $parameters['context']))
521
+		        || in_array('invoicesuppliercard', explode(':', $parameters['context']))
522
+				|| in_array('propalcard', explode(':', $parameters['context']))
523
+		        || in_array('supplier_proposalcard', explode(':', $parameters['context']))
524
+				|| in_array('ordercard', explode(':', $parameters['context']))
525
+		        || in_array('ordersuppliercard', explode(':', $parameters['context']))
526
+				|| in_array('invoicereccard', explode(':', $parameters['context']))
527 527
 		) {
528 528
 			
529 529
 			global $db;
530 530
 			
531 531
 			$objFrom = $parameters['objFrom'];
532 532
 			
533
-			foreach($objFrom->lines as $k=> &$lineOld) {
533
+			foreach ($objFrom->lines as $k=> &$lineOld) {
534 534
 				
535
-					if($lineOld->product_type == 9 && $lineOld->info_bits > 0 ) {
535
+					if ($lineOld->product_type == 9 && $lineOld->info_bits > 0) {
536 536
 							
537 537
 							$line = & $object->lines[$k];
538 538
 				
539 539
 							$idLine = (int) ($line->id ? $line->id : $line->rowid); 
540 540
 				
541 541
 							$db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element."
542
-							SET info_bits=".(int)$lineOld->info_bits."
542
+							SET info_bits=".(int) $lineOld->info_bits."
543 543
 							WHERE rowid = ".$idLine."
544 544
 							");
545 545
 						
@@ -555,15 +555,15 @@  discard block
 block discarded – undo
555 555
 	
556 556
 	function doActions($parameters, &$object, $action, $hookmanager)
557 557
 	{
558
-		global $db, $conf, $langs,$user;
558
+		global $db, $conf, $langs, $user;
559 559
 		
560 560
 		dol_include_once('/subtotal/class/subtotal.class.php');
561 561
 		dol_include_once('/subtotal/lib/subtotal.lib.php');
562
-		require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
562
+		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
563 563
 		
564 564
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
565 565
 		
566
-		if($object->element=='facture') $idvar = 'facid';
566
+		if ($object->element == 'facture') $idvar = 'facid';
567 567
 		else $idvar = 'id';
568 568
 			
569 569
 		if ($action == 'updateligne' || $action == 'updateline')
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 				if ($line->id == $lineid && TSubtotal::isModSubtotalLine($line))
577 577
 				{
578 578
 					$found = true;
579
-					if(TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
579
+					if (TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
580 580
 						$extrafieldsline = new ExtraFields($db);
581 581
 						$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
582 582
 						$extrafieldsline->setOptionalsFromPost($extralabelsline, $line);
@@ -595,43 +595,43 @@  discard block
 block discarded – undo
595 595
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
596 596
 			}
597 597
 		}
598
-		else if($action === 'builddoc') {
598
+		else if ($action === 'builddoc') {
599 599
 			
600 600
 			if (
601
-				in_array('invoicecard',explode(':',$parameters['context']))
602
-				|| in_array('propalcard',explode(':',$parameters['context']))
603
-				|| in_array('ordercard',explode(':',$parameters['context']))
604
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
605
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
606
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
601
+				in_array('invoicecard', explode(':', $parameters['context']))
602
+				|| in_array('propalcard', explode(':', $parameters['context']))
603
+				|| in_array('ordercard', explode(':', $parameters['context']))
604
+			    || in_array('ordersuppliercard', explode(':', $parameters['context']))
605
+			    || in_array('invoicesuppliercard', explode(':', $parameters['context']))
606
+			    || in_array('supplier_proposalcard', explode(':', $parameters['context']))
607 607
 			)
608 608
 	        {								
609
-				if(in_array('invoicecard',explode(':',$parameters['context']))) {
609
+				if (in_array('invoicecard', explode(':', $parameters['context']))) {
610 610
 					$sessname = 'subtotal_hideInnerLines_facture';	
611 611
 					$sessname2 = 'subtotal_hidedetails_facture';
612 612
 					$sessname3 = 'subtotal_hideprices_facture';
613 613
 				}
614
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
614
+				elseif (in_array('invoicesuppliercard', explode(':', $parameters['context']))) {
615 615
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
616 616
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
617 617
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
618 618
 				}
619
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
619
+				elseif (in_array('propalcard', explode(':', $parameters['context']))) {
620 620
 					$sessname = 'subtotal_hideInnerLines_propal';
621 621
 					$sessname2 = 'subtotal_hidedetails_propal';	
622 622
 					$sessname3 = 'subtotal_hideprices_propal';
623 623
 				}
624
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
624
+				elseif (in_array('supplier_proposalcard', explode(':', $parameters['context']))) {
625 625
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
626 626
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
627 627
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
628 628
 				}
629
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
629
+				elseif (in_array('ordercard', explode(':', $parameters['context']))) {
630 630
 					$sessname = 'subtotal_hideInnerLines_commande';
631 631
 					$sessname2 = 'subtotal_hidedetails_commande';	
632 632
 					$sessname3 = 'subtotal_hideprices_commande';
633 633
 				}
634
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
634
+				elseif (in_array('ordersuppliercard', explode(':', $parameters['context']))) {
635 635
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
636 636
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
637 637
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
@@ -644,25 +644,25 @@  discard block
 block discarded – undo
644 644
 					
645 645
 				global $hideprices;
646 646
 				
647
-				$hideInnerLines = (int)GETPOST('hideInnerLines');
648
-				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system
647
+				$hideInnerLines = (int) GETPOST('hideInnerLines');
648
+				if (!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id])) $_SESSION[$sessname] = array(); // prevent old system
649 649
 				$_SESSION[$sessname][$object->id] = $hideInnerLines;		
650 650
 				
651
-				$hidedetails= (int)GETPOST('hidedetails');
652
-				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system
651
+				$hidedetails = (int) GETPOST('hidedetails');
652
+				if (!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id])) $_SESSION[$sessname2] = array(); // prevent old system
653 653
 				$_SESSION[$sessname2][$object->id] = $hidedetails;
654 654
 				
655
-				$hideprices= (int)GETPOST('hideprices');
656
-				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system
655
+				$hideprices = (int) GETPOST('hideprices');
656
+				if (!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id])) $_SESSION[$sessname3] = array(); // prevent old system
657 657
 				$_SESSION[$sessname3][$object->id] = $hideprices;
658 658
 				
659
-				foreach($object->lines as &$line) {
659
+				foreach ($object->lines as &$line) {
660 660
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
661 661
 					    
662
-                        if($line->qty>=90) {
662
+                        if ($line->qty >= 90) {
663 663
                             $line->modsubtotal_total = 1;
664 664
                         }
665
-                        else{
665
+                        else {
666 666
                             $line->modsubtotal_title = 1;
667 667
                         }
668 668
                         
@@ -672,34 +672,34 @@  discard block
 block discarded – undo
672 672
 	        }
673 673
 			
674 674
 		}
675
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
675
+		else if ($action === 'confirm_delete_all_lines' && GETPOST('confirm') == 'yes') {
676 676
 			
677 677
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
678 678
 			
679
-			foreach($Tab as $idLine) {
679
+			foreach ($Tab as $idLine) {
680 680
 				/**
681 681
 				 * @var $object Facture
682 682
 				 */
683
-				if($object->element=='facture') $object->deleteline($idLine);
683
+				if ($object->element == 'facture') $object->deleteline($idLine);
684 684
 				/**
685 685
 				 * @var $object Facture fournisseur
686 686
 				 */
687
-				else if($object->element=='invoice_supplier')
687
+				else if ($object->element == 'invoice_supplier')
688 688
 				{
689 689
 				    $object->deleteline($idLine);
690 690
 				}
691 691
 				/**
692 692
 				 * @var $object Propal
693 693
 				 */
694
-				else if($object->element=='propal') $object->deleteline($idLine);
694
+				else if ($object->element == 'propal') $object->deleteline($idLine);
695 695
 				/**
696 696
 				 * @var $object Propal Fournisseur
697 697
 				 */
698
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
698
+				else if ($object->element == 'supplier_proposal') $object->deleteline($idLine);
699 699
 				/**
700 700
 				 * @var $object Commande
701 701
 				 */
702
-				else if($object->element=='commande') 
702
+				else if ($object->element == 'commande') 
703 703
 				{
704 704
 					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
705 705
 					else $object->deleteline($idLine);
@@ -707,14 +707,14 @@  discard block
 block discarded – undo
707 707
 				/**
708 708
 				 * @var $object Commande fournisseur
709 709
 				 */
710
-				else if($object->element=='order_supplier')
710
+				else if ($object->element == 'order_supplier')
711 711
 				{
712 712
 				    $object->deleteline($idLine);
713 713
 				}
714 714
 				/**
715 715
 				 * @var $object Facturerec
716 716
 				 */
717
-				else if($object->element=='facturerec') $object->deleteline($idLine);
717
+				else if ($object->element == 'facturerec') $object->deleteline($idLine);
718 718
 			}
719 719
 			
720 720
 			header('location:?id='.$object->id);
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 		return 0;
738 738
 	}
739 739
 	
740
-	function formAddObjectLine ($parameters, &$object, &$action, $hookmanager) {
740
+	function formAddObjectLine($parameters, &$object, &$action, $hookmanager) {
741 741
 		return 0;
742 742
 	}
743 743
 	
@@ -755,8 +755,8 @@  discard block
 block discarded – undo
755 755
 			if (!empty($parameters['fk_element']))
756 756
 			{
757 757
 				
758
-				if($obj->fetch($parameters['fk_element'])){
759
-					$obj->id= $obj->rowid;
758
+				if ($obj->fetch($parameters['fk_element'])) {
759
+					$obj->id = $obj->rowid;
760 760
 					if (empty($obj->array_options))
761 761
 						$obj->fetch_optionals();
762 762
 					if (!empty($obj->array_options['options_subtotal_nc']))
@@ -776,22 +776,22 @@  discard block
 block discarded – undo
776 776
 		
777 777
 		$found = false;
778 778
 
779
-		$Tab= array();
779
+		$Tab = array();
780 780
 		
781
-		foreach($object->lines as $l) {
781
+		foreach ($object->lines as $l) {
782 782
 		
783 783
 		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
784
-			if($lid == $lineid) {
784
+			if ($lid == $lineid) {
785 785
 
786 786
 				$found = true;
787 787
 				$qty_line = $l->qty;
788 788
 			}
789 789
 			
790
-			if($found) {
790
+			if ($found) {
791 791
 				
792 792
 			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
793 793
 				
794
-				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
794
+				if ($l->special_code == $this->module_number && (($l->qty == 99 && $qty_line == 1) || ($l->qty == 98 && $qty_line == 2))) {
795 795
 					break; // end of story
796 796
 				}
797 797
 			}
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
 	 * 
821 821
 	 * @param	$use_level		isn't used anymore
822 822
 	 */
823
-	function getTotalLineFromObject(&$object, &$line, $use_level=false, $return_all=0) {
823
+	function getTotalLineFromObject(&$object, &$line, $use_level = false, $return_all = 0) {
824 824
 		
825 825
 		$rang = $line->rang;
826 826
 		$qty_line = $line->qty;
@@ -831,21 +831,21 @@  discard block
 block discarded – undo
831 831
 		$TTotal_tva = array();
832 832
 		
833 833
 		dol_include_once('/subtotal/class/subtotal.class.php');
834
-		foreach($object->lines as $l) {
834
+		foreach ($object->lines as $l) {
835 835
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
836
-			if($l->rang>=$rang) {
836
+			if ($l->rang >= $rang) {
837 837
 				//echo 'return!<br>';
838 838
 				if (!$return_all) return $total;
839 839
 				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
840 840
 			}
841
-			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
841
+			else if (TSubtotal::isTitle($l, 100 - $qty_line)) 
842 842
 		  	{
843 843
 				$total = 0;
844 844
 				$total_tva = 0;
845 845
 				$total_ttc = 0;
846 846
 				$TTotal_tva = array();
847 847
 			}
848
-			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
848
+			elseif (!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
849 849
 				$total += $l->total_ht;
850 850
 				$total_tva += $l->total_tva;
851 851
 				$TTotal_tva[$l->tva_tx] += $l->total_tva;
@@ -864,18 +864,18 @@  discard block
 block discarded – undo
864 864
 		
865 865
 		$rang = $line->rang;
866 866
 		$total = 0;
867
-		foreach($object->lines as $l) {
868
-			if($l->rang>=$rang) {
867
+		foreach ($object->lines as $l) {
868
+			if ($l->rang >= $rang) {
869 869
 				return price($total);
870 870
 			}
871
-                        if (TSubtotal::isSubtotal($l)){
871
+                        if (TSubtotal::isSubtotal($l)) {
872 872
                             $total = 0;
873
-                        } else  if ($l->situation_percent > 0 ){
873
+                        } else  if ($l->situation_percent > 0) {
874 874
                            
875 875
         	
876 876
 		 	$prev_progress = $l->get_prev_progress($object->id);
877
-		 	$progress = ($l->situation_percent - $prev_progress) /100;
878
-                        $total += ($l->total_ht/($l->situation_percent/100)) * $progress;
877
+		 	$progress = ($l->situation_percent - $prev_progress) / 100;
878
+                        $total += ($l->total_ht / ($l->situation_percent / 100)) * $progress;
879 879
                         
880 880
                     }
881 881
                 }
@@ -894,10 +894,10 @@  discard block
 block discarded – undo
894 894
 	 * @param $w            float               width
895 895
 	 * @param $h            float               height
896 896
 	 */
897
-	function pdf_add_total(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
898
-		global $conf,$subtotal_last_title_posy;
897
+	function pdf_add_total(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
898
+		global $conf, $subtotal_last_title_posy;
899 899
 
900
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
900
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
901 901
 		if (!empty($conf->global->SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES) && $hideInnerLines && !empty($subtotal_last_title_posy))
902 902
 		{
903 903
 			$posy = $subtotal_last_title_posy;
@@ -907,34 +907,34 @@  discard block
 block discarded – undo
907 907
 		$hidePriceOnSubtotalLines = (int) GETPOST('hide_price_on_subtotal_lines');
908 908
 		
909 909
 		$set_pagebreak_margin = false;
910
-		if(method_exists('Closure','bind')) {
910
+		if (method_exists('Closure', 'bind')) {
911 911
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
912
-			$sweetsThief = function ($pdf) {
913
-		    		return $pdf->bMargin ;
912
+			$sweetsThief = function($pdf) {
913
+		    		return $pdf->bMargin;
914 914
 			};
915 915
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
916 916
 	
917
-			$bMargin  = $sweetsThief($pdf);
917
+			$bMargin = $sweetsThief($pdf);
918 918
 	
919
-			$pdf->SetAutoPageBreak( false );
919
+			$pdf->SetAutoPageBreak(false);
920 920
 
921 921
 			$set_pagebreak_margin = true;			
922 922
 		}
923 923
 		
924 924
 			
925
-		if($line->qty==99)
926
-			$pdf->SetFillColor(220,220,220);
927
-		elseif ($line->qty==98)
928
-			$pdf->SetFillColor(230,230,230);
925
+		if ($line->qty == 99)
926
+			$pdf->SetFillColor(220, 220, 220);
927
+		elseif ($line->qty == 98)
928
+			$pdf->SetFillColor(230, 230, 230);
929 929
 		else
930
-			$pdf->SetFillColor(240,240,240);
930
+			$pdf->SetFillColor(240, 240, 240);
931 931
 		
932 932
 		$style = 'B';
933 933
 		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
934 934
 		
935 935
 		$pdf->SetFont('', $style, 9);
936 936
 		
937
-		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R',true);
937
+		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R', true);
938 938
 //		var_dump($bMargin);
939 939
 		$pageAfter = $pdf->getPage();
940 940
 		
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 				}
960 960
 			}
961 961
 			
962
-			if($total_to_print !== '') {
962
+			if ($total_to_print !== '') {
963 963
 				
964 964
 				if (GETPOST('hideInnerLines'))
965 965
 				{
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
 				else
974 974
 				{
975 975
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
976
-                                        if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
976
+                                        if (get_class($object) == 'Facture' && $object->type == Facture::TYPE_SITUATION) {//Facture de situation
977 977
                                                 $total_to_print = $this->getTotalToPrintSituation($object, $line);
978 978
                                         } else {
979 979
                                             	$total_to_print = price($total);
@@ -987,11 +987,11 @@  discard block
 block discarded – undo
987 987
 			}
988 988
 
989 989
 			$pdf->SetXY($pdf->postotalht, $posy);
990
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
991
-			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
990
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
991
+			$pdf->MultiCell($pdf->page_largeur - $pdf->marge_droite - $pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
992 992
 		}
993
-		else{
994
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
993
+		else {
994
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
995 995
 		}
996 996
 		
997 997
 		$posy = $posy + $cell_height;
@@ -1011,22 +1011,22 @@  discard block
 block discarded – undo
1011 1011
 	 * @param $w            float               width
1012 1012
 	 * @param $h            float               height
1013 1013
 	 */
1014
-	function pdf_add_title(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
1014
+	function pdf_add_title(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
1015 1015
 		
1016
-		global $db,$conf,$subtotal_last_title_posy;
1016
+		global $db, $conf, $subtotal_last_title_posy;
1017 1017
 		
1018 1018
 		$subtotal_last_title_posy = $posy;
1019
-		$pdf->SetXY ($posx, $posy);
1019
+		$pdf->SetXY($posx, $posy);
1020 1020
 		
1021
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1021
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1022 1022
 		
1023 1023
 		
1024 1024
  
1025
-		$style = ($line->qty==1) ? 'BU' : 'BUI';
1025
+		$style = ($line->qty == 1) ? 'BU' : 'BUI';
1026 1026
 		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
1027 1027
 		
1028
-		if($hideInnerLines) {
1029
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
1028
+		if ($hideInnerLines) {
1029
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9);
1030 1030
 			else 
1031 1031
 			{
1032 1032
 				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
@@ -1035,43 +1035,43 @@  discard block
 block discarded – undo
1035 1035
 		}
1036 1036
 		else {
1037 1037
 
1038
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
1038
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9); //TODO if super utile
1039 1039
 			else $pdf->SetFont('', $style, 9);
1040 1040
 			
1041 1041
 		}
1042 1042
 		
1043 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
1044
+		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J', true); // et maintenant avec du HTML
1045 1045
 		
1046
-		if($description && !$hidedesc) {
1046
+		if ($description && !$hidedesc) {
1047 1047
 			$posy = $pdf->GetY();
1048 1048
 			
1049 1049
 			$pdf->SetFont('', '', 8);
1050 1050
 			
1051
-			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J',true);
1051
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J', true);
1052 1052
 
1053 1053
 		}
1054 1054
 		
1055 1055
 	}
1056 1056
 
1057
-	function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='') {
1057
+	function pdf_writelinedesc_ref($parameters = array(), &$object, &$action = '') {
1058 1058
 	// ultimate PDF hook O_o
1059 1059
 		
1060
-		return $this->pdf_writelinedesc($parameters,$object,$action);
1060
+		return $this->pdf_writelinedesc($parameters, $object, $action);
1061 1061
 		
1062 1062
 	}
1063 1063
 
1064 1064
 	function isModSubtotalLine(&$parameters, &$object) {
1065 1065
 		
1066
-		if(is_array($parameters)) {
1066
+		if (is_array($parameters)) {
1067 1067
 			$i = & $parameters['i'];	
1068 1068
 		}
1069 1069
 		else {
1070
-			$i = (int)$parameters;
1070
+			$i = (int) $parameters;
1071 1071
 		}
1072 1072
 		
1073 1073
 		
1074
-		if($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) {
1074
+		if ($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) {
1075 1075
 			return true;
1076 1076
 		}
1077 1077
 		
@@ -1079,43 +1079,43 @@  discard block
 block discarded – undo
1079 1079
 		
1080 1080
 	}
1081 1081
 
1082
-	function pdf_getlineqty($parameters=array(), &$object, &$action='') {
1083
-		global $conf,$hideprices;
1082
+	function pdf_getlineqty($parameters = array(), &$object, &$action = '') {
1083
+		global $conf, $hideprices;
1084 1084
 		
1085
-		if($this->isModSubtotalLine($parameters,$object) ){
1085
+		if ($this->isModSubtotalLine($parameters, $object)) {
1086 1086
 			
1087 1087
 			$this->resprints = ' ';
1088 1088
 			
1089
-			if((float)DOL_VERSION<=3.6) {
1089
+			if ((float) DOL_VERSION <= 3.6) {
1090 1090
 				return '';
1091 1091
 			}
1092
-			else if((float)DOL_VERSION>=3.8) {
1092
+			else if ((float) DOL_VERSION >= 3.8) {
1093 1093
 				return 1;
1094 1094
 			}
1095 1095
 			
1096 1096
 		}
1097
-		elseif(!empty($hideprices)) {
1097
+		elseif (!empty($hideprices)) {
1098 1098
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1099 1099
 			return 1;
1100 1100
 		}
1101 1101
 		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1102 1102
 		{
1103
-			$hideInnerLines = (int)GETPOST('hideInnerLines');
1104
-			$hidedetails = (int)GETPOST('hidedetails');
1103
+			$hideInnerLines = (int) GETPOST('hideInnerLines');
1104
+			$hidedetails = (int) GETPOST('hidedetails');
1105 1105
 			if (empty($hideInnerLines) && !empty($hidedetails))
1106 1106
 			{
1107 1107
 				$this->resprints = $object->lines[$parameters['i']]->qty;
1108 1108
 			}
1109 1109
 		}
1110 1110
 		
1111
-		if(is_array($parameters)) $i = & $parameters['i'];
1112
-		else $i = (int)$parameters;
1111
+		if (is_array($parameters)) $i = & $parameters['i'];
1112
+		else $i = (int) $parameters;
1113 1113
 
1114 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)
1115 1115
 		
1116
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1116
+		if (empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1117 1117
 
1118
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1118
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1119 1119
 		{
1120 1120
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1121 1121
 			{
@@ -1127,20 +1127,20 @@  discard block
 block discarded – undo
1127 1127
 		return 0;
1128 1128
 	}
1129 1129
 	
1130
-	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1130
+	function pdf_getlinetotalexcltax($parameters = array(), &$object, &$action = '') {
1131 1131
 	    global $conf, $hideprices, $hookmanager;
1132 1132
 		
1133
-		if(is_array($parameters)) $i = & $parameters['i'];
1134
-		else $i = (int)$parameters;
1133
+		if (is_array($parameters)) $i = & $parameters['i'];
1134
+		else $i = (int) $parameters;
1135 1135
 			
1136
-		if($this->isModSubtotalLine($parameters,$object) ){
1136
+		if ($this->isModSubtotalLine($parameters, $object)) {
1137 1137
 			
1138 1138
 			$this->resprints = ' ';
1139 1139
 			
1140
-			if((float)DOL_VERSION<=3.6) {
1140
+			if ((float) DOL_VERSION <= 3.6) {
1141 1141
 				return '';
1142 1142
 			}
1143
-			else if((float)DOL_VERSION>=3.8) {
1143
+			else if ((float) DOL_VERSION >= 3.8) {
1144 1144
 				return 1;
1145 1145
 			}
1146 1146
 			
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 				}
1167 1167
 			}
1168 1168
 		}
1169
-		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1169
+		if ((int) GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) {
1170 1170
 		    $this->resprints = price($object->lines[$i]->total_ht);
1171 1171
 		}
1172 1172
 		
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 		{
1192 1192
 			// Check if a title exist for this line && if the title have subtotal
1193 1193
 			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1194
-			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1194
+			if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1195 1195
 			{
1196 1196
 
1197 1197
 				$this->resprints = ' ';
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 	 */
1212 1212
 	private function callHook(&$object, &$hookmanager, $action, $params, $defaultReturn = 1)
1213 1213
 	{
1214
-		$reshook=$hookmanager->executeHooks('subtotalHidePrices',$params, $object, $action);
1214
+		$reshook = $hookmanager->executeHooks('subtotalHidePrices', $params, $object, $action);
1215 1215
 		if ($reshook < 0)
1216 1216
 		{
1217 1217
 			$this->error = $hookmanager->error;
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 			$this->resprints = $hookmanager->resprints;
1228 1228
 
1229 1229
 			// override return (use  $this->results['overrideReturn'] or $this->resArray['overrideReturn'] in other module action_xxxx.class.php )
1230
-			if(isset($hookmanager->resArray['overrideReturn']))
1230
+			if (isset($hookmanager->resArray['overrideReturn']))
1231 1231
 			{
1232 1232
 				return $hookmanager->resArray['overrideReturn'];
1233 1233
 			}
@@ -1236,25 +1236,25 @@  discard block
 block discarded – undo
1236 1236
 		return $defaultReturn;
1237 1237
 	}
1238 1238
 	
1239
-	function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='') {
1239
+	function pdf_getlinetotalwithtax($parameters = array(), &$object, &$action = '') {
1240 1240
 		global $conf;
1241 1241
 		
1242
-		if($this->isModSubtotalLine($parameters,$object) ){
1242
+		if ($this->isModSubtotalLine($parameters, $object)) {
1243 1243
 			
1244 1244
 			$this->resprints = ' ';
1245 1245
 		
1246
-			if((float)DOL_VERSION<=3.6) {
1246
+			if ((float) DOL_VERSION <= 3.6) {
1247 1247
 				return '';
1248 1248
 			}
1249
-			else if((float)DOL_VERSION>=3.8) {
1249
+			else if ((float) DOL_VERSION >= 3.8) {
1250 1250
 				return 1;
1251 1251
 			}
1252 1252
 		}
1253 1253
 		
1254
-		if(is_array($parameters)) $i = & $parameters['i'];
1255
-		else $i = (int)$parameters;
1254
+		if (is_array($parameters)) $i = & $parameters['i'];
1255
+		else $i = (int) $parameters;
1256 1256
 		
1257
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1257
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) 
1258 1258
 		{
1259 1259
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1260 1260
 			{
@@ -1266,24 +1266,24 @@  discard block
 block discarded – undo
1266 1266
 		return 0;
1267 1267
 	}
1268 1268
 	
1269
-	function pdf_getlineunit($parameters=array(), &$object, &$action='') {
1269
+	function pdf_getlineunit($parameters = array(), &$object, &$action = '') {
1270 1270
 		global $conf;
1271 1271
 		
1272
-		if($this->isModSubtotalLine($parameters,$object) ){
1272
+		if ($this->isModSubtotalLine($parameters, $object)) {
1273 1273
 			$this->resprints = ' ';
1274 1274
 		
1275
-			if((float)DOL_VERSION<=3.6) {
1275
+			if ((float) DOL_VERSION <= 3.6) {
1276 1276
 				return '';
1277 1277
 			}
1278
-			else if((float)DOL_VERSION>=3.8) {
1278
+			else if ((float) DOL_VERSION >= 3.8) {
1279 1279
 				return 1;
1280 1280
 			}
1281 1281
 		}
1282 1282
 		
1283
-		if(is_array($parameters)) $i = & $parameters['i'];
1284
-		else $i = (int)$parameters;
1283
+		if (is_array($parameters)) $i = & $parameters['i'];
1284
+		else $i = (int) $parameters;
1285 1285
 			
1286
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1286
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1287 1287
 		{
1288 1288
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1289 1289
 			{
@@ -1295,31 +1295,31 @@  discard block
 block discarded – undo
1295 1295
 		return 0;
1296 1296
 	}
1297 1297
 	
1298
-	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1299
-	    global $conf,$hideprices,$hookmanager;
1298
+	function pdf_getlineupexcltax($parameters = array(), &$object, &$action = '') {
1299
+	    global $conf, $hideprices, $hookmanager;
1300 1300
 
1301
-		if(is_array($parameters)) $i = & $parameters['i'];
1302
-		else $i = (int)$parameters;
1301
+		if (is_array($parameters)) $i = & $parameters['i'];
1302
+		else $i = (int) $parameters;
1303 1303
 
1304
-		if($this->isModSubtotalLine($parameters,$object) ) {
1304
+		if ($this->isModSubtotalLine($parameters, $object)) {
1305 1305
 			$this->resprints = ' ';
1306 1306
 
1307 1307
             $line = $object->lines[$i];
1308 1308
 
1309 1309
             // On récupère les montants du bloc pour les afficher dans la ligne de sous-total
1310
-            if(TSubtotal::isSubtotal($line)) {
1310
+            if (TSubtotal::isSubtotal($line)) {
1311 1311
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1312 1312
 
1313
-                if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1313
+                if (!empty($parentTitle->array_options['options_show_total_ht'])) {
1314 1314
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1315 1315
                     $this->resprints = price($TTotal['total_subprice']);
1316 1316
                 }
1317 1317
             }
1318 1318
 		
1319
-			if((float)DOL_VERSION<=3.6) {
1319
+			if ((float) DOL_VERSION <= 3.6) {
1320 1320
 				return '';
1321 1321
 			}
1322
-			else if((float)DOL_VERSION>=3.8) {
1322
+			else if ((float) DOL_VERSION >= 3.8) {
1323 1323
 				return 1;
1324 1324
 			}
1325 1325
 		}
@@ -1347,7 +1347,7 @@  discard block
 block discarded – undo
1347 1347
 		    
1348 1348
 		    // Check if a title exist for this line && if the title have subtotal
1349 1349
 		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1350
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1350
+		    if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1351 1351
 		    {
1352 1352
 		        
1353 1353
 		        $this->resprints = ' ';
@@ -1361,31 +1361,31 @@  discard block
 block discarded – undo
1361 1361
 		return 0;
1362 1362
 	}
1363 1363
 	
1364
-	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1365
-	    global $conf,$hideprices,$hookmanager;
1364
+	function pdf_getlineremisepercent($parameters = array(), &$object, &$action = '') {
1365
+	    global $conf, $hideprices, $hookmanager;
1366 1366
 
1367
-        if(is_array($parameters)) $i = & $parameters['i'];
1367
+        if (is_array($parameters)) $i = & $parameters['i'];
1368 1368
         else $i = (int) $parameters;
1369 1369
 
1370
-		if($this->isModSubtotalLine($parameters,$object) ) {
1370
+		if ($this->isModSubtotalLine($parameters, $object)) {
1371 1371
 			$this->resprints = ' ';
1372 1372
 
1373 1373
             $line = $object->lines[$i];
1374 1374
 
1375 1375
             // Affichage de la remise 
1376
-            if(TSubtotal::isSubtotal($line)) {
1376
+            if (TSubtotal::isSubtotal($line)) {
1377 1377
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1378 1378
 
1379
-                if(! empty($parentTitle->array_options['options_show_reduc'])) {
1379
+                if (!empty($parentTitle->array_options['options_show_reduc'])) {
1380 1380
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1381
-                    $this->resprints = price($TTotal['total_ht'] / $TTotal['total_subprice']*100, 0, '', 1, 2, 2).'%';
1381
+                    $this->resprints = price($TTotal['total_ht'] / $TTotal['total_subprice'] * 100, 0, '', 1, 2, 2).'%';
1382 1382
                 }
1383 1383
             }
1384 1384
 		
1385
-			if((float)DOL_VERSION<=3.6) {
1385
+			if ((float) DOL_VERSION <= 3.6) {
1386 1386
 				return '';
1387 1387
 			}
1388
-			else if((float)DOL_VERSION>=3.8) {
1388
+			else if ((float) DOL_VERSION >= 3.8) {
1389 1389
 				return 1;
1390 1390
 			}
1391 1391
 		}
@@ -1393,24 +1393,24 @@  discard block
 block discarded – undo
1393 1393
 		return 0;
1394 1394
 	}
1395 1395
 	
1396
-	function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') {
1397
-		global $conf,$hideprices;
1396
+	function pdf_getlineupwithtax($parameters = array(), &$object, &$action = '') {
1397
+		global $conf, $hideprices;
1398 1398
 		
1399
-		if($this->isModSubtotalLine($parameters,$object) ){
1399
+		if ($this->isModSubtotalLine($parameters, $object)) {
1400 1400
 			$this->resprints = ' ';
1401
-			if((float)DOL_VERSION<=3.6) {
1401
+			if ((float) DOL_VERSION <= 3.6) {
1402 1402
 				return '';
1403 1403
 			}
1404
-			else if((float)DOL_VERSION>=3.8) {
1404
+			else if ((float) DOL_VERSION >= 3.8) {
1405 1405
 				return 1;
1406 1406
 			}
1407 1407
 		}
1408 1408
 		
1409
-		if(is_array($parameters)) $i = & $parameters['i'];
1410
-		else $i = (int)$parameters;
1409
+		if (is_array($parameters)) $i = & $parameters['i'];
1410
+		else $i = (int) $parameters;
1411 1411
 			
1412 1412
 		if (!empty($hideprices)
1413
-				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1413
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1414 1414
 		)
1415 1415
 		{
1416 1416
 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1423,22 +1423,22 @@  discard block
 block discarded – undo
1423 1423
 		return 0;
1424 1424
 	}
1425 1425
 	
1426
-	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1427
-	    global $conf,$hideprices,$hookmanager;
1426
+	function pdf_getlinevatrate($parameters = array(), &$object, &$action = '') {
1427
+	    global $conf, $hideprices, $hookmanager;
1428 1428
 	    
1429
-		if($this->isModSubtotalLine($parameters,$object) ){
1429
+		if ($this->isModSubtotalLine($parameters, $object)) {
1430 1430
 			$this->resprints = ' ';
1431 1431
 			
1432
-			if((float)DOL_VERSION<=3.6) {
1432
+			if ((float) DOL_VERSION <= 3.6) {
1433 1433
 				return '';
1434 1434
 			}
1435
-			else if((float)DOL_VERSION>=3.8) {
1435
+			else if ((float) DOL_VERSION >= 3.8) {
1436 1436
 				return 1;
1437 1437
 			}
1438 1438
 		}
1439 1439
 		
1440
-		if(is_array($parameters)) $i = & $parameters['i'];
1441
-		else $i = (int)$parameters;
1440
+		if (is_array($parameters)) $i = & $parameters['i'];
1441
+		else $i = (int) $parameters;
1442 1442
 		
1443 1443
 		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)
1444 1444
 
@@ -1465,7 +1465,7 @@  discard block
 block discarded – undo
1465 1465
 		    
1466 1466
 		    // Check if a title exist for this line && if the title have subtotal
1467 1467
 		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1468
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1468
+		    if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1469 1469
 		    {
1470 1470
 		        
1471 1471
 		        $this->resprints = ' ';
@@ -1479,23 +1479,23 @@  discard block
 block discarded – undo
1479 1479
 		return 0;
1480 1480
 	}
1481 1481
 		
1482
-	function pdf_getlineprogress($parameters=array(), &$object, &$action) {
1482
+	function pdf_getlineprogress($parameters = array(), &$object, &$action) {
1483 1483
 		global $conf;
1484 1484
 		
1485
-		if($this->isModSubtotalLine($parameters,$object) ){
1485
+		if ($this->isModSubtotalLine($parameters, $object)) {
1486 1486
 			$this->resprints = ' ';
1487
-			if((float)DOL_VERSION<=3.6) {
1487
+			if ((float) DOL_VERSION <= 3.6) {
1488 1488
 				return '';
1489 1489
 			}
1490
-			else if((float)DOL_VERSION>=3.8) {
1490
+			else if ((float) DOL_VERSION >= 3.8) {
1491 1491
 				return 1;
1492 1492
 			}
1493 1493
 		}
1494 1494
 		
1495
-		if(is_array($parameters)) $i = & $parameters['i'];
1496
-		else $i = (int)$parameters;
1495
+		if (is_array($parameters)) $i = & $parameters['i'];
1496
+		else $i = (int) $parameters;
1497 1497
 			
1498
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1498
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1499 1499
 		{
1500 1500
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1501 1501
 			{
@@ -1510,12 +1510,12 @@  discard block
 block discarded – undo
1510 1510
 	function add_numerotation(&$object) {
1511 1511
 		global $conf;
1512 1512
 		
1513
-		if(!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1513
+		if (!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1514 1514
 		
1515 1515
 			$TLevelTitre = array();
1516 1516
 			$prevlevel = 0;
1517 1517
 		
1518
-			foreach($object->lines as $k=>&$line) 
1518
+			foreach ($object->lines as $k=>&$line) 
1519 1519
 			{
1520 1520
 				if ($line->id > 0 && $this->isModSubtotalLine($k, $object) && $line->qty <= 10)
1521 1521
 				{
@@ -1529,12 +1529,12 @@  discard block
 block discarded – undo
1529 1529
 	}
1530 1530
 
1531 1531
 	// TODO ne gère pas encore la numération des lignes "Totaux"
1532
-	private function formatNumerotation(&$TLineTitle, $line_reference='', $level=1, $prefix_num=0)
1532
+	private function formatNumerotation(&$TLineTitle, $line_reference = '', $level = 1, $prefix_num = 0)
1533 1533
 	{
1534 1534
 		$TTitle = array();
1535 1535
 		
1536
-		$i=1;
1537
-		$j=0;
1536
+		$i = 1;
1537
+		$j = 0;
1538 1538
 		foreach ($TLineTitle as $k => &$line)
1539 1539
 		{
1540 1540
 			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
 			{
1545 1545
 				$TTitle[$j]['numerotation'] = ($prefix_num == 0) ? $i : $prefix_num.'.'.$i;
1546 1546
 				//var_dump('Prefix == '.$prefix_num.' // '.$line->desc.' ==> numerotation == '.$TTitle[$j]['numerotation'].'   ###    '.$line->qty .'=='. $level);
1547
-				if (empty($line->label) && (float)DOL_VERSION < 6)
1547
+				if (empty($line->label) && (float) DOL_VERSION < 6)
1548 1548
 				{
1549 1549
 					$line->label = !empty($line->desc) ? $line->desc : $line->description;
1550 1550
 					$line->desc = $line->description = '';
@@ -1570,26 +1570,26 @@  discard block
 block discarded – undo
1570 1570
 	
1571 1571
 	function setDocTVA(&$pdf, &$object) {
1572 1572
 		
1573
-		$hidedetails = (int)GETPOST('hidedetails');
1573
+		$hidedetails = (int) GETPOST('hidedetails');
1574 1574
 		
1575
-		if(empty($hidedetails)) return false;
1575
+		if (empty($hidedetails)) return false;
1576 1576
 		
1577 1577
 		// TODO can't add VAT to document without lines... :-/
1578 1578
 		
1579 1579
 		return true;
1580 1580
 	}
1581 1581
 	
1582
-	function beforePDFCreation($parameters=array(), &$object, &$action)
1582
+	function beforePDFCreation($parameters = array(), &$object, &$action)
1583 1583
 	{
1584 1584
 		/**
1585 1585
 		 * @var $pdf    TCPDF
1586 1586
 		 */
1587
-		global $pdf,$conf, $langs;
1587
+		global $pdf, $conf, $langs;
1588 1588
 
1589 1589
 		// var_dump($object->lines);
1590 1590
 		dol_include_once('/subtotal/class/subtotal.class.php');
1591 1591
 
1592
-		foreach($parameters as $key=>$value) {
1592
+		foreach ($parameters as $key=>$value) {
1593 1593
 			${$key} = $value;
1594 1594
 		}
1595 1595
 		
@@ -1597,34 +1597,34 @@  discard block
 block discarded – undo
1597 1597
 		
1598 1598
 		$this->add_numerotation($object);	
1599 1599
 		
1600
-        foreach($object->lines as $k => &$l) {
1601
-            if(TSubtotal::isSubtotal($l)) {
1600
+        foreach ($object->lines as $k => &$l) {
1601
+            if (TSubtotal::isSubtotal($l)) {
1602 1602
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1603
-                if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_total_ht'])) {
1604
-                    $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1603
+                if (!empty($parentTitle->id) && !empty($parentTitle->array_options['options_show_total_ht'])) {
1604
+                    $l->remise_percent = 100; // Affichage de la réduction sur la ligne de sous-total
1605 1605
                 }
1606 1606
             }
1607 1607
         }
1608 1608
 
1609
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1610
-		$hidedetails = (int)GETPOST('hidedetails');
1609
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1610
+		$hidedetails = (int) GETPOST('hidedetails');
1611 1611
 
1612 1612
 		if ($hideInnerLines) { // si c une ligne de titre
1613
-	    	$fk_parent_line=0;
1614
-			$TLines =array();
1613
+	    	$fk_parent_line = 0;
1614
+			$TLines = array();
1615 1615
 		
1616
-			$original_count=count($object->lines);
1616
+			$original_count = count($object->lines);
1617 1617
 		    $TTvas = array(); // tableau de tva
1618 1618
 		    
1619
-			foreach($object->lines as $k=>&$line) 
1619
+			foreach ($object->lines as $k=>&$line) 
1620 1620
 			{
1621 1621
 			    
1622
-				if($line->product_type==9 && $line->rowid>0) 
1622
+				if ($line->product_type == 9 && $line->rowid > 0) 
1623 1623
 				{
1624 1624
 					$fk_parent_line = $line->rowid;
1625 1625
 					
1626 1626
 					// Fix tk7201 - si on cache le détail, la TVA est renseigné au niveau du sous-total, l'erreur c'est s'il y a plusieurs sous-totaux pour les même lignes, ça va faire la somme
1627
-					if(TSubtotal::isSubtotal($line)) 
1627
+					if (TSubtotal::isSubtotal($line)) 
1628 1628
 					{
1629 1629
 						/*$total = $this->getTotalLineFromObject($object, $line, '');
1630 1630
 						
@@ -1653,22 +1653,22 @@  discard block
 block discarded – undo
1653 1653
 			
1654 1654
 				if ($hideInnerLines)
1655 1655
 				{
1656
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1656
+				    if (!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1657 1657
 				    {
1658
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1658
+				        if ($line->tva_tx != '0.000' && $line->product_type != 9) {
1659 1659
 				            
1660 1660
     				        // on remplit le tableau de tva pour substituer les lignes cachées
1661 1661
     				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1662 1662
     				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1663 1663
     				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1664 1664
     				    }
1665
-    					if($line->product_type==9 && $line->rowid>0)
1665
+    					if ($line->product_type == 9 && $line->rowid > 0)
1666 1666
     					{
1667 1667
     					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1668 1668
     					    // génère des lignes d'affichage des montants HT soumis à tva
1669 1669
     					    $nbtva = count($TTvas);
1670
-    					    if(!empty($nbtva)){
1671
-    					        foreach ($TTvas as $tx =>$val){
1670
+    					    if (!empty($nbtva)) {
1671
+    					        foreach ($TTvas as $tx =>$val) {
1672 1672
     					            $l = clone $line;
1673 1673
     					            $l->product_type = 1;
1674 1674
     					            $l->special_code = '';
@@ -1689,7 +1689,7 @@  discard block
 block discarded – undo
1689 1689
     					}
1690 1690
 				    } else {
1691 1691
 				        
1692
-				        if($line->product_type==9 && $line->rowid>0)
1692
+				        if ($line->product_type == 9 && $line->rowid > 0)
1693 1693
 				        {
1694 1694
 				            // ajoute la ligne de sous-total
1695 1695
 				            $TLines[] = $line; 
@@ -1717,9 +1717,9 @@  discard block
 block discarded – undo
1717 1717
 			
1718 1718
 			// cas incongru où il y aurait des produits en dessous du dernier sous-total
1719 1719
 			$nbtva = count($TTvas);
1720
-			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1720
+			if (!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1721 1721
 			{
1722
-			    foreach ($TTvas as $tx =>$val){
1722
+			    foreach ($TTvas as $tx =>$val) {
1723 1723
 			        $l = clone $line;
1724 1724
 			        $l->product_type = 1;
1725 1725
 			        $l->special_code = '';
@@ -1736,11 +1736,11 @@  discard block
 block discarded – undo
1736 1736
 			}
1737 1737
 			
1738 1738
 			global $nblignes;
1739
-			$nblignes=count($TLines);
1739
+			$nblignes = count($TLines);
1740 1740
 
1741 1741
 			$object->lines = $TLines;
1742 1742
 			
1743
-			if($i>count($object->lines)) {
1743
+			if ($i > count($object->lines)) {
1744 1744
 				$this->resprints = '';
1745 1745
 				return 0;
1746 1746
 			}
@@ -1749,59 +1749,59 @@  discard block
 block discarded – undo
1749 1749
 		return 0;
1750 1750
 	}
1751 1751
 
1752
-	function pdf_writelinedesc($parameters=array(), &$object, &$action)
1752
+	function pdf_writelinedesc($parameters = array(), &$object, &$action)
1753 1753
 	{
1754 1754
 		/**
1755 1755
 		 * @var $pdf    TCPDF
1756 1756
 		 */
1757
-		global $pdf,$conf;
1757
+		global $pdf, $conf;
1758 1758
 
1759
-		foreach($parameters as $key=>$value) {
1759
+		foreach ($parameters as $key=>$value) {
1760 1760
 			${$key} = $value;
1761 1761
 		}
1762 1762
 		
1763
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1764
-		$hidedetails = (int)GETPOST('hidedetails');
1763
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1764
+		$hidedetails = (int) GETPOST('hidedetails');
1765 1765
 		
1766
-		if($this->isModSubtotalLine($parameters,$object) ){			
1766
+		if ($this->isModSubtotalLine($parameters, $object)) {			
1767 1767
 		
1768 1768
 				global $hideprices;
1769 1769
 				
1770
-				if(!empty($hideprices)) {
1771
-					foreach($object->lines as &$line) {
1772
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1770
+				if (!empty($hideprices)) {
1771
+					foreach ($object->lines as &$line) {
1772
+						if ($line->fk_product_type != 9) $line->fk_parent_line = -1;	
1773 1773
 					}
1774 1774
 				}
1775 1775
 			
1776 1776
 				$line = &$object->lines[$i];
1777 1777
 				
1778
-				if($line->info_bits>0) { // PAGE BREAK
1778
+				if ($line->info_bits > 0) { // PAGE BREAK
1779 1779
 					$pdf->addPage();
1780 1780
 					$posy = $pdf->GetY();
1781 1781
 				}
1782 1782
 				
1783 1783
 				$label = $line->label;
1784
-				$description= !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1784
+				$description = !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1785 1785
 				
1786
-				if(empty($label)) {
1786
+				if (empty($label)) {
1787 1787
 					$label = $description;
1788
-					$description='';
1788
+					$description = '';
1789 1789
 				}
1790 1790
 				
1791
-				if($line->qty>90) {
1791
+				if ($line->qty > 90) {
1792 1792
 					
1793 1793
 					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1794 1794
 					
1795 1795
 					$pageBefore = $pdf->getPage();
1796
-					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1796
+					$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1797 1797
 					$pageAfter = $pdf->getPage();	
1798 1798
 
1799
-					if($pageAfter>$pageBefore) {
1799
+					if ($pageAfter > $pageBefore) {
1800 1800
 						//print "ST $pageAfter>$pageBefore<br>";
1801 1801
 						$pdf->rollbackTransaction(true);	
1802
-						$pdf->addPage('','', true);
1802
+						$pdf->addPage('', '', true);
1803 1803
 						$posy = $pdf->GetY();
1804
-						$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1804
+						$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1805 1805
 						$posy = $pdf->GetY();
1806 1806
 						//print 'add ST'.$pdf->getPage().'<br />';
1807 1807
 					}
@@ -1812,7 +1812,7 @@  discard block
 block discarded – undo
1812 1812
 				else if ($line->qty < 10) {
1813 1813
 					$pageBefore = $pdf->getPage();
1814 1814
 
1815
-					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
1815
+					$this->pdf_add_title($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h); 
1816 1816
 					$pageAfter = $pdf->getPage();	
1817 1817
 
1818 1818
 					
@@ -1887,9 +1887,9 @@  discard block
 block discarded – undo
1887 1887
 	 * @param $hookmanager  HookManager
1888 1888
 	 * @return int
1889 1889
 	 */
1890
-	function printObjectLine ($parameters, &$object, &$action, $hookmanager){
1890
+	function printObjectLine($parameters, &$object, &$action, $hookmanager) {
1891 1891
 		
1892
-		global $conf,$langs,$user,$db,$bc;
1892
+		global $conf, $langs, $user, $db, $bc;
1893 1893
 		
1894 1894
 		$num = &$parameters['num'];
1895 1895
 		$line = &$parameters['line'];
@@ -1897,32 +1897,32 @@  discard block
 block discarded – undo
1897 1897
 		
1898 1898
 		$var = &$parameters['var'];
1899 1899
 
1900
-		$contexts = explode(':',$parameters['context']);
1900
+		$contexts = explode(':', $parameters['context']);
1901 1901
 
1902 1902
 		$createRight = $user->rights->{$object->element}->creer;
1903
-		if($object->element == 'facturerec' )
1903
+		if ($object->element == 'facturerec')
1904 1904
 		{
1905 1905
 			$object->statut = 0; // hack for facture rec
1906 1906
 			$createRight = $user->rights->facture->creer;
1907 1907
 		}
1908
-		elseif($object->element == 'order_supplier' )
1908
+		elseif ($object->element == 'order_supplier')
1909 1909
 		{
1910 1910
 		    $createRight = $user->rights->fournisseur->commande->creer;
1911 1911
 		}
1912
-		elseif($object->element == 'invoice_supplier' )
1912
+		elseif ($object->element == 'invoice_supplier')
1913 1913
 		{
1914 1914
 		    $createRight = $user->rights->fournisseur->facture->creer;
1915 1915
 		}
1916 1916
 		
1917
-		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1917
+		if ($line->special_code != $this->module_number || $line->product_type != 9) {
1918 1918
 			null;
1919 1919
 		}	
1920
-		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)) 
1920
+		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)) 
1921 1921
         {
1922
-			if($object->element=='facture')$idvar = 'facid';
1923
-			else $idvar='id';
1922
+			if ($object->element == 'facture')$idvar = 'facid';
1923
+			else $idvar = 'id';
1924 1924
 			
1925
-			if((float)DOL_VERSION <= 3.4)
1925
+			if ((float) DOL_VERSION <= 3.4)
1926 1926
 			{
1927 1927
 				?>
1928 1928
 				<script type="text/javascript">
@@ -1946,20 +1946,20 @@  discard block
 block discarded – undo
1946 1946
 				<?php
1947 1947
 			}
1948 1948
 			
1949
-			if(empty($line->description)) $line->description = $line->desc;
1949
+			if (empty($line->description)) $line->description = $line->desc;
1950 1950
 			
1951 1951
 			$colspan = 5;
1952
-			if($object->element == 'facturerec' ) $colspan = 3;
1953
-			if($object->element == 'order_supplier') $colspan = 3;
1954
-			if($object->element == 'invoice_supplier') $colspan = 4;
1955
-			if($object->element == 'supplier_proposal') $colspan = 4;
1956
-			if(!empty($conf->multicurrency->enabled)) $colspan+=2;
1957
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1958
-			if(!empty($conf->margin->enabled)) $colspan++;
1959
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1960
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1961
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1962
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1952
+			if ($object->element == 'facturerec') $colspan = 3;
1953
+			if ($object->element == 'order_supplier') $colspan = 3;
1954
+			if ($object->element == 'invoice_supplier') $colspan = 4;
1955
+			if ($object->element == 'supplier_proposal') $colspan = 4;
1956
+			if (!empty($conf->multicurrency->enabled)) $colspan += 2;
1957
+			if ($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1958
+			if (!empty($conf->margin->enabled)) $colspan++;
1959
+			if (!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1960
+			if (!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1961
+			if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1962
+			if (!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1963 1963
 					
1964 1964
 			/* Titre */
1965 1965
 			//var_dump($line);
@@ -1969,35 +1969,35 @@  discard block
 block discarded – undo
1969 1969
             
1970 1970
 			
1971 1971
 			?>
1972
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1972
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1973 1973
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
1974 1974
 					{
1975
-						if($line->qty==99) print 'background:#adadcf';
1976
-						else if($line->qty==98) print 'background:#ddddff;';
1977
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
1978
-						else if($line->qty==1) print 'background:#adadcf;';
1979
-						else if($line->qty==2) print 'background:#ddddff;';
1980
-						else if($line->qty==50) print '';
1975
+						if ($line->qty == 99) print 'background:#adadcf';
1976
+						else if ($line->qty == 98) print 'background:#ddddff;';
1977
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
1978
+						else if ($line->qty == 1) print 'background:#adadcf;';
1979
+						else if ($line->qty == 2) print 'background:#ddddff;';
1980
+						else if ($line->qty == 50) print '';
1981 1981
 						else print 'background:#eeeeff;';
1982 1982
 
1983 1983
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
1984 1984
 					}
1985 1985
 					else 
1986 1986
 					{
1987
-						if($line->qty==99) print 'background:#ddffdd';
1988
-						else if($line->qty==98) print 'background:#ddddff;';
1989
-						else if($line->qty==2) print 'background:#eeeeff; ';
1990
-						else if($line->qty==50) print '';
1991
-						else print 'background:#eeffee;' ;
1987
+						if ($line->qty == 99) print 'background:#ddffdd';
1988
+						else if ($line->qty == 98) print 'background:#ddddff;';
1989
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
1990
+						else if ($line->qty == 50) print '';
1991
+						else print 'background:#eeffee;';
1992 1992
 					}
1993 1993
 
1994 1994
 			?>;">
1995 1995
 			
1996
-				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
1997
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
1996
+				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
1997
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
1998 1998
 
1999
-						$params=array('line'=>$line);
2000
-						$reshook=$hookmanager->executeHooks('formEditProductOptions',$params,$object,$action);
1999
+						$params = array('line'=>$line);
2000
+						$reshook = $hookmanager->executeHooks('formEditProductOptions', $params, $object, $action);
2001 2001
 						
2002 2002
 						echo '<div id="line_'.$line->id.'"></div>'; // Imitation Dolibarr
2003 2003
 						echo '<input type="hidden" value="'.$line->id.'" name="lineid">';
@@ -2005,7 +2005,7 @@  discard block
 block discarded – undo
2005 2005
 						echo '<input id="product_id" type="hidden" value="'.$line->fk_product.'" name="type">';
2006 2006
 						echo '<input id="special_code" type="hidden" value="'.$line->special_code.'" name="type">';
2007 2007
 
2008
-						$isFreeText=false;
2008
+						$isFreeText = false;
2009 2009
 						if (TSubtotal::isTitle($line))
2010 2010
 						{
2011 2011
 							$qty_displayed = $line->qty;
@@ -2027,13 +2027,13 @@  discard block
 block discarded – undo
2027 2027
 						    $line->description = '';
2028 2028
 						}
2029 2029
 						$newlabel = $line->label;
2030
-						if($line->label=='' && !$isFreeText) {
2031
-							if(TSubtotal::isSubtotal($line)) {
2030
+						if ($line->label == '' && !$isFreeText) {
2031
+							if (TSubtotal::isSubtotal($line)) {
2032 2032
 								$newlabel = $line->description.' '.$this->getTitle($object, $line);
2033
-								$line->description='';
2034
-							} elseif( (float)DOL_VERSION < 6 ) {
2035
-								$newlabel= $line->description;
2036
-								$line->description='';
2033
+								$line->description = '';
2034
+							} elseif ((float) DOL_VERSION < 6) {
2035
+								$newlabel = $line->description;
2036
+								$line->description = '';
2037 2037
 							}
2038 2038
 						}
2039 2039
 
@@ -2042,10 +2042,10 @@  discard block
 block discarded – undo
2042 2042
 						
2043 2043
 						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2044 2044
 						
2045
-						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
2045
+						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)))
2046 2046
 						{
2047 2047
 							$select = '<select name="subtotal_level">';
2048
-							for ($j=1; $j<10; $j++)
2048
+							for ($j = 1; $j < 10; $j++)
2049 2049
 							{
2050 2050
 								if (!empty($readonlyForSituation)) {
2051 2051
 									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
@@ -2059,7 +2059,7 @@  discard block
 block discarded – undo
2059 2059
 
2060 2060
 						echo '<div class="subtotal_underline" style="margin-left:24px; line-height: 25px;">';
2061 2061
                         echo '<div>';
2062
-                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2062
+                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '').' />&nbsp;';
2063 2063
                         echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2064 2064
                         echo '</div>';
2065 2065
 
@@ -2080,21 +2080,21 @@  discard block
 block discarded – undo
2080 2080
                                 echo '</div>';
2081 2081
                             }
2082 2082
                             echo '<div>';
2083
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2083
+                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '').' />&nbsp;';
2084 2084
                             echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2085 2085
                             echo '</div>';
2086 2086
 
2087 2087
                             echo '<div>';
2088
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2088
+                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '').' />&nbsp;';
2089 2089
                             echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2090 2090
                             echo '</div>';
2091 2091
                         }
2092 2092
                         else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2093 2093
 						echo '</div>';
2094 2094
 
2095
-						if($line->qty<10) {
2095
+						if ($line->qty < 10) {
2096 2096
 							// WYSIWYG editor
2097
-							require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
2097
+							require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
2098 2098
 							$nbrows = ROWS_2;
2099 2099
 							$cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
2100 2100
 							if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
@@ -2114,25 +2114,25 @@  discard block
 block discarded – undo
2114 2114
 
2115 2115
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2116 2116
 						 {
2117
-							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
2117
+							if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
2118 2118
 							{
2119
-								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2119
+								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
2120 2120
 								
2121 2121
 								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2122
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2122
+								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
2123 2123
 							}
2124 2124
 						 }
2125 2125
 						 else 
2126 2126
 						 {
2127
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2128
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2127
+							if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
2128
+							else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2129 2129
 						 }
2130 2130
 						 
2131 2131
 						 
2132 2132
 						 // Get display styles and apply them
2133 2133
 						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2134
-						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2135
-						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2134
+						 $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2135
+						 $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2136 2136
 						 
2137 2137
 						 if (empty($line->label)) {
2138 2138
 							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
@@ -2140,16 +2140,16 @@  discard block
 block discarded – undo
2140 2140
 						 } 
2141 2141
 						 else {
2142 2142
 
2143
-							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2143
+							if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2144 2144
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2145 2145
 							}
2146
-							else{
2146
+							else {
2147 2147
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
2148 2148
 							}
2149 2149
 
2150 2150
 						 } 
2151
-						if($line->qty>90) print ' : ';
2152
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2151
+						if ($line->qty > 90) print ' : ';
2152
+						if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2153 2153
 
2154 2154
 						 
2155 2155
 
@@ -2158,7 +2158,7 @@  discard block
 block discarded – undo
2158 2158
 			?></td>
2159 2159
 					 
2160 2160
 			<?php
2161
-				if($line->qty>90) {
2161
+				if ($line->qty > 90) {
2162 2162
 					/* Total */
2163 2163
 					$total_line = $this->getTotalLineFromObject($object, $line, '');
2164 2164
 					echo '<td class="nowrap liencolht" align="right" style="font-weight:bold;" rel="subtotal_total">'.price($total_line).'</td>';
@@ -2171,7 +2171,7 @@  discard block
 block discarded – undo
2171 2171
 				<?php
2172 2172
 				if ($action != 'selectlines') {
2173 2173
 				
2174
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
2174
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
2175 2175
 						?>
2176 2176
 						<input id="savelinebutton" class="button" type="submit" name="save" value="<?php echo $langs->trans('Save') ?>" />
2177 2177
 						<br />
@@ -2187,13 +2187,13 @@  discard block
 block discarded – undo
2187 2187
 						<?php
2188 2188
 						
2189 2189
 					}
2190
-					else{
2191
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2190
+					else {
2191
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2192 2192
 						{
2193
-							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>';
2193
+							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>';
2194 2194
 						}
2195 2195
 
2196
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
2196
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
2197 2197
 						{
2198 2198
 							echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=editline&lineid='.$line->id.'">'.img_edit().'</a>';
2199 2199
 						}								
@@ -2208,7 +2208,7 @@  discard block
 block discarded – undo
2208 2208
 				<?php
2209 2209
 
2210 2210
 				if ($action != 'editline' && $action != 'selectlines') {
2211
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2211
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2212 2212
 						{
2213 2213
 
2214 2214
 							if ($object->situation_counter == 1 || !$object->situation_cycle_ref)
@@ -2216,7 +2216,7 @@  discard block
 block discarded – undo
2216 2216
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteline&lineid='.$line->id.'">'.img_delete().'</a>';
2217 2217
 							}
2218 2218
 
2219
-							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) )
2219
+							if (TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref))
2220 2220
 							{
2221 2221
 								$img_delete = ((float) DOL_VERSION >= 3.8) ? img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal') : img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
2222 2222
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteallline&lineid='.$line->id.'">'.$img_delete.'</a>';
@@ -2227,7 +2227,7 @@  discard block
 block discarded – undo
2227 2227
 			</td>
2228 2228
 			
2229 2229
 			<?php 
2230
-			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2230
+			if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2231 2231
 			{
2232 2232
 				echo '<td class="subtotal_nc">';
2233 2233
 				echo '<input id="subtotal_nc-'.$line->id.'" class="subtotal_nc_chkbx" data-lineid="'.$line->id.'" type="checkbox" name="subtotal_nc" value="1" '.(!empty($line->array_options['options_subtotal_nc']) ? 'checked="checked"' : '').' />';
@@ -2238,11 +2238,11 @@  discard block
 block discarded – undo
2238 2238
 			<td align="center" class="tdlineupdown">
2239 2239
 			</td>
2240 2240
 			<?php } else { ?>
2241
-			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0  && $createRight ))?' class="tdlineupdown"':''); ?>></td>
2241
+			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0 && $createRight)) ? ' class="tdlineupdown"' : ''); ?>></td>
2242 2242
 			<?php } ?>
2243 2243
 
2244
-			<?php  if($action == 'selectlines'){ // dolibarr 8 ?>
2245
-			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
2244
+			<?php  if ($action == 'selectlines') { // dolibarr 8 ?>
2245
+			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i + 1; ?>]" value="<?php echo $line->id; ?>" ></td>
2246 2246
 			<?php } ?>
2247 2247
 
2248 2248
 			</tr>
@@ -2250,29 +2250,29 @@  discard block
 block discarded – undo
2250 2250
 			
2251 2251
 			
2252 2252
 			// Affichage des extrafields à la Dolibarr (car sinon non affiché sur les titres)
2253
-			if(TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2253
+			if (TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2254 2254
 				
2255
-				require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
2255
+				require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
2256 2256
 				
2257 2257
 				// Extrafields
2258 2258
 				$extrafieldsline = new ExtraFields($db);
2259 2259
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2260 2260
 				
2261
-				$colspan+=3; $mode = 'view';
2262
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2261
+				$colspan += 3; $mode = 'view';
2262
+				if ($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2263 2263
 				
2264 2264
 				$ex_element = $line->element;
2265 2265
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
2266
-				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ','colspan'=>$colspan));
2266
+				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ', 'colspan'=>$colspan));
2267 2267
 				$isExtraSelected = false;
2268
-				foreach($line->array_options as $option) {
2269
-					if(!empty($option) && $option != "-1") {
2268
+				foreach ($line->array_options as $option) {
2269
+					if (!empty($option) && $option != "-1") {
2270 2270
 						$isExtraSelected = true;
2271 2271
 						break;
2272 2272
 					}
2273 2273
 				}
2274 2274
 				
2275
-				if($mode === 'edit') {
2275
+				if ($mode === 'edit') {
2276 2276
 					?>
2277 2277
 					<script>
2278 2278
 						$(document).ready(function(){
@@ -2280,7 +2280,7 @@  discard block
 block discarded – undo
2280 2280
 							var all_tr_extrafields = $("tr.tr_extrafield_title");
2281 2281
 							<?php 
2282 2282
 							// Si un extrafield est rempli alors on affiche directement les extrafields
2283
-							if(!$isExtraSelected) {
2283
+							if (!$isExtraSelected) {
2284 2284
 								echo 'all_tr_extrafields.hide();';
2285 2285
 								echo 'var trad = "'.$langs->trans('showExtrafields').'";';
2286 2286
 								echo 'var extra = 0;';
@@ -2326,20 +2326,20 @@  discard block
 block discarded – undo
2326 2326
 
2327 2327
 	
2328 2328
 	function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) {
2329
-		global $conf,$langs;
2329
+		global $conf, $langs;
2330 2330
 		 
2331 2331
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2332 2332
 		{
2333 2333
 		    
2334
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2334
+		    if ($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2335 2335
 		    {
2336 2336
 		        foreach ($object->lines as $line)
2337 2337
 		        {
2338 2338
 		            // fetch optionals attributes and labels
2339 2339
 		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2340
-		            $extrafields=new ExtraFields($this->db);
2341
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2342
-		            $line->fetch_optionals($line->id,$extralabels);
2340
+		            $extrafields = new ExtraFields($this->db);
2341
+		            $extralabels = $extrafields->fetch_name_optionals_label($object->table_element_line, true);
2342
+		            $line->fetch_optionals($line->id, $extralabels);
2343 2343
 		        }
2344 2344
 		    }
2345 2345
 		    
@@ -2439,23 +2439,23 @@  discard block
 block discarded – undo
2439 2439
 	    $ThtmlData['data-qty']          = 0; //$line->qty;
2440 2440
 	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2441 2441
 	    
2442
-	    if(TSubtotal::isTitle($line)){
2442
+	    if (TSubtotal::isTitle($line)) {
2443 2443
 	        $ThtmlData['data-issubtotal'] = 'title';
2444
-	    }elseif(TSubtotal::isSubtotal($line)){
2444
+	    }elseif (TSubtotal::isSubtotal($line)) {
2445 2445
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2446 2446
 	    }
2447
-	    else{
2447
+	    else {
2448 2448
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2449 2449
 	    }
2450 2450
 	    
2451 2451
 	    
2452 2452
 	    // Change or add data  from hooks
2453
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2453
+	    $parameters = array_replace($parameters, array('ThtmlData' => $ThtmlData));
2454 2454
 	    
2455 2455
 	    // hook 
2456
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2456
+	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2457 2457
 	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2458
-	    if ($reshook>0)
2458
+	    if ($reshook > 0)
2459 2459
 	    {
2460 2460
 	        $ThtmlData = $hookmanager->resArray;
2461 2461
 	    }
@@ -2468,14 +2468,14 @@  discard block
 block discarded – undo
2468 2468
 	function implodeHtmlData($ThtmlData = array())
2469 2469
 	{
2470 2470
 	    $data = '';
2471
-	    foreach($ThtmlData as $k => $h )
2471
+	    foreach ($ThtmlData as $k => $h)
2472 2472
 	    {
2473
-	        if(is_array($h))
2473
+	        if (is_array($h))
2474 2474
 	        {
2475 2475
 	            $h = json_encode($h);
2476 2476
 	        }
2477 2477
 	        
2478
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2478
+	        $data .= $k.'="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2479 2479
 	    }
2480 2480
 	    
2481 2481
 	    return $data;
@@ -2483,26 +2483,26 @@  discard block
 block discarded – undo
2483 2483
 	
2484 2484
 	function _ajax_block_order_js($object)
2485 2485
 	{
2486
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2486
+	    global $conf, $tagidfortablednd, $filepath, $langs;
2487 2487
 	    
2488 2488
 	    /*
2489 2489
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2490 2490
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2491 2491
 	     */
2492 2492
 	    
2493
-	    $id=$object->id;
2494
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2495
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2493
+	    $id = $object->id;
2494
+	    $nboflines = (isset($object->lines) ?count($object->lines) : 0);
2495
+	    $forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1;
2496 2496
 	    
2497
-	    $id=$object->id;
2498
-	    $fk_element=$object->fk_element;
2499
-	    $table_element_line=$object->table_element_line;
2500
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2501
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2502
-	    $filepath=(empty($filepath)?'':$filepath);
2497
+	    $id = $object->id;
2498
+	    $fk_element = $object->fk_element;
2499
+	    $table_element_line = $object->table_element_line;
2500
+	    $nboflines = (isset($object->lines) ?count($object->lines) : (empty($nboflines) ? 0 : $nboflines));
2501
+	    $tagidfortablednd = (empty($tagidfortablednd) ? 'tablelines' : $tagidfortablednd);
2502
+	    $filepath = (empty($filepath) ? '' : $filepath);
2503 2503
 	    
2504 2504
 	    
2505
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2505
+	    if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1)
2506 2506
 	    {
2507 2507
 	        
2508 2508
 	        ?>
@@ -2520,7 +2520,7 @@  discard block
 block discarded – undo
2520 2520
 				moveBlockCol.disableSelection(); // prevent selection
2521 2521
 <?php if ($object->statut == 0) { ?>
2522 2522
 				// apply some graphical stuff
2523
-				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png',2);  ?>)');
2523
+				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png', 2); ?>)');
2524 2524
 				moveBlockCol.css("background-repeat","no-repeat");
2525 2525
 				moveBlockCol.css("background-position","center center");
2526 2526
 				moveBlockCol.css("cursor","move");
Please login to merge, or discard this patch.