1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Improve date sorting in tables

This commit is contained in:
Hillel Coren 2017-03-28 12:40:53 +03:00
parent 9d60b1468c
commit c7fd125f5b
11 changed files with 31 additions and 24 deletions

View File

@ -41,10 +41,10 @@ class CreditDatatable extends EntityDatatable
'credit_date',
function ($model) {
if (! Auth::user()->can('viewByOwner', [ENTITY_CREDIT, $model->user_id])) {
return Utils::fromSqlDate($model->credit_date);
return Utils::fromSqlDate($model->credit_date_sql);
}
return link_to("credits/{$model->public_id}/edit", Utils::fromSqlDate($model->credit_date))->toHtml();
return link_to("credits/{$model->public_id}/edit", Utils::fromSqlDate($model->credit_date_sql))->toHtml();
},
],
[

View File

@ -49,10 +49,10 @@ class ExpenseDatatable extends EntityDatatable
'expense_date',
function ($model) {
if (! Auth::user()->can('viewByOwner', [ENTITY_EXPENSE, $model->user_id])) {
return Utils::fromSqlDate($model->expense_date);
return Utils::fromSqlDate($model->expense_date_sql);
}
return link_to("expenses/{$model->public_id}/edit", Utils::fromSqlDate($model->expense_date))->toHtml();
return link_to("expenses/{$model->public_id}/edit", Utils::fromSqlDate($model->expense_date_sql))->toHtml();
},
],
[

View File

@ -41,7 +41,7 @@ class InvoiceDatatable extends EntityDatatable
[
'date',
function ($model) {
return Utils::fromSqlDate($model->date);
return Utils::fromSqlDate($model->invoice_date);
},
],
[
@ -65,7 +65,7 @@ class InvoiceDatatable extends EntityDatatable
[
$entityType == ENTITY_INVOICE ? 'due_date' : 'valid_until',
function ($model) {
return Utils::fromSqlDate($model->due_date);
return Utils::fromSqlDate($model->due_date_sql);
},
],
[
@ -173,7 +173,7 @@ class InvoiceDatatable extends EntityDatatable
private function getStatusLabel($model)
{
$class = Invoice::calcStatusClass($model->invoice_status_id, $model->balance, $model->due_date, $model->is_recurring);
$class = Invoice::calcStatusClass($model->invoice_status_id, $model->balance, $model->due_date_sql, $model->is_recurring);
$label = Invoice::calcStatusLabel($model->invoice_status_name, $class, $this->entityType, $model->quote_invoice_id);
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";

View File

@ -92,7 +92,7 @@ class PaymentDatatable extends EntityDatatable
},
],
[
'payment_date',
'date',
function ($model) {
if ($model->is_deleted) {
return Utils::dateToString($model->payment_date);

View File

@ -33,19 +33,19 @@ class RecurringInvoiceDatatable extends EntityDatatable
[
'start_date',
function ($model) {
return Utils::fromSqlDate($model->start_date);
return Utils::fromSqlDate($model->start_date_sql);
},
],
[
'last_sent',
function ($model) {
return Utils::fromSqlDate($model->last_sent_date);
return Utils::fromSqlDate($model->last_sent_date_sql);
},
],
[
'end_date',
function ($model) {
return Utils::fromSqlDate($model->end_date);
return Utils::fromSqlDate($model->end_date_sql);
},
],
[
@ -65,10 +65,10 @@ class RecurringInvoiceDatatable extends EntityDatatable
private function getStatusLabel($model)
{
$class = Invoice::calcStatusClass($model->invoice_status_id, $model->balance, $model->due_date, $model->is_recurring);
$class = Invoice::calcStatusClass($model->invoice_status_id, $model->balance, $model->due_date_sql, $model->is_recurring);
$label = Invoice::calcStatusLabel($model->invoice_status_name, $class, $this->entityType, $model->quote_invoice_id);
if ($model->invoice_status_id == INVOICE_STATUS_SENT && (! $model->last_sent_date || $model->last_sent_date == '0000-00-00')) {
if ($model->invoice_status_id == INVOICE_STATUS_SENT && (! $model->last_sent_date_sql || $model->last_sent_date_sql == '0000-00-00')) {
$label = trans('texts.pending');
}

View File

@ -39,7 +39,7 @@ class VendorDatatable extends EntityDatatable
},
],
[
'date',
'client_created_at',
function ($model) {
return Utils::timestampToDateString(strtotime($model->created_at));
},

View File

@ -32,7 +32,8 @@ class CreditRepository extends BaseRepository
'clients.user_id as client_user_id',
'credits.amount',
'credits.balance',
'credits.credit_date',
'credits.credit_date as credit_date_sql',
DB::raw("CONCAT(credits.credit_date, credits.created_at) as credit_date"),
'contacts.first_name',
'contacts.last_name',
'contacts.email',

View File

@ -66,7 +66,8 @@ class ExpenseRepository extends BaseRepository
'expenses.amount',
'expenses.deleted_at',
'expenses.exchange_rate',
'expenses.expense_date',
'expenses.expense_date as expense_date_sql',
DB::raw("CONCAT(expenses.expense_date, expenses.created_at) as expense_date"),
'expenses.id',
'expenses.is_deleted',
'expenses.private_notes',

View File

@ -68,9 +68,11 @@ class InvoiceRepository extends BaseRepository
'invoices.public_id',
'invoices.amount',
'invoices.balance',
'invoices.invoice_date as date',
'invoices.due_date',
'invoices.due_date as valid_until',
'invoices.invoice_date',
'invoices.due_date as due_date_sql',
DB::raw("CONCAT(invoices.invoice_date, invoices.created_at) as date"),
DB::raw("CONCAT(invoices.due_date, invoices.created_at) as due_date"),
DB::raw("CONCAT(invoices.due_date, invoices.created_at) as valid_until"),
'invoice_statuses.name as status',
'invoice_statuses.name as invoice_status_name',
'contacts.first_name',
@ -153,10 +155,12 @@ class InvoiceRepository extends BaseRepository
'invoices.public_id',
'invoices.amount',
'frequencies.name as frequency',
'invoices.start_date',
'invoices.end_date',
'invoices.last_sent_date',
'invoices.last_sent_date as last_sent',
'invoices.start_date as start_date_sql',
'invoices.end_date as end_date_sql',
'invoices.last_sent_date as last_sent_date_sql',
DB::raw("CONCAT(invoices.start_date, invoices.created_at) as start_date"),
DB::raw("CONCAT(invoices.end_date, invoices.created_at) as end_date"),
DB::raw("CONCAT(invoices.last_sent_date, invoices.created_at) as last_sent"),
'contacts.first_name',
'contacts.last_name',
'contacts.email',
@ -167,6 +171,7 @@ class InvoiceRepository extends BaseRepository
'invoices.invoice_status_id',
'invoices.balance',
'invoices.due_date',
'invoices.due_date as due_date_sql',
'invoices.is_recurring',
'invoices.quote_invoice_id'
);

View File

@ -38,6 +38,7 @@ class PaymentRepository extends BaseRepository
'clients.public_id as client_public_id',
'clients.user_id as client_user_id',
'payments.amount',
DB::raw("CONCAT(payments.payment_date, payments.created_at) as date"),
'payments.payment_date',
'payments.payment_status_id',
'payments.payment_type_id',

View File

@ -39,7 +39,6 @@ class VendorRepository extends BaseRepository
'vendor_contacts.first_name',
'vendor_contacts.last_name',
'vendors.created_at',
'vendors.created_at as date',
'vendors.work_phone',
'vendors.city',
'vendor_contacts.email',