From 087fea1f24da29eca35b171397c125f5de435200 Mon Sep 17 00:00:00 2001 From: "Sang, Le Thanh" Date: Thu, 22 Jan 2015 16:31:43 +0700 Subject: [PATCH] Multiple currency support in dashboard --- app/controllers/DashboardController.php | 9 +++++---- app/views/dashboard.blade.php | 7 +++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/DashboardController.php b/app/controllers/DashboardController.php index 7e8fa5a58be7..59aa2d8e7ab3 100644 --- a/app/controllers/DashboardController.php +++ b/app/controllers/DashboardController.php @@ -19,15 +19,16 @@ class DashboardController extends \BaseController ->groupBy('accounts.id') ->first(); - $select = DB::raw('SUM(clients.paid_to_date) as value'); + $select = DB::raw('SUM(clients.paid_to_date) as value, clients.currency_id as currency_id'); - $totalIncome = DB::table('accounts') + $totalIncomes = DB::table('accounts') ->select($select) ->leftJoin('clients', 'accounts.id', '=', 'clients.account_id') ->where('accounts.id', '=', Auth::user()->account_id) ->where('clients.is_deleted', '=', false) ->groupBy('accounts.id') - ->first(); + ->groupBy('clients.currency_id') + ->get(); $activities = Activity::where('activities.account_id', '=', Auth::user()->account_id) ->orderBy('created_at', 'desc')->take(6)->get(); @@ -49,7 +50,7 @@ class DashboardController extends \BaseController ->orderBy('due_date', 'asc')->take(6)->get(); $data = [ - 'totalIncome' => Utils::formatMoney($totalIncome ? $totalIncome->value : 0, Session::get(SESSION_CURRENCY)), + 'totalIncomes' => $totalIncomes, 'billedClients' => $metrics ? $metrics->billed_clients : 0, 'invoicesSent' => $metrics ? $metrics->invoices_sent : 0, 'activeClients' => $metrics ? $metrics->active_clients : 0, diff --git a/app/views/dashboard.blade.php b/app/views/dashboard.blade.php index 2373f41e3c6c..af538c448192 100644 --- a/app/views/dashboard.blade.php +++ b/app/views/dashboard.blade.php @@ -8,7 +8,9 @@
- {{ $totalIncome }} + @foreach ($totalIncomes as $totalIncome) + {{ Utils::formatMoney($totalIncome->value, $totalIncome->currency_id); }} + @endforeach
{{ trans('texts.in_total_revenue') }} @@ -145,4 +147,5 @@
-@stop \ No newline at end of file +@stop +