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