Ejemplo n.º 1
0
 public static function periode($strtime)
 {
     $day = date('d', $strtime);
     $month = date('n', $strtime);
     $year = date('Y', $strtime);
     return Myfungsi::bulan($month) . ' ' . $year;
 }
Ejemplo n.º 2
0
 public function get_index()
 {
     $date = Input::get('date', false);
     $pool_id = Auth::user()->pool_id;
     if (!$date) {
         $date = date('Y-m-d');
     }
     $timestamp = strtotime($date);
     $this->data['month'] = Myfungsi::bulan(date('n', strtotime($date)));
     return View::make('themes.layouts.dashboard', $this->data);
 }
Ejemplo n.º 3
0
 public function post_saveeditkso()
 {
     Log::write('info', Request::ip() . ' User : '******' Event: Edit KSO', true);
     $data = Input::all();
     $extradata = array('user_id' => Auth::user()->id, 'last_update' => date('Y-m-d H:i:s'));
     $savedata = $data + $extradata;
     $datasave = Kso::find($data['id']);
     $datasave->kso_number = $data['kso_number'];
     $datasave->fleet_id = $data['fleet_id'];
     $datasave->bravo_driver_id = $data['bravo_driver_id'];
     $datasave->charlie_driver_id = $data['charlie_driver_id'];
     $datasave->pool_id = $data['pool_id'];
     $datasave->dp = $data['dp'];
     $datasave->sisa_dp = $data['sisa_dp'];
     $datasave->setoran = $data['setoran'];
     $datasave->tab_sparepart = $data['tab_sparepart'];
     $datasave->kso_type_id = $data['kso_type_id'];
     $datasave->ops_start = $data['ops_start'];
     $datasave->ops_end = $data['ops_end'];
     $datasave->actived = $data['actived'];
     $datasave->save();
     if ($datasave) {
         if ($data['actived'] == 2) {
             $c = Fleet::find($data['fleet_id']);
             $c->fg_kso = 0;
             $c->save();
             $s = Anakasuh::where('fleet_id', '=', $data['fleet_id'])->where('status', '=', 1)->first();
             if ($s) {
                 $s->status = 0;
                 $s->end_date = date('Y-m-d', Myfungsi::sysdate());
                 $s->save();
             }
         } else {
             if ($data['actived'] == 1) {
                 $c = Fleet::find($data['fleet_id']);
                 $c->fg_kso = 1;
                 $c->save();
             }
         }
         return Redirect::to('ksos');
     }
     var_dump($data);
 }
Ejemplo n.º 4
0
 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');
 }
