Esempio n. 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);
 }
Esempio n. 2
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);
 }