Exemple #1
0
 function drawDetailTable($editable = true, $showImage = true, $columns = 1)
 {
     use_class('styles');
     $class_s = new styles();
     $design_id = $this->id;
     $original_products_id = $this->original_products_id;
     $element_id = $this->element_id;
     $prod_id_disabled = $this->original_products_id != '' ? ' readonly="readonly"' : '';
     $el_id_disabled = $this->element_id != '' ? ' readonly="readonly"' : '';
     $design_name = $this->name;
     $design_owner = ucfirst($this->owner_name);
     $attr_title = 'Product Attributes';
     if ($editable) {
         $sty_disabled = '';
         //$descat_disabled = ($showImage==='copy' || is_null($this->id) || $this->status=='1' || $this->status=='2' || $this->status=='11') ? '' : ' disabled="disabled"';
         $descat_disabled = ' disabled="disabled"';
         $prod_ref_hidden = true;
         $descat_hidden = '<input type="hidden" name="cat" value="' . $this->category . '" />';
         //used this to avoid cat value not submitted when its disabled
         #$destype_hidden = '<input type="hidden" name="type" value="'.$this->type.'" />';   //DISABLED (waiting status from design team need to activate or not)
         if ($showImage === 'copy' || is_null($this->id) || $this->status == '1' || $this->status == '2' || $this->status == '11') {
             $descat_disabled = '';
             $descat_hidden = '';
             $prod_id_disabled = '';
             $prod_ref_hidden = false;
             #$destype_hidden = '';  //DISABLED (waiting status from design team need to activate or not)
         }
         #$destype_disabled = $descat_disabled; //DISABLED (waiting status from design team need to activate or not)
         $destype_array[""] = 'Please select...';
         $descat_array[""] = 'Please select...';
         $destype_array = array_merge($destype_array, $this->getDesignType());
         $descat_array = array_merge($descat_array, $this->getDesignCategory());
         if (is_null($this->id)) {
             if ($this->category == 'R') {
                 $descat_array = array('R' => 'Recombination');
             } elseif ($this->category == 'W') {
                 $descat_array = array('W' => 'New Wax');
             } elseif ($this->category == 'E') {
                 $descat_array = array('E' => 'Revision');
             }
             //elseif($this->category=='V') $descat_array = array('V'=>'Variation');
             //elseif($this->category=='RV') $descat_array = array('R'=>'Recombination', 'V'=>'Variation');
         }
         $design_id = '<input type="text" name="designs_id" class="input" value="' . $design_id . '" readonly="readonly" />';
         $design_owner = '<input type="text" name="owner_name" class="input" value="' . $design_owner . '" disabled="disabled" />';
         $designtype_combo = '<select id="type" name="type" class="input"' . $destype_disabled . '>' . loadComboListFromArray($destype_array, '', $this->type, false) . '</select>';
         $designcat_combo = $descat_hidden . '<select id="cat" name="cat" class="input"' . $descat_disabled . '>' . loadComboListFromArray($descat_array, '', $this->category, false) . '</select>';
         $procat_combo = comboProductsCategory('procat', 'procat', $this->products_category_id, 'input');
         $probra_combo = comboProductsBrand('probra', 'probra', $this->products_brand_id, 'input');
         $original_products_id = '<input type="text" id="products_id" name="products_id" class="input" ' . $prod_id_disabled . ' value="' . $original_products_id . '" maxlength="32" />';
         $original_products_id .= '<br /><small class="notice">Seperate multiple ID by comma</small>';
         $element_id = '<input type="text" id="element_id" name="element_id" class="input" ' . $el_id_disabled . ' value="' . $element_id . '" maxlength="32" />';
         $design_name = '<input type="text" id="name" name="name" class="input" value="' . $design_name . '" /></td>';
         $target_price = '<input type="text" id="price" name="price" class="input" value="' . $this->target_price . '" /> <span class="notice">EUR</span>';
         $option_none = '<option value="0">Please select attribute...</option>';
         $attr_title .= ' <span class="notice smallText">(optional)</span>';
         $attr_collection = '<select name="styles_id_L" class="input"' . $sty_disabled . '>' . $option_none . $class_s->drawComboOptions($this->styles_id_L, 'L') . '</select>';
         //            $attr_fashiongrd = '<select name="styles_id_F" class="input"'.$sty_disabled.'>'.$option_none.$class_s->drawComboOptions($this->styles_id_F, 'F').'</select>';
         $design_structures = array(1 => 'Open', 2 => '100% Copy', 3 => 'Similar');
         $design_structure = '<select name="structure_id" class="input"' . $desstruct_disabled . '><option value="">Please select structure...</option>' . loadComboListFromArray($design_structures, null, $this->structure_id) . '</select>';
         $design_contents = array(1 => 'Open', 2 => '100% Copy', 3 => 'Similar', 4 => '30% Deviation MUST');
         $design_content = '<select name="content_id" class="input"' . $descont_disabled . '><option value="">Please select content...</option>' . loadComboListFromArray($design_contents, null, $this->content_id) . '</select>';
     } else {
         global $product_categories_name;
         global $products_brands_name;
         $sty_disabled = ' disabled="disabled"';
         $designtype_combo = $this->getDesignType($this->type);
         $designcat_combo = $this->getDesignCategory($this->category);
         $procat_combo = $product_categories_name[$this->products_category_id];
         $probra_combo = $product_brands_name[$this->products_brand_id];
         $original_products_id = '<a href="?open=product-detail&amp;products_id=' . $original_products_id . '">' . $original_products_id . '</a>';
         $element_id = '<a href="?open=element&amp;id=' . $element_id . '">' . $element_id . '</a>';
         $target_price = $this->target_price . ' EUR';
         $styles = $class_s->retrieveList('', "s.styles_id IN ({$this->styles_id_L}, {$this->styles_id_F})");
         $styles_name = array();
         foreach ($styles as $style) {
             $styles_name[$style['styles_id']] = $style['name'];
         }
         $attr_collection = $this->styles_id_L > '0' ? $styles_name[$this->styles_id_L] : '<span class="notice">Unset</span>';
         //            $attr_fashiongrd = ($this->styles_id_F>'0') ? $styles_name[$this->styles_id_F] : '<span class="notice">Unset</span>';
     }
     $content = '';
     if (!$editable && $showImage && $columns == 2) {
         $img = webImage($this->image_1, '80', '80', 'Image 1', 'img-border');
         $img .= $this->image_2 != '' ? '<br /><br />' . webImage($this->image_2, '80', '80', 'Image 2', 'img-border') : '';
         $img .= $this->image_3 != '' ? '<br /><br />' . webImage($this->image_3, '80', '80', 'Image 3', 'img-border') : '';
         $img .= $this->image_4 != '' ? '<br /><br />' . webImage($this->image_4, '80', '80', 'Image 4', 'img-border') : '';
         $content .= '<div style="float:left;margin:7px 5px 0 0;">' . $img . '</div>';
     }
     $content .= '<div><table class="form" border="0" cellpadding="0" cellspacing="0">';
     if (!is_null($this->id)) {
         if (!$editable && $showImage && $columns == 1) {
             //                $img1 = webImage($this->image_1, '150', '150', 'Main Image', 'img-border').' ';
             $img1 = webImage($this->image_1, '80', '80', 'Image 1', 'img-border') . ' ';
             //                $img2 = webImage($this->image_2, '150', '150', 'Additional Image', 'img-border');
             $img2 = webImage($this->image_2, '80', '80', 'Image 2', 'img-border');
             $img3 = webImage($this->image_3, '80', '80', 'Image 3', 'img-border');
             $img4 = webImage($this->image_4, '80', '80', 'Image 4', 'img-border');
             $content .= '<tr><td>' . $img1 . '</td><td>' . $img2 . '</td><td>' . $img3 . '</td>' . $img4 . '<td></td></tr>';
         }
         if ($editable !== 'copy') {
             $content .= '<tr><td>Design ID</td><td>' . $design_id . '</td></tr>';
         }
     }
     $content .= '<tr><td class="label">Design Created by</td><td>' . $design_owner . '</td></tr>';
     //$hide_ori_pid = ($this->category=='R' || $this->category=='V') ? false : true;
     //        echo "<pre>";var_dump($this);die();
     if ($prod_ref_hidden) {
         $hide_ori_pid = $prod_ref_hidden && $this->original_products_id != '' ? false : true;
     } else {
         $hide_ori_pid = $prod_ref_hidden;
     }
     $content .= '<tr><td class="label">Design Type</td><td width="230">' . $designtype_combo . '</td></tr>';
     $content .= '<tr><td class="label">Design Category</td><td width="230">' . $designcat_combo . '</td></tr>';
     $content .= '<tr id="oriprodid"' . ($hide_ori_pid ? ' style="display:none;' : '') . '"><td>Product ID (Original)</td><td>' . $original_products_id . '</td></tr>';
     $content .= '<tr><td>Element ID</td><td>' . $element_id . '</td></tr>';
     $content .= '<tr><td>Product Category</td><td>' . $procat_combo . '</td></tr>';
     $content .= '<tr><td>Product Brand</td><td>' . $probra_combo . '</td></tr>';
     $content .= '<tr><td>' . (is_null($this->id) ? 'New ' : '') . 'Design Name</td><td>' . $design_name . '</tr>';
     $content .= '<tr><td>Design Structure</td><td>' . $design_structure . '</td></tr>';
     $content .= '<tr><td>Design Content</td><td>' . $design_content . '</td></tr>';
     $content .= '<tr><td>Target Price</td><td>' . $target_price . '</td></tr>';
     $content .= '<tr><td colspan="2" class="bold" style="padding-top:20px;">' . $attr_title . '</td></tr>';
     $content .= '<tr><td>Collection</td><td>' . $attr_collection . '</td></tr>';
     //        $content .= '<tr><td>Fashion Grade</td><td>'.$attr_fashiongrd.'</td></tr>';
     if ($showImage === 'copy') {
         $status_combo = '<select name="status" class="input red bold">' . loadComboListFromArray($this->getDesignStatus(array('1', '2')), null, $this->status, false) . '</select>';
         $content .= '<tr><td class="red bold">NEW Status</td><td>' . $status_combo . '</td></tr>';
     }
     $content .= '</table></div>';
     return $content;
 }
 //    $q .= " WHERE d.status IN (1,2,3,4,5,6,7,8,10,11,12)";
 $q .= " WHERE d.status IN (1,2,3,4,5,6,7,8,10,11,12,13,14)";
 $q .= " GROUP BY owner_id ORDER BY owner_name";
 $r = tep_db_query($q);
 while ($row = tep_db_fetch_array($r)) {
     $designers[$row['owner_id']] = "{$row['owner_name']} ({$row['totaldes']})";
 }
 use_class('styles');
 $class_s = new styles();
 $designs_filter .= '<div class="filter_desown" style="margin-bottom:5px;float:left;"><strong style="margin-right:5px;">Designer</strong><select><option value="0">Show All</option>' . loadComboListFromArray($designers, null, $designs_owner) . '</select></div>';
 $designs_filter .= '<div class="filter_destype" style="margin-bottom:5px;float:left;"><strong style="margin:0 5px 0 20px;">Design Type</strong><select><option value="0">Show All</option>' . loadComboListFromArray(design::getDesignType(), null, $designs_type) . '</select></div>';
 $designs_filter .= '<div class="filter_descat" style="margin-bottom:5px;float:left;"><strong style="margin:0 5px 0 20px;">Design Category</strong><select><option value="0">Show All</option>' . loadComboListFromArray(design::getDesignCategory(), null, $designs_category) . '</select></div>';
 $pcs = getProductsCategorySupportData();
 $prodcats .= loadComboList($pcs['tables'], $pcs['field_id'], $pcs['field_name'], $products_category, $pcs['filter']);
 $designs_filter .= '<div class="filter_prodcat" style="margin-bottom:5px;float:left;"><strong style="margin:0 5px 0 20px;">Product Category</strong><select><option value="0">Show All</option>' . $prodcats . '</select></div>';
 $designs_filter .= '<div class="filter_collection" style="margin-bottom:5px;' . ($status > 2 ? 'float:left;' : '') . '"><strong style="margin:0 5px 0 20px;">Collection</strong><select><option value="0">Show All</option>' . $class_s->drawComboOptions($styles_id_L, 'L', null, '', 'sd.name') . '</select></div>';
 if ($status > 2) {
     $designs_filter .= '<div class="filter_leadtime" style="margin-bottom:5px;"><strong style="margin:0 5px 0 20px;">Lead Time</strong>' . leadTimeCombo($lead_time_value) . '</div>';
 }
 $designs_filter .= '<div style="margin:2px;clear:both;"> &sdot; <span class="smallText red">Sorting is available only for your Design which is on <strong>Ideas</strong> and <strong>Request</strong> Tab, and Filter by <strong>Category</strong> and <strong>Attributes</strong> is not used</div>';
 $filter = $styles_id_L <= 0 ? '' : " AND styles_id_L={$styles_id_L} ";
 if ($designs_type != '0') {
     $filter .= " AND d.designs_type='{$designs_type}' ";
 }
 if ($designs_category != '0') {
     $filter .= " AND d.designs_category='{$designs_category}' ";
 }
 if ($products_category != '0') {
     $filter .= " AND d.products_category_id={$products_category} ";
 }
 if ($designs_owner != '0') {
            $value = '&nbsp;';
        }
        $cols[$hk] = $value;
    }
    $productrow = '<tr id="temp-' . $pid . '">';
    foreach ($cols as $ck => $cv) {
        $productrow .= '<td class="' . $ck . '">' . $cv . '</td>';
    }
    $productrow .= '</tr>';
    return $productrow;
}
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'LOADATTRIBUTES') {
        $groupid = tep_db_prepare_input($_POST['groupid']);
        $choose = '<option value="0">-</option>';
        echo utf8_encode($choose . $class_s->drawComboOptions('', $groupid));
        exit;
    } elseif ($_POST['me_action'] == 'LOADPRODUCT') {
        $pid = tep_db_prepare_input($_POST['pid']);
        $pos = tep_db_prepare_input($_POST['pos']) + 1;
        $curgroup_id = tep_db_prepare_input($_POST['curgroup_id']);
        echo utf8_encode(loadProductRow($pid, $pos, $curgroup_id));
        exit;
    } elseif ($_POST['me_action'] == 'ADDATTRIBUTESPERPRODUCT') {
        $pid = tep_db_prepare_input($_POST['pid']);
        $pos = tep_db_prepare_input($_POST['pos']);
        $curgroup_id = tep_db_prepare_input($_POST['curgroup_id']);
        $newattr = array_unique($_POST['newattr']);
        $added = array();
        foreach ($newattr as $aid) {
            if ($aid > 0) {
 /**
  * Draw list of all attributes of a product for 1 specific attribute group. To add behavior for adding and removing attributes,
  * be sure to include the javascript behavior with function drawAttributesJSBehavior(). Javascript needed to be attached
  * only once even if you call drawAttributes function several times in 1 module.
  * @global Object $class_s styles object, will be auto created if none found
  * @param Int $products_id Product ID
  * @param String $attr_group Attribute Group
  * @return String html string of all attributes
  */
 function drawAttributes($products_id, $attr_group)
 {
     global $class_s;
     if (!is_object($class_s)) {
         use_class('styles');
         $class_s = new styles();
     }
     $attributes = $class_s->retrieveList($attr_group, "shp.products_id='{$products_id}'");
     $total_attrs = count($attributes);
     $icon_add_style = $total_attrs == 0 ? 'display:none;' : '';
     $form_style = $total_attrs == 0 ? '' : 'display:none;';
     $result = '<div id="attr-' . $products_id . '-' . $attr_group . '" class="attr-form-parent">';
     //add (plus) icon floating right, please only use one (left/right)
     //$result .= '<div style="float:right;'.$icon_add_style.'" title="Click to add" class="btn-attr-add ui-state-default ui-corner-all"><span class="ui-icon ui-icon-plus pointer"></span></div>';
     $result .= '<div class="attr-form" style="margin-bottom:5px;' . $form_style . '">';
     $result .= '<select class="cmb-attr-form input">';
     $result .= '<option value="0">Add New ' . $class_s->groups[$attr_group] . '...</option>';
     $result .= $class_s->drawComboOptions('', $attr_group, null, '', 'sd.name');
     $result .= '</select>';
     $result .= '</div>';
     // .attr-form
     $result .= '<div class="attr-list" style="float:left;">';
     foreach ($attributes as $attr) {
         $result .= $this->drawSingleAttribute($products_id, $attr['styles_id'], $attr['name'], $attr_group);
     }
     //add (plus) icon floating left, please only use one (left/right)
     $result .= '<div style="float:left;margin:1px 0 0 2px;' . $icon_add_style . '" title="Click to add" class="btn-attr-add ui-state-default ui-corner-all"><span class="ui-icon ui-icon-plus pointer"></span></div>';
     $result .= '</div>';
     $result .= '</div>';
     // #attr-{products_id}-{attr_group}
     return $result;
 }