function printBatches($pid, $batches, $suffix_counter, $use_red_paper = false) { global $logger, $output, $ignoreStockStatusDepot, $add_to_daily_statistic, $max_item_per_pi, $pi_batches_path, $file_prefix, $pi_created; $logger->write('PREPARING PRODUCT ID ' . $pid . ' - Suffix ' . $suffix_counter . ' - ' . ($use_red_paper ? 'Red' : 'Normal') . ' Paper'); $file_suffix = "_{$suffix_counter}"; $filename = 'batches-' . ($use_red_paper ? 'RED' : '') . $file_prefix . $pid . $file_suffix; $logger->write("PREPARING PI FILE: {$filename}.pdf"); $pi_pdf = new production_instruction_pdf(false); $pi_pdf->filename = $pi_batches_path . $filename; $n_item = 0; foreach ($batches as $key => $dt) { $n_item++; list($type, $oiid) = explode('|', $dt); //$pi_pdf->addOrder($type, $oid); $pi_pdf->addItem($type, $oiid); $logger->write("{$type}-{$oiid} ADDED"); $pi_created++; unset($batches[$key]); if ($n_item >= $max_item_per_pi && $n_item % $max_item_per_pi == 0) { $suffix_counter--; printBatches($pid, $batches, $suffix_counter, $use_red_paper); break 1; } } //asort($pi_pdf->orders); //$pi_pdf->createPDF(true, $output, true, false); $pi_pdf->createPDF($ignoreStockStatusDepot, $output, $add_to_daily_statistic, false); $logger->write("PI FILE CREATED: {$filename}.pdf"); echo ". "; }
$orders = array(); $orders_id = ''; if ($type == 'SP') { $class_jo = new jng_sp_orders(); $orders = $class_jo->retrieveItemDetail($opid); $orders_id = $orders['jng_sp_orders_id']; } elseif ($type == 'JG') { $class_o = new orders(); $orders = $class_o->retrieveProductDetail($opid); $orders_id = $orders['orders_id']; } elseif ($type == 'DP') { $class_do = new depot_orders(); $orders_id = $opid; } $class_pi->addOrder($type, $orders_id); } $class_pi->createPDF(false, $output_type); } else { use_class('production_instruction'); $class_pi = new production_instruction(); $id = tep_db_prepare_input($_GET['opid']); $orders_products_id = explode(',', $id); $class_pi->loadOrderProducts($type, null, $orders_products_id); if (count($class_pi->orders_products) > 0) { echo $class_pi->printProductionInstruction(); } else { echo '<h1>There is no product to print</h1>'; } } } tep_db_close();
<?php global $db; require_once '../confy.php'; require_once '../functions.php'; require_once '../functions-2.php'; require_once DIR_WS_FUNCTIONS . 'html_output.php'; tep_db_connect(); $allowed_type = array('DP', 'SP', 'JG'); $order_type = strtoupper($_GET['type']); $order_id = intval($_GET['id']); if (in_array($order_type, $allowed_type) && $order_id > 0) { use_class('production_instruction_pdf'); $class_pi = new production_instruction_pdf(); $class_pi->addOrder($order_type, $order_id); $class_pi->createPDF(false, 'F'); $message = 'PI Printed!'; } else { $message = 'BAD REQUEST:'; } echo '<strong>' . $message . ':</strong><br />'; echo 'Order Type = ' . $order_type . '<br />'; echo 'Order ID = ' . $order_id . '<br />'; tep_db_close();
$q .= " HAVING SUM(op.products_quantity) = op.order_item_total"; $q .= " ORDER BY o.date_purchased ,o.orders_id"; $dbq = tep_db_query($q); $type = 'JG'; $njg = 0; while ($r = tep_db_fetch_array($dbq)) { $orders_id = $r['orders_id']; $class_pi = new production_instruction_pdf(); $class_pi->addOrder($type, $orders_id); $class_pi->createPDF(false, $output, $add_to_daily_statistic); echo "create {$type}-PI {$orders_id}<br/>"; $njg++; } echo "<h3>{$njg} JG-PI created</h3>"; //DP $q = "SELECT depot_orders_id FROM depot_orders"; $q .= " WHERE order_date BETWEEN DATE('{$start_date}') AND DATE('{$end_date}')"; $q .= " and status = 3"; $q .= " ORDER BY depot_orders_id"; $dbq = tep_db_query($q); $type = 'DP'; $ndp = 0; while ($r = tep_db_fetch_array($dbq)) { $orders_id = $r['depot_orders_id']; $class_pi = new production_instruction_pdf(); $class_pi->addOrder($type, $orders_id); $class_pi->createPDF(false, $output, $add_to_daily_statistic); echo "create {$type}-PI {$orders_id}<br/>"; $ndp++; } echo "<h3>{$ndp} DP-PI created</h3>";
require_once '../confy.php'; require_once '../functions.php'; require_once '../functions-2.php'; require_once DIR_WS_FUNCTIONS . 'html_output.php'; tep_db_connect(); $type = $_GET['type']; $orders_id = $_GET['oid']; $orders_items_id = $_GET['oiid']; if ($orders_items_id == '') { $orders_items_id = null; } $output = isset($_GET['output']) && $_GET['output'] != '' ? $_GET['output'] : 'D'; $add_to_daily_statistic = isset($_GET['atds']) && $_GET['atds'] != '' ? $_GET['atds'] : false; $ignoreStockStatusDepot = false; if ($type != '') { use_class('production_instruction_pdf'); $class_pi = new production_instruction_pdf(false); //ADD ITEMS OR ORDER if ($orders_id == '' && !is_null($orders_items_id)) { $oiids = !is_array($orders_items_id) ? explode(',', $orders_items_id) : $orders_items_id; foreach ($oiids as $oiid) { $class_pi->addItem($type, $oiid); } } else { $class_pi->addOrder($type, $orders_id, $orders_items_id); } //PRODUCE PDF $class_pi->createPDF($ignoreStockStatusDepot, $output, $add_to_daily_statistic); } tep_db_close();