diff --git a/htdocs/admin/facture_situation.php b/htdocs/admin/facture_situation.php index 0a4c36cb8a8..65f7ca4b8de 100644 --- a/htdocs/admin/facture_situation.php +++ b/htdocs/admin/facture_situation.php @@ -96,9 +96,26 @@ print "\n"; _printOnOff('INVOICE_USE_SITUATION', $langs->trans('UseSituationInvoices')); _printOnOff('INVOICE_USE_SITUATION_CREDIT_NOTE', $langs->trans('UseSituationInvoicesCreditNote')); -_printOnOff('INVOICE_USE_RETAINED_WARRANTY', $langs->trans('Retainedwarranty')); -_printOnOff('USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION', $langs->trans('RetainedwarrantyOnlyForSituation')); -_printOnOff('USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION_FINAL', $langs->trans('RetainedwarrantyOnlyForSituationFinal')); +//_printOnOff('INVOICE_USE_RETAINED_WARRANTY', $langs->trans('Retainedwarranty')); + +$confkey = 'INVOICE_USE_RETAINED_WARRANTY'; + +$arrayAvailableType = array( + Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation"), + Facture::TYPE_STANDARD.'+'.Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation").' + '.$langs->trans("InvoiceStandard"), +); +$selected = array(); +$implodeglue = '+'; +if(!empty($conf->global->{$confkey}) && !is_array($conf->global->{$confkey})){ + $selected = explode('+', $conf->global->{$confkey}); +} + +$curentInput = (empty($inputCount)?1:($inputCount+1)); +$formSelectInvoiceType = $form->selectarray('value'. $curentInput, $arrayAvailableType, $selected, 1); +_printInputFormPart($confkey, $langs->trans('AllowedInvoiceForRetainedWarranty'), '', array(), $formSelectInvoiceType); + +//_printOnOff('INVOICE_RETAINED_WARRANTY_LIMITED_TO_SITUATION', $langs->trans('RetainedwarrantyOnlyForSituation')); +_printOnOff('INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION', $langs->trans('RetainedwarrantyOnlyForSituationFinal')); $metas = array( 'type' => 'number', @@ -228,9 +245,13 @@ function _printInputFormPart($confkey, $title = false, $desc = '', $metas = arra print ''; if ($type=='textarea') { - print ''; - } else { + print ''; + }elseif($type=='input'){ print ''; } + else{ + // custom + print $type; + } print ''; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 62a84a51245..ada61efae91 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -140,10 +140,9 @@ $isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid, $isdraft); // retained warranty invoice available type -if(empty($conf->global->USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION)) { - $retainedWarrantyInvoiceAvailableType = array( Facture::TYPE_SITUATION, Facture::TYPE_STANDARD); -} else { - $retainedWarrantyInvoiceAvailableType = array( Facture::TYPE_SITUATION ); +$retainedWarrantyInvoiceAvailableType=array(); +if(!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { + $retainedWarrantyInvoiceAvailableType = explode('+', $conf->global->INVOICE_USE_RETAINED_WARRANTY); } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0b1915a6fc9..af709cec2c4 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4750,15 +4750,15 @@ class Facture extends CommonInvoice { global $conf; - // TODO : add a flag on invoices to store this conf : USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION_FINAL + // TODO : add a flag on invoices to store this conf : INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION - // note : we dont need to test USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION because if $this->retained_warranty is not empty it's because it was set when this conf was active + // note : we dont need to test INVOICE_USE_RETAINED_WARRANTY because if $this->retained_warranty is not empty it's because it was set when this conf was active $displayWarranty = false; if(!empty($this->retained_warranty)) { $displayWarranty = true; - if ($this->type == Facture::TYPE_SITUATION && !empty($conf->global->USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION_FINAL)) { + if ($this->type == Facture::TYPE_SITUATION && !empty($conf->global->INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION)) { // Check if this situation invoice is 100% for real $displayWarranty = false; if (!empty($this->situation_final)) { @@ -4794,7 +4794,7 @@ class Facture extends CommonInvoice $retainedWarrantyAmount = 0; // Billed - retained warranty - if($this->type == Facture::TYPE_SITUATION && !empty($conf->global->USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION_FINAL)) + if($this->type == Facture::TYPE_SITUATION && !empty($conf->global->INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION)) { $displayWarranty = true; // Check if this situation invoice is 100% for real diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index d2b830119ca..36747c4625a 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -219,6 +219,7 @@ ShowInvoiceSituation=Show situation invoice UseSituationInvoices=Allow situation invoice UseSituationInvoicesCreditNote=Allow situation invoice credit note Retainedwarranty=Retained warranty +AllowedInvoiceForRetainedWarranty=Retained warranty usable on the following types of invoices RetainedwarrantyDefaultPercent=Retained warranty default percent RetainedwarrantyOnlyForSituation=Make "retained warranty" available only for situation invoices RetainedwarrantyOnlyForSituationFinal=On situation invoices the global "retained warranty" deduction is applied only on the final situation