<?php use_class('jng_sp'); $class_sp = new jng_sp(); $vc_params = array(); $vc_labels = array(); $vc_units = array(); $unit_product = '<span class="notice">Products</span>'; $unit_price = '<span class="notice">EUR</span>'; $unit_percent = '<span class="notice">%</span>'; $vc_labels[] = 'Freight Charge Bali-HH'; $vc_params[] = 'cost_packaging_tohh'; $vc_units[] = $unit_percent; $vc_labels[] = 'Customs + Other Expenses'; $vc_params[] = 'cost_customs'; $vc_units[] = $unit_percent; $vc_labels[] = 'Product per Package Sent to Cust'; $vc_params[] = 'avg_product_orders_sent'; $vc_units[] = $unit_product; $vc_labels[] = 'Product per Package Returned by Cust'; $vc_params[] = 'avg_product_orders_returned'; $vc_units[] = $unit_product; $vc_labels[] = 'Postage per Package Sent to Cust'; $vc_params[] = 'cost_orders_sent'; $vc_units[] = $unit_price; $vc_labels[] = 'Postage per Package Returned by Cust'; $vc_params[] = 'cost_orders_returned'; $vc_units[] = $unit_price; $vc_labels[] = 'Packaging Cost in Bali'; $vc_params[] = 'cost_packaging_product'; $vc_units[] = $unit_price;
<?php ini_set('memory_limit', '256M'); set_time_limit(0); $mt_start = microtime(); global $db; require_once '../confy.php'; require_once '../functions.php'; require_once '../functions-2.php'; tep_db_connect(); use_class('logger'); $logger = new logger('cron', 'daily-counter'); use_class('jng_sp'); use_class('jng_sp_orders'); use_class('jng_sp_catalog'); $class_sp = new jng_sp(); $class_jo = new jng_sp_orders(); $class_jc = new jng_sp_catalog(); $sp_data = $class_sp->retrieveList(); ////////////////////////////// // SP PRODUCTS SOLD COUNTER // ////////////////////////////// $logger->write('1 - Product Sold Counter'); //TODO: The calculation is still based on jng_sp_catalog, which means SP with no //catalog (like buyvip/retails) will not be included in this calculation! foreach ($sp_data as $sp_list) { $class_jo->productsSoldCounter($sp_list['jng_sp_id']); } unset($sp); /* WE STOP CALCULATING VC USING OLD METHOD * NEW VC CALCULATION IS NOT IN ORDER BASED, BUT IN SP BASED
<?php /** * Provide data for Chart Sales Summary "Last 60 Days Sales Chart" on Dashboard * @author IT TEAM BONOFACTUM * @created Nov 18, 2013 10:53:01 PM */ require_once 'confy_open.php'; use_class('php-ofc-library/open-flash-chart'); use_class('jng_sp'); $class_sp = new jng_sp(); $period = array(); $bar_values = array(); $format_date = 'd M'; $days = isset($_GET['d']) ? tep_db_prepare_input($_GET['d']) : 60; $y_points = 10; for ($p = $days; $p >= 0; $p--) { $format = date($format_date, strtotime("-{$p} days")); $period[] = $format; $bar_values[$format] = 0; } $q = " SELECT * FROM"; $q .= " (SELECT o.date_purchased AS order_date, op.products_quantity AS products"; $q .= " FROM orders o"; $q .= " LEFT JOIN orders_products op ON op.orders_id=o.orders_id"; $q .= " WHERE o.date_purchased>=DATE_SUB(CURRENT_DATE(), INTERVAL {$days} DAY)"; $q .= " AND o.orders_status<=10"; $q .= " UNION ALL"; $sp_active = $class_sp->retrieveList(); //Products sold on sp's $q .= " SELECT jo.order_date, joi.order_quantity AS products";
<?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ use_class('jng_sp'); use_class('scorecard'); $class_sp = new jng_sp(); $year_period = date('Y'); $year_previous = strval(intval($year_period) - 1); $current_month = date('m'); $based_options = array(); $based_options['sp'] = 'Sales Partners'; $based_options['stars'] = 'Stars'; if (isset($_POST['me_action'])) { if ($_POST['me_action'] == 'SAVEMANUALINPUT') { $spanid = tep_db_prepare_input($_POST['spanid']); $newvalue = str_replace(' ', '', tep_db_prepare_input($_POST['newvalue'])); if (strpos($newvalue, ',') !== false) { $newvalue = str_replace(',', '.', str_replace('.', '', $newvalue)); } $spanid_exp = explode('-', $spanid); $based = $spanid_exp[0]; $based_id = $spanid_exp[2]; $period_raw = $spanid_exp[1]; $period = substr($period_raw, 0, 4) . '-' . substr($period_raw, 4, 2) . '-01'; $colname = $spanid_exp[3]; $products_listed = null; $products_listed_top = null; $plan_total_sent = null;
/** * Construct KPI Leadtime Table * @param string $status * @param string $kpi_closing_date_start * @param string $kpi_closing_date_end * @return string */ function kpiLeadtimeLoad($kpi_status, $kpi_closing_date_start = '', $kpi_closing_date_end = '') { use_class('jng_sp'); use_class('design'); $class_sp = new jng_sp(); $sp_b2b = array_keys($class_sp->retrieveList('active_status = 1 AND use_amvd_logistic = 1')); $target_leadtime = load_config('kpi-leadtime'); $design_categories = design::getDesignCategory(); $initial = array('sourcing' => 0, 'depot-refill-orders' => 0, 'internal-levelling-orders' => 0, 'cust-order-mto-mmo' => 0, 'external-levelling-order' => 0, 'full-dso' => 0, 'mto' => 0); foreach ($design_categories as $des_cat_id => $des_cat_name) { $initial["design-{$des_cat_id}"] = 0; } $below_target = $initial; $on_target = $initial; $above_target_1to3d = $initial; $above_target_gt3d = $initial; $total = $initial; $kpi_leadtime_data_o = array(); //open $kpi_leadtime_data_c = array(); //closed //PREPARE KPI LEADTIME DATA if ($kpi_status == 'o') { //OPEN ORDERS //Sourcing $q = " SELECT sp_type, item_id, quantity, MIN(status_date) AS date_start FROM"; $q .= " ("; $q .= " SELECT 'sp' AS sp_type, joi.jng_sp_orders_items_id AS item_id" . ", joish.status_date, joi.order_quantity AS quantity"; $q .= " FROM jng_sp_orders_items joi" . " INNER JOIN jng_sp_orders_items_status_history joish ON joish.jng_sp_orders_items_id = joi.jng_sp_orders_items_id" . " AND joish.status = 2"; $q .= " WHERE joi.status = 2"; $q .= " UNION"; $q .= " SELECT 'jg' AS sp_type, op.orders_products_id AS item_id" . ", opsh.status_date, op.products_quantity AS quantity"; $q .= " FROM orders_products op" . " INNER JOIN orders_products_status_history opsh ON opsh.orders_products_id = op.orders_products_id" . " AND opsh.status = 2"; $q .= " WHERE op.status = 2"; $q .= " UNION"; $q .= " SELECT 'dp' AS sp_type, do.depot_orders_id AS item_id" . ", dosh.update_time AS status_date, do.quantity"; $q .= " FROM depot_orders do" . " INNER JOIN depot_orders_status_history dosh ON dosh.depot_orders_id = do.depot_orders_id" . " AND dosh.status = 2"; $q .= " WHERE do.status = 2"; $q .= ") dt"; $q .= " GROUP BY sp_type, item_id"; $dbq = tep_db_query($q); while ($r = tep_db_fetch_array($dbq)) { //Sourcing Order Type $kpi_leadtime_data_o['sourcing'][] = $r; } //Production $q = " SELECT sp_type, item_id, quantity, MIN(status_date) AS date_start, mode, order_type, order_type_id, order_type_name"; $q .= " FROM ("; $q .= " SELECT 'sp' AS sp_type, joi.jng_sp_orders_items_id AS item_id" . ", joish.status_date, joi.order_quantity AS quantity, joi.mode" . ", '' AS order_type, '' AS order_type_id, '' AS order_type_name"; $q .= " FROM jng_sp_orders_items joi" . " INNER JOIN jng_sp_orders_items_status_history joish ON joish.jng_sp_orders_items_id = joi.jng_sp_orders_items_id" . " AND joish.status = 4"; $q .= " WHERE joi.status = 4"; $q .= " UNION"; $q .= " SELECT 'jg' AS sp_type, op.orders_products_id AS item_id" . ", opsh.status_date, op.products_quantity AS quantity, op.mode" . ", '' AS order_type, '' AS order_type_id, '' AS order_type_name"; $q .= " FROM orders_products op" . " INNER JOIN orders_products_status_history opsh ON opsh.orders_products_id = op.orders_products_id" . " AND opsh.status = 4"; $q .= " WHERE op.status = 4"; $q .= " UNION"; $q .= " SELECT 'dp' AS sp_type, do.depot_orders_id AS item_id" . ", dosh.update_time AS status_date, do.quantity, '' AS mode" . ", trans_type AS order_type, trans_id AS order_type_id, group_name AS order_type_name"; $q .= " FROM depot_orders do" . " INNER JOIN depot_orders_status_history dosh ON dosh.depot_orders_id = do.depot_orders_id" . " AND dosh.status = 4"; $q .= " WHERE do.status = 4"; $q .= ") dt"; $q .= " GROUP BY sp_type, item_id"; $dbq = tep_db_query($q); while ($r = tep_db_fetch_array($dbq)) { if ($r['order_type'] == 'AR' || $r['order_type'] == '' && $r['order_type_id'] == depot_orders::MANUAL_REFILL_ID) { //Depot Refill Order Type $kpi_leadtime_data_o['depot-refill-orders'][] = $r; } elseif ($r['order_type_name'] == depot_orders::GROUP_NAME_LTF_INTERNAL) { //Internal Levelling Order Type $kpi_leadtime_data_o['internal-levelling-orders'][] = $r; } elseif ($r['mode'] == 2 || $r['mode'] == 4) { //Customer Orders (MTO/MMO) Order Type $kpi_leadtime_data_o['cust-order-mto-mmo'][] = $r; } } //Outsourcing $q = " SELECT do.depot_orders_id AS item_id, MIN(dosh.update_time) AS status_date, do.quantity"; $q .= " FROM depot_orders do" . " INNER JOIN depot_orders_status_history dosh ON dosh.depot_orders_id = do.depot_orders_id" . " AND dosh.status = 22"; $q .= " WHERE do.status = 22"; $q .= " AND do.trans_type = '' && do.trans_id = " . depot_orders::MANUAL_REFILL_OUTSOURCED; $q .= " GROUP BY item_id"; $dbq = tep_db_query($q); while ($r = tep_db_fetch_array($dbq)) { //External Levelling Order Type $kpi_leadtime_data_o['external-levelling-order'][] = $r; } //Customer Order $q = " SELECT sp_type, item_id, quantity, MIN(status_date) AS date_start, mode"; $q .= " FROM ("; $q .= " SELECT 'sp' AS sp_type, joi.jng_sp_orders_items_id AS item_id" . ", joish.status_date, joi.order_quantity AS quantity, joi.mode"; $q .= " FROM jng_sp_orders jo " . " INNER JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_id = jo.jng_sp_orders_id" . " INNER JOIN jng_sp_orders_items_status_history joish ON joish.jng_sp_orders_items_id = joi.jng_sp_orders_items_id" . " AND joish.status = 1"; $q .= " WHERE joi.status < 9 AND jo.jng_sp_id NOT IN (" . implode(',', $sp_b2b) . ")"; $q .= " UNION"; $q .= " SELECT 'jg' AS sp_type, op.orders_products_id AS item_id" . ", opsh.status_date, op.products_quantity AS quantity, op.mode"; $q .= " FROM orders_products op" . " INNER JOIN orders_products_status_history opsh ON opsh.orders_products_id = op.orders_products_id" . " AND opsh.status = 1"; $q .= " WHERE op.status < 9"; $q .= ") dt"; $q .= " GROUP BY sp_type, item_id"; $dbq = tep_db_query($q); while ($r = tep_db_fetch_array($dbq)) { if ($r['mode'] == 1) { //Full DSO Order Type $kpi_leadtime_data_o['full-dso'][] = $r; } elseif ($r['mode'] == 2 || $r['mode'] == 3 || $r['mode'] == 4) { $kpi_leadtime_data_o['mto'][] = $r; } } //Design $q = " SELECT d.designs_category, 1 AS quantity, d.designs_id AS item_id" . ", FROM_UNIXTIME(MIN(dsh.status_time)) AS date_start"; $q .= " FROM designs d " . " INNER JOIN designs_status_history dsh ON dsh.designs_id = d.designs_id AND dsh.status = 2"; $q .= " WHERE d.status NOT IN (1, 9)"; $q .= " GROUP BY d.designs_id"; $dbq = tep_db_query($q); while ($r = tep_db_fetch_array($dbq)) { $kpi_leadtime_data_o["design-{$r['designs_category']}"][] = $r; } } elseif ($kpi_status == 'c') { $kpi_filter_closing_date_start = date('Y-m-d', strtotime($kpi_closing_date_start)); $kpi_filter_closing_date_end = date('Y-m-d', strtotime($kpi_closing_date_end)); //Sourcing $q = " SELECT * FROM"; $q .= " ("; $q .= " SELECT 'sp' AS sp_type, joi.jng_sp_orders_items_id AS item_id, joi.order_quantity AS quantity" . ", MIN(joish_2.status_date) AS date_start, MAX(joish_3.status_date) AS date_end"; $q .= " FROM jng_sp_orders_items_status_history joish_3" . " LEFT JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_items_id = joish_3.jng_sp_orders_items_id" . " LEFT JOIN jng_sp_orders_items_status_history joish_2 ON joish_2.jng_sp_orders_items_id = joi.jng_sp_orders_items_id" . " AND joish_2.status = 2"; $q .= " WHERE joish_3.status_date >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND joish_3.status_date <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND joish_3.status = 3 AND joi.status NOT IN (1, 2)"; $q .= " GROUP BY sp_type, item_id"; $q .= " UNION"; $q .= " SELECT 'jg' AS sp_type, op.orders_products_id AS item_id, op.products_quantity AS quantity" . ", MIN(opsh_2.status_date) AS date_start, MAX(opsh_3.status_date) AS date_end"; $q .= " FROM orders_products_status_history opsh_3" . " LEFT JOIN orders_products op ON op.orders_products_id = opsh_3.orders_products_id" . " LEFT JOIN orders_products_status_history opsh_2 ON opsh_2.orders_products_id = op.orders_products_id" . " AND opsh_2.status = 2"; $q .= " WHERE opsh_3.status_date >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND opsh_3.status_date <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND opsh_3.status = 3 AND op.status NOT IN (1, 2)"; $q .= " GROUP BY sp_type, item_id"; $q .= " UNION"; $q .= " SELECT 'dp' AS sp_type, do.depot_orders_id AS item_id, do.quantity" . ", MIN(dosh_2.update_time) AS date_start, MAX(dosh_3.update_time) AS date_end"; $q .= " FROM depot_orders_status_history dosh_3" . " LEFT JOIN depot_orders do ON do.depot_orders_id = dosh_3.depot_orders_id" . " LEFT JOIN depot_orders_status_history dosh_2 ON dosh_2.depot_orders_id = do.depot_orders_id" . " AND dosh_2.status = 2"; $q .= " WHERE dosh_3.update_time >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND dosh_3.update_time <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND dosh_3.status = 3 AND do.status NOT IN (1, 2)"; $q .= " GROUP BY sp_type, item_id"; $q .= ") dt"; $q .= " WHERE date_start IS NOT NULL AND date_end IS NOT NULL"; $dbq = tep_db_query($q); while ($r = tep_db_fetch_array($dbq)) { //Sourcing Order Type $kpi_leadtime_data_c['sourcing'][] = $r; } //Production $q = " SELECT * FROM"; $q .= " ("; $q .= " SELECT 'sp' AS sp_type, joi.jng_sp_orders_items_id AS item_id, joi.order_quantity AS quantity" . ", MIN(joish_4.status_date) AS date_start, MAX(joish_5.status_date) AS date_end, joi.mode" . ", '' AS order_type, '' AS order_type_id, '' AS order_type_name"; $q .= " FROM jng_sp_orders_items_status_history joish_5" . " LEFT JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_items_id = joish_5.jng_sp_orders_items_id" . " LEFT JOIN jng_sp_orders_items_status_history joish_4 ON joish_4.jng_sp_orders_items_id = joi.jng_sp_orders_items_id" . " AND joish_4.status = 4"; $q .= " WHERE joish_5.status_date >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND joish_5.status_date <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND joish_5.status = 5 AND joi.status NOT IN (1, 2, 3, 4)"; $q .= " GROUP BY sp_type, item_id"; $q .= " UNION"; $q .= " SELECT 'jg' AS sp_type, op.orders_products_id AS item_id, op.products_quantity AS quantity" . ", MIN(opsh_4.status_date) AS date_start, MAX(opsh_5.status_date) AS date_end, op.mode" . ", '' AS order_type, '' AS order_type_id, '' AS order_type_name"; $q .= " FROM orders_products_status_history opsh_5" . " LEFT JOIN orders_products op ON op.orders_products_id = opsh_5.orders_products_id" . " LEFT JOIN orders_products_status_history opsh_4 ON opsh_4.orders_products_id = op.orders_products_id" . " AND opsh_4.status = 4"; $q .= " WHERE opsh_5.status_date >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND opsh_5.status_date <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND opsh_5.status = 5 AND op.status NOT IN (1, 2, 3, 4)"; $q .= " GROUP BY sp_type, item_id"; $q .= " UNION"; $q .= " SELECT 'dp' AS sp_type, do.depot_orders_id AS item_id, do.quantity" . ", MIN(dosh_4.update_time) AS date_start, MAX(dosh_5.update_time) AS date_end, '' AS mode" . ", trans_type AS order_type, trans_id AS order_type_id, group_name AS order_type_name"; $q .= " FROM depot_orders_status_history dosh_5" . " LEFT JOIN depot_orders do ON do.depot_orders_id = dosh_5.depot_orders_id" . " LEFT JOIN depot_orders_status_history dosh_4 ON dosh_4.depot_orders_id = do.depot_orders_id" . " AND dosh_4.status = 4"; $q .= " WHERE dosh_5.update_time >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND dosh_5.update_time <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND dosh_5.status = 5 AND do.status NOT IN (1, 2, 3, 4)"; $q .= " GROUP BY sp_type, item_id"; $q .= ") dt"; $q .= " WHERE date_start IS NOT NULL AND date_end IS NOT NULL"; $dbq = tep_db_query($q); while ($r = tep_db_fetch_array($dbq)) { if ($r['order_type'] == 'AR' || $r['order_type'] == '' && $r['order_type_id'] == depot_orders::MANUAL_REFILL_ID) { //Depot Refill Order Type $kpi_leadtime_data_c['depot-refill-orders'][] = $r; } elseif ($r['order_type_name'] == depot_orders::GROUP_NAME_LTF_INTERNAL) { //Internal Levelling Order Type $kpi_leadtime_data_c['internal-levelling-orders'][] = $r; } elseif ($r['mode'] == 2 || $r['mode'] == 4) { //Customer Orders (MTO/MMO) Order Type $kpi_leadtime_data_c['cust-order-mto-mmo'][] = $r; } } //Outsourcing $q = " SELECT * FROM"; $q .= " ("; $q .= " SELECT do.depot_orders_id AS item_id, do.quantity" . ", MIN(dosh_8.update_time) AS date_start, MAX(dosh_22.update_time) AS date_end"; $q .= " FROM depot_orders_status_history dosh_22" . " LEFT JOIN depot_orders do ON do.depot_orders_id = dosh_22.depot_orders_id" . " LEFT JOIN depot_orders_status_history dosh_8 ON dosh_8.depot_orders_id = do.depot_orders_id" . " AND dosh_8.status = 8"; $q .= " WHERE dosh_22.update_time >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND dosh_22.update_time <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND do.trans_type = '' AND do.trans_id = " . depot_orders::MANUAL_REFILL_OUTSOURCED . " AND dosh_22.status = 22 AND do.status NOT IN (1, 2, 3, 4, 5, 6, 7, 8, 9)"; $q .= " GROUP BY item_id"; $q .= ") dt"; $q .= " WHERE date_start IS NOT NULL AND date_end IS NOT NULL"; $dbq = tep_db_query($q); while ($r = tep_db_fetch_array($dbq)) { //External Levelling Order Type $kpi_leadtime_data_c['external-levelling-order'][] = $r; } //Customer Order (only B2C Sales Partner) $q = " SELECT * FROM"; $q .= " ("; $q .= " SELECT 'sp' AS sp_type, joi.jng_sp_orders_items_id AS item_id, joi.order_quantity AS quantity" . ", MIN(joish_1.status_date) AS date_start, MAX(joish_9.status_date) AS date_end, joi.mode"; $q .= " FROM jng_sp_orders_items_status_history joish_9" . " LEFT JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_items_id = joish_9.jng_sp_orders_items_id" . " INNER JOIN jng_sp_orders jo ON jo.jng_sp_orders_id = joi.jng_sp_orders_id" . " LEFT JOIN jng_sp_orders_items_status_history joish_1 ON joish_1.jng_sp_orders_items_id = joi.jng_sp_orders_items_id" . " AND joish_1.status = 1"; $q .= " WHERE joish_9.status_date >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND joish_9.status_date <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND joish_9.status = 9 AND joi.status NOT IN (1, 2, 3, 4, 5, 6, 7, 8)" . " AND jo.jng_sp_id NOT IN (" . implode(',', $sp_b2b) . ")"; $q .= " GROUP BY sp_type, item_id"; $q .= " UNION"; $q .= " SELECT 'jg' AS sp_type, op.orders_products_id AS item_id, op.products_quantity AS quantity" . ", MIN(opsh_1.status_date) AS date_start, MAX(opsh_9.status_date) AS date_end, op.mode"; $q .= " FROM orders_products_status_history opsh_9" . " LEFT JOIN orders_products op ON op.orders_products_id = opsh_9.orders_products_id" . " LEFT JOIN orders_products_status_history opsh_1 ON opsh_1.orders_products_id = op.orders_products_id" . " AND opsh_1.status = 1"; $q .= " WHERE opsh_9.status_date >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND opsh_9.status_date <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND opsh_9.status = 9 AND op.status NOT IN (1, 2, 3, 4, 5, 6, 7, 8)"; $q .= " GROUP BY sp_type, item_id"; $q .= " UNION"; $q .= " SELECT 'dp' AS sp_type, do.depot_orders_id AS item_id, do.quantity" . ", MIN(dosh_1.update_time) AS date_start, MAX(dosh_9.update_time) AS date_end, '' AS mode"; $q .= " FROM depot_orders_status_history dosh_9" . " LEFT JOIN depot_orders do ON do.depot_orders_id = dosh_9.depot_orders_id" . " LEFT JOIN depot_orders_status_history dosh_1 ON dosh_1.depot_orders_id = do.depot_orders_id" . " AND dosh_1.status = 1"; $q .= " WHERE dosh_9.update_time >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND dosh_9.update_time <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND dosh_9.status = 9 AND do.status NOT IN (1, 2, 3, 4, 5, 6, 7, 8)"; $q .= " GROUP BY sp_type, item_id"; $q .= ") dt"; $q .= " WHERE date_start IS NOT NULL AND date_end IS NOT NULL"; $dbq = tep_db_query($q); while ($r = tep_db_fetch_array($dbq)) { if ($r['mode'] == 1) { //Full DSO Order Type $kpi_leadtime_data_c['full-dso'][] = $r; } elseif ($r['mode'] == 2 || $r['mode'] == 3 || $r['mode'] == 4) { $kpi_leadtime_data_c['mto'][] = $r; } } //Design $q = " SELECT d.designs_category, 1 AS quantity, d.designs_id AS item_id" . ", FROM_UNIXTIME(MIN(dsh_2.status_time)) AS date_start" . ", FROM_UNIXTIME(MAX(dsh_9.status_time)) AS date_end"; $q .= " FROM designs_status_history dsh_9 " . " LEFT JOIN designs d ON d.designs_id = dsh_9.designs_id" . " LEFT JOIN designs_status_history dsh_2 ON dsh_2.designs_id = d.designs_id AND dsh_2.status = 2"; $q .= " WHERE dsh_9.status_time >= " . strtotime($kpi_filter_closing_date_start . " 00:00:00") . " AND dsh_9.status_time <= " . strtotime($kpi_filter_closing_date_end . " 23:59:59") . " AND dsh_9.status = 9 AND d.status = 9"; $q .= " GROUP BY d.designs_id"; $dbq = tep_db_query($q); while ($r = tep_db_fetch_array($dbq)) { $kpi_leadtime_data_c["design-{$r['designs_category']}"][] = $r; } } $today = date('d-m-Y'); if ($kpi_status == 'c') { $kpi_leadtime_data = $kpi_leadtime_data_c; } else { $kpi_leadtime_data = $kpi_leadtime_data_o; } $leadtime_arr = array(); foreach ($kpi_leadtime_data as $order_type => $klds) { //klds: kpi leadtime datas foreach ($klds as $kld) { $lsd = $kld['date_start']; $led = $kpi_status == 'o' ? $today : $kld['date_end']; $qty = $kld['quantity']; $datediff_sec = strtotime($led) - strtotime($lsd); $leadtime = ceil($datediff_sec / 3600 / 24); //in days format (round up) $leadtime_arr[$order_type][] = $leadtime; $target = $target_leadtime[$order_type]; $total[$order_type] += $qty; if ($leadtime < $target) { $below_target[$order_type] += $qty; } elseif ($leadtime == $target) { $on_target[$order_type] += $qty; } elseif ($leadtime > $target + 3) { $above_target_gt3d[$order_type] += $qty; } else { $above_target_1to3d[$order_type] += $qty; } } $leadtime_avg[$order_type] = count($leadtime_arr[$order_type]) > 0 ? number_format(array_sum($leadtime_arr[$order_type]) / count($leadtime_arr[$order_type]), 2) : '-'; $leadtime_median[$order_type] = median($leadtime_arr[$order_type], 2); } //DRAW KPI LEADTIME TABLE $tooltip_info_saved = ' title="press enter to save changes" '; $border_dotted_bottom = 'border-bottom:1px dotted #ccc; '; $border_dotted_right = 'border-right:1px dotted #ccc; '; $kpi_lead = '<h3>' . ($kpi_status == 'o' ? 'Lead time of currently open orders/process (' . date('d.m.Y') . ')' : 'Lead time of orders with closing date from ' . date('d.m.Y', strtotime($kpi_closing_date_start)) . ' to ' . date('d.m.Y', strtotime($kpi_closing_date_end))) . '</h3>'; $kpi_lead .= '<table class="spo" cellspacing="0" cellpadding="0">'; $kpi_lead .= '<thead>'; $kpi_lead .= '<tr class="o">'; $kpi_lead .= '<th class="i" colspan="2" style="' . $border_dotted_bottom . $border_dotted_right . '">Running Lead Time / Lead Time</th>'; $kpi_lead .= '<th class="r" rowspan="2" style="' . $border_dotted_right . '">Target Lead Time<br/>in Days</th>'; $kpi_lead .= '<th class="d" rowspan="2" style="' . $border_dotted_right . '">Below Target</th>'; $kpi_lead .= '<th class="d" rowspan="2" style="' . $border_dotted_right . '">On Target</th>'; $kpi_lead .= '<th class="r" rowspan="2" style="' . $border_dotted_right . '">Above Target<br/>1 to 3 days</th>'; $kpi_lead .= '<th class="r" rowspan="2" style="' . $border_dotted_right . '">Above Target<br/>> 3 days</th>'; $kpi_lead .= '<th class="r" rowspan="2" style="' . $border_dotted_right . '">Total<br/>(based on Qty)</th>'; $kpi_lead .= '<th class="r" rowspan="2" style="' . $border_dotted_right . '">Lead Time<br/>Average in Days</th>'; $kpi_lead .= '<th class="r" rowspan="2">Lead Time<br/>Median in Days</th>'; $kpi_lead .= '</tr>'; $kpi_lead .= '<tr>'; $kpi_lead .= '<th style="' . $border_dotted_right . '">Category</th>'; $kpi_lead .= '<th style="' . $border_dotted_right . '">Order Type</th>'; $kpi_lead .= '</tr>'; $kpi_lead .= '</thead>'; $kpi_lead .= '<tbody>'; //Sourcing $kpi_lead .= '<tr class="e">'; $kpi_lead .= '<td><strong>Sourcing</strong></td>'; $kpi_lead .= '<td>Sourcing</td>'; $kpi_lead .= '<td class="tac"><input type="text" class="target_leadtime w040 tac" name="lt-sourcing" value="' . $target_leadtime['sourcing'] . '"' . $tooltip_info_saved . '/></td>'; $kpi_lead .= '<td class="tac">' . $below_target['sourcing'] . '<br/>' . kpiFormatPercentage($total['sourcing'], $below_target['sourcing']) . '</td>'; $kpi_lead .= '<td class="tac">' . $on_target['sourcing'] . '<br/>' . kpiFormatPercentage($total['sourcing'], $on_target['sourcing']) . '</td>'; $kpi_lead .= '<td class="tac">' . $above_target_1to3d['sourcing'] . '<br/>' . kpiFormatPercentage($total['sourcing'], $above_target_1to3d['sourcing']) . '</td>'; $kpi_lead .= '<td class="tac">' . $above_target_gt3d['sourcing'] . '<br/>' . kpiFormatPercentage($total['sourcing'], $above_target_gt3d['sourcing']) . '</td>'; $kpi_lead .= '<td class="tac">' . $total['sourcing'] . '<br/>' . kpiFormatPercentage($total['sourcing'], $total['sourcing']) . '</td>'; $kpi_lead .= '<td class="tac">' . (isset($leadtime_avg['sourcing']) ? $leadtime_avg['sourcing'] : 'N/A') . '</td>'; $kpi_lead .= '<td class="tac">' . (isset($leadtime_median['sourcing']) ? $leadtime_median['sourcing'] : 'N/A') . '</td>'; $kpi_lead .= '</tr>'; //Production $kpi_lead .= '<tr class="o">'; $kpi_lead .= '<td rowspan="3"><strong>Production</strong></td>'; $kpi_lead .= '<td>Depot Refill Orders</td>'; $kpi_lead .= '<td class="tac"><input type="text" class="target_leadtime w040 tac" name="lt-depot-refill-orders" value="' . $target_leadtime['depot-refill-orders'] . '"' . $tooltip_info_saved . '/></td>'; $kpi_lead .= '<td class="tac">' . $below_target['depot-refill-orders'] . '<br/>' . kpiFormatPercentage($total['depot-refill-orders'], $below_target['depot-refill-orders']) . '</td>'; $kpi_lead .= '<td class="tac">' . $on_target['depot-refill-orders'] . '<br/>' . kpiFormatPercentage($total['depot-refill-orders'], $on_target['depot-refill-orders']) . '</td>'; $kpi_lead .= '<td class="tac">' . $above_target_1to3d['depot-refill-orders'] . '<br/>' . kpiFormatPercentage($total['depot-refill-orders'], $above_target_1to3d['depot-refill-orders']) . '</td>'; $kpi_lead .= '<td class="tac">' . $above_target_gt3d['depot-refill-orders'] . '<br/>' . kpiFormatPercentage($total['depot-refill-orders'], $above_target_gt3d['depot-refill-orders']) . '</td>'; $kpi_lead .= '<td class="tac">' . $total['depot-refill-orders'] . '<br/>' . kpiFormatPercentage($total['depot-refill-orders'], $total['depot-refill-orders']) . '</td>'; $kpi_lead .= '<td class="tac">' . (isset($leadtime_avg['depot-refill-orders']) ? $leadtime_avg['depot-refill-orders'] : 'N/A') . '</td>'; $kpi_lead .= '<td class="tac">' . (isset($leadtime_median['depot-refill-orders']) ? $leadtime_median['depot-refill-orders'] : 'N/A') . '</td>'; $kpi_lead .= '</tr>'; $kpi_lead .= '<tr class="o">'; $kpi_lead .= '<td>Internal Levelling Orders</td>'; $kpi_lead .= '<td class="tac"><input type="text" class="target_leadtime w040 tac" name="lt-internal-levelling-orders" value="' . $target_leadtime['internal-levelling-orders'] . '"' . $tooltip_info_saved . '/></td>'; $kpi_lead .= '<td class="tac">' . $below_target['internal-levelling-orders'] . '<br/>' . kpiFormatPercentage($total['internal-levelling-orders'], $below_target['internal-levelling-orders']) . '</td>'; $kpi_lead .= '<td class="tac">' . $on_target['internal-levelling-orders'] . '<br/>' . kpiFormatPercentage($total['internal-levelling-orders'], $on_target['internal-levelling-orders']) . '</td>'; $kpi_lead .= '<td class="tac">' . $above_target_1to3d['internal-levelling-orders'] . '<br/>' . kpiFormatPercentage($total['internal-levelling-orders'], $above_target_1to3d['internal-levelling-orders']) . '</td>'; $kpi_lead .= '<td class="tac">' . $above_target_gt3d['internal-levelling-orders'] . '<br/>' . kpiFormatPercentage($total['internal-levelling-orders'], $above_target_gt3d['internal-levelling-orders']) . '</td>'; $kpi_lead .= '<td class="tac">' . $total['internal-levelling-orders'] . '<br/>' . kpiFormatPercentage($total['internal-levelling-orders'], $total['internal-levelling-orders']) . '</td>'; $kpi_lead .= '<td class="tac">' . (isset($leadtime_avg['internal-levelling-orders']) ? $leadtime_avg['internal-levelling-orders'] : 'N/A') . '</td>'; $kpi_lead .= '<td class="tac">' . (isset($leadtime_median['internal-levelling-orders']) ? $leadtime_median['internal-levelling-orders'] : 'N/A') . '</td>'; $kpi_lead .= '</tr>'; $kpi_lead .= '<tr class="o">'; $kpi_lead .= '<td>Customer Orders (MTO/MMO)</td>'; $kpi_lead .= '<td class="tac"><input type="text" class="target_leadtime w040 tac" name="lt-cust-order-mto-mmo" value="' . $target_leadtime['cust-order-mto-mmo'] . '"' . $tooltip_info_saved . '/></td>'; $kpi_lead .= '<td class="tac">' . $below_target['cust-order-mto-mmo'] . '<br/>' . kpiFormatPercentage($total['cust-order-mto-mmo'], $below_target['cust-order-mto-mmo']) . '</td>'; $kpi_lead .= '<td class="tac">' . $on_target['cust-order-mto-mmo'] . '<br/>' . kpiFormatPercentage($total['cust-order-mto-mmo'], $on_target['cust-order-mto-mmo']) . '</td>'; $kpi_lead .= '<td class="tac">' . $above_target_1to3d['cust-order-mto-mmo'] . '<br/>' . kpiFormatPercentage($total['cust-order-mto-mmo'], $above_target_1to3d['cust-order-mto-mmo']) . '</td>'; $kpi_lead .= '<td class="tac">' . $above_target_gt3d['cust-order-mto-mmo'] . '<br/>' . kpiFormatPercentage($total['cust-order-mto-mmo'], $above_target_gt3d['cust-order-mto-mmo']) . '</td>'; $kpi_lead .= '<td class="tac">' . $total['cust-order-mto-mmo'] . '<br/>' . kpiFormatPercentage($total['cust-order-mto-mmo'], $total['cust-order-mto-mmo']) . '</td>'; $kpi_lead .= '<td class="tac">' . (isset($leadtime_avg['cust-order-mto-mmo']) ? $leadtime_avg['cust-order-mto-mmo'] : 'N/A') . '</td>'; $kpi_lead .= '<td class="tac">' . (isset($leadtime_median['cust-order-mto-mmo']) ? $leadtime_median['cust-order-mto-mmo'] : 'N/A') . '</td>'; $kpi_lead .= '</tr>'; //Outsourcing $kpi_lead .= '<tr class="e">'; $kpi_lead .= '<td><strong>Outsourcing</strong></td>'; $kpi_lead .= '<td>External Levelling Orders</td>'; $kpi_lead .= '<td class="tac"><input type="text" class="target_leadtime w040 tac" name="lt-external-levelling-order" value="' . $target_leadtime['external-levelling-order'] . '"' . $tooltip_info_saved . '/></td>'; $kpi_lead .= '<td class="tac">' . $below_target['external-levelling-order'] . '<br/>' . kpiFormatPercentage($total['external-levelling-order'], $below_target['external-levelling-order']) . '</td>'; $kpi_lead .= '<td class="tac">' . $on_target['external-levelling-order'] . '<br/>' . kpiFormatPercentage($total['external-levelling-order'], $on_target['external-levelling-order']) . '</td>'; $kpi_lead .= '<td class="tac">' . $above_target_1to3d['external-levelling-order'] . '<br/>' . kpiFormatPercentage($total['external-levelling-order'], $above_target_1to3d['external-levelling-order']) . '</td>'; $kpi_lead .= '<td class="tac">' . $above_target_gt3d['external-levelling-order'] . '<br/>' . kpiFormatPercentage($total['external-levelling-order'], $above_target_gt3d['external-levelling-order']) . '</td>'; $kpi_lead .= '<td class="tac">' . $total['external-levelling-order'] . '<br/>' . kpiFormatPercentage($total['external-levelling-order'], $total['external-levelling-order']) . '</td>'; $kpi_lead .= '<td class="tac">' . (isset($leadtime_avg['external-levelling-order']) ? $leadtime_avg['external-levelling-order'] : 'N/A') . '</td>'; $kpi_lead .= '<td class="tac">' . (isset($leadtime_median['external-levelling-order']) ? $leadtime_median['external-levelling-order'] : 'N/A') . '</td>'; $kpi_lead .= '</tr>'; //Customer Order $kpi_lead .= '<tr class="o">'; $kpi_lead .= '<td rowspan="2"><strong>Customer Order</strong></td>'; $kpi_lead .= '<td>Full DSO</td>'; $kpi_lead .= '<td class="tac"><input type="text" class="target_leadtime w040 tac" name="lt-full-dso" value="' . $target_leadtime['full-dso'] . '"' . $tooltip_info_saved . '/></td>'; $kpi_lead .= '<td class="tac">' . $below_target['full-dso'] . '<br/>' . kpiFormatPercentage($total['full-dso'], $below_target['full-dso']) . '</td>'; $kpi_lead .= '<td class="tac">' . $on_target['full-dso'] . '<br/>' . kpiFormatPercentage($total['full-dso'], $on_target['full-dso']) . '</td>'; $kpi_lead .= '<td class="tac">' . $above_target_1to3d['full-dso'] . '<br/>' . kpiFormatPercentage($total['full-dso'], $above_target_1to3d['full-dso']) . '</td>'; $kpi_lead .= '<td class="tac">' . $above_target_gt3d['full-dso'] . '<br/>' . kpiFormatPercentage($total['full-dso'], $above_target_gt3d['full-dso']) . '</td>'; $kpi_lead .= '<td class="tac">' . $total['full-dso'] . '<br/>' . kpiFormatPercentage($total['full-dso'], $total['full-dso']) . '</td>'; $kpi_lead .= '<td class="tac">' . (isset($leadtime_avg['full-dso']) ? $leadtime_avg['full-dso'] : 'N/A') . '</td>'; $kpi_lead .= '<td class="tac">' . (isset($leadtime_median['full-dso']) ? $leadtime_median['full-dso'] : 'N/A') . '</td>'; $kpi_lead .= '</tr>'; $kpi_lead .= '<tr class="o">'; $kpi_lead .= '<td>MTO (Full MTO and Mixed Orders)</td>'; $kpi_lead .= '<td class="tac"><input type="text" class="target_leadtime w040 tac" name="lt-mto" value="' . $target_leadtime['mto'] . '"' . $tooltip_info_saved . '/></td>'; $kpi_lead .= '<td class="tac">' . $below_target['mto'] . '<br/>' . kpiFormatPercentage($total['mto'], $below_target['mto']) . '</td>'; $kpi_lead .= '<td class="tac">' . $on_target['mto'] . '<br/>' . kpiFormatPercentage($total['mto'], $on_target['mto']) . '</td>'; $kpi_lead .= '<td class="tac">' . $above_target_1to3d['mto'] . '<br/>' . kpiFormatPercentage($total['mto'], $above_target_1to3d['mto']) . '</td>'; $kpi_lead .= '<td class="tac">' . $above_target_gt3d['mto'] . '<br/>' . kpiFormatPercentage($total['mto'], $above_target_gt3d['mto']) . '</td>'; $kpi_lead .= '<td class="tac">' . $total['mto'] . '<br/>' . kpiFormatPercentage($total['mto'], $total['mto']) . '</td>'; $kpi_lead .= '<td class="tac">' . (isset($leadtime_avg['mto']) ? $leadtime_avg['mto'] : 'N/A') . '</td>'; $kpi_lead .= '<td class="tac">' . (isset($leadtime_median['mto']) ? $leadtime_median['mto'] : 'N/A') . '</td>'; $kpi_lead .= '</tr>'; //Design $kpi_lead .= '<tr class="e">'; $kpi_lead .= '<td rowspan="' . count($design_categories) . '"><strong>Design</strong></td>'; $des_cat_id_counter = 0; foreach ($design_categories as $des_cat_id => $des_cat_name) { $des_cat_id_counter++; if ($des_cat_id_counter > 1) { $kpi_lead .= '<tr class="e">'; } $design_order_type = "design-{$des_cat_id}"; $kpi_lead .= "<td>{$des_cat_name}</td>"; $kpi_lead .= '<td class="tac"><input type="text" class="target_leadtime w040 tac" name="lt-design-' . $des_cat_id . '" value="' . $target_leadtime[$design_order_type] . '"' . $tooltip_info_saved . '/></td>'; $kpi_lead .= '<td class="tac">' . $below_target[$design_order_type] . '<br/>' . kpiFormatPercentage($total[$design_order_type], $below_target[$design_order_type]) . '</td>'; $kpi_lead .= '<td class="tac">' . $on_target[$design_order_type] . '<br/>' . kpiFormatPercentage($total[$design_order_type], $on_target[$design_order_type]) . '</td>'; $kpi_lead .= '<td class="tac">' . $above_target_1to3d[$design_order_type] . '<br/>' . kpiFormatPercentage($total[$design_order_type], $above_target_1to3d[$design_order_type]) . '</td>'; $kpi_lead .= '<td class="tac">' . $above_target_gt3d[$design_order_type] . '<br/>' . kpiFormatPercentage($total[$design_order_type], $above_target_gt3d[$design_order_type]) . '</td>'; $kpi_lead .= '<td class="tac">' . $total[$design_order_type] . '<br/>' . kpiFormatPercentage($total[$design_order_type], $total[$design_order_type]) . '</td>'; $kpi_lead .= '<td class="tac">' . (isset($leadtime_avg[$design_order_type]) ? $leadtime_avg[$design_order_type] : 'N/A') . '</td>'; $kpi_lead .= '<td class="tac">' . (isset($leadtime_median[$design_order_type]) ? $leadtime_median[$design_order_type] : 'N/A') . '</td>'; $kpi_lead .= '</tr>'; } $kpi_lead .= '</tbody>'; $kpi_lead .= '</table>'; return $kpi_lead; }
<?php use_class('jng_sp'); $class_sp = new jng_sp(); $all_sp = $class_sp->retrieveList(); use_class('jng_sp_download'); $class_jd = new jng_sp_download(); use_class('jng_sp_orders'); $class_jo = new jng_sp_orders(); use_class('jng_sp_customers'); $class_jcust = new jng_sp_customers(); use_class('jng_sp_orders_xml'); $total_orders_created = 0; $daily_counter = array(); foreach ($all_sp as $sp_detail) { //initial setting $files_imported = 0; $orders_created = 0; $products_created = 0; $jng_sp_id = $sp_detail["jng_sp_id"]; $jng_sp_name = $sp_detail["name"]; $process_status = array('1' => 'D', '2' => 'R', '3' => 'R', '4' => 'R', '5' => 'R'); $xmlwithgpg = array('1'); if (array_key_exists($jng_sp_id, $process_status)) { $sp_detail = $class_sp->retrieveDetail($jng_sp_id); $jng_sp_id_with_no_external_xml_class = array('2', '4', '5'); if (!in_array($jng_sp_id, $jng_sp_id_with_no_external_xml_class)) { use_class('jng_sp_orders_xml_' . $jng_sp_id); } switch ($jng_sp_id) { case '1':
*/ global $db; require_once '../confy.php'; require_once '../functions.php'; require_once '../functions-2.php'; tep_db_connect(); use_class('logger'); $logger = new logger('cron', 'tradebyte-catalog-updater'); use_class('jng_sp'); use_class('jng_sp_catalog'); use_class('jng_sp_upload'); use_class('products_minierp'); use_class('products_articles'); use_class('tradebyte'); use_class('xml_tools'); $class_sp = new jng_sp(); $class_jc = new jng_sp_catalog(); $class_pm = new products_minierp(); function getANR($pcode, $length) { $a_nr = $pcode; if ($length > 0) { $a_nr .= '_' . textLength($length, false); } return $a_nr; } function getStock($stock, $stock_booked) { $stock = $stock - $stock_booked; if ($stock < 0) { $stock = 0;
use_class('depot_orders'); use_class('products_minierp'); use_class('products_articles'); use_class('minierp_customers'); use_class('products_ean'); use_class('jng_sp_orders'); use_class('jng_sp_customers'); use_class('jng_sp'); use_class('orders'); $class_do = new depot_orders(); $class_pm = new products_minierp(); $class_pa = new products_articles(); $class_mc = new minierp_customers(); $class_jo = new jng_sp_orders(); $class_jc = new jng_sp_customers(); $class_sp = new jng_sp(); $class_o = new orders(); $sp_list_raw = $class_sp->retrieveList(); $sp_list = array(); foreach ($sp_list_raw as $sp) { $sp_list[$sp['jng_sp_id']] = $sp; } function getTotalOrderAmount($type, $order_id, $currency = 'EUR') { $type = strtoupper($type); if ($type == 'J') { global $class_o; $orders_total = $class_o->retrieveTotals($order_id); $total_price = $orders_total['ot_total']['value']; } elseif ($type == 'S') { $q_total_price = "SELECT jo.shipping_costs+jo.cod_costs+SUM(joi.order_quantity * joi.price) total_price FROM jng_sp_orders jo";
$voucher_query .= " FROM coupon_redeem_track crt"; $voucher_query .= " INNER JOIN coupons c ON c.coupon_id=crt.coupon_id"; $voucher_query .= " INNER JOIN coupons_description cd ON cd.coupon_id=crt.coupon_id AND cd.language_id=" . LANGUAGEID; $voucher_query .= " WHERE crt.order_id={$order_id}"; $voucher_result = tep_db_query($voucher_query); $voucher_used = tep_db_num_rows($voucher_result); if ($voucher_used > 0) { while ($row = tep_db_fetch_array($voucher_result)) { $vouchers[] = $row; } } } } elseif ($source == Order::ORDER_TYPE_SALES_PARTNER) { use_class('jng_sp'); use_class('jng_sp_customers'); $class_sp = new jng_sp(); $class_jcust = new jng_sp_customers(); $order_object = new Order(Order::ORDER_TYPE_SALES_PARTNER, $order_id); $order = $class_jo->retrieveDetail($order_id); $sp_detail = $class_sp->retrieveDetail($order['jng_sp_id']); $customer = $class_jcust->retrieveDetail(null, $order['jng_sp_id'], $order['customer_billing_id']); if (is_null($customer)) { $customer_ids = $class_jcust->getFromOrder($order['jng_sp_orders_id']); $customer = $class_jcust->retrieveDetail($customer_ids['customer_billing_id']); } $order['amount_discount'] = 0; $order_int_comments = $class_jo->retrieveComments($order_id); $comments = $class_jo->drawComments($order_int_comments, 'Internal Comments', 'h2'); $items = $class_jo->retrieveItems($order_id); $items_colname_id = 'jng_sp_orders_items_id'; $items_colname_price = 'price';
<?php //*SPECIAL NOTE: THIS MODULE IS CALLED FROM PRODUCTS ANALYSIS use_class('jng_sp'); use_class('products_articles'); use_class('ReportCOGS'); $class_sp = new jng_sp(); $class_pa = new products_articles(); $total_periods = 10; $class_col_product = 'w150 tac'; $class_col_periods = 'w150 tac'; if (isset($_POST['me_action'])) { if ($_POST['me_action'] == 'LOADPRODUCT') { use_class('products_minierp'); $class_pm = new products_minierp(); $pid = tep_db_prepare_input($_POST['pid']); $rowclass = $_POST['rowclass']; $product = $class_pm->retrieveDetail($pid, 'p'); $product_image = webImage($product['p']['products_image'], IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1, 'Product ' . $pid, ''); $ajaxResult = array(); $ajaxResult['pid'] = $pid; $ajaxResult['image'] = $product_image; $ajaxResult['info'] = $pid; //$ajaxResult['info'] = $pid.' / '.$product['p']['products_model']; echo ajaxReturn($ajaxResult); exit; } elseif ($_POST['me_action'] == 'LOADPERIOD') { $spid = tep_db_prepare_input($_POST['spid']); $products = tep_db_prepare_input($_POST['products']); $period = tep_db_prepare_input($_POST['period']); $period_start_raw = tep_db_prepare_input($_POST['period_start']);
use_class('ProductAttribute'); use_class('design_draft'); use_class('products_minierp'); use_class('products_articles'); use_class('products_brand'); use_class('element'); use_class('jng_sp'); use_class('jng_sp_catalog'); use_service('color_pattern'); use_class('production_instruction_manual'); use_class('styles'); use_class('design'); $class_pm = new products_minierp(); $class_pa = new products_articles(); $class_pb = new products_brand(); $class_sp = new jng_sp(); $class_jc = new jng_sp_catalog(); $class_cp = new color_pattern(); $class_s = new styles(); $class_d = new design(); $default_SP = array('1', '2', '3'); $target_group['1'] = $NAV_TARGET_GROUP_NMDE; $target_group['2'] = $NAV_TARGET_GROUP_OTDE; $colpaterns = $class_cp->retrieveListGrid(SERVICECLIENTCODE, null, LANGUAGEID); $colpats = $colpaterns['Data']; function getDetailData($products_id, $type) { global $class_pm, $class_pa, $class_pb, $class_sp, $target_group, $colpats, $class_s; $result = array(); $detail_is_complete = false; $r_dt = '';
<?php die('ALREADY MOVED TO cron/orders-confiramtion.php'); //Process Easylog Export file before confirming delivery file_get_contents('http://manobo.de/cron/dhl-easylog-export-processor.php'); use_class('Order'); use_class('jng_sp'); use_class('jng_sp_upload'); use_class('jng_sp_orders'); $class_sp = new jng_sp(); $class_ju = new jng_sp_upload(); $class_jo = new jng_sp_orders(); $runinlocal = DB_SERVER == 'localhost'; $content = ''; $sp_detail = array(); $data = array(); if (isset($_GET['reconfirm']) && $_GET['reconfirm'] != '') { $is_reconfirm = true; $order_id = tep_db_prepare_input($_GET['reconfirm']); $data_rc = $class_jo->getReconfirmDelivery($order_id); $jng_sp_id = $data_rc['orders'][0]['jng_sp_id']; $sp_detail[$jng_sp_id] = $class_sp->retrieveDetail($jng_sp_id); $data[$jng_sp_id] = $data_rc; $jng_sp_name_array = array($jng_sp_id => $sp_detail[$jng_sp_id]['name']); } else { $is_reconfirm = false; $jng_sp_active = $class_sp->retrieveList("", "name"); $jng_sp_name_array = array(); foreach ($jng_sp_active as $temp_sp) { $jng_sp_id = $temp_sp['jng_sp_id']; $jng_sp_name_array[$jng_sp_id] = $temp_sp['name'];
private function renderFilter() { use_class('jng_sp'); use_class('products_brand'); use_class('CategoryTop'); $class_sp = new jng_sp(); $class_pb = new products_brand(); $sp_datas = $class_sp->retrieveList(); $brands = $class_pb->retrieveList("active_status='1'"); //FILTER Order Type $order_type_selected = self::getSession(self::FILTER_ORDER_TYPE); $order_types = array(self::ORDER_TYPE_ALL => 'All Orders', self::ORDER_TYPE_JG => 'JG Orders'); $order_type_groups['SP Orders'][self::ORDER_TYPE_SP] = 'All SP Orders'; foreach ($sp_datas as $sp_id => $sp_data) { $order_type_groups['SP Orders'][$sp_id] = $sp_data['name']; } $order_type_groups['Depot Orders'] = $this->DP_ORDER_TYPES; $filter_order_type = '<select name="' . self::FILTER_ORDER_TYPE . '" class="cbo_filters">' . loadComboListFromArray($order_types, null, $order_type_selected, true, $order_type_groups) . '</select>'; /* Filter SP now merged into Filter Order Type array_unshift($sp_datas, array(self::FILTER_SP_ID => '0', 'name' => 'All Sales Partners')); $filter_sp = $class_sp->drawCombo($sp_datas, $this->filters_sp_id, '', self::FILTER_SP_ID, 'cbo_filters'); */ //FILTER Brand $brand_options = array(); $brand_options[0] = 'Show All Brands'; foreach ($brands as $b) { $brand_options[$b['products_brand_id']] = $b['brand_name']; } $filter_brand = '<select name="' . self::FILTER_BRAND_ID . '" class="cbo_filters">' . loadComboListFromArray($brand_options, null, $this->filters_brand_id, false) . '</select>'; //FILTER Category $category_selected = self::getSession(self::FILTER_CAT_ID); $categories = array('' => 'Show All Categories'); $category_groups = array(); while ($ct = CategoryTop::getOneByOneAsObject()) { if ($ct->getCategoriesTotalCount() > 0) { while ($cat = $ct->getCategoriesOneByOneAsObject()) { if ($cat->getProductCodePrefix() != "") { $category_groups[$ct->name][$cat->id] = $cat->getName(1); } } } } $filter_category = '<select name="' . self::FILTER_CAT_ID . '" class="cbo_filters">' . loadComboListFromArray($categories, null, $category_selected, true, $category_groups) . '</select>'; /* $filter_category = comboProductsCategory( self::FILTER_CAT_ID , self::FILTER_CAT_ID , $this->filters_cat_id , 'cbo_filters' , '' , 'Show All Category'); */ //FILTER Product ID/EAN $filter_prod_search = '<input type="text" name="' . self::FILTER_LIST_EAN . '" class="txt_filters input" value="' . $this->filters_list_ean . '" />'; //FILTER Order No. $filter_orders_no = '<input type="text" name="' . self::FILTER_LIST_ORDERS_NO . '" class="txt_filters" value="' . $this->filters_list_orders_no . '" />'; //FILTER Lead Time Start Date $filter_leadtime = '<input name="' . self::FILTER_LEADTIME_START_DATE . '" class="date_picker" value="' . $this->filters_leadtime_date_start . '"/>' . ' to <input name="' . self::FILTER_LEADTIME_END_DATE . '" class="date_picker" value="' . $this->filters_leadtime_date_end . '"/>' . ' <input type="button" value="Go" class="btn_filters_leadtime_go" ' . 'title="Apply lead time start date filter" />' . ' <input type="button" value="Clear" class="date_range_clear" ' . 'title="Clear lead time start date filter" />'; $enter_info = '<span class="notice smallText" style="font-weight:normal;">' . '(press <em>Enter</em> to filter)</span>'; $result .= '<div style="margin-bottom:10px;">'; $result .= '<table border="0" cellpadding="0" cellspacing="0">'; $result .= '<tr>'; $result .= '<td class="bold">Order Type</td>'; //$result .= '<td class="bold">Sales Partner</td>'; $result .= '<td class="bold">Brand</td>'; $result .= '<td class="bold">Category</td>'; $result .= '<td class="bold">Product ID/EAN ' . $enter_info . '</td>'; $result .= '<td class="bold">Order No. ' . $enter_info . '</td>'; $result .= '<td class="bold">Lead Time Start Date</td>'; $result .= '</tr>'; $result .= '<tr>' . '<td>' . $filter_order_type . '</td>' . '<td>' . $filter_brand . '</td>' . '<td>' . $filter_category . '</td>' . '<td>' . $filter_prod_search . '</td>' . '<td>' . $filter_orders_no . '</td>' . '<td>' . $filter_leadtime . '</td>' . '</tr>'; $result .= '</table></div>'; return $result; }
<?php use_class('jng_sp'); $class_sp = new jng_sp(); use_class('jng_sp_customers_special'); $class_jcs = new jng_sp_customers_special(); use_class('jng_sp_customers'); $class_jcust = new jng_sp_customers(); $jng_sp_customers_id = isset($_GET['id']) ? tep_db_prepare_input($_GET['id']) : ''; if ($jng_sp_customers_id == '') { exit; } $detail = $class_jcs->getCustomerDetail($jng_sp_customers_id); if (is_null($detail)) { exit; } //AJAX ACTION if (isset($_POST['me_action'])) { if ($_POST['me_action'] == 'ADDNEWCOMMENT') { $customer_id = tep_db_prepare_input($_POST['customer_id']); $comment = tep_db_prepare_input(utf8_decode($_POST['comment'])); $comment = trim($comment); if ($comment != "") { $comment_by = $session_userinfo['username']; $comment_id = $class_jcs->insertComment($customer_id, $comment, $comment_by); // $comment = $class_jcs->retrieveCommentDetail($comment_id); // $comments = array($comment); // $result = $class_jcs->drawComments($comments, true); $result = drawSingleComment($comment_id, $comment_by, time(), $comment); echo utf8_encode($result); }
*/ global $db; require_once '../confy.php'; require_once '../functions.php'; require_once '../functions-2.php'; tep_db_connect(); session_start(); $session_userinfo = unserialize($_SESSION['user']); use_class('logger'); $logger = new logger('cron', 'daily-counter-cogs'); use_class('Product'); use_class('ReportCOGS'); use_class('SalesPartner'); use_class('jng_sp'); use_class('products_minierp'); $class_sp = new jng_sp(); $class_pm = new products_minierp(); //BEFORE DOING ANYTHING, FIRST WE NEED TO SET MATEXP AND COGS OF NEW ORDERS $timestamp_new_orders_checker = strtotime('-2 days'); $jg_counter = 0; $sp_counter = 0; $q = "SELECT * FROM ((" . " SELECT" . " 0 AS jng_sp_id," . " op.orders_products_id AS item_id," . " o.date_purchased AS order_date," . " op.products_id," . " op.products_model AS products_code," . " op.material_expenses AS item_matexp," . " op.cogs AS item_cogs," . " p.material_expenses" . " FROM orders o" . " INNER JOIN orders_products op ON op.orders_id = o.orders_id" . " LEFT JOIN products p ON p.products_id = op.products_id" . " WHERE (op.material_expenses = 0 OR op.cogs = 0)" . " AND op.orders_products_id > 0" . " AND p.material_expenses > 0" . ") UNION ALL (" . " SELECT" . " jo.jng_sp_id," . " joi.jng_sp_orders_items_id AS item_id," . " jo.order_date," . " joi.products_id," . " joi.article_number AS products_code," . " joi.material_expenses AS item_matexp," . " joi.cogs AS item_cogs," . " p.material_expenses" . " FROM jng_sp_orders jo" . " INNER JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_id = jo.jng_sp_orders_id" . " LEFT JOIN products p ON p.products_id = joi.products_id" . " WHERE (joi.material_expenses = 0 OR joi.cogs = 0)" . " AND joi.jng_sp_orders_items_id > 0" . " )) temp_table" . " ORDER BY item_id"; //" LIMIT 10000"; $r = tep_db_query($q); while ($row = tep_db_fetch_array($r)) { $order_date_timestamp = strtotime($row['order_date']); $p = new Product($row['products_id']); //By default we will always use the current material expense and cogs //it needs to be converted to local currency $matexp = convertCurrency($row['material_expenses'], CURRENCY_CODE_EURO, CURRENCY_DEFAULT); $cogs = $p->getProductCOGSValue();
<?php //ini_set('display_errors',1); error_reporting(E_ALL); use_class('logger'); use_class('jng_sp'); use_class('jng_sp_download'); use_class('jng_sp_catalog'); use_class('jng_sp_preorders'); use_class('jng_sp_orders'); use_class('jng_sp_customers'); use_class('products_minierp'); use_class('products_ean'); $class_sp = new jng_sp(); $class_jd = new jng_sp_download(); $class_jc = new jng_sp_catalog(); $class_jo = new jng_sp_orders(); $class_jcust = new jng_sp_customers(); $class_pm = new products_minierp(); $class_ean = new products_ean(); //settings for amazon stock file $amvd_report_type = array(); $amvd_report_type[] = 'Week-to-Date'; $amvd_report_type[] = 'Yesterday'; $amvd_report_type[] = 'Last Week'; $amvd_report_type[] = 'Month-to-Date'; $amvd_report_type[] = 'Last Month'; $amvd_report_type[] = 'Quarter-to-Date'; $amvd_report_type[] = 'Year-to-Date'; $amvd_report_type[] = 'Last 12 Months'; $default_sp_id = '5'; $download_status_to_generate = 'R';
<?php if (!class_exists('jng_sp')) { use_class('jng_sp'); $class_sp = new jng_sp(); use_class('jng_sp_catalog'); $class_jc = new jng_sp_catalog(); use_class('products_brand'); $class_pb = new products_brand(); $jng_sp_id = tep_db_prepare_input($_GET['sp']); $products_id = tep_db_prepare_input($_GET['id']); $sp_info = $class_sp->retrieveDetail($jng_sp_id); $catalog = $class_jc->retrieveDetail(null, $jng_sp_id, $products_id); $title = "Total VC Prediction"; } $SCENARIO_STEP_MARGIN = 3; $SCENARIO_STEP_PRICE = 5; $SCENARIO_STEP_RETURN_RATE = 10; $cat_query = "SELECT p.products_image"; $cat_query .= ", MAX(jo.order_date) AS latest_date"; $cat_query .= ", IFNULL(AVG(joi.price), 0) AS selling_price"; $cat_query .= ", IFNULL(SUM(joi.order_quantity),0) AS total_sold"; $cat_query .= ", IFNULL(SUM(joi.return_quantity),0) AS total_returns"; $cat_query .= ", IFNULL(SUM(joi.order_quantity-joi.return_quantity),0) AS total_net_sold"; $cat_query .= ", IFNULL(SUM((joi.order_quantity-joi.return_quantity)*joi.net_sales),0) AS total_net_sales"; $cat_query .= ", IFNULL(AVG(joi.net_sales),0) AS average_net_sales"; $cat_query .= ", IFNULL(SUM((joi.order_quantity-joi.return_quantity)*joi.material_expenses),0) AS total_material_expenses"; $cat_query .= ", IFNULL(AVG(joi.material_expenses),0) AS average_material_expenses"; $cat_query .= ", IFNULL(SUM(joi.order_quantity*joi.cost_logistic),0) AS total_cost_logistic"; $cat_query .= ", IFNULL(AVG(joi.cost_logistic),0) AS average_cost_logistic"; $cat_query .= ", IFNULL(SUM(joi.order_quantity*joi.cost_distribution),0) AS total_cost_distribution";
<?php use_class('Product'); use_class('ReportCOGS'); use_class('depot_orders'); use_class('jng_sp'); use_class('jng_sp_orders'); use_class('orders'); $class_sp = new jng_sp(); $class_jo = new jng_sp_orders(); $class_o = new orders(); $class_do = new depot_orders(); if (isset($_GET['week-sum-b2c']) && $_GET['week-sum-b2c'] != '') { if ($_GET['week-sum-b2c'] == 'PREPAYMENT') { //date setup $sp_with_prepayment = array('0', '2', '8'); $sp_filter = implode(',', $sp_with_prepayment); $sp_list = $class_sp->retrieveList("jng_sp_id IN ({$sp_filter})"); $lookback_start = '-14 days'; $weekly_days = 7; $date_start = date('Y-m-d', strtotime($lookback_start)); $dates = array(); $datas = array(); for ($d = 0; $d < $weekly_days; $d++) { $date_ts = strtotime($date_start . " -{$d} days"); $date_display = date('d-M-y', $date_ts); $date_filter = date('Y-m-d', $date_ts); $dates[$date_filter] = $date_display; $datas[$date_filter] = array(); foreach ($sp_with_prepayment as $spid) { $datas[$date_filter][$spid] = array();
* @author IT TEAM BONOFACTUM * @created Jun 10, 2013 10:00:44 AM */ global $db; require_once '../confy.php'; require_once '../functions.php'; require_once '../functions-2.php'; tep_db_connect(); use_class('logger'); $logger = new logger('cron', 'tradebyte-message-sender'); use_class('jng_sp'); use_class('jng_sp_orders'); use_class('tradebyte'); use_class('xml_tools'); $class_jo = new jng_sp_orders(); $class_sp = new jng_sp(); $message_id_counter = 0; $message_id_prefix = date('ymdHis'); function constructMessage(&$xmlt, $msg_data, $type, $xml_messages_list) { global $message_id_prefix, $message_id_counter; $message_id_counter++; $timestamp = time(); $date_created = tradebyte::getDateFormat($timestamp); $xml_message = $xmlt->drawTag($xml_messages_list, 'MESSAGE'); $xmlt->drawTag($xml_message, 'MESSAGE_ID', $message_id_prefix . $message_id_counter); $xmlt->drawTag($xml_message, 'MESSAGE_TYPE', tradebyte::getMessageType($type)); $xmlt->drawTag($xml_message, 'TB_ORDER_ID', $msg_data['tb_order_id']); $xmlt->drawTag($xml_message, 'TB_ORDER_ITEM_ID', $msg_data['tb_order_item_id']); $xmlt->drawTag($xml_message, 'SKU', $msg_data['sku']); $xmlt->drawTag($xml_message, 'CHANNEL_SIGN', $msg_data['channel']);
$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; echo $return_label; break; } break; case 'sp': use_class('jng_sp_orders'); $o_jngspo = new jng_sp_orders(); $oi = $o_jngspo->retrieveItemDetail($reqid); #header("Content-Type: text/plain; charset=utf-8"); switch ($barcodetype) { case 'code39': use_class('jng_sp'); $o_jngsp = new jng_sp(); #table jng_sp_orders_items $oi_o_id = $oi["jng_sp_orders_id"]; $oi_order_qty = $oi["order_qty"]; $oi_article_number = $oi["article_number"]; $oi_order_item_count = $oi["order_item_count"]; $oi_order_item_total = $oi["order_item_total"]; #table jng_sp_orders $o = $o_jngspo->retrieveDetail($oi_o_id); $o_order_no = $o["order_id"]; $o_order_date = strtotime($o["order_date"]); $day = date("d", $o_order_date); $month = date("M", $o_order_date); $o_daily_count = $o["daily_count"]; $o_shipment_id = $o["shipment_id"]; $o_cust_fname = $o["customer_shipping_firstname"];
$content .= '<div id="production" class="draw-table" style="clear:both;padding-top:20px;">'; $content .= ' <div style="float:left;">'; $content .= ' <h2>Antitarnish Liquid Usage</h2>'; $content .= ' <table border="0" cellpadding="0" cellspacing="0">'; $content .= ' <tr><th style="width:150px;">Configuration</th><th colspan="2" style="width:150px;">Value</th></tr>'; $content .= ' <tr class="o"><td>Silver Usage</td><td>' . $input72 . '</td><td>gram</td></tr>'; $content .= ' <tr class="e"><td>Antitarnish Usage</td><td>' . $input73 . '</td><td>liter</td></tr>'; $content .= ' </table>'; $content .= ' </div>'; $content .= '</div>'; //#production .draw-table // //Production Instruction Settings Form use_class('jng_sp'); use_class('products_brand'); $class_sp = new jng_sp(); $class_pb = new products_brand(); $sps = $class_sp->retrieveList(); $brands = $class_pb->retrieveList('active_status=1'); $content .= '<div id="production-instruction" class="draw-table" style="clear:both;padding-top:20px;">'; $content .= ' <div style="float:left;">'; $content .= ' <h2>Production Instruction (PI) Using Red Paper</h2>'; $content .= ' <table border="0" cellpadding="0" cellspacing="0">'; $content .= ' <tr><th style="width:150px;">Configuration</th><th style="width:550px;">Value</th></tr>'; $content .= ' <tr class="o"><td>Sales Partner</td><td>'; $checked = in_array('0', $sp_using_red_paper) ? 'checked="checked"' : ''; $cbid = 'set-pi-red-sp-0'; $content .= '<div class="float-left w080 tal" style="margin:2px 0;"><input type="checkbox" id="' . $cbid . '" name="' . $cbid . '" value="0" ' . $checked . '/><label for="' . $cbid . '"> JG.DE</label></div>'; foreach ($sps as $sp_id => $dt) { $cbid = 'set-pi-red-sp-' . $sp_id; $checked = in_array($sp_id, $sp_using_red_paper) ? 'checked="checked"' : '';
require_once '../functions-2.php'; require_once '../functions-xml.php'; tep_db_connect(); use_class('logger'); $logger = new logger('cron', 'sp-2-orders-confirmer'); $timestamp = date('Y-m-d H:i:s'); $RUNTIME = array('10', '40'); //Cron will be processed only on minute $RUNTIME //10 and 40 because we download new orders every 00 and 30 //so in minutes 10 and 40 we will confirm the orders if (in_array(date('i'), $RUNTIME)) { use_class('jng_sp'); use_class('jng_sp_upload'); use_class('jng_sp_orders'); use_class('products_ean'); $class_sp = new jng_sp(); $class_ju = new jng_sp_upload(); $class_jo = new jng_sp_orders(); $class_ean = new products_ean(); $jng_sp_active = $class_sp->retrieveList("active_status=1"); $logger->write("Task 1 (CHECK UNCONFIRMED ORDERS) - Start"); foreach ($jng_sp_active as $temp_sp) { $jng_sp_id = $temp_sp['jng_sp_id']; $jng_sp_name = $temp_sp['name']; $orders = $class_jo->getUnconfirmedOrders($jng_sp_id); if (count($orders) == 0) { $logger->write("There is no new order to confirm"); } else { switch ($jng_sp_id) { case '2': $need_jms_upload = false;
tep_db_connect(); use_class('logger'); $logger = new logger('cron', 'tradebyte-orders-downloader'); use_class('Order'); use_class('tradebyte'); use_class('xml_tools'); use_class('products_ean'); use_class('jng_sp'); use_class('jng_sp_download'); use_class('jng_sp_orders'); use_class('jng_sp_customers'); use_class('logger'); $tb = new tradebyte(); $xmlt = new xml_tools(); $class_ean = new products_ean(); $class_sp = new jng_sp(); $class_jd = new jng_sp_download(); $class_jo = new jng_sp_orders(); $class_jcust = new jng_sp_customers(); $zade_prepayment_need_refreshed = false; function logThis($logdata) { global $logger; $logger->write($logdata); echo "{$logdata}<br />\n"; } ///////////////////////////// // STEP 1: DOWNLOAD ORDERS // ///////////////////////////// logThis('STEP 1: DOWNLOAD ORDERS'); //$tb->connect('NONSSL');
$item_trans = array(); $order_trans = array(); if ($item['trans_type'] == 'SP') { $item_trans = $class_jo->retrieveItemDetail($item['trans_id']); $order_trans = $class_jo->retrieveDetail($item_trans['jng_sp_orders_id']); } elseif ($item['trans_type'] == 'JG') { $item_trans = $class_o->retrieveProductDetail($item['trans_id']); $order_trans = $class_o->retrieveDetail($item_trans['orders_id']); } if (count($item_trans) > 0 && $item_trans['status'] == '8' && $item_trans['stock_status'] != 'D') { $sp_name = 'Missing MO'; $sp_class = 'blue'; $sp_id = $order_trans['jng_sp_id']; if (in_array($sp_id, $order_show_sp_info)) { use_class('jng_sp'); $class_sp = new jng_sp(); $sp = $class_sp->retrieveDetail($sp_id); $sp_name = $sp['package_prefix']; } } elseif ($is_outsourced) { $sp_name = 'Outsourcing'; $info = '<h3 style="margin:20px 0 0 0;">Bag/Label must have text</h3><h2>DP-' . $id . '<br />Quantity: ' . $item['quantity'] . 'x</h2>'; } elseif ($item['group_name'] != '') { //$sp_name .= ' Manual'; $sp_name .= ' ' . strtoupper($segment['location']); $info = '<h3 style="margin:20px 0 0 0;">Please group with Label</h3><h2>"' . $item['group_name'] . '"</h2>'; } $result .= printPackageTip('P', $box_date, $info, $sp_name, $sp_class); if ($is_outsourced) { saveIDforPrintingOrderLabel($id_raw); $result .= '<input type="hidden" id="print_order_id" value="' . $id_raw . '" />';
<?php use_class('jng_sp'); $class_sp = new jng_sp(); //SP SETTING $jng_sp_id = '2'; $sp_detail = $class_sp->retrieveDetail($jng_sp_id); $commission_excl_tax = round($sp_detail['provision_rate'] * (1 + VAT), 2); $currency = 'EUR'; $session_page = 'otto-commissions'; $year_now = date('Y'); $month_prev = date('m', strtotime("-1 month")); if (isset($_POST['year']) && $_POST['year'] != '') { $year = tep_db_prepare_input($_POST['year']); } elseif (isset($_SESSION[$session_page]['year-period']) && $_SESSION[$session_page]['year-period'] != '') { $year = $_SESSION[$session_page]['year-period']; } else { $year = $year_now; } if (isset($_POST['month']) && $_POST['month'] != '') { $month = tep_db_prepare_input($_POST['month']); } elseif (isset($_SESSION[$session_page]['month-period']) && $_SESSION[$session_page]['month-period'] != '') { $month = $_SESSION[$session_page]['month-period']; } else { $month = $month_prev; } $_SESSION[$session_page]['year-period'] = $year; $_SESSION[$session_page]['month-period'] = $month; $year_options = array(); $month_options = array(); for ($y = 2010; $y <= $year_now; $y++) {
public static function retrieveDailyAverageSoldExcludingPromotionOrdersQuery($date_start, $total_days_to_lookback, $pid_aid_filter = '') { use_class('jng_sp'); $class_sp = new jng_sp(); $sp_list = $class_sp->retrieveList('use_in_forecast=1'); $sp_filter = implode(',', array_keys($sp_list)); //WE MUST REDUCE 1 DAY BECAUSE "date - X days" when both days are //considered will give (X+1) total days instead. $total_days_to_lookback_calc = $total_days_to_lookback - 1; //start and end is reversed because we're looking backward $date_start_query = date('Y-m-d', strtotime($date_start)); $date_end_query = date('Y-m-d', strtotime("{$date_start_query} -{$total_days_to_lookback_calc} days")); $q = "SELECT products_id, articles_id, SUM(total_sold) AS total_sold FROM ("; //SP Query $q .= " SELECT joi.products_id, joi.products_articles_id AS articles_id, SUM(joi.order_quantity) AS total_sold"; $q .= " FROM jng_sp_orders jo"; $q .= " INNER JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_id=jo.jng_sp_orders_id AND joi.status NOT IN (10,12)"; $q .= " WHERE jo.jng_sp_id IN ({$sp_filter})"; $q .= " AND joi.shipping_window_open<='{$date_start_query}' AND joi.shipping_window_open>='{$date_end_query}'"; if ($pid_aid_filter != '') { $q .= " AND {$pid_aid_filter}"; } $q .= " AND NOT " . isPromotionalOrderQuery('SP'); $q .= " GROUP BY products_id, articles_id"; $q .= " UNION ALL "; //JG Query $date_start_query .= ' 23:59:59'; $date_end_query .= ' 00:00:00'; $q .= " SELECT op.products_id, op.products_articles_id AS articles_id, SUM(op.products_quantity) AS total_sold"; $q .= " FROM orders o"; $q .= " INNER JOIN orders_products op ON op.orders_id=o.orders_id AND op.status NOT IN (10,12)"; $q .= " WHERE o.date_purchased<='{$date_start_query}' AND o.date_purchased>='{$date_end_query}'"; if ($pid_aid_filter != '') { $q .= " AND {$pid_aid_filter}"; } $q .= " AND NOT " . isPromotionalOrderQuery('JG'); $q .= " GROUP BY products_id, articles_id"; $q .= ") temp_table"; $q .= " GROUP BY products_id, articles_id"; $q .= " ORDER BY products_id, articles_id"; $r = tep_db_query($q); $result = array(); while ($row = tep_db_fetch_array($r)) { $row['daily_average'] = round($row['total_sold'] / $total_days_to_lookback, 2); $result[] = $row; } return $result; }
* @created Mar 25, 2013 3:14:41 PM */ set_time_limit(0); global $db; require_once '../confy.php'; require_once '../functions.php'; require_once '../functions-2.php'; require_once DIR_WS_FUNCTIONS . 'html_output.php'; require_once DIR_WS_CLASSES . 'fpdf.php'; tep_db_connect(); define('FPDF_IMGPATH', DIR_WS_IMAGES . 'pdf/'); define('FPDF_FONTPATH', FPDF_IMGPATH . 'fonts/'); use_class('logger'); $logger = new logger('print', 'sales-report-weekly-products'); use_class('jng_sp'); $class_sp = new jng_sp(); $sp_list = $class_sp->retrieveList(); $pid = !empty($_POST['pid']) ? $_POST['pid'] : ''; $filter_date = !empty($_POST['filter_date']) ? $_POST['filter_date'] : date('Y-m-d h:i:s'); $filename = !empty($_POST['filename']) ? $_POST['filename'] : 'sales-report-weekly-products-'; $filename = $filename . date('YmdHi', strtotime($filter_date)) . '.pdf'; $logger->write('Filter Date: ' . $filter_date); class PDF extends FPDF { var $margin = 10; //Create image stars function drawStar($stars_amount, $xpos, $ypos, $stars_max = 3, $width = 5, $height = 5) { $uri = @$_SERVER["HTTPS"] == "on" ? "https://" : "http://"; $uri .= "manobo.de/images/"; $stars = '';
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; }
/** * Get SP data which using amazon logistic * @return Array Array of SP data */ function getSalesPartnerUseAmazonLogistic() { use_class('jng_sp'); $class_sp = new jng_sp(); $sps = $class_sp->retrieveList("use_amvd_logistic=1"); return $sps; }
<?php use_class('SalesPartner'); use_class('jng_sp'); $class_sp = new jng_sp(); //Redirect to SP List if no ID is to open if (isset($_GET['id']) && $_GET['id'] != '') { $salespartner_id = tep_db_prepare_input($_GET['id']); } else { header('Location: ?open=sp-list'); exit; } $obj_sp = new SalesPartner($salespartner_id); //SUBMIT ACTION if (isset($_POST['me_action'])) { if ($_POST['me_action'] == 'AMVDSAVECONFIG') { $config = array(); $config['stock-status-ds'] = '+' . intval($_POST['ssds']) . ' days'; $config['stock-status-okfg'] = '+' . intval($_POST['ssokfg']) . ' days'; $config['stock-status-ns'] = '+' . intval($_POST['ssns']) . ' days'; save_config('amazon-vd-settings', $config); } elseif ($_POST['me_action'] == 'SALESPARTNERDELETE') { /* $exist_query = tep_db_query("SELECT jng_sp_id FROM jng_sp WHERE jng_sp_id=$salespartner_id"); if(tep_db_num_rows($exist_query)>0) { $check1_query = tep_db_query("SELECT * FROM minierp_groups_credentials WHERE salespartners_id=$salespartner_id"); $check1 = (tep_db_num_rows($check1_query)==0); if($check1) { tep_db_query("DELETE FROM jng_sp WHERE jng_sp_id=$salespartner_id"); $messagebox->add("Module ID: <strong>$salespartner_id</strong> is successfully deleted."); $salespartner_id = 'new';