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) * @param string $unit unit of frequency (d, m, y)
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function setFrequencyAndUnit($frequency=0,$unit='') function setFrequencyAndUnit($frequency,$unit)
{ {
if (! $this->table_element) if (! $this->table_element)
{ {
@ -715,26 +715,24 @@ class FactureRec extends Facture
return -1; 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; return -2;
} }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $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($unit))
{ {
if (!empty($frequency)) $sql .= ','; $sql.= ', unit_frequency = "'.$this->db->escape($unit).'"';
else $sql .= ' SET';
$sql.= ' unit_frequency = "'.$this->db->escape($unit).'"';
} }
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
if (!empty($frequency)) $this->frequency = $frequency; $this->frequency = $frequency;
if (!empty($unit)) $this->unit_frequency = $unit; if (!empty($unit)) $this->unit_frequency = $unit;
return 1; return 1;
} }

View File

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

View File

@ -106,6 +106,7 @@ EnterPaymentDueToCustomer=Make payment due to customer
DisabledBecauseRemainderToPayIsZero=Disabled because remaining unpaid is zero DisabledBecauseRemainderToPayIsZero=Disabled because remaining unpaid is zero
PriceBase=Price base PriceBase=Price base
BillStatus=Invoice status BillStatus=Invoice status
StatusOfGeneratedInvoices=Status of generated invoices
BillStatusDraft=Draft (needs to be validated) BillStatusDraft=Draft (needs to be validated)
BillStatusPaid=Paid BillStatusPaid=Paid
BillStatusPaidBackOrConverted=Paid or converted into discount BillStatusPaidBackOrConverted=Paid or converted into discount
@ -139,6 +140,7 @@ ErrorCantCancelIfReplacementInvoiceNotValidated=Error, can't cancel an invoice t
BillFrom=From BillFrom=From
BillTo=To BillTo=To
ActionsOnBill=Actions on invoice ActionsOnBill=Actions on invoice
NotARecurringInvoiceTemplate=Not a recurring template invoice
NewBill=New invoice NewBill=New invoice
LastBills=Last %s invoices LastBills=Last %s invoices
LastCustomersBills=Last %s customers invoices LastCustomersBills=Last %s customers invoices