Ejemplo n.º 5
0
 public function post_exphutangarmada()
 {
     $input = Input::all();
     $shift = 'all';
     $saldohutangbymonth = $this->allQuery($input['date'], Auth::user()->pool_id, $shift, 0, 1000);
     if ($saldohutangbymonth) {
         $objPHPExcel = new PHPExcel();
         $objPHPExcel->getProperties()->setCreator(Auth::user()->fullname)->setLastModifiedBy(Auth::user()->fullname)->setTitle("Laporan Harian " . Pool::find(Auth::user()->pool_id)->pool_name . '-' . date('Y-m-d'))->setSubject("Laporan Harian " . Pool::find(Auth::user()->pool_id)->pool_name . '-' . date('Y-m-d'))->setDescription("Laporan harian operasi pool")->setKeywords("Laporan Harian")->setCategory("");
         $styleArray = array('font' => array('bold' => true, 'color' => array('rgb' => 'FF0000'), 'size' => 16));
         $sheet_active = 0;
         $objPHPExcel->createSheet(NULL, $sheet_active);
         $objPHPExcel->setActiveSheetIndex($sheet_active);
         //title
         $objPHPExcel->getActiveSheet()->mergeCells('A2:J2');
         $objPHPExcel->getActiveSheet()->setCellValue('A2', 'LAPORAN HUTANG ARMADA PER TANGGAL ' . Myfungsi::fulldate(strtotime($input['date'])));
         $objPHPExcel->getActiveSheet()->getStyle('A2')->applyFromArray($styleArray);
         // Coloum header
         $objPHPExcel->getActiveSheet()->mergeCells('A5:A6');
         $objPHPExcel->getActiveSheet()->mergeCells('B5:B6');
         $objPHPExcel->getActiveSheet()->mergeCells('C5:D5');
         $objPHPExcel->getActiveSheet()->mergeCells('E5:E6');
         $objPHPExcel->getActiveSheet()->mergeCells('F5:I5');
         $objPHPExcel->getActiveSheet()->mergeCells('J5:L5');
         $objPHPExcel->getActiveSheet()->mergeCells('M5:O5');
         $objPHPExcel->getActiveSheet()->setCellValue('A5', 'NO');
         $objPHPExcel->getActiveSheet()->setCellValue('B5', 'BAPAK ASUH');
         $objPHPExcel->getActiveSheet()->setCellValue('C5', 'PENGEMUDI');
         $objPHPExcel->getActiveSheet()->setCellValue('C6', 'NIP');
         $objPHPExcel->getActiveSheet()->setCellValue('D6', 'NAMA');
         $objPHPExcel->getActiveSheet()->setCellValue('E5', 'BODY');
         $objPHPExcel->getActiveSheet()->setCellValue('F5', 'PEMAKAIAN SPAREPART ARMADA');
         $objPHPExcel->getActiveSheet()->setCellValue('F6', 'PEMAKAIAN');
         $objPHPExcel->getActiveSheet()->setCellValue('G6', 'TABUNGAN');
         $objPHPExcel->getActiveSheet()->setCellValue('H6', 'BAYAR');
         $objPHPExcel->getActiveSheet()->setCellValue('I6', 'SELISIH');
         $objPHPExcel->getActiveSheet()->setCellValue('J5', 'SETORAN ARMADA');
         $objPHPExcel->getActiveSheet()->setCellValue('J6', 'KS');
         $objPHPExcel->getActiveSheet()->setCellValue('K6', 'BAYAR KS');
         $objPHPExcel->getActiveSheet()->setCellValue('L6', 'SELISIH');
         $objPHPExcel->getActiveSheet()->setCellValue('M5', 'SALDO ARMADA');
         $objPHPExcel->getActiveSheet()->setCellValue('M6', 'SALDO SPAREPART');
         $objPHPExcel->getActiveSheet()->setCellValue('N6', 'SALDO KS');
         $objPHPExcel->getActiveSheet()->setCellValue('O6', 'SALDO AKHIR');
         $objPHPExcel->getActiveSheet()->setCellValue('P5', 'SHIFT');
         $no = 1;
         $starline = 8;
         foreach ($saldohutangbymonth as $saldo) {
             $bpkasuh = Anakasuh::where('status', '=', 1)->where('fleet_id', '=', $saldo->fleet_id)->first();
             $bravo = Driver::find($saldo->bravo_driver_id);
             $saldosp = $saldo->tabungan_sparepart + $saldo->hutang_dp_sparepart + $saldo->cicilan_sparepart - $saldo->pemakaian_part;
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $starline, $no);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $starline, $bpkasuh ? User::find($bpkasuh->user_id)->fullname : 'TIDAK ADA BAPAK ASUH');
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, $starline, $bravo ? $bravo->nip : 'NONE');
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $starline, $bravo ? $bravo->name : 'NONE');
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $starline, $saldo->taxi_number);
             //pemakaikan sp
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $starline, $saldo->pemakaian_part);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $starline, $saldo->tabungan_sparepart);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $starline, $saldo->hutang_dp_sparepart + $saldo->cicilan_sparepart);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(8, $starline, $saldosp);
             //setoran armada
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(9, $starline, $saldo->ks);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(10, $starline, $saldo->cicilan_ks);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(11, $starline, $saldo->selisi_ks);
             //saldo armada
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(12, $starline, $saldosp);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(13, $starline, $saldo->selisi_ks);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(14, $starline, $saldosp + $saldo->selisi_ks);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(15, $starline, $saldo->shift_id);
             $no++;
             $starline++;
         }
         $objPHPExcel->getActiveSheet()->getStyle('A5:O' . ($starline + 1))->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_HAIR);
         $objPHPExcel->getActiveSheet()->getStyle('A5:O6')->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
         $objPHPExcel->getActiveSheet()->getStyle('A5:O' . ($starline + 1))->getBorders()->getOutline()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
         $objPHPExcel->getActiveSheet()->getStyle('A' . ($starline + 1) . ':O' . ($starline + 1))->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
         //end
         //SET TANGGAL UNDUH DAN PASSWORD
         $objPHPExcel->getActiveSheet()->setCellValue('B' . ($starline + 10), 'Tanggal Unduh');
         $objPHPExcel->getActiveSheet()->setCellValue('C' . ($starline + 10), ':');
         $objPHPExcel->getActiveSheet()->setCellValue('D' . ($starline + 10), date('Y-m-d H:i:s'));
         $objPHPExcel->getSecurity()->setLockWindows(true);
         $objPHPExcel->getSecurity()->setLockStructure(true);
         $objPHPExcel->getSecurity()->setWorkbookPassword("FreeBlocking");
         $objPHPExcel->getActiveSheet()->getProtection()->setPassword('FreeBlocking');
         $objPHPExcel->getActiveSheet()->getProtection()->setSheet(true);
         // This should be enabled in order to enable any of the following!
         //$objPHPExcel->getActiveSheet()->getProtection()->setSort(true);
         $objPHPExcel->getActiveSheet()->getProtection()->setInsertRows(true);
         //END
         $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
         $objWriter->save(path('public') . 'Laporan-hutang-armada.xls');
         return Response::download(path('public') . 'Laporan-hutang-armada.xls');
     }
     //end if
     //var_dump($saldohutangbymonth);
 }
