diff --git a/app/Ninja/Reports/ActivityReport.php b/app/Ninja/Reports/ActivityReport.php index 70c6145db27d..3e843b25b3f9 100644 --- a/app/Ninja/Reports/ActivityReport.php +++ b/app/Ninja/Reports/ActivityReport.php @@ -23,7 +23,8 @@ class ActivityReport extends AbstractReport $activities = Activity::scope() ->with('client.contacts', 'user', 'invoice', 'payment', 'credit', 'task', 'expense', 'account') - ->whereRaw("DATE(created_at) >= \"{$startDate}\" and DATE(created_at) <= \"$endDate\""); + ->whereRaw("DATE(created_at) >= \"{$startDate}\" and DATE(created_at) <= \"$endDate\"") + ->orderBy('id', 'desc'); foreach ($activities->get() as $activity) { $client = $activity->client; diff --git a/app/Ninja/Reports/AgingReport.php b/app/Ninja/Reports/AgingReport.php index a7d1213d9c96..78799255090b 100644 --- a/app/Ninja/Reports/AgingReport.php +++ b/app/Ninja/Reports/AgingReport.php @@ -22,6 +22,7 @@ class AgingReport extends AbstractReport $account = Auth::user()->account; $clients = Client::scope() + ->orderBy('name') ->withArchived() ->with('contacts') ->with(['invoices' => function ($query) { diff --git a/app/Ninja/Reports/ClientReport.php b/app/Ninja/Reports/ClientReport.php index b0f12f63ea90..befde9b3bc67 100644 --- a/app/Ninja/Reports/ClientReport.php +++ b/app/Ninja/Reports/ClientReport.php @@ -19,6 +19,7 @@ class ClientReport extends AbstractReport $account = Auth::user()->account; $clients = Client::scope() + ->orderBy('name') ->withArchived() ->with('contacts') ->with(['invoices' => function ($query) { diff --git a/app/Ninja/Reports/ExpenseReport.php b/app/Ninja/Reports/ExpenseReport.php index 880845f07555..10a4220e1ce8 100644 --- a/app/Ninja/Reports/ExpenseReport.php +++ b/app/Ninja/Reports/ExpenseReport.php @@ -21,6 +21,7 @@ class ExpenseReport extends AbstractReport $account = Auth::user()->account; $expenses = Expense::scope() + ->orderBy('expense_date', 'desc') ->withArchived() ->with('client.contacts', 'vendor') ->where('expense_date', '>=', $this->startDate) diff --git a/app/Ninja/Reports/InvoiceReport.php b/app/Ninja/Reports/InvoiceReport.php index e2e90a28323f..b9cb66d0f560 100644 --- a/app/Ninja/Reports/InvoiceReport.php +++ b/app/Ninja/Reports/InvoiceReport.php @@ -24,6 +24,7 @@ class InvoiceReport extends AbstractReport $status = $this->options['invoice_status']; $clients = Client::scope() + ->orderBy('name') ->withArchived() ->with('contacts') ->with(['invoices' => function ($query) use ($status) { diff --git a/app/Ninja/Reports/PaymentReport.php b/app/Ninja/Reports/PaymentReport.php index 5df24a1d1659..d448646ab989 100644 --- a/app/Ninja/Reports/PaymentReport.php +++ b/app/Ninja/Reports/PaymentReport.php @@ -22,6 +22,7 @@ class PaymentReport extends AbstractReport $account = Auth::user()->account; $payments = Payment::scope() + ->orderBy('payment_date', 'desc') ->withArchived() ->excludeFailed() ->whereHas('client', function ($query) { diff --git a/app/Ninja/Reports/ProductReport.php b/app/Ninja/Reports/ProductReport.php index 19bb5c1fcc81..a0124a825b48 100644 --- a/app/Ninja/Reports/ProductReport.php +++ b/app/Ninja/Reports/ProductReport.php @@ -24,6 +24,7 @@ class ProductReport extends AbstractReport $status = $this->options['invoice_status']; $clients = Client::scope() + ->orderBy('name') ->withArchived() ->with('contacts') ->with(['invoices' => function ($query) use ($status) { diff --git a/app/Ninja/Reports/ProfitAndLossReport.php b/app/Ninja/Reports/ProfitAndLossReport.php index 919c57153792..4cd0a47c9bfd 100644 --- a/app/Ninja/Reports/ProfitAndLossReport.php +++ b/app/Ninja/Reports/ProfitAndLossReport.php @@ -21,6 +21,7 @@ class ProfitAndLossReport extends AbstractReport $account = Auth::user()->account; $payments = Payment::scope() + ->orderBy('payment_date', 'desc') ->with('client.contacts') ->withArchived() ->excludeFailed() @@ -43,6 +44,7 @@ class ProfitAndLossReport extends AbstractReport } $expenses = Expense::scope() + ->orderBy('expense_date', 'desc') ->with('client.contacts') ->withArchived() ->where('expense_date', '>=', $this->startDate) diff --git a/app/Ninja/Reports/QuoteReport.php b/app/Ninja/Reports/QuoteReport.php index f69679ab8ef8..e53f6e0fb8fe 100644 --- a/app/Ninja/Reports/QuoteReport.php +++ b/app/Ninja/Reports/QuoteReport.php @@ -21,6 +21,7 @@ class QuoteReport extends AbstractReport $status = $this->options['invoice_status']; $clients = Client::scope() + ->orderBy('name') ->withArchived() ->with('contacts') ->with(['invoices' => function ($query) use ($status) { @@ -43,9 +44,9 @@ class QuoteReport extends AbstractReport $account->formatMoney($invoice->amount, $client), $invoice->present()->status(), ]; - } - $this->addToTotals($client->currency_id, 'amount', $invoice->amount); + $this->addToTotals($client->currency_id, 'amount', $invoice->amount); + } } } } diff --git a/app/Ninja/Reports/TaskReport.php b/app/Ninja/Reports/TaskReport.php index 803f799a2a6f..29d83e1486f3 100644 --- a/app/Ninja/Reports/TaskReport.php +++ b/app/Ninja/Reports/TaskReport.php @@ -18,6 +18,7 @@ class TaskReport extends AbstractReport public function run() { $tasks = Task::scope() + ->orderBy('created_at', 'desc') ->with('client.contacts') ->withArchived() ->dateRange($this->startDate, $this->endDate); diff --git a/app/Ninja/Reports/TaxRateReport.php b/app/Ninja/Reports/TaxRateReport.php index 4930393412d6..c964a7f4dcd6 100644 --- a/app/Ninja/Reports/TaxRateReport.php +++ b/app/Ninja/Reports/TaxRateReport.php @@ -20,6 +20,7 @@ class TaxRateReport extends AbstractReport $account = Auth::user()->account; $clients = Client::scope() + ->orderBy('name') ->withArchived() ->with('contacts') ->with(['invoices' => function ($query) { diff --git a/resources/views/reports/chart_builder.blade.php b/resources/views/reports/chart_builder.blade.php index c8bb069f8994..f519a9bb6740 100644 --- a/resources/views/reports/chart_builder.blade.php +++ b/resources/views/reports/chart_builder.blade.php @@ -290,6 +290,9 @@ $(function(){ $(".tablesorter-data").tablesorter({ + @if (! request()->group_when_sorted) + sortList: [[0,0]], + @endif theme: 'bootstrap', widgets: ['zebra', 'uitheme', 'filter'{!! request()->group_when_sorted ? ", 'group'" : "" !!}, 'columnSelector'], headerTemplate : '{content} {icon}',