/**
  * Get all key and name/label of all active product attributes group
  * @return Array Array of style groups with group id as array key and group
  *     name as array value
  */
 public static function getAttributeGroups()
 {
     //Please sort array by the name
     $groups = array();
     $groups[self::GROUP_ID_CARELABEL] = 'Care Label';
     $groups[self::GROUP_ID_COLLECTION] = 'Collection';
     //$groups[self::GROUP_ID_COLOR] = 'Color';
     $groups[self::GROUP_ID_COMPOSITION] = 'Composition';
     $groups[self::GROUP_ID_FASHION_GRADE] = 'Fashion Grade';
     $groups[self::GROUP_ID_FASHION_STYLE] = 'Fashion Style';
     $groups[self::GROUP_ID_MATERIAL] = 'Material Characteristic';
     $groups[self::GROUP_ID_PACKAGE_CONTENT] = 'Package Content';
     $groups[self::GROUP_ID_PACKAGING] = 'Packaging';
     $groups[self::GROUP_ID_PATTERN] = 'Pattern';
     $groups[self::GROUP_ID_PRODUCT_FINISHING] = 'Product Finishing';
     $groups[self::GROUP_ID_SHAPE] = 'Product Shape';
     $groups[self::GROUP_ID_ORIGIN] = 'Production Country';
     $groups[self::GROUP_ID_STYLE] = 'Style';
     //SUBCATEGORY:
     $sub_category_title = 'Sub Category';
     //OLD SUBCATEGORY GROUP
     //$groups[self::GROUP_ID_SUB_CATEGORY] = $sub_category_title;
     //SUB CATEGORY IS NOW BASED ON TOP CATEGORY
     while ($ct = CategoryTop::getOneByOneAsObject()) {
         $groups[$ct->getSubCategoryGroup()] = $sub_category_title . ' ' . $ct->name;
     }
     $groups[self::GROUP_ID_SYMBOL] = 'Symbol';
     $groups[self::GROUP_ID_TOPIC] = 'Topic';
     $groups[self::GROUP_ID_WEEK] = 'Week';
     return $groups;
 }
