middleware('auth'); } /** * Show the application dashboard. * * @return \Illuminate\Contracts\Support\Renderable */ public function notislelong() { $user = Auth::user(); $lelongid = CawanganLelong::join('lelong','cawangan_lelong.lelong_id','=','lelong.id') ->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id') ->where('cawangan.caw_code','=',$user->kodcaw) ->where('lelong.sts_lelong','=', 0) ->get(); // dd($lelongid); foreach($lelongid as $index1=>$bil){ $listsag = LelongBid::where('lelong_id', $bil['lelong_id']) ->where('kodcaw','=',$user->kodcaw) ->get(); $lelongid[$index1]['bilangan'] = sizeof($listsag); // dd(sizeof($listsag)); } return view('jananotis.notislelong',compact('lelongid')); } public function senarainotis($lelong_id){ $user = Auth::user(); $bayaran=0; $arraydetails = []; $caw = Cawangan::where('caw_code','=',$user->kodcaw) ->first(); $lelong_id = $lelong_id; $marhun = LelongBid::join('cawangan', 'lelongbid.caw_id', '=', 'cawangan.id') ->where('lelong_id','=',$lelong_id) ->where('lelongbid.kodcaw','=',$user->kodcaw); $arraynorujukan = $marhun->pluck('norujukan')->toArray(); $datalelong = $marhun->get(); $marhuns = Gadai::on($datalelong[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan) ->select('nokp') ->groupBy('nokp') ->get(); // dd($marhuns); $arraysag = []; foreach($marhuns as $index1=>$cal){ $customer = Customer::where('kpbaru','=',$cal['nokp']) ->orWhere('kplama','=',$cal['nokp']) ->first(); $listsag = Gadai::on($datalelong[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan) ->where('nokp','=',$cal['nokp']) ->get(); // dd($listgadai); foreach($listsag as $index=>$listing){ $bayaran = $listing['hargajualan'] - $listing['bakihargajualan']; // dd($bayaran); $listsag[$index]['bayaran'] = $bayaran; } $marhuns[$index1]['nama'] = $customer; $marhuns[$index1]['listsag'] = $listsag; } return view('jananotis.senarainotis',compact('marhuns','lelong_id','bayaran','listsag')); } public function senarainotis2($lelong_id){ $user = Auth::user(); $lelong = Lelong::find($lelong_id); // dd($lelong); $caw = Cawangan::with(["lelongBid" => function($q) use ($lelong_id){ $q->where('lelong_id', '=', $lelong_id)->select('id','caw_id','kodcaw','norujukan','hargaasas','pinjaman','bakiupah'); }]) ->where('caw_code','=',$user->kodcaw)->first(); $lelongbid_data_pluck_norujukan = $caw->lelongBid->pluck('norujukan')->toArray(); $lelongbid_keyby_norujukan = $caw->lelongBid->keyBy('norujukan'); // dd($lelongbid_keyby_norujukan); $gadai_all = Gadai::on($caw->caw_code)->whereIn('norujukan', $lelongbid_data_pluck_norujukan) ->select('nokp','tempoh','norujukan','bakipjm','bakiupah','hargajualan','bakihargajualan') ->orderBy('nokp','ASC') ->get(); $gadai_all_pluck_nokp = $gadai_all->pluck('nokp')->unique(); $customers = Customer::whereIn('kpbaru', $gadai_all_pluck_nokp) ->orWhereIn('kplama', $gadai_all_pluck_nokp) ->select('kpbaru', 'kplama','alamat1','alamat2','alamat3','telefon') ->get(); // dd($customers->toArray()); $customers_keyBy_noKp = $customers->keyBy(function ($item) { if ($item->kpbaru != '') { return $item->kpbaru; } else if ($item->kplama != '') { return $item->kplama; } }); $gadai_all_groupby_nokp = $gadai_all->groupBy('nokp'); foreach($customers as $index=>$customer){ if($customer->kpbaru != ''){ $customers[$index]['nokp'] = $customer->kpbaru; } elseif($customer->kplama != ''){ $customers[$index]['nokp'] = $customer->kplama; } if($gadai_all_groupby_nokp[$customer->nokp]){ $customers[$index]['gadai'] = $gadai_all_groupby_nokp[$customer->nokp]; } foreach($customer['gadai'] as $index2=>$datagadai){ if($lelongbid_keyby_norujukan[$datagadai->norujukan]){ // $customer['gadai'][$index2]['lelongbid'] = $lelongbid_keyby_norujukan[$datagadai->norujukan]; $lelongbid_true = $lelongbid_keyby_norujukan[$datagadai->norujukan]; $ktlhbyr = $datagadai->hargajualan - $datagadai->bakihargajualan; $sumcajlelong = $lelongbid_true->hargaasas * ($lelong->cajlelong / 100); $cajlelongnew = round($sumcajlelong, 1, 1); $totalbaki = $lelongbid_true->hargaasas - $lelongbid_true->pinjaman - $lelongbid_true->bakiupah - $cajlelongnew; $customer['gadai'][$index2]['bakilelong'] = number_format($totalbaki, 2, '.', ','); $customer['gadai'][$index2]['ktlhbyr'] = number_format($ktlhbyr, 2, '.', ','); } } // dd($customer); } return view('jananotis.senarainotis2',compact('customers','lelong_id')); } public function jananotis($lelong_id){ $user = Auth::user(); $caw = Cawangan::where('caw_code','=',$user->kodcaw) ->first(); $lelong_id = $lelong_id; $current = Carbon::now(); $current = new Carbon(); $tarikh_cetak = $current->toDateString(); $marhun = LelongBid::join('cawangan', 'lelongbid.caw_id', '=', 'cawangan.id') ->where('lelong_id','=',$lelong_id) ->where('lelongbid.kodcaw','=',$user->kodcaw); $arraynorujukan = $marhun->pluck('norujukan')->toArray(); $datalelong = $marhun->get(); $marhuns = Gadai::on($datalelong[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan) ->select('nokp','norujukan') ->orderBy('nokp', 'asc') ->get(); // dd($marhuns); $arraysag = []; foreach($marhuns as $index1=>$cal){ $customer = Customer::where('kpbaru','=',$cal['nokp']) ->orWhere('kplama','=',$cal['nokp']) ->join('poskod','customer.poskod','=','poskod.poskod') ->join('daerah','poskod.koddaerah','=','daerah.koddaerah') ->join('negeri','poskod.kodnegeri','=','negeri.kodnegeri') ->first(); $listsag = Gadai::on($datalelong[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan) ->where('nokp','=',$cal['nokp']) ->get(); // dd($listsag); foreach($listsag as $index=>$listing) { $bayaran = $listing['hargajualan'] - $listing['bakihargajualan']; } $marhuns[$index1]['nama'] = ($customer) ? $customer : dd($cal['nokp']); $marhuns[$index1]['listsag'] = $listsag; } $lelongid = CawanganLelong::join('lelong','cawangan_lelong.lelong_id','=','lelong.id') ->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id') ->where('cawangan.caw_code','=',$user->kodcaw) ->where('cawangan_lelong.lelong_id', $lelong_id) ->get(); $pdf = PDF::loadView('pdf.jananotis',compact('marhuns','lelong_id','lelongid','caw','tarikh_cetak','customer','listsag')) ->setPaper('a4', 'potrait'); return $pdf->download('Penjanaan Notis Fasa 1:Batch Lelong '.$lelong_id.'.pdf'); } public function jananotis2($lelong_id) { // focus only on variable: $marhuns, $lelongid, $caw, $tarikh_cetak // variable not use: $lelong_id, $customer, $listsag $user = Auth::user(); $caw = Cawangan::where('caw_code', '=', $user->kodcaw)->first(); $currentdate = Carbon::now(); $tarikh_cetak = $currentdate->toDateString(); $lelongid = Lelong::find($lelong_id); $arraynorujukan = LelongBid::where('lelong_id', $lelong_id)->where('kodcaw', $caw->caw_code)->pluck('norujukan'); $marhuns = Gadai::on($caw->caw_code)->whereIn('norujukan', $arraynorujukan)->select('nokp', 'norujukan')->orderBy('nokp', 'asc')->get(); $marhuns_pluck_nokp = $marhuns->pluck('nokp'); $customers = Customer::whereIn('kpbaru', $marhuns_pluck_nokp) ->orWhereIn('kplama', $marhuns_pluck_nokp) ->join('poskod', 'customer.poskod', '=', 'poskod.poskod') ->join('daerah', 'poskod.koddaerah', '=', 'daerah.koddaerah') ->join('negeri', 'poskod.kodnegeri', '=', 'negeri.kodnegeri') ->get(); $customers_keyBy_noKp = $customers->keyBy(function ($item) { if ($item->kpbaru != '') { return $item->kpbaru; } else if ($item->kplama != '') { return $item->kplama; } }); foreach ($marhuns as $index => $marhun) { if ($customers_keyBy_noKp[$marhun->nokp]) { $marhuns[$index]['nama'] = $customers_keyBy_noKp[$marhun->nokp]; } } $pdf = PDF::loadView('pdf.jananotis', compact('marhuns', 'lelongid', 'caw', 'tarikh_cetak')) ->setPaper('a4', 'potrait'); return $pdf->download('Penjanaan Notis Fasa 1:Batch Lelong ' . $lelong_id . '.pdf'); } public function listnotis(Request $request){ $lelong_id = $request->lelong_id; $user = Auth::user(); $caw = Cawangan::where('caw_code','=',$user->kodcaw) ->first(); $bayaran=0; $arraydetails = []; $caw = Cawangan::where('caw_code','=',$user->kodcaw) ->first(); $lelong_id = $lelong_id; $marhun = LelongBid::join('cawangan', 'lelongbid.caw_id', '=', 'cawangan.id') ->where('lelong_id','=',$lelong_id) ->where('lelongbid.kodcaw','=',$user->kodcaw) ->orderBy('norujukan'); $arraynorujukan = $marhun->pluck('norujukan')->toArray(); $datalelong = $marhun->get(); $marhuns = Gadai::on($datalelong[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan) ->select('nokp') ->groupBy('nokp') ->get(); // dd($marhuns); $arraysag = []; foreach($marhuns as $index1=>$cal){ $customer = Customer::where('kpbaru','=',$cal['nokp']) ->orWhere('kplama','=',$cal['nokp']) ->get(); $listsag = Gadai::on($datalelong[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan) ->where('nokp','=',$cal['nokp']) ->get(); // dd($listgadai); foreach($listsag as $index=>$listing){ $bayaran = $listing['hargajualan'] - $listing['bakihargajualan']; } $marhuns[$index1]['nama'] = $customer; $marhuns[$index1]['listsag'] = $listsag; // dd($marhuns[$index1]['nama']); } $listsaglelong = Gadai::on($datalelong[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan) ->get(); foreach($listsaglelong as $index2=>$sag){ $nokp = Customer::where('kpbaru','=',$sag['nokp']) ->orWhere('kplama','=',$sag['nokp']) ->first(); $listsaglelong[$index2]['nama'] = $nokp; } if($request->type == 'excel') { return view('excel.listnotis_excel',compact('marhuns','lelong_id','bayaran','listsag','caw')); } elseif($request->type == 'excelbysag') { return view('excel.listnotis_excelbysag',compact('listsaglelong','lelong_id','bayaran','listsag','caw')); } else { $pdf = PDF::loadView('pdf.listnotis',compact('marhuns','lelong_id','bayaran','listsag','caw')) ->setPaper('a4', 'landscape'); return $pdf->download('Senarai Notis.pdf'); } } Public function listnotis2(Request $request){ $user = Auth::user(); $lelong_id = $request->lelong_id; $lelong = Lelong::find($lelong_id); $caw = Cawangan::with(["lelongBid" => function($q) use ($lelong_id){ $q->where('lelong_id', '=', $lelong_id)->select('id','caw_id','kodcaw','norujukan','hargaasas','pinjaman','bakiupah'); }]) ->where('caw_code','=',$user->kodcaw)->first(); $lelongbid_data_pluck_norujukan = $caw->lelongBid->pluck('norujukan')->toArray(); $lelongbid_keyby_norujukan = $caw->lelongBid->keyBy('norujukan'); // dd($lelongbid_keyby_norujukan); $gadai_all = Gadai::on($caw->caw_code)->whereIn('norujukan', $lelongbid_data_pluck_norujukan) ->select('nokp','tempoh','norujukan','bakipjm','bakiupah','hargajualan','bakihargajualan') ->orderBy('norujukan','ASC') ->get(); // dd($gadai_all); $gadai_all_pluck_nokp = $gadai_all->pluck('nokp')->unique(); $customers = Customer::whereIn('kpbaru', $gadai_all_pluck_nokp) ->orWhereIn('kplama', $gadai_all_pluck_nokp) ->select('nama','kpbaru', 'kplama','alamat1','alamat2','alamat3','telefon') ->get(); // dd($customers->toArray()); $customers_keyBy_noKp = $customers->keyBy(function ($item) { if ($item->kpbaru != '') { return $item->kpbaru; } else if ($item->kplama != '') { return $item->kplama; } }); $gadai_all_groupby_nokp = $gadai_all->groupBy('nokp'); foreach($gadai_all as $index3=>$gadai){ if($customers_keyBy_noKp[$gadai->nokp]){ $gadai_all[$index3]["cust_info"] = $customers_keyBy_noKp[$gadai->nokp]; } } foreach($customers as $index=>$customer){ if($customer->kpbaru != ''){ $customers[$index]['nokp'] = $customer->kpbaru; } elseif($customer->kplama != ''){ $customers[$index]['nokp'] = $customer->kplama; } if($gadai_all_groupby_nokp[$customer->nokp]){ $customers[$index]['gadai'] = $gadai_all_groupby_nokp[$customer->nokp]; } foreach($customer['gadai'] as $index2=>$datagadai){ if($lelongbid_keyby_norujukan[$datagadai->norujukan]){ // $customer['gadai'][$index2]['lelongbid'] = $lelongbid_keyby_norujukan[$datagadai->norujukan]; $lelongbid_true = $lelongbid_keyby_norujukan[$datagadai->norujukan]; $ktlhbyr = $datagadai->hargajualan - $datagadai->bakihargajualan; $sumcajlelong = $lelongbid_true->hargaasas * ($lelong->cajlelong / 100); $cajlelongnew = round($sumcajlelong, 1, 1); $totalbaki = $lelongbid_true->hargaasas - $lelongbid_true->pinjaman - $lelongbid_true->bakiupah - $cajlelongnew; $customer['gadai'][$index2]['bakilelong'] = number_format($totalbaki, 2, '.', ','); $customer['gadai'][$index2]['ktlhbyr'] = number_format($ktlhbyr, 2, '.', ','); } } // dd($customer); } if($request->type == 'excel') { return view('excel.listnotis_excel2',compact('customers','lelong_id','caw')); } elseif($request->type == 'excelbysag') { return view('excel.listnotis_excelbysag2',compact('gadai_all','lelong_id','caw')); } else { $pdf = PDF::loadView('pdf.listnotis2',compact('customers','lelong_id','caw')) ->setPaper('a4', 'landscape'); return $pdf->download('Senarai Notis.pdf'); } } Public function kemaskininotis(Request $request){ $tetapan = Tetapan::where('id','=',1)->get(); return view('jananotis.kemaskininotis',compact('tetapan')); } public function storeall(Request $request) { // dd($request->all()); $tetapan = Tetapan::find(1); $tetapan->para2 = $request->para2; $tetapan->update(); $cawangan = Cawangan::all(); foreach($cawangan as $updatecaw){ $update = Cawangan::where('id', $updatecaw['id']) ->update(['para2'=>$request->para2]); // $update->para2 = $request->para2; // $update->update(); } return redirect()->route('jananotis.kemaskininotis') ->with('success','Kemaskini Berjaya'); } public function store(Request $request) { // dd($request->all()); $tetapan = Tetapan::find(1); $tetapan->para2caw = $request->para2; $tetapan->update(); $cawangan = Cawangan::all(); foreach($cawangan as $updatecaw){ $update = Cawangan::where('id', $updatecaw['id']) ->where('caw_code', $request->kodcaw) ->update(['para2'=>$request->para2]); } return redirect()->route('jananotis.kemaskininotisbycaw') ->with('success','Kemaskini Berjaya'); } Public function kemaskininotisbycaw (Request $request){ $caw = Cawangan::all(); return view('jananotis.kemaskininotisbycaw',compact('caw')); } public function jananotisfasa2($lelong_id){ $user = Auth::user(); $caw = Cawangan::where('caw_code','=',$user->kodcaw) ->first(); $lelong_id = $lelong_id; $current = Carbon::now(); $current = new Carbon(); $tarikh_cetak = $current->toDateString(); $marhun = LelongBid::join('cawangan', 'lelongbid.caw_id', '=', 'cawangan.id') ->where('lelong_id','=',$lelong_id) ->where('lelongbid.kodcaw','=',$user->kodcaw); $arraynorujukan = $marhun->pluck('norujukan')->toArray(); $datalelong = $marhun->get(); $marhuns = Gadai::on($datalelong[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan) ->select('nokp','norujukan') ->get(); // dd($marhuns); $arraysag = []; foreach($marhuns as $index1=>$cal){ $customer = Customer::where('kpbaru','=',$cal['nokp']) ->orWhere('kplama','=',$cal['nokp']) ->join('poskod','customer.poskod','=','poskod.poskod') ->join('daerah','poskod.koddaerah','=','daerah.koddaerah') ->join('negeri','poskod.kodnegeri','=','negeri.kodnegeri') ->first(); $listsag = Gadai::on($datalelong[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan) ->where('nokp','=',$cal['nokp']) ->get(); // dd($listsag); foreach($listsag as $index=>$listing){ $bayaran = $listing['hargajualan'] - $listing['bakihargajualan']; } $marhuns[$index1]['nama'] = ($customer) ? $customer : dd($cal['nokp']); $marhuns[$index1]['listsag'] = $listsag; } $lelongid = CawanganLelong::join('lelong','cawangan_lelong.lelong_id','=','lelong.id') ->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id') ->where('cawangan.caw_code','=',$user->kodcaw) ->where('cawangan_lelong.lelong_id', $lelong_id) ->get(); // return view('pdf.jananotisfasa2',compact('marhuns','lelong_id','lelongid','caw','tarikh_cetak','customer','listsag')); $pdf = PDF::loadView('pdf.jananotisfasa2',compact('marhuns','lelong_id','lelongid','caw','tarikh_cetak','customer','listsag')) ->setPaper('a4', 'potrait'); return $pdf->download('Penjanaan Notis Fasa 2:Batch Lelong '.$lelong_id.'.pdf'); } public function storeallfasa2(Request $request) { // dd($request->all()); $tetapan = Tetapan::find(1); $tetapan->para3 = $request->para3; $tetapan->update(); $cawangan = Cawangan::all(); foreach($cawangan as $updatecaw){ $update = Cawangan::where('id', $updatecaw['id']) ->update(['para3'=>$request->para3]); // $update->para2 = $request->para2; // $update->update(); } return redirect()->route('jananotis.kemaskininotis') ->with('success','Kemaskini Berjaya'); } // public function jananotisperingatan() // { // $currentDate = Carbon::now(); // $currentDate = $currentDate->toDateString(); // $caw = Cawangan::all(); // $tetapan = Tetapan::where('id','=',1)->first(); // return view('notisperingatan.jananotisperingatan',compact('caw','tetapan', 'currentDate')); // } // public function senaraitempnotisperingatan(Request $request) // { // $fasa = $request->fasa; // $jbg = $request->jbg; // $jbg2 = $request->jbg2; // if($request->fasa == '1'){ // $cawangan_all = Cawangan::orderBy('caw_name')->get(); // // dd($cawangan_all); // $senarai = []; // $total_bil_lelong = 0; // foreach($cawangan_all as $cawangan){ // $getsurat1 = NotisBid::where('kodcaw', $cawangan->caw_code)->get(); // $sag_pluck_norujukan = $getsurat1->pluck('norujukan'); // // dd($sag_pluck_norujukan); // $getsurat = Gadai::on($cawangan->caw_code) // ->whereNotIn('norujukan', $sag_pluck_norujukan) // ->where('tempoh', '>=', $jbg) // ->where('tempoh', '<=', $jbg2) // ->where('sttebus','=','') // ->where('tagpalsu','=',0) // ->where('tagpalsu2','=',0) // ->where('taglel','=',0) // ->where('lelong_tawarruq','=',1) // ->whereNotNull('upah12'); // $bil_lelong = $getsurat->count('norujukan'); // $total_bil_lelong += $bil_lelong; // $total_berat = $getsurat->sum('berat'); // $total_nilaimarhun = $getsurat->sum('nilaimarhun'); // $total_pembiayaan = $getsurat->sum('pinjaman'); // // $total_bakipjm = $getsurat->sum('bakipjm'); // $data = [ // 'bil_lelong'=>$bil_lelong, // 'total_berat'=>$total_berat, // 'total_nilaimarhun'=>$total_nilaimarhun, // 'total_pembiayaan'=>$total_pembiayaan, // // 'total_bakipjm'=>$total_bakipjm, // 'kodcaw'=>$cawangan->caw_code, // 'caw_name'=>$cawangan->caw_name]; // array_push($senarai,$data); // // dump($data); // } // } // else if($request->fasa == '2'){ // $cawangan_all = Cawangan::all(); // $senarai = []; // $total_bil_lelong = 0; // //dd($jbgadai); // foreach($cawangan_all as $cawangan){ // $getsurat1 = NotisBid::where('kodcaw', $cawangan->caw_code)->get(); // $sag_pluck_norujukan = $getsurat1->pluck('norujukan'); // // dd($sag_pluck_norujukan); // $getsurat = Gadai::on($cawangan->caw_code) // ->whereNotIn('norujukan', $sag_pluck_norujukan) // ->where('tempoh', '>=', $jbg) // // ->where('tempoh', '<=', $jbg2) // ->where('sttebus','=','') // ->where('tagpalsu','=',0) // ->where('tagpalsu2','=',0) // ->where('taglel','=',0) // // ->where('lelong_tawarruq','=',1) // ->whereNotNull('upah12'); // // $cawangan_simulasi = CawanganLelong::where('caw_id',$cawangan->id)->where('kali', '=' ,$kali)->count(); // // if($cawangan_simulasi == 0){ // $bil_lelong = $getsurat->count('norujukan'); // $total_bil_lelong += $bil_lelong; // $total_berat = $getsurat->sum('berat'); // $total_nilaimarhun = $getsurat->sum('nilaimarhun'); // $total_pembiayaan = $getsurat->sum('pinjaman'); // $total_bakipjm = $getsurat->sum('bakipjm'); // $data = [ // 'bil_lelong'=>$bil_lelong, // 'total_berat'=>$total_berat, // 'total_nilaimarhun'=>$total_nilaimarhun, // 'total_pembiayaan'=>$total_pembiayaan, // 'total_bakipjm'=>$total_bakipjm, // 'kodcaw'=>$cawangan->caw_code, // 'caw_name'=>$cawangan->caw_name]; // array_push($senarai,$data); // // dd($data); // // } // } // } // // dd($data); // if($total_bil_lelong == 0) // { // return redirect()->route('notisperingatan.jananotisperingatan') // ->with('failed','Tiada surat untuk di dijana'); // } // return view('notisperingatan.senaraitempnotisperingatan', compact( // 'getsurat', // 'senarai', // 'fasa', // 'jbg', // 'jbg2' // )); // } // public function tempbycawnotisperingatan(Request $request) // { // $fasa = $request->fasa; // $jbg = $request->jbg; // $jbg2 = $request->jbg2; // $details = $request->kodcaw; // // dd($jbg); // if($fasa == '1'){ // $getsurat = Gadai::on($details) // ->where('tempoh', '>=', $jbg) // ->where('tempoh', '<=', $jbg2) // ->where('kodcaw', $details) // ->where('sttebus', '=', '') // ->where('lelong_tawarruq','=',1) // ->where('taglel', '=', 0) // ->where('tagpalsu', '=', 0) // ->where('tagpalsu2', '=', 0) // ->whereNotNull('upah12') // ->get(); // $t_gadais = Gadai::on($details) // ->where('tempoh', '>=', $jbg) // ->where('tempoh', '<=', $jbg2) // ->where('sttebus', '=', '') // ->where('taglel', '=', 0) // ->where('tagpalsu', '=', 0) // ->where('tagpalsu2', '=', 0) // ->whereNotNull('upah12') // ->orderBy('t_gadai') // ->select('t_gadai') // ->first(); // }else{ // $getsurat = Gadai::on($details) // ->where('tempoh', '>=', $jbg) // // ->where('tempoh', '<=', $jbg2) // ->where('kodcaw', $details) // ->where('sttebus', '=', '') // ->where('taglel', '=', 0) // ->where('tagpalsu', '=', 0) // ->where('tagpalsu2', '=', 0) // ->whereNotNull('upah12') // ->get(); // $t_gadais = Gadai::on($details) // ->where('tempoh', '>=', $jbg) // // ->where('tempoh', '<=', $jbg2) // ->where('sttebus', '=', '') // ->where('taglel', '=', 0) // ->where('tagpalsu', '=', 0) // ->where('tagpalsu2', '=', 0) // ->whereNotNull('upah12') // ->orderBy('t_gadai') // ->select('t_gadai') // ->first(); // } // // $tarikh_lelong = Carbon::parse($t_lelong); // // $t_anggaran = ($tarikh_lelong->subMonths(1))->toDateString(); // // $t_lelongdisplay = $tarikh_lelong->format('d-m-Y'); // //$t_anggaran = ($tarikh_lelong->subDays(20))->format('d/m/Y'); // //$t_daftarlelong = ($tarikh_lelong->subMonths(1))->format('d/m/Y'); // //dd($getsurat); // foreach($getsurat as $index1=>$surats) // { // $senarai = Gadai::on($details) // ->where('norujukan', $surats['norujukan']) // ->get(); // // dd($surats['tempoh']); // $total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan','=',$surats['norujukan'])->sum('keuntungan_rebet'); // $total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan','=',$surats['norujukan'])->sum('bayaran_keuntungan'); // $beza_keuntungan = $total_untung_asal - $total_untung_rebet; // // dd($beza_keuntungan); // // $keuntungan = bcdiv(($surats['tempoh']-$surats['tempohbayar'])*$surats['kadarupah']/100*$surats['bakipjm'],1,1)-$beza_keuntungan; // $jbg = $surats['tempoh']-$surats['tempohbayar']; // $jbg2 = 12- $surats['tempohbayar']; // if($surats['tempoh'] <= '12.00'){ // $keuntungan = bcdiv(($jbg)*$surats['kadarupah']/100*$surats['bakipjm'],1,1)-$beza_keuntungan; // }else{ // $keuntungan = bcdiv(($jbg2)*$surats['kadarupah']/100*$surats['bakipjm'],1,1)-$beza_keuntungan; // } // // dd($surats['hargajualan']); // $ktlhbyr = $surats['hargajualan']-$surats['bakihargajualan']; // // dd($ktlhbyr); // $getsurat[$index1]['list_norujukan'] = $senarai; // $getsurat[$index1]['keuntungan'] = $keuntungan; // $getsurat[$index1]['ktlhbyr'] = $ktlhbyr; // } // // $keuntungantlhbyr = TransaksiKeuntungan::on('mysql2') // // ->sum('bayaran_keuntungan'); // return view('notisperingatan.tempbycawnotisperingatan', compact( 'getsurat', // 'details', // 'senarai', // 'keuntungan', // 't_gadais', // 'ktlhbyr' // )); // } // public function janadatanotisperingatan(Request $request) // { // $fasa = $request->fasa; // $jbg = $request->jbg; // $jbg2 = $request->jbg2; // $current = Carbon::now(); // $current = new Carbon(); // $tarikh_notis = $current->toDateString(); // $selected_caw = $request->caw; // if(!empty($selected_caw)) // { // $caws = Cawangan::whereIn('caw_code',$selected_caw)->get(); // $bil_surat = 0; // $sag_cawangans = []; // foreach($caws as $caw){ // if($fasa == '1'){ // $surat = Gadai::on($caw->caw_code) // ->where('tempoh', '>=', $jbg) // ->where('tempoh', '<=', $jbg2) // ->where('sttebus','=','') // ->where('tagpalsu','=',0) // ->where('tagpalsu2','=',0) // ->where('taglel','=',0) // ->where('lelong_tawarruq','=',1); // // ->count('norujukan'); // } // else if($fasa == '2'){ // $surat = Gadai::on($caw->caw_code) // ->where('tempoh', '>=', $jbg) // ->where('sttebus','=','') // ->where('tagpalsu','=',0) // ->where('tagpalsu2','=',0) // ->where('taglel','=',0); // // ->count('norujukan'); // } // $bil_sag_cawangan = $surat->count('norujukan'); // array_push($sag_cawangans,['cawangan'=>$caw,'data'=>$surat->get()]); // $bil_surat += $bil_sag_cawangan; // } // if($bil_surat == 0) // { // return redirect()->route('notisperingatan.jananotisperingatan') // ->with('failed','Tiada surat untuk di jana'); // } // //create notis // $notis = Notis::create([ // 'tarikh_notis' => $tarikh_notis, // 'daritempoh' => $jbg, // 'hinggatempoh' => $jbg2, // 'sts_notis' => 1, // 'fasa' => $fasa // ]); // foreach($sag_cawangans as $index=>$cawnotis){ // $caw_notis = new CawanganNotis; // $caw_notis->notis_id = $notis->id; // $caw_notis->caw_id = $cawnotis['cawangan']->id; // $caw_notis->fasa = $request->fasa; // $caw_notis->daritempoh = $request->jbg; // $caw_notis->hinggatempoh = $request->jbg2; // $caw_notis->status = 1; // $caw_notis->save(); // $suratcaw = $cawnotis['data']; // $notis_bid_arr = []; // $now = Carbon::now(); // foreach($suratcaw as $surat) // { // $notis_to_be_inserted = new NotisBid(); // $notis_to_be_inserted->notis_id = $notis->id; // $notis_to_be_inserted->caw_id = $cawnotis['cawangan']->id; // $notis_to_be_inserted->kodcaw = $surat->kodcaw; // $notis_to_be_inserted->norujukan = $surat->norujukan; // $notis_to_be_inserted->nokp = $surat->nokp; // $notis_to_be_inserted->jbg = $surat->tempoh; // $notis_to_be_inserted->kadarupah = $surat->kadarupah; // $notis_to_be_inserted->nilaimarhun = $surat->nilaimarhun; // $notis_to_be_inserted->pinjaman = $surat->bakipjm; // $notis_to_be_inserted->bakiupah = $surat->bakiupah; // $notis_to_be_inserted->berat = $surat->berat; // $notis_to_be_inserted->marhun = $surat->marhun; // $notis_to_be_inserted->percent = $surat->percentpinj; // $notis_to_be_inserted->fasa = $request->fasa; // $notis_bid_arr[] = $notis_to_be_inserted->attributesToArray(); // } // $notis_bid_collection = collect($notis_bid_arr); // NotisBid::insert($notis_bid_arr); // } // } // else // { // return redirect()->route('notisperingatan.jananotisperingatan')->with('failed','Tiada surat untuk di jana'); // } // return redirect()->route('notisperingatan.shownotisperingatan',$notis->id); // // return redirect()->route('analisa.senaraisimulasi')->with('success',"Success daftar simulasi!"); // } // public function shownotisperingatan($id) // { // $notis_id = $id; // $notis = Notis::with(['cawangan', 'notisBid'])->find($id); // $data = $notis; // $cawanganAll = $notis->cawangan; // $notisBidGroupByCawId = $notis->notisBid->groupBy('caw_id'); // foreach($cawanganAll as $caw_key_by_id) // { // if($notisBidGroupByCawId[$caw_key_by_id['id']]); // { // $caw_key_by_id['notisBid'] = $notisBidGroupByCawId[$caw_key_by_id['id']]; // } // } // $total_marhun = 0; // $total_nilaimarhun = 0; // $total_pinjaman = 0; // $total_bakiupah = 0; // $total_berat = 0; // $arraycaw = []; // foreach ($cawanganAll as $caw) { // $berat = 0; // $nilai_marhun = 0; // $pinjaman = 0; // $bakiupah = 0; // foreach ($caw['notisBid'] as $notis_bid) { // $total_marhun += 1; // $nilai_marhun += $notis_bid->nilaimarhun; // $pinjaman += $notis_bid->pinjaman; // $bakiupah += $notis_bid->bakiupah; // $berat += $notis_bid->berat; // } // array_push($arraycaw, [ // 'id_cawangan' => $caw['id'], // 'cawangan' => $caw->caw_name, // 'bil_marhun' => count($caw['notisBid']), // 'berat' => $berat, // 'n_marhun' => $nilai_marhun, // 'pinjaman' => $pinjaman, // 'upahsimpan' => $bakiupah, // 'bakiupah' => $bakiupah, // ]); // $total_nilaimarhun += $nilai_marhun; // $total_pinjaman += $pinjaman; // $total_bakiupah += $bakiupah; // $total_berat += $berat; // } // return view('notisperingatan.shownotisperingatan', compact( // 'data', // 'arraycaw', // 'total_marhun', // 'total_berat', // 'total_pinjaman', // 'notis_id', // 'total_bakiupah', // 'total_nilaimarhun', // 'notis' // )); // } // public function senarainotisall() // { // $arrayinfo = []; // $notis = Notis::select('tarikh_notis') // ->groupBy('tarikh_notis') // ->get(); // // ->toArray(); // // dd($notis); // foreach($notis as $info) // { // $detailsinfo = CawanganNotis::join('cawangan','cawangan_notis.caw_id','=','cawangan.id') // // ->where('kali',$info->kali) // ->get() // ->toArray(); // // dd($detailsinfo); // array_push($arrayinfo, ['info'=> $info, 'detailsinfo'=>$detailsinfo]); // } // return view('notisperingatan.senarainotisall',compact('notis','arrayinfo')); // } // public function shownotisperingatanall(Request $request, $tarikhnotis) // { // $tarikhnotis = $tarikhnotis; // $notis = Notis::where('tarikh_notis','=',$tarikhnotis)->first(); // $cawangannotis = CawanganNotis::where('created_at','like', '%'.$tarikhnotis.'%')->get(); // // dd($cawangannotis); // $arraydata = []; // $arraycaw = []; // $data = []; // $total_marhun = 0; // $total_berat = 0; // $total_nmarhun = 0; // $total_pinjaman = 0; // $total_upah = 0; // $total_bakiupah = 0; // $total_nilaimarhun = 0; // foreach($cawangannotis as $cawlel) // { // $cawangan = Cawangan::where('id','=',$cawlel->caw_id)->first(); // // $databid = LelongBid::join('cawangan_lelong','cawangan_lelong.caw_id','=','lelongbid.caw_id') // $databid = NotisBid:: join('cawangan_notis', function ($join) { // $join->on('cawangan_notis.caw_id', '=', 'notisbid.caw_id') // ->on('cawangan_notis.notis_id', '=', 'notisbid.notis_id'); // }) // ->select('notisbid.id','notisbid.berat','notisbid.marhun','notisbid.nilaimarhun','notisbid.pinjaman','notisbid.bakiupah') // ->where('cawangan_notis.caw_id','=', $cawlel->caw_id) // ->where('cawangan_notis.notis_id','=', $cawlel->notis_id) // ->get(); // $t_notis = Notis::join('cawangan_notis','cawangan_notis.notis_id','=','notis.id') // ->where('cawangan_notis.notis_id','=', $cawlel->notis_id) // ->first(); // $packet = 0; // $berat = 0; // $nilai_marhun = 0; // $pinjaman =0; // $bakiupah = 0; // $id = $cawlel->notis_id; // foreach($databid as $index1=>$bid) // { // $berat = $berat + $bid['berat']; // $nilai_marhun = $nilai_marhun + $bid['nilaimarhun']; // $pinjaman =$pinjaman + $bid['pinjaman']; // $bakiupah = $bakiupah + $bid['bakiupah']; // } // array_push($arraycaw,[ // 'id_cawangan'=> $cawangan['id'], // 'cawangan'=>$cawangan['caw_name'], // 't_notis'=>$notis['tarikh_notis'], // 'bil_marhun'=>sizeof($databid), // 'berat'=>$berat, // 'n_marhun'=>$nilai_marhun, // 'pinjaman'=>$pinjaman, // 'bakiupah'=>$bakiupah, // 'daritempoh'=>$t_notis['daritempoh'], // 'hinggatempoh'=>$t_notis['hinggatempoh'], // 'fasa'=>$t_notis['fasa'], // ]); // $total_marhun = $total_marhun + sizeof($databid); // $total_berat = $total_berat + $berat; // $total_nilaimarhun = $total_nilaimarhun + $nilai_marhun; // $total_pinjaman = $total_pinjaman + $pinjaman; // $total_bakiupah = $total_bakiupah + $bakiupah; // $data = Notis::where('tarikh_notis','=',$tarikhnotis)->first(); // } // return view('notisperingatan.shownotisperingatanall',compact( // 'arraycaw', // 'total_marhun', // 'total_berat', // 'total_nmarhun', // 'total_pinjaman', // 'total_upah', // 'data', // 'tarikhnotis', // 'total_bakiupah', // 'total_nilaimarhun' // )); // } }