$result = array();
     $result['eladded'] = $el_added;
     ajaxReturn($result);
     exit;
 } elseif ($_POST['me_action'] == 'ELEMENTSUSEDADDDIRECT') {
     $pid = tep_db_prepare_input($_POST['pid']);
     $elid = tep_db_prepare_input($_POST['elid']);
     $elqty = tep_db_prepare_input($_POST['elqty']);
     $el_added = $class_pm->addElementToProducts($pid, $elid, $elqty);
     $result = array();
     $result['eladded'] = $el_added;
     ajaxReturn($result);
     exit;
 } elseif ($_POST['me_action'] == 'SEARCHUSEDELEMENTS') {
     $products_id_copy = tep_db_prepare_input($_POST['pid_c']);
     $el_used = $class_pm->retrieveElementsUsage($products_id_copy);
     $loe = '';
     if (count($el_used) > 0) {
         $htable = array();
         $ht = array();
         $ht['sp'] = 'Image';
         $ht['q'] = 'ID';
         $ht['r'] = 'Name';
         $ht['s'] = 'Qty';
         $htable[] = $ht;
         $el_used_lists = array();
         foreach ($el_used as $el_id => $data) {
             $e = new element($el_id);
             $el_image = '';
             if ($e->id != null) {
                 $el_used_lists[] = $el_id;
예제 #2
0
function cancelOrderStockHandler($type, $oiid, $stock_status, $status, $print_count, $print_confirmed, $products_id, $articles_id, $quantity, $is_promotion_order = false)
{
    global $STOCKLESS_ELEMENTS_CATEGORY;
    use_class('products_minierp');
    use_class('elements_stock');
    use_class('element');
    $class_pm = new products_minierp();
    $class_es = new elements_stock();
    $timestamp = date('Y-m-d H:i:s');
    if (in_array($status, array('1', '2', '3')) && $print_confirmed == 0 || $status == '8' && $print_count == 0) {
        switch ($stock_status) {
            case 'D':
                //DEPOT STOCK
                $class_pm->stockAdd(WAREHOUSE_ID_FOR_HANDLING_ORDERS, $products_id, $articles_id, $quantity, 'ADD CANCEL ' . $type . '-' . $oiid);
                break;
            case 'P':
                //FG STOCK
                $class_pm->stockAdd(WAREHOUSE_ID_PRODUCTS_BALI, $products_id, $articles_id, $quantity, 'ADD CANCEL ' . $type . '-' . $oiid);
                break;
            case 'R':
                //ELEMENTS STOCK
                $elements_used = array();
                $el_usage = $class_pm->retrieveElementsUsage($products_id, $articles_id);
                foreach ($el_usage as $e) {
                    $elements_used[$e['elements_id']] = $e['quantity'];
                }
                foreach ($elements_used as $eid => $el_qty) {
                    $el = new element($eid);
                    $el_cat_id = !is_null($el->attributes['category']['id']) ? $el->attributes['category']['id'] : '';
                    if (!in_array($el_cat_id, $STOCKLESS_ELEMENTS_CATEGORY)) {
                        $stock_qty = $quantity * $el_qty;
                        $current_stock = $class_es->addStockByPieces(WAREHOUSE_ID_ELEMENTS, $eid, $stock_qty, 'ADD CANCEL ' . $type . '-' . $oiid, $is_promotion_order);
                    }
                }
                break;
        }
    }
}
 $q .= " WHERE do.leadtime_start_date IS NOT NULL AND do.trans_type != 'SP' AND do.trans_type != 'JG' ";
 $q .= " AND do.leadtime_start_date < '{$day_filter}' AND do.status = 2";
 $q .= ") a";
 $q .= " ORDER BY a.leadtime_start_date DESC";
 $result = tep_db_query($q);
 $el_id = array();
 $el = array();
 $element_name_max_chars = 30;
 while ($row = tep_db_fetch_array($result)) {
     $products_id = $row['products_id'];
     $articles_id = $row['articles_id'];
     $status = $row['stock_status'];
     $qty = $row['quantity'];
     if ($products_id != '') {
         $product = $class_pm->retrieveDetail($products_id);
         $elements = $class_pm->retrieveElementsUsage($products_id, $articles_id);
     }
     if (is_array($elements) && count($elements) > 0) {
         $elements_stock = $class_es->retrieveAll($whid);
         foreach ($elements as $eid => $usage) {
             $e = new element($eid);
             $stock = $elements_stock[$eid];
             $elusage = $qty * $usage['quantity'];
             if (isset($status) && $status == 'S') {
                 if ($stock < $elusage && !in_array($e->attributes['category']['id'], $STOCKLESS_ELEMENTS_CATEGORY)) {
                     $el['id1'] = $eid;
                     $el['tar q'] = $elusage;
                     $el_id[] = $el;
                     break;
                 }
             }
use_class('products_minierp');
$class_es = new elements_stock();
$class_pm = new products_minierp();
$class_pa = new products_articles();
$ean_eu_collection = array();
$max_el_per_article = 0;
$use_elements = array();
$class_d = new design($_GET['d']);
$products = $class_d->retrieveProducts();
foreach ($products as $p) {
    $query_products_categories = "SELECT * FROM products_to_categories ptc WHERE products_id={$p['products_id']}";
    $tpdbq_products_categories = tep_db_query($query_products_categories);
    $products_categories = tep_db_fetch_array($tpdbq_products_categories);
    // find what use element in this product
    $ean_eu_collection[$p['products_id'] . '-0'] = '';
    $tpdbq_products_use_elements = $class_pm->retrieveElementsUsage($p[products_id]);
    foreach ($tpdbq_products_use_elements as $row_pue) {
        $use_elements[] = array('elements_id' => $row_pue['elements_id'], 'quantity' => (int) $row_pue['quantity'] * $eao);
        $ean_eu_collection[$p['products_id'] . '-0'] .= $row_pue['elements_id'] . ' x ' . $row_pue['quantity'] . '|';
    }
    $mepa = count($tpdbq_products_use_elements);
    if ($mepa > $max_el_per_article) {
        $max_el_per_article = $mepa;
    }
    $tpdbq_products_articles = $class_pa->retrieveList($p[products_id], "active_status='1'");
    foreach ($tpdbq_products_articles as $row_pa) {
        $ean_eu_collection[$p['products_id'] . '-' . $row_pa['products_articles_id']] = '';
        $tpdbq_products_articles_use_elements = $class_pm->retrieveElementsUsage($p[products_id], $row_pa['products_articles_id']);
        foreach ($tpdbq_products_articles_use_elements as $row_pue) {
            $use_elements[] = array('elements_id' => $row_pue['elements_id'], 'quantity' => (int) $row_pue['quantity'] * $eao);
            $ean_eu_collection[$p['products_id'] . '-' . $row_pa['products_articles_id']] .= $row_pue['elements_id'] . ' x ' . $row_pue['quantity'] . '|';
예제 #5
0
 $extra_images = array();
 $add_have_set_to_default = false;
 $alternate_main_image_key = null;
 $x = 0;
 while ($row = tep_db_fetch_array($extra_images_query)) {
     $extra_images[$x] = $row;
     if ($row['alternate_main_image'] == 1) {
         $add_have_set_to_default = true;
         $alternate_main_image_key = $x;
     }
     $x++;
 }
 $depot_stock = $class_pm->stockRetrieve(WAREHOUSE_ID_FOR_HANDLING_ORDERS, $products_id, '*');
 $depot_refill = $class_do->refillOpenOrdersQuantity(SEGMENT_ID_DEFAULT, $products_id, '*');
 $elements_status_raw = true;
 $elements_usage = $class_pm->retrieveElementsUsage($products_id);
 if (count($elements_usage) > 0) {
     $elements_stock = $class_es->retrieveList(WAREHOUSE_ID_ELEMENTS, 'elements_id IN (' . implode(',', array_keys($elements_usage)) . ')');
     foreach ($elements_usage as $eid => $eu) {
         if ($eu['quantity'] > $elements_stock[$eid]) {
             $elements_status_raw = false;
             break;
         }
     }
 } else {
     $elements_status_raw = '<span class="green" title="No Element used Found for this product">NEF</span>';
 }
 $elements_status = is_bool($elements_status_raw) ? '<span class="' . ($elements_status_raw ? 'green">OK</span>' : 'red">NS') . '</span>' : $elements_status_raw;
 $products_agegroup_options = $class_pm->productAgeGroupName();
 $products_brand = $products['products_brand_id'] > 0 ? $class_pb->retrieveDetail($products['products_brand_id']) : '';
 $date_added = date('Y-m-d', strtotime($products['products_date_added']));
예제 #6
0
 function isReadyForGraphics()
 {
     use_class('products_articles');
     $class_pa = new products_articles();
     use_class('products_minierp');
     $class_pm = new products_minierp();
     $drafts = $this->retrieveDrafts("approve_status!='R'");
     if (count($drafts) > 0) {
         $products = $this->retrieveProducts();
         $drafts_products = array();
         foreach ($products as $p) {
             if (!in_array($p['drafts_id'], $drafts_products)) {
                 $drafts_products[] = $p['drafts_id'];
             }
         }
     } else {
         return false;
     }
     $rule1 = count($drafts_products) >= count($drafts);
     if (!$rule1) {
         return $rule1;
     }
     foreach ($products as $p) {
         $el_usage = $class_pm->retrieveElementsUsage($p['products_id']);
         $rule2 = count($el_usage) > 0;
         if (!$rule2) {
             return $rule2;
         }
     }
     foreach ($products as $p) {
         $pa = $class_pa->retrieveList($p['products_id']);
         foreach ($pa as $val) {
             $rule3 = $class_pa->haveOverridedElement($val['products_articles_id']);
             if (!$rule3) {
                 return $rule3;
             }
         }
     }
     foreach ($products as $p) {
         $qm = "SELECT is_main FROM products_use_elements WHERE is_main = '1'" . " AND products_id = '" . $p['products_id'] . "'";
         $qm_r = tep_db_query($qm);
         $rule4 = tep_db_num_rows($qm_r);
         if ($rule4 == 0) {
             return $rule4;
         }
     }
     return true;
 }
예제 #7
0
 private function getElementsNeeded($colname)
 {
     use_class('products_minierp');
     $class_pm = new products_minierp();
     $elements_needed = array();
     foreach ($this->items as $i) {
         $eus = $class_pm->retrieveElementsUsage($i['products_id'], $i['articles_id']);
         foreach ($eus as $eu) {
             if (!isset($elements_needed[$eu['elements_id']])) {
                 $elements_needed[$eu['elements_id']] = 0;
             }
             $elements_needed[$eu['elements_id']] += $i[$colname] * $eu['quantity'];
         }
     }
     return $elements_needed;
 }
$class_pm = new products_minierp();
$class_pa = new products_articles();
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'GETPRODUCTDETAIL') {
        $product_input = tep_db_prepare_input($_POST['product_input']);
        $result = false;
        $elements_datas = array();
        $jng_warehouses_id = 1;
        if (strlen($product_input) == 13) {
            $ean = $product_input;
            $product_info = $class_ean->getProductArticle($ean);
            if (!empty($product_info['products_id']) && !is_null($product_info['products_id'])) {
                $products_id = $product_info['products_id'];
                $articles_id = $product_info['products_articles_id'];
                $product_data = $class_pm->retrieveDetail($products_id, 'p');
                $elements_used = $class_pm->retrieveElementsUsage($products_id, $articles_id);
                foreach ($elements_used as $element) {
                    $element_stock_query = "SELECT es.stock";
                    $element_stock_query .= " FROM elements_stock es";
                    $element_stock_query .= " WHERE es.jng_warehouses_id={$jng_warehouses_id}";
                    $element_stock_query .= " AND es.elements_id=" . $element['elements_id'];
                    $element_stock_result = tep_db_query($element_stock_query);
                    if (tep_db_num_rows($element_stock_result) > 0) {
                        $element_stock = tep_db_fetch_array($element_stock_result);
                        $el_stock = $element_stock[stock];
                    }
                    $elements_datas[] = $element['elements_id'] . "-" . $element['quantity'] . "-" . $el_stock;
                }
                $result['products_id'] = $product_data['p']['products_id'];
                $result['products_length'] = $product_info['length'] > 0 ? textLength($product_info['length']) : textLength("-");
                $result['products_ean'] = $ean;
 /**
  * Generate family match key
  * @param Int $products_id
  * @param Int $articles_id
  * @return String
  */
 function refreshFamilyMatchKey($products_id, $articles_id = null)
 {
     //$group_ref_el_cat = array('casting', 'findings', 'handmade', 'chains', 'pearl');
     $group_ref_el_cat = $this->el_cat_searchkey;
     //Old Key formula : brand_id-categories_id-[el_id-qty] >> 13.12.10 changed to exclude brand_id
     //New Key formula : categories_id-[el_id-qty]
     use_class('element');
     use_class('products_minierp');
     use_class('products_articles');
     $class_pa = new products_articles();
     $class_pm = new products_minierp();
     if (is_null($products_id)) {
         $articles = $class_pa->retrieveDetail($articles_id);
         $products_id = $articles['products_id'];
     }
     $family_searchkey = '';
     $key1 = array();
     $key2 = array();
     $el_used = $class_pm->retrieveElementsUsage($products_id, $articles_id);
     if (count($el_used) > 0) {
         //$p_data = $class_pm->retrieveDetail($products_id, 'p,cat');
         $p_data = $class_pm->retrieveDetail($products_id, 'cat');
         //$key1[] = $p_data['p']['products_brand_id'];
         $key1[] = $p_data['categories_id'];
         foreach ($el_used as $dt) {
             $elid = $dt['elements_id'];
             $el = new element($elid);
             if (in_array($el->attributes['category']['id'], $group_ref_el_cat)) {
                 $key2[] = $elid;
                 $key2[] = $dt['quantity'];
             }
         }
         if (count($key2) > 0) {
             $family_searchkey = implode('-', array_merge($key1, $key2));
             if (is_null($articles_id)) {
                 tep_db_perform('products', array('family_searchkey' => $family_searchkey), 'update', "products_id={$products_id}");
                 //update also articles if exist
                 $articles = $class_pa->retrieveList($products_id);
                 foreach ($articles as $article) {
                     $articles_id = $article['products_articles_id'];
                     $this->refreshFamilyMatchKey($products_id, $articles_id);
                 }
             } else {
                 tep_db_perform('products_articles', array('family_searchkey' => $family_searchkey), 'update', "products_articles_id={$articles_id}");
             }
         }
     }
     return $family_searchkey;
 }
예제 #10
0
 function countElementsUsage($products_id, $articles_id = null)
 {
     $euid = $products_id . (is_null($articles_id) ? '' : '-' . $articles_id);
     if (isset($this->elements_usage[$euid]) && is_array($this->elements_usage[$euid])) {
         $eu = $this->elements_usage[$euid];
     } else {
         $eu = array();
         if (!is_null($products_id) && $products_id != '') {
             //lets use function from class products_minierp
             use_class('products_minierp');
             $class_pm = new products_minierp();
             $el_usage = $class_pm->retrieveElementsUsage($products_id, $articles_id);
             foreach ($el_usage as $e) {
                 $eu[$e['elements_id']] = $e['quantity'];
             }
         }
         $this->elements_usage[$euid] = $eu;
     }
     return $eu;
 }
use_class('element');
$class_pm = new products_minierp();
$pids = array(15058, 15255, 15257, 15269, 15271, 15275, 15411, 15996, 16101, 16103, 16284, 16574, 16575, 16576, 16577, 16578, 16579, 16580, 16581, 16583, 16584, 16585, 16586, 16587, 16589, 16591, 16592, 16593, 16600, 16606, 17541, 17835, 18028, 18029, 18030, 21114, 22498, 23189, 24293, 24925, 24934, 25018, 25043, 25204, 25459, 25461, 25899, 26384, 26546, 26582, 26669, 27017, 27025, 27271, 27277, 27634, 28731, 29819, 30328, 30627, 31280, 31289, 31299, 31308, 31316, 31416, 31429, 31440, 31545, 31857, 31865, 31880, 32064, 32360, 33045, 33053, 33063, 33074, 33296, 33884, 34352, 34357, 35605, 38834, 38130, 43468, 43470, 43476, 43491, 43495, 43580, 43783, 43795, 43875, 44119, 44120, 43128, 44596, 45182, 45163, 44886, 45745, 43702, 43705, 46488, 46493, 46494, 46495, 46751, 47223, 47469, 47477, 47478, 47480, 47481, 47484, 47488, 47490, 47489, 47491, 47556, 47558, 47560, 47564, 47563, 47567, 47568, 47569, 47570, 47571, 47714, 47716, 47718, 47720, 47972, 48127, 48792, 48941, 48944, 49230, 32336, 50293, 50300, 50308, 50309, 50313, 50314, 50323, 50324, 50327, 50328, 50329, 50346, 50449, 50450, 50455, 50558, 50559, 50562, 50565, 50650, 50913, 51016, 51093, 51218, 51216, 51396, 51430, 51553, 51557, 51559, 51560, 51572, 51585, 51590, 51640, 51645, 51821, 51825, 51847, 53322, 53330, 53459, 53472, 53610, 53763, 53846, 53847, 53963, 53962, 53961, 53960, 53958, 53957, 54119, 54126, 54197, 54210, 54301, 54307, 54314, 54317, 54321, 54365, 54369, 54370, 54371, 54413, 54414, 54420, 54534, 54696, 54706, 54799, 54847, 54869, 54919, 54920, 54921, 54985, 54978, 55005, 55019, 55027, 55035, 55249, 55248, 55247, 55261, 55262, 55286, 55294, 55295, 55298, 55426, 55428, 55429, 55430, 55489, 55493, 55515, 55539, 55567, 55571, 55582, 55635, 55720, 55752, 55762, 55813, 55871, 55978, 56013, 56014, 56066, 56077, 56078, 56079, 56080, 56156, 33227, 56287, 56308, 56315, 56329, 56502, 56522, 56592, 56643, 56837, 57337, 57840, 57847, 57854, 58498, 58587, 58589, 58590, 58591, 58588, 58593, 58595, 58596, 58597, 58599, 58502, 58973, 58721, 58722, 58724, 58994, 59000, 59075, 58916, 58915, 59153, 58926, 58928, 58929, 58930, 58938, 59236, 59235, 59238, 59347, 59351, 59352, 59353, 59451, 59396, 59397, 59194, 59579, 59560, 59562, 59565, 59566, 59359, 59626, 59512, 59699, 59671, 59517, 59720, 59718, 59448, 59574, 59817, 59819, 59835, 59805, 60299, 60179, 60451, 60575, 60350, 60351, 60356, 60357, 60601, 60602, 60562, 60563, 60564, 60624, 60608, 60633, 60634, 60635, 60636, 60655, 60656, 60657, 60658, 60659, 60672, 60674, 60528, 60529, 60530, 60531, 60629, 60763, 60764, 60765, 60766, 60768, 60670, 60594, 60595, 60782, 60771, 60772, 60773, 60774, 60775, 60776, 60777, 60850, 60884, 60887, 60949, 60950, 60960, 60961, 60955, 60957, 60668, 60975, 60976, 60983, 60934, 61004, 61005, 61006, 60886, 61030, 61031, 61032, 61033, 61137, 61138, 61139, 61148, 61167, 61196, 61264, 61288, 61289, 61290, 61472, 61474, 61475, 61476, 61478, 61636, 61637, 61639, 61664, 61665, 61666, 61667, 61669, 61792, 61874, 61876, 61814, 61815, 61965, 61890, 61891, 61988, 61910, 61915, 61971, 62029, 62019, 62050, 62041, 62042, 62043, 62044, 61899, 62061, 62053, 62063, 62023, 62081, 62057, 62126, 62122, 62124, 62131, 62140, 62148, 62119, 62176, 62186, 62187, 62188, 62189, 62174, 62221, 62254, 62224, 62261, 62274, 62275, 62276, 62277, 62287, 62271, 62272, 62305, 62259, 62299, 62263, 62300, 62301, 62293, 62304, 62292, 62267, 62357, 62358, 62359, 62388, 62382, 62383, 62416);
$h = "<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\"><tr>\n    <td><div><b>Image</b></div></td>\n    <td><div><b>Products<br/>ID</b></div></td>\n    <td><div><b>Products<br/>Code</b></div></td>\n    <td><div><b>Length</b></div></td>\n    <td><div><b>EAN</b></div></td>\n    <td><div><b>Elements<br/>Image</b></div></td>\n    <td><div><b>Elements<br/>ID</b></div></td>\n    <td><div><b>Elements<br/>Qty</b></div></td>\n    </tr>";
echo $h;
foreach ($pids as $pid) {
    $q = "SELECT jc.*,p.products_ean FROM jng_sp_catalog jc";
    $q .= " INNER JOIN products p ON p.products_id = jc.products_id";
    $q .= " WHERE jc.jng_sp_id = 5 AND jc.products_id = {$pid}";
    $h = '';
    $dbq = tep_db_query($q);
    $r = tep_db_fetch_array($dbq);
    $article_number = $r['article_number'];
    $p = $class_pm->retrieveDetail($pid, 'p');
    $p = $p['p'];
    $pue = $class_pm->retrieveElementsUsage($pid);
    $heu = '';
    $heu1 = '';
    $counter = 0;
    foreach ($pue as $elid => $dt) {
        $class_e = new element($elid);
        $eimg = webImage($class_e->image, '80', '80');
        if (count($pue) == 1) {
            $heu = "<td><div>{$eimg}</div></td><td><div>{$elid}</div></td><td><div>{$dt['quantity']}</div></td>";
        } else {
            $counter++;
            if ($heu == '') {
                $heu = "<td><div>{$eimg}</div></td><td><div>{$elid}</div></td><td><div>{$dt['quantity']}</div></td>";
            } else {
                $heu1 .= "<tr><td><div>{$eimg}</div></td><td><div>{$elid}</div></td><td><div>{$dt['quantity']}</div></td></tr>";
            }
예제 #12
0
 $colors = $class_pm->loadColorPatternNames($pid, '2');
 $colors_main = '';
 if (is_array($colors)) {
     foreach ($colors as $c) {
         $colors_main = $c;
         break;
     }
 } else {
     $colors = array();
 }
 $materials_ids = $class_pm->loadProductMaterials($pid);
 $materials = array();
 foreach ($materials_ids as $mid) {
     $materials[] = $materials_name[$mid];
 }
 $pues = $class_pm->retrieveElementsUsage($pid, 0);
 $materials_stone = '';
 $materials_stone_size = '';
 $stones_mats = array();
 $stones_sizes = array();
 foreach ($pues as $pue) {
     $e = new element($pue['elements_id']);
     if ($e->attributes['category']['id'] == '5') {
         $matname = explode(', ', $e->attributes['material']['name']);
         $stones_mats[$matname[0]] += $pue['quantity'];
         $stones_sizes[$e->attributes['size']['name']] += $pue['quantity'];
     }
 }
 if (count($stones_mats) > 0) {
     $stones_bq = max($stones_mats);
     $materials_stone = array_search($stones_bq, $stones_mats);
예제 #13
0
                 $htp['date_add'] = date('d.m.y H:i:s', $tsproductionstatus);
                 $htp['status'] = 'Production: ' . statusNameProduction($hp['status']);
                 $htp['login'] = $hp['update_by'];
                 $htable[] = $htp;
                 unset($history_prod[$hpk]);
             }
         }
     }
 }
 if ($do['status'] == '2') {
     use_class('element');
     use_class('elements_stock');
     $class_es = new elements_stock();
     $estock = $class_es->retrieveAll($whid_material);
     $sourcing_table = array();
     $eused = $class_pm->retrieveElementsUsage($do['products_id'], $do['articles_id']);
     $sourcing_info = '<div style="margin-top:20px;">';
     $sourcing_info .= '<h3>Sourcing Information</h3>';
     if (count($eused) > 0) {
         $sourcing_table = array();
         $st = array();
         $st['d'] = 'Image';
         $st['id1'] = 'Element ID';
         $st['a'] = 'Qty Required';
         $st['o'] = 'Stock Available';
         $sourcing_table[] = $st;
         foreach ($eused as $eid => $eu) {
             $colclass = '';
             if ($eu['quantity'] > $estock[$eid]) {
                 $colclass = ' bold red';
             }