mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 17:18:13 +01:00
clean module subtotal (#35003)
* clean module subtotal * Update commonsubtotal.class.php * Update subtotals.php
This commit is contained in:
@@ -56,19 +56,19 @@ $formother = new FormOther($db);
|
||||
$default = 'ffffff';
|
||||
|
||||
// Constant and translation of the module description
|
||||
$modules = array(
|
||||
$modules = [
|
||||
'PROPAL' => array('lang' => 'propal', 'key' => 'Proposal', 'old_pdf' => '(azur model)'),
|
||||
'COMMANDE' => array('lang' => 'orders', 'key' => 'CustomerOrder', 'old_pdf' => '(einstein model)'),
|
||||
'FACTURE' => array('lang' => 'bills', 'key' => 'CustomerInvoice', 'old_pdf' => '(crabe model)'),
|
||||
'FACTUREREC' => array('lang' => 'bills', 'key' => 'RecurringInvoiceTemplate'),
|
||||
);
|
||||
];
|
||||
// Conditions for the option to be offered
|
||||
$conditions = array(
|
||||
'PROPAL' => (isModEnabled("propal")),
|
||||
'COMMANDE' => (isModEnabled("order")),
|
||||
'FACTURE' => (isModEnabled("invoice")),
|
||||
'FACTUREREC' => (isModEnabled("invoice")),
|
||||
);
|
||||
$conditions = [
|
||||
'PROPAL' => isModEnabled("propal"),
|
||||
'COMMANDE' => isModEnabled("order"),
|
||||
'FACTURE' => isModEnabled("invoice"),
|
||||
'FACTUREREC' => isModEnabled("invoice"),
|
||||
];
|
||||
|
||||
$max_depth = 0;
|
||||
|
||||
|
||||
@@ -493,7 +493,13 @@ trait CommonSubtotal
|
||||
{
|
||||
$current_module = $this->element;
|
||||
// Ensure the object is one of the supported types
|
||||
$allowed_types = array('propal', 'commande', 'facture', 'facturerec', 'shipping');
|
||||
$allowed_types = [
|
||||
'propal',
|
||||
'commande',
|
||||
'facture',
|
||||
'facturerec',
|
||||
'shipping',
|
||||
];
|
||||
if (!in_array($current_module, $allowed_types)) {
|
||||
if (isset($this->errors)) {
|
||||
$this->errors[] = $langs->trans("UnsupportedModuleError");
|
||||
@@ -512,78 +518,78 @@ trait CommonSubtotal
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if ($current_module == 'facture') {
|
||||
$result = $this->updateline( // @phpstan-ignore-line
|
||||
$this->lines[$i]->id, // @phpstan-ignore-line
|
||||
$this->lines[$i]->desc, // @phpstan-ignore-line
|
||||
$this->lines[$i]->subprice, // @phpstan-ignore-line
|
||||
$this->lines[$i]->qty, // @phpstan-ignore-line
|
||||
$mode == 'discount' ? $value : $this->lines[$i]->remise_percent, // @phpstan-ignore-line
|
||||
$this->lines[$i]->date_start, // @phpstan-ignore-line
|
||||
$this->lines[$i]->date_end, // @phpstan-ignore-line
|
||||
$mode == 'tva' ? $value : $this->lines[$i]->tva_tx, // @phpstan-ignore-line
|
||||
$this->lines[$i]->localtax1_tx, // @phpstan-ignore-line
|
||||
$this->lines[$i]->localtax2_tx, // @phpstan-ignore-line
|
||||
'HT', // @phpstan-ignore-line
|
||||
$this->lines[$i]->info_bits, // @phpstan-ignore-line
|
||||
$this->lines[$i]->product_type, // @phpstan-ignore-line
|
||||
$this->lines[$i]->fk_parent_line, 0, // @phpstan-ignore-line
|
||||
$this->lines[$i]->fk_fournprice, // @phpstan-ignore-line
|
||||
$this->lines[$i]->pa_ht, // @phpstan-ignore-line
|
||||
$this->lines[$i]->label, // @phpstan-ignore-line
|
||||
$this->lines[$i]->special_code, // @phpstan-ignore-line
|
||||
$this->lines[$i]->array_options, // @phpstan-ignore-line
|
||||
$this->lines[$i]->situation_percent, // @phpstan-ignore-line
|
||||
$this->lines[$i]->fk_unit, // @phpstan-ignore-line
|
||||
$this->lines[$i]->multicurrency_subprice // @phpstan-ignore-line
|
||||
if ($current_module == 'facture' && $this instanceof Facture) {
|
||||
$result = $this->updateline(
|
||||
$this->lines[$i]->id,
|
||||
$this->lines[$i]->desc,
|
||||
$this->lines[$i]->subprice,
|
||||
$this->lines[$i]->qty,
|
||||
$mode == 'discount' ? $value : $this->lines[$i]->remise_percent,
|
||||
$this->lines[$i]->date_start,
|
||||
$this->lines[$i]->date_end,
|
||||
$mode == 'tva' ? $value : $this->lines[$i]->tva_tx,
|
||||
$this->lines[$i]->localtax1_tx,
|
||||
$this->lines[$i]->localtax2_tx,
|
||||
'HT',
|
||||
$this->lines[$i]->info_bits,
|
||||
$this->lines[$i]->product_type,
|
||||
$this->lines[$i]->fk_parent_line, 0,
|
||||
$this->lines[$i]->fk_fournprice,
|
||||
$this->lines[$i]->pa_ht,
|
||||
$this->lines[$i]->label,
|
||||
$this->lines[$i]->special_code,
|
||||
$this->lines[$i]->array_options,
|
||||
$this->lines[$i]->situation_percent,
|
||||
$this->lines[$i]->fk_unit,
|
||||
$this->lines[$i]->multicurrency_subprice
|
||||
);
|
||||
} elseif ($current_module == 'commande') {
|
||||
$result = $this->updateline( // @phpstan-ignore-line
|
||||
$this->lines[$i]->id, // @phpstan-ignore-line
|
||||
$this->lines[$i]->desc, // @phpstan-ignore-line
|
||||
$this->lines[$i]->subprice, // @phpstan-ignore-line
|
||||
$this->lines[$i]->qty, // @phpstan-ignore-line
|
||||
$mode == 'discount' ? $value : $this->lines[$i]->remise_percent, // @phpstan-ignore-line
|
||||
$mode == 'tva' ? $value : $this->lines[$i]->tva_tx, // @phpstan-ignore-line
|
||||
$this->lines[$i]->localtax1_rate, // @phpstan-ignore-line
|
||||
$this->lines[$i]->localtax2_rate, // @phpstan-ignore-line
|
||||
'HT', // @phpstan-ignore-line
|
||||
$this->lines[$i]->info_bits, // @phpstan-ignore-line
|
||||
$this->lines[$i]->date_start, // @phpstan-ignore-line
|
||||
$this->lines[$i]->date_end, // @phpstan-ignore-line
|
||||
$this->lines[$i]->product_type, // @phpstan-ignore-line
|
||||
$this->lines[$i]->fk_parent_line, 0, // @phpstan-ignore-line
|
||||
$this->lines[$i]->fk_fournprice, // @phpstan-ignore-line
|
||||
$this->lines[$i]->pa_ht, // @phpstan-ignore-line
|
||||
$this->lines[$i]->label, // @phpstan-ignore-line
|
||||
$this->lines[$i]->special_code, // @phpstan-ignore-line
|
||||
$this->lines[$i]->array_options, // @phpstan-ignore-line
|
||||
$this->lines[$i]->fk_unit, // @phpstan-ignore-line
|
||||
$this->lines[$i]->multicurrency_subprice // @phpstan-ignore-line
|
||||
} elseif ($current_module == 'commande' && $this instanceof Commande) {
|
||||
$result = $this->updateline(
|
||||
$this->lines[$i]->id,
|
||||
$this->lines[$i]->desc,
|
||||
$this->lines[$i]->subprice,
|
||||
$this->lines[$i]->qty,
|
||||
$mode == 'discount' ? $value : $this->lines[$i]->remise_percent,
|
||||
$mode == 'tva' ? $value : $this->lines[$i]->tva_tx,
|
||||
$this->lines[$i]->localtax1_rate,
|
||||
$this->lines[$i]->localtax2_rate,
|
||||
'HT',
|
||||
$this->lines[$i]->info_bits,
|
||||
$this->lines[$i]->date_start,
|
||||
$this->lines[$i]->date_end,
|
||||
$this->lines[$i]->product_type,
|
||||
$this->lines[$i]->fk_parent_line, 0,
|
||||
$this->lines[$i]->fk_fournprice,
|
||||
$this->lines[$i]->pa_ht,
|
||||
$this->lines[$i]->label,
|
||||
$this->lines[$i]->special_code,
|
||||
$this->lines[$i]->array_options,
|
||||
$this->lines[$i]->fk_unit,
|
||||
$this->lines[$i]->multicurrency_subprice
|
||||
);
|
||||
} elseif ($current_module == 'propal') {
|
||||
$result = $this->updateline( // @phpstan-ignore-line
|
||||
$this->lines[$i]->id, // @phpstan-ignore-line
|
||||
$this->lines[$i]->subprice, // @phpstan-ignore-line
|
||||
$this->lines[$i]->qty, // @phpstan-ignore-line
|
||||
$mode == 'discount' ? $value : $this->lines[$i]->remise_percent, // @phpstan-ignore-line
|
||||
$mode == 'tva' ? $value : $this->lines[$i]->tva_tx, // @phpstan-ignore-line
|
||||
$this->lines[$i]->localtax1_rate, // @phpstan-ignore-line
|
||||
$this->lines[$i]->localtax2_rate, // @phpstan-ignore-line
|
||||
$this->lines[$i]->desc, // @phpstan-ignore-line
|
||||
'HT', // @phpstan-ignore-line
|
||||
$this->lines[$i]->info_bits, // @phpstan-ignore-line
|
||||
$this->lines[$i]->special_code, // @phpstan-ignore-line
|
||||
$this->lines[$i]->fk_parent_line, 0, // @phpstan-ignore-line
|
||||
$this->lines[$i]->fk_fournprice, // @phpstan-ignore-line
|
||||
$this->lines[$i]->pa_ht, // @phpstan-ignore-line
|
||||
$this->lines[$i]->label, // @phpstan-ignore-line
|
||||
$this->lines[$i]->product_type, // @phpstan-ignore-line
|
||||
$this->lines[$i]->date_start, // @phpstan-ignore-line
|
||||
$this->lines[$i]->date_end, // @phpstan-ignore-line
|
||||
$this->lines[$i]->array_options, // @phpstan-ignore-line
|
||||
$this->lines[$i]->fk_unit, // @phpstan-ignore-line
|
||||
$this->lines[$i]->multicurrency_subprice // @phpstan-ignore-line
|
||||
} elseif ($current_module == 'propal' && $this instanceof Propal) {
|
||||
$result = $this->updateline(
|
||||
$this->lines[$i]->id,
|
||||
$this->lines[$i]->subprice,
|
||||
$this->lines[$i]->qty,
|
||||
$mode == 'discount' ? $value : $this->lines[$i]->remise_percent,
|
||||
$mode == 'tva' ? $value : $this->lines[$i]->tva_tx,
|
||||
$this->lines[$i]->localtax1_rate,
|
||||
$this->lines[$i]->localtax2_rate,
|
||||
$this->lines[$i]->desc,
|
||||
'HT',
|
||||
$this->lines[$i]->info_bits,
|
||||
$this->lines[$i]->special_code,
|
||||
$this->lines[$i]->fk_parent_line, 0,
|
||||
$this->lines[$i]->fk_fournprice,
|
||||
$this->lines[$i]->pa_ht,
|
||||
$this->lines[$i]->label,
|
||||
$this->lines[$i]->product_type,
|
||||
$this->lines[$i]->date_start,
|
||||
$this->lines[$i]->date_end,
|
||||
$this->lines[$i]->array_options,
|
||||
$this->lines[$i]->fk_unit,
|
||||
$this->lines[$i]->multicurrency_subprice
|
||||
);
|
||||
}
|
||||
if ($result < 0) {
|
||||
|
||||
Reference in New Issue
Block a user