$cellsizecollweek = $cellsize + $margin;
$cell_height_col = 55;
$cell_height = 5;
$pdf->setXY($margin, $ypos);
$pdf->setFont('Arial', 'B', '14');
$pdf->cell(240, 5, 'SALES REPORT WEEKLY PRODUCT KW ' . date('W') . ' (' . date('d.m.Y', strtotime($filter_date)) . ')', 0, 0, 'C');
$pdf->setFont('Arial', '', '10');
$ypos += 10;
$pdf->setXY($cellstart, $ypos);
$firstorder = true;
$no = 1;
$catids = load_config('products-categories-sorting');
if (SERVER_IS_LOCAL) {
    use_class('CategoryTop');
    //load all categories which not sorted
    while ($ct = CategoryTop::getOneByOneAsObject()) {
        if ($ct->getCategoriesTotalCount() > 0) {
            while ($cat = $ct->getCategoriesOneByOneAsObject()) {
                if (!in_array($cat->id, $catids)) {
                    $catids[] = $cat->id;
                }
            }
        }
    }
}
foreach ($catids as $catid) {
    $header = true;
    if (is_array($products[$catid])) {
        foreach ($products[$catid] as $pid => $p) {
            if ($ypos >= 165 || $no == 1 && $firstorder == false) {
                $pdf->AddPage('L');
 /**
  * Get all category top as object one by one
  * will return false after all is loaded
  * @return CategoryTop The requested category top as an object 
  *      or false if not found
  */
 public static function getOneByOneAsObject()
 {
     if (is_null(self::$last_loaded_key)) {
         self::loadAll();
         self::$last_loaded_key = 0;
     } else {
         self::$last_loaded_key++;
     }
     if (isset(self::$existing_ids[self::$last_loaded_key])) {
         $id = self::$existing_ids[self::$last_loaded_key];
         $result = new CategoryTop($id);
     } else {
         $result = false;
         self::$last_loaded_key = null;
     }
     return $result;
 }
<?php

use_class('CategoryTop');
$lid = LANGUAGEID;
$ctid = tep_db_prepare_input($_GET['ctid']);
$ct = new CategoryTop($ctid);
$row_per_page_in_list = 10;
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'LOADLIST') {
        $page = tep_db_prepare_input($_POST['page']);
        //currently we don't support the paging function yet
        $otto_sp_id = '2';
        $spm = getSellingPointMatrix(null, null, $otto_sp_id);
        if ($ct->getCategoriesTotalCount() == 0) {
            $cat_list = '<h3 class="red">No Category found in database</h3>';
        } else {
            $table_cat = array();
            $c = array();
            //$c['so w080'] = 'Sort';
            $c['nm w200'] = 'Name';
            $c['id w080'] = 'ID';
            $c['pr w080'] = 'Product Code Prefix';
            $c['sp w080'] = 'Selling<br />Points';
            $c['ac w300'] = 'Action';
            $table_cat[] = $c;
            while ($cat = $ct->getCategoriesOneByOneAsObject()) {
                $parent = $cat->getParent();
                $cid = $cat->id;
                $cname = $cat->getName($lid);
                $prefix = $cat->getProductCodePrefix();
                if ($prefix == "") {
Beispiel #5
0
 $content .= '</div>';
 //    $content .= '<div id="cat-top" style="margin-bottom:20px;width:220px;">';
 //    $content .= '<fieldset>';
 //    $content .= '<legend>Top Categories</legend>';
 //    $content .= '<label class="bold">Select top category</label>';
 //    $content .= '<p>'.CategoryTop::displayAsComboBox('cmb-top-cat', '', '', '', '', false, '', false, '1').'<input type="button" class="input button" id="cat-top-button" value="Choose" style="width:70px;margin-left:10px;"></p>';
 //    $content .= '</fieldset>';
 //    $content .= '</div>';
 $content .= '<div style="margin-bottom:20px;width:350px;" id="generate-cat-div">';
 //DIV OPEN "generate-cat-div"
 $content .= '<fieldset>';
 if (SERVER_IS_LOCAL) {
     $content .= '<legend>Generate Catalog File</legend>';
     $content .= '<div id="cat-top" style="margin-bottom:20px;width:220px;">';
     $content .= '<label class="bold">Top Category</label>';
     $content .= '<p style="padding:0;margin:0;">' . CategoryTop::displayAsComboBox('cmb-top-cat', '', '', '', 'width:180px;', false, '', false, '1') . '</p>';
     $content .= '</div>';
     $content .= '<label class="bold">Catalog Status</label><p style="padding:0;margin:0;"><div id="catalog-status"></div></p>';
 }
 $content .= '<input id="btn-gen-catalog" type="button" name="generatexml" value="Generate Catalog File" />';
 if (is_array($last_success_full)) {
     $content .= '<div style="clear:both;padding:15px 0;">';
     $content .= '<div class="bold">Last Successfull Upload:</div>';
     //        $content .= '<div><table border="0" cellpadding="0" cellspacing="0">';
     $content .= '<p style="padding:0;margin:0;">';
     if (is_array($last_success_full)) {
         //            $content .= '<tr><td>'.date('d.m.Y H:i:s', strtotime($last_success_full['upload_time'])).'</td></tr>';
         $content .= date('d.m.Y H:i:s', strtotime($last_success_full['upload_time']));
     }
     //        $content .= '</table></div>';
     $content .= '</p>';
 private function renderFilter()
 {
     use_class('jng_sp');
     use_class('products_brand');
     use_class('CategoryTop');
     $class_sp = new jng_sp();
     $class_pb = new products_brand();
     $sp_datas = $class_sp->retrieveList();
     $brands = $class_pb->retrieveList("active_status='1'");
     //FILTER Order Type
     $order_type_selected = self::getSession(self::FILTER_ORDER_TYPE);
     $order_types = array(self::ORDER_TYPE_ALL => 'All Orders', self::ORDER_TYPE_JG => 'JG Orders');
     $order_type_groups['SP Orders'][self::ORDER_TYPE_SP] = 'All SP Orders';
     foreach ($sp_datas as $sp_id => $sp_data) {
         $order_type_groups['SP Orders'][$sp_id] = $sp_data['name'];
     }
     $order_type_groups['Depot Orders'] = $this->DP_ORDER_TYPES;
     $filter_order_type = '<select name="' . self::FILTER_ORDER_TYPE . '" class="cbo_filters">' . loadComboListFromArray($order_types, null, $order_type_selected, true, $order_type_groups) . '</select>';
     /* Filter SP now merged into Filter Order Type
        array_unshift($sp_datas, array(self::FILTER_SP_ID => '0', 'name' => 'All Sales Partners'));
        $filter_sp = $class_sp->drawCombo($sp_datas, $this->filters_sp_id, '', self::FILTER_SP_ID, 'cbo_filters');
         */
     //FILTER Brand
     $brand_options = array();
     $brand_options[0] = 'Show All Brands';
     foreach ($brands as $b) {
         $brand_options[$b['products_brand_id']] = $b['brand_name'];
     }
     $filter_brand = '<select name="' . self::FILTER_BRAND_ID . '" class="cbo_filters">' . loadComboListFromArray($brand_options, null, $this->filters_brand_id, false) . '</select>';
     //FILTER Category
     $category_selected = self::getSession(self::FILTER_CAT_ID);
     $categories = array('' => 'Show All Categories');
     $category_groups = array();
     while ($ct = CategoryTop::getOneByOneAsObject()) {
         if ($ct->getCategoriesTotalCount() > 0) {
             while ($cat = $ct->getCategoriesOneByOneAsObject()) {
                 if ($cat->getProductCodePrefix() != "") {
                     $category_groups[$ct->name][$cat->id] = $cat->getName(1);
                 }
             }
         }
     }
     $filter_category = '<select name="' . self::FILTER_CAT_ID . '" class="cbo_filters">' . loadComboListFromArray($categories, null, $category_selected, true, $category_groups) . '</select>';
     /*
             $filter_category = 
            comboProductsCategory(
                    self::FILTER_CAT_ID
                    , self::FILTER_CAT_ID
                    , $this->filters_cat_id
                    , 'cbo_filters'
                    , ''
                    , 'Show All Category');
     */
     //FILTER Product ID/EAN
     $filter_prod_search = '<input type="text" name="' . self::FILTER_LIST_EAN . '" class="txt_filters input" value="' . $this->filters_list_ean . '" />';
     //FILTER Order No.
     $filter_orders_no = '<input type="text" name="' . self::FILTER_LIST_ORDERS_NO . '" class="txt_filters" value="' . $this->filters_list_orders_no . '" />';
     //FILTER Lead Time Start Date
     $filter_leadtime = '<input name="' . self::FILTER_LEADTIME_START_DATE . '" class="date_picker" value="' . $this->filters_leadtime_date_start . '"/>' . ' to <input name="' . self::FILTER_LEADTIME_END_DATE . '" class="date_picker" value="' . $this->filters_leadtime_date_end . '"/>' . ' <input type="button" value="Go" class="btn_filters_leadtime_go" ' . 'title="Apply lead time start date filter" />' . ' <input type="button" value="Clear" class="date_range_clear" ' . 'title="Clear lead time start date filter" />';
     $enter_info = '<span class="notice smallText" style="font-weight:normal;">' . '(press <em>Enter</em> to filter)</span>';
     $result .= '<div style="margin-bottom:10px;">';
     $result .= '<table border="0" cellpadding="0" cellspacing="0">';
     $result .= '<tr>';
     $result .= '<td class="bold">Order Type</td>';
     //$result .= '<td class="bold">Sales Partner</td>';
     $result .= '<td class="bold">Brand</td>';
     $result .= '<td class="bold">Category</td>';
     $result .= '<td class="bold">Product ID/EAN ' . $enter_info . '</td>';
     $result .= '<td class="bold">Order No. ' . $enter_info . '</td>';
     $result .= '<td class="bold">Lead Time Start Date</td>';
     $result .= '</tr>';
     $result .= '<tr>' . '<td>' . $filter_order_type . '</td>' . '<td>' . $filter_brand . '</td>' . '<td>' . $filter_category . '</td>' . '<td>' . $filter_prod_search . '</td>' . '<td>' . $filter_orders_no . '</td>' . '<td>' . $filter_leadtime . '</td>' . '</tr>';
     $result .= '</table></div>';
     return $result;
 }
                 $result .= '</tr>';
             }
         }
     }
     $result .= '</table></div>';
     echo utf8_encode($result);
     exit;
 } elseif ($_POST['me_action'] == 'LOADCATS') {
     $param_code = 'V';
     $category_top_id = tep_db_prepare_input($_POST['ctid']);
     $genders = Product::getOldProductFunction()->productGenderName();
     unset($genders[0]);
     //none
     unset($genders[3]);
     //unisex
     $obj_ct = new CategoryTop($category_top_id);
     $cats = array();
     while ($cat = $obj_ct->getCategoriesOneByOneAsObject()) {
         $cats[$cat->id] = $cat->getName(LANGUAGEID);
     }
     ProductAttribute::getOldStylesFunction()->retrieveList($obj_ct->getSubCategoryGroup());
     if (in_array($jng_sp_id, array(1005))) {
         //get from Primary Navigation (Navigation for this SP separated between Primary and Secondary)
         $navids = retrieveNavIDs($jng_sp_id, 'c');
     } else {
         //Navigation are used for both Primary and Additional
         $navids = retrieveNavIDs($jng_sp_id, '');
     }
     $params = $class_jpc->loadAsMapper($jng_sp_id, $param_code);
     if (count($cats) == 0) {
         $result = '<h3 class="red">No Categories found</h3>';
 /**
  * Build input for $filters
  * @return string
  */
 private function createFiltersInput()
 {
     // >,>=,=,<=,<
     $input .= $this->createInputTextRange('filters-prod-id', 'products id', '', '', '', '', true);
     $input .= $this->createInputTextRange('filters-prod-price', 'price', '', '', ' ' . DEFAULT_CURRENCY, 'currency');
     $input .= $this->createInputTextRange('filters-prod-age', 'days');
     $input .= $this->createInputTextRange('filters-prod-disc', 'discount % ', 3, '', '%');
     $input .= $this->createInputTextRange('filters-prod-vc', 'vc ');
     $input .= $this->createInputTextRange('filters-prod-vcpct', 'vc % ', '', '', '%');
     $input .= $this->createInputTextRange('filters-prod-margin', 'margin % ', '', '', '%');
     $input .= $this->createInputTextRange('filters-prod-soldlast30', 'pieces', '', '', ' pieces');
     $input .= $this->createInputTextRange('filters-prod-soldlast60', 'pieces', '', '', ' pieces');
     $input .= $this->createInputTextRange('filters-prod-soldlast90', 'pieces', '', '', ' pieces');
     for ($y = product::STATIC_LOG_YEAR_START; $y <= date('Y'); $y++) {
         $input .= $this->createInputTextRange('filters-prod-sold' . $y, 'pieces', '', '', ' pieces');
     }
     $input .= $this->createInputTextRange('filters-prod-totalsold', 'pieces', '', '', ' pieces');
     $input .= $this->createInputTextRange('filters-prod-stars', 'stars', '', '', ' stars');
     $input .= $this->createInputTextRange('filters-prod-matexp', 'amount on EUR', '', '', ' EUR');
     $input .= $this->createInputTextRange('filters-hh-stock', 'pieces', '', '', ' pieces');
     $input .= $this->createInputTextRange('filters-prod-deflength', 'default length');
     $input .= $this->createInputTextRange('filters-prod-returnrate', 'return %');
     $input .= $this->createInputTextRange('filters-pd2-ttlstones', 'pieces', '', '', ' pieces');
     $input .= $this->createInputTextRangeDate('filters-date-killed');
     $input .= $this->createInputTextRangeDate('filters-date-keep');
     $input .= $this->createInputTextRangeDate('filters-date-keep-exclude');
     $input .= $this->createInputTextRangeDate('filters-date-finalized');
     // =, != with input free text
     $input .= $this->createInputTextEqualOrNot('filters-el-used', 'elements id', '', '', '', true);
     $input .= $this->createInputTextEqualOrNot('filters-prod-ean', 'product ean', '', '', '', true);
     $input .= $this->createInputTextEqualOrNot('filters-prod-model', 'products model', '', '', '', true);
     // like %input%, not like %input%
     $input .= $this->createInputTextContainOrNot('filters-prod-name', 'name');
     $input .= $this->createInputTextContainOrNot('filters-prod-description', 'description');
     $input .= $this->createInputTextContainOrNot('filters-prod-promoname', 'promoname');
     // =, != with input drop down combo
     //prepare data combo
     $combo_element_finishing = $this->createCombo('filters-el-finishing', 'status', array('1' => 'Yellow Goldplate', '11' => 'Hammer', '111' => 'Brush', '1111' => 'Oxid', '11111' => 'Rose Goldplate'), null, null);
     $combo_prod_clearimage = $this->createCombo('filters-prod-clearimage', 'status', array('0' => 'Has NO Clear Image', '1' => 'Has a Clear Image'), null, null);
     $combo_prod_complexity = $this->createCombo('filters-prod-complexity', 'status', productComplexityName(), null, null);
     $combo_prod_content = $this->createCombo('filters-prod-content', 'status', array('0' => 'NOT Improved', '1' => 'Improved'), null, null);
     $combo_prod_discounted = $this->createCombo('filters-prod-discounted', 'status', array('0' => 'No', '1' => 'Yes'), null, null);
     $combo_prod_family = $this->createCombo('filters-prod-family', 'status', array('0' => 'Has NO Family', '1' => 'Has a Family'), null, null);
     $combo_prod_image = $this->createCombo('filters-prod-image', 'status', array('0' => 'NOT Improved', '1' => 'Improved'), null, null);
     $combo_prod_margin_status = $this->createCombo('filters-prod-margin-status', 'status', array('0' => 'Bad', '1' => 'Good'), null, null);
     $combo_prod_outsourced = $this->createCombo('filters-prod-outsourced', 'status', array('0' => 'No (Produce in House)', '1' => 'Yes (Outsourced)'), null, null);
     $combo_prod_wholesale = $this->createCombo('filters-prod-wholesale', 'status', array('0' => 'No', '1' => 'Yes'), null, null);
     //prepare input filters
     // =
     $input .= $this->createInputComboEqual('filters-prod-clearimage', '', '', '', '', null, '', '', false, $combo_prod_clearimage);
     $input .= $this->createInputComboEqual('filters-prod-content', '', '', '', '', null, '', '', false, $combo_prod_content);
     $input .= $this->createInputComboEqual('filters-prod-discounted', '', '', '', '', null, '', '', false, $combo_prod_discounted);
     $input .= $this->createInputComboEqual('filters-prod-family', '', '', '', '', null, '', '', true, $combo_prod_family);
     $input .= $this->createInputComboEqual('filters-prod-image', '', '', '', '', null, '', '', false, $combo_prod_image);
     $input .= $this->createInputComboEqual('filters-prod-outsourced', '', '', '', '', null, '', '', false, $combo_prod_outsourced);
     $input .= $this->createInputComboEqual('filters-prod-wholesale', '', '', '', '', null, '', '', false, $combo_prod_wholesale);
     // =, !=
     $input .= $this->createInputComboEqualOrNot('filters-el-finishing', 'finishing', '', '', '', null, '', '', false, $combo_element_finishing);
     $input .= $this->createInputComboEqualOrNot('filters-prod-brand', '', '', '', '', null, '', '', true, comboProductsBrand('filters-prod-brand', '', '', 'filters-val', 'style="display:none;margin-left:20px;"'));
     $input .= $this->createInputComboEqualOrNot('filters-prod-cat-top', '', '', '', '', null, '', '', true, CategoryTop::displayAsComboBox('filters-prod-cat-top', '', '', 'filters-val', 'display:none;margin-left:20px;'));
     $input .= $this->createInputComboEqualOrNot('filters-prod-cat', '', '', '', '', null, '', '', true, comboProductsCategory('filters-prod-cat', '', '', 'filters-val', 'style="display:none;margin-left:20px;"'));
     $input .= $this->createInputComboEqualOrNot('filters-prod-description-imp-stat', '', '', '', '', null, '', '', true, comboProductsDescriptionImprovedStatus('filters-prod-description-imp-stat', '', '', 'filters-val', 'style="display:none;margin-left:20px;"'));
     $input .= $this->createInputComboEqualOrNot('filters-prod-color', 'color', 'color_pattern_description', 'color_pattern_id', 'name', null, "languages_id = '1'", '', true);
     $input .= $this->createInputComboEqualOrNot('filters-prod-complexity', '', '', '', '', null, '', '', true, $combo_prod_complexity);
     $input .= $this->createInputComboEqualOrNot('filters-prod-margin-status', 'status', '', '', '', null, '', '', false, $combo_prod_margin_status);
     $input .= $this->createInputComboEqualOrNot('filters-prod-mat', 'material', 'products_materials', 'products_materials_id', 'material_name', null, '', '', true);
     $input .= $this->createInputComboEqualOrNot('filters-watchlist-of', '', '', '', '', null, '', '', true, comboWatchlistUsers('filters-watchlist-of', '', '', 'filters-val', 'style="display:none;margin-left:20px;"'));
     foreach ($this->class_styles->groups as $gk => $gv) {
         $input .= $this->createInputComboEqualOrNot("filters-prod-styles-{$gk}", 'attribute', 'styles s LEFT JOIN styles_description sd ON sd.styles_id=s.styles_id AND sd.languages_id=2', 's.styles_id', 'sd.name', null, "groups='{$gk}'", '', true);
     }
     return $input;
 }
             $chk_rad_1 = ' checked="checked"';
         } else {
             $chk_rad_0 = ' checked="checked"';
             $chk_rad_1 = '';
         }
     }
     $frm_separator = '<div>&nbsp;</div>';
     $result = '<h2>TOP Category Detail</h2>' . '<div>ID</div>' . '<div><input type="text" id="frm-inp-id" value="' . $id . '" readonly="readonly" class="w040 readonly" /></div>' . $frm_separator . '<div>Name</div>' . '<input type="text" id="frm-inp-name" class="w200" value="' . $name . '" />' . $frm_separator . '<div class="bold">Product Length/Size:</div>' . '<input type="radio" id="frm-rad-use-size-0" name="use_size"' . $chk_rad_0 . ' />' . ' <label for="frm-rad-use-size-0">Use length in cm</label><br />' . '<input type="radio" id="frm-rad-use-size-1" name="use_size"' . $chk_rad_1 . ' />' . ' <label for="frm-rad-use-size-1">Use preset values</label>' . $frm_separator . '<div id="frm-container-buttons">' . '<input type="button" id="frm-btn-save" value="' . $btn_val . '" />' . '<input type="button" id="frm-btn-cancel" value="Cancel" />' . '</div>' . '<div id="frm-container-status" style="margin-top:5px;' . 'display:none;"></div>';
     echo utf8_encode($result);
     exit;
 } elseif ($_POST['me_action'] == 'SAVEDETAIL') {
     $id = tep_db_prepare_input($_POST['detail_id']);
     $name = tep_db_prepare_input($_POST['name']);
     $is_using_size = $_POST['is_using_size'] == '1';
     if ($id > 0) {
         $ct = new CategoryTop($id);
         $updated = $ct->updateDetail($name, $is_using_size);
         if ($updated) {
             $update_msg = 'TOP Category is updated successfully';
         } else {
             $update_msg = 'Failed to update top category';
         }
     } else {
         $new_id = CategoryTop::createNewCategoryTop($name, $is_using_size);
         if ($new_id > 0) {
             $updated = true;
             $update_msg = 'New top category created with ID ' . $new_id;
         } else {
             $updated = false;
             $update_msg = 'Failed to create new top category ';
         }