Example #1
0
 public function get_clonejho()
 {
     $checkouts = Checkin::all();
     foreach ($checkouts as $a) {
         $chk = Checkin::where('fleet_id', '=', $a->fleet_id)->where('operasi_time', '=', $a->operasi_time)->first();
         $chk->jho_id = $a->jho_id;
     }
 }
Example #2
0
 public function post_toolspj()
 {
     $date = Input::get('tanggal', date('Y-m-d'));
     ini_set('max_execution_time', 120);
     $timestamp = strtotime($date);
     //list armada on schedule
     $arrayschedule = array();
     $schedule = Schedule::where('month', '=', date('n', $timestamp))->where('year', '=', date('Y', $timestamp))->get(array('id', 'fleet_id'));
     foreach ($schedule as $sc) {
         $arrayschedule[] = $sc->id;
     }
     $fleets = array();
     if (is_array($arrayschedule) && !empty($arrayschedule)) {
         $fleets = Scheduledate::join('schedules', 'schedules.id', '=', 'schedule_dates.schedule_id')->join('fleets', 'fleets.id', '=', 'schedules.fleet_id')->join('ksos', 'ksos.fleet_id', '=', 'schedules.fleet_id')->where_in('schedule_dates.schedule_id', $arrayschedule)->where('schedules.pool_id', '=', Auth::user()->pool_id)->where('schedule_dates.date', '=', date('j', $timestamp))->where('schedules.month', '=', date('n', $timestamp))->where('schedule_dates.shift_id', '=', 1)->where('ksos.actived', '=', 1)->order_by('fleets.taxi_number', 'asc')->get(array('schedule_dates.id as id', 'schedule_dates.driver_id', 'schedules.fleet_id', 'fleets.taxi_number'));
     }
     if ($fleets) {
         foreach ($fleets as $f) {
             $scheduledate = Scheduledate::find($f->id);
             $scheduledate->fg_check = 1;
             $scheduledate->save();
             $schedule = Schedule::find($scheduledate->schedule_id);
             //$driverinfo = Driver::find($scheduledate->driver_id);
             //$fleetinfo = Fleet::find($schedule->fleet_id);
             $ksoinfo = Kso::where_fleet_id($schedule->fleet_id)->where_actived(1)->first();
             $dateopertion = mktime(0, 0, 0, $schedule->month, $scheduledate->date, $schedule->year);
             $checkouts = Checkout::where_fleet_id($schedule->fleet_id)->where_operasi_time(date('Y-m-d', $dateopertion))->first();
             //delete checkouts
             if ($checkouts) {
                 $checkouts->delete();
             }
             $codeops = 1;
             $status = 7;
             $keterangan = 'Print SPJ melalui Tools';
             if (!$checkouts) {
                 //insert into to checkouts step
                 $checkouts = new Checkout();
                 $checkouts->kso_id = $ksoinfo->id;
                 $checkouts->operasi_time = date('Y-m-d', $dateopertion);
                 $checkouts->fleet_id = $schedule->fleet_id;
                 $checkouts->driver_id = $scheduledate->driver_id;
                 $checkouts->checkout_step_id = $status;
                 $checkouts->shift_id = $scheduledate->shift_id;
                 $checkouts->user_id = Auth::user()->id;
                 $checkouts->pool_id = Auth::user()->pool_id;
                 $checkouts->printspj_time = date('Y-m-d H:i:s', Myfungsi::sysdate());
                 $checkouts->operasi_status_id = $codeops;
                 $checkouts->keterangan = $keterangan;
                 $checkouts->save();
                 $cinada = Checkin::where('operasi_time', '=', date('Y-m-d', $dateopertion))->where('fleet_id', '=', $schedule->fleet_id)->first();
                 if ($cinada) {
                     $cinada->delete();
                 }
                 if (!$cinada) {
                     $cin = Checkin::create(array('kso_id' => $ksoinfo->id, 'fleet_id' => $schedule->fleet_id, 'driver_id' => $scheduledate->driver_id, 'checkin_time' => date('Y-m-d H:i:s', Myfungsi::sysdate()), 'shift_id' => $scheduledate->shift_id, 'km_fleet' => 0, 'rit' => 0, 'incomekm' => 0, 'operasi_time' => date('Y-m-d', $dateopertion), 'pool_id' => Auth::user()->pool_id, 'operasi_status_id' => $codeops, 'fg_late' => '', 'checkin_step_id' => 2, 'document_check_user_id' => Auth::user()->id, 'physic_check_user_id' => '', 'bengkel_check_user_id' => '', 'finance_check_user_id' => '', 'keterangan' => $keterangan));
                     if ($cin) {
                         $docs = new Checkindocument();
                         $docs->checkin_id = $cin->id;
                         $docs->save();
                         //return Redirect::to('schedule');
                     }
                     //
                 }
             }
         }
         return Redirect::to('schedule');
     }
 }