Ejemplo n.º 6
0
 public function get_reportdailyjson($date = false)
 {
     if (!$date) {
         $date = date('Y-m-d');
     }
     $timestamp = strtotime($date);
     $report_daily = DB::table('financial_report_daily')->where_pool_id(Auth::user()->pool_id)->get();
     $tanggalKSO = Myfungsi::fulldate($timestamp);
     $returndata = array('tanggal' => $tanggalKSO, 'date' => $date);
     return json_encode($returndata);
 }
Ejemplo n.º 7
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.º 8
0
 public function post_exppemakaianunit()
 {
     $input = Input::all();
     $wolist = DB::table('wo_listparts')->where('month', '=', date('n', strtotime($input['date'])))->where('year', '=', date('Y', strtotime($input['date'])))->where('kso_id', '=', $input['kso_id'])->order_by('inserted_date_set', 'asc')->get();
     $kso = Kso::find($input['kso_id']);
     if ($wolist && $kso) {
         $objPHPExcel = new PHPExcel();
         $objReader = PHPExcel_IOFactory::createReader('Excel5');
         $objPHPExcel = $objReader->load(path('public') . 'template/rekapbonpengemuditemplate.xls');
         $no = 1;
         $startline = 11;
         $objPHPExcel->getActiveSheet()->setCellValue('A4', 'PERIODE ' . Myfungsi::periode(strtotime($input['date'])));
         $objPHPExcel->getActiveSheet()->setCellValue('B6', Fleet::find($kso->fleet_id)->taxi_number);
         $objPHPExcel->getActiveSheet()->setCellValue('B7', Driver::find($kso->bravo_driver_id)->nip);
         $objPHPExcel->getActiveSheet()->setCellValue('B8', Driver::find($kso->bravo_driver_id)->name);
         foreach ($wolist as $bon) {
             $row = $startline + 2;
             $objPHPExcel->getActiveSheet()->insertNewRowBefore($row - 1, 1);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $row, $no++);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $row, $bon->inserted_date_set);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, $row, $bon->wo_number);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $row, $bon->part_number);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $row, $bon->name_sparepart);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $row, $bon->qty);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $row, $bon->satuan);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $row, $bon->price);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(8, $row, '=F' . $row . '*H' . $row);
         }
         $objPHPExcel->getActiveSheet()->removeRow($row - 1, 1);
         $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
         $objWriter->save(path('public') . 'Laporan-hutang-armada.xls');
         return Response::download(path('public') . 'Laporan-hutang-armada.xls');
     }
 }
