$row_temp = array(); $tab_have_sub_status = array('4'); foreach ($status_to_show as $sv) { $colval = isset($kpi_status_cycletime[$sv]) ? array_sum($kpi_status_cycletime[$sv]) / count($kpi_status_cycletime[$sv]) : 0; $temp_status = explode('-', $sv); if ($colval > 0 || !isset($temp_status[1]) && isset($kpi_status_cycletime[$sv])) { $result = true; $total_process += $colval; if (isset($temp_status[1])) { $total_process_sub[$temp_status[0]] += $colval; } if (in_array($temp_status[0], $tab_have_sub_status) && !isset($row_temp[$temp_status[0]])) { $row_temp[$temp_status[0]]['c1'] = '<strong style="font-size:13px;">' . statusName($temp_status[0]) . '</strong>'; $total_process_temp[$sv] += $colval; } $row_temp[$sv]['c1'] = $temp_status[0] == '4' && isset($temp_status[1]) ? statusNameProduction($temp_status[1]) : statusName($sv); $row_temp[$sv]['c2 right'] = displayDuration($colval, 'day', 2); if (!isset($temp_status[1])) { $row_temp[$sv]['c1'] = '<strong style="font-size:13px;">' . $row_temp[$sv]['c1'] . '</strong>'; $row_temp[$sv]['c2 right'] = '<strong style="font-size:13px;">' . $row_temp[$sv]['c2 right'] . '</strong>'; } if (isset($temp_status[1])) { $row_temp[$sv]['c1'] = '<div style="margin-left:20px;">' . $row_temp[$sv]['c1'] . '</div>'; } } } //Show sub status leadtime foreach ($row_temp as $rk => $rv) { $row = array(); if (in_array($rk, $tab_have_sub_status)) { if (isset($total_process_sub[$rk])) {
} $t = array(); $t['info'] = 'TOTAL'; foreach ($week_total as $spid => $ttl) { $canrt = $ttl == 0 ? 0 : $week_cancel[$spid] / $ttl * 100; $t['sp' . $spid] = number_format($canrt, 1) . '%<br /><small class="notice">' . $week_cancel[$spid] . '/' . $ttl . '</small>'; } $table[] = $t; $result = tep_draw_table('proman', $table, false, true); } echo utf8_encode($result); exit; } elseif ($_GET['week-sum'] == 'LATEORDERS') { $status_summary = array('1' => 0, '2' => 0, '3' => 0, '4' => 0, '5' => 0, '6' => 0, '7' => 0, '8' => 0); $hidesendtohh = isset($_GET['hidetohh']) && $_GET['hidetohh'] == 'true'; $status = statusName(); $statusdaymrk = strtotime('-3 days'); $considerlate = date('Y-m-d', strtotime('-7 days')); $considerlate_status = date('Y-m-d', $statusdaymrk); $limitrows = 100; $tohh_text = $hidesendtohh ? 'Show' : 'Hide'; $tohh_text2 = $hidesendtohh ? 'Include' : 'Exclude'; $togglethumbs = '<div style="margin-bottom:20px;">'; $togglethumbs .= '<input id="lo-togglethumbs" type="button" class="button" value="Toggle Products Thumbnails" />'; $togglethumbs .= '<input id="lo-toggletohh" type="button" class="button" value="' . $tohh_text . ' Status "Sent to HH"" title="Click here to ' . $tohh_text2 . ' Status Sent to HH in the list" />'; $togglethumbs .= '<input id="lo-hidetohh" type="hidden" value="' . ($hidesendtohh ? '1' : '0') . '" />'; //$togglethumbs .= '<input id="lo-checkinhh" type="button" class="button" value="Check Waiting Orders in HH" />'; $togglethumbs .= '</div>'; //DEPOT ORDERS $q = "SELECT do.*, bs.name AS segment_name, DATE(MAX(dosh.update_time)) AS status_date"; $q .= ", p.products_image, p.products_model, p.products_price AS price";
use_class('depot_orders'); use_class('jng_sp'); use_class('jng_sp_orders'); use_class('jng_sp_packages'); use_class('minierp_packages'); use_class('products_ean'); use_class('bins'); $class_o = new orders(); $class_do = new depot_orders(); $class_sp = new jng_sp(); $class_jo = new jng_sp_orders(); $class_jp = new jng_sp_packages(); $class_mp = new minierp_packages(); $class_ean = new products_ean(); $class_bins = new bins(); $item_status = statusName(); define('EAN_MISMATCH_ERROR', 'EANMISMATCH'); $waiting_box_name = 'Waiting Box'; $packing_box_name = 'Packing Box'; $finish_box_name = 'Finish Box'; $order_show_sp_info = array('9'); //am.fr function printPackageTip($type, $no, $info = '', $spname = '', $spclass = '') { global $waiting_box_name, $packing_box_name; if ($type == EAN_MISMATCH_ERROR) { $result = '<div class="package-tip red-bright">'; $result .= 'EAN Code<br />MISMATCH'; $result .= '</div>'; //$result .= '<div class="package-tip-info">Required EAN: '..'</div>'; $result .= '<div><table align="center" border="0" cellpadding="0" cellspacing="0">';
break; case 'price2': //Total Price $qty_price = $ordered_qty * $i[$items_colname_price]; $value = displayCurrency($order_currency, $qty_price); if (!statusIsCancelled($i['status'])) { $total_price += $qty_price; } break; case 'input tac': //Status $value = '<div><a href="?open=' . ($source == 'JG' ? 'order-history&opid' : 'sp-order-history&oi_id') . '=' . $i[$items_colname_id] . '&hidemenu=true" class="view_webpage" title="' . $sop_mouse_over['status_history'] . '">'; $value .= $product_status_mappings[$i['status']]; $value .= '</a></div>'; $value .= '<div class="thumb" style="display:none;">'; $value .= '<div>(' . statusName($i['status']) . ')</div>'; $value .= '<div style="margin-top:10px;">PI Barcode: <a href="/print/production_instruction_pdf.php?type=' . strtolower($source) . '&oiid=' . $i[$items_colname_id] . '" target="_blank" title="' . $sop_mouse_over['pi_download'] . '">' . $source . '-' . $i[$items_colname_id] . '</a></div>'; if ($source == Order::ORDER_TYPE_JULIE_GRACE) { $value .= '<div>No Shipping Window</div>'; } else { $value .= '<div>'; $value .= '<abbr title="Shipping Window">Ship-Win</abbr>: ' . date('d.m', strtotime($i['shipping_window_open'])) . '-'; $value .= !is_null($i['shipping_window_close']) ? date('d.m', strtotime($i['shipping_window_close'])) : 'N/A'; $value .= '</div>'; } $value .= '<div class="notice" style="margin-top:10px;">'; $value .= '<div><abbr title="Lead Time">LT</abbr> Start: ' . date('d.m.Y H:i', strtotime($i['leadtime_start_date'])) . '</div>'; $value .= '<div>Print Count/Confirmed: ' . $i['print_count'] . '/' . $i['print_confirmed'] . '</div>'; $value .= '<div><abbr title="Last EAN Printed">LEP</abbr>: ' . ($i['ean_printed'] != '' ? date('d.m.Y H:i', strtotime($i['ean_printed'])) : 'no log yet') . '</div>'; $value .= '</div>'; if ($source == Order::ORDER_TYPE_SALES_PARTNER) {
$order_product['name'] .= '<br />• '.$pa_row['products_options'].' '.$pa_row['products_options_values']; } $order_product['name'] .= '</small>'; } */ $order_product['price'] = displayCurrency($order_currency, $row['final_price']); $order_product['qty'] = $row['products_quantity']; $order_product['price2'] = displayCurrency($order_currency, $p_qty_pri); if ($row['status'] == '-') { $status = $statusName[$row['status']]; } else { $status = '<a href="?open=order-history&opid=' . $op_id_temp . '&hidemenu=true" class="view_webpage">'; if (statusIsCancelled($row['status'])) { $order_product['qty'] = '<span class="notice">' . $row['products_quantity'] . '</span>'; $order_product['price2'] = '<span class="notice">-</span>'; $status .= statusName($row['status']); } else { $status .= $statusName[$row['status']]; } $status .= '</a>'; } $stock_status = stockStatusDisplay($row['stock_status'], $row['status'], $row['products_id'], $row['products_articles_id'], $row['products_quantity'], $do); $stock_status .= " / " . modeName($row['mode']); $order_product['source'] = $stock_status; $order_product['nick'] = $status; //if($row['products_problem']=='1') $order_product['name'] = '<img src="images/icon-yellow.png" onclick="alert(\'This Product is marked as damage/missing on arrival\');" align="left" title="This Product is marked as damage/missing on arrival" /> ' . $order_product['name']; $action = '<input type="hidden" name="opid" value="' . $row['orders_products_id'] . '" id="opid-' . $row['orders_products_id'] . '" />'; $action .= '<input type="hidden" name="status" value="' . $row['status'] . '" />'; $action .= '<input type="hidden" name="print_count" value="' . $row['print_count'] . '" />'; if ($row['status'] < 9) { $action .= '<input type="button" name="Cancel" value="Cancel" />';
<?php use_class('SalesPartner'); use_class('jng_sp_orders'); use_class('orders'); use_class('products_ean'); $barcode = tep_db_prepare_input($_POST['barcode']); $barcode_split = explode('-', $barcode); $type = $barcode_split[0]; $type_length = strlen($type); $item_id = $barcode_split[1]; $inhh_status = '8'; $products_ean = array(); $products_qty = array(); $products_found = false; $statusName = statusName(); $barcode_new = ''; $result['status'] = 'NONE'; $result['relabel_ean'] = '0'; $result['barcode_new'] = $barcode; if ($type == 'SP' || $type == 'JR') { $class_jo = new jng_sp_orders(); $item = $class_jo->retrieveItemDetail($item_id); if (isset($item['jng_sp_orders_id']) && $item['jng_sp_orders_id'] > 0) { $order = $class_jo->retrieveDetail($item['jng_sp_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!';
function oiErrorStatus($items_id, $item_status, $status_tab) { $result = null; $status_depos = array('8', '9', '11'); if ($status_tab == '3') { if (in_array($item_status, $status_depos)) { $result = "<strong>JG-{$items_id}</strong> is moved to HH<br /><strong class='red'>REMOVE PI and CANCEL PRODUCTION!</strong>"; } } 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; }
function productStatusName($status = null) { return statusName($status); }
public function renderLeadtimePopup($order_type, $orders_items_id) { $query = ''; if ($order_type == self::ORDER_TYPE_SP) { $query = " SELECT * FROM ("; $query .= "SELECT joi.jng_sp_orders_items_id, joi.leadtime_start_date, joish.status, joish.status_date"; $query .= " FROM jng_sp_orders_items joi"; $query .= " INNER JOIN jng_sp_orders_items_status_history joish ON joish.jng_sp_orders_items_id = joi.jng_sp_orders_items_id"; $query .= " WHERE joi.status >= 1 AND joi.jng_sp_orders_items_id = {$orders_items_id}"; $query .= " UNION ALL"; $query .= " SELECT psh.orders_items_id AS jng_sp_orders_items_id, joi.leadtime_start_date, CONCAT('4-',SUBSTR(psh.status,1,1)) status, psh.status_date"; $query .= " FROM jng_sp_orders_items joi"; $query .= " INNER JOIN production_status_history psh ON psh.type='SP' AND psh.orders_items_id = joi.jng_sp_orders_items_id"; $query .= " WHERE joi.status >= 1 AND joi.jng_sp_orders_items_id = {$orders_items_id}"; $query .= " ) dt"; $query .= " ORDER BY status_date, status"; } elseif ($order_type == self::ORDER_TYPE_JG) { $query = " SELECT * FROM ("; $query .= " SELECT opsh.orders_products_id, op.leadtime_start_date, opsh.status, opsh.status_date"; $query .= " FROM orders_products op"; $query .= " INNER JOIN orders_products_status_history opsh ON opsh.orders_products_id = op.orders_products_id"; $query .= " WHERE op.status >= 1 AND op.orders_products_id = {$orders_items_id}"; $query .= " UNION ALL"; $query .= " SELECT psh.orders_items_id AS orders_products_id, op.leadtime_start_date, CONCAT('4-',SUBSTR(psh.status,1,1)) status, psh.status_date"; $query .= " FROM orders_products op"; $query .= " INNER JOIN production_status_history psh ON psh.type='JG' AND psh.orders_items_id = op.orders_products_id"; $query .= " WHERE op.status >= 1 AND op.orders_products_id = {$orders_items_id}"; $query .= " ) dt"; $query .= " ORDER BY status_date, status"; } elseif ($order_type == self::ORDER_TYPE_DP) { $query = " SELECT * FROM ("; $query .= " SELECT do.depot_orders_id, do.leadtime_start_date, dosh.status, dosh.update_time AS status_date"; $query .= " FROM depot_orders do"; $query .= " INNER JOIN depot_orders_status_history dosh ON dosh.depot_orders_id = do.depot_orders_id"; $query .= " WHERE do.status >= 1 AND do.depot_orders_id = {$orders_items_id}"; $query .= " UNION ALL"; $query .= " SELECT psh.orders_items_id AS depot_orders_id, do.leadtime_start_date, CONCAT('4-',SUBSTR(psh.status,1,1)) status, psh.status_date"; $query .= " FROM depot_orders do"; $query .= " INNER JOIN production_status_history psh ON psh.type='DP' AND psh.orders_items_id = do.depot_orders_id"; $query .= " WHERE do.status >= 1 AND do.depot_orders_id = {$orders_items_id}"; $query .= " ) dt"; $query .= " ORDER BY status_date, status"; } if ($query != '') { $dbq = tep_db_query($query); $prev_oi_id = ''; $kpi_status_cycletime = array(); while ($row = tep_db_fetch_array($dbq)) { $leadtime_start_date = $row['leadtime_start_date']; $current_status = $row['status']; $oi_id = $row['jng_sp_orders_items_id']; //use leadtime start date as start date when orders processed if ($current_status == 1) { $row['status_date'] = $leadtime_start_date; } if ($oi_id == $prev_oi_id && isset($prev_status)) { //UPDATED TO USE AVERAGE VALUE if (!isset($kpi_status_cycletime[$prev_status])) { $kpi_status_cycletime[$prev_status] = array(); } if (!isset($kpi_status_cycletime[$prev_status][$oi_id])) { $kpi_status_cycletime[$prev_status][$oi_id] = 0; } $kpi_status_cycletime[$prev_status][$oi_id] += strtotime($row['status_date']) - strtotime($prev_status_time); } $prev_status = $row['status']; $prev_status_time = $row['status_date']; $prev_oi_id = $oi_id; } //---START Manage status to show using below array (notes: status need to be sorted based on real process - from new until ends) $status_to_show = array('1', '2', '3', '4'); //Include also production sub status $prod_sub_status = getProductionSubStatus(4); foreach ($prod_sub_status as $pss_k => $pss_v) { array_push($status_to_show, "4-{$pss_k}"); } for ($s = 5; $s <= 7; $s++) { array_push($status_to_show, "{$s}"); } //Also Depot/Mixed status, in case there order taken over by HH then set back to MTO array_push($status_to_show, '8'); //---END Manage status to show... $row = array(); $tooltip_leadtime = array(); $row['c1'] = 'Tabs Through'; $row['c2'] = 'Lead Time'; $tooltip_leadtime[] = $row; $total_process = 0; $total_process_sub = array(); $total_process_temp = array(); $result = false; $row_temp = array(); $tab_have_sub_status = array('4'); foreach ($status_to_show as $sv) { $colval = isset($kpi_status_cycletime[$sv]) ? array_sum($kpi_status_cycletime[$sv]) / count($kpi_status_cycletime[$sv]) : 0; $temp_status = explode('-', $sv); if ($colval > 0 || !isset($temp_status[1]) && isset($kpi_status_cycletime[$sv])) { $result = true; $total_process += $colval; if (isset($temp_status[1])) { $total_process_sub[$temp_status[0]] += $colval; } if (in_array($temp_status[0], $tab_have_sub_status) && !isset($row_temp[$temp_status[0]])) { $row_temp[$temp_status[0]]['c1'] = '<strong style="font-size:13px;">' . statusName($temp_status[0]) . '</strong>'; $total_process_temp[$sv] += $colval; } $row_temp[$sv]['c1'] = $temp_status[0] == '4' && isset($temp_status[1]) ? statusNameProduction($temp_status[1]) : statusName($sv); $row_temp[$sv]['c2 right'] = displayDuration($colval, 'day', 2); if (!isset($temp_status[1])) { $row_temp[$sv]['c1'] = '<strong style="font-size:13px;">' . $row_temp[$sv]['c1'] . '</strong>'; $row_temp[$sv]['c2 right'] = '<strong style="font-size:13px;">' . $row_temp[$sv]['c2 right'] . '</strong>'; } if (isset($temp_status[1])) { $row_temp[$sv]['c1'] = '<div style="margin-left:20px;">' . $row_temp[$sv]['c1'] . '</div>'; } } } //Show sub status leadtime foreach ($row_temp as $rk => $rv) { $row = array(); if (in_array($rk, $tab_have_sub_status)) { if (isset($total_process_sub[$rk])) { $tps = $total_process_sub[$rk]; $total_process -= $total_process_temp[$rk]; } else { $tps = $total_process_temp[$rk]; } $row_temp[$rk]['c2 right'] = '<strong style="font-size:13px;">' . displayDuration($tps, 'day', 2) . '</strong>'; } $row['c1'] = $row_temp[$rk]['c1']; $row['c2 right'] = $row_temp[$rk]['c2 right']; $tooltip_leadtime[] = $row; } if (!$result) { $result = "No lead time per tab measured yet for this"; } else { $row['c1'] = '<span style="font-size:13px;">Total</span>'; $row['c2 right'] = '<span style="font-size:13px;">' . displayDuration($total_process, 'day', 2) . '</span>'; $tooltip_leadtime[] = $row; $result = tep_draw_table('summary2', $tooltip_leadtime, false, true); } } else { $result = 'Query not found for this order type'; } return $result; }
function statusName() { return statusName(); }
$ajaxResult['pid'] = $pid; $ajaxResult['aid'] = $aid; $ajaxResult['stock'] = $qty_stock; echo ajaxReturn($ajaxResult); exit; } elseif ($_POST['me_action'] == 'CONFIRMPREORDER') { $preorder->setAsConfirmed(); echo 'OK'; exit; } elseif ($_POST['me_action'] == 'CHECKDOSTATUS') { $dofilter = implode(',', $preorder->depot_orders_id); $result = '<table border="0" cellspacing="0" cellpadding="0">'; $result .= '<tr><td class="bold" style="width:120px;">Status</td><td class="tac bold">Total Products</td></tr>'; $q = tep_db_query("SELECT status, SUM(quantity) AS total_order FROM depot_orders WHERE depot_orders_id IN ({$dofilter}) GROUP BY status"); while ($row = tep_db_fetch_array($q)) { $result .= '<tr><td>' . statusName($row['status']) . '</td><td class="tac">' . $row['total_order'] . '</td></tr>'; } $result .= '</table>'; echo utf8_encode($result); exit; } if (isset($preorder)) { $preorder->comments->processPostAction($preorder->create_by_id, $preorder->followers); $preorder->followers->processPostAction(); } } if (isset($_GET['sourcing-overview']) && $_GET['sourcing-overview'] == 'true') { use_class('element'); use_class('elements_stock'); $class_es = new elements_stock(); //$overview = '<h1>Sourcing Overview for Preorder: '.$preorder->name.'</h1>'; //todo: change below version to this version for live
$languages[$row['languages_id']]['path'] = $row['directory']; } //SP CONFIRM NEW ORDERS //except for amazon and buyvip which we will generate on demand because we have //to upload manually the confimation file to their website //TODO: move from manual confirmation to here //JNG CONFIRM ORDERS CANCELLATION //need a new function to retrieve products for cancelation, //but think of a general way to not return an array but the database result //so the update and confirmation is sent per row which is much more safe. //in the future we might use this method to run a query instead of always //returning a full list as array, we always try to run in per row $logger->write('- Confirm cancel status of JNG orders'); $cancel_status_unconfirmed = '10'; $cancel_status_confirmed = '12'; $cancel_status_name = statusName($cancel_status_confirmed); $items = $class_o->retrieveOrdersProducts($cancel_status_unconfirmed); $items_total = count($items); if ($items_total == 0) { $logger->write('There are no unconfirmed canceled found'); } else { $logger->write("There are {$items_total} items need to be confirmed"); //Group Items per Order $orders_cancelled = array(); foreach ($items as $i) { if (!isset($orders_cancelled[$i['orders_id']])) { $orders_cancelled[$i['orders_id']] = array(); } $orders_cancelled[$i['orders_id']][] = $i['orders_products_id']; } $orders_total = count($orders_cancelled);
function statusName($status = null) { return statusName($status); }
use_class('products_articles'); $class_pa = new products_articles(); $whid_material = '1'; //1 is default warehuse for elements $whid_fg_hh = '5'; //5 is default warehouse for depot in HH $order_id = tep_db_prepare_input($_GET['id']); if (isset($_POST['me_action'])) { if ($_POST['me_action'] == 'SETSTATUS') { $newstatus = tep_db_prepare_input($_POST['newstatus']); $class_do->updateStatus($order_id, $newstatus, $session_userinfo['username']); if ($newstatus == '1') { $class_do->updateStockStatus($order_id, '0'); } $newstatus_msg['1'] = 'Order is set back as <strong>' . statusName('1') . '<strong>!'; $newstatus_msg['8'] = 'Order is set as <strong>' . statusName('8') . '<strong>!'; $newstatus_msg['10'] = 'Order is <strong>Canceled<strong>!'; $messagebox->add($newstatus_msg[$newstatus], 'green'); if ($newstatus == '1' || $newstatus == '10') { $subject = 'MISSING PRODUCT!'; $message = 'A Product from Depot Order has been reported missing (sent to HH but never receive): '; $message .= '<a href="http://manobo.de/?open=depot-order&id=' . $order_id . '">DP-' . $order_id . '</a>'; } elseif ($newstatus == '8') { $subject = 'MANUAL SET STATUS!'; $message = 'A Product from Depot Order has been set manually as received in HH by ' . $session_userinfo['username'] . ': '; $message .= '<a href="http://manobo.de/?open=depot-order&id=' . $order_id . '">DP-' . $order_id . '</a>'; } if ($subject != '' && $message != '') { tep_mail(EMAIL_NAME_DEBUGR, EMAIL_ADDRESS_DEBUGR, $subject, $message, FROM_EMAIL_NAME, FROM_EMAIL_ADDRESS, false); } unset($class_do->items[$order_id]);