@@ -54,7 +54,9 @@ discard block |
||
54 | 54 | dol_include_once('/subtotal/class/subtotal.class.php'); |
55 | 55 | $TTitle = TSubtotal::getAllTitleFromDocument($object); |
56 | 56 | $html = ''; |
57 | - if ($showLabel) $html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>'; |
|
57 | + if ($showLabel) { |
|
58 | + $html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>'; |
|
59 | + } |
|
58 | 60 | $html.= '<select onChange="$(\'select[name=under_title]\').val(this.value);" name="under_title" class="under_title minwidth200"><option value="-1"></option>'; |
59 | 61 | |
60 | 62 | $nbsp = ' '; |
@@ -95,7 +97,9 @@ discard block |
||
95 | 97 | $TFreeText = getTFreeText(); |
96 | 98 | $html = '<label for="free_text">'.$langs->trans('subtotalLabelForFreeText').'</label>'; |
97 | 99 | $html.= '<select onChange="getTFreeText($(this));" name="free_text" class="minwidth200">'; |
98 | - if ($withEmpty) $html.= '<option value=""></option>'; |
|
100 | + if ($withEmpty) { |
|
101 | + $html.= '<option value=""></option>'; |
|
102 | + } |
|
99 | 103 | |
100 | 104 | $TFreeTextContents = array(); |
101 | 105 | foreach ($TFreeText as $id => $tab) |
@@ -134,8 +138,13 @@ discard block |
||
134 | 138 | $level = GETPOST('subtotal_level', 'int'); |
135 | 139 | if (!empty($level)) |
136 | 140 | { |
137 | - if ($line->qty > 90) $line->qty = 100 - $level; // Si on edit une ligne sous-total |
|
138 | - else $line->qty = $level; |
|
141 | + if ($line->qty > 90) { |
|
142 | + $line->qty = 100 - $level; |
|
143 | + } |
|
144 | + // Si on edit une ligne sous-total |
|
145 | + else { |
|
146 | + $line->qty = $level; |
|
147 | + } |
|
139 | 148 | } |
140 | 149 | |
141 | 150 | $res = TSubtotal::doUpdateLine($object, $line->id, $description, 0, $line->qty, 0, '', '', 0, 9, 0, 0, 'HT', $pagebreak, 0, 1, null, 0, $label, TSubtotal::$module_number, $line->array_options); |
@@ -162,13 +171,18 @@ discard block |
||
162 | 171 | { |
163 | 172 | $subtotal_tva_tx = $subtotal_tva_tx_init; // ré-init car la variable peut évoluer |
164 | 173 | |
165 | - if (!empty($showBlockExtrafields)) $line->array_options = $array_options; |
|
166 | - if ($subtotal_tva_tx == '') $subtotal_tva_tx = $line->tva_tx; |
|
174 | + if (!empty($showBlockExtrafields)) { |
|
175 | + $line->array_options = $array_options; |
|
176 | + } |
|
177 | + if ($subtotal_tva_tx == '') { |
|
178 | + $subtotal_tva_tx = $line->tva_tx; |
|
179 | + } |
|
167 | 180 | if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) |
168 | 181 | { |
169 | 182 | $subtotal_progress = $subtotal_progress_init; |
170 | - if ($subtotal_progress == '') $subtotal_progress = $line->situation_percent; |
|
171 | - else |
|
183 | + if ($subtotal_progress == '') { |
|
184 | + $subtotal_progress = $line->situation_percent; |
|
185 | + } else |
|
172 | 186 | { |
173 | 187 | $prev_percent = $line->get_prev_progress($object->id); |
174 | 188 | if ($subtotal_progress < $prev_percent) |
@@ -181,14 +195,21 @@ discard block |
||
181 | 195 | |
182 | 196 | $res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $subtotal_tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $subtotal_progress, $line->fk_unit); |
183 | 197 | |
184 | - if ($res > 0) $success_updated_line++; |
|
185 | - else $error_updated_line++; |
|
198 | + if ($res > 0) { |
|
199 | + $success_updated_line++; |
|
200 | + } else { |
|
201 | + $error_updated_line++; |
|
202 | + } |
|
186 | 203 | } |
187 | 204 | } |
188 | 205 | |
189 | - if ($nb_progress_not_updated > 0) setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings'); |
|
206 | + if ($nb_progress_not_updated > 0) { |
|
207 | + setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings'); |
|
208 | + } |
|
190 | 209 | |
191 | - if ($success_updated_line > 0) setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line)); |
|
210 | + if ($success_updated_line > 0) { |
|
211 | + setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line)); |
|
212 | + } |
|
192 | 213 | if ($error_updated_line > 0) |
193 | 214 | { |
194 | 215 | setEventMessage($langs->trans('subtotal_error_updated_line', $error_updated_line), 'errors'); |
@@ -229,15 +250,16 @@ discard block |
||
229 | 250 | global $db,$langs,$tmp_object_nc; |
230 | 251 | |
231 | 252 | $error = 0; |
232 | - if (empty($element)) $error++; |
|
253 | + if (empty($element)) { |
|
254 | + $error++; |
|
255 | + } |
|
233 | 256 | |
234 | 257 | if (!$error) |
235 | 258 | { |
236 | 259 | if (!empty($tmp_object_nc) && $tmp_object_nc->element == $element && $tmp_object_nc->id == $elementid) |
237 | 260 | { |
238 | 261 | $object = $tmp_object_nc; |
239 | - } |
|
240 | - else |
|
262 | + } else |
|
241 | 263 | { |
242 | 264 | $classname = ucfirst($element); |
243 | 265 | |
@@ -257,8 +279,11 @@ discard block |
||
257 | 279 | |
258 | 280 | $object = new $classname($db); // Propal | Commande | Facture |
259 | 281 | $res = $object->fetch($elementid); |
260 | - if ($res < 0) $error++; |
|
261 | - else $tmp_object_nc = $object; |
|
282 | + if ($res < 0) { |
|
283 | + $error++; |
|
284 | + } else { |
|
285 | + $tmp_object_nc = $object; |
|
286 | + } |
|
262 | 287 | } |
263 | 288 | } |
264 | 289 | |
@@ -286,21 +311,21 @@ discard block |
||
286 | 311 | $res = doUpdate($object, $line_block, $subtotal_nc); |
287 | 312 | } |
288 | 313 | } |
289 | - } |
|
290 | - else |
|
314 | + } else |
|
291 | 315 | { |
292 | 316 | $res = doUpdate($object, $line, $subtotal_nc); |
293 | 317 | } |
294 | 318 | |
295 | 319 | $res = $object->update_price(1); |
296 | - if ($res <= 0) $error++; |
|
320 | + if ($res <= 0) { |
|
321 | + $error++; |
|
322 | + } |
|
297 | 323 | |
298 | 324 | if (!$error) |
299 | 325 | { |
300 | 326 | setEventMessage($langs->trans('subtotal_update_nc_success')); |
301 | 327 | $db->commit(); |
302 | - } |
|
303 | - else |
|
328 | + } else |
|
304 | 329 | { |
305 | 330 | setEventMessage($langs->trans('subtotal_update_nc_error'), 'errors'); |
306 | 331 | $db->rollback(); |
@@ -313,7 +338,9 @@ discard block |
||
313 | 338 | { |
314 | 339 | global $user; |
315 | 340 | |
316 | - if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1; |
|
341 | + if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) { |
|
342 | + return 1; |
|
343 | + } |
|
317 | 344 | // Update extrafield et total |
318 | 345 | if(! empty($subtotal_nc)) { |
319 | 346 | $line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = |
@@ -321,12 +348,17 @@ discard block |
||
321 | 348 | |
322 | 349 | $line->array_options['options_subtotal_nc'] = 1; |
323 | 350 | |
324 | - if ($line->element == 'propaldet') $res = $line->update(); |
|
325 | - else $res = $line->update($user); |
|
326 | - } |
|
327 | - else { |
|
351 | + if ($line->element == 'propaldet') { |
|
352 | + $res = $line->update(); |
|
353 | + } else { |
|
354 | + $res = $line->update($user); |
|
355 | + } |
|
356 | + } else { |
|
328 | 357 | if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) { |
329 | - if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label |
|
358 | + if(empty($line->label)) { |
|
359 | + $line->label = $line->description; |
|
360 | + } |
|
361 | + // supplier lines don't have the field label |
|
330 | 362 | |
331 | 363 | require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); |
332 | 364 | $extrafields=new ExtraFields($object->db); |
@@ -334,7 +366,9 @@ discard block |
||
334 | 366 | $line->fetch_optionals($line->id,$extralabels); |
335 | 367 | } |
336 | 368 | $line->array_options['options_subtotal_nc'] = 0; |
337 | - if($object->element == 'order_supplier') $line->update($user); |
|
369 | + if($object->element == 'order_supplier') { |
|
370 | + $line->update($user); |
|
371 | + } |
|
338 | 372 | $res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); |
339 | 373 | } |
340 | 374 |