$post_result .= '<tr><td> </td></tr>'; $post_result .= '<tr><td align="center" height="150px"><span class="bold" style="font-size:36px;">' . $message . '</span></td></tr>'; $post_result .= '<tr>'; $post_result .= '<td align="center"><input type="button" style="width:200px;height:100px;font-size:20px;" class="done bold" value="DONE"/></td>'; $post_result .= '<tr><td> </td></tr>'; $post_result .= '</tr>'; $post_result .= '</table>'; $ajaxResult = array(); $ajaxResult['result'] = $post_result; ajaxReturn($ajaxResult); exit; } } if (isset($_GET) && count($_GET) > 0) { $ean_no = $_GET['ean']; $pa = $class_pean->getProductArticle($ean_no); $products_id = $pa['products_id']; if ($products_id != '') { $qp = "SELECT p.*, pd.products_name FROM products p INNER JOIN products_description pd ON p.products_id = pd.products_id\n WHERE p.products_id = {$products_id} AND pd.language_id = 2"; $dbqp = tep_db_query($qp); $rp = tep_db_fetch_array($dbqp); $p_img = webImage($rp['products_image'], '350', '350', 'Products ' . $ean_no, 'ui-corner-all'); $p_length = $pa['length'] > 0 ? ' / ' . textLength($pa['length']) : ''; $is_best_product = $class_pm->isBestProduct($pa['products_id']); if ($is_best_product) { $used_form = '<table style="width:100%;position:absolute;top:0;left:0;" border="0" cellpadding="0" cellspacing="0">'; $used_form .= '<tr><td align="center" colspan="2">' . $p_img . '</td></tr>'; $used_form .= '<tr><td align="center" colspan="2" style="font-size:16px;font-weight:bold;">' . $rp['products_model'] . $p_length . '</td></tr>'; $used_form .= '<tr><td align="center" colspan="2" style="padding:9px;"><span class="bold" style="vertical-align:middle;font-size:34px;">Please Do Product Quality Check</span></td></tr>'; $used_form .= '<tr>'; $used_form .= '<input type="hidden" id="hid-ids" value="' . $pa['products_id'] . '-' . $pa['products_articles_id'] . '"/>';
$data->appendChild($data_attribute); $cell->appendChild($data); } else { //If no, remove existing data placeholder $data->removeChild($data->firstChild); } //Now fill in the data placeholder with data $data->appendChild($EDD_as_dom_text); } } break; case 'ACK_STATE': if (is_null($i)) { if ($jng_sp_id == '5') { //AM.VD Auto Cancelation Rule $ean_pinfo = $class_ean->getProductArticle($ean); $po_pid_collection = array(); $po_pid_collection[$ean] = $ean_pinfo['products_id']; if (isset($ean_detail_info_collections[$ean])) { $ean_detail_info = $ean_detail_info_collections[$ean]; } else { $ean_detail_info = $class_jo->getAMVD_AutoCancelSupportingData($po_pid_collection); $ean_detail_info_collections[$ean] = $ean_detail_info; } $as_key = $class_jo->checkAMVD_AutoCancelRule($ean, $ean_detail_info, $sp_specsets) ? 'CP' : 'CO'; } else { $as_key = 'CO'; } } else { $as_key = $i['order_quantity'] == 0 ? 'CO' : 'AC'; }
$value = '<input type="text" name="keep[' . $row['order_id'] . ']" class="w040 tac" value="' . intval($row['order_quantity']) . '" />'; break; default: $value = ' '; } $cols[$class_raw] = strval($value); } $table[] = $cols; } } $date_filter_nice = date('d.m.Y', strtotime($date_filter)); $total_confirmed = $total_orders - $total_cancels; //GRAB IMPORT DATA $last_import = $class_jd->retrieveLatestDownloads($jng_sp_id, 'IMPORTDATA', 1); $importdata = $class_jc->importDataQueryEAN($jng_sp_id, $products_ean); $pdata = $class_ean->getProductArticle($products_ean); $stock = $class_pm->stockRetrieve($whid, $pdata['products_id'], $pdata['articles_id'], true); $content .= "<h2>Order Date {$date_filter_nice} - EAN {$products_ean}</h2>"; $content .= '<div class="smallText red" style="margin-bottom:5px;">* ' . (count($last_import) > 0 ? 'Using Data from last import: ' . $last_import[0]['info'] : 'No import data can be used') . '</div>'; $content .= '<div class="draw-table" style="margin-bottom:20px;"><table border="0" cellspacing="0" cellpadding="0">'; $content .= '<tr><th>Open PO</th><th>Stock SP</th><th>Stock HH</th><th>Ordered<br />by Customers</th><th>Delivered<br />to Customers</th></tr>'; $content .= "<tr class=\"o\"><td class=\"w080 tac\">{$importdata['sp_open_orders']}</td><td class=\"w080 tac\">{$importdata['sp_stock']}</td><td class=\"w080 tac\">{$stock}</td><td class=\"w080 tac\">{$importdata['sp_ordered']}</td><td class=\"w080 tac\">{$importdata['sp_delivered']}</td></tr>"; $content .= '</table></div>'; $content .= "<h3>Total Order = {$total_orders} ⋅ Total Cancels = {$total_cancels} ⋅ Total Confirmed = {$total_confirmed}</h3>"; $content .= '<form name="cancel_orders" action="?' . $_SERVER['QUERY_STRING'] . '" method="post">'; $content .= '<input type="hidden" name="me_action" value="CANCELORDERS" />'; $content .= tep_draw_table('', $table); $content .= '<div class="buttons-left"><input type="submit" name="submit" value="Cancel Orders!" title="Click here to cancel orders as " /></div>'; $content .= '</form>'; } else { $jng_sp_id = '5';
} $result['label'] = $class_bl->generateLabelProductTag($ean, $pi_barcode, $products_and_articles_id); } elseif ($label_type == 'jewelboxlabel') { $result_data = $class_bl->generateBoxLabel($product_id, $article_id, $productean); } elseif ($label_type == 'label_product_ottob2b') { $result_data = $class_bl->generateLabelOttoB2B($product_id, $article_id, $productean); } elseif ($label_type == 'label_product_hse') { $result_data = $class_bl->generateLabelHSE($product_id, $article_id, $productean); } elseif ($label_type == 'elementorderlabel') { $result = $class_bl->generateElementOrderLabel($barcode_id); } else { if ($barcode_id != '') { $result_data = $class_bl->generateBarcode($barcode_type, $barcode_id, '', $printer_resolution); } else { if ($productean != '' && ($product_id == 0 || $article_id == 0)) { $product = $class_pean->getProductArticle($productean); $product_id = $product['products_id']; $article_id = $product['products_articles_id']; } $products_data['products_id'] = $product_id; $products_data['products_articles_id'] = $article_id; if ($sp_id == '') { $sp_id = '0'; } $ean_data = $class_bl->getEANReturnResult('', $products_data, $sp_id); $result_data = $class_bl->generateBarcode($barcode_type, '', $ean_data); //qty is handled no by MC (printLooping), //so above code is only for getting the label constructor unset($result_data['qty']); } }
} } //START TEMPLATE $products_entry = ''; if (isset($_GET['products_id'])) { $products_id = tep_db_prepare_input($_GET['products_id']); $product_data = $class_pm->retrieveDetail($products_id, 'p,pc,pnc,cat,pci,pl'); } elseif (isset($_POST['products_id'])) { //REDIRECT LINK IF AN ORDER IS FOUND BY POST if (isset($_POST['products_id'])) { $products_entry = tep_db_prepare_input($_POST['products_id']); } if (strlen($products_entry) == 13) { use_class('products_ean'); $class_ean = new products_ean(); $ean_pinfo = $class_ean->getProductArticle($products_entry); $products_id = $ean_pinfo['products_id']; } else { $products_query = tep_db_query("SELECT products_id FROM products WHERE products_model='{$products_entry}'"); if (tep_db_num_rows($products_query) > 0) { $products = tep_db_fetch_array($products_query); $products_id = $products['products_id']; } else { $products_id = $products_entry; } } if ($products_id != '') { header("Location: ?open=product-detail&products_id={$products_id}"); exit; } else { $messagebox->add('Can not find Products ID / Code / EAN "' . $products_entry . '" in database');
$eanlist[]='4050878469740'; $eanlist[]='4050878047429'; $eanlist[]='4050878145514'; */ $sp_specsets = load_config('sp-specific-settings'); use_class('products_ean'); use_class('products_minierp'); use_class('jng_sp_orders'); $class_pe = new products_ean(); $class_pm = new products_minierp(); $class_jo = new jng_sp_orders(); $ean_pid = array(); $orders = array(); $products = array(); foreach ($eanlist as $ean) { $p_info = $class_pe->getProductArticle($ean); $pid = $p_info['products_id']; $ean_pid[$ean] = $pid; if (!isset($products[$pid])) { $pdata = $class_pm->retrieveDetail($pid, 'sp'); $products[$pid] = $pdata['sp']['5']; } } $ean_detail_info = $class_jo->getAMVD_AutoCancelSupportingData($ean_pid); echo "<table id='ean_table' border='1'>"; echo "<tr>"; echo "<th>PID</th>"; echo "<th>EAN</th>"; echo "<th>Status</th>"; echo "<th>Age</th>"; echo "<th>Article Sold</th>";
function generateLabelProductTag($ean, $pi_barcode = null, $products_and_articles_id = null) { //Generate Label must be triggered by only 1 of these 3 parameters: //- $ean: EAN code //- $pi_barcode: PI Barcode //- $products_and_articles_id: Products ID and Articles ID seperated by ";" - Articles ID should be 0 for default length //Parameters use is prioritized from the top, use null or empty string to use next priority use_class('products_minierp'); use_class('products_ean'); $class_pm = new products_minierp(); $class_ean = new products_ean(); if (is_string($ean) && strlen($ean) == 13) { $product_info = $class_ean->getProductArticle($ean); $products_id = $product_info['products_id']; } elseif (is_string($pi_barcode) && $pi_barcode != '') { $splitter = strpos('ß', $pi_barcode) !== false ? 'ß' : '-'; $pi_barcode_split = explode($splitter, $pi_barcode); switch ($pi_barcode_split[0]) { case 'JG': use_class('orders'); $class_o = new orders(); $op = $class_o->retrieveProductDetail($pi_barcode_split[1]); $products_id = $op['products_id']; $articles_id = $op['products_articles_id']; break; case 'SP': use_class('jng_sp_orders'); $class_jo = new jng_sp_orders(); $oi = $class_jo->retrieveItemDetail($pi_barcode_split[1]); $products_id = $oi['products_id']; $articles_id = $oi['products_articles_id']; break; case 'DP': use_class('depot_orders'); $class_do = new depot_orders(); $do = $class_do->retrieveDetail($pi_barcode_split[1]); $products_id = $do['products_id']; $articles_id = $do['articles_id']; break; } $ean = null; } elseif (is_string($products_and_articles_id) && strlen($ean) >= 3) { $pid_aid_split = explode(';', $products_and_articles_id); $products_id = $pid_aid_split[0]; $articles_id = $pid_aid_split[1]; $ean = null; } $p = $class_pm->retrieveDetail($products_id, 'p'); //DATA NEEDED: if (is_null($ean)) { $ean = $class_ean->getEAN($products_id, $articles_id); } $price = displayCurrency('EUR', $p['p']['products_price'], false); //START GENERATING LABEL $left_margin_amvd = 30; //IF SUDDENLY HH PRINTED TOO MUCH TO THE RIGHT PLS CHANGE USING 5 AS BELOW //$left_margin_amvd = 5; //IF SUDDENLY MARGIN GOING LEFT UNTIL TRUNCATE PLS USE 30 AS ABOVE $lbcmd = "^XA"; //Start Format (used at the beginning of ZPL II code) $lbcmd .= "^CI6"; //Change Internation Font/Encoding (6=Single Byte Encoding - Germany Character Set) $lbcmd .= "^MTD"; //^MTD : Direct Thermal Media; ^MTT : Thermal Transfer Media $lbcmd .= "^MD15"; //Media Darkness (-30 to 30, it will reduce/add to the current darkness settings) $lbcmd .= "^JWM"; //Set Ribbon Tension (L=Low / M=Medium / H=High) $lbcmd .= "^MMT"; //Print Mode (T=Tear-off, P=Peel-off, C=Cutter, ,D=Delayed Cutter) $lbcmd .= "^MUd,300,300"; //Set Units of Measurement: ^MUa,b,c (a=units [D=dots, I=inches, M=mm], b=dpi [150,200,300], c=dpi conversion [300,600]) /* ExampleThis is an example of Converting dpi Values. Convert a 150 dpi format to a 300 dpi format with a base in dots: ^MUd,150,300 Convert a 150 dpi format to a 600 dpi format with a base in dots: ^MUd,150,600 Convert a 200 dpi format to a 600 dpi format with a base in dots: ^MUd,200,600 To reset the conversion factor to the original format, enter matching values for parameters b and c: ^MUd,150,150 ^MUd,200,200 ^MUd,300,300 ^MUd,600,600 */ $lbcmd .= "^LH55,7"; //Label Home: ^LHx,y (x=x-axis position in dots [0-32000], y=y-axis position in dots [0-32000]) /* Depending on the printhead used in your printer, use one of these when figuring the values for x and y: 6 dots = 1 mm, 152 dots = 1 inch 8 dots = 1 mm, 203 dots = 1 inch 11.8 dots = 1 mm, 300 dots = 1 inch 24 dots = 1 mm, 608 dots = 1 inch */ $lbcmd .= "^MNY"; //Media Tracking (N=continuous media, Y/W=non-continuous media web/gap sensing) $lbcmd .= "^PW900"; //Print Width (label width in dots) //$lbcmd .= "^LL149"; //Label Length (1-32000, only for continues media) //$lbcmd .= "^JMB^FS"; //Set dots per milimeter (Big Size of Barcode) /* Description The ^JM command lowers the density of the print—24 dots/mm becomes 12, 12 dots/mm becomes 6, 8 dots/mm becomes 4, and 6 dots/mm becomes 3. ^JM also affects the field origin (^FO) placement on the label (see example below). When sent to the printer, the ^JM command doubles the format size of the label. Depending on the printhead, normal dot-per-millimeter capabilities for a Zebra printer are 12 dots/mm (304 dots/inch), 8 dots/mm (203 dots/inch) or 6 dots/mm (153 dots/inch). This command must be entered before the first ^FS command in a format. The effects of ^JM are persistent. Accepted Values: A = 24 dots/mm, 12 dots/mm, 8 dots/mm or 6 dots/mm B = 12 dots/mm, 6 dots/mm, 4 dots/mm or 3 dots/mm Default Value: A */ /* * Printing Function * * ^FO = Field Origin: ^FOx,y,z * ( * x = x-axis location in dots [0-32000] * y = y-axis-location in dots [0-32000] * z = justification [0=left,1=right,2=auto/script dependent] * ) * ^BE = EAN-13 Bar Code: ^BEo,h,f,g * ( * o = orientation [N=normal, R=90, I=180, B=270] * h = barcode height in dots [1-32000] * f = print interpretation line [N=no, Y=yes] * g = print interpretation line above code [N=no, Y=yes] * ) * ^A = Scalable/Bitmapped Font: ^Afo,h,w * ( * f = font name [A through Z, and 0 to 9] * o = field orientation [N=normal, R=90, I=180, B=270] * h = character height in dots [10-32000] * w = width in dots [10-32000] * ) * ^FD = Field Data: ^FDa (a=data to be printed [any data string up to 3072 bytes]) * */ $lbcmd .= "^FO0,65" . "^BEN,60,Y,N" . "^FD{$ean}" . "^FS"; //draw EAN $lbcmd .= "^FO260,90" . "^ARN,35,31" . "^FH_^FD_15" . "^FS"; //draw EUR Symbol $lbcmd .= "^FO290,90" . "^ARN,35,31" . "^FD{$price}" . "^FS"; //draw Price $lbcmd .= "^XZ"; //End Format (ending/closing bracket) return $lbcmd; }
function checkProductOnBag($sp_type, $order_id, $ean_code, $list_return_need_refresh = false) { global $class_jo; global $class_o; use_class('payone'); use_class('products_minierp'); use_class('products_ean'); $class_payone = new payone(); $class_pm = new products_minierp(); $class_pean = new products_ean(); $status = 'RETURNNOTALLOWED'; $result = array(); $is_best_product = false; $articles = $class_pean->getProductArticle($ean_code); $length = textLength($articles['length']); //Default value of image additional info (this info will displayed on product image of Mod03ProductBagCheckView.mxml $image_additional_info_text = ''; //Notes: below style is adjusted with flex Property Styles, please match it with it if need to add more styles $image_additional_info_style[] = 'color:#000000'; $image_additional_info_style[] = 'fontSize:25'; $image_additional_info_style[] = 'textAlign:right'; //start, end, left, right, center, justify //Return could be created at least 1 day after it is sent $qty = 0; $qtyr = 0; $latest_shipping = date('Y-m-d 23:59:59', strtotime('yesterday')); if (strtolower($sp_type) == 's') { $qc = "SELECT joi.jng_sp_orders_items_id, joi.products_id" . ", joi.order_quantity, MAX(joish.status_date) AS sent_date" . " FROM jng_sp_orders_items joi" . " INNER JOIN jng_sp_orders_items_status_history joish" . " ON joish.jng_sp_orders_items_id = joi.jng_sp_orders_items_id" . " AND joish.status = 9" . " WHERE joi.jng_sp_orders_id = '{$order_id}'" . " AND joi.products_ean = '{$ean_code}' AND joi.status NOT IN (10,12)" . " GROUP BY jng_sp_orders_items_id" . " HAVING sent_date <= '{$latest_shipping}'"; $c = tep_db_query($qc); //We need to handle if 1 article is bought multiple times as diff item while ($rc = tep_db_fetch_array($c)) { $item_id = $rc['jng_sp_orders_items_id']; $qty = intval($rc['order_quantity']); $products_id = $rc['products_id']; $qc2 = "SELECT SUM(return_quantity) AS return_quantity" . " FROM jng_sp_orders_items_return" . " WHERE jng_sp_orders_items_id = '{$item_id}'"; $c2 = tep_db_query($qc2); $r2 = tep_db_fetch_array($c2); $qtyr = intval($r2['return_quantity']); if ($qty > $qtyr) { break; } } } elseif (strtolower($sp_type) == 'j') { $products_id = $articles['products_id']; $products_articles_id = $articles['products_articles_id']; $qc = "SELECT op.orders_products_id, op.products_id" . ", op.products_quantity, MAX(opsh.status_date) AS sent_date" . " FROM orders_products op" . " INNER JOIN orders_products_status_history opsh" . " ON opsh.orders_products_id = op.orders_products_id" . " AND opsh.status = 9" . " WHERE op.orders_id = '{$order_id}'" . " AND op.products_id = '{$products_id}'" . " AND op.products_articles_id = '{$products_articles_id}'" . " AND op.status NOT IN (10,12)" . " GROUP BY orders_products_id" . " HAVING sent_date <= '{$latest_shipping}'"; $c = tep_db_query($qc); //We need to handle if 1 article is bought multiple times as diff item while ($rc = tep_db_fetch_array($c)) { $item_id = $rc['orders_products_id']; $qty = intval($rc['products_quantity']); $products_id = $rc['products_id']; $qc2 = "SELECT SUM(return_qty) AS return_quantity" . " FROM orders_products_return" . " WHERE orders_products_id = '{$item_id}'"; $c2 = tep_db_query($qc2); $r2 = tep_db_fetch_array($c2); $qtyr = intval($r2['return_quantity']); if ($qty > $qtyr) { break; } } } if ($qty > $qtyr) { $status = 'MCCHECKPRODUCTONBAG'; //Return reasons $return_reasons[] = 'Goldplating'; $return_reasons[] = 'Stone missing'; $return_reasons[] = 'Silver not polished'; $return_reasons[] = 'Scratches'; $return_reasons[] = 'Knot in chain'; $return_reasons[] = 'Soldering point visible'; $return_reasons[] = 'Broken'; $return_reasons[] = 'Out of shape'; $return_reasons[] = 'Tarnishing'; $return_reasons[] = 'Too big'; $return_reasons[] = 'Too large'; $return_reasons[] = 'Different from image'; $return_reasons[] = 'Change mind'; $return_reasons[] = 'Double order'; $return_reasons[] = 'Quality'; $return_reasons[] = 'Goldplated peeled off'; $return_reasons[] = 'Wrong color'; $return_reasons[] = 'Wrong product'; $return_reasons[] = 'Bad setting'; sort($return_reasons); //Note: DO NOT change Others, since this value used on some logic on MC codes $return_reasons = array_merge(array('Others'), $return_reasons); $result['return_reason_list'] = $return_reasons; //Show Swarovski Elements text when product contain material swarovski "4" if ($class_pm->productContainMaterials($products_id, 4)) { $image_additional_info_text = 'Swarovski Elements'; } } if ($products_id != '' && $products_id != 0) { /*DEACTIVATE CHECKING, SINCE ALL RETURNED PRODUCTS ARE KEPT ON HH DEPOT $is_best_product = $class_pm->isBestProduct($products_id); */ $is_best_product = true; $result['product_id'] = $products_id; $qp = "SELECT p.*, pd.products_name FROM products p INNER JOIN products_description pd ON p.products_id = pd.products_id\n WHERE p.products_id = {$products_id} AND pd.language_id = 2"; $dbqp = tep_db_query($qp); $rp = tep_db_fetch_array($dbqp); $result['is_best_product'] = $is_best_product; $result['product_code'] = $rp['products_model']; $result['product_name'] = $rp['products_name']; $result['product_length'] = $length; $result['product_image'] = webImageSource($rp['products_image'], '350'); //'http://www.julie-grace.de/images/imagecache/500x500_03601033.jpg'; $result['product_image_80'] = webImageSource($rp['products_image'], '80'); //'http://www.julie-grace.de/images/imagecache/500x500_03601033.jpg'; } $result['ean_code'] = $ean_code; $result['list_return_need_refresh'] = $list_return_need_refresh; $result['order_product_id'] = $item_id; $result['status'] = $status; $result['image_additional_info_text'] = $image_additional_info_text; $result['image_additional_info_style'] = $image_additional_info_style; return $result; }
$ajaxResult = array(); $ajaxResult['result'] = $post_result; $ajaxResult['scanned_ean'] = $ean_no; ajaxReturn($ajaxResult); exit; } elseif ($_POST['me_action'] == 'CHECKBGPRODUCTSRECEIVED') { $mode = $_POST['mode']; $package_id = $_POST['package_id']; $sendback_id = $_POST['sendback_id']; $products_id = $_POST['products_id']; $ean_no = $_POST['ean']; $type = $_POST['type']; $qty_sent = $_POST['qty_sent']; if ($mode == 'rcv_different_product') { $package_contents = $class_sendback->retrievePackageContentList($package_id, "s.products_ean='{$ean_no}' AND s.type='{$type}' AND s.status='18' AND (s.quantity_stock=0 AND s.quantity_actual=0)"); $products_ean = $class_pean->getProductArticle($ean_no); $products_id = $products_ean['products_id']; $qty_rcv = count($package_contents) > 0 ? $package_contents[0]['quantity_received'] : 0; $qty_sent = '0'; } else { $qty_rcv = $_POST['qty_rcv']; } $qty_rcv++; $is_best_product = $class_pm->isBestProduct($products_id); if ($is_best_product) { $received_status = ''; $post_result .= '<div style="background:#E4E3E0;width:500px;padding:20px;">'; $post_result .= '<table border="0" cellpadding="0" cellspacing="0">'; $post_result .= '<tr><td align="center" colspan="2" style="vertical-align:middle"><h1>Please Do Product Quality Check</h1></td></tr>'; $post_result .= '<tr>'; $post_result .= '<td align="center" style="vertical-align:middle"><input type="button" style="width:120px;height:70px;font-size:20px;" class="qcproduct green bold" value="QC OK" title="Put To \'Bin In HH\' Box"/></td>';
function receivedProductsDifferent($package_id, $new_ean, $received_status = '', $create_received_data = true) { global $session_userinfo; $result = ''; $package = $this->retrievePackageList("sendback_package_id='{$package_id}'"); $package_contents = $this->retrievePackageContentList($package_id, "s.products_ean='{$new_ean}' AND s.type='X' AND s.status='18'"); $sendback = array(); if (count($package_contents) > 0) { $sendback_id = $package_contents[0]['sendback_id']; $qty_received = $create_received_data ? $package_contents[0]['quantity_received'] + 1 : $package_contents[0]['quantity_received']; $qty_stock = !$create_received_data ? $package_contents[0]['quantity_stock'] + 1 : $package_contents[0]['quantity_stock']; $sendback['quantity_received'] = $qty_received; $sendback['quantity_stock'] = $qty_stock; tep_db_perform('sendback', $sendback, 'update', "sendback_id='{$sendback_id}'"); } else { use_class('products_ean'); $class_pean = new products_ean(); $articles = $class_pean->getProductArticle($new_ean); $qty_received = $create_received_data ? 1 : 0; $sendback['type'] = 'X'; $sendback['bin_segments_id'] = $package[0]['segments_id']; $sendback['products_id'] = $articles['products_id']; $sendback['products_articles_id'] = $articles['products_articles_id']; $sendback['products_ean'] = $new_ean; if (!$create_received_data) { $sendback['quantity_stock'] = 1; } $sendback['quantity_received'] = $qty_received; $sendback['status'] = '18'; tep_db_perform('sendback', $sendback); $sendback_id = tep_db_insert_id(); $this->addItem($package_id, $sendback_id); } if ($create_received_data) { //CREATE SENDBACK RECEIVED DATA $rcv = array(); $rcv['sendback_id'] = $sendback_id; $rcv['received_date'] = date("Y-m-d H:i:s"); $rcv['received_by'] = $session_userinfo['username']; if ($received_status != '') { $rcv['status'] = $received_status; } tep_db_perform('sendback_received', $rcv); $sendback_received_id = tep_db_insert_id(); $result = "{$sendback_received_id};{$sendback_id};{$qty_received}"; } else { $result = "{$sendback_id};{$qty_received}"; } return $result; }
function getBinByEAN($segment_id, $ean_code) { use_class('products_ean'); $class_ean = new products_ean(); $pinfo = $class_ean->getProductArticle($ean_code); $bin = $this->getBinByProduct($segment_id, $pinfo['products_id'], $pinfo['products_articles_id']); return $bin; }
function recommendationList($segments_id, $keywords = '') { use_class('bins'); $class_bin = new bins(); use_class('products_ean'); $class_ean = new products_ean(); $segment = $class_bin->retrieveSegmentDetail($segments_id); $whid = $segment['warehouses_id']; $products = array(); //here we define which column in the query is in article level $articles_data = array('article_length', 'article_ean', 'article_weekly_sold', 'article_sold_monthly_1', 'article_stock', 'article_orders_qty', 'article_nonrefill_qty', 'article_fc_base_monthly', 'article_fc_base_daily'); //DEFAULT ARTICLE $q = "SELECT p.products_id, p.products_model, p.products_image, pd.products_name"; $q .= ", pl.weekly_sold, pl.sold_monthly_1, pl.fc_base_monthly"; $q .= ", pnc.products_length AS article_length, p.products_ean AS article_ean"; $q .= ", pal.weekly_sold AS article_weekly_sold, pal.sold_monthly_1 AS article_sold_monthly_1"; $q .= ", pal.fc_base_monthly AS article_fc_base_monthly, pal.fc_base_daily AS article_fc_base_daily"; $q .= ", (ps.stock - ps.booking_active) AS article_stock" . ", SUM(IF(do.trans_type IN (" . self::FILTER_TRANS_TYPE_ALLREFILL . "), do.quantity, 0)) AS article_orders_qty" . ", SUM(IF(do.trans_type = '" . self::TRANS_TYPE_NON_REFILL . "', do.quantity, 0)) AS article_nonrefill_qty"; $q .= " FROM products p"; $q .= " LEFT JOIN products_best_good pbg ON pbg.products_id=p.products_id"; $q .= " LEFT JOIN products_non_configurator pnc ON pnc.products_id=p.products_id"; $q .= " LEFT JOIN products_log pl ON pl.products_id=p.products_id"; $q .= " LEFT JOIN products_description pd ON pd.products_id=p.products_id AND pd.language_id=2"; $q .= " LEFT JOIN products_articles_log pal ON pal.products_id=p.products_id AND pal.products_articles_id=0"; $q .= " LEFT JOIN products_stock ps ON ps.jng_warehouses_id={$whid} AND ps.products_id=p.products_id AND ps.articles_id=0"; $q .= " LEFT JOIN depot_orders do ON do.segments_id={$segments_id} AND do.products_id=p.products_id AND do.articles_id=0 AND do.status NOT IN (" . self::FILTER_STATUS_CLOSE . ")"; $filter = array(); if ($keywords != '') { if (is_numeric($keywords)) { if (strlen($keywords) == '13') { $ean_product = $class_ean->getProductArticle($keywords); $filter[] = " p.products_id={$ean_product['products_id']}"; } else { if (strval(intval($keywords)) === $keywords) { $filter[] = " p.products_id={$keywords}"; } else { $filter[] = " p.products_model='{$keywords}'"; } } } else { $keywords_name = array(); if (strpos($keywords, ',') !== false) { $keywords_id = array(); $keywords_code = array(); $keywords_explode = explode(',', $keywords); foreach ($keywords_explode as $kw) { if (is_numeric($kw)) { if (strlen($kw) == '13') { $ean_product = $class_ean->getProductArticle($kw); $keywords_id[] = $ean_product[products_id]; } elseif (strval(intval($kw)) === $kw) { $keywords_id[] = $kw; } else { $keywords_code[] = "'{$kw}'"; } } else { $keywords_code[] = "'{$kw}'"; $keywords_name[] = $kw; } } if (count($keywords_id) > 0) { $filter[] = ' p.products_id IN (' . implode(',', $keywords_id) . ')'; } if (count($keywords_code) > 0) { $filter[] = ' p.products_model IN (' . implode(',', $keywords_code) . ')'; } } else { $keywords_name[] = $keywords; } if (count($keywords_name) > 0) { foreach ($keywords_name as $kwn) { $filter[] = " pd.products_name LIKE '%{$kwn}%'"; } } } } $q .= " WHERE p.active_status = '1' AND "; if (count($filter) > 0) { $q .= implode(' OR ', $filter); } else { $q .= "pbg.status=1"; } $q .= " GROUP BY p.products_id"; $q .= " ORDER BY pl.sold_monthly_1 DESC"; $r = tep_db_query($q); while ($row = tep_db_fetch_array($r)) { $pid = $row['products_id']; $aid = '0'; if (!isset($products[$pid])) { $p = array(); $p['code'] = $row['products_model']; $p['image'] = $row['products_image']; $p['name'] = $row['products_name']; $p['sold_weekly'] = $row['weekly_sold']; $p['sold_monthly_1'] = $row['sold_monthly_1']; $p['sold_weekly_avg'] = $row['sold_monthly_1'] / 4; $p['fc_base_monthly'] = $row['fc_base_monthly']; $products[$pid] = $p; $products[$pid]['articles'] = array(); } $a = array(); foreach ($articles_data as $ad) { $a[$ad] = $row[$ad]; } $products[$pid]['articles'][$aid] = $a; } if (count($products) > 0) { //ADDITIONAL ARTICLE $q = "SELECT pa.products_id, pa.products_articles_id, pa.length AS article_length, pa.products_ean AS article_ean"; $q .= ", pal.weekly_sold AS article_weekly_sold, pal.sold_monthly_1 AS article_sold_monthly_1"; $q .= ", pal.fc_base_monthly AS article_fc_base_monthly, pal.fc_base_daily AS article_fc_base_daily"; $q .= ", (ps.stock - ps.booking_active) AS article_stock" . ", SUM(IF(do.trans_type IN (" . self::FILTER_TRANS_TYPE_ALLREFILL . "), do.quantity, 0)) AS article_orders_qty" . ", SUM(IF(do.trans_type = '" . self::TRANS_TYPE_NON_REFILL . "', do.quantity, 0)) AS article_nonrefill_qty"; $q .= " FROM products p"; $q .= " INNER JOIN products_articles pa ON pa.products_id=p.products_id"; $q .= " LEFT JOIN products_articles_log pal ON pal.products_articles_id=pa.products_articles_id"; $q .= " LEFT JOIN products_stock ps ON ps.jng_warehouses_id={$whid} AND ps.products_id=p.products_id AND ps.articles_id=pa.products_articles_id"; $q .= " LEFT JOIN depot_orders do ON do.segments_id={$segments_id} AND do.products_id=p.products_id AND do.articles_id=pa.products_articles_id AND do.status NOT IN (" . self::FILTER_STATUS_CLOSE . ")"; $q .= " WHERE p.products_id IN (" . implode(',', array_keys($products)) . ")"; $q .= " GROUP BY p.products_id, pa.products_articles_id"; $r = tep_db_query($q); while ($row = tep_db_fetch_array($r)) { $pid = $row['products_id']; $aid = $row['products_articles_id']; if (isset($products[$pid])) { $a = array(); foreach ($articles_data as $ad) { $a[$ad] = $row[$ad]; } $products[$pid]['articles'][$aid] = $a; } } foreach ($products as $pid => $p) { $recommend_product = false; $total_articles = count($p['articles']); if ($total_articles < 10) { $min_qty_per_article = $p['sold_weekly_avg'] / $total_articles; $products[$pid]['min_qty_per_article'] = $min_qty_per_article; $products[$pid]['qty_stock'] = 0; $products[$pid]['qty_order'] = 0; $products[$pid]['qty_nonrefill'] = 0; foreach ($p['articles'] as $aid => $a) { $products[$pid]['qty_stock'] += $a['article_stock']; $products[$pid]['qty_order'] += $a['article_orders_qty']; $products[$pid]['qty_nonrefill'] += $a['article_nonrefill_qty']; $current_level = $a['article_stock'] + $a['article_orders_qty']; if ($current_level < $min_qty_per_article) { $recommend_product = true; } } } else { $recommend_product = false; } if (!$recommend_product && count($filter) == 0) { unset($products[$pid]); } } } return $products; }
$eans[] = '4050878310202'; $eans[] = '4050878435202'; $eans[] = '4050878001780'; $eans[] = '4050878302702'; $eans[] = '4050878395483'; $eans[] = '4050878221843'; $eans[] = '4050878446529'; $eans[] = '4050878438951'; $eans[] = '4050878101862'; $eans[] = '4050878282493'; $eans[] = '4050878332631'; $eans[] = '4050878292652'; $eans[] = '4050878436681'; $eans[] = '4050878446871'; $po_pid_collection = array(); foreach ($eans as $ean) { $p = $class_ean->getProductArticle($ean); $po_pid_collection[$ean] = $p['products_id']; } $ean_detail_info = $class_jo->getAMVD_AutoCancelSupportingData($po_pid_collection, $sp_specsets); echo "<pre>"; //var_dump($ean_detail_info); echo "EAN,PID,CANCEL - Article Sold : Product Sold\n"; foreach ($po_pid_collection as $ean => $pid) { $result = $class_jo->checkAMVD_AutoCancelRule($ean, $ean_detail_info, $sp_specsets); echo "{$ean},{$pid},"; echo $result ? '1' : '0'; echo " - " . $ean_detail_info[$ean]['total_sold'] . " : " . $ean_detail_info[$ean]['total_sold_products']; echo "\n"; } echo "<pre>";
if (isset($do['products_id'])) { $products_id = $do['products_id']; } } elseif (strlen($entry) == 13) { $isean = false; foreach ($EAN_PREFIX as $ep) { $prefix_length = strlen($ep); if (substr($entry, 0, $prefix_length) == $ep) { $isean = true; break 1; } } if ($isean) { use_class('products_ean'); $class_ean = new products_ean(); $ean_info = $class_ean->getProductArticle($entry); if (isset($ean_info['products_id'])) { $products_id = $ean_info['products_id']; } } } if (is_null($products_id)) { $is_code = false; if (!is_numeric($entry)) { $is_code = true; } elseif ((strlen($entry) == 8 || strlen($entry) == 10) && substr($entry, 0, 1) == '0') { $is_code = true; } if ($is_code) { $q = tep_db_query("SELECT products_id FROM products WHERE products_model='{$entry}'"); if (tep_db_num_rows($q) > 0) {
} $order['daily_count'] = $daily_counter[$dateonly]; $order_id = $class_jo->importOrder($order); if (!is_null($order_id) && $order_id != '') { $orders_created_collection[] = $order_id; $orders_created++; $leadtime_start_date = $import_date; foreach ($xml_parser[$xfc]->orders_items[$oc] as $ic => $item) { if (count($item) > 0) { $item['jng_sp_orders_id'] = $order_id; $item['order_item_total'] = count($xml_parser[$xfc]->orders_items[$oc]); if (!isset($class_ean)) { use_class('products_ean'); $class_ean = new products_ean(); } $pdata = $class_ean->getProductArticle($item['products_ean']); $item['products_id'] = $pdata['products_id']; $item['products_articles_id'] = $pdata['products_articles_id']; if (!isset($item['price']) && isset($item['price_received'])) { //AT VAT = 20% $at_vat = 0.2; $real_commission = round($sp_detail['provision_rate'] * (1 + $at_vat), 2); $net_price = $item['price_received'] / (1 - $real_commission); $item['price'] = (1 + $at_vat) * $net_price; } $item['delivery_time'] = $sp_detail['delivery_time']; $item['delivery_replacement_time'] = 'null'; $item['confirm_order_time'] = date('Y-m-d H:i:s'); $item_id = $class_jo->addItem($order_id, $item); $products_created++; }
$class_do->eanPrintedSet($oiid); } $pid = $item['products_id']; $aid = $item['articles_id']; $ean = $item['products_ean']; $qty = $item['quantity']; $ean_printed = $item['ean_printed']; $barcode_id = "DP-{$oiid}"; break; } if (statusIsCancelled($item['status'])) { $cancel = true; $result['status'] = 'CANCEL'; } } elseif (strlen($product_input) == 13) { $pean = $class_ean->getProductArticle($product_input); $pid = $pean['products_id']; $aid = $pean['products_articles_id']; $ean = $product_input; } else { if (is_numeric($product_input) && substr($product_input, 0, 1) != '0') { $pid = $product_input; } else { $products = $class_pm->retrieveList("products_model='{$product_input}'"); $products_total = count($products); switch (count($products)) { case 0: break; case 1: $pid = $products[0]['products_id']; break;
} //echo "<pre>";var_dump($o);die(); $orders_id = $class_jo->importOrder($o); $items_ids = array(); if (!is_null($orders_id) && $orders_id > 0) { //NEW ORDER SUCCESSFULLY CREATED logThis(" = ORDER ID {$orders_id} created"); $orders_created[] = $orders_id; //ORDERS ITEMS $n_items = $order_data->ITEM_COUNT; $item = $order->ITEMS->ITEM; $n_item = 0; foreach ($item as $i) { $n_item++; $oi = array(); $pdata = $class_ean->getProductArticle($i->EAN); $oi['products_id'] = $pdata['products_id']; $oi['products_articles_id'] = $pdata['products_articles_id']; $oi['products_ean'] = $i->EAN; $oi['article_reference_number'] = $i->TB_ID; $oi['jng_sp_orders_id'] = $orders_id; $oi['article_number'] = $i->SKU; $oi['billing_text'] = $i->CHANNEL_SKU; $oi['order_quantity'] = $i->QUANTITY; $oi['delivery_time'] = $i->DELIVERY_TIME; $oi['delivery_replacement_time'] = 'null'; $oi['text'] = 'null'; $oi['price_received'] = !isset($i->TRANSFER_PRICE) || $i->TRANSFER_PRICE == 0 || $i->TRANSFER_PRICE == $i->ITEM_PRICE ? getPurchasePrice($i->ITEM_PRICE, $jng_sp_id) : $i->TRANSFER_PRICE; $oi['price'] = $i->ITEM_PRICE; $oi['order_item_count'] = $n_item; $oi['order_item_total'] = $n_items;
use_class('products_articles'); use_class('products_ean'); use_class('products_minierp'); $class_ean = new products_ean(); $class_pm = new products_minierp(); $class_pa = new products_articles(); if (isset($_POST['me_action'])) { if ($_POST['me_action'] == 'GETPRODUCTDETAIL') { $product_input = tep_db_prepare_input($_POST['product_input']); $result = false; $elements_datas = array(); $jng_warehouses_id = 1; if (strlen($product_input) == 13) { $ean = $product_input; $product_info = $class_ean->getProductArticle($ean); if (!empty($product_info['products_id']) && !is_null($product_info['products_id'])) { $products_id = $product_info['products_id']; $articles_id = $product_info['products_articles_id']; $product_data = $class_pm->retrieveDetail($products_id, 'p'); $elements_used = $class_pm->retrieveElementsUsage($products_id, $articles_id); foreach ($elements_used as $element) { $element_stock_query = "SELECT es.stock"; $element_stock_query .= " FROM elements_stock es"; $element_stock_query .= " WHERE es.jng_warehouses_id={$jng_warehouses_id}"; $element_stock_query .= " AND es.elements_id=" . $element['elements_id']; $element_stock_result = tep_db_query($element_stock_query); if (tep_db_num_rows($element_stock_result) > 0) { $element_stock = tep_db_fetch_array($element_stock_result); $el_stock = $element_stock[stock]; }
} else { $class_bin->removeProductFromBox($bins_id); if ($bin['p_stock'] > 0) { $class_pm->stockReduce($jng_warehouses_id, $products_id, $articles_id, $bin['p_stock'], "REDUCE by {$session_userinfo['username']}"); } header("Location: ?open=products-stock-detail&binid={$bin['bins_id']}" . ($hidemenuscript != '' ? '&hidemenu=true' : '')); exit; } } elseif ($_POST['me_action'] == 'SETBIN') { $bins_id = tep_db_prepare_input($_POST['bins_id']); $bin = $class_bin->retrieveBinDetail($bins_id); $ean = tep_db_prepare_input($_POST['ean']); $qty = tep_db_prepare_input($_POST['qty']); use_class('products_ean'); $class_ean = new products_ean(); $article = $class_ean->getProductArticle($ean); if ($article['products_id'] == '0') { $messagebox->add("<strong>Manual Bin In Failed: UNKNOWN EAN</strong><br />Please check if correct EAN Label is used"); } else { $segment = $class_bin->retrieveSegmentDetail($bin['bin_segments_id']); $jng_warehouses_id = $segment['warehouses_id']; $products_id = $article['products_id']; $articles_id = $article['products_articles_id']; $stock = $class_pm->stockRetrieveDetail($jng_warehouses_id, $products_id, $articles_id); $bin_current = $class_bin->getBinProductStock($stock['products_stock_id']); if (is_null($bin_current)) { $class_pm->stockAdd($jng_warehouses_id, $products_id, $articles_id, $qty, "MANUAL BIN-IN by {$session_userinfo['username']}"); $class_bin->bookBinForProduct($bins_id, $stock['products_stock_id']); header("Location: ?open=products-stock-detail&id={$stock['products_stock_id']}" . ($hidemenuscript != '' ? '&hidemenu=true' : '')); exit; } else {
if (!isset($_SESSION[$session_page]['viewall'])) { $_SESSION[$session_page]['viewall'] = '1'; } $view_all = $_SESSION[$session_page]['viewall']; //PAGING QUERY & LINKS if ($view_all == '1') { $filter_query = " WHERE (p.products_status='1' OR ps.stock>0)"; } else { $filter_query = " WHERE ps.stock>0"; } if ($keywords != '') { if (is_numeric($keywords)) { if (strlen($keywords) == 13) { use_class('products_ean'); $class_ean = new products_ean(); $pinfo = $class_ean->getProductArticle($keywords); if ($pinfo['products_id'] > 0) { unset($_SESSION[$session_page]['keywords']); header("Location: ?open=products-stock-detail&product=" . $keywords); exit; } } $filter_query .= " AND (p.products_id IN ({$keywords}) OR p.products_model LIKE '%{$keywords}%')"; } else { $filter_query_products_name = " AND pd.products_name LIKE '%{$keywords}%'"; $tmp_keywords = explode(',', $keywords); if (count($tmp_keywords) > 0) { if (is_numeric($tmp_keywords[0])) { $filter_query .= " AND p.products_id IN ({$keywords})"; } else { $filter_query .= $filter_query_products_name;