Added 'overdue' status to invoice list

This commit is contained in:
Hillel Coren 2016-02-11 21:12:50 +02:00
parent 0a2a97d89a
commit d1dd02644b
2 changed files with 13 additions and 4 deletions

View File

@ -160,7 +160,7 @@ class InvoiceService extends BaseService
[ [
'invoice_status_name', 'invoice_status_name',
function ($model) { function ($model) {
return $model->quote_invoice_id ? link_to("invoices/{$model->quote_invoice_id}/edit", trans('texts.converted')) : self::getStatusLabel($model->invoice_status_id, $model->invoice_status_name); return $model->quote_invoice_id ? link_to("invoices/{$model->quote_invoice_id}/edit", trans('texts.converted')) : self::getStatusLabel($model);
} }
] ]
]; ];
@ -236,11 +236,18 @@ class InvoiceService extends BaseService
]; ];
} }
private function getStatusLabel($statusId, $statusName) private function getStatusLabel($model)
{ {
$label = trans("texts.status_" . strtolower($statusName)); // check if invoice is overdue
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")) {
return "<h4><div class=\"label label-danger\">".trans('texts.overdue')."</div></h4>";
}
}
$label = trans("texts.status_" . strtolower($model->invoice_status_name));
$class = 'default'; $class = 'default';
switch ($statusId) { switch ($model->invoice_status_id) {
case INVOICE_STATUS_SENT: case INVOICE_STATUS_SENT:
$class = 'info'; $class = 'info';
break; break;

View File

@ -1149,4 +1149,6 @@ return array(
'trial_footer_last_day' => 'This is the last day of your free trial, :link to upgrade now.', 'trial_footer_last_day' => 'This is the last day of your free trial, :link to upgrade now.',
'trial_call_to_action' => 'Start Free Trial', 'trial_call_to_action' => 'Start Free Trial',
'trial_success' => 'Successfully enabled two week free pro plan trial', 'trial_success' => 'Successfully enabled two week free pro plan trial',
'overdue' => 'Overdue',
); );