Esempio n. 1
0
 public function post_otorisasi()
 {
     $input = Input::json();
     $username = $input->username;
     $password = $input->password;
     $bap_id = $input->bap_id;
     $ver2 = User::where('username', '=', $username)->first();
     if ($ver2) {
         if (Hash::check($password, $ver2->password)) {
             if ($ver2->id !== Auth::user()->id) {
                 //melihat driver_id dan fleet_id pada bap
                 $bap = Bap::find($bap_id);
                 //create log open block
                 try {
                     $open = Openblocking::create(array('bap_id' => $bap_id, 'tanggal' => date('Y-m-d H:i:s'), 'otorisasi1_id' => Auth::user()->id, 'otorisasi2_id' => $ver2->id));
                     if ($open) {
                         $driver = Driver::find($bap->driver_id);
                         $driver->fg_blocked = 0;
                         $driver->save();
                         $setor = Fleet::find($bap->fleet_id);
                         $setor->fg_setor = 0;
                         $setor->save();
                         return json_encode(array('status' => true, 'msg' => 'Otorisasi open block berhasil!'));
                     }
                 } catch (Exception $e) {
                     return json_encode(array('status' => true, 'msg' => 'Otorisasi sudah dilakukan!'));
                 }
             } else {
                 return json_encode(array('status' => false, 'msg' => 'Otorisasi harus orang yang berbeda!'));
             }
         }
     }
     return json_encode(array('status' => false, 'msg' => 'Otorisasi kedua gagal!'));
 }
Esempio n. 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();
         /*
         $sd = date('Y-m-01', strtotime($checkin->operasi_time));
         $ed = date('Y-m-d', strtotime($checkin->operasi_time));
         
         $financial = DB::table('checkins')
                 ->select(DB::raw('sum(if((checkin_financials.financial_type_id = 1),checkin_financials.amount,0)) AS setoran_wajib,sum(if((checkin_financials.financial_type_id = 2),checkin_financials.amount,0)) AS tabungan_sparepart,sum(if((checkin_financials.financial_type_id = 3),checkin_financials.amount,0)) AS denda,sum(if((checkin_financials.financial_type_id = 4),checkin_financials.amount,0)) AS potongan,sum(if((checkin_financials.financial_type_id = 5),checkin_financials.amount,0)) AS cicilan_sparepart,sum(if((checkin_financials.financial_type_id = 6),checkin_financials.amount,0)) AS cicilan_ks,sum(if((checkin_financials.financial_type_id = 7),checkin_financials.amount,0)) AS biaya_cuci,sum(if((checkin_financials.financial_type_id = 8),checkin_financials.amount,0)) AS iuran_laka,sum(if((checkin_financials.financial_type_id = 9),checkin_financials.amount,0)) AS cicilan_dp_kso,sum(if((checkin_financials.financial_type_id = 10),checkin_financials.amount,0)) AS cicilan_hutang_lama,sum(if((checkin_financials.financial_type_id = 11),checkin_financials.amount,0)) AS ks,sum(if((checkin_financials.financial_type_id = 12),checkin_financials.amount,0)) AS cicilan_lain,sum(if((checkin_financials.financial_type_id = 13),checkin_financials.amount,0)) AS hutang_dp_sparepart,sum(if((checkin_financials.financial_type_id = 20),checkin_financials.amount,0)) AS setoran_cash,sum(if((checkin_financials.financial_type_id = 21),checkin_financials.amount,0)) AS tabungan,(sum(if((checkin_financials.financial_type_id = 11),checkin_financials.amount,0)) - sum(if((checkin_financials.financial_type_id = 6),checkin_financials.amount,0))) AS selisi_ks '))
                 ->add_select(DB::raw('checkins.id, checkins.operasi_time , checkins.pool_id, checkins.shift_id'))
                 ->left_join('checkin_financials', 'checkins.id', '=', 'checkin_financials.checkin_id')
                 ->where_between('checkins.operasi_time',$sd , $ed)
                 ->where('checkins.kso_id', '=' ,$checkin->kso_id)
                 ->group_by('checkins.kso_id', 'checkins.operasi_time');
         */
         $bayar_ks = $financial->cicilan_ks;
         //bayar ks dalam bulan ini
         $ks = $financial->ks;
         //ks yang timbul bulan ini
         $selisih_ks = $financial->selisi_ks;
         if ($bayar_ks >= $ks) {
             /* set bs berdasarkan tanggal kso */
             $startkso = Kso::find($checkin->kso_id);
             if ($startkso->ops_start >= date('Y-m-10', strtotime($checkin->operasi_time)) && $startkso->ops_start <= date('Y-m-15', strtotime($checkin->operasi_time))) {
                 $xd = date('Y-m-d', strtotime($enddatemonth . ' -1 days'));
                 if ($checkin->operasi_time > $xd) {
                     $pot = $kso->setoran;
                 }
             } else {
                 if ($startkso->ops_start <= date('Y-m-10', strtotime($checkin->operasi_time))) {
                     $pot = $kso->setoran;
                 }
             }
         }
         /*
         else if ($checkin->pool_id == 2 && $selisih_ks >= (-200000) ) { // khusus mndo bulan ini
               $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;
     if ($fleetinfo->fg_bandara == 1) {
         $tag_other = 11000;
     }
     //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;
     }
     //set $tagihanopenblock
     $tagihanopenblock = 0;
     $bap = Bap::where('operasi_time', '=', $checkin->operasi_time)->where('driver_id', '=', $checkin->driver_id)->first();
     if ($bap) {
         $open = Openblocking::where('bap_id', '=', $bap->id)->first();
         if ($open) {
             $tagihanopenblock = $open->pay;
         }
     }
     //end tagihan open block
     $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, 'tagihanopenblock' => $tagihanopenblock, '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 + $tagihanopenblock - $pot);
     return json_encode($returndata);
 }
Esempio n. 3
0
 public function get_sbap($id = false)
 {
     if (!$id) {
         return false;
     }
     $infobap = Bap::find($id);
     $fleet_id = $infobap->fleet_id;
     $driver_id = $infobap->driver_id;
     //informasi ks pengemudi
     $financial_driver = DB::table('financial_report_monthly_driver')->where('driver_id', '=', $driver_id)->order_by('operasi_time', 'desc')->skip(1)->take(3)->get();
     $financial_fleet = DB::table('financial_report_monthly_fleet')->where('fleet_id', '=', $fleet_id)->order_by('operasi_time', 'desc')->skip(1)->take(3)->get();
     //array dari bernagai informasi
     /* informasi dari bulan 1 dan 2 bulan ke belangang di mulai dari 1-3 
        $month1 = date('n-Y', strtotime($infobap->date));
        $month2 = date('n-Y',(strtotime('-1 month',strtotime($infobap->date))));
        $month3 = date('n-Y',(strtotime('-2 month',strtotime($infobap->date))));
        echo $month1.$month2.$month3;*/
     $this->data['financial_driver'] = $financial_driver;
     $this->data['financial_fleet'] = $financial_driver;
     $this->data['bap'] = $infobap;
     return View::make('themes.modul.' . $this->views . '.sbap', $this->data);
 }
