$result['status'] = 'UPDATED'; $class_jo->updateItemStatus($item_id, $status_new, $user_name); if ($status_current == '4' && $status_new == '5' && $item['prod_status'] != '') { tep_db_perform('jng_sp_orders_items', array('prod_status' => ''), 'update', "jng_sp_orders_items_id='{$item_id}'"); } if ($status_current == '4' && $status_new == '5' && $at_machine > 0) { //IF PRODUCT IS FINISH, ALSO SET ANTITARNISH USAGE $silver_usage = $class_jo->calcSilverUsage($item_id); antitarnishUsageAdd($at_machine, $silver_usage); } } } } } elseif ($order_type == 'JG') { //Handle J&G Orders $item = $class_o->retrieveProductDetail($item_id); $sub_status_different = "{$item['status']}-{$item['prod_status']}" != $status_new; if (isset($item['status'])) { $refill_qty_request = $item['products_quantity']; //Validate current status if ($item['status'] != $status_current && $sub_status_different) { //Handle invalid current status //ex 1: when trying to move from "ready" to "production", but current status is not "ready" //ex 2: when trynig to move from "production" to "finish", but current status is not "finish" $oiErrorStatus = oiErrorStatus($item['status']); if ($oiErrorStatus == 'MOVEDTODEPOT') { $result['status'] = 'UPDATED'; } else { $result['status'] = 'BADSTATUS'; $result['result_msg'] = $oiErrorStatus; }
/** * Get vip status of customer from an order * @param String $type * @param Int $orders_id * @return Boolean */ function checkCustomerIsVIP($type, $orders_id) { $type = strtoupper($type); $is_vip = false; if ($type == 'SP') { use_class('jng_sp_orders'); use_class('jng_sp_customers'); use_class('jng_sp_customers_special'); $class_jo = new jng_sp_orders(); $class_jc = new jng_sp_customers(); $class_jcs = new jng_sp_customers_special(); $o = $class_jo->retrieveDetail($orders_id); //GET CUSTOMER DETAIL VIP OR NOT $cust_data = $class_jc->retrieveDetail(null, $o['jng_sp_id'], $o['customer_billing_id']); if (is_array($cust_data) && $cust_data['jng_sp_customers_id'] > 0) { $cust_detail = $class_jcs->getCustomerDetail($cust_data['jng_sp_customers_id']); } $is_vip = $cust_detail['list_type'] == 'V'; } elseif ($type == 'JG') { use_class('orders'); use_class('customers_special_list'); $class_o = new orders(); $class_csl = new customers_special_list(); $o = $class_o->retrieveDetail($orders_id); //GET CUSTOMER DETAIL VIP OR NOT $cust_detail = $class_csl->getCustomerDetail($o['customers_id']); $is_vip = $cust_detail['list_type'] == 'V'; } elseif ($type == 'DP') { use_class('depot_orders'); $class_do = new depot_orders(); $do = $class_do->retrieveDetail($orders_id); if ($do['trans_type'] == 'SP' || $do['trans_type'] == 'JG') { if ($do['trans_type'] == 'SP') { use_class('jng_sp_orders'); $class_jo = new jng_sp_orders(); $it = $class_jo->retrieveItemDetail($do['trans_id']); $orders_id = $it['jng_sp_orders_id']; } elseif ($do['trans_type'] == 'JG') { use_class('orders'); $class_o = new orders(); $it = $class_o->retrieveProductDetail($do['trans_id']); $orders_id = $it['orders_id']; } $is_vip = checkCustomerIsVIP($do['trans_type'], $orders_id); } } return $is_vip; }
$result = '<div id="package-tip-header">' . $id_raw . '</div>'; //Validate barcode if (count($id_split) == 1) { //Barcode in unknown format $errinfo = 'Barcode must have prefix: <strong>"JG-"</strong>, <strong>"SP-"</strong> or <strong>"DP-"</strong><br />'; //$errinfo .= 'Please switch to <strong>Sales Partner</strong> or <strong>Julie & Grace</strong> for no prefix barcode'; $result .= printPackageTip('E', $box_date, $errinfo); } else { //Barcode valid //Set type and id for the process $type = $id_split[0]; $id = $id_split[1]; if ($type == 'SP') { $item = $class_jo->retrieveItemDetail($id); } elseif ($type == 'JG') { $item = $class_o->retrieveProductDetail($id); } //Check if order is already transfered as depot order //and make sure the transfered order is not canceled $item_do = $class_do->retrieveDetailTransmigran($type, $id); if (!is_null($item_do) && !statusIsCancelled($item_do['status'])) { //if yes, handle order as depot $type = 'DP'; $id = $item_do['depot_orders_id']; } else { //if no, check if need to transfer it as depot order $status_create_do = array('8', '9', '10', '11', '12', '20'); if (in_array($item['status'], $status_create_do)) { //yes, we need to transfer it //check if transfer is still possible if (realOrderIsPossibleToTransferred($type, $id)) {
function getOrderDetail($barcode = '', $idcode_ret = '') { //die("$barcode | $idcode_ret"); $result = array(); $result['status'] = 'MCORDERNOTFOUND'; use_class('jng_sp'); use_class('jng_sp_orders'); if ($barcode != '') { list($type, $order_product_id) = split('-', strtoupper($barcode)); //GET order_id $order_id = ''; if ($type == 'SP' || $type == 'JR') { $status = 'MCSCANPRODUCT'; use_class('jng_sp_customers'); $class_sp = new jng_sp(); $class_jo = new jng_sp_orders(); $class_jc = new jng_sp_customers(); $item = $class_jo->retrieveItemDetail($order_product_id); $order_id = $item['jng_sp_orders_id']; $order = $class_jo->retrieveDetail($order_id); if (count($order) > 0) { $sp = $class_sp->retrieveDetail($order['jng_sp_id']); $customer = $class_jc->retrieveDetail(null, $order['jng_sp_id'], $order['customer_billing_id']); $customer_name = $order['customer_billing_firstname'] . ' ' . $order['customer_billing_lastname']; $customers_street_address = $order['customer_billing_address'] . ' ' . $order['customer_billing_address2']; $order_type = $sp['name'] . ' Order ' . $order['order_id']; $result = setOrderResult($status, 'S', $order_id, $order_type, $customer['jng_sp_customers_id'], $customer_name, $order['customer_billing_email'], $order['customer_billing_phone'], $customers_street_address, $order['customer_billing_postcode'], $order['customer_billing_city'], $order['customer_billing_country']); } } elseif ($type == 'JG') { $status = 'MCSCANPRODUCT'; use_class('orders'); $class_o = new orders(); $item = $class_o->retrieveProductDetail($order_product_id); $order_id = $item['orders_id']; $order = $class_o->retrieveDetail($order_id); if (count($order) > 0) { $order_type = 'J&G Order ' . $order['orders_no']; $result = setOrderResult($status, 'J', $order_id, $order_type, $order['customers_id'], $order['customers_name'], $order['customers_email_address'], $order['customers_telephone'], $order['customers_street_address'], $order['customers_postcode'], $order['customers_city'], $order['customers_country']); } } } elseif ($idcode_ret != '') { //1 idcode_ret utk 1 order $qsp = "SELECT j.name AS sp_name, jo.* FROM jng_sp_orders jo INNER JOIN jng_sp j ON j.jng_sp_id = jo.jng_sp_id"; $qsp .= " WHERE idcode_ret = '{$idcode_ret}' ORDER BY jo.order_date DESC LIMIT 1"; $rsp = tep_db_query($qsp); $dsp = tep_db_num_rows($rsp) > 0 ? tep_db_fetch_array($rsp) : null; if (is_null($dsp)) { /* 12.05.2015: * If not found, try to search using order number. * So far at this time, returns from LZ.ID, ZR.ID, ZR.BR used order number barcode */ $qsp = "SELECT j.name AS sp_name, jo.* FROM jng_sp_orders jo INNER JOIN jng_sp j ON j.jng_sp_id = jo.jng_sp_id"; $qsp .= " WHERE jo.order_id = '{$idcode_ret}' ORDER BY jo.order_date DESC LIMIT 1"; $rsp = tep_db_query($qsp); $dsp = tep_db_num_rows($rsp) > 0 ? tep_db_fetch_array($rsp) : null; } $qjg = "SELECT * FROM orders WHERE idcode_ret='{$idcode_ret}' ORDER BY date_purchased DESC LIMIT 1"; $rjg = tep_db_query($qjg); $djg = tep_db_num_rows($rjg) > 0 ? tep_db_fetch_array($rjg) : null; if (!is_null($dsp) || !is_null($djg)) { $status = 'MCSCANPRODUCT'; if (!is_null($dsp) && !is_null($djg)) { $dsp_time = strtotime($dsp['order_date']); $djg_time = strtotime($djg['date_purchased']); $use_data = $dsp_time >= $djg_time ? 'sp' : 'jg'; } else { $use_data = !is_null($dsp) ? 'sp' : 'jg'; } if ($use_data == 'sp') { $order_id = $dsp['jng_sp_orders_id']; use_class('jng_sp_customers'); $class_jc = new jng_sp_customers(); $customer = $class_jc->retrieveDetail(null, $dsp['jng_sp_id'], $dsp['customer_billing_id']); $customer_name = $dsp['customer_billing_firstname'] . ' ' . $dsp['customer_billing_lastname']; $customers_street_address = $dsp['customer_billing_address'] . ' ' . $dsp['customer_billing_address2']; $order_type = $dsp['sp_name'] . ' Order ' . $dsp['order_id']; $result = setOrderResult($status, 'S', $order_id, $order_type, $customer['jng_sp_customers_id'], $customer_name, $dsp['customer_billing_email'], $dsp['customer_billing_phone'], $customers_street_address, $dsp['customer_billing_postcode'], $dsp['customer_billing_city'], $dsp['customer_billing_country']); } else { $order_id = $djg['orders_id']; $order_type = 'J&G Order ' . $djg['orders_no']; $result = setOrderResult($status, 'J', $order_id, $order_type, $djg['customers_id'], $djg['customers_name'], $djg['customers_email_address'], $djg['customers_telephone'], $djg['customers_street_address'], $djg['customers_postcode'], $djg['customers_city'], $djg['customers_country']); } } } return $result; }
function createReturnContainer($return_id, $return_qty, $opid) { use_class('orders'); use_class('payone_invoice'); use_class('minierp_customers'); $class_o = new orders(); $class_pi = new payone_invoice(); $class_cust = new minierp_customers(); $insert_id = ''; $op = $class_o->retrieveProductDetail($opid); $order_id = $op['orders_id']; $order = $class_o->retrieveDetail($order_id, true); $customers_id = $order['customers_id']; $item = $class_o->retrieveProductDetail($opid); $final_price = $item['final_price']; //CHECK WHETHER CUSTOMER USING COUPON DISCOUNT OR NOT (ONLY ON JNG ORDERS) $qcheck_disc = "SELECT c.* FROM `coupon_redeem_track` crt INNER JOIN `coupons` c\n ON crt.`coupon_id` = c.`coupon_id`\n WHERE crt.`order_id` = {$order_id}"; $dbq_disc = tep_db_query($qcheck_disc); if (tep_db_num_rows($dbq_disc) > 0) { $r_disc = tep_db_fetch_array($dbq_disc); $disc = $r_disc['coupon_amount']; if ($disc > 0 && $disc < 1) { $final_price = $final_price - $final_price * $disc; $final_price = ceil($final_price * 100) / 100; //take only 2 digits decimals ex: 21.165 became 21.16 } } $customer = $class_cust->retrieveDetail($customers_id); $customer_bankdata = $class_cust->getBankAccountData($order_id); $class_pi->retrieveDetail("J", $order_id); //ONLY QUEING JUST FOR TRANSACTION THAT HAVE payone_txid (FIRST GET FROM SUBMITTING INVOICE) if ($class_pi->detail['payone_txid'] != '') { $payone_txid = $class_pi->detail['payone_txid']; $payment_method = $order['payment_method']; $data_por = array(); $data_por['return_id'] = $return_id; $data_por['jng_sp_orders_items_id'] = $item['orders_products_id']; $data_por['jng_sp_customers_id'] = $customer['customers_id']; $data_por['amount'] = round($return_qty * ($final_price * 100)); $data_por['txid'] = $payone_txid; $data_por['invoice_id'] = $class_pi->detail['invoice_id']; $data_por['invoice_no'] = $class_pi->detail['invoice_no']; $data_por['id'] = $item['products_model']; $data_por['pr'] = round($final_price * 100); $data_por['no'] = $return_qty; $data_por['de'] = strlen($item['products_name']) > 32 ? substr($item['products_name'], 0, 32) : $item['products_name']; $data_por['va'] = 0; $data_por['payment_method'] = $payment_method; $data_por['currency'] = 'EUR'; if (!is_null($customer_bankdata)) { $data_por['bankcode'] = $customer_bankdata['banktransfer_blz']; $data_por['bankcountry'] = 'DE'; $data_por['bankaccount'] = $customer_bankdata['banktransfer_number']; $data_por['bankaccountholder'] = $customer_bankdata['banktransfer_owner']; } // echo "<pre>";var_dump($data_por); $insert_id = $this->payoneReturnItemContainer($data_por); $items_q = tep_db_query("SELECT SUM(products_quantity) AS total FROM orders_products WHERE orders_id={$order_id} AND status NOT IN (10, 12)"); $items = tep_db_fetch_array($items_q); $items_total = $items['total']; $returns_q = "SELECT SUM(opr.return_qty) AS total" . " FROM orders_products op" . " LEFT JOIN orders_products_return opr" . " ON opr.orders_products_id = op.orders_products_id" . " WHERE op.orders_id={$order_id}" . " AND op.status NOT IN (10, 12)"; $returns_r = tep_db_query($returns_q); $returns = tep_db_fetch_array($returns_r); $returns_total = $returns['total']; if ($items_total == $returns_total) { $amount_paid = $class_pi->detail['invoice_amount_paid']; $total_costs = $order['shipping_costs'] + $order['cod_costs']; if ($order['shipping_costs'] > 0) { // if((($amount_paid*1)==0)||(($amount_paid<>$order['shipping_costs'])&&($amount_paid<>$total_costs))){ if ($amount_paid * 1 == 0 || $amount_paid > $total_costs) { $q_check = "SELECT * FROM payone_orders_return WHERE txid = '{$payone_txid}' AND id = 'Shipping'"; $dbc = tep_db_query($q_check); if (tep_db_num_rows($dbc) == 0) { //HANDLE DOUBLE OR MORE SHIPING RETURN CONTAINER $amount = round($order['shipping_costs'] * 100); $data_por = array(); $data_por['return_id'] = 0; $data_por['jng_sp_orders_items_id'] = 0; $data_por['jng_sp_customers_id'] = $customer['customers_id']; $data_por['amount'] = $amount; $data_por['txid'] = $payone_txid; $data_por['invoice_id'] = $class_pi->detail['invoice_id']; $data_por['invoice_no'] = $class_pi->detail['invoice_no']; $data_por['id'] = 'Shipping'; $data_por['pr'] = $amount; $data_por['no'] = 1; $data_por['de'] = 'Verpackung & Versand'; $data_por['va'] = 0; $data_por['payment_method'] = $payment_method; $data_por['currency'] = 'EUR'; $insert_id = $this->payoneReturnItemContainer($data_por); } } } } } else { //ORDER NOT SUBMITTED YET TO PAYONE, SO NO TXID CREATED YET. JUST NEED TO EXCLUDE ITEM FROM payone_invoice TABLE COLUMN 'invoice_order_items_id' $oids_arr = explode(',', $class_pi->detail['invoice_order_items_id']); if (is_array($oids_arr)) { $new_amount = $class_pi->detail['invoice_amount'] - $return_qty * $final_price; foreach ($oids_arr as $key => $value) { if ($value == $opid) { unset($oids_arr[$key]); } } $oids = implode(',', $oids_arr); if (count($oids_arr) == 0) { //ALL PRODUCTS RETURNED $new_amount = 0; $class_pi->updateCompleteStatus('3'); //INVOICE CANCELLED } tep_db_perform('payone_invoice', array('invoice_amount' => $new_amount, 'invoice_order_items_id' => $oids), 'update', "invoice_id = '" . $class_pi->detail['invoice_id'] . "'"); } } return $insert_id; }
use_class('orders'); use_class('depot_orders'); use_class('production_instruction_pdf'); $class_pi = new production_instruction_pdf(); $opids = explode(',', $_GET['opid']); foreach ($opids as $opid) { $type = strtoupper($type); $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) {
} elseif ($status_tab == '4') { if (in_array($item_status, $status_depos)) { $result = "<strong>JG-{$items_id}</strong> is moved to HH<br /><strong class='red'>REMOVE PI and PUT PRODUCT TO DEPO BOX</strong>"; } } if (is_null($result)) { $result = "<strong>JG-{$items_id}</strong> Status is now <strong>" . statusName($item_status) . '</strong>'; } return $result; } if ($_POST['me_action'] == 'CHECKOISTATUS') { $result = null; $items_id = tep_db_prepare_input($_POST['op_id']); $status_tab = tep_db_prepare_input($_POST['status_tab']); $status_depos = array('8', '9', '11'); $item = $class_o->retrieveProductDetail($items_id); if (count($item) == 0) { $result = "<br /><strong>JG-{$items_id}</strong> is not found"; } else { $result = '<br />' . oiErrorStatus($items_id, $item['status'], $status_tab); } echo utf8_encode($result); exit; } elseif ($_POST['me_action'] == 'REFRESHPRODUCTCOUNTER') { $status_counter = $class_o->productStatusCounter($statusNameShow, $ean_list, $date_range_start, $date_range_end, $brand_id, $cat_id); $result = array(); foreach ($status_counter as $status => $counter) { $result[] = "{$status},{$counter}"; } ajaxReturn($result); exit;
if (is_numeric($partnertype)) { $reqid = $partnertype; $partnertype = 'sp'; } if (!empty($reqid) && $reqid != '') { global $db; require_once '../confy.php'; require_once '../functions.php'; require_once '../functions-2.php'; tep_db_connect(); #switch partner prefix switch ($partnertype) { case 'jg': use_class('orders'); $o_o = new orders(); $products = $o_o->retrieveProductDetail($reqid); #header("Content-Type: text/plain; charset=utf-8"); switch ($barcodetype) { case 'code39': #table orders,products,dll. $order_id = $products["orders_id"]; $article_number = $products["products_model"]; $order_item_count = $products["order_item_count"]; $order_item_total = $products["order_item_total"]; $order_qty = $products["products_quantity"]; #table orders $orders = $o_o->retrieveDetail($order_id); $order_no = $orders["orders_no"]; $order_date = strtotime($orders["date_purchased"]); $day = date("d", $order_date); $month = date("M", $order_date);
function updateStatus($items_id, $new_status, $updater = '', $add_to_prod_target = true) { use_class('production_target'); $pt = new production_target(); list($new_status, $sub_status) = explode('-', $new_status); $item = $this->retrieveDetail($items_id); $is_outsourced = $this->isOutsourceOrder($item['trans_type'], $item['trans_id']); $timestamp = date('Y-m-d H:i:s'); $sub_status = trim(strtoupper($sub_status)); if ($new_status == '10') { $this->doCancelOrders($items_id, $item['status'], $updater); } else { if ($add_to_prod_target) { if (!$is_outsourced) { //outsourcing orders should never affect the Finish KPI Graphs if ($new_status == '5') { $pt->addDataToField($timestamp, 'finish', $item['quantity']); } } if ($new_status == '6') { $pt->addDataToField($timestamp, 'package', $item['quantity']); } if ($new_status == '7') { $pt->addDataToField($timestamp, 'sent', $item['quantity']); } } if ($new_status == '4' && $sub_status != '') { $set_prod_status = ", prod_status = '" . $sub_status . "'"; } //PS: please don't set empty prod_status when it updated to status > 4,... //...since this will used for check whether order could transferred to DP or not... //...when real order taken over by HH while order still on production tep_db_query("UPDATE depot_orders SET status='{$new_status}' {$set_prod_status} WHERE depot_orders_id={$items_id}"); $save_main_status_history = true; //if ( ( in_array($item['status'], array('1','3','4','5')) && $new_status=='4' ) && ( $sub_status!='' && ( trim(strtoupper($item['prod_status'])) != $sub_status ) ) ) { /* $item['status'] = 1 is included here to also save prod. status history when there's real order cancelled/taken over by hh caused using depot hh stock while real order is already processed in production, finish, or in package. The first status created was 1. */ //replace using below, allowing all process which set to production to have a chance saving the prod. status history if ($new_status == '4' && $sub_status != '' && trim(strtoupper($item['prod_status'])) != $sub_status) { $psh = array(); $psh['orders_items_id'] = $items_id; $psh['type'] = 'DP'; $psh['status'] = $sub_status; $psh['status_quantity'] = $item['quantity']; $psh['status_date'] = $timestamp; $psh['update_by'] = $updater; saveProductionStatusHistory($psh); if ($item['status'] == '4') { $save_main_status_history = false; } } if ($save_main_status_history) { $sda = array(); $sda['depot_orders_id'] = $items_id; $sda['status'] = $new_status; $sda['update_time'] = $timestamp; $sda['update_by'] = $updater; tep_db_perform('depot_orders_status_history', $sda); } if (!$is_outsourced) { if ($new_status == '2' && $item['stock_status'] != 'S' && $item['stock_status'] != 'W') { $this->updateStockStatus($items_id, false); $this->prodStatusReset($items_id); $this->eanPrintedReset($items_id); //$this->printCountReset($items_id); //now we don't need to reset print_count for reprint pi when move to ready again. } elseif ($new_status == '3' && $item['stock_status'] == 'S' || $new_status == '4' && $item['stock_status'] == 'W') { $eu = $this->countElementsUsage($item['products_id'], $item['articles_id']); if (count($eu) > 0) { $jng_warehouses_id = '1'; use_class('elements_stock'); $class_es = new elements_stock(); foreach ($eu as $elements_id => $euqty) { $reduce_amount = $item['quantity'] * $euqty; $class_es->reduceStockByPieces($jng_warehouses_id, $elements_id, $reduce_amount, 'RED DP-' . $items_id); } } $this->updateStockStatus($items_id, 'R'); } } } switch ($item['trans_type']) { case 'SP': use_class('jng_sp_orders'); $class_jo = new jng_sp_orders(); $item_sp = $class_jo->retrieveItemDetail($item['trans_id']); if ($item['status'] == '1' && ($new_status == '2' || $new_status == '3')) { $class_jo->productionTargetIn($timestamp, $item_sp); } elseif ($new_status == '6') { $class_jo->productionTargetOut($timestamp, $item_sp); } elseif ($new_status == '12') { $class_jo->productionTargetInReset($item_sp); } break; case 'JG': use_class('orders'); $class_o = new orders(); $item_jg = $class_o->retrieveProductDetail($item['trans_id']); if ($item['status'] == '1' && ($new_status == '2' || $new_status == '3')) { $class_o->productionTargetIn($timestamp, $item_jg); } elseif ($new_status == '6') { $class_o->productionTargetOut($timestamp, $item_jg); } elseif ($new_status == '12') { $class_o->productionTargetInReset($item_jg); } break; default: if ($item['status'] == '1' && ($new_status == '2' || $new_status == '3')) { $this->productionTargetIn($timestamp, $item); } elseif ($new_status == '6') { $this->productionTargetOut($timestamp, $item); } elseif ($new_status == '12') { $this->productionTargetInReset($item); } } if ($new_status == '3' && !$is_outsourced) { //use_class('production_instruction_pdf'); //$class_pi = new production_instruction_pdf(); if ($item['print_count'] > 0 && $item['print_confirmed'] > 0) { //SECOND OR MORE PI PRINTED, could happen when there product by stock_status is "OK" but in real stock is "0" so this will set back to "NS". And when ready this will reprinted by using this block $this->printConfirmReset($items_id); $this->printCountReset($items_id); } /* $class_pi->addOrder('DP', $items_id); $add_to_daily_statistic = $item['print_count']==0 ? true : false; $class_pi->createPDF(false, 'F', $add_to_daily_statistic); */ } return $new_status; }
$class_orders = new orders(); $class_jo = new jng_sp_orders(); $class_pean = new products_ean(); $class_pm = new products_minierp(); list($reqid, $barcodetype) = split(";", strtolower(trim($_SERVER['QUERY_STRING']))); list($partnertype, $reqid) = split("-", $reqid); if (is_numeric($partnertype)) { $reqid = $partnertype; $partnertype = 'sp'; } if (!empty($reqid) && $reqid != '') { $partners_need_ean13 = array('3'); #switch partner prefix switch ($partnertype) { case 'jg': $products = $class_orders->retrieveProductDetail($reqid); #header("Content-Type: text/plain; charset=utf-8"); switch ($barcodetype) { case 'code39': #table orders,products,dll. $order_id = $products["orders_id"]; $article_number = $products["products_model"]; $order_item_count = $products["order_item_count"]; $order_item_total = $products["order_item_total"]; $order_qty = $products["products_quantity"]; #table orders $orders = $class_orders->retrieveDetail($order_id); $order_no = $orders["orders_no"]; $order_date = strtotime($orders["date_purchased"]); $day = date("d", $order_date); $month = date("M", $order_date);
$order['shipment_id'] = $invoice->detail['invoice_no']; } $reference = $order['shipment_id']; $cod_value = $order['payment_method'] == 'CASH_ON_DELIVERY' ? number_format($invoice->detail['invoice_amount'], 2, ',', '') : 0; break; } if ($order['customer_shipping_address2'] != '') { $shipping_address .= ' ' . $order['customer_shipping_address2']; } $mc_order = mc_orderDetail($order['jng_sp_id'], $reference, $display_counter, $shipping_name, $shipping_address, $order['customer_shipping_city'], $order['customer_shipping_postcode'], $cod_value); } } } elseif ($order_type == 'JG') { use_class('orders'); $class_o = new orders(); $i_temporary = $class_o->retrieveProductDetail($item_id); if (isset($i_temporary['status']) && $i_temporary['status'] != $REQUIRED_STATUS) { $i_status = $class_o->productStatusName(); $result['status'] = 'BADSTATUS'; $result['badstatus'] = $i_status[$i_temporary['status']]; } else { $order_id = $i_temporary['orders_id']; $order = $class_o->retrieveDetail($order_id); if (isset($order['orders_id'])) { $display_counter = dailyCounterNo($order['date_purchased'], $order['daily_count']); $mc_order = mc_orderDetail('0', 'JG' . $order['orders_id'], $display_counter, $order['delivery_name'], $order['delivery_street_address'], $order['delivery_city'], $order['delivery_postcode'], 0); } } } else { $order_id = ''; $result['status'] = 'BADREQUEST';
$t['id2'] = 'Order Source'; $t['id3'] = 'Article No'; $t['q'] = 'Price'; $t['s'] = 'Qty'; $table[] = $t; while ($row = tep_db_fetch_array($res)) { $type = '<span class="notice">Manual</span>'; if ($row['trans_type'] == 'SP') { use_class('jng_sp_orders'); $class_jo = new jng_sp_orders(); $item_source = $class_jo->retrieveItemDetail($row['trans_id']); $type = '<a href="/?open=sp-order&id=' . $item_source['jng_sp_orders_id'] . '&oiid=' . $row['trans_id'] . '&hidemenu=true" class="view_webpage">' . $row['trans_type'] . '-' . $row['trans_id'] . '</a>'; } elseif ($row['trans_type'] == 'JG') { use_class('orders'); $class_o = new orders(); $item_source = $class_o->retrieveProductDetail($row['trans_id']); $type = '<a href="/?open=order&id=' . $item_source['orders_id'] . '&opid=' . $row['trans_id'] . '&hidemenu=true" class="view_webpage">' . $row['trans_type'] . '-' . $row['trans_id'] . '</a>'; } $t = array(); $t['d'] = date('d-M-y', strtotime($row['order_date'])); $t['id1'] = '<a href="?open=depot-order&id=' . $row['depot_orders_id'] . '&hidemenu=true" class="view_webpage">DP-' . $row['depot_orders_id'] . '</a>'; $t['id2'] = $type; $length = textLength($row['article_length'] > 0 ? $row['article_length'] : $row['products_length'], false); $row['article_number'] = $row['products_model'] . ($length > 0 ? '_' . $length : ''); $article = '<div><a href="?open=product-detail&products_id=' . $row['products_id'] . '" target="_blank" title="View Product Detail">' . $row['article_number'] . '</a></div>'; $pimg = webImageSource($row['products_image'], '500'); if ($pimg != '') { $thumb = '<div class="thumb" style="display:none;"><a href="' . $pimg . '" class="view_image" title="View Image of ' . $row['article_number'] . '">' . webImage($row['products_image'], '80', '80', '', 'img-border img-padding') . '</a></div>'; $article = $thumb . $article; } $t['id3'] = $article;
function retrieveData($barcode_type, $barcode_id) { use_class('jng_sp'); use_class('orders'); use_class('jng_sp_orders'); use_class('depot_orders'); use_class('products_ean'); use_class('products_minierp'); $class_sp = new jng_sp(); $class_orders = new orders(); $class_jo = new jng_sp_orders(); $class_do = new depot_orders(); $class_pean = new products_ean(); $class_pm = new products_minierp(); $result = ''; //list($partner_type,$order_product_id) = split("-",$barcode_id); //$partner_type = strtolower($partner_type); $tmp_bcid = explode('-', $barcode_id); $partner_type = strtolower($tmp_bcid[0]); $order_product_id = $tmp_bcid[1]; if (is_numeric($partner_type)) { $order_product_id = $partner_type; $partner_type = 'sp'; } //all id without prefix JG or SP indicates as SP if (!empty($order_product_id) && $order_product_id != '') { $partners_need_ean13 = array('3'); #switch partner prefix switch ($partner_type) { case 'jg': $products = $class_orders->retrieveProductDetail($order_product_id); #header("Content-Type: text/plain; charset=utf-8"); switch ($barcode_type) { case 'code39': if (count($products) > 0) { #table orders,products,dll. $order_id = $products["orders_id"]; $article_number = $products["products_model"]; $order_item_count = $products["order_item_count"]; $order_item_total = $products["order_item_total"]; $order_qty = $products["products_quantity"]; #table orders $orders = $class_orders->retrieveDetail($order_id); $order_no = $orders["orders_no"]; $order_date = strtotime($orders["date_purchased"]); $day = date("d", $order_date); $month = date("M", $order_date); $daily_count = $orders["daily_count"]; #format return label >> date;number;orderseq;nametag;kunde;auftragsnr;lieferscheinnr;qty;artikel $label_date = $day . ". " . $month; $label_order_seq = $order_item_count . "/" . $order_item_total; $label_cust_name = $orders["delivery_name"]; $qcountry = "SELECT countries_iso_code_2 FROM countries WHERE countries_name = '{$orders['delivery_country']}'"; $dbqcountry = tep_db_query($qcountry); $rescountry = tep_db_fetch_array($dbqcountry); $label_suffix = $rescountry['countries_iso_code_2'] != '' ? ".{$rescountry['countries_iso_code_2']}" : ""; $label_numtag = "JG" . $label_suffix; $label_auftragsnr = $order_no == '' ? "-" : $order_no; $label_lieferscheinnr = ''; $return_label = $label_date . ";" . $daily_count . ";" . $label_order_seq . ";" . $label_numtag . ";" . $label_cust_name; $return_label .= ";" . $label_auftragsnr . ";" . $label_lieferscheinnr . ";" . $order_qty . ";" . $article_number . ";" . $order_product_id . ";" . $partner_type; $result = $return_label; } else { $result = "no data"; } break; case 'ean13': if (count($products) > 0) { $result = $this->getEANReturnResult($partner_type, $products); } else { $result = "no data"; } break; } break; case 'sp': $oi = $class_jo->retrieveItemDetail($order_product_id); $order_id = $oi["jng_sp_orders_id"]; $o = $class_jo->retrieveDetail($order_id); $sp_id = $o["jng_sp_id"]; #header("Content-Type: text/plain; charset=utf-8"); switch ($barcode_type) { case 'code39': if (count($oi) > 0) { #table jng_sp_orders_items // $order_qty = $oi["order_quantity"] * 1; $article_number = $oi["article_number"]; $order_item_count = $oi["order_item_count"]; $order_item_total = $oi["order_item_total"]; $order_qty = intval($oi["order_quantity"]); #table jng_sp_orders $order_no = $o["order_id"]; $class_ordersrder_date = strtotime($o["order_date"]); $day = date("d", $class_ordersrder_date); $month = date("M", $class_ordersrder_date); $daily_count = $o["daily_count"]; $shipment_id = $o["shipment_id"]; $cust_fname = $o["customer_shipping_firstname"]; $cust_lname = $o["customer_shipping_lastname"]; #table jng_sp $jngsp = $class_sp->retrieveDetail($sp_id); $prefix_num = $jngsp["package_prefix"]; #format return label >> date;number;orderseq;nametag;kunde;auftragsnr;lieferscheinnr;qty;artikel $label_date = $day . ". " . $month; $label_order_seq = $order_item_count . "/" . $order_item_total; $label_cust_name = $cust_fname . " " . $cust_lname; $label_numtag = $prefix_num == '' ? "-" : $prefix_num; $label_auftragsnr = $order_no == '' ? "-" : $order_no; $label_lieferscheinnr = $shipment_id; $return_label = $label_date . ";" . $daily_count . ";" . $label_order_seq . ";" . $label_numtag . ";" . $label_cust_name; $return_label .= ";" . $label_auftragsnr . ";" . $label_lieferscheinnr . ";" . $order_qty . ";" . $article_number . ";" . $order_product_id . ";" . $partner_type; if (in_array($sp_id, $partners_need_ean13)) { if (count($oi) > 0) { $cats = $class_jo->getCategories($order_id); $oi_product_id = $oi["products_id"]; $oi_product_article_id = $oi["products_articles_id"]; $ean = $oi_product_article_id != '' ? $class_pean->getEAN($oi_product_id, $oi_product_article_id) : $class_pean->getEAN($oi_product_id); if ($ean != '') { $label_material = "925er SILBER"; $return_label .= ";" . $ean . ";" . strtoupper($cats['categories_name']) . ";" . $label_material . ";" . $oi['price'] . " EUR;{$order_qty};{$o['jng_sp_id']}"; } } } $result = $return_label; } else { $result = "no data"; } break; case 'ean13': if (count($oi) > 0) { $result = $this->getEANReturnResult($partner_type, $oi, $sp_id); } else { $result = "no data"; } break; } break; case 'dp': //ONLY PRODUCT LABEL / ean13 $do = $class_do->retrieveDetail($order_product_id); switch ($barcode_type) { case 'code39': $article_number = $do["products_ean"]; $order_item_count = '1'; $order_item_total = '1'; $order_qty = intval($do["quantity"]); $daily_count = $order_qty . 'x'; #format return label >> date;number;orderseq;nametag;kunde;auftragsnr;lieferscheinnr;qty;artikel $label_date = "Quantity: "; $label_order_seq = "{$order_item_count}/{$order_item_total}"; $label_cust_name = 'Outsourcing'; $label_numtag = '-'; $label_auftragsnr = '-'; $label_lieferscheinnr = '-'; $return_label = $label_date . ";" . $daily_count . ";" . $label_order_seq . ";" . $label_numtag . ";" . $label_cust_name; $return_label .= ";" . $label_auftragsnr . ";" . $label_lieferscheinnr . ";" . $order_qty . ";" . $article_number . ";" . $order_product_id . ";" . $partner_type; $result = $return_label; break; case 'ean13': default: if (count($do) > 0) { $do['products_articles_id'] = $do['articles_id']; $result = $this->getEANReturnResult($partner_type, $do); } else { $result = "no data"; } } break; } } else { $result = "no data"; } return $result; }
if ($waxing['status'] == $old_status) { $class_ow->updateStatus($waxing_id, $new_status, $session_userinfo['username']); if ($new_status == '5') { //Set order product to finish if waxing status is finish $set_product_status = true; $opid = $waxing['orders_products_id']; $ow_data = $class_ow->retrieveByOrderProducts($opid); foreach ($ow_data as $ow) { if ($ow['status'] < 5) { $set_product_status = false; break 1; } } if ($set_product_status) { $op_old_status = '4'; $product = $class_o->retrieveProductDetail($opid); if ($product['status'] == $op_old_status) { $class_o->updateProductStatus($opid, $new_status, $session_userinfo['username']); } } } elseif ($new_status == '7') { if ($waxing['image_id'] != '') { $q = tep_db_query("SELECT * FROM customers_images WHERE id={$waxing['image_id']}"); if (tep_db_num_rows($q) > 0) { $ci = tep_db_fetch_array($q); $to_name = 'F2F'; $to_email_address = '*****@*****.**'; $opid = 'JG-' . $waxing['orders_products_id']; $imglink = JNGWEBADDRESS . 'images/' . $ci['customers_image']; $imglink = '<a href="' . $imglink . '">' . $imglink . '</a>'; include DIR_WS_EMAILS . $languages[1]['path'] . '/orders-engraving.php';
$content .= '<h3 class="red">Depot Order ' . $order_id . ' is not found in Database'; } else { $statusName = statusNameShort(); $bih_start_date = $do['order_date']; $bih_end_date = null; if ($do['trans_type'] == 'SP') { use_class('jng_sp_orders'); $class_jo = new jng_sp_orders(); $itrans = $class_jo->retrieveItemDetail($do['trans_id']); $otrans = $class_jo->retrieveDetail($itrans['jng_sp_orders_id']); $bih_start_date = $otrans['order_date']; $order_source = $class_do->translateOrderSource($do['trans_type'], $do['trans_id'], false, $itrans['jng_sp_orders_id'], $do['products_id']); } elseif ($do['trans_type'] == 'JG') { use_class('orders'); $class_o = new orders(); $itrans = $class_o->retrieveProductDetail($do['trans_id']); $otrans = $class_o->retrieveDetail($itrans['orders_id']); $bih_start_date = $otrans['date_purchased']; $order_source = $class_do->translateOrderSource($do['trans_type'], $do['trans_id'], false, $itrans['orders_id'], $do['products_id']); } else { $order_source = $class_do->translateOrderSource($do['trans_type'], $do['trans_id'], false, null, $do['products_id']); } $status_date = null; $history = $class_do->retrieveHistory($order_id); $history_prod = retrieveProductionHistory('DP', $order_id); $htable = array(); $ht = array(); $ht['sort'] = 'No'; $ht['date_add'] = 'Date'; $ht['status'] = 'Status'; $ht['login'] = '******';