/**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     date_default_timezone_set('Asia/Jakarta');
     $abouts = array();
     $news = array();
     $memo = array();
     Config::set('registered', false);
     $articles = \App\article::select('article.*', 'users.first_name', 'users.last_name')->leftJoin('users', 'article.user', '=', 'users.id')->get();
     foreach ($articles as $article) {
         switch ($article->type) {
             case 'about':
                 $abouts[] = $article;
                 break;
             case 'news':
                 $news[] = $article;
                 break;
             case 'memo':
                 $memo[] = $article;
                 break;
         }
     }
     $kota = \App\kota::all();
     foreach ($kota as $v) {
         $dkota[$v->idkota] = $v->nmkota;
     }
     $satuan = \App\satuan::all();
     foreach ($satuan as $v) {
         $dsatuan[$v->idsatuan] = $v->namasatuan;
     }
     $cabang = \App\cabang::all();
     foreach ($cabang as $v) {
         $dcabang[$v->idcabang] = $v->nama;
     }
     $dcabang = \App\Helpers::assoc_merge([0 => '--Daftar Cabang--'], $dcabang);
     //Hitung total quote yang baru
     $quotes = \App\quote::where('status', '=', '0');
     $quotesData['all'] = $quotes->limit(3)->get();
     $quotesData['count'] = $quotes->count();
     //Hitung total SJT yang belum tiba
     $sjt = \App\berangkat::where('status', '<', '3');
     $sjtData['all'] = $sjt->limit(3)->get();
     $sjtData['count'] = $sjt->count();
     //Hitung total tagihan yang belum terbayar
     $totNotification = $quotes->count() + $sjt->count();
     $notification = ['all' => $totNotification, 'quote' => $quotesData, 'sjt' => $sjtData];
     $data = array('abouts' => $abouts, 'news' => $news, 'memo' => $memo, 'kota' => $dkota, 'satuan' => $dsatuan, 'cabang' => $dcabang, 'nquotes' => $quotes, 'notification' => $notification);
     return View::share($data);
 }
 public function penagihan()
 {
     $title = 'Laporan Tagihan Pengiriman';
     $arrdata = Request::all();
     $tagihan = \App\resi::select('resi.status', 'resi.noresi', 'resi.tglresi', 'resi.tagihan', 'resi.totalbiaya', 'resi.dp', 'resi.sisa', 'k.nama AS ppengirim', 'k.cp AS cppengirim', 't.nama AS ppenerima', 't.cp AS cppenerima');
     $tagihan->leftJoin('konsumen AS k', 'k.idkonsumen', '=', 'resi.idkonsumen');
     $tagihan->leftJoin('konsumen AS t', 't.idkonsumen', '=', 'resi.idpenerima');
     $cab = 0;
     /*		if($arrdata){
     			$title .= "<div class='form-inline'>";
     			$subtitle = [];
     			if(Request::get('cabang')){
     				$tagihan->leftJoin('cabang','cabang.idcabang','=','resi.idcab');
     				$tagihan->where('resi.idcab','=',Request::get('cabang'));
     				$cab = \App\cabang::where(	'idcabang','=',Request::get('cabang'))->first();
     				$subtitle[] = \App\Helpers::awsomeFilterLabel('Cabang',$cab->nama);
     			}
     			if(Request::get('tanggal')){
     				$tgl = explode("-",trim(Request::get('tanggal')));
     				$tgawal = $tgl[0];
     				$tgakhir = $tgl[1];
     				$tagihan->where('tglresi','>=',$tgawal);
     				$tagihan->where('tglresi','<=',$tgakhir);
     				$subtitle[] = \App\Helpers::awsomeFilterLabel('Tanggal',date_format(date_create($tgawal),'d M Y').' - '.date_format(date_create($tgakhir),'d M Y'));
     			}
     			if(Request::get('tagihan')){
     				$tagihan->where('tagihan','=',Request::get('tagihan'));
     				$subtitle[] = \App\Helpers::awsomeFilterLabel('Ditagihkan ke',Request::get('tagihan'));
     			}
     
     			$count = count($subtitle);
     			$i=0;
     			do{
     				$title .= $subtitle[$i];
     				$i++;
     				if($i<$count){$title .= ' ';}				
     			}while($i<$count);
     			$title .= '</div>';
     		}*/
     $tagihan->where('crbyr', 'Non Tunai');
     $dtcabang = \App\cabang::all();
     foreach ($dtcabang as $c) {
         $cabang[$c->idcabang] = $c->nama;
     }
     //dd($tagihan->get());
     return view('laporan.penagihan')->with('title', $title)->with('tagihans', $tagihan->get())->with('cabang', $cabang);
 }
 public function getCabang()
 {
     $cabang = \App\cabang::all();
     return $cabang;
 }