Ejemplo n.º 9
0
 public function post_expkasharian()
 {
     $shift_id = Input::get('shift_id', 'all');
     $startdate = Input::get('startdateops', date('Y-m-01'));
     $date = Input::get('date', date('Y-m-d'));
     $objPHPExcel = new PHPExcel();
     $objPHPExcel->getProperties()->setCreator(Auth::user()->fullname)->setLastModifiedBy(Auth::user()->fullname)->setTitle("Laporan Harian " . Pool::find(Auth::user()->pool_id)->pool_name . '-' . date('Y-m-d'))->setSubject("Laporan Harian " . Pool::find(Auth::user()->pool_id)->pool_name . '-' . date('Y-m-d'))->setDescription("Laporan harian operasi pool")->setKeywords("Laporan Harian")->setCategory("");
     $styleArray = array('font' => array('bold' => true, 'color' => array('rgb' => 'FF0000'), 'size' => 16));
     $jenis_kendaraan = Fleetmodel::where('actived', '=', 1)->get();
     $sheet_active = 0;
     if (Input::get('statusopsdef') == 'all') {
         //query export
         if ($shift_id == 'all') {
             $financials = DB::table('financial_report_summary_graf')->where('operasi_time', '>=', $startdate)->where('operasi_time', '<=', $date)->where_pool_id(Auth::user()->pool_id)->order_by('operasi_time', 'asc')->get();
         } else {
             $financials = DB::table('financial_report_summary')->where('shift_id', '=', $shift_id)->where('operasi_time', '>=', $startdate)->where('operasi_time', '<=', $date)->where_pool_id(Auth::user()->pool_id)->order_by('operasi_time', 'asc')->get();
         }
         $objPHPExcel->createSheet(NULL, 0);
         $objPHPExcel->setActiveSheetIndex(0);
         $objPHPExcel->getActiveSheet()->mergeCells('A2:X2');
         $objPHPExcel->getActiveSheet()->setCellValue('A2', 'LAPORAN PENDAPATAN PERIODE TANGGAL ' . Myfungsi::fulldate(strtotime($startdate)) . ' - ' . Myfungsi::fulldate(strtotime($date)) . ' Gabungan Armada');
         $objPHPExcel->getActiveSheet()->getStyle('A2')->applyFromArray($styleArray);
         $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setVisible(false);
         $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false);
         $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
         $objPHPExcel->getActiveSheet()->mergeCells('A5:A6');
         $objPHPExcel->getActiveSheet()->mergeCells('B5:B6');
         $objPHPExcel->getActiveSheet()->mergeCells('C5:D5');
         $objPHPExcel->getActiveSheet()->mergeCells('E5:E6');
         $objPHPExcel->getActiveSheet()->mergeCells('F5:G5');
         $objPHPExcel->getActiveSheet()->mergeCells('H5:H6');
         $objPHPExcel->getActiveSheet()->mergeCells('I5:I6');
         $objPHPExcel->getActiveSheet()->mergeCells('J5:J6');
         $objPHPExcel->getActiveSheet()->mergeCells('K5:K6');
         $objPHPExcel->getActiveSheet()->mergeCells('L5:O5');
         $objPHPExcel->getActiveSheet()->mergeCells('P5:R5');
         //$objPHPExcel->getActiveSheet()->mergeCells('R5:R6');
         $objPHPExcel->getActiveSheet()->mergeCells('S5:S6');
         $objPHPExcel->getActiveSheet()->mergeCells('T5:T6');
         $objPHPExcel->getActiveSheet()->mergeCells('U5:U6');
         $objPHPExcel->getActiveSheet()->mergeCells('V5:V6');
         $objPHPExcel->getActiveSheet()->mergeCells('W5:W6');
         $objPHPExcel->getActiveSheet()->mergeCells('X5:X6');
         $objPHPExcel->getActiveSheet()->setCellValue('A5', 'NO');
         $objPHPExcel->getActiveSheet()->setCellValue('B5', 'BAPAK ASUH');
         $objPHPExcel->getActiveSheet()->setCellValue('C5', 'PENGEMUDI');
         $objPHPExcel->getActiveSheet()->setCellValue('C6', 'NIP');
         $objPHPExcel->getActiveSheet()->setCellValue('D6', 'NAMA');
         $objPHPExcel->getActiveSheet()->setCellValue('E5', 'TANGGAL OPERASI');
         $objPHPExcel->getActiveSheet()->setCellValue('F5', 'STATUS');
         $objPHPExcel->getActiveSheet()->setCellValue('F6', 'OPS');
         $objPHPExcel->getActiveSheet()->setCellValue('G6', 'BS');
         $objPHPExcel->getActiveSheet()->setCellValue('H5', 'SETORAN MURNI');
         $objPHPExcel->getActiveSheet()->setCellValue('I5', 'TAB SPAREPART');
         $objPHPExcel->getActiveSheet()->setCellValue('J5', 'DENDA JAM');
         $objPHPExcel->getActiveSheet()->setCellValue('K5', 'DP SPAREPART');
         $objPHPExcel->getActiveSheet()->setCellValue('L5', 'BAYAR  CICILAN');
         $objPHPExcel->getActiveSheet()->setCellValue('L6', 'KS');
         $objPHPExcel->getActiveSheet()->setCellValue('M6', 'S-PART');
         $objPHPExcel->getActiveSheet()->setCellValue('N6', 'DP-KSO');
         $objPHPExcel->getActiveSheet()->setCellValue('O6', 'HUT-LAMA');
         $objPHPExcel->getActiveSheet()->setCellValue('P5', 'BAYAR');
         $objPHPExcel->getActiveSheet()->setCellValue('P6', 'STIKER BANDARA & KEAMANAN');
         $objPHPExcel->getActiveSheet()->setCellValue('Q6', 'CUCI');
         $objPHPExcel->getActiveSheet()->setCellValue('R6', 'LAKA');
         $objPHPExcel->getActiveSheet()->setCellValue('S5', 'HARUS SETOR');
         $objPHPExcel->getActiveSheet()->setCellValue('T5', 'POTONGAN');
         $objPHPExcel->getActiveSheet()->setCellValue('U5', 'SETOR CASH');
         $objPHPExcel->getActiveSheet()->setCellValue('V5', 'KETEKORAN');
         $objPHPExcel->getActiveSheet()->setCellValue('W5', 'SETORAN OPS');
         $objPHPExcel->getActiveSheet()->setCellValue('X5', 'SHIFT');
         $no = 1;
         $starline = 8;
         foreach ($financials as $finan) {
             $ks = abs($finan->setoran_cash - ($finan->setoran_wajib + $finan->tabungan_sparepart + $finan->denda + $finan->cicilan_sparepart + $finan->cicilan_ks + $finan->biaya_cuci + $finan->iuran_laka + $finan->cicilan_dp_kso + $finan->cicilan_hutang_lama + $finan->cicilan_lain + $finan->hutang_dp_sparepart - $finan->potongan));
             $bs = 'Tidak';
             if ($ks <= $finan->cicilan_ks) {
                 $bs = 'Ya';
             }
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $starline, $no);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $starline, '');
             //$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, $starline, $finan->nip);
             //$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $starline, $finan->name);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $starline, $finan->operasi_time);
             //$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $starline, $finan->kode);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $starline, $bs);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $starline, $finan->setoran_wajib);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(8, $starline, $finan->tabungan_sparepart);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(9, $starline, $finan->denda);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(10, $starline, $finan->hutang_dp_sparepart);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(11, $starline, $finan->cicilan_ks);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(12, $starline, $finan->cicilan_sparepart);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(13, $starline, $finan->cicilan_dp_kso);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(14, $starline, $finan->cicilan_hutang_lama);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(15, $starline, $finan->cicilan_lain);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(16, $starline, $finan->biaya_cuci);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(17, $starline, $finan->iuran_laka);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(18, $starline, '=SUM(H' . $starline . ':R' . $starline . ')');
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(19, $starline, $finan->potongan);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(20, $starline, $finan->setoran_cash);
             //$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(20, $starline, $finan->ks);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(21, $starline, '=(U' . $starline . '-(S' . $starline . '-T' . $starline . '))');
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(22, $starline, '=(U' . $starline . '-(Q' . $starline . '+R' . $starline . '))');
             //$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(23, $starline,  $finan->shift); //col X
             //$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(24, $starline, $finan->shift_id);
             //$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(14, $starline, $finan->cicilan_lain);
             //hidden coloumn status operasi
             //$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(25, $starline,  $finan->operasi_status_id); //col Z
             $no++;
             $starline++;
         }
         $objPHPExcel->getActiveSheet()->mergeCells('A' . ($starline + 1) . ':G' . ($starline + 1) . '');
         $objPHPExcel->getActiveSheet()->setCellValue('A' . ($starline + 1), 'TOTAL SETORAN ');
         $objPHPExcel->getActiveSheet()->setCellValue('H' . ($starline + 1), '=SUM(H8:H' . $starline . ')');
         $objPHPExcel->getActiveSheet()->setCellValue('I' . ($starline + 1), '=SUM(I8:I' . $starline . ')');
         $objPHPExcel->getActiveSheet()->setCellValue('J' . ($starline + 1), '=SUM(J8:J' . $starline . ')');
         $objPHPExcel->getActiveSheet()->setCellValue('K' . ($starline + 1), '=SUM(K8:K' . $starline . ')');
         $objPHPExcel->getActiveSheet()->setCellValue('L' . ($starline + 1), '=SUM(L8:L' . $starline . ')');
         $objPHPExcel->getActiveSheet()->setCellValue('M' . ($starline + 1), '=SUM(M8:M' . $starline . ')');
         $objPHPExcel->getActiveSheet()->setCellValue('N' . ($starline + 1), '=SUM(N8:N' . $starline . ')');
         $objPHPExcel->getActiveSheet()->setCellValue('O' . ($starline + 1), '=SUM(O8:O' . $starline . ')');
         $objPHPExcel->getActiveSheet()->setCellValue('P' . ($starline + 1), '=SUM(P8:P' . $starline . ')');
         $objPHPExcel->getActiveSheet()->setCellValue('Q' . ($starline + 1), '=SUM(Q8:Q' . $starline . ')');
         $objPHPExcel->getActiveSheet()->setCellValue('R' . ($starline + 1), '=SUM(R8:R' . $starline . ')');
         $objPHPExcel->getActiveSheet()->setCellValue('S' . ($starline + 1), '=SUM(S8:S' . $starline . ')');
         $objPHPExcel->getActiveSheet()->setCellValue('T' . ($starline + 1), '=SUM(T8:T' . $starline . ')');
         $objPHPExcel->getActiveSheet()->setCellValue('U' . ($starline + 1), '=SUM(U8:U' . $starline . ')');
         $objPHPExcel->getActiveSheet()->setCellValue('V' . ($starline + 1), '=SUM(V8:V' . $starline . ')');
         $objPHPExcel->getActiveSheet()->setCellValue('W' . ($starline + 1), '=SUM(W8:W' . $starline . ')');
         $objPHPExcel->getActiveSheet()->getStyle('A5:X' . ($starline + 1))->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_HAIR);
         $objPHPExcel->getActiveSheet()->getStyle('A5:X6')->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
         $objPHPExcel->getActiveSheet()->getStyle('A5:X' . ($starline + 1))->getBorders()->getOutline()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
         $objPHPExcel->getActiveSheet()->getStyle('A' . ($starline + 1) . ':X' . ($starline + 1))->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
         $objPHPExcel->getActiveSheet()->setTitle('Laporan KAS ' . date('d', strtotime($startdate)) . ' - ' . $date);
     } else {
         foreach ($jenis_kendaraan as $model) {
             //query export
             if ($shift_id == 'all') {
                 $financials = DB::table('financial_report_sum_all')->where('operasi_time', '>=', $startdate)->where('operasi_time', '<=', $date)->where('fleet_model_id', '=', $model->id)->where_pool_id(Auth::user()->pool_id)->order_by('operasi_time', 'asc')->get();
             } else {
                 $financials = DB::table('financial_report_sum')->where('shift_id', '=', $shift_id)->where('operasi_time', '>=', $startdate)->where('operasi_time', '<=', $date)->where('fleet_model_id', '=', $model->id)->where_pool_id(Auth::user()->pool_id)->order_by('operasi_time', 'asc')->get();
             }
             $objPHPExcel->createSheet(NULL, $sheet_active);
             $objPHPExcel->setActiveSheetIndex($sheet_active);
             $objPHPExcel->getActiveSheet()->mergeCells('A2:X2');
             $objPHPExcel->getActiveSheet()->setCellValue('A2', 'LAPORAN PENDAPATAN PERIODE TANGGAL ' . Myfungsi::fulldate(strtotime($startdate)) . ' - ' . Myfungsi::fulldate(strtotime($date)) . ' ' . $model->fleet_model);
             $objPHPExcel->getActiveSheet()->getStyle('A2')->applyFromArray($styleArray);
             $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setVisible(false);
             $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false);
             $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
             $objPHPExcel->getActiveSheet()->mergeCells('A5:A6');
             $objPHPExcel->getActiveSheet()->mergeCells('B5:B6');
             $objPHPExcel->getActiveSheet()->mergeCells('C5:D5');
             $objPHPExcel->getActiveSheet()->mergeCells('E5:E6');
             $objPHPExcel->getActiveSheet()->mergeCells('F5:G5');
             $objPHPExcel->getActiveSheet()->mergeCells('H5:H6');
             $objPHPExcel->getActiveSheet()->mergeCells('I5:I6');
             $objPHPExcel->getActiveSheet()->mergeCells('J5:J6');
             $objPHPExcel->getActiveSheet()->mergeCells('K5:K6');
             $objPHPExcel->getActiveSheet()->mergeCells('L5:O5');
             $objPHPExcel->getActiveSheet()->mergeCells('P5:R5');
             //$objPHPExcel->getActiveSheet()->mergeCells('R5:R6');
             $objPHPExcel->getActiveSheet()->mergeCells('S5:S6');
             $objPHPExcel->getActiveSheet()->mergeCells('T5:T6');
             $objPHPExcel->getActiveSheet()->mergeCells('U5:U6');
             $objPHPExcel->getActiveSheet()->mergeCells('V5:V6');
             $objPHPExcel->getActiveSheet()->mergeCells('W5:W6');
             $objPHPExcel->getActiveSheet()->mergeCells('X5:X6');
             $objPHPExcel->getActiveSheet()->setCellValue('A5', 'NO');
             $objPHPExcel->getActiveSheet()->setCellValue('B5', 'BAPAK ASUH');
             $objPHPExcel->getActiveSheet()->setCellValue('C5', 'PENGEMUDI');
             $objPHPExcel->getActiveSheet()->setCellValue('C6', 'NIP');
             $objPHPExcel->getActiveSheet()->setCellValue('D6', 'NAMA');
             $objPHPExcel->getActiveSheet()->setCellValue('E5', 'TANGGAL OPERASI');
             $objPHPExcel->getActiveSheet()->setCellValue('F5', 'STATUS');
             $objPHPExcel->getActiveSheet()->setCellValue('F6', 'OPS');
             $objPHPExcel->getActiveSheet()->setCellValue('G6', 'BS');
             $objPHPExcel->getActiveSheet()->setCellValue('H5', 'SETORAN MURNI');
             $objPHPExcel->getActiveSheet()->setCellValue('I5', 'TAB SPAREPART');
             $objPHPExcel->getActiveSheet()->setCellValue('J5', 'DENDA JAM');
             $objPHPExcel->getActiveSheet()->setCellValue('K5', 'DP SPAREPART');
             $objPHPExcel->getActiveSheet()->setCellValue('L5', 'BAYAR  CICILAN');
             $objPHPExcel->getActiveSheet()->setCellValue('L6', 'KS');
             $objPHPExcel->getActiveSheet()->setCellValue('M6', 'S-PART');
             $objPHPExcel->getActiveSheet()->setCellValue('N6', 'DP-KSO');
             $objPHPExcel->getActiveSheet()->setCellValue('O6', 'HUT-LAMA');
             $objPHPExcel->getActiveSheet()->setCellValue('P5', 'BAYAR');
             $objPHPExcel->getActiveSheet()->setCellValue('P6', 'STIKER BANDARA & KEAMANAN');
             $objPHPExcel->getActiveSheet()->setCellValue('Q6', 'CUCI');
             $objPHPExcel->getActiveSheet()->setCellValue('R6', 'LAKA');
             $objPHPExcel->getActiveSheet()->setCellValue('S5', 'HARUS SETOR');
             $objPHPExcel->getActiveSheet()->setCellValue('T5', 'POTONGAN');
             $objPHPExcel->getActiveSheet()->setCellValue('U5', 'SETOR CASH');
             $objPHPExcel->getActiveSheet()->setCellValue('V5', 'KETEKORAN');
             $objPHPExcel->getActiveSheet()->setCellValue('W5', 'SETORAN OPS');
             $objPHPExcel->getActiveSheet()->setCellValue('X5', 'SHIFT');
             $no = 1;
             $starline = 8;
             foreach ($financials as $finan) {
                 $ks = abs($finan->setoran_cash - ($finan->setoran_wajib + $finan->tabungan_sparepart + $finan->denda + $finan->cicilan_sparepart + $finan->cicilan_ks + $finan->biaya_cuci + $finan->iuran_laka + $finan->cicilan_dp_kso + $finan->cicilan_hutang_lama + $finan->cicilan_lain + $finan->hutang_dp_sparepart - $finan->potongan));
                 $bs = 'Tidak';
                 if ($ks <= $finan->cicilan_ks) {
                     $bs = 'Ya';
                 }
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $starline, $no);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $starline, '');
                 //$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, $starline, $finan->nip);
                 //$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $starline, $finan->name);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $starline, $finan->operasi_time);
                 //$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $starline, $finan->kode);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $starline, $bs);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $starline, $finan->setoran_wajib);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(8, $starline, $finan->tabungan_sparepart);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(9, $starline, $finan->denda);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(10, $starline, $finan->hutang_dp_sparepart);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(11, $starline, $finan->cicilan_ks);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(12, $starline, $finan->cicilan_sparepart);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(13, $starline, $finan->cicilan_dp_kso);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(14, $starline, $finan->cicilan_hutang_lama);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(15, $starline, $finan->cicilan_lain);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(16, $starline, $finan->biaya_cuci);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(17, $starline, $finan->iuran_laka);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(18, $starline, '=SUM(H' . $starline . ':R' . $starline . ')');
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(19, $starline, $finan->potongan);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(20, $starline, $finan->setoran_cash);
                 //$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(20, $starline, $finan->ks);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(21, $starline, '=(U' . $starline . '-(S' . $starline . '-T' . $starline . '))');
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(22, $starline, '=(U' . $starline . '-(Q' . $starline . '+R' . $starline . '))');
                 //$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(23, $starline,  $finan->shift); //col X
                 //$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(24, $starline, $finan->shift_id);
                 //$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(14, $starline, $finan->cicilan_lain);
                 //hidden coloumn status operasi
                 //$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(25, $starline,  $finan->operasi_status_id); //col Z
                 $no++;
                 $starline++;
             }
             $objPHPExcel->getActiveSheet()->mergeCells('A' . ($starline + 1) . ':G' . ($starline + 1) . '');
             $objPHPExcel->getActiveSheet()->setCellValue('A' . ($starline + 1), 'TOTAL SETORAN ');
             $objPHPExcel->getActiveSheet()->setCellValue('H' . ($starline + 1), '=SUM(H8:H' . $starline . ')');
             $objPHPExcel->getActiveSheet()->setCellValue('I' . ($starline + 1), '=SUM(I8:I' . $starline . ')');
             $objPHPExcel->getActiveSheet()->setCellValue('J' . ($starline + 1), '=SUM(J8:J' . $starline . ')');
             $objPHPExcel->getActiveSheet()->setCellValue('K' . ($starline + 1), '=SUM(K8:K' . $starline . ')');
             $objPHPExcel->getActiveSheet()->setCellValue('L' . ($starline + 1), '=SUM(L8:L' . $starline . ')');
             $objPHPExcel->getActiveSheet()->setCellValue('M' . ($starline + 1), '=SUM(M8:M' . $starline . ')');
             $objPHPExcel->getActiveSheet()->setCellValue('N' . ($starline + 1), '=SUM(N8:N' . $starline . ')');
             $objPHPExcel->getActiveSheet()->setCellValue('O' . ($starline + 1), '=SUM(O8:O' . $starline . ')');
             $objPHPExcel->getActiveSheet()->setCellValue('P' . ($starline + 1), '=SUM(P8:P' . $starline . ')');
             $objPHPExcel->getActiveSheet()->setCellValue('Q' . ($starline + 1), '=SUM(Q8:Q' . $starline . ')');
             $objPHPExcel->getActiveSheet()->setCellValue('R' . ($starline + 1), '=SUM(R8:R' . $starline . ')');
             $objPHPExcel->getActiveSheet()->setCellValue('S' . ($starline + 1), '=SUM(S8:S' . $starline . ')');
             $objPHPExcel->getActiveSheet()->setCellValue('T' . ($starline + 1), '=SUM(T8:T' . $starline . ')');
             $objPHPExcel->getActiveSheet()->setCellValue('U' . ($starline + 1), '=SUM(U8:U' . $starline . ')');
             $objPHPExcel->getActiveSheet()->setCellValue('V' . ($starline + 1), '=SUM(V8:V' . $starline . ')');
             $objPHPExcel->getActiveSheet()->setCellValue('W' . ($starline + 1), '=SUM(W8:W' . $starline . ')');
             $objPHPExcel->getActiveSheet()->getStyle('A5:X' . ($starline + 1))->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_HAIR);
             $objPHPExcel->getActiveSheet()->getStyle('A5:X6')->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objPHPExcel->getActiveSheet()->getStyle('A5:X' . ($starline + 1))->getBorders()->getOutline()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objPHPExcel->getActiveSheet()->getStyle('A' . ($starline + 1) . ':X' . ($starline + 1))->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
             $objPHPExcel->getActiveSheet()->setTitle('Laporan KAS ' . date('d', strtotime($startdate)) . ' - ' . $date);
             $sheet_active++;
         }
     }
     //end if gabungan
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
     $objWriter->save(path('public') . 'Laporan-KAS-' . Pool::find(Auth::user()->pool_id)->pool_name . '.xls');
     return Response::download(path('public') . 'Laporan-KAS-' . Pool::find(Auth::user()->pool_id)->pool_name . '.xls', 'Laporan-KAS-' . Pool::find(Auth::user()->pool_id)->pool_name . '.xls');
 }