Example #3
0
 public function get_findbyidCheckouts($id = false)
 {
     if (!$id) {
         return false;
     }
     $checkout = Checkout::find($id);
     $fleetinfo = Fleet::find($checkout->fleet_id);
     $driverinfo = Driver::find($checkout->driver_id);
     $checkin = Checkin::where('fleet_id', '=', $checkout->fleet_id)->where('operasi_time', '=', $checkout->operasi_time)->first();
     if ($checkin) {
         $checkin_documents = Checkindocument::where_checkin_id($checkin->id)->first();
         //$cpy = Checkinphysic::where_checkin_id($checkin->id)->first();
         $sp_pyss = array();
         /*
         	    if($cpy){
         	    	
         	    	$sp_pys = explode(',', $cpy->sparepart_id );
         	    	$ket_pys = explode(',', $cpy->ket );
         
         	    	foreach ($sp_pys as $k => $v) {
             	$sp_pyss[$v] = $ket_pys[$k];
             }
         
         	    }
         */
         $std_doc = explode(',', $checkin_documents->std_document_id);
         $ket_doc = explode(',', $checkin_documents->ket);
         $std_equip = explode(',', $checkin_documents->std_equip_id);
         $std_neat = explode(',', $checkin_documents->std_neats_id);
         $std_docs = array();
         $std_equips = array();
         $std_neats = array();
         foreach ($std_doc as $k => $v) {
             $std_docs[$v] = $ket_doc[$k];
         }
         foreach ($std_equip as $k => $v) {
             $std_equips[$v] = $v;
         }
         foreach ($std_neat as $k => $v) {
             $std_neats[$v] = $v;
         }
         $returndata = array('id' => $checkout->id, 'nip' => $driverinfo->nip, 'name' => $driverinfo->name, 'taxi_number' => $fleetinfo->taxi_number, 'police_number' => $fleetinfo->police_number, 'pool_id' => $checkout->pool_id, 'pool' => Pool::find($checkout->pool_id)->pool_name, 'status' => Checkinstep::find($checkin->checkin_step_id)->checkin_step, 'statusops' => Statusoperasi::find($checkin->operasi_status_id)->operasi_status, 'statusopsval' => $checkout->operasi_status_id, 'km_fleet' => $checkin->km_fleet, 'rit' => $checkin->rit, 'incomekm' => $checkin->incomekm, 'checkin_time' => $checkin->checkin_time, 'std_doc_id' => $std_docs, 'std_equip_id' => $std_equips, 'std_neat_id' => $std_neats, 'psy_check' => $sp_pyss, 'checkin' => true, 'checkinid' => $checkin->id, 'operasi_status_id' => $checkin->operasi_status_id, 'fg_bengkel' => $fleetinfo->fg_bengkel);
     } else {
         $returndata = array('id' => $checkout->id, 'nip' => $driverinfo->nip, 'name' => $driverinfo->name, 'taxi_number' => $fleetinfo->taxi_number, 'police_number' => $fleetinfo->police_number, 'pool_id' => $checkout->pool_id, 'pool' => Pool::find($checkout->pool_id)->pool_name, 'status' => Checkinstep::find(1)->checkin_step, 'statusops' => Statusoperasi::find($checkout->operasi_status_id)->operasi_status, 'statusopsval' => $checkout->operasi_status_id, 'checkin' => false);
     }
     return json_encode($returndata);
 }