Show ‘Expired’ for overdue quotes in list view

This commit is contained in:
Hillel Coren 2016-03-14 10:40:14 +02:00
parent 9c0eaac6b8
commit d6697171f6
2 changed files with 8 additions and 4 deletions

View File

@ -160,8 +160,8 @@ class InvoiceService extends BaseService
], ],
[ [
'invoice_status_name', 'invoice_status_name',
function ($model) { function ($model) use ($entityType) {
return $model->quote_invoice_id ? link_to("invoices/{$model->quote_invoice_id}/edit", trans('texts.converted'))->toHtml() : self::getStatusLabel($model); return $model->quote_invoice_id ? link_to("invoices/{$model->quote_invoice_id}/edit", trans('texts.converted'))->toHtml() : self::getStatusLabel($entityType, $model);
} }
] ]
]; ];
@ -237,12 +237,13 @@ class InvoiceService extends BaseService
]; ];
} }
private function getStatusLabel($model) private function getStatusLabel($entityType, $model)
{ {
// check if invoice is overdue // check if invoice is overdue
if (Utils::parseFloat($model->balance) && $model->due_date && $model->due_date != '0000-00-00') { if (Utils::parseFloat($model->balance) && $model->due_date && $model->due_date != '0000-00-00') {
if (\DateTime::createFromFormat('Y-m-d', $model->due_date) < new \DateTime("now")) { if (\DateTime::createFromFormat('Y-m-d', $model->due_date) < new \DateTime("now")) {
return "<h4><div class=\"label label-danger\">".trans('texts.overdue')."</div></h4>"; $label = $entityType == ENTITY_INVOICE ? trans('texts.overdue') : trans('texts.expired');
return "<h4><div class=\"label label-danger\">" . $label . "</div></h4>";
} }
} }

View File

@ -1057,6 +1057,9 @@ $LANG = array(
'enable_portal_password_help'=>'Allows you to set a password for each contact. If a password is set, the contact will be required to enter a password before viewing invoices.', 'enable_portal_password_help'=>'Allows you to set a password for each contact. If a password is set, the contact will be required to enter a password before viewing invoices.',
'send_portal_password'=>'Generate password automatically', 'send_portal_password'=>'Generate password automatically',
'send_portal_password_help'=>'If no password is set, one will be generated and sent with the first invoice.', 'send_portal_password_help'=>'If no password is set, one will be generated and sent with the first invoice.',
'expired' => 'Expired',
); );
return $LANG; return $LANG;