Exemple #1
0
 public function get_findbyidFleetBlocking($id = false)
 {
     if (!$id) {
         return false;
     }
     $checkout = Checkout::find($id);
     $fleet = Fleet::find($checkout->fleet_id);
     $driver = Driver::find($checkout->driver_id);
     $kso = Kso::find($checkout->kso_id);
     $financial_driver = DB::table('financial_report_driver')->where('driver_id', '=', $checkout->driver_id)->first();
     $financial_fleet = DB::table('financial_report_bykso')->where('kso_id', '=', $checkout->kso_id)->first();
     $financial_fleet_part = DB::table('wo_financial_report_bykso')->where('kso_id', '=', $checkout->kso_id)->first();
     $fleet_ks = 0;
     $fleet_cicilan_ks = 0;
     $fleet_tabungan_sparepart = 0;
     $fleet_cicilan_db_kso = 0;
     $fleet_cicilan_sparepart = 0;
     $fleet_dp_sparepart = 0;
     if ($financial_fleet) {
         $fleet_ks = $financial_fleet->ks;
         $fleet_cicilan_ks = $financial_fleet->cicilan_ks;
         $fleet_tabungan_sparepart = $financial_fleet->tabungan_sparepart;
         $fleet_cicilan_db_kso = $financial_fleet->cicilan_dp_kso;
         $fleet_cicilan_sparepart = $financial_fleet->cicilan_sparepart;
         $fleet_dp_sparepart = $financial_fleet->hutang_dp_sparepart;
     }
     $total_pemakaian_part = 0;
     if ($financial_fleet_part) {
         $total_pemakaian_part = $financial_fleet_part->pemakaian_part;
     }
     //check hutang lama
     $hutang_lama = Driverfinancial::where_driver_id($checkout->driver_id)->where_financial_type_id('18')->first();
     $tagihan_hutang_lama = 0;
     if ($hutang_lama) {
         $tagihan_hutang_lama = $hutang_lama->amount;
     }
     $driver_ks = 0;
     $driver_cicilan_ks = 0;
     $cicilan_hutang_lama = 0;
     if ($financial_driver) {
         $driver_ks = $financial_driver->ks;
         $driver_cicilan_ks = $financial_driver->cicilan_ks;
         $cicilan_hutang_lama = $financial_driver->cicilan_hutang_lama;
     }
     $fleetinfo = array('police_number' => $fleet->police_number, 'bravo' => Driver::find($kso->bravo_driver_id)->name, 'taxi_number' => $fleet->taxi_number, 'total_ks' => $fleet_ks, 'pembayaran_ks' => $fleet_cicilan_ks, 'tab_sparepart' => $fleet_tabungan_sparepart, 'hutang_dp_kso' => $kso->sisa_dp, 'pem_hutang_dp_kso' => $fleet_cicilan_db_kso, 'pem_sparepart' => $total_pemakaian_part, 'saldo_unit' => number_format($fleet_cicilan_ks + $fleet_cicilan_db_kso - ($fleet_ks + $kso->sisa_dp) + ($fleet_tabungan_sparepart + $fleet_cicilan_sparepart + $fleet_dp_sparepart - $total_pemakaian_part), 2, ',', '.'), 'pembayaran_sparepart' => $fleet_cicilan_sparepart + $fleet_dp_sparepart, 'status' => $fleet->fg_blocked == 1 || $fleet->fg_bengkel == 1 ? 'Blocked' : 'Ready');
     $driverinfo = array('id' => $driver->id, 'name' => $driver->name, 'nip' => $driver->nip, 'saldo_ks_driver' => $driver_ks, 'pembayaran_ks_driver' => $driver_cicilan_ks, 'hutang_lama' => $tagihan_hutang_lama, 'cicilan_hutang_lama' => $cicilan_hutang_lama, 'status' => $driver->fg_blocked == 1 ? 'Blocked' : 'Ok');
     $bapinfo = array();
     $baps = Bap::where_driver_id($checkout->driver_id)->order_by('date', 'desc');
     $countbap = $baps->count();
     if ($baps->get()) {
         foreach ($baps->get() as $bap) {
             $bapinfo[] = array('id' => $bap->id, 'date' => $bap->date, 'bap_number' => $bap->bap_number, 'user' => User::find($bap->user_id)->fullname);
         }
     }
     $time = Myfungsi::sysdate();
     //date ajustment
     //strtotime($checkout->operasi_time);
     $t = strtotime($checkout->operasi_time . " 7 hours 0 seconds");
     $time_proses = false;
     if ($time >= $t) {
         $time_proses = true;
     }
     $returndata = array('checkout_id' => $id, 'fleetinfo' => $fleetinfo, 'driverinfo' => $driverinfo, 'bapinfo' => $bapinfo, 'countbap' => $countbap, 'time_proses' => $time_proses);
     return json_encode($returndata);
 }
