function print_receipt($id) { $struk = $this->menu_model->getStruks(array('where' => array('pembayaran.id_order' => $id))); $conf = $this->office_model->get_config_resto(); require_once dirname(__FILE__) . "/Escpos.php"; $fp = fopen("/dev/usb/lp1", "w"); $printer = new Escpos($fp); $printer->lineSpacing(19); $printer->setJustification(1); $printer->text($conf->row('nama_resto') . "\n"); $printer->text($conf->row('alamat_resto') . "\n"); $printer->text($conf->row('telephone') . $hp . "\n"); $printer->setJustification(); $printer->text("\n"); $printer->text("No. Meja : " . $struk->row('no_meja') . " || Nama : " . $struk->row('nama_konsumen') . "\n"); $printer->text("----------------------------------------"); $printer->text("Nama Menu Jml Harga SubTot\n"); $printer->text("----------------------------------------"); foreach ($struk->result() as $key => $v) { $sub_tot = $v->harga * $v->jumlah_selesai; $printer->text($v->nama_menu . " \n"); $printer->setJustification(2); $printer->text($v->jumlah_selesai . " | " . outNominal($v->harga) . " | " . outNominal($sub_tot) . " \n"); $printer->setJustification(); } $printer->text(" -------------------------------"); $printer->text(" TOTAL : Rp. " . outNominal($struk->row('total')) . " \n"); $printer->text(" DISC : % " . $struk->row('discount') . " \n"); $printer->text(" GRAND TOTAL : Rp. " . outNominal($struk->row('grand_total')) . " \n"); $printer->text(" TUNAI : Rp. " . outNominal($struk->row('fisik_uang')) . " \n"); $printer->text(" KEMBALI: Rp. " . outNominal($struk->row('kembali')) . " \n"); $printer->text("----------------------------------------"); $printer->setJustification(1); $printer->text("Terimakasih atas kunjunganya.\n"); $printer->setJustification(); $printer->text("----------------------------------------"); $printer->text("Kasir : " . $this->session->userdata('display_name') . " \n"); $printer->text(date("d/m/Y H:i:s") . "\n"); $printer->text("\n"); $printer->text("\n"); $printer->cut(); }
} $printer->setDoubleStrike(false); $printer->cut(); /* Fonts (many printers do not have a 'Font C') */ $fonts = array(Escpos::FONT_A, Escpos::FONT_B, Escpos::FONT_C); for ($i = 0; $i < count($fonts); $i++) { $printer->setFont($fonts[$i]); $printer->text("The quick brown fox jumps over the lazy dog\n"); } $printer->setFont(); // Reset $printer->cut(); /* Justification */ $justification = array(Escpos::JUSTIFY_LEFT, Escpos::JUSTIFY_CENTER, Escpos::JUSTIFY_RIGHT); for ($i = 0; $i < count($justification); $i++) { $printer->setJustification($justification[$i]); $printer->text("A man a plan a canal panama\n"); } $printer->setJustification(); // Reset $printer->cut(); /* Barcodes - see barcode.php for more detail */ $printer->setBarcodeHeight(80); $printer->setBarcodeTextPosition(Escpos::BARCODE_TEXT_BELOW); $printer->barcode("9876"); $printer->feed(); $printer->cut(); /* Graphics - this demo will not work on some non-Epson printers */ 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);
<td align="center" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif;"><?php echo $quota; ?> MB</td> </tr> <?php } //send info to printer for printing vouchers. require_once dirname(__FILE__) . "/escpos/Escpos.php"; $connector = null; $connector = new WindowsPrintConnector($printername); $printer = new Escpos($connector); /* Initialize Printer */ $printer->initialize(); $printer->setJustification(Escpos::JUSTIFY_CENTER); $printer->setTextSize(2, 2); $printer->text("WIFI HOTSPOT\n"); $logo = new EscposImage("escpos/escposlogo.png"); $printer->bitImage($logo); $printer->setTextSize(1, 1); $printer->text("\nNOTE: Each code valid for one\n"); $printer->text("device only.\n\n"); $printer->text("Download Speed " . $downloadspeed . " kbps\n"); $printer->text("Upload Speed " . $uploadspeed . " kbps\n"); $printer->text("Quota " . $quota . " MB\n"); $printer->text("\n"); $printer->setTextSize(2, 2); $printer->text($voucherstring . "\n"); $printer->text("Usable One Time\n\n"); $printer->setTextSize(1, 2);
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 */ }
public static function pwresetReceipt(AccountOwner_model $owner, $password) { if (!isset(self::$conf['ip']) || self::$conf['ip'] == "0.0.0.0") { return false; } try { $connector = new NetworkPrintConnector(self::$conf['ip'], self::$conf['port']); $profile = SimpleCapabilityProfile::getInstance(); $printer = new Escpos($connector, $profile); /* Header */ $printer->setJustification(Escpos::JUSTIFY_CENTER); if (isset(self::$conf['logo']) && file_exists(self::$conf['logo'])) { try { /* Include top image if set & available */ $logofile = self::$conf['logo']; $ser = $logofile . ".ser"; if (file_exists($ser)) { $img = unserialize(file_get_contents($ser)); } else { $img = new EscposImage($logofile); @file_put_contents($ser, serialize($img)); // Attempt to cache } $printer->bitImage($img); } catch (Exception $e) { trigger_error($e->getMessage()); } } $printer->setEmphasis(true); $printer->text(self::$conf['header'] . "\n"); $printer->setEmphasis(false); $printer->feed(); $printer->text("User Account Information\n"); $printer->feed(2); $printer->setJustification(Escpos::JUSTIFY_LEFT); /* User info */ $barcode = ""; $seen = array(); $printer->text("User Account:\n " . $owner->owner_firstname . " " . $owner->owner_surname . "\n\n"); $printer->text("Login name(s):\n"); foreach ($owner->list_Account as $acct) { if (!isset($seen[$acct->account_login])) { $printer->text(" " . $acct->account_login . "\n"); $seen[$acct->account_login] = true; if (is_numeric($acct->account_login) && ($barcode == "" || strlen($acct->account_login) < strlen($barcode))) { $barcode = $acct->account_login; } } } $printer->feed(); $printer->text("Password:\n {$password}\n"); $printer->feed(2); /* Footer */ $printer->text(self::$conf['footer'] . "\n"); $printer->feed(); /* Barcode */ if ($barcode != "") { $printer->setJustification(Escpos::JUSTIFY_CENTER); $printer->barcode($barcode, Escpos::BARCODE_CODE39); $printer->feed(); $printer->text($barcode); $printer->feed(1); $printer->setJustification(Escpos::JUSTIFY_LEFT); } $printer->cut(); $printer->close(); } catch (Exception $e) { trigger_error($e->getMessage()); // Should be logged some-place for troubleshooting. return false; } }
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 */ }