From 1e47266b16f10c99c2b4334e64ecbf88ffa8e311 Mon Sep 17 00:00:00 2001 From: tnegre Date: Fri, 11 Oct 2024 12:02:34 +0200 Subject: [PATCH] Manage update for INVOICE_USE_RETAINED_WARRANTY --- htdocs/admin/invoice_situation.php | 21 ++++++++++++++++----- htdocs/langs/en_US/stocks.lang | 3 +-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/invoice_situation.php b/htdocs/admin/invoice_situation.php index d734783b37fad..6b7979be2b7ac 100644 --- a/htdocs/admin/invoice_situation.php +++ b/htdocs/admin/invoice_situation.php @@ -79,15 +79,26 @@ $item->nameText = $langs->trans('AllowedInvoiceForRetainedWarranty'); $arrayAvailableType = array( - 0 => "", // don't use $showempty in selectArray since it sets a value of -1 Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation"), Facture::TYPE_STANDARD.'+'.Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation").' + '.$langs->trans("InvoiceStandard"), ); -if ($action == 'edit') { - $item->fieldInputOverride = $form->selectarray('INVOICE_USE_RETAINED_WARRANTY', $arrayAvailableType, $conf->global->INVOICE_USE_RETAINED_WARRANTY, 0); -} else { - $item->fieldOutputOverride= isset($arrayAvailableType[getDolGlobalString('INVOICE_USE_RETAINED_WARRANTY')]) ? $arrayAvailableType[getDolGlobalString('INVOICE_USE_RETAINED_WARRANTY')] : ''; +switch ($action) { + case 'edit': + $item->fieldInputOverride = $form->selectarray('INVOICE_USE_RETAINED_WARRANTY', $arrayAvailableType, $conf->global->INVOICE_USE_RETAINED_WARRANTY, 1); + break; + case 'update': + $ret_warranty_val = GETPOST('INVOICE_USE_RETAINED_WARRANTY'); + if ($ret_warranty_val == -1) { + $conf->global->INVOICE_USE_RETAINED_WARRANTY = ''; + $_POST['INVOICE_USE_RETAINED_WARRANTY'] = ''; + } else { + $conf->global->INVOICE_USE_RETAINED_WARRANTY = $ret_warranty_val; + } + $item->fieldOutputOverride = $arrayAvailableType[$ret_warranty_val] ?? ''; + break; + default: + $item->fieldOutputOverride = $arrayAvailableType[getDolGlobalString('INVOICE_USE_RETAINED_WARRANTY')] ?? ''; } //$item = $formSetup->newItem('INVOICE_RETAINED_WARRANTY_LIMITED_TO_SITUATION')->setAsYesNo(); diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index b32510414cee5..f0f44ae3d4256 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -335,5 +335,4 @@ ExternalWarehouse=External warehouse LatestModifiedWarehouses=Latest %s modified warehouses LatestStockMovements=Latest %s stock movements QtyCurrentlyKnownInStock=System estimated quantity you have in stock. As long as the inventory is not closed, this is a realtime value and it may change if you continue to make stock movement during the inventory (not recommended). -QtyInStockWhenInventoryWasValidated=System estimated quantity you had in stock when the inventory was validated (before the stock correction) -StockTransferProFormat=Proforma stocks transfer \ No newline at end of file +QtyInStockWhenInventoryWasValidated=System estimated quantity you had in stock when the inventory was validated (before the stock correction) \ No newline at end of file