/**
  * 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');
 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;
 }