Ejemplo n.º 1
0
 public function get_fleetsonnotprintspj()
 {
     $date = Input::get('date', date('Y-m-d'));
     $pool_id = Auth::user()->pool_id;
     $timestamp = strtotime($date);
     /*
     $fleets_on_not_printspj = 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('ksos.actived','=',1)
                 ->where('schedules.pool_id', '=', $pool_id )
                 ->where('schedule_dates.date', '=', date('j', $timestamp))
                 ->where('schedules.month','=',date('n', $timestamp ))
                 ->where('schedule_dates.fg_check','=',0)                  
                 ->order_by('fleets.taxi_number','asc')
                 ->get(array('schedule_dates.id as id','schedule_dates.driver_id','schedules.fleet_id','fleets.taxi_number'));
     */
     $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_on_not_printspj = array();
     if (is_array($arrayschedule) && !empty($arrayschedule)) {
         $fleets_on_not_printspj = Scheduledate::join('schedules', 'schedules.id', '=', 'schedule_dates.schedule_id')->join('fleets', 'fleets.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('schedule_dates.fg_check', '=', 0)->order_by('fleets.taxi_number', 'asc')->get(array('fleets.taxi_number', 'schedule_dates.id as id'));
     }
     $datas = array_map(function ($object) {
         return $object->to_array();
     }, $fleets_on_not_printspj);
     return Response::json($datas);
 }
Ejemplo n.º 2
0
 public function get_checkout()
 {
     $callback = Input::get('callback');
     $id = Input::get('schedule_id');
     $fleets = Scheduledate::join('schedules', 'schedules.id', '=', 'schedule_dates.schedule_id')->join('fleets', 'fleets.id', '=', 'schedules.fleet_id')->join('drivers', 'drivers.id', '=', 'schedule_dates.driver_id')->where('schedule_dates.id', '=', $id)->first();
     $fleetdatas = $fleets->to_array();
     return Response::jsonp($callback, $fleetdatas);
 }
Ejemplo n.º 3
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');
     }
 }
Ejemplo n.º 4
0
 public function get_ExportJhoHarianPdf($date = false)
 {
     if (!$date) {
         $date = date('Y-m-d');
     }
     $timestamp = strtotime($date);
     $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;
     }
     $this->data['scheduleday'] = array();
     if (is_array($arrayschedule) && !empty($arrayschedule)) {
         $this->data['scheduleday'] = Scheduledate::join('schedules', 'schedules.id', '=', 'schedule_dates.schedule_id')->where_in('schedule_dates.schedule_id', $arrayschedule)->where('schedules.pool_id', '=', Auth::user()->pool_id)->where('schedule_dates.date', '=', date('j', $timestamp))->get(array('schedule_dates.id as id', 'schedule_dates.driver_id', 'schedules.fleet_id', 'schedule_dates.fg_check'));
     }
     $this->data['tanggal'] = Myfungsi::fulldate($timestamp);
     /*
     ob_start();
       echo View::make('themes.modul.'.$this->report.'.scheduleharian',$this->data);
     $content = ob_get_clean();
     
     try
     {
         $html2pdf = new HTML2PDF('P', 'A4', 'en');
         $html2pdf->pdf->SetDisplayMode('fullpage');
         //$html2pdf->pdf->SetProtection(array('print'), 'spipu');
         $html2pdf->writeHTML($content, isset($_GET['vuehtml']));
         return Response::make($html2pdf->Output(), 200, array('Content-type' => 'application/pdf'));
     }
     catch(HTML2PDF_exception $e) {
         echo $e;
         exit;
     }
     */
     return View::make('themes.modul.' . $this->report . '.scheduleharian', $this->data);
 }