Exemple #2
0
 public function post_findbyid()
 {
     $jsondata = Input::json();
     $checkin = Checkin::find($jsondata->id);
     $driverinfo = Driver::find($checkin->driver_id);
     $fleetinfo = Fleet::find($checkin->fleet_id);
     $kso = Kso::find($checkin->kso_id);
     //potongan hari libur
     $pot = 0;
     if ($jsondata->dayof === 'minggu') {
         $pot = Paymentcut::where('pool_id', '=', Auth::user()->pool_id)->where('financial_type_id', '=', 16)->first()->amount;
     } else {
         if ($jsondata->dayof === 'nasional') {
             $pot = Paymentcut::where('pool_id', '=', Auth::user()->pool_id)->where('financial_type_id', '=', 17)->first()->amount;
         }
     }
     //potongan bs
     $enddatemonth = date('Y-m-t', strtotime($checkin->operasi_time));
     $datechecked = date('Y-m-d', strtotime($enddatemonth . ' -2 days'));
     if ($checkin->operasi_time > $datechecked) {
         $financial = DB::table('financial_report_monthly_bykso')->where('kso_id', '=', $checkin->kso_id)->where_month(date('m', strtotime($checkin->operasi_time)))->where_year(date('Y', strtotime($checkin->operasi_time)))->first();
         $bayar_ks = $financial->cicilan_ks;
         //bayar ks dalam bulan ini
         $ks = $financial->ks;
         //ks yang timbul bulan ini
         if ($bayar_ks >= $ks) {
             $pot = $kso->setoran;
         }
     }
     if ($kso->kso_type_id == 2) {
         $pot = 0;
     }
     //end potongan BS
     //tagihan ks
     $tagihan_ks = Kewajiban::where('fleet_id', '=', $checkin->fleet_id)->where('driver_id', '=', $checkin->driver_id)->where('financial_type_id', '=', 6)->first();
     $tag_ks = 0;
     if ($tagihan_ks) {
         $tag_ks = $tagihan_ks->amount;
         $financialfleet = DB::table('financial_report_bykso')->where('kso_id', '=', $checkin->kso_id)->first();
         if ($financialfleet->cicilan_ks >= $financialfleet->ks) {
             $tagihan_ks->amount = 0;
             $tagihan_ks->save();
         }
     }
     //end tagihan ks
     //iuran lain-lain
     $iuran_laka = 0;
     $biaya_tc = 0;
     if ($fleetinfo->fg_laka == 1 && $checkin->operasi_status_id == 1) {
         $iuran_laka = Otherpayment::where('pool_id', '=', Auth::user()->pool_id)->where('financial_type_id', '=', 8)->first()->amount;
     }
     if ($checkin->operasi_status_id == 1) {
         $biaya_tc = Otherpayment::where('pool_id', '=', Auth::user()->pool_id)->where('financial_type_id', '=', 7)->first()->amount;
     }
     //denda keterlambatan
     $denda = 0;
     $jamopsplusday = date('Y-m-d', strtotime($checkin->operasi_time . ' +1 days'));
     $shift = Shift::find($checkin->shift_id);
     $batas_terlambat = date('Y-m-d H:i:s', Myfungsi::sysdate(date('Y-m-d H:i:s', strtotime($jamopsplusday . ' ' . $shift->jam_checkin . ' +' . $shift->ci_adjust . ' minutes'))));
     if ($checkin->checkin_time > $batas_terlambat) {
         $hours = (strtotime($checkin->checkin_time) - strtotime($batas_terlambat)) / 60 / 60;
         $denda = ceil($hours) * 10000;
     }
     //end denda
     //tag_cicilan_dp
     $tag_cicilan_dp = 0;
     $tagihan_dp = Kewajiban::where('fleet_id', '=', $checkin->fleet_id)->where('driver_id', '=', $checkin->driver_id)->where('financial_type_id', '=', 9)->first();
     if ($tagihan_dp) {
         $tag_cicilan_dp = $tagihan_dp->amount;
     }
     //end tagihan cicilan dp kso
     //tagihan dp sparepart
     $tag_dp_spart = 0;
     $dp_spart = Kewajiban::where('fleet_id', '=', $checkin->fleet_id)->where('driver_id', '=', $checkin->driver_id)->where('financial_type_id', '=', 13)->first();
     if ($dp_spart) {
         $tag_dp_spart = $dp_spart->amount;
     }
     //tagihan hutang sparepart
     $tag_spart = 0;
     $tagihan_spart = Kewajiban::where('fleet_id', '=', $checkin->fleet_id)->where('driver_id', '=', $checkin->driver_id)->where('financial_type_id', '=', 5)->first();
     if ($tagihan_spart) {
         $tag_spart = $tagihan_spart->amount;
     }
     //tagihan hutang lama
     $tag_hut_lama = 0;
     $hutang_lama_pengemudi = Driverfinancial::where('driver_id', '=', $checkin->driver_id)->where('financial_type_id', '=', 10)->first();
     if ($hutang_lama_pengemudi) {
         $tag_hut_lama = $hutang_lama_pengemudi->amount;
     }
     //end tagihan hutang lama
     //tagihan other
     $tag_other = 0;
     //km tempuh operasi
     $last_operasi = date('Y-m-d', strtotime($checkin->operasi_time . ' -1 days'));
     $last_checkin = Checkin::where_fleet_id($checkin->fleet_id)->where_operasi_time($last_operasi)->first();
     $km_tempuh = $checkin->km_fleet;
     if ($last_checkin) {
         $km_tempuh = $checkin->km_fleet - $last_checkin->km_fleet;
     }
     $returndata = array('id' => $checkin->id, 'nip' => $driverinfo->nip, 'name' => $driverinfo->name, 'taxi_number' => $fleetinfo->taxi_number, 'police_number' => $fleetinfo->police_number, 'pool_id' => $fleetinfo->pool_id, 'pool' => Pool::find($fleetinfo->pool_id)->pool_name, 'setoran_wajib' => $kso->setoran, 'tab_sp' => $kso->tab_sparepart, 'pot' => $pot, 'denda' => $denda, 'iuran_laka' => $iuran_laka, 'biaya_tc' => $biaya_tc, 'tag_spart' => $tag_spart, 'tag_ks' => $tag_ks, 'tag_cicilan_dp' => $tag_cicilan_dp, 'tag_dp_spart' => $tag_dp_spart, 'tag_hut_lama' => $tag_hut_lama, 'tag_other' => $tag_other, 'in_time' => $checkin->checkin_time, 'km_tempuh' => $km_tempuh, 'total' => $kso->setoran + $kso->tab_sparepart + $denda + $iuran_laka + $biaya_tc + $tag_spart + $tag_ks + $tag_cicilan_dp + $tag_dp_spart + $tag_hut_lama + $tag_other - $pot);
     return json_encode($returndata);
 }
