예제 #1
0
 function item_same_category_form()
 {
     global $display;
     EClassApi::getCities();
     EClassApi::getCats();
     $p_item_same = (int) Url::get('p_item_same', 1);
     $itemVipCat = $this->getItemVipCat();
     /*$sql = 'SELECT id, name, up_time, created_time, user_id, user_name, description, city_id, category_id, currency_id, price, original_image_url, img_server FROM item WHERE';
             $where = '';
     
             if($itemVipCat['str_item_id'] != ''){
                 $where .= ( $where != '' ? " AND " : "") . " id NOT IN ({$itemVipCat['str_item_id']})";
                 unset ($itemVipCat['str_item_id']);
             }else{
                 unset ($itemVipCat['str_item_id']);
             }
             
             if (CGlobal::$curCategory) {
                 $where .= ( $where != '' ? " AND " : "") . " category_id = " . CGlobal::$curCategory;
             }
             $where .= ( $where != '' ? " AND " : "") . " status=1";
     
             if (CGlobal::$curCity) {
                 $where = " city_id = " . CGlobal::$curCity . ($where != '' ? " AND " : "") . $where;
             }
             $where	.= " AND sticky = 0 ";
             $sql .= "$where ORDER BY up_time DESC";*/
     $divID = 'item_same_cat';
     $code = 'item_same_cat';
     $url_path = WEB_DIR . "ajax.php?act=item&code=item_same_category&category_id=" . CGlobal::$curCategory;
     /*$limit = '';
             $item_per_page = 6;
             $i = 1;
     
             if($p_item_same == 1){
                 $item_per_page = 6 - count($itemVipCat);
             }
     
             require_once ROOT_PATH . 'core/ECPagging.php';
             $pagging = ECPagging::AjaxPagingNextCat($limit, $item_per_page, true, 'p_item_same', $url_path, $divID);
     
     
             if($p_item_same > 1){
                 $limit=' LIMIT '.((($p_item_same-1)*$item_per_page)-count($itemVipCat)).','.($item_per_page);
             }
     
             $sql .= $limit;
     
             $items = array();
             $re = DB::query($sql);
     
     
             if ($re) {
                 while ($value = mysql_fetch_assoc($re)) {
     
                     $value['price'] = EClassApi::convertCurrency($value['price'], $value['currency_id']);
                     $value['currency_id'] = 1;
                     if ($i <= $item_per_page) {
                         if (isset(CGlobal::$allCategories[$value['category_id']])) {
                             $value['href'] = WEB_DIR . ECRewrite::formatUrl('?page=item_detail&id=' . $value['id'] . '&ebname=' . EClassApi::safe_title($value['name']) . '&nice_name=' . CGlobal::$allCategories[$value['category_id']]['nice_name']);
                         } else {
                             $value['href'] = WEB_DIR . ECRewrite::formatUrl('?page=item_detail&id=' . $value['id'] . '&ebname=' . EClassApi::safe_title($value['name']));
                         }
     
                         $value['item_time'] = date('h:i | d.m', $value['created_time']);
     
     
                         $value['price_name'] = 'Giá bán';
                         $value['item_type'] = 'Giao dịch bán';
     
                         $value['name'] = strip_tags(EClassApi::filter_title($value['name']));
     
                         if ($value['price'] && $value['price'] > 0) {
                             $value['price'] = number_format($value['price'], 0, ',', '.');
                             $value['currency_id'] = CGlobal::$currency[$value['currency_id']];
                         } else {
                             $value['price'] = 'Liên hệ';
                             $value['currency_id'] = '';
                         }
     
                         if ($value['original_image_url']) {
                             $value['original_image_url'] = EClassApi::getImageThumb($value['original_image_url'], 80, 80, 0, $value['img_server']);
                         } else {
                             $value['original_image_url'] = 'style/images/no-images-69x53.jpg';
                         }
     
                         $value['profile_url'] = WEB_DIR . $value['user_name'];
                         $value['user_name_title'] = $value['user_name'];
                         $value['user_name'] = (strlen($value['user_name']) > 10 ) ? substr($value['user_name'], 0, 10) . '...' : $value['user_name'];
     
                         if (isset(CGlobal::$cities[$value['city_id']])) {
                             $value['city'] = CGlobal::$cities[$value['city_id']]['name'];
                         } else {
                             $value['city'] = "Toàn quốc";
                         }
     
                         $value['vip_cat_img'] = '';
     
                         $items[$value['id']] = $value;
                     }
                     $i++;
                 }
             }
     
             if ($i <= $item_per_page) {
                 $pagging = ECPagging::AjaxPagingNextCat($limit, $item_per_page, false, 'p_item_same', $url_path, $divID);
             }*/
     //mảng dữ liệu trống
     if (is_array($itemVipCat) && count($itemVipCat) > 0) {
         $countNull = 6 - count($itemVipCat);
     } else {
         $countNull = 6;
     }
     //Lấy zone
     foreach (CGlobal::$allCategories[CGlobal::$allCategories[CGlobal::$curCategory]['parent_id']]['zones'] as $val) {
         $zone = $val;
     }
     $no_image = 'style/images/service.png';
     switch ($zone) {
         case 2:
             //Thời trang
             $no_image = 'style/images/box_hot/thoi_trang.png';
             break;
         case 1:
             //Nhà cửa
             $no_image = 'style/images/box_hot/nha_cua.png';
             break;
         case 6:
             //Điện máy
             $no_image = 'style/images/box_hot/dien_may.png';
             break;
         case 3:
             //Hàng hiệu
             $no_image = 'style/images/box_hot/hang_hieu.png';
             break;
         case 5:
             //Ô tô
             $no_image = 'style/images/box_hot/oto.png';
             break;
         case 7:
             //Nhà đất
             $no_image = 'style/images/box_hot/nha_dat.png';
             break;
         default:
             break;
     }
     $items = array();
     for ($i = 0; $i < $countNull; $i++) {
         $value['can_buy'] = 1;
         $value['original_image_url'] = $no_image;
         $value['name'] = "BẠN MUỐN QUẢNG CÁO";
         $key = "null_" . $i;
         $items[$key] = $value;
     }
     if ($zone == 2 || $zone == 9) {
         $display->add('title', "Hàng mới về");
     } else {
         $display->add('title', "Sản phẩm hot");
     }
     $arr = User::$current->data;
     $item_ids = explode(',', $_REQUEST['recent_items']);
     if ($item_ids[0]) {
         $display->add('item_id', $item_ids[0]);
     }
     if (User::level()) {
         $phone = 0;
         if ($arr['mobile_phone'] != "") {
             $phone = $arr['mobile_phone'];
         } else {
             if ($arr['home_phone'] != "") {
                 $phone = $arr['home_phone'];
             }
         }
         $display->add('phone', $phone);
         $display->add('full_name', EClassApi::descriptionText($arr['full_name']));
     }
     //        $display->add('pagging', $pagging);
     $display->add('is_admin', User::have_permit(ADMIN_VIP_ITEM_CATEGORY));
     $display->add('zone', $zone);
     if (is_array($itemVipCat) && count($itemVipCat) > 0) {
         $items = $itemVipCat + $items;
     }
     $display->add('items', $items);
     //        $display->add('current_user_id', $arr['id']);
     if ($items) {
         if (Url::get('code') != $code) {
             echo '<div id="' . $divID . '">';
         } else {
             echo "<div>";
         }
         $display->output('ItemSameCategory', false, 'ItemSameCategory');
         echo "</div>";
     }
 }