$handle->bindParam(':narticles', $prenote->narticles); $handle->bindParam(':reference', $prenote->clientName); $handle->bindParam(':comment', $prenote->cotizationNumber); $handle->bindValue(':type_description', 'Venta'); $handle->bindParam(':workstation', $prenote->terminal); $handle->bindParam(':customer_id', $prenote->customerUUID); $handle->bindValue(':id', '0', PDO::PARAM_INT); $handle->bindParam(':store_id', $prenote->store_id, PDO::PARAM_INT); $handle->execute(); save_products($link, $prenote_uuid, $prenote->product, $prenote->id_employee, $lastUpdate); $link->commit(); $prenote->folio = $code; $saved = true; } else { $terminalCode = ord($prenote->terminal); generate_barcode(false, $prenote->folio, $terminalCode); $saved = true; } for ($i = 0; $i < $print_times; $i++) { $isPrinted = print_ticket($prenote); } if ($isPrinted == true) { unlink($prenote->folio . ".png"); unlink($prenote->folio . ".pdf"); $printed = true; } echo json_encode(array($saved, $printed, $prenote)); } } catch (PDOException $ex) { error_log($ex->getMessage()); //print($ex->getMessage());
function add_barcode($form) { //print_r($_POST); die(); $totaal = 0; foreach ($form['fields'] as $field) { if ($field['type'] == 'product') { $totaal = $_POST['input_' . $field['id'] . '_3']; } } foreach ($form['fields'] as $field) { if ($field['inputName'] == 'barcode') { $barcodes = []; for ($i = 0; $i < $totaal; $i++) { $barcodes[] = generate_barcode(); } $_POST['input_' . $field['id']] = implode(',', $barcodes); } } return $form; }
} echo file_get_contents(PT::$ABSPATH . "/templates/" . $config['template'] . "/img/default_provider.png"); break; case 'category': if (isset($_GET['id'])) { $cat = CategoriesService::get($_GET['id']); if ($cat->hasImage !== false) { echo CategoriesService::getImage($cat->id); break; } } echo file_get_contents(PT::$ABSPATH . "/templates/" . $config['template'] . "/img/default_category.png"); break; case 'resource': $res = ResourcesService::get($_GET['id']); if ($res->type == Resource::TYPE_IMAGE) { echo $res->content; } break; case 'barcode': generate_barcode("ean13", $_GET['code']); break; case 'custcard': generate_barcode("code128", $_GET['code']); break; case 'js': $file = $_GET['id']; $file = str_replace("..", ".", $file); require_once PT::$ABSPATH . "/templates/" . $config['template'] . "/" . $file; break; }
<?php // load composer autoloader require 'vendor/autoload.php'; // disable Dompdf autoloader define('DOMPDF_ENABLE_AUTOLOAD', false); // require dompdf config file require_once "vendor/dompdf/dompdf/dompdf_config.inc.php"; // $pathToPdfs = array(); for ($i = 0; $i < 10; $i++) { // create the barcode $code = randomstring(); $pathToBarcode = generate_barcode($code); // create html for dompdf $barcode_html = "\n\t\t <img src='" . $pathToBarcode . "' \n\t\t \t\t\tstyle='position: absolute; \n\t\t \t\t\ttop: -40px; \n\t\t \t\t\tleft: -40px; \n\t\t \t\t\twidth:280px; \n\t\t \t\t\theight: 70px;' >\n\t\t <div style='position: absolute; top: 11px; left: 30px; width: 80px; height: 20px; text-align: center; background-color:white; text-transform: uppercase;'>\n\t\t \t\t" . $code . "\n\t\t </div>"; // init dompdf and set paper size $dompdf = new DOMPDF(); $customPaper = array(0, 0, 175, 60); $dompdf->set_paper($customPaper); // load html to dompdf $dompdf->load_html($barcode_html); // render the pdf $dompdf->render(); // cleanup barcode png if (file_exists($pathToBarcode)) { unlink($pathToBarcode); } // save pdf to temp dir $output = $dompdf->output(); $pdfName = $code . '.pdf';