//$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)) { //yes, then let's transfer it if (is_null($item_do)) { $item_do = $class_do->transferFromRealOrder(SEGMENT_ID_HAMBURG, $type, $id); } //Update depot order status to "FINISH"
function addOrder($type, $order_id, $items = null) { global $class_jo, $class_o, $class_do, $class_jc, $class_jcs, $class_csl, $class_bins, $pi_country_code; //load settings for red paper $pi_settings = load_config('production-instruction-settings'); $sp_using_red_paper = explode(',', $pi_settings['red-paper-sp-id']); $brand_using_red_paper = explode(',', $pi_settings['red-paper-brand-id']); /* - $items COULD BE MULTIPLE, "ARRAY" OR "STRING WITH COMMA SEPARATED" - MULTIPLE $items "ONLY" FOR SP AND JG, FOR DP PLEASE CALL addOrder REPEATEDLY */ $order_key = $type . 'O' . $order_id; if (!is_null($items)) { $is = array(); if (!is_array($items)) { $items = explode(',', $items); } } switch (strtoupper($type)) { case 'SP': $o = $class_jo->retrieveDetail($order_id); //if(is_null($items)) $is = $class_jo->retrieveItems($order_id); //else foreach($items as $item_id) $is[] = $class_jo->retrieveItemDetail($item_id); $is = $class_jo->retrieveItems($order_id); if (!is_null($items)) { foreach ($is as $key => $is_temp) { if (!in_array($is_temp['jng_sp_orders_items_id'], $items)) { unset($is[$key]); } } } //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']); } $order = array(); $order['type'] = $type; $order['id'] = $order_id; $order['jng_sp_id'] = $o['jng_sp_id']; $order['code'] = $o['order_id'] == '' ? 'J&G ID: ' . $order_id : $o['order_id']; $order['date'] = $o['order_date']; $order['daily_count'] = $o['daily_count']; $order['shipto_name'] = "{$o['customer_shipping_firstname']} {$o['customer_shipping_lastname']}"; $order['shipto_address'] = "{$o['customer_shipping_country']}"; $order['customer'] = "{$o['customer_billing_firstname']} {$o['customer_billing_lastname']}"; $order['customer_type'] = $this->spinfo[$o['jng_sp_id']]['package_prefix']; $order['customer_is_vip'] = $cust_detail['list_type'] == 'V' ? true : false; if (in_array($o['jng_sp_id'], $sp_using_red_paper) || $order['customer_is_vip']) { $order['priority'] = '1'; } else { $order['priority'] = $o['priority']; } $items = array(); foreach ($is as $i) { if (!statusIsCancelled($i['status'])) { if ($i['products_ean'] != '' && !in_array($i['products_ean'], $this->products_ean)) { $product_key = $i['products_id'] . '-' . $i['products_articles_id']; $this->products_ean[$product_key] = $i['products_ean']; } $itemp = array(); $itemp['status'] = $i['status']; $itemp['products_id'] = $i['products_id']; $itemp['articles_id'] = $i['products_articles_id']; $itemp['quantity'] = $i['order_quantity']; $itemp['counter'] = $i['order_item_count'] . '/' . $i['order_item_total']; $itemp['stock_status'] = $i['stock_status']; $itemp['print_count'] = $i['print_count']; $itemp['prod_target_in'] = $i['prod_target_in']; $itemp['shipping_window_open'] = $i['shipping_window_open']; $items[$i['jng_sp_orders_items_id']] = $itemp; } } break; case 'JG': $o = $class_o->retrieveDetail($order_id); //if(is_null($items)) $is = $class_o->retrieveProducts($order_id); //else foreach($items as $item_id) $is[] = $class_o->retrieveProductDetail($item_id); $is = $class_o->retrieveProducts($order_id); if (!is_null($items)) { foreach ($is as $key => $is_temp) { if (!in_array($is_temp['orders_products_id'], $items)) { unset($is[$key]); } } } $country_code = array_search($o[delivery_country], $pi_country_code); if ($country_code === false) { $country_code = 'DE'; } //GET CUSTOMER DETAIL VIP OR NOT $cust_detail = $class_csl->getCustomerDetail($o['customers_id']); $order = array(); $order['type'] = $type; $order['id'] = $order_id; $order['jng_sp_id'] = 0; $order['code'] = $o['orders_no']; $order['date'] = $o['date_purchased']; $order['daily_count'] = $o['daily_count']; $order['shipto_name'] = ($o['delivery_company'] == '' ? '' : $o['delivery_company'] . ' - ') . $o['delivery_name']; $order['shipto_address'] = "{$o['delivery_country']}"; $order['customer'] = "{$o['customers_name']}"; $order['customer_type'] = 'JG.' . $country_code; $order['customer_is_vip'] = $cust_detail['list_type'] == 'V' ? true : false; $order['priority'] = in_array(0, $sp_using_red_paper) ? '1' : '0'; $items = array(); foreach ($is as $i) { if (!statusIsCancelled($i['status'])) { $itemp = array(); $itemp['status'] = $i['status']; $itemp['products_id'] = $i['products_id']; $itemp['articles_id'] = $i['products_articles_id']; $itemp['quantity'] = $i['products_quantity']; $itemp['counter'] = $i['order_item_count'] . '/' . $i['order_item_total']; $itemp['stock_status'] = $i['stock_status']; $itemp['print_count'] = $i['print_count']; $itemp['custom_img'] = $i['customers_image']; $itemp['custom_imgcm'] = $i['customers_image_comment']; $itemp['custom_text'] = $i['customers_text_line1'] . ($i['customers_text_line2'] != '' ? "\n" . $i['customers_text_line2'] : ''); $itemp['prod_target_in'] = $i['prod_target_in']; $items[$i['orders_products_id']] = $itemp; } } break; case 'DP': $o = $class_do->retrieveDetail($order_id); $segment = $class_bins->retrieveSegmentDetail($o['segments_id']); $o['delivery_name'] = $segment['name']; $o['delivery_country'] = $segment['location'] . ', Deutschland'; $o['customer_is_vip'] = false; $dp_is_prioritized = false; if ($o['trans_type'] == 'SP') { $it = $class_jo->retrieveItemDetail($o['trans_id']); $ot = $class_jo->retrieveDetail($it['jng_sp_orders_id']); if (in_array($ot['jng_sp_id'], $sp_using_red_paper)) { $dp_is_prioritized = true; } //GET CUSTOMER DETAIL VIP OR NOT $cust_data = $class_jc->retrieveDetail(null, $ot['jng_sp_id'], $ot['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']); } if ($cust_detail['list_type'] == 'V') { $o['customer_is_vip'] = true; } $o['delivery_name'] = "{$ot['customer_shipping_firstname']} {$ot['customer_shipping_lastname']}"; $o['delivery_country'] = "{$ot['customer_shipping_country']}"; $o['customer_name'] = $this->spinfo[$ot['jng_sp_id']]['package_prefix'] . " - {$ot['customer_billing_firstname']} {$ot['customer_billing_lastname']}"; $o['prod_target_in'] = $it['prod_target_in']; $o['jng_sp_id'] = $ot['jng_sp_id']; } elseif ($o['trans_type'] == 'JG') { $it = $class_o->retrieveProductDetail($o['trans_id']); $ot = $class_o->retrieveDetail($it['orders_id']); if (in_array(0, $sp_using_red_paper)) { $dp_is_prioritized = true; } //GET CUSTOMER DETAIL VIP OR NOT $cust_detail = $class_csl->getCustomerDetail($ot['customers_id']); if ($cust_detail['list_type'] == 'V') { $o['customer_is_vip'] = true; } $o['delivery_name'] = ($ot['delivery_company'] == '' ? '' : $ot['delivery_company'] . ' - ') . $ot['delivery_name']; $o['delivery_country'] = "{$ot['delivery_country']}"; $o['customer_name'] = "JG.DE - {$ot['customers_name']}"; $o['prod_target_in'] = $it['prod_target_in']; $o['jng_sp_id'] = 0; } elseif ($o['trans_type'] == 'AR') { $o['customer_name'] = 'Refill Order'; } else { $is_outsourced = $class_do->isOutsourceOrder($o['trans_type'], $o['trans_id']); if ($is_outsourced) { $o['customer_name'] = $o['group_name']; } else { $o['customer_name'] = $o['group_name'] == '' ? 'Manual Order' : 'Manual - ' . $o['group_name']; } } $order = array(); $order['type'] = $type; $order['id'] = $order_id; $order['jng_sp_id'] = isset($o['jng_sp_id']) ? $o['jng_sp_id'] : ''; $order['code'] = null; $order['date'] = $o['order_date']; $order['daily_count'] = null; $order['shipto_name'] = $o['delivery_name']; $order['shipto_address'] = $o['delivery_country']; $order['customer'] = $o['customer_name']; $order['customer_type'] = null; $order['customer_is_vip'] = $o['customer_is_vip']; if ($o['trans_type'] == 'AR' && $o['trans_id'] == depot_orders::AUTO_REFILL_ID_ZALANDO || $dp_is_prioritized || $order['customer_is_vip']) { $order['priority'] = '1'; } else { $order['priority'] = '0'; } $items = array(); if ($o['products_ean'] != '' && !in_array($o['products_ean'], $this->products_ean)) { $product_key = $o['products_id'] . '-' . $o['articles_id']; $this->products_ean[$product_key] = $o['products_ean']; } if (!statusIsCancelled($o['status'])) { $itemp = array(); $itemp['status'] = $i['status']; $itemp['products_id'] = $o['products_id']; $itemp['articles_id'] = $o['articles_id']; $itemp['quantity'] = $o['quantity']; $itemp['counter'] = '1/1'; $itemp['stock_status'] = $o['stock_status']; $itemp['print_count'] = $o['print_count']; $itemp['prod_target_in'] = $o['prod_target_in']; $items[$o['depot_orders_id']] = $itemp; } break; } $this->orders[$order_key]['detail'] = $order; $this->orders[$order_key]['items'] = $items; foreach ($items as $i) { $this->loadProduct($i['products_id'], $i['articles_id']); } }
if (!isset($orders_xml_group[$xml])) { $orders_xml_group[$xml] = array(); } if (!isset($orders_xml_group[$xml][$oid])) { $orders_xml_group[$xml][$oid] = array(); } //$o['item'] = $i; if (!isset($orders_xml_group[$xml][$oid][$i['products_ean']])) { $orders_xml_group[$xml][$oid][$i['products_ean']] = array(); $orders_xml_group[$xml][$oid][$i['products_ean']]['order_quantity'] = 0; $orders_xml_group[$xml][$oid][$i['products_ean']]['cancel_quantity'] = 0; $orders_xml_group[$xml][$oid][$i['products_ean']]['stock_status'] = $i['stock_status']; $orders_xml_group[$xml][$oid][$i['products_ean']]['shipping_window_open'] = $i['shipping_window_open']; $orders_xml_group[$xml][$oid][$i['products_ean']]['shipping_window_close'] = $i['shipping_window_close']; } if (statusIsCancelled($i['status'])) { $orders_xml_group[$xml][$oid][$i['products_ean']]['cancel_quantity'] += $i['order_quantity']; } else { $orders_xml_group[$xml][$oid][$i['products_ean']]['order_quantity'] += $i['order_quantity']; } if (stockStatusStrength($i['stock_status']) > stockStatusStrength($orders_xml_group[$xml][$oid][$i['products_ean']]['stock_status'])) { $orders_xml_group[$xml][$oid][$i['products_ean']]['stock_status'] = $i['stock_status']; } if (!in_array($i['jng_sp_orders_id'], $orders_confirmed)) { $orders_confirmed[] = $i['jng_sp_orders_id']; } } } } } //END ORDER LOOPING
//Return Quantity if ($i['return_qty'] > 0) { $value = '<span class="red">' . $i['return_qty'] . '</span>'; $total_return += $i['return_qty']; } break; case 'price3': //Return Amount if ($i['return_qty'] > 0) { $refund_amount = $i['return_qty'] * $i[$items_colname_price]; $value = '<span class="red">' . displayCurrency($order_currency, $refund_amount) . '</span>'; $total_refund += $refund_amount; } break; } if (statusIsCancelled($i['status']) && $hkey != 'input tac' && $hkey != 'action') { $value = '<span class="notice deleted" title="Canceled">' . $value . '</span>'; } $row[$hkey] = $value == '' ? ' ' : $value; } $tables[] = $row; } $all_products_canceled = $total_products_canceled == $total_products; $all_products_depot_ready = $total_products_depot_ready + $total_products_canceled == $total_products; $all_products_sent = $total_products_sent > 0 && $total_products_sent + $total_products_canceled == $total_products; $total_row = array(); foreach ($header as $hkey => $h) { $value = ''; switch ($hkey) { case 'image': $value = 'TOTAL';
$order_invoices[] = $oi; $oi_usetotal = true; } else { $oi_usetotal = false; } $content .= tep_draw_table('invoices', $order_invoices, false, $oi_usetotal); $content .= '<div> </div>'; } } else { $invoice->getReceipts(); $invoice->getReminders(); $amount_refund = $invoice->detail['invoice_amount_overpayment'] + $invoice->detail['invoice_amount_overpayment_canceled']; $amount_fines = $invoice->detail['invoice_amount_fines'] - $invoice->detail['invoice_amount_fines_canceled']; if ($worst_status <= 8) { $content .= '<p style="color:gray;">Download Invoice button will be available after products are sent to customer</p>'; } elseif (statusIsCancelled($worst_status)) { $content .= '<p style="color:gray;">No Invoice for canceled order</p>'; } else { $order_object = new Order(Order::ORDER_TYPE_JULIE_GRACE, $order_id); $content .= '<span><a href="http://www.manobo.de/print/' . ($order_object->payment_method == Order::PAYMENT_METHOD_INVOICE ? 'invoices-pdf-with-transfer-slip.php' : 'invoices-pdf.php') . '?id=' . $order_id . '" target="_blank"></a><input type="button" id="dlinvoice" value="Download Invoice" ' . 'title="Click here to Download Invoice"/></span><br /><br />'; } $content .= '<h2>Payone Invoice ' . $invoice->detail['invoice_no'] . '<h2>'; $content .= '<div style="float:left;">'; $content .= '<div style="margin-bottom:20px;"><table class="form" border="0" cellpadding="0" cellspacing="0">'; $content .= '<tr><td class="label">Invoice Id</td><td>' . $invoice->detail['invoice_id'] . '</td></tr>'; $content .= '<tr><td>Payone TXID</td><td>' . $invoice->detail['payone_txid'] . '</td></tr>'; $content .= '<tr><td>Create Date</td><td>' . date('d.m.Y', strtotime($invoice->detail['invoice_date'])) . '</td></tr>'; $content .= '<tr><td>Due Date</td><td>' . date('d.m.Y', strtotime($invoice->detail['invoice_due_date'])) . '</td></tr>'; $content .= '<tr><td>Status</td><td>' . payone_invoice_status($invoice->detail['invoice_complete_status']) . '</td></tr>'; $content .= '</table></div>'; $content .= '<h3>Invoice Amount<h3>';
$item = $class_o->retrieveProductDetail($item_id); if (isset($item['orders_id']) && $item['orders_id'] > 0) { $order = $class_o->retrieveDetail($item['orders_id']); //check if logistic process is alread flagged if (!is_null($order['logistic_process'])) { $lp_time = date('d.m.Y H:i:s', strtotime($order['logistic_process'])); $result['status'] = 'ERROR'; $result['message'] = 'already processed on ' . $lp_time; $result['message'] .= "\n\n" . 'Please check order detail in Manobo for detail information about preventing double sendings!'; } else { if ($item['status'] == $inhh_status || statusIsCancelled($item['status'])) { $products_found = true; $items = $class_o->retrieveProducts($item['orders_id']); foreach ($items as $i) { if ($i['status'] == $inhh_status) { if (statusIsCancelled($item['status']) && $barcode_new == '') { $barcode_new = 'JG-' . $i['orders_products_id']; } $qty = intval($i['products_quantity']); $ean_code = $class_ean->getEAN($i['products_id'], $i['products_articles_id']); for ($x = 1; $x <= $qty; $x++) { $products_ean[] = $ean_code; } } } } else { $result['status'] = 'ERROR'; $result['message'] = $statusName[$item['status']]; } } } else {
function drawOrderDisplay($order_type, $order_id, $displaypart = 'ALL', $excludecurrentorderinhistory = true) { //$displaypart = 'ALL' / 'NEW' / 'HISTORY' global $class_do, $class_pm, $class_pa, $class_mc, $class_jo, $class_jc, $class_o, $sp_list; //ORDERED PRODUCTS DISPLAY SETTING $col_limit = 5; //max no of columns $row_limit = 5; //max no of rows $border = '1'; //border width $imgsize = '80'; //image size $padding = '5'; //box padding $margin = '10'; //box margin $po_limit = $col_limit * $row_limit; //max no of products - auto calc $powidth = ceil($col_limit * ($imgsize + 2 * ($border + $padding) + $margin) / 10) * 10; $total_price = 0; if ($order_type == 'SP') { use_class('jng_sp_customers_special'); $csl = new jng_sp_customers_special(); $order = $class_jo->retrieveDetail($order_id); $order_source = $sp_list[$order['jng_sp_id']]['name']; $order_products = $class_jo->retrieveItems($order_id); $customer = $class_jc->retrieveDetail(null, $order['jng_sp_id'], $order['customer_billing_id']); $list_type = $csl->getListType($customer['jng_sp_customers_id']); $cust_crown = $csl->getTypeSymbol($list_type, $customer['jng_sp_customers_id']); $customer_name = $cust_crown . $order['customer_billing_firstname'] . ' ' . $order['customer_billing_lastname']; $customer_address = $order['customer_billing_address']; if ($order['customer_billing_address2'] != '') { $customer_address .= ', ' . $order['customer_billing_address2']; } $customer_address .= ', ' . $order['customer_billing_postcode']; $customer_address .= ' ' . $order['customer_billing_city']; $customer_address .= ', ' . $order['customer_billing_country']; $products_ordered = $class_jc->retrieveOrdersItems($customer['jng_sp_customers_id']); $colname_order_id = 'jng_sp_orders_id'; $colname_items_id = 'jng_sp_orders_items_id'; $colname_order_date = 'order_date'; $colname_order_qty = 'order_quantity'; $colname_return_qty = 'return_quantity'; $colname_products_id = 'products_id'; $colname_products_code = 'article_number'; $colname_articles_id = 'products_articles_id'; $colname_custom_text1 = null; $colname_custom_text2 = null; $colname_custom_image = null; $order_history_display = null; $total_price = getTotalOrderAmount('S', $order_id); } elseif ($order_type == 'JG') { use_class('customers_special_list'); $csl = new customers_special_list(); $order = $class_o->retrieveDetail($order_id); $order_source = 'JULIE&GRACE'; $total_price = getTotalOrderAmount('J', $order_id, $order['currency']); $order_products = $class_o->retrieveProducts($order_id); //$customer = $class_mc->retrieveDetail($order['customers_id']); $list_type = $csl->getListType($order['customers_id']); $cust_crown = $csl->getTypeSymbol($list_type, $order['customers_id']); $customer_name = $cust_crown . $order['customers_name']; $customer_address = ''; if ($order['customers_company'] != '') { $customer_address .= $order['customers_company'] . ', '; } $customer_address .= $order['customers_street_address']; $customer_address .= ', ' . $order['customers_postcode']; $customer_address .= ' ' . $order['customers_city']; $customer_address .= ', ' . $order['customers_country']; $products_ordered = $class_mc->retrieveOrdersProducts($order['customers_id'], 'op.status>0'); $colname_order_id = 'orders_id'; $colname_items_id = 'orders_products_id'; $colname_order_date = 'date_purchased'; $colname_order_qty = 'products_quantity'; $colname_return_qty = 'return_quantity'; $colname_products_id = 'products_id'; $colname_products_code = 'products_model'; $colname_articles_id = 'products_articles_id'; $colname_custom_text1 = 'customers_text_line1'; $colname_custom_text2 = 'customers_text_line2'; $colname_custom_image = 'customers_image'; $order_history_display = null; } elseif ($order_type == 'DP') { $order = $class_do->retrieveDetail($order_id); $product_detail = $class_pm->retrieveDetail($order['products_id'], 'p'); $order['products_image'] = $product_detail['p']['products_image']; $order['products_model'] = $product_detail['p']['products_model']; $order['order_item_count'] = '1'; $order['order_item_total'] = '1'; $order_products = array(); $order_products[] = $order; $colname_order_id = 'depot_orders_id'; $colname_items_id = 'depot_orders_id'; $colname_order_date = 'order_date'; $colname_order_qty = 'quantity'; $colname_return_qty = ''; $colname_products_id = 'products_id'; $colname_products_code = 'products_model'; $colname_articles_id = 'articles_id'; $colname_custom_text1 = null; $colname_custom_text2 = null; $colname_custom_image = null; if ($order['trans_type'] == 'SP' || $order['trans_type'] == 'JG') { if ($order['trans_type'] == 'SP') { $item = $class_jo->retrieveItemDetail($order['trans_id']); //if ($item['jng_sp_id'] != '2') { //echo "<pre>"; //var_dump($item); //die("ttt"); if ($item['stock_status'] == '0') { $order_history_display = drawOrderDisplay($order['trans_type'], $item['jng_sp_orders_id'], 'HISTORY', false); } $total_price = getTotalOrderAmount('S', $item['jng_sp_orders_id']); //} } else { //die("test"); $item = $class_o->retrieveProductDetail($order['trans_id']); $total_price = getTotalOrderAmount('J', $item['orders_id']); if ($item['stock_status'] == '0') { $order_history_display = drawOrderDisplay($order['trans_type'], $item['orders_id'], 'HISTORY', false); } } } } $result = ''; if ($displaypart == 'ALL' || $displaypart == 'NEW') { //NEW ORDER $result .= '<h2 style="position:fixed;top:0;left:0;line-height:20px;width:480px;padding:5px 10px;background:#ccc;border-right:1px inset #666;">New ' . $order_type . ' Order ' . $order_id . ' (' . $total_price . ')</h2>'; //$result .= '<div style="position:fixed;top:30;bottom:0;left:0;width:480px;padding:10px;background:#efefef;border-right:1px inset #666;overflow:auto;">'; $result .= '<div id="box-order-items" style="position:fixed;top:30;bottom:0;height:93%;left:0;width:480px;padding:10px;background:#efefef;border-right:1px inset #666;overflow:auto;">'; $neworder = array(); $no = array(); $no['l'] = 'No'; $no['d'] = 'Image'; $no['t2'] = 'Info'; $no['q'] = 'Order<br/>Qty.'; $no['r'] = 'Stock Status<br /> and Actions'; $neworder[] = $no; foreach ($order_products as $op) { if ($op[$colname_articles_id] > 0) { $article = $class_pa->retrieveDetail($op[$colname_articles_id]); $prolength = $article['length']; } else { $product_detail = $class_pm->retrieveDetail($op[$colname_products_id], 'pnc'); $prolength = $product_detail['pnc']['products_length']; } $customize_info = ''; if (!is_null($colname_custom_text1) && !is_null($colname_custom_text2)) { if ($op[$colname_custom_text1] != '' || $op[$colname_custom_text2] != '') { $customize_info .= '<div style="margin-top:10px;">'; if ($op[$colname_custom_text1] != '') { $customize_info .= $op[$colname_custom_text1]; } if ($op[$colname_custom_text2] != '') { $customize_info .= '<br />' . $op[$colname_custom_text2]; } $customize_info .= '</div>'; } } if (!is_null($colname_custom_image) && $op[$colname_custom_image] != '') { $customize_info .= webImage($op[$colname_custom_image], '80', '80', 'Custom Image'); } $length_text = $prolength > 0 ? 'Length: ' . textLength($prolength) : '<span class="notice">No Length</span>'; //$tooltip_data = getTooltipThumbData($op[$colname_products_id], $op[$colname_articles_id], 0); $pdata = $class_pm->retrieveDetail($op[$colname_products_id], 'pl,sp'); $tooltip_text = '<table class="tiny" border="0" cellpadding="0" cellspacing="0" align="center">'; $tooltip_text .= '<tr><td width="80" title="Sold Last 30 Days">Sold L30D</td><td>' . intval($pdata['pl']['sold_monthly_1']) . ' products</td></tr>'; $tooltip_text .= '<tr><td>Total sold</td><td>' . intval($pdata['sp']['0']['total_sold']) . ' products</td></tr>'; $tooltip_text .= '<tr><td>Return Rate</td><td>' . number_format($pdata['sp']['0']['returned_rate'], 1) . '%</td></tr>'; $tooltip_text .= '<tr><td>Product Age</td><td>' . $pdata['sp']['0']['active_age'] . ' days</td></tr>'; $tooltip_text .= '</table>'; $info = array(); //var_dump($order_type); $info[] = $order_type . '-' . $op[$colname_items_id]; $info[] = $op['products_ean']; $info[] = $op[$colname_products_id] . ' / ' . $op[$colname_products_code]; $info[] = $length_text; $info[] = ' '; $info[] = '<strong>All SP Summary</strong>'; $info[] = $tooltip_text; $action_hidden = '<input type="hidden" id="' . $order_type . '-' . $op[$colname_items_id] . '" name="oiid" value="' . $op[$colname_items_id] . '" />'; $action_hidden .= '<input type="hidden" name="type" value="' . $order_type . '" />'; $action = array(); $action[] = stockStatusDisplay($op['stock_status'], $op['status'], $op[$colname_products_id], $op[$colname_articles_id], $op[$colname_order_qty], null); $action[] = ' '; if ($op['stock_status'] == 'S') { $action[] = '<input type="button" name="2" value="» Sourcing" class="bl green" />'; } elseif ($op['stock_status'] == 'R' || $op['stock_status'] == 'P' || $op['stock_status'] == 'W') { $action[] = '<input type="button" name="3" value="» Ready" class="bl green" />'; //$action[] = '<input type="button" name="test" value="» Sourcing" class="bl red" />'; } $action[] = '<input type="button" name="10" value="× Cancel" class="bl red" />'; $no = array(); $no['l'] = $op['order_item_count'] . '/' . $op['order_item_total']; $no['d'] = webImage($op['products_image'], '80', '80', 'Product Image') . $customize_info; $no['t2'] = implode('<br />', $info); if (isset($op['order_quantity'])) { $order_quantity = $op['order_quantity']; } elseif (isset($op['products_quantity'])) { $order_quantity = $op['products_quantity']; } else { $order_quantity = $op['quantity']; } $no['q'] = $order_quantity; $no['r'] = $action_hidden . implode('<br />', $action); $neworder[] = $no; } $result .= tep_draw_table('spo', $neworder); $result .= '<div class="buttons"><input type="button" name="nextorder" value="Next Order" class="button" /></div>'; $result .= '</div>'; //NEW ORDER - CLOSER } if (!is_null($order_history_display)) { $result .= $order_history_display; } elseif ($displaypart == 'ALL' || $displaypart == 'HISTORY') { $result .= '<div style="margin-left:510px;color:#666;" >'; //HISTORICAL INFO if ($order_type == 'DP') { $result .= '<h2>DEPOT ' . ($order['trans_type'] == 'AR' ? 'REFILL' : 'MANUAL ORDER') . '</h2>'; } else { //var_dump($order_type); $result .= '<h2>Customer Detail</h2>'; // $result .= '<table border="0" cellpadding="0" cellspacing="0">'; // $result .= '<tr><td width="150">Customer From</td><td>'.$order_source.'</td></tr>'; // $result .= '<tr><td>Customer Name</td><td>'.$customer_name.'</td></tr>'; // $result .= '<tr><td>Customer Address</td><td>'.$customer_address.'</td></tr>'; // $result .= '<tr><td></td><td></td></tr>'; // $result .= '</table>'; $result .= '<div class="bold">' . $order_source . '</div>'; $result .= '<div>' . $customer_name . '</div>'; $result .= '<div>' . $customer_address . '</div>'; $result .= '<div> </div>'; $orders_collection = array(); $products_ordered_total = 0; $products_returned_total = 0; $products_canceled_total = 0; $products_inprocess_total = 0; foreach ($products_ordered as $pok => $pov) { if ($excludecurrentorderinhistory && $pov[$colname_order_id] == $order[$colname_order_id]) { unset($products_ordered[$pok]); } else { if (!in_array($pov[$colname_order_id], $orders_collection)) { $orders_collection[] = $pov[$colname_order_id]; } $products_ordered_total += $pov[$colname_order_qty]; $products_returned_total += $pov[$colname_return_qty]; if (statusIsCancelled($pov['status'])) { $products_canceled_total += $pov[$colname_order_qty]; } if ($pov['status'] < 9) { $products_inprocess_total += $pov[$colname_order_qty]; } } } $result .= '<h2>Customer Historical Info</h2>'; if ($products_ordered_total > 0) { $products_success_total = $products_ordered_total - ($products_inprocess_total + $products_canceled_total); $return_rate = $products_returned_total == 0 ? 0 : $products_returned_total / $products_success_total * 100; $process_class = $products_inprocess_total > 0 ? 'red' : 'green'; $success_class = $products_success_total > 0 ? 'green' : 'red'; $return_class = $products_returned_total > 0 ? 'red' : 'green'; $return_rate_class = $return_rate <= 10 ? 'green' : 'red'; $prevtext = $excludecurrentorderinhistory ? 'Previous' : ''; $result .= '<h3>» Customer ' . $prevtext . ' Orders Total = ' . count($orders_collection) . '</h3>'; $result .= '<h3>» Ordered Products Total = ' . $products_ordered_total . '</h3>'; $result .= '<h3>» Ordered Products Canceled = ' . $products_canceled_total . '</h3>'; $result .= '<h3 class="' . $process_class . '">» Ordered Products in Progress = ' . $products_inprocess_total . '</h3>'; $result .= '<h3 class="' . $success_class . '">» Ordered Products Received = ' . $products_success_total . '</h3>'; $result .= '<h3 class="' . $return_class . '">» Ordered Products Returns = ' . $products_returned_total . '</h3>'; $result .= '<h3 class="' . $return_rate_class . '">» Customer Return Rate = ' . number_format($return_rate, 1) . '%</h3>'; $result .= '<h3>» Recent Ordered Products List (Showing Max ' . $po_limit . ' Products): ' . '</h3>'; $result .= '<div style="width:' . $powidth . 'px;">'; $pocount = 0; foreach ($products_ordered as $po) { $pocount++; if ($pocount <= $po_limit) { if ($po[$colname_articles_id] > 0) { $article = $class_pa->retrieveDetail($po[$colname_articles_id]); $prolength = $article['length']; } else { $product_detail = $class_pm->retrieveDetail($po[$colname_products_id], 'pnc'); $prolength = $product_detail['pnc']['products_length']; } $length_text = $prolength > 0 ? textLength($prolength) : '<span class="notice">No Length</span>'; $status = $po['status'] == '8' ? modeName($po['mode']) : statusNameShort($po['status'], true); $status_class = $po['status'] < 9 ? 'red' : 'notice'; $qty_class = statusIsCancelled($po['status']) > 0 ? 'notice' : 'green'; $result .= '<div style="float:left;border:' . $border . 'px solid #ccc;text-align:center;margin:0 ' . $margin . 'px ' . $margin . 'px 0;padding:' . $padding . 'px;">'; $result .= webImage($po['products_image'], $imgsize, $imgsize); $result .= '<br />'; $result .= $length_text; $result .= '<br />'; $result .= '<span title="Order Date">' . date('d.m.Y', strtotime($po[$colname_order_date])) . '</span>'; $result .= '<br />'; $result .= '<span class="' . $status_class . '" title="Current Status">' . $status . '</span>'; $result .= '<br />'; $result .= '<strong class="' . $qty_class . '" title="Order Quantity">+' . intval($po[$colname_order_qty]) . '</strong>'; $result .= ' '; $returns = intval($po[$colname_return_qty]); $retclas = $returns > 0 ? 'red' : 'notice'; $result .= '<strong class="' . $retclas . '" title="Return Quantity">-' . $returns . '</strong>'; $result .= '</div>'; } } $result .= '</div>'; $result .= '<div style="clear:both;"> </div>'; } else { $result .= '<h3>» No Order Historical info, a New Customer</h3>'; } } $result .= '</div>'; //HISTORICAL INFO - CLOSER } return $result; }
function recalcTotals($orders_id) { $order = $this->retrieveDetail($orders_id); $products = $this->retrieveProducts($orders_id); $ot_subtotal = 0; foreach ($products as $p) { if (!statusIsCancelled($p['status'])) { $ot_subtotal += $p['products_quantity'] * $p['final_price']; } } $totals = $this->retrieveTotals($orders_id); if ($totals['ot_subtotal']['value'] != $ot_subtotal) { $ot_total = $ot_subtotal; //UPDATE SUB TOTAL $sda_ot = array(); $sda_ot['value'] = $ot_subtotal; $sda_ot['text'] = displayCurrency($order['currency'], $ot_subtotal); tep_db_perform('orders_total', $sda_ot, 'update', "orders_id={$orders_id} AND class='ot_subtotal'"); if (isset($totals['ot_shipping'])) { $ot_total += $totals['ot_shipping']['value']; } if (isset($totals['ot_coupon'])) { $ot_total -= $totals['ot_coupon']['value']; } if (isset($totals['ot_gv'])) { $ot_total -= $totals['ot_gv']['value']; } //UPDATE TOTAL $sda_ot = array(); $sda_ot['value'] = $ot_total; $sda_ot['text'] = displayCurrency($order['currency'], $ot_total); tep_db_perform('orders_total', $sda_ot, 'update', "orders_id={$orders_id} AND class='ot_total'"); } }
/** * Check if an item is canceled (confirmed or not confirmed) * @param Int $status Item status * @return Boolean */ public static function isStatusCancel($status) { return statusIsCancelled($status); }
/** * Use this function to set SP order priority (will be printed with red paper) * this function will also check if the changing the priority is still possible * @param String $orders_id Order ID to be updated * @param Boolean $priority True to prioritize or False to set back to normal * @return Boolean True if priority update is successful or False if Fail */ function setOrderPriority($orders_id, $priority) { if (is_bool($priority)) { $priority = $priority ? '1' : '0'; } $items = $this->retrieveItems($orders_id); $file_exist = false; $run_change_priority = true; $pi_folder_path = DIR_FS_MINIERP . DIR_WS_GATEWAY . "ready_orders/SP/"; $pi_file_path = array(); $pi_file_path_prioritized = array(); if (is_array($items) && count($items) > 0) { foreach ($items as $k => $i) { if (statusIsCancelled($i['status'])) { //ignore canceled products unset($items[$k]); } else { if ($i['status'] > 3) { //ignore products with status not in new/sourcing/ready $run_change_priority = false; break; } else { if ($i['print_count'] > 0) { //if pi is already generated at least once //must check if file is still exist in server //if not, changing priority is not allowed $filename = 'SP-' . $i['jng_sp_orders_items_id']; $pi_file_path[$k] = $pi_folder_path . $filename . '.pdf'; $pi_file_path_prioritized[$k] = $pi_folder_path . $filename . '-RED.pdf'; if (!is_file($pi_file_path[$k]) && !is_file($pi_file_path_prioritized[$k])) { $run_change_priority = false; break; } else { $file_exist = true; } } } } } } if ($run_change_priority && count($items) > 0) { //change priority process $sda = array('priority' => $priority); tep_db_perform('jng_sp_orders', $sda, 'update', "jng_sp_orders_id={$orders_id}"); if ($file_exist) { //if file is already created, rename it as necessary foreach ($items as $k => $i) { if ($priority == '0') { if (is_file($pi_file_path[$k])) { if (is_file($pi_file_path_prioritized[$k])) { unlink($pi_file_path_prioritized[$k]); } } else { rename($pi_file_path_prioritized[$k], $pi_file_path[$k]); } } else { if (is_file($pi_file_path_prioritized[$k])) { if (is_file($pi_file_path[$k])) { unlink($pi_file_path[$k]); } } else { rename($pi_file_path[$k], $pi_file_path_prioritized[$k]); } } } } } return $run_change_priority; }
private function loadItems($reload = false) { if ($this->items_total == 0 || $reload == true) { $this->items = array(); $this->items_canceled = array(); $this->items_notcanceled = array(); $this->items_total_qty = 0; $this->items_canceled_total_qty = 0; $this->items_notcanceled_total_qty = 0; $this->items_returned = array(); $this->items_returned_total_qty = 0; if ($this->isOrderFromSalesPartner()) { $table = OrderItem::TABLENAME_SP; $colname_order_id = self::COLNAME_ID_SP; $colname_item_id = OrderItem::COLNAME_ID_SP; } elseif ($this->isOrderFromJulieGrace()) { $table = OrderItem::TABLENAME_JG; $colname_order_id = self::COLNAME_ID_JG; $colname_item_id = OrderItem::COLNAME_ID_JG; } $q = "SELECT {$colname_item_id} FROM {$table} WHERE {$colname_order_id}" . " = '" . $this->order_id . "'"; $r = tep_db_query($q); while ($row = tep_db_fetch_array($r)) { $item_id = $row[$colname_item_id]; $i = new OrderItem($this, $item_id); $this->items[$item_id] = $i; $this->items_total_qty += $i->ordered_quantity; if (statusIsCancelled($i->status)) { $this->items_canceled[$item_id] = $i; $this->items_canceled_total_qty += $i->ordered_quantity; } else { $this->items_notcanceled[$item_id] = $i; $this->items_notcanceled_total_qty += $i->ordered_quantity; } $return_qty = $i->getReturnQuantity(); if ($return_qty > 0) { $this->items_returned[$item_id] = $i; $this->items_returned_total_qty += $return_qty; } } $this->items_total = count($this->items); $this->items_canceled_total = count($this->items_canceled); $this->items_notcanceled_total = count($this->items_notcanceled); $this->items_returned_total = count($this->items_returned); } }
$content .= '<tr><td>Order Quantity</td><td>' . $do['quantity'] . '</td></tr>'; $content .= '<tr><td>Product ID / Code</td><td>' . $product['p']['products_id'] . ' / ' . $product['p']['products_model'] . '</td></tr>'; $content .= $length_text; $content .= '</table></div>'; $content .= '<div style="margin:20px 0 0 3px;">'; $content .= '<h3>Status History</h3>'; $content .= tep_draw_table('', $htable); if ($status_date < strtotime('-3 day')) { $content .= '<div style="margin-top:5px;">'; $content .= '<form name="setas" action="?open=depot-order&id=' . $order_id . '" method="post">'; $content .= '<input type="hidden" name="me_action" value="SETSTATUS" />'; $content .= '<input type="hidden" id="set-as-status" name="newstatus" value="" />'; if ($do['status'] != '8') { $content .= '<input type="button" id="set-as-8" value="Already Received in HH" class="green" />'; } if (!statusIsCancelled($do['status'])) { $content .= '<input type="button" id="set-as-10" value="CANCEL" class="red" title="Product is lost, click this button to Cancel" />'; } $content .= '<input type="button" id="set-as-1" value="REPRODUCE" class="red" title="Product is lost, click this button to Reproduce it" />'; $content .= '</form>'; $content .= '</div>'; } $content .= $sourcing_info; $content .= $binin_history; $content .= '</div>'; $content .= '</div>'; } $javascript .= ' $(".buttons-left input:button").click(function() { var idsplit = $(this).attr("id").split("-"); $("#set-as-status").val(idsplit[2]);