@@ -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 | |
@@ -194,8 +200,11 @@ discard block |
||
| 194 | 200 | break; |
| 195 | 201 | } |
| 196 | 202 | |
| 197 | - if (!empty($conf->global->SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK)) $this->addToEnd($parent, $object, $rang); |
|
| 198 | - else $this->addToBegin($parent, $object, $rang); |
|
| 203 | + if (!empty($conf->global->SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK)) { |
|
| 204 | + $this->addToEnd($parent, $object, $rang); |
|
| 205 | + } else { |
|
| 206 | + $this->addToBegin($parent, $object, $rang); |
|
| 207 | + } |
|
| 199 | 208 | |
| 200 | 209 | } |
| 201 | 210 | |
@@ -216,8 +225,7 @@ discard block |
||
| 216 | 225 | if (!$is_supplier){ |
| 217 | 226 | $facture = new Facture($this->db); |
| 218 | 227 | $ret = $facture->fetch($object->fk_facture); |
| 219 | - } |
|
| 220 | - else |
|
| 228 | + } else |
|
| 221 | 229 | { |
| 222 | 230 | $facture = new FactureFournisseur($this->db); |
| 223 | 231 | $ret = $facture->fetch($object->fk_facture_fourn); |
@@ -228,14 +236,19 @@ discard block |
||
| 228 | 236 | $rang = !empty($subtotal_current_rang) ? $subtotal_current_rang : $object->rang; |
| 229 | 237 | // Si le fk_commande courrant est différent alors on change de commande => ajout d'un titre |
| 230 | 238 | if ($current_fk_commande != $subtotal_bloc_previous_fk_commande ) { |
| 231 | - if (!$is_supplier) $commande = new Commande($this->db); |
|
| 232 | - else $commande = new CommandeFournisseur($this->db); |
|
| 239 | + if (!$is_supplier) { |
|
| 240 | + $commande = new Commande($this->db); |
|
| 241 | + } else { |
|
| 242 | + $commande = new CommandeFournisseur($this->db); |
|
| 243 | + } |
|
| 233 | 244 | $commande->fetch($current_fk_commande); |
| 234 | 245 | |
| 235 | 246 | $label = $conf->global->SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE; |
| 236 | 247 | if (empty($label)) { |
| 237 | 248 | $label = 'Commande [__REFORDER__]'; |
| 238 | - if (!$is_supplier) $label .= ' - Référence client : [__REFCUSTOMER__]'; |
|
| 249 | + if (!$is_supplier) { |
|
| 250 | + $label .= ' - Référence client : [__REFCUSTOMER__]'; |
|
| 251 | + } |
|
| 239 | 252 | } |
| 240 | 253 | $label = str_replace(array('__REFORDER__', '__REFCUSTOMER__'), array($commande->ref, $commande->ref_client), $label); |
| 241 | 254 | |
@@ -276,7 +289,9 @@ discard block |
||
| 276 | 289 | |
| 277 | 290 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && in_array($action, array('LINEPROPAL_INSERT', 'LINEPROPAL_UPDATE', 'LINEORDER_INSERT', 'LINEORDER_UPDATE', 'LINEBILL_INSERT', 'LINEBILL_UPDATE', 'LINEBILL_SUPPLIER_CREATE', 'LINEBILL_SUPPLIER_UPDATE'))) |
| 278 | 291 | { |
| 279 | - if(! function_exists('_updateLineNC')) dol_include_once('/subtotal/lib/subtotal.lib.php'); |
|
| 292 | + if(! function_exists('_updateLineNC')) { |
|
| 293 | + dol_include_once('/subtotal/lib/subtotal.lib.php'); |
|
| 294 | + } |
|
| 280 | 295 | |
| 281 | 296 | $doli_action = GETPOST('action'); |
| 282 | 297 | $set = GETPOST('set'); |
@@ -294,32 +309,50 @@ discard block |
||
| 294 | 309 | $object->total_ht = $object->total_tva = $object->total_ttc = $object->total_localtax1 = $object->total_localtax2 = |
| 295 | 310 | $object->multicurrency_total_ht = $object->multicurrency_total_tva = $object->multicurrency_total_ttc = 0; |
| 296 | 311 | |
| 297 | - if ($object->element == 'propal') $res = $object->update(1); |
|
| 298 | - else $res = $object->update($user, 1); |
|
| 312 | + if ($object->element == 'propal') { |
|
| 313 | + $res = $object->update(1); |
|
| 314 | + } else { |
|
| 315 | + $res = $object->update($user, 1); |
|
| 316 | + } |
|
| 299 | 317 | |
| 300 | - if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
| 318 | + if ($res > 0) { |
|
| 319 | + setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
| 320 | + } |
|
| 301 | 321 | break; |
| 302 | 322 | } |
| 303 | 323 | } |
| 304 | 324 | |
| 305 | 325 | // $object correspond à la ligne ajoutée |
| 306 | - if(empty($object->array_options)) $object->fetch_optionals(); |
|
| 326 | + if(empty($object->array_options)) { |
|
| 327 | + $object->fetch_optionals(); |
|
| 328 | + } |
|
| 307 | 329 | |
| 308 | 330 | if(! empty($object->array_options['options_subtotal_nc'])) { |
| 309 | 331 | $object->total_ht = $object->total_tva = $object->total_ttc = $object->total_localtax1 = $object->total_localtax2 = |
| 310 | 332 | $object->multicurrency_total_ht = $object->multicurrency_total_tva = $object->multicurrency_total_ttc = 0; |
| 311 | 333 | |
| 312 | - if ($object->element == 'propaldet') $res = $object->update(1); |
|
| 313 | - else $res = $object->update($user, 1); |
|
| 334 | + if ($object->element == 'propaldet') { |
|
| 335 | + $res = $object->update(1); |
|
| 336 | + } else { |
|
| 337 | + $res = $object->update($user, 1); |
|
| 338 | + } |
|
| 314 | 339 | |
| 315 | - if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
| 340 | + if ($res > 0) { |
|
| 341 | + setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
| 342 | + } |
|
| 316 | 343 | } |
| 317 | 344 | |
| 318 | 345 | // Correction d'un bug lors de la création d'une commande depuis une propale qui a, au moins, une ligne NC |
| 319 | 346 | $parent_element = ''; |
| 320 | - if($object->element == 'propaldet') $parent_element = 'propal'; |
|
| 321 | - if($object->element == 'commandedet') $parent_element = 'commande'; |
|
| 322 | - if($object->element == 'facturedet') $parent_element = 'facture'; |
|
| 347 | + if($object->element == 'propaldet') { |
|
| 348 | + $parent_element = 'propal'; |
|
| 349 | + } |
|
| 350 | + if($object->element == 'commandedet') { |
|
| 351 | + $parent_element = 'commande'; |
|
| 352 | + } |
|
| 353 | + if($object->element == 'facturedet') { |
|
| 354 | + $parent_element = 'facture'; |
|
| 355 | + } |
|
| 323 | 356 | |
| 324 | 357 | if(! empty($parent_element) && ! empty($object->array_options['options_subtotal_nc'])) { |
| 325 | 358 | _updateLineNC($parent_element, $object->{'fk_'.$parent_element}, $object->id, $object->array_options['options_subtotal_nc'], 1); |
@@ -519,26 +552,38 @@ discard block |
||
| 519 | 552 | ); |
| 520 | 553 | |
| 521 | 554 | // En fonction de l'objet et de la version, les lignes conservent l'id de l'objet d'origine |
| 522 | - if (method_exists($object, 'fetch_lines')) $object->fetch_lines(); |
|
| 523 | - else $object->fetch($object->id); |
|
| 555 | + if (method_exists($object, 'fetch_lines')) { |
|
| 556 | + $object->fetch_lines(); |
|
| 557 | + } else { |
|
| 558 | + $object->fetch($object->id); |
|
| 559 | + } |
|
| 524 | 560 | |
| 525 | 561 | foreach ($object->lines as &$line) |
| 526 | 562 | { |
| 527 | - if (empty($line->array_options)) $line->fetch_optionals(); |
|
| 563 | + if (empty($line->array_options)) { |
|
| 564 | + $line->fetch_optionals(); |
|
| 565 | + } |
|
| 528 | 566 | |
| 529 | 567 | if (!TSubtotal::isModSubtotalLine($line) && !empty($line->array_options['options_subtotal_nc'])) |
| 530 | 568 | { |
| 531 | 569 | $line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = |
| 532 | 570 | $line->multicurrency_total_ht = $line->multicurrency_total_tva = $line->multicurrency_total_ttc = 0; |
| 533 | 571 | |
| 534 | - if ($line->element == 'propaldet') $res = $line->update(1); |
|
| 535 | - else $res = $line->update($user, 1); |
|
| 572 | + if ($line->element == 'propaldet') { |
|
| 573 | + $res = $line->update(1); |
|
| 574 | + } else { |
|
| 575 | + $res = $line->update($user, 1); |
|
| 576 | + } |
|
| 536 | 577 | |
| 537 | - if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
| 578 | + if ($res > 0) { |
|
| 579 | + setEventMessage($langs->trans('subtotal_update_nc_success')); |
|
| 580 | + } |
|
| 538 | 581 | } |
| 539 | 582 | } |
| 540 | 583 | |
| 541 | - if (!empty($line)) $object->update_price(1); |
|
| 584 | + if (!empty($line)) { |
|
| 585 | + $object->update_price(1); |
|
| 586 | + } |
|
| 542 | 587 | } |
| 543 | 588 | |
| 544 | 589 | } elseif ($action == 'PROPAL_MODIFY') { |
@@ -608,9 +653,7 @@ discard block |
||
| 608 | 653 | dol_syslog( |
| 609 | 654 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id |
| 610 | 655 | ); |
| 611 | - } |
|
| 612 | - |
|
| 613 | - elseif ($action == 'BILL_MODIFY') { |
|
| 656 | + } elseif ($action == 'BILL_MODIFY') { |
|
| 614 | 657 | dol_syslog( |
| 615 | 658 | "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id |
| 616 | 659 | ); |