Ejemplo n.º 1
0
                     $total_products_weekly = array_sum($total_products);
                     $result .= '<tr class="t"><td class="d">TOTAL</td>';
                     foreach($weekly as $type=>$value) {
                         $percent = ($total_products_weekly>0) ? $value/$total_products_weekly*100 : 0;
                         $percent_text = '<br /><small class="notice">'.number_format($percent, 1).'%</small>';
                         $colspan = ($type=='MO') ? ' colspan="2"' : '';
                         $result .= '<td class="q"'.$colspan.'>'.strval($value).$percent_text.'</td>';
                     }
                     $result .= '<td class="q bold">'.strval($total_products_weekly).'</td>';
                     $result .= '</tr>';
                 }
                 $result .= '</table></div>';
                 $result .= '</div>';
                 */
 //MTO PER STARS PER DAY COUNTER
 $MTOkey = modeKey('MTO') . ',' . modeKey('MMO');
 $q = "SELECT order_date, stars, SUM(total_quantity) AS total_quantity FROM ((";
 $q .= "SELECT DATE(jo.order_date) AS order_date, joi.products_stars AS stars, joi.order_quantity AS total_quantity";
 $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) AND joi.mode IN ({$MTOkey})";
 $q .= " WHERE jo.order_date>='{$filterdate_start}' AND jo.order_date<='{$filterdate_end}'";
 $q .= ") UNION ALL (";
 $q .= "SELECT DATE(o.date_purchased) AS order_date, op.products_stars AS stars, op.products_quantity AS total_quantity";
 $q .= " FROM orders o";
 $q .= " INNER JOIN orders_products op ON op.orders_id=o.orders_id AND op.status NOT IN (10,12) AND op.mode IN ({$MTOkey})";
 $q .= " WHERE o.date_purchased>='{$filterdate_start}' AND o.date_purchased<='{$filterdate_end}'";
 $q .= ")) orders_mto GROUP BY order_date, stars";
 $q .= " ORDER BY order_date DESC, stars DESC";
 //if($session_userinfo['id']=='1') $result .= '<div>'.$q.'</div>';
 $r = tep_db_query($q);
 $mto_stars = array();
 } else {
     if ($i['status'] > 8) {
         $total_products_sent++;
     }
 }
 $product = $class_pm->retrieveDetail($i['products_id'], 'p,pnc');
 $article = $i['products_articles_id'] > 0 ? $class_pa->retrieveDetail($i['products_articles_id']) : null;
 $ordered_qty = intval($i[$items_colname_qty]);
 if ($i['status'] == 8) {
     if ($i['stock_status'] == 'D') {
         $total_products_depot_ready++;
         if ($i['print_count'] == '1') {
             $total_products_depot_ready_printed++;
         }
     }
     if ($i['mode'] == modeKey('MMO')) {
         $do = $class_do->retrieveDetailTransmigran($source, $i[$items_colname_id]);
         if ($i['stock_status'] != 'D' || $i['stock_status'] == 'D' && $do['status'] == 8) {
             $i['status'] = $do['status'];
             $i['status_date'] = $do['status_date'];
         }
     }
 }
 if ($i['status'] <= $worst_status) {
     $worst_status = $i['status'];
     $ws_timestamp = strtotime($i['status_date']);
     if ($ws_timestamp > $worst_status_date) {
         $worst_status_date = $ws_timestamp;
     }
 }
 foreach ($header as $hkey => $h) {
         $oi_trans = $class_do->retrieveDetailTransmigran($order_type, $oiid);
     }
     //CANCEL MMO IF NOT YET IN PRODUCTION
     if (!is_null($oi_trans) && $oi_trans['status'] < 4) {
         $class_do->doCancelOrders($oi_trans['depot_orders_id'], $oi_trans['status'], 'auto-set');
     }
     //REQUEST DEPOT REFILL IF ORDER WAS NOT YET IN PRODUCTION
     if (is_null($oi_trans) && $oi['status'] < 4 || !is_null($oi_trans) && $oi_trans['status'] < 4) {
         $refill_type = depot_orders::AUTO_REFILL_ID_DSO;
         $refill_qty_request = $order_qty;
     }
     //Orders with DS Prioritized should keep their "mode"
     if ($oi['ds_prioritized'] == '1') {
         if ($oi['mode'] == modeKey('MMO')) {
             $items_mmo[] = $oiid;
         } elseif ($oi['mode'] == modeKey('MTO')) {
             $items_mto[] = $oiid;
         }
     } else {
         if (is_null($oi_trans) || $oi_trans['status'] < 7) {
             $items_dso[] = $oiid;
         } else {
             $items_mmo[] = $oiid;
         }
     }
 }
 /* WE MOVE THIS PROCESS TO DAILY CRON depot-refill.php
    //PROCESS DEPOT REFILL REQUEST
    //Dont create refill order if we're having backlog issue in production
    //But 3 stars products will ignore this rule and always create refill order
    //if(($oi['stars']==3 || $refill_requirement) && !is_null($refill_type) && !is_null($refill_qty_request)) {
Ejemplo n.º 4
0
 function updateOrderItemMode($opids, $mode)
 {
     if (is_array($opids)) {
         $opids = implode(',', $opids);
     }
     if ($opids != '') {
         $mode = in_array($mode, modeName()) ? modeKey($mode) : 0;
         $sda = array('mode' => $mode);
         tep_db_perform('orders_products', $sda, 'update', "orders_products_id IN ({$opids})");
     }
 }