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')); } }
public function post_simpanbap() { Log::write('info', Request::ip() . ' User : '******' Event: Simpan Proses BAP', true); $lastnumber = Bap::max('id'); $num = myFungsi::numberComplate($lastnumber + 1, 5); $total_amount = Input::get('total_amount'); $amount = Input::get('amount'); foreach (Input::get('financial_type_id') as $key => $val) { if ($val == 6) { $besar_ks = $total_amount[$key]; $bayar_ks = $amount[$key]; } $ke = Kewajiban::where_fleet_id(Input::get('fleet_id'))->where_driver_id(Input::get('driver_id'))->where_financial_type_id($val)->first(); if ($ke) { $ke->amount = $amount[$key]; $ke->total_amount = $total_amount[$key]; $ke->save(); } else { Kewajiban::create(array('fleet_id' => Input::get('fleet_id'), 'driver_id' => Input::get('driver_id'), 'financial_type_id' => $val, 'amount' => $amount[$key], 'total_amount' => $total_amount[$key])); } } $fleet_id = Input::get('fleet_id'); $bap_number = 'DT-' . $num . '/BAP/' . Fleet::find($fleet_id)->taxi_number . '/' . date('m') . '/' . date('Y'); $driver_id = Input::get('driver_id'); $driver_status = Input::get('driver_status'); $keputusan_id = Input::get('keputusan_id'); $pool_id = Input::get('pool_id'); $sum_sparepart = Input::get('sum_sparepart'); $sum_ks = Input::get('sum_ks'); $sum_akhir_unit = Input::get('sum_akhir_unit'); $lampiran = Input::get('lampiran'); $std_bap_id = implode(',', Input::get('pelanggaran')); $ket_bap_other = Input::get('ket_bap_other'); $keterangan = Input::get('keterangan'); $solusi = Input::get('solusi'); $saksi1_name = Input::get('saksi1_name'); $saksi1_nik = Input::get('saksi1_nik'); $saksi1_jabatan = Input::get('saksi1_jabatan'); $saksi2_name = Input::get('saksi2_name'); $saksi2_nik = Input::get('saksi2_nik'); $saksi2_jabatan = Input::get('saksi2_jabatan'); $bap = Bap::create(array('date' => date('Y-m-d'), 'bap_number' => $bap_number, 'fleet_id' => $fleet_id, 'driver_id' => $driver_id, 'driver_status' => $driver_status, 'keputusan_id' => $keputusan_id, 'pool_id' => $pool_id, 'sum_sparepart' => $sum_sparepart, 'sum_ks' => $sum_ks, 'sum_akhir_unit' => $sum_akhir_unit, 'lampiran' => $lampiran, 'std_bap_id' => $std_bap_id, 'ket_bap_other' => $ket_bap_other, 'keterangan' => $keterangan, 'solusi' => $solusi, 'saksi1_name' => $saksi1_name, 'saksi1_nik' => $saksi1_nik, 'saksi1_jabatan' => $saksi1_jabatan, 'saksi2_name' => $saksi2_name, 'saksi2_nik' => $saksi2_nik, 'saksi2_jabatan' => $saksi2_jabatan, 'user_id' => Auth::user()->id, 'last_update' => date('Y-m-d H:i:s', Myfungsi::sysdate()), 'besar_ks' => $besar_ks, 'bayar_ks' => $bayar_ks)); return Redirect::to('proses'); }
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); }