Ejemplo n.º 10
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.º 11
0
 public function post_saveCheckFisik()
 {
     Log::write('info', Request::ip() . ' User : '******' Event: Save Checkin', true);
     $data = Input::json();
     $id = $data->id;
     $docs_ket = $data->std_docs;
     $neats = $data->std_neats;
     $equips = $data->std_equips;
     $sp_kets = $data->ket_sp;
     $checkin = Checkin::find($id);
     //$checkin->operasi_status_id = $data->status_ops;
     $checkin->save();
     $docs = array();
     foreach (Stddoc::all() as $doc) {
         array_push($docs, $doc->id);
     }
     $sps = array();
     foreach (Stdfleet::all() as $sp) {
         array_push($sps, $sp->id);
     }
     $fg_bengkel = $data->hasilcheckfisik == 2 ? 1 : 0;
     $cin = Checkindocument::where_checkin_id($id)->first();
     $cpy = Checkinphysic::where_checkin_id($id)->first();
     if (!$cpy) {
         $cpy = Checkinphysic::create(array('checkin_id' => $id));
     }
     if ($cin->operasi_time > date('Y-m-d', Myfungsi::sysdate())) {
         $datax['message'] = 'invalide time';
     } else {
         $cin->std_neats_id = implode(",", $neats);
         $cin->std_document_id = implode(",", $docs);
         $cin->ket = implode(",", $docs_ket);
         $cin->std_equip_id = implode(",", $equips);
         $cin->save();
         //save pysicly
         $cpy->sparepart_id = implode(",", $sps);
         $cpy->ket = implode(",", $sp_kets);
         $cpy->save();
         //update jika perlu berbaikan
         $fl = Fleet::find($checkin->fleet_id);
         $fl->fg_bengkel = $fg_bengkel;
         $fl->save();
         $datax['message'] = 'Data Saved';
     }
     return json_encode($datax);
 }
Ejemplo n.º 12
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));
         }
     }
 }