Esempio n. 1
0
 public function index()
 {
     $widget = ['baru' => Penjualan::where('status', 1)->whereBetween('tgl_order', [Carbon::now()->startOfMonth(), Carbon::today()])->count(), 'poBaru' => Penjualan::whereBetween('tgl_order', [Carbon::now()->startOfMonth(), Carbon::today()])->count(), 'rls' => Penjualan::where('status', '!=', 1)->whereBetween('tgl_order', [Carbon::now()->startOfMonth(), Carbon::today()])->count(), 'orders' => Order::where('status', 1)->count(), 'agen' => Customer::where('tipe', 2)->orWhere('tipe', 3)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year)->count(), 'mitra' => Customer::where('tipe', 1)->orWhere('tipe', 6)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year)->count(), 'biasa' => Customer::where('tipe', 4)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year)->count(), 'agenLastYear' => Customer::where('tipe', 2)->orWhere('tipe', 3)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year - 1)->count(), 'mitraLastYear' => Customer::where('tipe', 1)->orWhere('tipe', 6)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year - 1)->count(), 'biasaLastYear' => Customer::where('tipe', 4)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year - 1)->count()];
     $box = ['penjualans' => Penjualan::orderBy('tgl_order', 'DESC')->take(7)->get(), 'barangs' => Barang::orderBy('id', 'DESC')->take(4)->get(), 'customers' => Penjualan::with('customer')->orderBy('tgl_order', 'DESC')->take(8)->get(), 'followups' => Followup::orderBy('created_at', 'desc')->take(6)->get(), 'bahan' => DB::table('bahan')->where('stok', 0)->take(5)->get(), 'menipis' => DB::table('bahan')->where('stok', 0)->count()];
     // CHART =========================================================================================
     $laporanTahunan = Penjualan::select(DB::raw('MONTH(tgl_transfer) as month, count(`id`) as count, sum(`nominal`) as nominal'))->where('status', '!=', 1)->where(DB::raw('YEAR(tgl_transfer)'), Carbon::now()->year)->groupBy(DB::raw('YEAR(tgl_transfer)'))->groupBy(DB::raw('MONTH(tgl_transfer)'))->orderBy('tgl_transfer', 'asc')->get();
     $total = ['thisMonth' => Penjualan::where('status', '!=', 1)->where('tgl_transfer', '>=', Carbon::now()->startOfMonth())->sum('nominal'), 'thisMonthLastYear' => Penjualan::where(DB::raw('YEAR(tgl_transfer)'), Carbon::now()->year - 1)->where(DB::raw('MONTH(tgl_transfer)'), Carbon::now()->month)->where('status', '!=', 1)->sum('nominal'), 'lastYear' => Penjualan::where(DB::raw('YEAR(tgl_transfer)'), Carbon::now()->year - 1)->where('status', '!=', 1)->sum('nominal'), 'thisYear' => Penjualan::where(DB::raw('YEAR(tgl_transfer)'), Carbon::now()->year)->where('status', '!=', 1)->sum('nominal')];
     // END OF CHART =========================================================================================
     // dd($total['thisMonth']);
     return View::make('admin', compact('box', 'widget', 'total', 'laporanTahunan'));
 }
 /**
  * Display a listing of followups
  *
  * @return Response
  */
 public function index()
 {
     $followups = Followup::orderBy('created_at', 'desc')->get();
     return View::make('admin.followups.index', compact('followups'));
 }