Exemple #3
0
 public function post_savePayment()
 {
     Log::write('info', Request::ip() . ' User : '******' Event: Save Setoran', true);
     $jsondata = Input::json();
     //lihat KS
     $tabungan_pengemudi = 0;
     $ks_pengemudi = 0;
     if ((int) $jsondata->ks > 0) {
         $tabungan_pengemudi = (int) $jsondata->ks;
     } else {
         $ks_pengemudi = abs((int) $jsondata->ks);
     }
     $setoran = array();
     $setoran['1'] = (int) $jsondata->setoran_wajib;
     $setoran['2'] = (int) $jsondata->tab_sp;
     $setoran['3'] = (int) $jsondata->denda;
     $setoran['4'] = (int) $jsondata->pot;
     $setoran['5'] = (int) $jsondata->tag_spart;
     $setoran['6'] = (int) $jsondata->tag_ks;
     $setoran['7'] = (int) $jsondata->biaya_tc;
     $setoran['8'] = (int) $jsondata->iuran_laka;
     $setoran['9'] = (int) $jsondata->tag_cicilan_dp;
     $setoran['10'] = (int) $jsondata->tag_hut_lama;
     $setoran['11'] = (int) $ks_pengemudi;
     $setoran['12'] = (int) $jsondata->tag_other;
     $setoran['13'] = (int) $jsondata->tag_dp_spart;
     $setoran['20'] = (int) $jsondata->setoran_cash;
     $setoran['21'] = (int) $tabungan_pengemudi;
     try {
         foreach ($setoran as $key => $value) {
             $payment = Checkinfinancial::create(array('checkin_id' => $jsondata->checkin_id, 'financial_type_id' => $key, 'amount' => $value));
         }
         $checkin = Checkin::find($jsondata->checkin_id);
         /*
         /* membuat super block berdasarkan parameter ini
         /* 1. KS Pengemudi Melebihi atau sama dengan 500.000,- dalam bulan berjalan
         /* 2. Belum di devinisikan ( besar akumulasi batas KS ) 
         */
         $finandriver = DB::table('financial_report_monthly_driver_status')->where('month', '=', date('n', strtotime($checkin->operasi_time)))->where('year', '=', date('Y', strtotime($checkin->operasi_time)))->where('driver_id', '=', $checkin->driver_id)->where('operasi_status_id', '=', 1)->order_by('id', 'desc')->first();
         if ($setoran['11'] > 0) {
             Blocked::create(array('driver_id' => $checkin->driver_id, 'fleet_id' => $checkin->fleet_id, 'std_bap_id' => 4, 'checkin_id' => $checkin->id, 'date' => date('Y-m-d H:i:s', Myfungsi::sysdate())));
             $block = Driver::find($checkin->driver_id);
             $block->fg_blocked = 1;
             /*super block melebihi ks 500000*/
             if ($finandriver) {
                 if ($finandriver->selisi_ks < -500000) {
                     //$block->fg_super_blocked = 1;
                 }
             }
             $block->save();
         }
         //update status checkin
         //informasi siapa yang menerima setoran dan waktu setoran
         $checkin->checkin_step_id = 3;
         $checkin->finance_check_user_id = Auth::user()->id;
         $checkin->finance_time = date('Y-m-d H:i:s', Myfungsi::sysdate());
         $checkin->save();
         $pothutanglama = Driverfinancial::where_driver_id($checkin->driver_id)->where_financial_type_id(18)->first();
         if ($pothutanglama) {
             $pothutanglama->amount = $pothutanglama->amount - $jsondata->tag_hut_lama;
         }
         $tabunganpengemudi = Driverfinancial::where_driver_id($checkin->driver_id)->where_financial_type_id(21)->first();
         if ($tabunganpengemudi) {
             $tabunganpengemudi->amount = $tabunganpengemudi->amount + $tabungan_pengemudi;
         } else {
             Driverfinancial::create(array('driver_id' => $checkin->driver_id, 'financial_type_id' => 21, 'amount' => $tabungan_pengemudi));
         }
         $ks = Kewajiban::where_fleet_id($checkin->fleet_id)->where_driver_id($checkin->driver_id)->where_financial_type_id(6)->first();
         if ($ks) {
             $ks->total_amount = $ks->total_amount + $setoran['11'] - $setoran['6'];
         } else {
             Kewajiban::create(array('fleet_id' => $checkin->fleet_id, 'driver_id' => $checkin->driver_id, 'financial_type_id' => 6, 'amount' => 0, 'total_amount' => $setoran['11']));
         }
         $setor = Fleet::find($checkin->fleet_id);
         $setor->fg_setor = 0;
         $setor->save();
         /*
         if((int)$jsondata->denda > 10000)
         {
           Blocked::create(array(
                               'driver_id'=>$checkin->driver_id, 
                               'fleet_id' => $checkin->fleet_id , 
                               'blocked_status_id' => 6,
                               'checkin_id' => $checkin->id,  
                               'date'=> date('Y-m-d H:i:s') ));
         
           $block = Driver::find($checkin->driver_id);
           $block->fg_blocked = 1;
           $block->save();
         }
         */
         return json_encode(array('id' => $jsondata->checkin_id, 'msg' => 'Setoran berhasil di simpan'));
     } catch (Exception $e) {
         return json_encode(array('id' => $jsondata->checkin_id, 'msg' => 'Setoran Sudah pernah di input'));
     }
 }
