示例#1
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);
 }
示例#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);
 }