Ejemplo n.º 1
0
 function testSave()
 {
     //Arrange
     $copy_id = 1;
     $patron_id = 1;
     $id = 1;
     $due_date = '2015-10-10';
     $test_checkout = new Checkout($copy_id, $patron_id, $due_date, $id);
     $test_checkout->save();
     //Act
     $result = Checkout::getAll();
     //Assert
     $this->assertEquals($test_checkout, $result[0]);
 }
Ejemplo n.º 2
0
 function test_find()
 {
     //Arrange
     $due_date = "0001-01-01";
     $test_checkout = new Checkout($due_date);
     $test_checkout->save();
     $due_date2 = "2020-01-01";
     $test_checkout2 = new Checkout($due_date2);
     $test_checkout2->save();
     //Act
     $result = Checkout::find($test_checkout->getId());
     //Assert
     $this->assertEquals($test_checkout, $result);
 }
Ejemplo n.º 3
0
 function test_getCheckouts()
 {
     //Arrange
     $name = "Jerald the crotchety grandpa";
     $test_patron = new Patron($name);
     $test_patron->save();
     $checked_in_status = 0;
     $due_date = "1234-12-12";
     $copy_id = 5;
     $new_checkout = new Checkout($checked_in_status, $due_date, $copy_id, $test_patron->getId());
     $new_checkout->save();
     //Act
     $result = $test_patron->getCheckouts();
     //Assert
     $this->assertEquals([$new_checkout], $result);
 }
Ejemplo n.º 4
0
 function testAddCheckout()
 {
     $title = "Three Blind Mice";
     $test_book = new Book($title);
     $test_book->save();
     $test_copy = new Copy($amount = 1, $test_book->getId());
     $test_copy->save();
     $name = "Joe Bongtana";
     $test_patron = new Patron($name);
     $test_patron->save();
     $due_date = "01-01-2016";
     $status = 1;
     $test_checkout = new Checkout($test_copy->getId(), $test_patron->getId(), $due_date, $status);
     $test_checkout->save();
     $test_patron->addCheckout($test_checkout);
     $result = Checkout::getAll();
     $this->assertEquals($test_checkout, $result);
 }
Ejemplo n.º 5
0
 function test_deleteAll()
 {
     //Arrange
     $copy_id = 1;
     $patron_id = 4;
     $due_date = "2015-09-03";
     $test_checkout = new Checkout($copy_id, $patron_id, $due_date);
     $test_checkout->save();
     $copy_id2 = 2;
     $patron_id2 = 1;
     $due_date2 = "2015-10-05";
     $test_checkout2 = new Checkout($copy_id2, $patron_id2, $due_date2);
     $test_checkout2->save();
     //Act
     Checkout::deleteAll();
     //Assert
     $result = Checkout::getAll();
     $this->assertEquals([], $result);
 }
Ejemplo n.º 6
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.º 7
0
 function test_updateDueDate()
 {
     //Arrange
     $due_date = "0001-01-01";
     $copy_id = 1;
     $patron_id = 2;
     $test_checkout = new Checkout($due_date, $copy_id, $patron_id);
     $test_checkout->save();
     $new_due_date = "2015-11-11";
     $test_checkout->updateDueDate($new_due_date);
     //Act
     $id = $test_checkout->getId();
     $result = new Checkout($new_due_date, $copy_id, $patron_id, $id);
     //Assert
     $this->assertEquals(Checkout::findDueDate($id), $result);
 }
Ejemplo n.º 8
0
 function test_updateDueDate()
 {
     //Arrange
     // Make a Patron
     $name = "Dan Brown";
     $phone = "3";
     $email = "*****@*****.**";
     $test_patron = new Patron($name, $phone, $email);
     $test_patron->save();
     // Make a Checkout and save
     $patron_id = $test_patron->getId();
     $copy_id = 1;
     $due_date = "2015-08-09";
     $test_checkout = new Checkout($patron_id, $copy_id, $due_date);
     $test_checkout->save();
     $new_due_date = "2015-08-27";
     //Act
     $test_checkout->updateDueDate($new_due_date);
     //Assert
     $result = $test_checkout->getDueDate();
     $this->assertEquals($new_due_date, $result);
 }
