Esempio n. 1
0
 function item_same_category_form()
 {
     global $display;
     AZLib::getProvinces();
     AZLib::getCats();
     $item_id = (int) Url::get('item_id');
     $sql = 'SELECT id, name, list_brief, offer, modify_time, sku, read_count, category_id, currency_id, price, price_out, img_url, img_server FROM item WHERE';
     $where = " id!={$item_id}";
     if (CGlobal::$curCategory) {
         $where .= ($where != '' ? " AND " : "") . " category_id = " . CGlobal::$curCategory;
     }
     $where .= ($where != '' ? " AND " : "") . " status=1";
     if (CGlobal::$curCity) {
         // $where = " province_id = " . CGlobal::$curCity . ($where != '' ? " AND " : "") . $where;//ngannv comment vì k có trường province id trong bảng item
     }
     $sql .= "{$where} ORDER BY item_order ASC";
     $divID = 'item_same_cat';
     $code = 'item_same_cat';
     $url_path = WEB_DIR . "ajax.php?act=item&code=item_same_category&category_id=" . CGlobal::$curCategory . "&item_id={$item_id}";
     $limit = '';
     $item_per_page = 3;
     $i = 1;
     $pagging = AZPagging::AjaxPagingNext($limit, $item_per_page, true, 'p_item_same', $url_path, $divID);
     $sql .= $limit;
     $items = array();
     $re = DB::query($sql);
     if ($re) {
         while ($item = mysql_fetch_assoc($re)) {
             if ($i <= $item_per_page) {
                 if (isset(CGlobal::$allCategories[$item['category_id']])) {
                     $item['href'] = WEB_DIR . CGlobal::$allCategories[$item['category_id']]['nice_name'] . "/p{$item['id']}/" . AZLib::safe_title($item['name']) . ".html";
                 } else {
                     $item['href'] = WEB_DIR . "p{$item['id']}/" . AZLib::safe_title($item['name']) . ".html";
                 }
                 $item['modify_time'] = date('H:i | d.m.y', $item['modify_time']);
                 $item['price_num'] = (int) $item['price'];
                 if ($item['price']) {
                     $item['price'] = number_format($item['price'], 0, ',', '.');
                 } else {
                     $item['price'] = '';
                 }
                 $item['price_title'] = 'Giá bán';
                 if ($item['price_out'] > 0) {
                     $item['price_out'] = number_format($item['price_out'], 0, ',', '.') . ($item['currency_id'] == ' ' ? ' ' . CGlobal::$currency[$item['currency_id']] : '');
                 } else {
                     $item['price_out'] = '0';
                 }
                 //$item['price'] 			= AZLib::convertCurrency($item['price'],			$item['currency_id']);
                 //$item['price_out'] 		= AZLib::convertCurrency($item['price_out'],		$item['currency_id']);
                 $item['name'] = AZLib::filter_title($item['name']);
                 if ($item['img_url']) {
                     $item['img_thumb_wl'] = AZLib::getImageThumb($item['img_url'], 180, 0, 1, $item['img_server']);
                 } else {
                     $item['img_url'] = '';
                 }
                 if (!CGlobal::$curLevel2Cat) {
                     if (isset(CGlobal::$allCategories[$item['category_id']])) {
                         $item['cat_name'] = CGlobal::$allCategories[$item['category_id']]['name'];
                     } else {
                         $item['cat_name'] = "ID: {$item['category_id']}";
                     }
                 }
                 $items[$item['id']] = $item;
                 /* 
                                    $value['price'] = AZLib::convertCurrency($value['price'], $value['currency_id']);
                                   $value['currency_id'] = 1;
                                  
                                    if (isset(CGlobal::$allCategories[$value['category_id']]))
                                     {
                                         $value['href'] = WEB_DIR . AZRewrite::formatUrl('?page=item_detail&id=' . $value['id'] . '&ebname=' . AZLib::safe_title($value['name']) . '&nice_name=' . CGlobal::$allCategories[$value['category_id']]['nice_name']);
                                     } else {
                                         $value['href'] = WEB_DIR . AZRewrite::formatUrl('?page=item_detail&id=' . $value['id'] . '&ebname=' . AZLib::safe_title($value['name']));
                                     }
                 
                                     $value['item_time'] = date('h:i | d.m', $value['modify_time']);
                 
                 
                                     $value['price_name'] = 'Giá bán';
                                     $value['item_type'] = 'Giao dịch bán';
                 
                                     $value['name'] = strip_tags(AZLib::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['img_url']) {
                                         $value['img_url'] = AZLib::getImageThumb($value['img_url'], 80, 80, 0, $value['img_server']);
                                     } else {
                                         $value['img_url'] = 'style/images/no-images-69x53.jpg';
                                     }
                 
                                     $items[$value['id']] = $value;
                 */
             }
             $i++;
         }
     }
     if ($i <= $item_per_page) {
         $pagging = AZPagging::AjaxPagingNext($limit, $item_per_page, false, 'p_item_same', $url_path, $divID);
     }
     $display->add('pagging', $pagging);
     $display->add('items', $items);
     $display->add('admin_item', User::have_permit(ADMIN_ITEM));
     if ($items) {
         if (Url::get('code') != $code) {
             echo '<div id="' . $divID . '">';
         } else {
             echo "<div>";
         }
         $display->output('ItemSameCategory', false, 'ItemSameCategory');
         echo "</div>";
     }
 }