From 23afb80c822e2dc0c57b4dfe52da576604d2e8be Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 15 Feb 2016 14:42:05 +0100 Subject: [PATCH] Can remove status recurring or not of template invoice --- .../facture/class/facture-rec.class.php | 16 ++--- htdocs/compta/facture/fiche-rec.php | 65 ++++++++++--------- htdocs/langs/en_US/bills.lang | 2 + 3 files changed, 45 insertions(+), 38 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 16dcedc3035..9fb103aa6c5 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -707,7 +707,7 @@ class FactureRec extends Facture * @param string $unit unit of frequency (d, m, y) * @return int <0 if KO, >0 if OK */ - function setFrequencyAndUnit($frequency=0,$unit='') + function setFrequencyAndUnit($frequency,$unit) { if (! $this->table_element) { @@ -715,26 +715,24 @@ class FactureRec extends Facture return -1; } - if (empty($frequency) && empty($unit)) + if (!empty($frequency) && empty($unit)) { - dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with params frequency and unit not defined",LOG_ERR); + dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with params frequency defined but unit not defined",LOG_ERR); return -2; } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - if (!empty($frequency)) $sql.= ' SET frequency = '.$frequency; + $sql.= ' SET frequency = '.($frequency?$this->db->escape($frequency):'null'); if (!empty($unit)) { - if (!empty($frequency)) $sql .= ','; - else $sql .= ' SET'; - $sql.= ' unit_frequency = "'.$this->db->escape($unit).'"'; + $sql.= ', unit_frequency = "'.$this->db->escape($unit).'"'; } $sql.= ' WHERE rowid = '.$this->id; - + dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); if ($this->db->query($sql)) { - if (!empty($frequency)) $this->frequency = $frequency; + $this->frequency = $frequency; if (!empty($unit)) $this->unit_frequency = $unit; return 1; } diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 342971556ae..5224c825003 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -705,38 +705,45 @@ else { print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency); } + else + { + print $langs->trans("NotARecurringInvoiceTemplate"); + } } print ''; - // Date when - print ''; - print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer); - print ''; - print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'datepicker'); - print ''; - print ''; - - - // Max period / Rest period - print ''; - print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer); - print ''; - if ($object->nb_gen_max > 0) print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer); - print ''; - print ''; - print ''.$langs->trans("RestPeriodNumber").''; - print ''; - print ($object->nb_gen_max-$object->nb_gen_done); - print ''; - - // Auto validate - print ''; - print $form->editfieldkey($langs->trans("InvoiceAutoValidate"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer); - print ''; - $select = 'select;0:'.$langs->trans('No').',1:'.$langs->trans('Yes'); - print $form->editfieldval($langs->trans("InvoiceAutoValidate"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer, $select); - print ''; - print ''; + //if (! empty($object->frequency)) // If no frequency defined, it is not a recurring template invoice + //{ + // Date when + print ''; + print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer); + print ''; + print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'datepicker'); + print ''; + print ''; + + + // Max period / Rest period + print ''; + print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer); + print ''; + if ($object->nb_gen_max > 0) print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer); + print ''; + print ''; + print ''.$langs->trans("RestPeriodNumber").''; + print ''; + print ($object->nb_gen_max-$object->nb_gen_done); + print ''; + + // Auto validate + print ''; + print $form->editfieldkey($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer); + print ''; + $select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated'); + print $form->editfieldval($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer, $select); + print ''; + print ''; + //} print ''; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 2b5c5e3d241..88805ece9e6 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -106,6 +106,7 @@ EnterPaymentDueToCustomer=Make payment due to customer DisabledBecauseRemainderToPayIsZero=Disabled because remaining unpaid is zero PriceBase=Price base BillStatus=Invoice status +StatusOfGeneratedInvoices=Status of generated invoices BillStatusDraft=Draft (needs to be validated) BillStatusPaid=Paid BillStatusPaidBackOrConverted=Paid or converted into discount @@ -139,6 +140,7 @@ ErrorCantCancelIfReplacementInvoiceNotValidated=Error, can't cancel an invoice t BillFrom=From BillTo=To ActionsOnBill=Actions on invoice +NotARecurringInvoiceTemplate=Not a recurring template invoice NewBill=New invoice LastBills=Last %s invoices LastCustomersBills=Last %s customers invoices