Ejemplo n.º 9
0
 function test_getAll()
 {
     // for now, feed a dummy copy_id just for testing
     // later, we will need to use getNextCopy() in Book class
     // to get a copy for a given book
     //Arrange
     // Make a Patron
     $name = "Dan Brown";
     $phone = "3";
     $email = "*****@*****.**";
     $test_patron = new Patron($name, $phone, $email);
     $test_patron->save();
     // Make a Checkout and save
     $patron_id = $test_patron->getId();
     $copy_id = 1;
     $date = "2015-08-09";
     $test_checkout = new Checkout($patron_id, $copy_id, $date);
     $test_checkout->save();
     // Make a 2nd Checkout and save under the same patron
     $copy_id2 = 1;
     $date2 = "2015-08-09";
     $test_checkout2 = new Checkout($patron_id, $copy_id2, $date2);
     $test_checkout2->save();
     //Act
     $result = Checkout::getAll();
     //Assert
     $this->assertEquals([$test_checkout, $test_checkout2], $result);
 }
Ejemplo n.º 10
0
 function testCheckIn()
 {
     $patron_name = "Randy Mclure";
     $test_patron = new Patron($patron_name);
     $test_patron->save();
     $due_date = "2015-09-10";
     $copy_id = 1;
     $patron_id = 1;
     $checkin_status = 1;
     $test_checkout = new Checkout($due_date, $copy_id, $test_patron->getId(), $checkin_status);
     $test_checkout->save($test_patron);
     $test_checkout->checkIn();
     $result = $test_checkout->getCheckinStatus();
     $this->assertEquals(1, $result);
 }
 function testFind()
 {
     //Arrange
     $id = null;
     $patron_id = 1;
     $copy_id = 1;
     $due_date = "2012-12-12";
     $test_checkout = new Checkout($id, $patron_id, $copy_id, $due_date);
     $test_checkout->save();
     $patron_id2 = 1;
     $copy_id2 = 1;
     $due_date2 = "1989-09-04";
     $test_checkout2 = new Checkout($id, $patron_id2, $copy_id2, $due_date2);
     $test_checkout2->save();
     //Act
     $result = Checkout::find($test_checkout->getId());
     //Assert
     $this->assertEquals($test_checkout, $result);
 }
Ejemplo n.º 12
0
    $author = $book->getAuthors();
    $copies = Copy::findCopies($id);
    return $app['twig']->render('book.html.twig', array('book' => $book, 'author' => $author, 'copies' => $copies, 'patrons' => Patron::getAll(), 'checkouts' => Checkout::getAll()));
});
$app->post("/add_copy", function () use($app) {
    $book_id = $_POST['book_id'];
    $book = Book::find($book_id);
    $author = $book->getAuthors();
    $copy = new Copy($book_id);
    $copy->save();
    $copies = Copy::findCopies($book_id);
    return $app['twig']->render('book.html.twig', array('book' => $book, 'author' => $author, 'copies' => $copies, 'patrons' => Patron::getAll(), 'checkouts' => Checkout::getAll()));
});
$app->patch("/checkout_copy/{id}", function ($id) use($app) {
    $checkout = new Checkout($_POST['copy_id'], $_POST['patron_id'], $_POST['due_date']);
    $checkout->save();
    $book_id = $_POST['book_id'];
    $book = Book::find($book_id);
    $author = $book->getAuthors();
    return $app['twig']->render('book.html.twig', array('book' => $book, 'author' => $author, 'copies' => Copy::getAll(), 'patrons' => Patron::getAll(), 'checkouts' => Checkout::getAll()));
});
// $app->patch("/checkout_copy/{id}", function($id) use ($app) {
//     $book = Book::find($id);
//     $author = $book->getAuthors();
//     $copy_id = $_POST['copy_id'];
//     $copy = Copy::find($copy_id);
//     //$checkout = new Checkout($copy_id, $)
//     $copy->update($_POST['due_date']);
//     $copies = Copy::findCopies($id);
//     return $app['twig']->render('book.html.twig', array('book'=>$book, 'author'=>$author, 'copies'=> $copies, 'patrons'=>Patron::getAll()));
// });
Ejemplo n.º 13
0
 function test_getPatron()
 {
     //Arrange
     $name = "Phyllis the kind Grandma";
     $test_patron = new Patron($name);
     $test_patron->save();
     $checked_in_status = 0;
     $due_date = "2000 BC";
     $copy_id = 1;
     $test_checkout = new Checkout($checked_in_status, $due_date, $copy_id, $test_patron->getId());
     $test_checkout->save();
     //Act
     $result = $test_checkout->getPatron();
     //Assert
     $this->assertEquals($test_patron, $result);
 }