Exemple #4
0
 public function get_findbyIdDriver($id = false)
 {
     if (!$id) {
         return false;
     }
     $driver = Driver::find($id);
     $financial_driver = DB::table('financial_report_driver')->where('driver_id', '=', $driver->id)->first();
     //check hutang lama
     $hutang_lama = Driverfinancial::where_driver_id($driver->id)->where_financial_type_id('18')->first();
     $tagihan_hutang_lama = 0;
     if ($hutang_lama) {
         $tagihan_hutang_lama = $hutang_lama->amount;
     }
     $driver_ks = 0;
     $driver_cicilan_ks = 0;
     $cicilan_hutang_lama = 0;
     if ($financial_driver) {
         $driver_ks = $financial_driver->ks;
         $driver_cicilan_ks = $financial_driver->cicilan_ks;
         $cicilan_hutang_lama = $financial_driver->cicilan_hutang_lama;
     }
     $driverinfo = array('id' => $driver->id, 'name' => $driver->name, 'nip' => $driver->nip, 'saldo_ks_driver' => number_format($driver_ks, 2, ',', '.'), 'pembayaran_ks_driver' => number_format($driver_cicilan_ks, 2, ',', '.'), 'hutang_lama' => number_format($tagihan_hutang_lama, 2, ',', '.'), 'cicilan_hutang_lama' => number_format($cicilan_hutang_lama, 2, ',', '.'), 'status' => $driver->fg_blocked == 1 ? 'Blocked' : 'Ok');
     $bapinfo = array();
     $baps = Bap::where_driver_id($driver->id)->order_by('date', 'desc');
     $countbap = $baps->count();
     if ($baps->get()) {
         foreach ($baps->get() as $bap) {
             $bapinfo[] = array('id' => $bap->id, 'date' => $bap->date, 'bap_number' => $bap->bap_number, 'user' => User::find($bap->user_id)->fullname);
         }
     }
     $returndata = array('driverinfo' => $driverinfo, 'bapinfo' => $bapinfo, 'countbap' => $countbap);
     return json_encode($returndata);
 }