@@ -89,12 +89,14 @@ discard block |
||
89 | 89 | |
90 | 90 | if ($this->version == 'development') { |
91 | 91 | return $langs->trans("Development"); |
92 | - } elseif ($this->version == 'experimental') |
|
93 | - |
|
92 | + } elseif ($this->version == 'experimental') { |
|
93 | + |
|
94 | 94 | return $langs->trans("Experimental"); |
95 | - elseif ($this->version == 'dolibarr') return DOL_VERSION; |
|
96 | - elseif ($this->version) return $this->version; |
|
97 | - else { |
|
95 | + } elseif ($this->version == 'dolibarr') { |
|
96 | + return DOL_VERSION; |
|
97 | + } elseif ($this->version) { |
|
98 | + return $this->version; |
|
99 | + } else { |
|
98 | 100 | return $langs->trans("Unknown"); |
99 | 101 | } |
100 | 102 | } |
@@ -122,14 +124,18 @@ discard block |
||
122 | 124 | $subtotal_line_found = false; |
123 | 125 | foreach ($parent->lines as $k => &$line) |
124 | 126 | { |
125 | - if ($line->rang < $rang) continue; |
|
126 | - elseif ($line->rang == $rang) // Je suis sur la ligne de titre où je souhaite ajouter ma nouvelle ligne en fin de bloc |
|
127 | + if ($line->rang < $rang) { |
|
128 | + continue; |
|
129 | + } elseif ($line->rang == $rang) { |
|
130 | + // Je suis sur la ligne de titre où je souhaite ajouter ma nouvelle ligne en fin de bloc |
|
127 | 131 | { |
128 | 132 | $title_level = $line->qty; |
129 | 133 | } |
130 | - elseif (!$subtotal_line_found && $title_level > -1 && ($line->qty == 100 - $title_level)) // Le level de mon titre a été trouvé avant, donc maintenant je vais m'arrêter jusqu'à trouver un sous-total |
|
134 | + } elseif (!$subtotal_line_found && $title_level > -1 && ($line->qty == 100 - $title_level)) { |
|
135 | + // Le level de mon titre a été trouvé avant, donc maintenant je vais m'arrêter jusqu'à trouver un sous-total |
|
131 | 136 | { |
132 | 137 | $subtotal_line_found = true; |
138 | + } |
|
133 | 139 | $rang = $line->rang; |
134 | 140 | } |
135 | 141 | |
@@ -191,8 +197,11 @@ discard block |
||
191 | 197 | break; |
192 | 198 | } |
193 | 199 | |
194 | - if (!empty($conf->global->SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK)) $this->addToEnd($parent, $object, $rang); |
|
195 | - else $this->addToBegin($parent, $object, $rang); |
|
200 | + if (!empty($conf->global->SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK)) { |
|
201 | + $this->addToEnd($parent, $object, $rang); |
|
202 | + } else { |
|
203 | + $this->addToBegin($parent, $object, $rang); |
|
204 | + } |
|
196 | 205 | |
197 | 206 | } |
198 | 207 | |
@@ -220,7 +229,9 @@ discard block |
||
220 | 229 | $commande->fetch($current_fk_commande); |
221 | 230 | |
222 | 231 | $label = $conf->global->SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE; |
223 | - if (empty($label)) $label = 'Commande [__REFORDER__] - Référence client : [__REFCUSTOMER__]'; |
|
232 | + if (empty($label)) { |
|
233 | + $label = 'Commande [__REFORDER__] - Référence client : [__REFCUSTOMER__]'; |
|
234 | + } |
|
224 | 235 | $label = str_replace(array('__REFORDER__', '__REFCUSTOMER__'), array($commande->ref, $commande->ref_client), $label); |
225 | 236 | |
226 | 237 | TSubtotal::addTitle($facture, $label, 1, $rang); |
@@ -271,10 +282,15 @@ discard block |
||
271 | 282 | $object->total_ht = $object->total_tva = $object->total_ttc = $object->total_localtax1 = $object->total_localtax2 = |
272 | 283 | $object->multicurrency_total_ht = $object->multicurrency_total_tva = $object->multicurrency_total_ttc = 0; |
273 | 284 | |
274 | - if ($object->element == 'propal') $res = $object->update(1); |
|
275 | - else $res = $object->update($user, 1); |
|
285 | + if ($object->element == 'propal') { |
|
286 | + $res = $object->update(1); |
|
287 | + } else { |
|
288 | + $res = $object->update($user, 1); |
|
289 | + } |
|
276 | 290 | |
277 | - if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
291 | + if ($res > 0) { |
|
292 | + setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
293 | + } |
|
278 | 294 | break; |
279 | 295 | } |
280 | 296 | } |
@@ -284,10 +300,15 @@ discard block |
||
284 | 300 | $object->total_ht = $object->total_tva = $object->total_ttc = $object->total_localtax1 = $object->total_localtax2 = |
285 | 301 | $object->multicurrency_total_ht = $object->multicurrency_total_tva = $object->multicurrency_total_ttc = 0; |
286 | 302 | |
287 | - if ($object->element == 'propaldet') $res = $object->update(1); |
|
288 | - else $res = $object->update($user, 1); |
|
303 | + if ($object->element == 'propaldet') { |
|
304 | + $res = $object->update(1); |
|
305 | + } else { |
|
306 | + $res = $object->update($user, 1); |
|
307 | + } |
|
289 | 308 | |
290 | - if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
309 | + if ($res > 0) { |
|
310 | + setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
311 | + } |
|
291 | 312 | } |
292 | 313 | } |
293 | 314 | } |
@@ -484,26 +505,38 @@ discard block |
||
484 | 505 | ); |
485 | 506 | |
486 | 507 | // En fonction de l'objet et de la version, les lignes conservent l'id de l'objet d'origine |
487 | - if (method_exists($object, 'fetch_lines')) $object->fetch_lines(); |
|
488 | - else $object->fetch($object->id); |
|
508 | + if (method_exists($object, 'fetch_lines')) { |
|
509 | + $object->fetch_lines(); |
|
510 | + } else { |
|
511 | + $object->fetch($object->id); |
|
512 | + } |
|
489 | 513 | |
490 | 514 | foreach ($object->lines as &$line) |
491 | 515 | { |
492 | - if (empty($line->array_options)) $line->fetch_optionals(); |
|
516 | + if (empty($line->array_options)) { |
|
517 | + $line->fetch_optionals(); |
|
518 | + } |
|
493 | 519 | |
494 | 520 | if (!TSubtotal::isModSubtotalLine($line) && !empty($line->array_options['options_subtotal_nc'])) |
495 | 521 | { |
496 | 522 | $line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = |
497 | 523 | $line->multicurrency_total_ht = $line->multicurrency_total_tva = $line->multicurrency_total_ttc = 0; |
498 | 524 | |
499 | - if ($line->element == 'propaldet') $res = $line->update(1); |
|
500 | - else $res = $line->update($user, 1); |
|
525 | + if ($line->element == 'propaldet') { |
|
526 | + $res = $line->update(1); |
|
527 | + } else { |
|
528 | + $res = $line->update($user, 1); |
|
529 | + } |
|
501 | 530 | |
502 | - if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
531 | + if ($res > 0) { |
|
532 | + setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
533 | + } |
|
503 | 534 | } |
504 | 535 | } |
505 | 536 | |
506 | - if (!empty($line)) $object->update_price(1); |
|
537 | + if (!empty($line)) { |
|
538 | + $object->update_price(1); |
|
539 | + } |
|
507 | 540 | } |
508 | 541 | |
509 | 542 | } elseif ($action == 'PROPAL_MODIFY') { |
@@ -573,9 +606,7 @@ discard block |
||
573 | 606 | dol_syslog( |
574 | 607 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id |
575 | 608 | ); |
576 | - } |
|
577 | - |
|
578 | - elseif ($action == 'BILL_MODIFY') { |
|
609 | + } elseif ($action == 'BILL_MODIFY') { |
|
579 | 610 | dol_syslog( |
580 | 611 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id |
581 | 612 | ); |
@@ -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'); |
@@ -226,21 +247,25 @@ discard block |
||
226 | 247 | global $db,$langs,$tmp_object_nc; |
227 | 248 | |
228 | 249 | $error = 0; |
229 | - if (empty($element)) $error++; |
|
250 | + if (empty($element)) { |
|
251 | + $error++; |
|
252 | + } |
|
230 | 253 | |
231 | 254 | if (!$error) |
232 | 255 | { |
233 | 256 | if (!empty($tmp_object_nc) && $tmp_object_nc->element == $element && $tmp_object_nc->id == $elementid) |
234 | 257 | { |
235 | 258 | $object = $tmp_object_nc; |
236 | - } |
|
237 | - else |
|
259 | + } else |
|
238 | 260 | { |
239 | 261 | $classname = ucfirst($element); |
240 | 262 | $object = new $classname($db); // Propal | Commande | Facture |
241 | 263 | $res = $object->fetch($elementid); |
242 | - if ($res < 0) $error++; |
|
243 | - else $tmp_object_nc = $object; |
|
264 | + if ($res < 0) { |
|
265 | + $error++; |
|
266 | + } else { |
|
267 | + $tmp_object_nc = $object; |
|
268 | + } |
|
244 | 269 | } |
245 | 270 | } |
246 | 271 | |
@@ -268,21 +293,21 @@ discard block |
||
268 | 293 | $res = doUpdate($object, $line_block, $subtotal_nc); |
269 | 294 | } |
270 | 295 | } |
271 | - } |
|
272 | - else |
|
296 | + } else |
|
273 | 297 | { |
274 | 298 | $res = doUpdate($object, $line, $subtotal_nc); |
275 | 299 | } |
276 | 300 | |
277 | 301 | $res = $object->update_price(1); |
278 | - if ($res <= 0) $error++; |
|
302 | + if ($res <= 0) { |
|
303 | + $error++; |
|
304 | + } |
|
279 | 305 | |
280 | 306 | if (!$error) |
281 | 307 | { |
282 | 308 | setEventMessage($langs->trans('subtotal_update_nc_success')); |
283 | 309 | $db->commit(); |
284 | - } |
|
285 | - else |
|
310 | + } else |
|
286 | 311 | { |
287 | 312 | setEventMessage($langs->trans('subtotal_update_nc_error'), 'errors'); |
288 | 313 | $db->rollback(); |
@@ -295,7 +320,9 @@ discard block |
||
295 | 320 | { |
296 | 321 | global $user; |
297 | 322 | |
298 | - if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1; |
|
323 | + if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) { |
|
324 | + return 1; |
|
325 | + } |
|
299 | 326 | // Update extrafield et total |
300 | 327 | if(! empty($subtotal_nc)) { |
301 | 328 | $line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = |
@@ -303,10 +330,12 @@ discard block |
||
303 | 330 | |
304 | 331 | $line->array_options['options_subtotal_nc'] = 1; |
305 | 332 | |
306 | - if ($line->element == 'propaldet') $res = $line->update(); |
|
307 | - else $res = $line->update($user); |
|
308 | - } |
|
309 | - else { |
|
333 | + if ($line->element == 'propaldet') { |
|
334 | + $res = $line->update(); |
|
335 | + } else { |
|
336 | + $res = $line->update($user); |
|
337 | + } |
|
338 | + } else { |
|
310 | 339 | $line->array_options['options_subtotal_nc'] = 0; |
311 | 340 | $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); |
312 | 341 | } |