Exemplo n.º 1
0
 private function _totalISK()
 {
     $total_isk = DB::table('sheet')->select(DB::raw('DATE(created_at) as date'), DB::raw('SUM(total_isk) as sum'))->whereBetween('created_at', [Carbon::now()->subWeek(), Carbon::now()])->where('is_paid', 1)->groupBy('date')->orderBy('date')->get('date', 'sum');
     $total_payout = DB::table('sheet')->select(DB::raw('DATE(created_at) as date'), DB::raw('SUM(payout) as sum'))->whereBetween('created_at', [Carbon::now()->subWeek(), Carbon::now()])->where('is_paid', 1)->groupBy('date')->orderBy('date')->get('date', 'sum');
     $total_corp_cut = DB::table('sheet')->select(DB::raw('DATE(created_at) as date'), DB::raw('SUM(corp_cut) as sum'))->whereBetween('created_at', [Carbon::now()->subWeek(), Carbon::now()])->where('is_paid', 1)->groupBy('date')->orderBy('date')->get('date', 'sum');
     $data = [];
     foreach ($total_isk as $res) {
         $data[$res->date] = [];
         $data[$res->date]['total'] = $res->sum;
     }
     foreach ($total_payout as $res) {
         $data[$res->date]['payout'] = $res->sum;
     }
     foreach ($total_corp_cut as $res) {
         $data[$res->date]['corp'] = $res->sum;
     }
     $total_isk_data_table = Lava::DataTable()->addStringColumn('Day')->addNumberColumn('Total')->addNumberColumn('Payout')->addNumberColumn('Corp');
     foreach ($data as $date => $type) {
         $date = Carbon::parse($date)->format('M j');
         $total = isset($type['total']) ? $type['total'] : 0;
         $payout = isset($type['payout']) ? $type['payout'] : 0;
         $corp = isset($type['corp']) ? $type['corp'] : 0;
         $total_isk_data_table->addRow([$date, $total, $payout, $corp]);
     }
     Lava::LineChart('totalisk', $total_isk_data_table);
 }
Exemplo n.º 2
0
 public function index()
 {
     $orders = Order::all();
     $sales = null;
     $taxes = null;
     foreach ($orders as $order) {
         $sales = $sales + $order->total;
         $taxes = $taxes + $order->sub_total;
     }
     $taxes = $sales - $taxes;
     $temperatures = Lava::DataTable();
     $temperatures->addDateColumn('Date')->addNumberColumn('Last period')->addNumberColumn('This period')->addRow(array('2015-11-1', 4524, 3503))->addRow(array('2015-11-2', 2332, 3880))->addRow(array('2015-11-3', 4700, 2130))->addRow(array('2015-11-4', 4200, 3100))->addRow(array('2015-11-5', 4302, 3500))->addRow(array('2015-11-6', 4130, 2332))->addRow(array('2015-11-7', 4820, 3200))->addRow(array('2015-11-8', 2504, 3500))->addRow(array('2015-11-9', 4500, 3500))->addRow(array('2015-11-10', 3350, 3500))->addRow(array('2015-11-11', 3350, 3100))->addRow(array('2015-11-12', 4500, 3555))->addRow(array('2015-11-13', 4500, 3330))->addRow(array('2015-11-14', 3350, 3200))->addRow(array('2015-11-15', 4500, 3500))->addRow(array('2015-11-16', 3350, 3500))->addRow(array('2015-11-17', 4500, 4500))->addRow(array('2015-11-18', 4500, 3500));
     $linechart = Lava::LineChart('Temps')->dataTable($temperatures)->title('Sales');
     //
     ///        dd(Lava::BackgroundColor());
     $viewBag = array('permission' => \Auth::user()->permission->name, 'orders' => $orders, 'orders_active' => Order::where('trash', '=', 0)->orderBy('created_at', 'desc')->take(5)->get(), 'sales' => $sales, 'taxes' => $taxes, 'products' => Product::where('trash', '=', 0)->get(), 'products_amount' => Product::where('stock', '=', 'N')->get(), 'users' => User::where('trash', '=', 0)->get(), 'categories' => Category::where('trash', '=', 0)->get());
     return \View::make('backend.index', $viewBag);
 }