Can remove status recurring or not of template invoice

This commit is contained in:
Laurent Destailleur
2016-02-15 14:42:05 +01:00
parent f1f5c48337
commit 23afb80c82
3 changed files with 45 additions and 38 deletions

View File

@@ -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;
}

View File

@@ -705,38 +705,45 @@ else
{
print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency);
}
else
{
print $langs->trans("NotARecurringInvoiceTemplate");
}
}
print '</td></tr>';
// Date when
print '<tr><td>';
print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer);
print '</td><td colspan="5">';
print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'datepicker');
print '</td>';
print '</tr>';
// Max period / Rest period
print '<tr><td>';
print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer);
print '</td><td colspan="5">';
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 '</td>';
print '</tr>';
print '<tr><td>'.$langs->trans("RestPeriodNumber").'</td>';
print '<td>';
print ($object->nb_gen_max-$object->nb_gen_done);
print '</td>';
// Auto validate
print '<tr><td>';
print $form->editfieldkey($langs->trans("InvoiceAutoValidate"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer);
print '</td><td colspan="5">';
$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 '</td>';
print '</tr>';
//if (! empty($object->frequency)) // If no frequency defined, it is not a recurring template invoice
//{
// Date when
print '<tr><td>';
print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer);
print '</td><td colspan="5">';
print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'datepicker');
print '</td>';
print '</tr>';
// Max period / Rest period
print '<tr><td>';
print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer);
print '</td><td colspan="5">';
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 '</td>';
print '</tr>';
print '<tr><td>'.$langs->trans("RestPeriodNumber").'</td>';
print '<td>';
print ($object->nb_gen_max-$object->nb_gen_done);
print '</td>';
// Auto validate
print '<tr><td>';
print $form->editfieldkey($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer);
print '</td><td colspan="5">';
$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 '</td>';
print '</tr>';
//}
print '</table>';

View File

@@ -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