function load_shop_label() { if (!CGlobal::$user_profile) { User::check_get_user(); } if (CGlobal::$user_profile) { $mode_default = 'comment'; if (!CGlobal::$shop_setting) { if (CGlobal::$user_profile['shop_setting']) { CGlobal::$shop_setting = unserialize(stripslashes(CGlobal::$user_profile['shop_setting'])); } if (!CGlobal::$shop_setting) { CGlobal::$shop_setting = array('shop_name' => CGlobal::$user_profile['full_name'] ? CGlobal::$user_profile['full_name'] : CGlobal::$user_profile['user_name'], 'default_mode' => 1, 'default_layout' => 1, 'item_list_mode' => 0, 'adv_banner' => ''); } } if (CGlobal::$shop_setting && !isset(CGlobal::$shop_setting['default_layout'])) { CGlobal::$shop_setting['default_layout'] = 1; } if (Url::get("mode") == "comment" || CGlobal::$shop_setting['default_mode'] == 2) { CGlobal::$website_title = 'Lưu bút - Shop ' . CGlobal::$user_profile['user_name']; } if (!CGlobal::$shop_setting['default_mode']) { if (Url::get('mode') == 'shop' || DB::select('item', 'user_id=' . CGlobal::$user_profile['id'] . ' AND status=1')) { //Nếu có sp, mặc định là vào shop CGlobal::$shop_setting['default_mode'] = 1; $mode_default = 'shop'; } else { //Nếu ko có sản phẩm, mặc định vào lưu bút CGlobal::$shop_setting['default_mode'] = 2; $mode_default = 'comment'; } } else { if (CGlobal::$shop_setting['default_mode'] == 1) { $mode_default = 'shop'; } else { $mode_default = 'comment'; } } } if (CGlobal::$shop_label) { CGlobal::$website_title .= ' | ' . CGlobal::$shop_label['name']; $this->label_id = CGlobal::$shop_label['id']; } else { $this->label_id = (int) Url::get('label_id', 0); if ($this->label_id) { CGlobal::$shop_label = DB::select("label", "id=" . $this->label_id); } if (!CGlobal::$shop_label) { $this->label_id = 0; } } $page_shop_item = (int) Url::get('page_shop_item', 1); $label_id = (int) Url::get("label_id", 0); $list_type = (int) Url::get("list_type", 0); global $display; $display->add('top_level_id', $label_id); $display->add('list_type', $list_type); $display->add('can_edit', User::have_permit(ADMIN_ITEM) || User::id() == CGlobal::$user_profile['id']); $status_check = User::id() == CGlobal::$user_profile['id'] || User::have_permit(ADMIN_ITEM) ? ' status IN(0,1,2,3,4,5)' : ' status =1'; if ($label_id) { $total_item = DB::fetch('SELECT count(*) AS total_row FROM label_item AS L JOIN item AS I ON L.item_id=I.id AND I.' . $status_check . ' AND I.user_id=' . CGlobal::$user_profile['id'] . ' WHERE L.user_id=' . CGlobal::$user_profile['id'] . ' AND L.label_id=' . $label_id, 'total_row', 0); } else { $total_item = DB::fetch('SELECT count(*) AS total_row FROM item WHERE ' . $status_check . ' AND user_id=' . CGlobal::$user_profile['id'], 'total_row', 0); } $pagging = ''; $items = array(); $divID = 'shop_item'; $item_per_page = 0; if ($total_item) { $item_per_page = 9; $limit = ''; $url_path = WEB_DIR . 'ajax.php?act=shop&code=load_shop_label&user_id=' . CGlobal::$user_profile['id'] . '&label_id=' . $label_id . (!$list_type ? '' : '&list_type=' . $list_type); $pagging = AZPagging::AjaxPaging($limit, $total_item, $item_per_page, 5, 'page_shop_item', '', false, false, $url_path, $divID, true); if ($label_id) { $display->add('label_name', CGlobal::$shop_label['name']); $select = 'SELECT I.id, I.name,I.sapo, I.user_name, I.user_id,I.description,I.category_id, I.read_count, I.reply_count, I.currency_id, I.price, I.province_id, I.up_time,I.price_out, I.brief, I.img_url, I.status, I.state, I.img_server FROM label_item AS L JOIN item AS I ON L.item_id=I.id AND I.' . $status_check . ' AND I.user_id=' . CGlobal::$user_profile['id'] . ' WHERE L.user_id=' . CGlobal::$user_profile['id'] . ' AND L.label_id=' . $label_id . ' ORDER BY shop_order, up_time DESC' . $limit; } else { $select = 'SELECT id, name, sapo, user_name, user_id, description, category_id, read_count, reply_count, currency_id, price, brief, img_url, province_id, up_time, price_out, status, state, img_server,sticky FROM item WHERE ' . $status_check . ' AND user_id=' . CGlobal::$user_profile['id'] . ' ORDER BY shop_order, up_time DESC' . $limit; } $re = DB::query($select); if (User::is_login()) { $wids = User::get_wishlist('wish_list_items'); $w_items = array(); if ($wids) { $w_items = explode(',', $wids); } } if ($re) { AZLib::getProvinces(); AZLib::getCats(); $item_ids = ''; while ($item = mysql_fetch_assoc($re)) { $item['price'] = AZLib::convertCurrency($item['price'], $item['currency_id']); $item['price_out'] = AZLib::convertCurrency($item['price_out'], $item['currency_id']); $item['currency_id'] = 1; if ($item['img_url']) { $item['image_url'] = AZLib::getImageThumb($item['img_url'], 200, 200, 0, $item['img_server']); } if (isset(CGlobal::$allCategories[$item['category_id']])) { $item['href'] = WEB_DIR . AZRewrite::formatUrl('?page=item_detail&id=' . $item['id'] . '&ebname=' . AZLib::safe_title(AZLib::word_limit($item['name'], 12, '')) . '&nice_name=' . CGlobal::$allCategories[$item['category_id']]['nice_name']); } else { $item['href'] = WEB_DIR . AZRewrite::formatUrl('?page=item_detail&id=' . $item['id'] . '&ebname=' . AZLib::safe_title(AZLib::word_limit($item['name'], 12, ''))); } $tooltip = ''; $tooltip .= 'Xem: ' . $item['read_count'] . ' - Phản hồi: ' . $item['reply_count']; $item['time_label'] = ''; $up_time = date('H:i | ', $item['up_time']); if (date('d.m.y', $item['up_time']) == date('d.m.y', TIME_NOW)) { $up_time .= '<font color="green">Hôm nay</font>'; } else { $up_time .= date('d.m.y', $item['up_time']); } //$item['created_time'] = 'đăng '.AZLib::duration_time($item['up_time']); $item['created_time'] = $up_time; if ($item['price']) { $item['price'] = number_format($item['price'], 0, ',', '.'); $item['currency_id'] = CGlobal::$currency[$item['currency_id']]; } else { $item['price'] = ''; $item['currency_id'] = ''; } $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['no_base_source'] = AZLib::remove_4_js(str_replace(array("<br>", "<br />"), '', $item['brief'])); $item['description'] = AZLib::plainText(AZLib::parseBBCode(html_entity_decode($item['description'], ENT_QUOTES, "UTF-8"))); $item['description'] = preg_replace("/\\[([\\s]*[0-9]{1,2}[\\s]*)\\]/eis", " ", $item['description']); $item['description'] = str_replace(array("'", "\""), array("", " "), $item['description']); $item['description'] = AZLib::word_limit($item['description'], 250, ''); /* if($item['sapo']!=''){ $item['brief'] = $item['sapo']; $item['brief'] = AZLib::subString(AZLib::filter_title($item['brief']),0,255,true); $item['brief'] = AZLib::word_limit($item['brief'],30,''); } else{ $item['brief'] = String::display_sort_title($item['description'],30); } */ $item['brief'] = ''; $item['parent_name'] = ''; if (isset(CGlobal::$allCategories[$item['category_id']]) && CGlobal::$allCategories[$item['category_id']]['parent_id']) { $parent_id = CGlobal::$allCategories[$item['category_id']]['parent_id']; if (isset(CGlobal::$allCategories[$parent_id])) { $item['parent_name'] = CGlobal::$allCategories[$parent_id]['name'] . ' - '; } } if (isset(CGlobal::$allCategories[$item['category_id']]['name'])) { $item['category_name'] = $item['parent_name'] . CGlobal::$allCategories[$item['category_id']]['name']; } else { $item['category'] = ''; $item['category_name'] = ''; } $item['safe_title'] = AZLib::safe_title($item['parent_name'] . $item['category_name']); $item['category_href'] = WEB_DIR . AZRewrite::formatUrl('?page=list_detail&category_id=' . $item['category_id'] . '&ebname=' . $item['safe_title']); $item['name'] = AZLib::subString(AZLib::filter_title($item['name']), 0, 115, true); $item['name'] = AZLib::word_limit($item['name'], 12, ''); $item['user_name'] = $item['user_name']; $item['profile_url'] = WEB_DIR . $item['user_name']; $item['city'] = CGlobal::$provinces[$item['province_id']]['name']; if ($item['img_url']) { $item['img_url'] = AZLib::getImageThumb($item['img_url'], 110, 0, 1, $item['img_server']); } else { $item['img_url'] = 'style/images/no-images-69x53.jpg'; } if (isset($_GET['ebname'])) { $item['up_url'] = Url::build_current(array('action' => 'up', 'id' => $item['id'], 'category_id' => CGlobal::$curCategory, 'type' => Url::get('type'), 'ebname' => $_GET['ebname'])); $item['down_url'] = Url::build_current(array('action' => 'down', 'id' => $item['id'], 'category_id' => CGlobal::$curCategory, 'type' => Url::get('type'), 'ebname' => $_GET['ebname'])); } else { $item['up_url'] = Url::build_current(array('action' => 'up', 'id' => $item['id'], 'category_id' => CGlobal::$curCategory, 'type' => Url::get('type'))); $item['down_url'] = Url::build_current(array('action' => 'down', 'id' => $item['id'], 'category_id' => CGlobal::$curCategory, 'type' => Url::get('type'))); } $item['in_wish_list'] = false; if (User::is_login()) { if (in_array($item['id'], $w_items)) { $item['in_wish_list'] = true; } else { $item['in_wish_list'] = false; } } else { if (isset($_COOKIE['wish_list_item_ids'])) { $arr = explode(',', $_COOKIE['wish_list_item_ids']); foreach ($arr as $k => $v) { if ($v == $item['id']) { $item['in_wish_list'] = true; } } } } if (CGlobal::$user_profile['id'] == User::id()) { $tooltip .= ' - <strong>ID tin: ' . $item['id'] . '</strong>'; } $item['invalid'] = ''; if ($item['status'] == 2) { $tooltip .= '<div style=\\\'color:red\\\'>(Đang kiểm duyệt)</div>'; $item['invalid'] = '<font color="red">(Đang kiểm duyệt)</font>'; } elseif ($item['status'] == 3) { $tooltip .= '<div style=\\\'color:red\\\'>(Tin theo dõi lừa đảo)</div>'; $item['invalid'] = '<font color="red">(Theo dõi lừa đảo)</font>'; } elseif ($item['status'] == 0) { $tooltip .= '<div style=\\\'color:red\\\'>(Đang ẩn)</div>'; $item['invalid'] = '<font color="red">(Đang ẩn)</font>'; } elseif ($item['status'] == 5) { $tooltip .= '<div style=\\\'color:red\\\'>(Đang kiểm duyệt chờ chứng thực)</div>'; $item['invalid'] = '<font color="red">(KD chờ chứng thực)</font>'; } elseif ($item['status'] == 4) { $tooltip .= '<div style=\\\'color:red\\\'>(Tin trùng)</div>'; $item['invalid'] = '<font color="red">(Tin trùng)</font>'; } elseif ($item['state'] == 1) { $tooltip .= '<div style=\\\'color:red\\\'>(Đang khóa)</div>'; $item['invalid'] = '<font color="red">(Đang khóa)</font>'; } $item['tooltip'] = $tooltip; $item['lids'] = ''; $item_ids .= ($item_ids != '' ? ',' : '') . $item['id']; $items[$item['id']] = $item; } } if ($item_ids) { $item_labels = array(); //Label của tất cả sp đang đc hiển thị $re = DB::query("SELECT id, label_id, item_id FROM label_item WHERE item_id IN({$item_ids})"); if ($re) { while ($l_item = mysql_fetch_assoc($re)) { if (isset($items[$l_item['item_id']])) { $items[$l_item['item_id']]['lids'] .= ($items[$l_item['item_id']]['lids'] != '' ? ',' : '') . $l_item['label_id']; } } } } } $display->add('loading_ajax', true); $display->add('is_admin', (int) User::have_permit(ADMIN_ITEM)); $display->add('cur_id', (int) User::id()); $display->add('total_sp', (int) $total_item); $display->add('items', $items); $display->add('paging', $pagging); $display->add('item_per_page', $item_per_page); $display->add('page_num', $page_shop_item); $display->add('shop_user_id', CGlobal::$user_profile['id']); $display->add('shop_user_name', CGlobal::$user_profile['user_name']); $display->output($list_type != 1 ? 'ShopItem' : 'ShopItemListDetail', false, 'Shop'); }