Esempio n. 4
0
 public function post_openpusat()
 {
     $driver_id = Input::get('id');
     $bap_number = Input::get('bap_number');
     $catatan = Input::get('catatan');
     $pay = Input::get('pay');
     $bap = Bap::where_bap_number($bap_number)->first();
     if ($bap) {
         $openblock = Openblocking::where('bap_id', '=', $bap->id)->first();
         if (!$openblock) {
             return Redirect::to('proses/otorisasipusat')->with('status', 'Belum dilakukan otoritas open block di pool');
         }
         $openblock->otorisasi3_id = Auth::user()->id;
         $openblock->catatan = $catatan;
         $openblock->pay = $pay;
         $y = $openblock->save();
         $driver = Driver::find($driver_id);
         $driver->fg_super_blocked = 0;
         $x = $driver->save();
         if ($x && $y) {
             return Redirect::to('proses/otorisasipusat')->with('status', 'Open Block Berhasil');
         } else {
             return Redirect::to('proses/otorisasipusat')->with('status', 'Open Block gagal');
         }
     }
     return Redirect::to('proses/otorisasipusat')->with('status', 'Nomor BAP tidak ditemukan');
 }
Esempio n. 5
0
 public function get_baparchive()
 {
     $date = Input::get('date', date('Y-m-d'));
     $baps = Bap::left_join('open_blocking as ob', 'ob.bap_id', '=', 'baps.id')->where('baps.date', '=', $date)->where('baps.pool_id', '=', Auth::user()->pool_id)->get(array('baps.bap_number', 'baps.id as id', 'baps.fleet_id', 'baps.driver_id', 'baps.user_id', 'baps.pool_id', 'baps.date', 'baps.last_update', 'ob.bap_id', 'ob.otorisasi2_id'));
     $this->data['date'] = $date;
     $this->data['baps'] = $baps;
     return View::make('themes.modul.' . $this->views . '.baparchive', $this->data);
 }