//check if product is not yet moved to Depot/Mixed
         if ($oi['status'] != '8') {
             //set order as DSO and move items to Depot/Mixed
             $items_dso[] = $oiid;
             if ($order_type == 'SP') {
                 $class_jo->updateItemStatus($oiid, '8', 'auto-set');
             } elseif ($order_type == 'JG') {
                 $class_o->updateProductStatus($oiid, '8', 'auto-set');
             }
         }
     }
 } else {
     if ($class_pm->productIsKilled($oi['products_id'])) {
         //Auto Cancel Order for Killed Products<
         if ($order_type == 'SP') {
             $class_jo->doCancelOrders($oiid, $oi['status'], $session_userinfo['username']);
         } elseif ($order_type == 'JG') {
             $class_o->doCancelOrders($oiid, $oi['status'], $session_userinfo['username']);
         }
         $items_auto_canceled[] = $order_type . '-' . $oiid;
         //RELEASE ITEM FROM ORDER
         unset($items[$oiid]);
         $orders_total[$order_key]--;
     }
     if ($oi['order_item_total'] == 1 && !$order_must_wait_in_depot_tab) {
         //SET AS MTO IF SINGLE PRODUCT ORDER
         $items_mto[] = $oiid;
         if ($order_type == 'SP') {
             $class_jo->updateItemStatus($oiid, '1', 'auto-set');
         } elseif ($order_type == 'JG') {
             $class_o->updateProductStatus($oiid, '1', 'auto-set');
             //FAIL TO IMPORT ORDER, Notify IT Team
             //TODO: CHECK IF IT'S ONLY A DUPLICATE ORDER BEING RESENT,
             //WHEN YES SHOULD IGNORE SENDING THE FAIL NOTIFICATION
             logThis('  = Failed to import new order: ' . $o['order_id']);
             $subject = 'IMPORTANT & URGENT:  Import Order from Tradebyte Failed';
             $send_message = 'Manobo FAILED TO IMPORT ORDER from Tradebyte in this xml file: ';
             $send_message .= '<br />' . $xml_filename;
             $send_message .= '<br /><br />Please check root cause and make sure new orders are imported!';
             tep_mail(EMAIL_NAME_DEBUGR, EMAIL_ADDRESS_DEBUGR, $subject, $send_message, FROM_EMAIL_NAME, FROM_EMAIL_ADDRESS, false);
         }
     }
     //CHECK IF ORDER IS ALREADY CANCELED IN TBONE
     $items_canceled = array();
     if ($tb_confirmed_void && $orders_id > 0 && count($items_ids) > 0) {
         foreach ($items_ids as $item_id) {
             $class_jo->doCancelOrders($item_id, '1', 'auto-set');
             $items_canceled[] = $item_id;
         }
         logThis("  = Auto cancel order");
         $orders_canceled[] = $orders_id;
     }
     //Set auto cancel items as confirmed
     if (count($items_canceled) > 0) {
         $class_jo->confirmOrderDelivery($items_canceled);
         logThis("  = Auto confirm canceled orders");
     }
 }
 $files_imported++;
 $done_filename = TRADEBYTE_ARCHIVE_ORDERS_PATH . $o_file['filename'];
 //SET AS FILES IMPORTED AND MOVE IT TO archive
 $class_jd->updateDownloadImported($o_file['jng_sp_download_id']);
 $date_filter = tep_db_prepare_input($_POST['date_filter']);
 $link_id = tep_db_prepare_input($_POST['link_id']);
 list($prefix, $products_ean) = explode('-', $link_id);
 $logger->write("Canceling SPID {$jng_sp_id} - Date {$date_filter}  - EAN {$products_ean}");
 $total_canceled = 0;
 $q = "SELECT joi.jng_sp_orders_items_id, joi.order_quantity, joi.status";
 $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";
 $q .= " WHERE jo.jng_sp_id={$jng_sp_id} AND jo.order_date LIKE '{$date_filter}%' AND jo.confirm_status='0'";
 $q .= " AND joi.products_ean='{$products_ean}'";
 $q .= " AND joi.status NOT IN (10,12)";
 $r = tep_db_query($q);
 while ($row = tep_db_fetch_array($r)) {
     $total_canceled += $row['order_quantity'];
     $logger->write('SP-' . $row['jng_sp_orders_items_id']);
     $class_jo->doCancelOrders($row['jng_sp_orders_items_id'], $row['status'], $session_userinfo['name']);
     //echo "Simulating cancel SP-$row[jng_sp_orders_items_id] with status ".statusName($row['status']).'<br />';
 }
 /*
 foreach($_POST['ean_list'] as $ean) $logger->write($ean);
 $q  = "SELECT joi.jng_sp_orders_items_id, joi.order_quantity, joi.status";
 $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";
 $q .= " WHERE jo.jng_sp_id=$jng_sp_id AND jo.order_date LIKE '$date_filter%' AND jo.confirm_status='0'";
 $q .= " AND joi.products_ean IN ('$products_ean')";
 $q .= " AND joi.status NOT IN (10,12)";
 $r = tep_db_query($q);
 while($row=tep_db_fetch_array($r)) {
     $total_canceled += $row['order_quantity'];
     $logger->write('SP-'.$row['jng_sp_orders_items_id']);
     $class_jo->doCancelOrders($row['jng_sp_orders_items_id'], $row['status'], $session_userinfo['name']);
 $sop_mouse_over['payone_link'] = 'Click here to open payone search page ' . 'directly. If payone requested login, please submit your login data, ' . 'close the popup and click this link again';
 $sop_mouse_over['status_history'] = 'Click here to view status change chronology.';
 $sop_mouse_over['invoice_download'] = 'Click here to download invoice as PDF.';
 $sop_mouse_over['pi_download'] = 'Click here to redownload Production ' . 'Instruction, please notice that print counter will be increased on ' . 'each download';
 $sop_mouse_over['shipping_cost'] = 'Free shipping for J&G orders from ' . '30,00 EUR / Customer of OTTO always pay shipping costs';
 $sop_mouse_over['voucher_cancel'] = 'This is the amount we have to ' . 'cancel from the discount because of returns. This works only if a ' . 'connection to minimum 1 voucher with percentage is found. Please ' . 'notice that this is just a simplified overview, for the real refund ' . 'process please check directly in payone system.';
 $text_encrypted = 'ENCRYPTED';
 if (isset($_POST['me_action'])) {
     if ($_POST['me_action'] == 'CANCELPRODUCT') {
         $cancel_source = tep_db_prepare_input($_POST['cancel_source']);
         $cancel_id = tep_db_prepare_input($_POST['cancel_id']);
         $cancel_old_status = tep_db_prepare_input($_POST['cancel_status']);
         if ($cancel_source == Order::ORDER_TYPE_JULIE_GRACE) {
             $new_status = $class_o->doCancelOrders($cancel_id, $cancel_old_status, $session_userinfo['username']);
         } elseif ($cancel_source == Order::ORDER_TYPE_SALES_PARTNER) {
             $new_status = $class_jo->doCancelOrders($cancel_id, $cancel_old_status, $session_userinfo['username']);
         }
         $result = isset($new_status) && statusIsCancelled($new_status) ? 'OK' : 'FAIL';
         $result .= '|' . $cancel_id;
         echo utf8_encode($result);
         exit;
     } elseif ($_POST['me_action'] == 'RESETLOGISTICPROCESS') {
         if ($source == Order::ORDER_TYPE_JULIE_GRACE) {
             $class_o->logisticProcessReset($order_id);
         } elseif ($source == Order::ORDER_TYPE_SALES_PARTNER) {
             $class_jo->logisticProcessReset($order_id);
         }
         echo utf8_encode('OK');
         exit;
     } elseif ($_POST['me_action'] == 'ADDNEWCOMMENT') {
         $order_id = tep_db_prepare_input($_POST['order_id']);
    return displayCurrency($currency, $total_price);
}
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'PROCESSITEM') {
        $type = tep_db_prepare_input($_POST['type']);
        $item_id = tep_db_prepare_input($_POST['oiid']);
        $new_status = tep_db_prepare_input($_POST['newstatus']);
        $old_status = '1';
        $success = '0';
        $status = '';
        switch ($type) {
            case 'SP':
                $item = $class_jo->retrieveItemDetail($item_id);
                if ($item['status'] == $old_status) {
                    if ($new_status == '10') {
                        $class_jo->doCancelOrders($item_id, $old_status, $session_userinfo['username']);
                    } else {
                        $class_jo->updateItemStatus($item_id, $new_status, $session_userinfo['username']);
                    }
                    $success = '1';
                    $status = statusNameShort($new_status, true);
                } else {
                    $status = statusNameShort($item['status'], true);
                }
                break;
            case 'JG':
                $item = $class_o->retrieveProductDetail($item_id);
                if ($item['status'] == $old_status) {
                    if ($new_status == '10') {
                        $class_o->doCancelOrders($item_id, $old_status, $session_userinfo['username']);
                    } else {
Example #6
0
 function doCancelOrders($items_id, $old_status, $updater)
 {
     $item = $this->retrieveDetail($items_id);
     $new_status = '12';
     if (count($item) > 0 && $item['status'] == $old_status) {
         $this->updateStatus($items_id, $new_status, $updater);
         $this->updateStockStatus($items_id, '0');
         cancelOrderStockHandler('DP', $items_id, $item['stock_status'], $item['status'], $item['print_count'], $item['print_confirmed'], $item['products_id'], $item['articles_id'], $item['quantity']);
         //ALSO CANCEL SOURCE ORDER IF MMO (SP/JG)
         if ($item['trans_type'] == 'SP') {
             use_class('jng_sp_orders');
             $class_jo = new jng_sp_orders();
             $item_trans = $class_jo->retrieveItemDetail($item['trans_id']);
             //ALSO CANCEL REAL ORDERS IF status = "in HH" AND IT'S stock_status NOT USING DEPOT STOCK "D"
             if ($item_trans['status'] == '8' && $item_trans['stock_status'] != 'D') {
                 $class_jo->doCancelOrders($item['trans_id'], $item_trans['status'], $updater, 'J', false);
             }
         } elseif ($item['trans_type'] == 'JG') {
             use_class('orders');
             $class_o = new orders();
             $item_trans = $class_o->retrieveProductDetail($item['trans_id']);
             //ALSO CANCEL REAL ORDERS IF status = "in HH" AND IT'S stock_status NOT USING DEPOT STOCK "D"
             if ($item_trans['status'] == '8' && $item_trans['stock_status'] != 'D') {
                 $class_o->doCancelOrders($item['trans_id'], $item_trans['status'], $updater, 'J', false);
             }
         }
     } else {
         $new_status = $item['status'];
     }
     return $new_status;
 }
 if (!is_null($order['logistic_process'])) {
     $lp_time = date('d.m.Y H:i:s', strtotime($order['logistic_process']));
     $result['status'] = 'BADSTATUS';
     $result['badstatus'] = 'already processed on ' . $lp_time;
 } else {
     //check if shipping window is reached
     if (strtotime($i_temporary['shipping_window_open']) <= time()) {
         //if reached, check also if shipping window is passed
         if (!is_null($i_temporary['shipping_window_close']) && strtotime($i_temporary['shipping_window_close'] . ' 23:59:59') <= time()) {
             //if passed, then suggest bin in and cancel all items
             $result['recommend_binin'] = '1';
             $items = $class_jo->retrieveItems($order_id);
             foreach ($items as $key => $item) {
                 if ($item['status'] == $req_status) {
                     $items_id = $item['jng_sp_orders_items_id'];
                     $class_jo->doCancelOrders($items_id, $item['status'], $username);
                 }
             }
         } else {
             //if not yet passed, then allow normal process to send products
             $sp_detail = $class_sp->retrieveDetail($order['jng_sp_id']);
             $use_amvd_logistic = $sp_detail['use_amvd_logistic'] == '1';
             $display_counter = dailyCounterNo($order['order_date'], $order['daily_count']);
             $shipping_name = $order['customer_shipping_firstname'] . ' ' . $order['customer_shipping_lastname'];
             if ($order['customer_shipping_title'] != '') {
                 $shipping_name = $order['customer_shipping_title'] . ' ' . $shipping_name;
             }
             $shipping_address = $order['customer_shipping_address'];
             $shipping_company = $order['customer_shipping_address2'];
             $cod_value = 0;
             if ($use_amvd_logistic) {