Ejemplo n.º 14
0
 function test_updateReturned()
 {
     //Arrange
     $copy_id = 1;
     $patron_id = 4;
     $due_date = "2015-09-03";
     $test_checkout = new Checkout($copy_id, $patron_id, $due_date);
     $test_checkout->save();
     //Act
     $new_returned = true;
     $test_checkout->updateReturned($new_returned);
     //Assert
     $result = Checkout::getAll();
     $this->assertEquals($new_returned, $result[0]->getReturned());
 }
Ejemplo n.º 15
0
 function testGetCurrentCheckouts()
 {
     $patron_name = "Randy Mclure";
     $test_patron = new Patron($patron_name);
     $test_patron->save();
     $due_date = null;
     $copy_id = 1;
     $checkin_status = 1;
     $test_checkout = new Checkout($due_date, $copy_id, $test_patron->getId(), $checkin_status);
     $test_checkout->save($test_patron, $due_date);
     $test_checkout->checkIn();
     $due_date2 = null;
     $copy_id2 = 2;
     $checkin_status2 = 0;
     $test_checkout2 = new Checkout($due_date2, $copy_id2, $test_patron->getId(), $checkin_status2);
     $test_checkout2->save($test_patron);
     $result = $test_patron->getCurrentCheckouts();
     $this->assertEquals([$test_checkout2], $result);
 }
Ejemplo n.º 16
0
 function testGetCheckouts()
 {
     //Arrange
     $name = "Jim Bob";
     $id = 1;
     $test_patron = new Patron($name, $id);
     $test_patron->save();
     $book_id = 1;
     $id = 1;
     $test_copy = new Copy($book_id, $id);
     $test_copy->save();
     $book_id2 = 2;
     $id2 = 2;
     $test_copy2 = new Copy($book_id2, $id2);
     $test_copy2->save();
     $copy_id = $test_copy->getId();
     $patron_id = $test_patron->getId();
     $id = null;
     $due_date = "2015-09-30";
     $test_checkout = new Checkout($copy_id, $patron_id, $due_date, $id);
     $test_checkout->save();
     // $copy_id2 = $test_copy2->getId();
     // $patron_id2 = $test_patron->getId();
     // $id2 = null;
     // $due_date2 = "2015-09-30";
     // $test_checkout2 = new Checkout($copy_id2, $patron_id2, $id2, $due_date2);
     $copy_id2 = $test_copy2->getId();
     $patron_id2 = $test_patron->getId();
     $id2 = null;
     $due_date2 = "2015-04-20";
     $test_checkout2 = new Checkout($copy_id2, $patron_id2, $due_date2, $id2);
     $test_checkout2->save();
     // var_dump($test_checkout);
     // var_dump($test_checkout2);
     //Act
     // $test_patron->addCheckout($test_checkout);
     // $test_patron->addCheckout($test_checkout2);
     $result = $test_patron->getCheckouts();
     // var_dump($result);
     //Assert
     $this->assertEquals(2, count($test_patron->getCheckouts()));
 }
Ejemplo n.º 17
0
 function test_getCheckout()
 {
     //Arrange
     $book_id = 4;
     $test_copy = new Copy($book_id);
     $test_copy->save();
     $checked_in_status = 0;
     $due_date = "1234-12-12";
     $patron_id = 4;
     $new_checkout = new Checkout($checked_in_status, $due_date, $test_copy->getId(), $patron_id);
     $new_checkout->save();
     //Act
     $result = $test_copy->getCheckout();
     //Assert
     $this->assertEquals($new_checkout, $result);
 }
Ejemplo n.º 18
0
 function testUpdateCheckOutStatus()
 {
     $copy_id = 1;
     $patron_id = 1;
     $checkout_status = 0;
     $due_date = "2015-01-01";
     $test_checkout = new Checkout($patron_id, $copy_id, $due_date, $checkout_status);
     $test_checkout->save();
     $test_checkout->updateCheckOutStatus(1);
     $result = $test_checkout->getCheckOutStatus();
     $this->assertEquals(1, $result);
 }
Ejemplo n.º 19
0
 function test_getAllCheckouts()
 {
     //Arrange
     // create 2 test patrons.
     $name = "Suzie Palloozi";
     $phone = "1-800-439-0398";
     $test_patron = new Patron($name, $phone);
     $test_patron->save();
     // create 2 test checkouts. hard code copy_id for now
     $copy_id = 1;
     $patron_id = $test_patron->getId();
     $due_date = "2015-03-04";
     $test_checkout = new Checkout($copy_id, $patron_id, $due_date);
     $test_checkout->save();
     //Act
     $result = $test_patron->getAllCheckouts();
     //Assert
     $this->assertEquals([$test_checkout], $result);
 }
Ejemplo n.º 20
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));
         }
     }
 }