function processXMLFile($xml_file)
{
    global $timestamp, $logger;
    $xmlt = new xml_tools();
    $xml = $xmlt->loadFile($xml_file);
    $order_date = $timestamp;
    $segments_id = (int) $xml->LOCAL_INFO->SEGMENT_ID;
    $group_name = (string) $xml->LOCAL_INFO->GROUP_NAME;
    $refill_orders = $xml->REFILL_ORDERS->ORDER;
    $counter = 0;
    foreach ($refill_orders as $ro) {
        $products_id = (int) $ro->PRODUCTS_ID;
        $articles_id = (int) $ro->ARTICLES_ID;
        $products_ean = $ro->PRODUCTS_EAN;
        $quantity = (int) $ro->QUANTITY;
        $trans_type = (string) (strtoupper($ro->TRANS_TYPE) == 'NULL' ? '' : $ro->TRANS_TYPE);
        $trans_id = (int) $ro->TRANS_ID;
        //CREATE DEPOT ORDERS
        $q_check = "SELECT depot_orders_id FROM depot_orders " . " WHERE segments_id = {$segments_id}" . " AND trans_type = '' AND trans_id = {$trans_id}";
        $r_check = tep_db_query($q_check);
        //ONLY CREATE ORDER WHICH NOT IMPORTED
        if (tep_db_num_rows($r_check) == 0) {
            $class_do = new depot_orders();
            $class_do->newOrder($segments_id, $products_id, $articles_id, $products_ean, $quantity, $order_date, $trans_type, $trans_id, $group_name);
            $counter++;
        }
    }
    $logger->write("{$counter} orders imported");
    unlink($xml_file);
    $logger->write("xml deleted");
    return $counter;
}
     $ajaxResult = array();
     $ajaxResult['total_qty'] = $total_qty_ordered;
     $ajaxResult['total_orders'] = count($ids_created);
     $ajaxResult['ids_created'] = implode(',', $ids_created);
     ajaxReturn($ajaxResult);
     exit;
 } elseif ($_POST['me_action'] == 'CREATENRFINTERNALORDER') {
     $segments_id = tep_db_prepare_input($_POST['segments_id']);
     $products_id = tep_db_prepare_input($_POST['products_id']);
     $articles_id = tep_db_prepare_input($_POST['articles_id']);
     $products_ean = tep_db_prepare_input($_POST['products_ean']);
     $group_name = tep_db_prepare_input($_POST['group_name']);
     $total_qty = tep_db_prepare_input($_POST['total_qty']);
     $ids_created = array();
     for ($x = 1; $x <= $total_qty; $x++) {
         $items_id = $class_do->newOrder($segments_id, $products_id, $articles_id, $products_ean, 1, null, depot_orders::TRANS_TYPE_NON_REFILL, depot_orders::NONREFILL_INTERNAL_ID, 'Non-Refill: ' . $group_name);
         $ids_created[] = $items_id;
     }
     $ajaxResult = array();
     $ajaxResult['total_qty'] = $total_qty;
     $ajaxResult['ids_created'] = implode(',', $ids_created);
     ajaxReturn($ajaxResult);
     exit;
 } elseif ($_POST['me_action'] == 'LOADDAILYNRFORDERS') {
     $year = date('Y');
     $period_start = "{$year}-01-01 00:00:00";
     $period_end = "{$year}-12-31 23:59:59";
     $dl_icon_template = '<span id="%s" class="ui-icon ui-icon-disk pointer"' . 'style="float:right;" title="Click here to download PO for this order"></span>';
     $q = "SELECT SUM(do.quantity) AS qty, DATE(do.order_date) AS daily_period" . ", IFNULL(doo.suppliers_id, 0) AS suppliers_id" . ", IFNULL(es.suppliers_name, 'Internal') AS suppliers_name" . " FROM depot_orders do" . " LEFT JOIN depot_orders_outsourced doo ON doo.depot_orders_id=do.depot_orders_id" . " LEFT JOIN elements_suppliers es ON es.elements_suppliers_id=doo.suppliers_id" . " WHERE do.order_date >= '{$period_start}' AND do.order_date <= '{$period_end}'" . " AND do.trans_type='" . depot_orders::TRANS_TYPE_NON_REFILL . "'" . " AND do.status NOT IN (10,12)" . " GROUP BY daily_period, suppliers_id" . " ORDER BY daily_period, suppliers_id";
     $r = tep_db_query($q);
     $daily_data = array();
Exemplo n.º 3
0
     }
     $ajaxResult = array();
     $ajaxResult['total_qty'] = $total_qty_ordered;
     $ajaxResult['total_orders'] = count($ids_created);
     $ajaxResult['ids_created'] = implode(',', $ids_created);
     ajaxReturn($ajaxResult);
     exit;
 } elseif ($_POST['me_action'] == 'CREATELTFINTERNALORDER') {
     $segments_id = tep_db_prepare_input($_POST['segments_id']);
     $products_id = tep_db_prepare_input($_POST['products_id']);
     $articles_id = tep_db_prepare_input($_POST['articles_id']);
     $products_ean = tep_db_prepare_input($_POST['products_ean']);
     $total_qty = tep_db_prepare_input($_POST['total_qty']);
     $ids_created = array();
     for ($x = 1; $x <= $total_qty; $x++) {
         $items_id = $class_do->newOrder($segments_id, $products_id, $articles_id, $products_ean, 1, null, '', depot_orders::MANUAL_REFILL_LTF, depot_orders::GROUP_NAME_LTF_INTERNAL);
         $ids_created[] = $items_id;
     }
     $ajaxResult = array();
     $ajaxResult['total_qty'] = $total_qty;
     $ajaxResult['ids_created'] = implode(',', $ids_created);
     ajaxReturn($ajaxResult);
     exit;
 } elseif ($_POST['me_action'] == "CREATEORDER") {
     $segments_id = tep_db_prepare_input($_POST['segments_id']);
     $products_id = tep_db_prepare_input($_POST['products_id']);
     $articles_id = tep_db_prepare_input($_POST['articles_id']);
     $order_qty = tep_db_prepare_input($_POST['order_qty']);
     $group_name = tep_db_prepare_input($_POST['group_name']);
     $product_ean = $class_ean->getEAN($products_id, $articles_id);
     for ($x = 1; $x <= $order_qty; $x++) {
Exemplo n.º 4
0
 public function setAsConfirmed()
 {
     //WE DISABLE THE ELEMENTS SOURCING INTEGRATION HERE AND WILL BE IMPLEMENT IN A NEW MODULE TO DIRECTLY CREATE A PO
     global $session_userinfo;
     use_class('stock_booking');
     use_class('depot_orders');
     use_class('products_minierp');
     use_class('elements_preorder');
     $class_pm = new products_minierp();
     $class_do = new depot_orders();
     $depot_orders_id = array();
     $booking = new stock_booking();
     $booking->create('Preorder: ' . $this->name);
     foreach ($this->items as $i) {
         $stock = $class_pm->stockRetrieveDetail(WAREHOUSE_ID_PRODUCTS_HAMBURG, $i['products_id'], $i['articles_id']);
         $booking->addItem($stock['products_stock_id'], $i['qty_booked']);
         for ($q = 1; $q <= $i['qty_preproduce']; $q++) {
             $depot_orders_id[] = $class_do->newOrder(SEGMENT_ID_HAMBURG, $i['products_id'], $i['articles_id'], $i['products_ean'], 1);
         }
     }
     $elements_sourcing = $this->getElementsNeededForOnDemand();
     //        foreach($elements_sourcing as $eid=>$qty) {
     //            $epo = new elements_preorder($eid);
     //            $epo->addOrder($qty, null, 'Preorder '.$this->id);
     //        }
     $this->updateConnection($booking->id, $depot_orders_id, $elements_sourcing);
     $this->updateStatus($this->status, 2, $session_userinfo['username']);
 }
Exemplo n.º 5
0
 /**
  * Activate products in J&G website and optinally in other SP or create a sample order
  * @param Array $products_id Array of Products ID to be activated
  * @param Boolean $activate_in_sp Set to true to activate also to SP where the data is already prepared
  * @param Boolean $create_sample Set to true to auto create a sample order (as depot order) for all products
  */
 function activateProducts($products_id, $activate_in_sp = true, $create_sample = false)
 {
     //Just in case $products_id is sent as string:
     if (!is_array($products_id)) {
         $products_id = explode(',', $products_id);
     }
     //ACTIVATE IN SP
     if ($activate_in_sp) {
         use_class('jng_sp_catalog');
         $class_jc = new jng_sp_catalog();
         $class_jc->activateProducts($products_id);
     }
     //CREATE SAMPLE ORDER
     if ($create_sample) {
         use_class('depot_orders');
         use_class('products_ean');
         $class_do = new depot_orders();
         $class_ean = new products_ean();
         foreach ($products_id as $pid) {
             $ean = $class_ean->getEAN($pid);
             $so_qty = '2';
             //changed from '1' to '2' (prepared 1 for HH and 1 for Design Team Bali)
             for ($i = 1; $i <= $so_qty; $i++) {
                 $class_do->newOrder(SEGMENT_ID_HAMBURG, $pid, '0', $ean, '1', null, null, null, 'CSO - New Products');
             }
         }
     }
     //ACTIVATE PRODUCTS
     $sda = array();
     if ($create_sample) {
         $sda['sample_created'] = '1';
     }
     $sda['products_status'] = '1';
     //JNG Website active status
     $sda['active_status'] = '1';
     //General active status
     $sda['products_date_added'] = date('Y-m-d H:i:s');
     $products_filter = implode(',', $products_id);
     tep_db_perform('products', $sda, 'update', "products_id IN ({$products_filter})");
 }