Ejemplo n.º 5
0
     foreach ($scdul as $as) {
         // loop schedule date / driver
         $scheduledate = Scheduledate::where('schedule_id', '=', $as->id)->group_by('driver_id')->get(array('driver_id'));
         foreach ($scheduledate as $gdriver) {
             if (!in_array($gdriver->driver_id, $driver_ar)) {
                 array_push($driver_ar, $gdriver->driver_id);
             }
         }
     }
 }
 /********************************/
 /* Proses Pembuatan Jadwal View */
 /********************************/
 if (is_array($driver_ar) && !empty($driver_ar)) {
     foreach ($driver_ar as $key => $value) {
         $a = Scheduledate::join('schedules', 'schedules.id', '=', 'schedule_dates.schedule_id')->where('schedules.month', '=', date('n', $timestamp))->where('schedules.year', '=', date('Y', $timestamp))->where('pool_id', '=', Auth::user()->pool_id)->where('schedule_dates.driver_id', '=', $value)->get();
         $free = array();
         // prosess pembentukan jadwal per pengemudi dalam group
         foreach ($a as $aa) {
             //echo 'Tanggal '. $aa->date .' di bawa pengemudi ' . $aa->driver_id ;
             //echo '<br>';
             array_push($free, $aa->date);
         }
         // DISPLY PENGEMUDI
         echo '<tr>';
         echo '<td>';
         echo 'Driv ' . $value;
         //$kso = Kso::where_bravo_driver_id($value)->where_actived(1)->first();
         //if($kso) echo Fleet::find($kso->fleet_id)->taxi_number;
         echo '</td>';
         echo '<td>';
Ejemplo n.º 6
0
 public function post_qzotorisasicetak()
 {
     $data = Input::json();
     $username = $data->username;
     $password = $data->password;
     $ver2 = User::where('username', '=', $username)->first();
     if ($ver2) {
         if (Hash::check($password, $ver2->password)) {
             Log::write('info', Request::ip() . ' User : '******' Event: Print SPJ otoritas', true);
             $scheduledate = Scheduledate::find($data->id);
             $schedule = Schedule::find($scheduledate->schedule_id);
             $scheduledate->fg_check = 1;
             $scheduledate->save();
             $driverinfo = Driver::find($scheduledate->driver_id);
             $fleetinfo = Fleet::find($schedule->fleet_id);
             $ksoinfo = Kso::where_fleet_id($schedule->fleet_id)->where_actived(1)->first();
             $this->data['driverinfo'] = $driverinfo;
             $this->data['fleetinfo'] = $fleetinfo;
             $this->data['pool'] = Pool::find($schedule->pool_id);
             $codeops = $data->statusops;
             $keterangan = $data->keterangan;
             if ((int) $codeops == 1) {
                 if ($driverinfo->fg_blocked == 1) {
                     $status = 5;
                     $codeops = 7;
                 } else {
                     if ($driverinfo->fg_super_blocked == 1) {
                         $status = 5;
                         $codeops = 7;
                     } else {
                         if ($fleetinfo->fg_blocked == 1) {
                             $status = 5;
                             $codeops = 7;
                         } else {
                             if ($fleetinfo->fg_bengkel == 1) {
                                 $status = 6;
                                 $codeops = 4;
                             } else {
                                 if ($fleetinfo->fg_super_blocked == 1) {
                                     $status = 5;
                                     $codeops = 7;
                                 } else {
                                     $status = 3;
                                     $codeops = $codeops;
                                 }
                             }
                         }
                     }
                 }
             } else {
                 $status = 3;
             }
             $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();
             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 = $fleetinfo->id;
                 $checkouts->driver_id = $driverinfo->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->print_out_time = 1;
                 $checkouts->otorisasi_user_id = $ver2->id;
                 $checkouts->save();
                 if ((int) $codeops == 1) {
                     $scheduledate->fg_check = 1;
                     $scheduledate->save();
                 }
                 if ((int) $codeops !== 1) {
                     $cin = Checkin::create(array('kso_id' => $ksoinfo->id, 'fleet_id' => $fleetinfo->id, 'driver_id' => $driverinfo->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' => 12, '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();
                     }
                     //make can't print before setoran
                     $setor = Fleet::find($fleetinfo->id);
                     $setor->fg_setor = 1;
                     $setor->save();
                 }
             } else {
                 if ((int) $codeops !== 1) {
                     $checkinstatus = Checkin::where_fleet_id($schedule->fleet_id)->where_operasi_time(date('Y-m-d', $dateopertion))->first();
                     if (!$checkinstatus) {
                         $cin = Checkin::create(array('kso_id' => $ksoinfo->id, 'fleet_id' => $fleetinfo->id, 'driver_id' => $driverinfo->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' => 12, '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();
                         }
                     }
                 }
                 //reprint after open blocking
                 if ((int) $codeops == 1) {
                     $checkinremove = Checkin::where_fleet_id($schedule->fleet_id)->where_operasi_time(date('Y-m-d', $dateopertion))->where_in('operasi_status_id', array(2, 3, 4, 5, 6, 7))->first();
                     if ($checkinremove) {
                         $checkinremove->delete();
                         //make can print before setoran becouse update set on checkout step
                         $setor = Fleet::find($schedule->fleet_id);
                         $setor->fg_setor = 0;
                         $setor->save();
                     }
                 }
                 if ((int) $codeops == 1) {
                     $scheduledate->fg_check = 1;
                     $scheduledate->save();
                 }
                 $checkouts->kso_id = $ksoinfo->id;
                 $checkouts->operasi_time = date('Y-m-d', $dateopertion);
                 $checkouts->fleet_id = $fleetinfo->id;
                 $checkouts->driver_id = $driverinfo->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->operasi_status_id = $codeops;
                 $checkouts->printspj_time = date('Y-m-d H:i:s', Myfungsi::sysdate());
                 $checkouts->keterangan = $keterangan;
                 $checkouts->print_out_time = 1;
                 $checkouts->otorisasi_user_id = $ver2->id;
                 $checkouts->save();
             }
             $content = "";
             if ($checkouts->operasi_status_id == 1) {
                 $kopsurat = 'SURAT PERINTAH JALAN';
                 $content .= "Nama dan kendaraan yang tercantum diatas";
                 $content .= "DI IZINKAN untuk mengoprasikan kendaraan";
                 $content .= "PT.DIAN TAKSI sesuai dengan tanggal yang";
                 $content .= "tercantum diatas\r\n";
                 $content .= "--------------------------------------- \r\n";
                 $content .= "a";
                 // 1 SET CENTER PAGE
                 $content .= "Tanda Tangan \r\n";
                 $content .= "a";
                 // 1 SET LEFT PAGE
                 $content .= "--------------------------------------- \r\n";
                 $content .= "  Bag. Operasi               Security \r\n";
                 $content .= "\r\n \r\n \r\n";
             } else {
                 $kopsurat = 'SURAT PENGANTAR PROSES BAP';
                 $content .= "Nama dan kendaraan yang tercantum diatas";
                 $content .= "TIDAK DI IZINKAN mengoprasikan kendaraan";
                 $content .= "PT.DIAN TAKSI sesuai dengan tanggal yang";
                 $content .= "tercantum diatas\r\n";
             }
             $headerPrint = "";
             for ($j = 1; $j < 2; $j++) {
                 $headerPrint .= "@";
                 $headerPrint .= "a";
                 // 1 SET CENTER PAGE
                 $headerPrint .= "!";
                 $headerPrint .= $kopsurat . " \r\n";
                 $headerPrint .= "!";
                 $headerPrint .= "@";
                 // 1 RESET
                 $headerPrint .= "a";
                 // 1 SET CENTER PAGE
                 $headerPrint .= "PT. DHARMA INDAH AGUNG METROPOLITAN \r\n";
                 $headerPrint .= "POOL " . Pool::find($checkouts->pool_id)->pool_name . " \r\n";
                 $headerPrint .= "======================================= \r\n";
                 $headerPrint .= "a";
                 // 1 SET LEFT PAGE
                 //content printer
                 $headerPrint .= "Nama        : " . substr($driverinfo->name, 0, 25) . " \r\n";
                 $headerPrint .= "Nip         : " . $driverinfo->nip . " \r\n";
                 $headerPrint .= "Body        : " . $fleetinfo->taxi_number . " \r\n";
                 $headerPrint .= "Tgl Operasi : " . date('d/m/Y', strtotime($checkouts->operasi_time)) . " \r\n";
                 $headerPrint .= "--------------------------------------- \r\n";
                 $headerPrint .= $content;
                 $headerPrint .= "======================================= \r\n";
                 $headerPrint .= "Tanggal Cetak " . date('d/m/Y H:i:s', MyFungsi::sysdate(date('Y-m-d H:i:s'))) . " \r\n";
                 $headerPrint .= "Lembar ke - " . $j . " \r\n";
                 $headerPrint .= "\f";
                 // 5 FF
                 $headerPrint .= "VA";
                 // 4 motong kertas
                 $headerPrint .= "@";
                 // 5 END
             }
             //create temp file
             $file = 'dataprintspj' . $checkouts->pool_id . '.txt';
             $myFile = path('public') . '/qzprint/templatedata/' . $file;
             $fh = fopen($myFile, 'w') or die("can't open file");
             $resetPrint = "";
             fwrite($fh, $resetPrint);
             $dataPrint = $headerPrint;
             fwrite($fh, $dataPrint);
             fclose($fh);
             return json_encode(array('status' => 1, 'urlfile' => $file));
         }
     }
 }