/**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $reasons = Lava::DataTable();
     $reasons->addStringColumn('Reasons')->addNumberColumn('Percent')->addRow(array('Check Reviews', 5))->addRow(array('Watch Trailers', 2))->addRow(array('See Actors Other Work', 4))->addRow(array('Settle Argument', 89));
     $piechart = Lava::PieChart('IMDB')->setOptions(array('datatable' => $reasons, 'title' => 'Reasons I visit IMDB', 'is3D' => true, 'slices' => array(Lava::Slice(array('offset' => 0.2)), Lava::Slice(array('offset' => 0.25)), Lava::Slice(array('offset' => 0.3)))));
     return view('reports.birth_registration.pie_chart')->with('piechart', $piechart);
 }
 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);
 }
 private function _siteStats()
 {
     $sitesCreated = DB::table('site')->select(DB::raw('DATE(created_at) as date'), DB::raw('count(*) as count'))->whereBetween('created_at', [Carbon::now()->subWeek(1), Carbon::now()])->groupBy('date')->orderBy('date')->get('date', 'count');
     $sitesRun = DB::table('site')->select(DB::raw('DATE(created_at) as date'), DB::raw('count(*) as count'))->whereBetween('created_at', [Carbon::now()->subWeek(1), Carbon::now()])->where('finished', '1')->where('active', '0')->groupBy('date')->orderBy('date')->get('date', 'count');
     $sitesClosed = DB::table('site')->select(DB::raw('DATE(created_at) as date'), DB::raw('count(*) as count'))->whereBetween('created_at', [Carbon::now()->subWeek(1), Carbon::now()])->where('finished', '0')->where('active', '0')->groupBy('date')->orderBy('date')->get('date', 'count');
     $sitesTable = Lava::DataTable();
     $sitesTable->addDateColumn('Date')->addNumberColumn('Created')->addNumberColumn('Finished')->addNumberColumn('Closed');
     $data = [];
     foreach ($sitesCreated as $res) {
         $data[$res->date] = [];
         $data[$res->date]['created'] = $res->count;
     }
     foreach ($sitesRun as $res) {
         $data[$res->date]['run'] = $res->count;
     }
     foreach ($sitesClosed as $res) {
         $data[$res->date]['closed'] = $res->count;
     }
     foreach ($data as $date => $count) {
         if (isset($count['created'])) {
             $created = $count['created'];
         } else {
             $created = 0;
         }
         if (isset($count['run'])) {
             $run = $count['run'];
         } else {
             $run = 0;
         }
         if (isset($count['closed'])) {
             $closed = $count['closed'];
         } else {
             $closed = 0;
         }
         $sitesTable->addRow([$date, $created, $run, $closed]);
     }
     Lava::ColumnChart('Sites', $sitesTable, ['titleTextStyle' => ['color' => '#eb6b2c', 'fontSize' => 14]]);
 }