} catch (Exception $e) { /* Images not supported on your PHP, or image file not found */ $printer->text($e->getMessage() . "\n"); } $printer->cut(); /* Bit image */ try { $logo = new EscposImage("resources/escpos-php.png"); $imgModes = array(Escpos::IMG_DEFAULT, Escpos::IMG_DOUBLE_WIDTH, Escpos::IMG_DOUBLE_HEIGHT, Escpos::IMG_DOUBLE_WIDTH | Escpos::IMG_DOUBLE_HEIGHT); foreach ($imgModes as $mode) { $printer->bitImage($logo, $mode); } } catch (Exception $e) { /* Images not supported on your PHP, or image file not found */ $printer->text($e->getMessage() . "\n"); } $printer->cut(); /* QR Code - see also the more in-depth demo at qr-code.php */ $testStr = "Testing 123"; $models = array(Escpos::QR_MODEL_1 => "QR Model 1", Escpos::QR_MODEL_2 => "QR Model 2 (default)", Escpos::QR_MICRO => "Micro QR code\n(not supported on all printers)"); foreach ($models as $model => $name) { $printer->qrCode($testStr, Escpos::QR_ECLEVEL_L, 3, $model); $printer->text("{$name}\n"); $printer->feed(); } $printer->cut(); /* Pulse */ $printer->pulse(); /* Always close the printer! On some PrintConnectors, no actual * data is sent until the printer is closed. */ $printer->close();
function outprint($receipt, $pname, $noplate, $containerno, $invoiceno, $intime, $outtime, $hours, $charges) { require_once "assets/escpos-php/Escpos.php"; try { // Enter the share name for your USB printer here $connector = new WindowsPrintConnector("epson"); $printer = new Escpos($connector); /* Print top logo */ $printer->setJustification(Escpos::JUSTIFY_CENTER); /* Name of shop */ $printer->selectPrintMode(Escpos::MODE_DOUBLE_WIDTH); $printer->text("BILL/OUTPASS \n"); $printer->text("\nNhavaSheva toll plaza\n"); $printer->text("Operated By\n"); $printer->text("Shree Sai Samartha\n"); $printer->text("Enterprises Pay & Park\n"); $printer->selectPrintMode(); $printer->feed(); /* Title of receipt */ /* Items */ $printer->setJustification(Escpos::JUSTIFY_LEFT); $printer->setEmphasis(true); $printer->setTextSize(2, 1); $printer->text("RECEIPT NO :" . $receipt . "\n"); $printer->feed(); $printer->setTextSize(2, 1); $printer->text("V. TYPE :" . $pname . "\n"); $printer->setTextSize(2, 2); $printer->text("V.NO :" . $noplate . "\n"); $printer->feed(); $printer->setTextSize(2, 1); /*$printer -> text("IN DT:".date('d/m/y',strtotime($intime))."TM:".date('h:i:s',strtotime($intime))."\n");*/ $printer->text("IN :" . date('Y-m-d', strtotime($intime)) . " " . date('h:i:s', strtotime($intime)) . "\n"); $printer->text("OUT :" . date('Y-m-d', strtotime($outtime)) . " " . date('h:i:s', strtotime($outtime)) . "\n"); $printer->feed(); $printer->text("DURATION : " . $hours . "\n"); $printer->setTextSize(2, 2); $printer->feed(); $printer->text("AMOUNT : " . $charges); $printer->setTextSize(1, 1); $printer->setEmphasis(false); $printer->setEmphasis(true); $printer->setEmphasis(false); $printer->feed(); /* Tax and total */ /* Footer */ $printer->feed(1); $printer->setJustification(Escpos::JUSTIFY_CENTER); $printer->text("THANK YOU! VISIT AGAIN!\n"); //$printer -> feed(1); //$printer -> text(date('l jS \of F Y h:i:s A') . "\n"); /* Cut the receipt and open the cash drawer */ $printer->cut(); $printer->pulse(); $printer->close(); } catch (Exception $e) { echo "Couldn't print to this printer: " . $e->getMessage() . "\n"; } /* A wrapper to do organise item names & prices into columns */ /* Close printer */ }
function vehicle_print($data) { require_once "assets/escpos-php/Escpos.php"; try { // Enter the share name for your USB printer here $connector = new WindowsPrintConnector("epson"); $printer = new Escpos($connector); $age = array("Monday" => "35", "Tuesday" => "37", "Wednesday" => "43"); $day = jddayofweek(cal_to_jd(CAL_GREGORIAN, date("m"), date("d"), date("Y")), 1); /* Print top logo */ /*print report start*/ $exceldata = ""; $t_charges = 0; $total_hours = 0; foreach ($data->result_array() as $row) { $pid = $row['pid']; $vtype = $row['name']; $noplate = $row['noplate']; $intime = $row['intime']; if ($row['status'] == 0) { $status = 'IN'; } if ($row['status'] == 1) { $status = 'OUT'; } if (isset($row['outtime'])) { $outtime = $row['outtime']; $new_hours = $row['hours']; $total_charges = $row['charges']; } else { $in = $row['intime']; $out = date('Y-m-d H:i:s', time()); $hour1 = 0; $hour2 = 0; $date1 = $in; $date2 = $out; $datetimeObj1 = new DateTime($date1); $datetimeObj2 = new DateTime($date2); $interval = $datetimeObj1->diff($datetimeObj2); if ($interval->format('%a') > 0) { $hour1 = $interval->format('%a') * 24; } if ($interval->format('%h') > 0) { $hour2 = $interval->format('%h'); } $hrs = $hour1 + $hour2; $hrs = sprintf("%02d", $hrs); $minutes = $interval->format('%i'); $minutes = sprintf("%02d", $minutes); $secs = $interval->format('%s'); $secs = sprintf("%02d", $secs); $new_hours = $hrs . ":" . $minutes . ":" . $secs; $sql = "select charges from charges where typeid = (select id from parktype where name = '{$vtype}' )"; $query = $this->db->query($sql); $result = $query->result(); $result1 = array(); foreach ($result as $key => $value) { $result1['charges'] = $value->charges; } $charges = $result1['charges']; $tot_str = $hrs . '.' . $minutes; $hour_in_float = (double) $tot_str; $total_charges = ceil($hour_in_float / 8) * $charges; } $to_seconds = $this->time_to_seconds($new_hours); /*******total hours calculation*****/ $total_hours = $total_hours + $to_seconds; $hours = floor($total_hours / (60 * 60)); $divisor_for_minutes = $total_hours % (60 * 60); $minutes = floor($divisor_for_minutes / 60); // extract the remaining seconds $divisor_for_seconds = $divisor_for_minutes % 60; $seconds = ceil($divisor_for_seconds); $t_hours_sec = (int) $hours . ':' . (int) $minutes . ':' . (int) $seconds; /***********average hours calculation*********/ $ave_hours = $total_hours / count($data->result_array()); $hours = floor($ave_hours / (60 * 60)); $divisor_for_minutes = $ave_hours % (60 * 60); $minutes = floor($divisor_for_minutes / 60); $divisor_for_seconds = $divisor_for_minutes % 60; $seconds = ceil($divisor_for_seconds); $ave_sec = (int) $hours . ':' . (int) $minutes . ':' . (int) $seconds; /*****************/ $exceldata[] = array($pid, $vtype, $noplate, $intime, $row['outtime'], $new_hours, $total_charges, $status); $charges = $total_charges; $charges_t = $charges_t + $charges; $ii = 1; $objPHPExcel->getActiveSheet()->getStyle('A' . $ii . ':H' . $ii)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT); $ii++; } $exceldata[] = array('', 'TOTAl :' . count($data->result_array()), 'Total Hours :', $t_hours_sec, 'average hours :', $ave_sec, 'Total Charges :', $charges_t); //$exceldata[] = array('','','','','','average hours :'.$ave_sec,'',''); $excel_c = count($data->result_array()) + 4; /*for($col = ord('A'.$excel_c); $col <= ord('F'.$excel_c); $col++){ $objPHPExcel->getActiveSheet()->getStyle(chr($col))->getFont()->setSize(14); $objPHPExcel->getActiveSheet()->getStyle(chr($col))->getFont()->setBold(true); $objPHPExcel->getActiveSheet()->getStyle(chr($col))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); }*/ //$objPHPExcel->getActiveSheet()->getColumnDimension('G'.$excel_c)->setWidth(20); $objPHPExcel->getActiveSheet()->getRowDimension($excel_c)->setRowHeight(20); $objPHPExcel->getActiveSheet()->getStyle('A' . $excel_c . ':H' . $excel_c)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID); $objPHPExcel->getActiveSheet()->getStyle('A' . $excel_c . ':H' . $excel_c)->getFill()->getStartColor()->setARGB('29bb04'); $objPHPExcel->getActiveSheet()->getStyle('A' . $excel_c . ':H' . $excel_c)->getFont()->setSize(14); $objPHPExcel->getActiveSheet()->getStyle('A' . $excel_c . ':H' . $excel_c)->getFont()->setBold(true); $objPHPExcel->getActiveSheet()->getStyle('A' . $excel_c . ':H' . $excel_c)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); //Fill data $objPHPExcel->getActiveSheet()->fromArray($exceldata, null, 'A4'); /*print report end*/ $printer->setJustification(Escpos::JUSTIFY_CENTER); /* Name of shop */ $printer->selectPrintMode(Escpos::MODE_DOUBLE_WIDTH); $printer->text("RECEIPT\n"); $printer->text("\nNhavaSheva toll plaza\n"); $printer->text("Operated By\n"); $printer->text("Shree Sai Samartha\n"); $printer->text("Enterprises Pay & Park\n"); $printer->selectPrintMode(); $printer->feed(); /* Title of receipt */ /* Items */ $printer->setJustification(Escpos::JUSTIFY_LEFT); $printer->setEmphasis(true); $printer->setTextSize(2, 1); $rr = "RECEIPT NO :" . $receipt . "\n"; $printer->text($rr); //$printer -> feed(); $printer->text("V. TYPE :" . $parktype . "\n"); $printer->feed(); $printer->setTextSize(2, 2); $printer->text("V.NO :" . $noplate . "\n"); $printer->text("CO. NO :" . $containerno . "\n"); $printer->text("VO. NO :" . $invoiceno . "\n"); //$printer -> feed(); //$printer -> setTextSize(2,1); $printer->text("IN DT :" . date('d/m/Y', strtotime($intime)) . "\n"); $printer->text("IN TM :" . date('h:i:s', strtotime($intime)) . "\n"); $printer->setTextSize(2, 2); $printer->setTextSize(1, 1); $printer->setEmphasis(false); $printer->feed(); /* Tax and total */ /* Footer */ //$printer -> feed(1); $printer->setJustification(Escpos::JUSTIFY_CENTER); $printer->text("PARKING AT OWNERS RISK. MANAGEMENT IS NOT LIABLE\n"); $printer->text("TO PAY ANY LOSS OR DAMAGE OF ANY VEHICLE OR\n"); $printer->text("VALUABLE LEFT INSIDE IT\n"); //$printer -> feed(1); //$printer -> text(date('l jS \of F Y h:i:s A') . "\n"); /* Cut the receipt and open the cash drawer */ $printer->cut(); $printer->pulse(); $printer->close(); } catch (Exception $e) { echo "Couldn't print to this printer: " . $e->getMessage() . "\n"; } /* A wrapper to do organise item names & prices into columns */ /* Close printer */ }