use_class('jng_sp_catalog');
$class_jc = new jng_sp_catalog();
$joi = array();
$joi_query = "SELECT joi.*";
$joi_query .= " FROM jng_sp_orders jo";
$joi_query .= " INNER JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_id=jo.jng_sp_orders_id";
$joi_query .= " WHERE jo.jng_sp_id={$jng_sp_id}";
$joi_result = tep_db_query($joi_query);
while ($row = tep_db_fetch_array($joi_result)) {
    if (!isset($joi[$row['products_id']])) {
        $joi[$row['products_id']] = array();
    }
    $joi[$row['products_id']][] = $row;
}
$catalog_update = array();
$catalog = $class_jc->retrieveCatalog($jng_sp_id);
foreach ($catalog as $cat) {
    $pid = $cat['products_id'];
    if (isset($joi[$pid])) {
        $catalog_update[$pid] = array('vc_count' => 0, 'vc_total' => 0, 'vc_min' => 0, 'vc_max' => 0);
        foreach ($joi[$pid] as $i) {
            $net_sold = $i['order_quantity'] - $i['return_quantity'];
            $catalog_update[$pid]['vc_count'] += $i['order_quantity'];
            $catalog_update[$pid]['vc_total'] += $i['vc_value'];
            if ($catalog_update[$pid]['vc_min'] == 0 || $i['vc_value'] < $catalog_update[$pid]['vc_min']) {
                $catalog_update[$pid]['vc_min'] = $i['vc_value'];
            }
            if ($i['vc_value'] > $catalog_update[$pid]['vc_max']) {
                $catalog_update[$pid]['vc_max'] = $i['vc_value'];
            }
        }
<?php

global $db;
require_once '../confy.php';
require_once '../functions.php';
require_once '../functions-2.php';
tep_db_connect();
use_class('jng_sp_catalog');
$class_jc = new jng_sp_catalog();
$jng_sp_id = '1';
$filter_query = " jc.active_status='1'";
$nm_cat = $class_jc->retrieveCatalog($jng_sp_id, $filter_query);
$new_sp_id = '2';
$update_counter = 0;
foreach ($nm_cat as $c) {
    $check_query = tep_db_query("SELECT jng_sp_catalog_id, status_price, price, price_old FROM jng_sp_catalog WHERE jng_sp_id={$new_sp_id} AND products_id={$c['products_id']}");
    if (tep_db_num_rows($check_query) > 0) {
        $check_result = tep_db_fetch_array($check_query);
        $catalog_id = $check_result['jng_sp_catalog_id'];
        if ($check_result['status_price'] == '0' || $check_result['price'] != $c['price'] || $check_result['price_old'] != $c['price_old']) {
            $sda = array();
            $sda['status_price'] = '1';
            $sda['price'] = $c['price'];
            $sda['price_old'] = $c['price_old'];
            $class_jc->updateField($catalog_id, $sda);
            $update_counter++;
        }
    }
}
echo "{$update_counter} Products Price is updated.";
tep_db_close();
Пример #3
0
             }
             //APPLY PRODUCTS LINKING
             $dbqpl = tep_db_query("SELECT links_id, type FROM products_linking WHERE products_id={$products_id}");
             while ($r = tep_db_fetch_array($dbqpl)) {
                 $links_id = $r['links_id'];
                 $type = $r['type'];
                 $class_pl->add($pid, $type, $links_id, true);
             }
             //APPLY NAVID's
             $dbq = tep_db_query("SELECT jng_sp_id, navigation, navigation2, navigation3 FROM jng_sp_catalog WHERE products_id={$products_id} ORDER BY jng_sp_id");
             while ($r = tep_db_fetch_array($dbq)) {
                 $nav = $r['navigation'];
                 $nav2 = $r['navigation2'];
                 $nav3 = $r['navigation3'];
                 $class_jc->addProduct($r['jng_sp_id'], $pid);
                 $p_cat = $class_jc->retrieveCatalog($r['jng_sp_id'], "jc.products_id = '{$pid}'");
                 saveCatalog($p_cat[0]['jng_sp_catalog_id'], 'navigation', $nav);
                 saveCatalog($p_cat[0]['jng_sp_catalog_id'], 'navigation2', $nav2);
                 saveCatalog($p_cat[0]['jng_sp_catalog_id'], 'navigation3', $nav3);
             }
         }
     }
     $draft = new design_draft(null, $products_id);
     $draft->detailCompleted($products_id, $session_userinfo['username']);
     echo utf8_encode('UPDATED');
     exit;
 } elseif ($_POST['me_action'] == 'UPDATECATALOG') {
     $dt = array();
     $catalog_id = tep_db_prepare_input($_POST['jcid']);
     $field_name = tep_db_prepare_input($_POST['fieldName']);
     $field_value = tep_db_prepare_input($_POST['fieldValue']);
    $sel = $current_brand == 'N' ? $selected : '';
    $brand_combo .= '<option value="N" ' . $sel . '>No Logo</option>';
    $sel = $current_brand == '0' ? $selected : '';
    $brand_combo .= '<option value="0" ' . $sel . '>JULIE &amp; GRACE</option>';
    foreach ($brands as $b) {
        $sel = $current_brand == $b['products_brand_id'] ? $selected : '';
        $brand_combo .= '<option value="' . $b['products_brand_id'] . '" ' . $sel . '>' . $b['brand_name'] . '</option>';
    }
    $brand_combo .= '</select>';
    return $brand_combo;
}
$sort_query = " jc.total_sold DESC";
$limit = 80;
$offset = ($page - 1) * $limit;
$catalog_total = $class_jc->countTotalCatalog($jng_sp_id, $filter_query, $join_query);
$catalog = $class_jc->retrieveCatalog($jng_sp_id, $filter_query, $sort_query, $limit, $offset, $join_query);
$pagelink = tep_paging($catalog_total, $page, '?open=sp-products-links-popup&amp;products_id=' . $products_id . '&amp;type=' . $type . '&amp;jng_sp_id=' . $jng_sp_id . '&amp;hidemenu=true&amp;page=', '', '', $limit);
$content = '';
$content .= '<div style="float:left;width:120px;text-align:center;">';
$content .= '<div>' . webImage($product_data['p']['products_image'], '120', '120') . '</div>';
if (!is_null($product['brand'])) {
    $content .= '<div>' . webImage($product['brand']['brand_image'], '100', '') . '</div>';
}
$content .= '</div>';
$content .= '<div style="margin-left:140px;">';
$content .= '<h2>' . $product_data['p']['products_id'] . ' / ' . $product_data['p']['products_model'] . '</h2>';
$content .= '<h3>' . displayCurrency('EUR', $product['price']) . '</h3>';
$content .= '<div style="margin-top:20px;"><form name="filtering" action="?open=sp-products-links-popup&amp;products_id=' . $products_id . '&amp;type=' . $type . '&amp;jng_sp_id=' . $jng_sp_id . '&amp;hidemenu=true" method="post">';
$content .= '<table class="form" border="0" cellpadding="0" cellspacing="0">';
$content .= '<tr><td colspan="2"><strong>Filter By</strong></td></tr>';
$content .= '<tr><td>Nav ID</td><td>' . ComboBoxneckermannNavIDs('*', 'nav-filter', $navfiltered, '', 'onchange="filtering.submit();"') . '</td></tr>';
            }
            if ($value == '') {
                $value = '&nbsp;';
            }
            $cols[$hk] = $value;
        }
        $productrow = '<tr id="temp-' . $pid . '">';
        foreach ($cols as $ck => $cv) {
            $productrow .= '<td class="' . $ck . '">' . $cv . '</td>';
        }
        $productrow .= '</tr>';
        echo utf8_encode($productrow);
        exit;
    } elseif ($_POST['me_action'] == 'LOADPRODUCTSFORFINALIZE') {
        $pids = tep_db_prepare_input($_POST['pid_list']);
        $plist = $class_jc->retrieveCatalog($jng_sp_id, "jc.products_id IN ({$pids})", 'products_id');
        $result = array();
        foreach ($plist as $p) {
            $result[] = $p['products_id'] . '||' . $p['name'];
        }
        echo utf8_encode(implode('|||', $result));
        exit;
    }
}
$content .= '<div id="pageL" style="display:none;"><img src="images/ajax-load-1.gif" /></div>';
$content .= '<div id="page1">';
$content .= '<div><input id="btn-addall" type="button" value="Add ALL Products to ' . $sp_code . '" /></div>';
if ($jng_sp_id == '7') {
    $content .= '<div class="red" style="margin-top:10px;">* New added products' . ' is automatically activated and set with default BuyVIP price' . ' (Factor 4)</div>';
} else {
    $content .= '<div style="margin-top:20px;">';
Пример #6
0
 function copyFromProducts($products_id_to_copied, $products_id_to_applied, $options = '*', $elements_id_to_exclude = '', $skip_same_add_length_composition = false)
 {
     use_class('products_articles');
     $class_pa = new products_articles();
     $have_element_to_exclude = false;
     if ($elements_id_to_exclude != '' && !is_array($elements_id_to_exclude)) {
         $elements_id_to_exclude = explode(',', $elements_id_to_exclude);
         $have_element_to_exclude = true;
     }
     $product = $this->retrieveDetail($products_id_to_copied, 'p,pd,pnc,cat');
     $product_to_applied = $this->retrieveDetail($products_id_to_copied, 'cat');
     $categories_is_same = $product['categories_id'] == $product_to_applied['categories_id'];
     $articles = $class_pa->retrieveList($products_id_to_copied);
     $articles_to_applied = $class_pa->retrieveList($products_id_to_applied);
     $add_length = array();
     $add_length_to_applied = array();
     if (isset($articles) && is_array($articles) && count($articles) > 0) {
         foreach ($articles as $a) {
             $add_length[] = $a['length'];
         }
     }
     if (isset($articles_to_applied) && is_array($articles_to_applied) && count($articles_to_applied) > 0) {
         foreach ($articles_to_applied as $ata) {
             $add_length_to_applied[] = $ata['length'];
         }
     }
     if (!is_array($products_id_to_applied)) {
         $products_id_to_applied = explode(',', $products_id_to_applied);
     }
     if ($options != '*') {
         $options = explode(',', $options);
     }
     //START UPDATE PRODUCT DETAIL TO ALL PRODUCTS WHICH PRODUCT DETAIL IS NOT FILLED
     foreach ($products_id_to_applied as $pid) {
         if ($options == '*' || in_array('cp', $options)) {
             //APPLY COLOR PATTERN
             $cps = $this->loadColorPattern($products_id_to_copied);
             if (count($cps) > 0) {
                 saveColors($pid, implode(',', $cps));
             }
         }
         if ($options == '*' || in_array('b', $options)) {
             //APPLY BRAND
             use_class('products_brand');
             $class_pb = new products_brand();
             $class_pb->updateProductBrand($pid, $product['p']['products_brand_id']);
         }
         if (($options == '*' || in_array('l', $options)) && $categories_is_same) {
             //APPLY LENGTH
             $def_length = $product['pnc']['products_length'];
             $this->saveLength($pid, $def_length, $add_length);
         }
         if ($options == '*' || in_array('eu', $options)) {
             //TODO: CHECK HOW TO ALSO COPY ELEMENTS IF OTHER PRODUCTS STILL DOESN'T HAVE ANY
             //APPLY ELEMENT USED & QTY
             $el_used = $this->retrieveElementsUsage($products_id_to_copied);
             if (count($el_used) > 0) {
                 $elids = array();
                 $elqtys = array();
                 foreach ($el_used as $elid => $el_data) {
                     if ($have_element_to_exclude) {
                         $check_key = array_search($elid, $elements_id_to_exclude);
                         if ($check_key !== false) {
                             continue;
                         }
                     }
                     $elids[] = $elid;
                     $elqtys[] = $el_data['quantity'];
                 }
                 $this->addElementToProducts($pid, $elids, $elqtys);
             }
             //APPLY OVERRIDE ELEMENTS (IF EXISTS) AND HAVE SAME ADDITIONAL LENGTH COMPOSITION
             if (count($add_length) > 0 && $categories_is_same) {
                 $have_same_add_length_composition = true;
                 if (count($add_length) == count($add_length_to_applied)) {
                     foreach ($add_length as $al) {
                         if (!in_array($al, $add_length_to_applied)) {
                             $have_same_add_length_composition = false;
                             break;
                         }
                     }
                 } else {
                     $have_same_add_length_composition = false;
                 }
                 if ($have_same_add_length_composition || $skip_same_add_length_composition) {
                     foreach ($add_length as $length) {
                         $dbq_o = tep_db_query("SELECT * FROM products_articles WHERE products_id = {$products_id_to_copied} AND length = {$length}");
                         $dbq_c = tep_db_query("SELECT * FROM products_articles WHERE products_id = {$pid} AND length = {$length}");
                         if (tep_db_num_rows($dbq_o) > 0 && tep_db_num_rows($dbq_c) > 0) {
                             $r_o = tep_db_fetch_array($dbq_o);
                             $r_c = tep_db_fetch_array($dbq_c);
                             $products_articles_id = $r_c['products_articles_id'];
                             $dbq_ovr = tep_db_query("SELECT * FROM products_articles_use_elements WHERE products_articles_id = {$r_o['products_articles_id']}");
                             while ($r_ovr = tep_db_fetch_array($dbq_ovr)) {
                                 $ovr_elid = $r_ovr['elements_id'];
                                 $dbq_pue_o = tep_db_query("SELECT * FROM products_use_elements WHERE products_use_elements_id = {$r_ovr['products_use_elements_id']}");
                                 $r_pue_o = tep_db_fetch_array($dbq_pue_o);
                                 $dbq_pue_c = tep_db_query("SELECT * FROM products_use_elements WHERE products_id = {$pid} AND elements_id = {$r_pue_o['elements_id']}");
                                 $r_pue_c = tep_db_fetch_array($dbq_pue_c);
                                 $products_use_elements_id = $r_pue_c['products_use_elements_id'];
                                 $ovr_data = array();
                                 if ($have_element_to_exclude) {
                                     $check_key = array_search($r_ovr['elements_id'], $elements_id_to_exclude);
                                     if ($check_key !== false) {
                                         continue;
                                     }
                                 }
                                 $ovr_data['elements_id'] = $r_ovr['elements_id'];
                                 $ovr_data['quantity'] = $r_ovr['quantity'];
                                 $ovr_data['products_articles_id'] = $products_articles_id;
                                 $ovr_data['products_use_elements_id'] = $products_use_elements_id;
                                 $class_pa->overrideElement($products_articles_id, $products_use_elements_id, $ovr_data);
                             }
                         }
                     }
                 }
             }
         }
         if ($options == '*' || in_array('mp', $options)) {
             //APPLY MANUAL PI
             $dbqmp = tep_db_query("SELECT * FROM products_non_configurator pnc WHERE pnc.products_id={$products_id_to_copied}");
             $mpi = tep_db_fetch_array($dbqmp);
             saveManualPI($pid, $mpi['products_instruction']);
         }
         if ($options == '*' || in_array('pl', $options)) {
             //APPLY PRODUCTS LINKING
             use_class('products_linking');
             $class_pl = new products_linking();
             $dbqpl = tep_db_query("SELECT * FROM products_linking WHERE products_id={$products_id_to_copied}");
             while ($r = tep_db_fetch_array($dbqpl)) {
                 $links_id = $r['links_id'];
                 $type = $r['type'];
                 $class_pl->add($pid, $type, $links_id, true);
             }
         }
         if ($options == '*' || in_array('ni', $options)) {
             //APPLY NAVID's
             use_class('jng_sp_catalog');
             $class_jc = new jng_sp_catalog();
             $dbq = tep_db_query("SELECT jng_sp_id, navigation, navigation2, navigation3 FROM jng_sp_catalog WHERE products_id={$products_id_to_copied} ORDER BY jng_sp_id");
             while ($r = tep_db_fetch_array($dbq)) {
                 $nav = $r['navigation'];
                 $nav2 = $r['navigation2'];
                 $nav3 = $r['navigation3'];
                 $class_jc->addProduct($r['jng_sp_id'], $pid);
                 $p_cat = $class_jc->retrieveCatalog($r['jng_sp_id'], "jc.products_id = '{$pid}'");
                 saveCatalog($p_cat[0]['jng_sp_catalog_id'], 'navigation', $nav);
                 saveCatalog($p_cat[0]['jng_sp_catalog_id'], 'navigation2', $nav2);
                 saveCatalog($p_cat[0]['jng_sp_catalog_id'], 'navigation3', $nav3);
             }
         }
     }
 }