示例#1
0
 function draw()
 {
     global $display;
     $cat_newss = array();
     $display->add('is_admin', User::have_permit(ADMIN_NEWS));
     $display->add('url_home', WEB_DIR);
     $display->add('time_now', News::displayTime());
     $display->add('cat_name', $this->news_cat['name']);
     $display->add('cat_url', URL::build('news_list', array('news_catid' => $this->news_cat['id'], 'azname' => AZLib::safe_title($this->news_cat['name']))));
     $condition = ' status=1 ';
     $total = DB::count("news", $condition);
     $limit = '';
     //$pagging	= AZPagging::paging_list($limit,20,'page_no');
     $pagging = AZPagging::paging_list($limit, $total, 20);
     $re = DB::query('SELECT * FROM news WHERE ' . $condition . ' ORDER BY id DESC' . $limit);
     if ($re) {
         while ($news = mysql_fetch_assoc($re)) {
             $news['title'] = stripslashes($news['title']);
             $news['brief'] = stripslashes($news['brief']);
             $news['url'] = Url::build('news_detail', array('news_catid' => $news['news_catid'], 'news_id' => $news['id'], 'azname' => AZLib::safe_title($news['title'])));
             if ($news['image']) {
                 $news['image'] = AZLib::getImageThumb($news['image'], 150, 0, 0, $news['img_server']);
             }
             $news['news_h'] = date('H:i', $news['time_created']);
             $news['news_d'] = date('d-m-Y', $news['time_created']);
             $news['admin_link'] = News::admin_link($news);
             $cat_newss[$news['id']] = $news;
         }
     }
     $display->add('pagging', $pagging);
     $display->add('cat_newss', $cat_newss);
     $display->output("NewsPage");
 }
示例#2
0
文件: class.php 项目: duynhan07/elink
 function draw()
 {
     global $display;
     $display->add('skin_path', IMAGE_PATH);
     $txt = '';
     $option1 = '';
     $sql = "SELECT * FROM `public_survey` WHERE ";
     $search = Url::get('search');
     if ($search != '') {
         $condition = "title LIKE '%{$search}%' OR question LIKE '%{$search}%'";
     } else {
         $condition = " 1";
     }
     $totalRows = DB::count("public_survey", $condition);
     $limit = '';
     $display->add('pagging', AZPagging::paging_list($limit, $totalRows, 40));
     $sql .= $condition . $limit;
     $block_id = (int) Url::get('block_id', 0);
     $href = str_replace(WEB_DIR, '', urldecode(Url::get('href')));
     $surveys = DB::fetch_all($sql);
     if ($surveys) {
         foreach ($surveys as &$survey) {
             if ($block_id) {
                 $survey["add_to_block"] = $href . ($href != '' ? '&' : '?') . "cmd=add_poll_to_block&poll_id={$survey['id']}&block_id={$block_id}";
             }
             if ($survey['view'] == 1) {
                 $survey["url_view"] = Url::build_current(array("cmd" => "unpublish", "id" => $survey['id']));
                 $survey["view"] = '<img src="style/images/unexam.gif" title="Ẩn"/>';
                 $survey["view_str"] = "Hiển thị";
             } else {
                 $survey["url_view"] = Url::build_current(array("cmd" => "publish", "id" => $survey['id']));
                 $survey["view_str"] = "Đang ẩn";
                 $survey["view"] = '<img src="style/images/exam.gif" title="Cho hiển thị"/>';
             }
             $survey["url_view_survey"] = Url::build('view_survey', array('id' => $survey['id']));
             $survey["url_option"] = Url::build('admin_option', array('id_survey' => $survey['id']));
             $question = $survey['question'] . '<br><br>';
             $total_cout = DB::fetch('SELECT SUM(`count`) AS total_cout FROM `public_survey_opinion` WHERE id_survey=' . $survey['id'], 'total_cout', 0);
             $options = DB::fetch_all('SELECT * FROM `public_survey_opinion` WHERE id_survey=' . $survey['id']);
             foreach ($options as $option) {
                 $question .= "+ [ID:{$option['id']}] <b>{$option['option']}</b> <font color=red>({$option['count']}/{$total_cout} lượt chọn)</font><br>";
             }
             $survey["question"] = $question;
             if ($survey['type'] == 0) {
                 $type_send = "Nhiều lựa chọn";
             } else {
                 $type_send = "Một lựa chọn";
             }
             $survey["type_send"] = $type_send;
             $survey["time"] = date("d/m/Y H:i", $survey["time"]);
             $survey["time_m"] = date("d/m/Y H:i", $survey["time_m"]);
             $survey["edit"] = Url::build_current(array('id_survey' => $survey['id'], 'cmd' => 'edit'));
             $survey["delete"] = Url::build_current(array('id_survey' => $survey['id'], 'cmd' => 'delete'));
         }
     }
     $display->add('surveys', $surveys);
     $display->add('url_addnew', Url::build('admin_survey', array('cmd' => 'add')));
     $display->output('ListSurvey');
 }
示例#3
0
 function draw()
 {
     global $display;
     $display->add('msg', $this->showFormErrorMessages(1));
     $display->add("url_admin", Url::build_current());
     $status_select = Url::get('status_select', 6);
     //1:Chưa cập nhật; 2: Đã gửi đơn hàng ; 3: Đã TT; 4: Hủy đơn hàng; 5: Đã duyệt
     $status_arr = array(6 => "--Tất cả--", 2 => "Đã gửi đơn hàng", 1 => "Chưa cập nhật", 3 => "Đã Thanh toán", 5 => "Đã duyệt", 4 => "Đã hủy");
     $display->add("status_option", AZLib::getOption($status_arr, $status_select));
     $date_begin = Url::get('date_begin');
     $date_end = Url::get('date_end');
     $display->add("date_begin", $date_begin);
     $display->add("date_end", $date_end);
     $created_time_from = 0;
     $created_time_to = 0;
     if ($date_begin) {
         $date_arr = explode("-", $date_begin);
         if (isset($date_arr[0]) && isset($date_arr[1]) && isset($date_arr[2])) {
             $created_time_from = mktime(0, 0, 0, (int) $date_arr[1], (int) $date_arr[0], (int) $date_arr[2]);
         }
     }
     if ($date_end) {
         $date_arr = explode("-", $date_end);
         if (isset($date_arr[0]) && isset($date_arr[1]) && isset($date_arr[2])) {
             $created_time_to = mktime(23, 59, 59, (int) $date_arr[1], (int) $date_arr[0], (int) $date_arr[2]);
         }
     }
     $condition = "";
     if ($status_select != 6) {
         $condition .= "status=" . $status_select;
     }
     if ($created_time_from) {
         $condition .= ($condition != '' ? ' AND ' : '') . ' time_create >=' . $created_time_from;
     }
     if ($date_end) {
         $condition .= ($condition != '' ? ' AND ' : '') . " time_create <={$created_time_to}";
     }
     $total = DB::count("cart", $condition);
     $limit = '';
     $display->add('paging', AZPagging::paging_list($limit, $total, 40, 10, 'page_no', '', true, 'Đơn hàng'));
     $all_carts = array();
     $re = DB::query("SELECT * FROM cart " . ($condition != '' ? 'WHERE ' : '') . $condition . " ORDER BY id DESC {$limit}");
     if ($re) {
         while ($Cart = mysql_fetch_assoc($re)) {
             $Cart["time_create"] = date('d/m/Y H:i:s', $Cart['time_create']);
             $Cart["time_change"] = date('d/m/Y H:i:s', $Cart['time_change']);
             $Cart["url"] = Url::build_current(array('cmd' => 'edit', 'id' => $Cart['id']));
             $Cart["status"] = $status_arr[$Cart['status']];
             $Cart["delete"] = Url::build_current(array('cmd' => 'delete', 'id' => $Cart['id']));
             $Cart["price"] = number_format($Cart['price'], null, null, '.');
             $all_carts[$Cart['id']] = $Cart;
         }
     }
     $display->add('all_carts', $all_carts);
     $display->add('is_admin', User::is_admin());
     $this->beginForm();
     $display->output('CartAdmin');
     $this->endForm();
 }
示例#4
0
 function draw()
 {
     global $display;
     $keyword = Url::get('keyword');
     $display->add('keyword', $keyword);
     $display->add('export_link', Url::build_current(array('cmd' => 'export')));
     $where = '1';
     if ($keyword != '') {
         $where .= ' AND email LIKE "%' . $keyword . '%"';
     }
     $total_item = DB::count('news_letter_email', $where);
     $limit = '';
     $item_per_page = 40;
     $page_no = (int) Url::get('page_no');
     $pagging = AZPagging::paging_list($limit, $total_item, $item_per_page, 10);
     $re = DB::query('SELECT * FROM news_letter_email WHERE ' . $where . ' ORDER BY id ' . $limit);
     $news_letter_emails = array();
     $i = 0;
     if ($page_no <= 0) {
         $page_no = 1;
     }
     if ($re) {
         while ($item = mysql_fetch_assoc($re)) {
             $item['time_add'] = date('H:i', $item['time_add']) . ' ngày ' . date('d/m/Y', $item['time_add']) . '<br />Cách đây ' . AZLib::duration_time($item['time_add']);
             $item['delete'] = AZLib::buttonDel(Url::build_current(array('cmd' => 'delete', 'id' => $item['id'])), 'style/images/admin/delete.gif', 'Loại bỏ Email này khỏi danh sách!');
             $i++;
             $item['i'] = $i + ($page_no - 1) * $item_per_page;
             $news_letter_emails[$item['id']] = $item;
         }
     }
     $display->add('pagging', $pagging);
     $display->add('news_letter_emails', $news_letter_emails);
     $display->add('count', $total_item);
     $this->beginForm();
     $display->output("NewsLetterAdmin");
     $this->endForm();
 }
示例#5
0
    function draw()
    {
        global $display;
        if ($this->search_catid) {
            $keywords = AZLib::getParam('keywords');
            if ($keywords != '') {
                global $display;
                $page_no = (int) Url::get('page_no', 1);
                if ($page_no <= 0) {
                    $page_no = 1;
                }
                $item_per_page = 30;
                $sql = 'SELECT * FROM item WHERE ';
                $where = '';
                $curMainCat = CGlobal::$curMainCat;
                $curLevel2Cat = CGlobal::$curLevel2Cat;
                $sql .= CGlobal::$item_condition . " ORDER BY item_order ASC";
                $total_row = DB::count("item", CGlobal::$item_condition);
                if (CGlobal::$allCategories[$this->search_catid]['parent_id'] && isset(CGlobal::$allCategories[CGlobal::$allCategories[$this->search_catid]['parent_id']])) {
                    $ebname = CGlobal::$allCategories[CGlobal::$allCategories[$this->search_catid]['parent_id']]['ebname'] . '-' . CGlobal::$allCategories[$this->search_catid]['ebname'];
                } else {
                    $ebname = CGlobal::$allCategories[$this->search_catid]['ebname'];
                }
                #######################################################################################
                #Paging
                $filter_get = Url::get('filter');
                $min = Url::get('min');
                $max = Url::get('max');
                $order = Url::get('order');
                $paging = AZPagging::paging_list($limit, $total_row, $item_per_page, 10, 'page_no', '', true, 'Sản phẩm', 'Trang');
                $sql .= $limit;
                #Paging
                #######################################################################################
                $items = array();
                $re = DB::query($sql);
                if ($re) {
                    while ($item = mysql_fetch_assoc($re)) {
                        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'] = AZLib::convertCurrency($item['price'], $item['currency_id']);
                        $item['price_out'] = AZLib::convertCurrency($item['price_out'], $item['currency_id']);
                        $item['currency_id'] = 1;
                        $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['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;
                    }
                }
                $display->add('page', $page_no);
                $display->add('items', $items);
                $display->add('paging', $paging);
                $display->output("sphinx_search");
            } else {
                echo '<div style="padding:20px;color:#f00;font-size:18px;border:1px solid #ccc" align="center">
			        	Bạn chưa nhập vào từ khóa cần tìm kiếm!
			         </div>';
            }
        } else {
            echo '<div style="padding:20px;color:#f00;font-size:18px;border:1px solid #ccc" align="center">
		        	Bạn chưa chọn danh mục tìm kiếm!
		         </div>';
        }
    }
示例#6
0
 function draw()
 {
     global $display;
     $status_arr = array('0' => 'Chưa trả lời / phản hồi', '1' => 'Đã phản hồi / phản hồi', '2' => 'Tất cả');
     $status = (int) Url::get('status', 0);
     $display->add('url_admin', Url::build_current());
     $display->add('status_option', AZLib::getOption($status_arr, $status));
     $item_per_page_arr = array('20' => '20', '50' => '50', '100' => '100', '150' => '150', '200' => '200', '300' => '300', '500' => '500');
     $item_per_page = (int) Url::get('row_per_page', 20);
     $display->add('row_per_page_option', AZLib::getOption($item_per_page_arr, $item_per_page));
     $from_date_arr[-1] = '--Từ ngày--';
     for ($i = 30; $i >= 0; $i--) {
         $time_from = mktime(0, 0, 0, date('m', TIME_NOW), date('d', TIME_NOW), date('Y', TIME_NOW)) - $i * 24 * 3600;
         $from_date_arr[$time_from] = date('d/m/Y', $time_from);
     }
     $to_date_arr[-1] = '--Đến ngày--';
     for ($i = 0; $i <= 30; $i++) {
         $time_to = mktime(23, 59, 59, date('m', TIME_NOW), date('d', TIME_NOW), date('Y', TIME_NOW)) - $i * 24 * 3600;
         $to_date_arr[$time_to] = date('d/m/Y', $time_to);
     }
     $from_date = Url::get('from_date', -1);
     $to_date = Url::get('to_date', -1);
     $display->add('from_date_option', AZLib::getOption($from_date_arr, $from_date));
     $display->add('to_date_option', AZLib::getOption($to_date_arr, $to_date));
     $sql = ' 1 ';
     if ($from_date > -1) {
         $sql .= " AND time>=" . $from_date;
     }
     if ($to_date > -1) {
         $sql .= " AND time<=" . $to_date;
     }
     $txt_ykien = Url::get('txt_ykien', '');
     if ($txt_ykien != '') {
         $sql .= " AND content like '%{$txt_ykien}%'";
     }
     $display->add('txt_ykien', $txt_ykien);
     if ($status != 2) {
         $sql .= ' AND  status=' . $status;
     }
     $num_of_row = DB::count('feedback', $sql);
     $limit = '';
     $display->add('pagging', AZPagging::paging_list($limit, $num_of_row, $item_per_page, 10, 'page_no', '', true, 'Liên hệ'));
     $page_no = (int) Url::get('page_no', 1);
     if ($page_no <= 0) {
         $page_no = 1;
     }
     $i = 0;
     $all_feedbacks = array();
     $sql = "SELECT * FROM feedback WHERE {$sql} ORDER BY id DESC {$limit}";
     $re = DB::query($sql);
     if ($re) {
         while ($row = mysql_fetch_assoc($re)) {
             $email = '';
             if ($row['name']) {
                 $email = stripslashes($row['name']) . " ";
             }
             if ($row['address']) {
                 $email .= "( " . stripslashes($row['address']) . ") ";
             }
             $email .= '<a href="mailto:' . $row['email'] . '"><font color=blue>' . $row['email'] . "</font></a>";
             $row['email'] = $email;
             $row['date'] = date("d/m/Y H:i:s", $row['time']);
             $row['date2'] = AZLib::duration_time($row['time']);
             $row['url_del'] = AZLib::buttonDel(Url::build_current(array('id' => $row['id'], 'cmd' => 'delete')), 'style/images/delete.gif', 'Xóa ý kiến');
             $row['url_reply'] = Url::build_current(array('id' => $row['id'], 'cmd' => 'reply'));
             if ($row['reply_content']) {
                 $row['reply_content'] = stripslashes($row['reply_content']);
             } else {
                 $row['reply_content'] = "Chưa có";
             }
             if (!$row['status']) {
                 $row['exam'] = AZLib::button(Url::build_current(array('id' => $row['id'], 'cmd' => 'exam')), 'style/images/exam.gif', 'Duyệt liên hệ');
             } else {
                 $row['exam'] = AZLib::button(Url::build_current(array('id' => $row['id'], 'cmd' => 'unexam')), 'style/images/unexam.gif', 'Bỏ duyệt liên hệ');
             }
             if ($i % 2 == 0) {
                 $row['bgcolor'] = '#FFFFFF';
             } else {
                 $row['bgcolor'] = '#CCFF99';
             }
             $i++;
             $row['i'] = ($page_no - 1) * $item_per_page + $i;
             $all_feedbacks[$row['id']] = $row;
         }
     }
     $display->add('all_feedbacks', $all_feedbacks);
     $this->beginForm();
     $display->output("FeedbackAdmin");
     $this->endForm();
 }
示例#7
0
 function draw()
 {
     global $display;
     $this->beginForm(false, "POST", false, Url::build_current());
     $display->add('msg', $this->showFormErrorMessages(1));
     $display->add('url_admin', Url::build_current());
     $key_word = Url::get('key_word');
     $display->add('key_word', $key_word);
     $display->add('option_date1', AZLib::getOptionNum(1, 31, (int) Url::get('cmb_date1', 1)));
     $display->add('option_month1', AZLib::getOptionNum(1, 12, (int) Url::get('cmb_month1', 1)));
     $display->add('option_year1', AZLib::getOptionNum(2011, date("Y"), (int) Url::get('cmb_year1', 2011)));
     $display->add('option_date2', AZLib::getOptionNum(1, 31, (int) Url::get('cmb_date2', date('d'))));
     $display->add('option_month2', AZLib::getOptionNum(1, 12, (int) Url::get('cmb_month2', date('m'))));
     $display->add('option_year2', AZLib::getOptionNum(2011, date("Y"), (int) Url::get('cmb_year2', date('Y'))));
     $display->add('url_add', Url::build_current(array('cmd' => 'add')));
     if (Url::get('cmb_date1') != '' && Url::get('cmb_month1') != '' && Url::get('cmb_year1') != '') {
         $from_date = mktime(0, 0, 0, Url::get('cmb_month1'), Url::get('cmb_date1'), Url::get('cmb_year1'));
     } else {
         $from_date = 0;
     }
     if (Url::get('cmb_date2') != '' && Url::get('cmb_month2') != '' && Url::get('cmb_year2') != '') {
         $to_date = mktime(23, 59, 59, Url::get('cmb_month2'), Url::get('cmb_date2'), Url::get('cmb_year2'));
     } else {
         $to_date = 0;
     }
     $condition = '';
     $status = Url::get('status', 0);
     $user_c = Url::get('user_c');
     $user_m = Url::get('user_m');
     if ($status == 1) {
         $condition .= ($condition != '' ? ' AND ' : ' ') . ' status=1';
     } elseif ($status == 2) {
         $condition .= ($condition != '' ? ' AND ' : ' ') . ' status=0';
     }
     if ($user_c != '') {
         $condition .= ($condition != '' ? ' AND ' : ' ') . ' user_c LIKE "%' . $user_c . '%"';
     }
     if ($user_m != '') {
         $condition .= ($condition != '' ? ' AND ' : ' ') . ' user_m LIKE "%' . $user_m . '%"';
     }
     if ($from_date && $to_date) {
         $condition .= ($condition != '' ? ' AND ' : ' ') . ' time_c >=' . $from_date . ' AND time_c <= ' . $to_date;
     }
     $display->add('user_c', $user_c);
     $display->add('user_m', $user_m);
     $display->add('status_option', AZLib::getOption(array(0 => "Tất cả", 1 => "Hiện", 2 => "Ẩn SP"), $status));
     if ($key_word) {
         $key_word_s = '';
         $arr = explode(' ', $key_word);
         if ($arr) {
             foreach ($arr as $key) {
                 $key = trim($key);
                 if ($key != '') {
                     $key_word_s .= ($key_word_s == '' ? '+' : ' +') . "{$key}";
                 }
             }
         }
         if ($key_word_s != '') {
             $condition .= " AND MATCH(title, des) AGAINST ('{$key_word_s}' IN BOOLEAN MODE)";
         }
         //$condition .= ' AND (title LIKE "%'.$key_word.'%" OR des LIKE "%'.$key_word.'%")';
     }
     /*if(Url::get('key_word','str',''))
     		$condition.=($condition!=''?' AND ':' ').' (title LIKE "%'.$key_word.'%" OR des LIKE "%'.$key_word.'%")';*/
     $total_item = DB::count('document', $condition);
     $LIMIT = '';
     $paging = AZPagging::paging_list($LIMIT, $total_item, 20, 10, 'page_no', '', true, "Tài liệu", 'Trang');
     $display->add('paging', $paging);
     $condition = ($condition != '' ? 'WHERE' : '') . $condition;
     $documents = array();
     $sql = 'SELECT * FROM document ' . $condition . ' ORDER BY id DESC ' . $LIMIT;
     $re = DB::query($sql);
     if ($re) {
         while ($row = mysql_fetch_assoc($re)) {
             $row['title'] = stripslashes($row['title']);
             $row['des'] = stripslashes($row['des']);
             if ($row['status'] == 1) {
                 $row['change'] = AZLib::button(Url::build_current(array('cmd' => 'change', 'id' => $row['id'], "href" => urlencode(Url::build_all()))), 'style/images/unexam.gif', 'Disable');
                 $row['bgcolor'] = "#FFFFFF";
                 $row['status'] = 'OK';
             } else {
                 $row['change'] = AZLib::button(Url::build_current(array('cmd' => 'change', 'id' => $row['id'], "href" => urlencode(Url::build_all()))), 'style/images/exam.gif', 'Enable');
                 $row['bgcolor'] = "#FF9900";
                 $row['status'] = 'Disable';
             }
             $row['time_last'] = $row['time_last'] ? date("H\\hi:s d/m/Y", $row['time_last']) : '';
             $row['time_c'] = date("H\\hi:s d/m/Y", $row['time_c']) . " bởi {$row['user_c']}";
             $row['time_m'] = date("H\\hi:s d/m/Y", $row['time_m']) . " bởi {$row['user_m']}";
             $row['edit'] = AZLib::button(Url::build_current(array('cmd' => 'edit', 'id' => $row['id'], "href" => urlencode(Url::build_all()))), 'style/images/edit.gif', 'Sửa tài liệu');
             $row['delete'] = AZLib::buttonDel(Url::build_current(array('cmd' => 'delete', 'id' => $row['id'], "href" => urlencode('?' . $_SERVER['QUERY_STRING']))), 'style/images/delete.gif', 'Sửa tài liệu');
             if ($row['url']) {
                 $row['document_detail'] = $row['url'];
             } else {
                 $row['document_detail'] = WEB_DIR . "download-{$row['id']}/" . AZLib::safe_title($row['title']) . ".html";
                 $row['url'] = WEB_ROOT . "download-{$row['id']}/" . AZLib::safe_title($row['title']) . ".html";
             }
             $documents[$row['id']] = $row;
         }
     }
     $display->add('documents', $documents);
     $display->output('DocumentAdmin');
     $this->endForm();
 }
示例#8
0
 function draw()
 {
     global $display;
     $this->beginForm(false, "POST", false, Url::build_current());
     $key_word = Url::get('key_word');
     $condition = " status=1";
     $display->add('key_word', $key_word);
     if ($key_word) {
         $key_word_s = '';
         $arr = explode(' ', $key_word);
         if ($arr) {
             foreach ($arr as $key) {
                 $key = trim($key);
                 if ($key != '') {
                     $key_word_s .= ($key_word_s == '' ? '+' : ' +') . "{$key}";
                 }
             }
         }
         if ($key_word_s != '') {
             $condition .= " AND MATCH(title, des) AGAINST ('{$key_word_s}' IN BOOLEAN MODE)";
         }
         //$condition .= ' AND (title LIKE "%'.$key_word.'%" OR des LIKE "%'.$key_word.'%")';
     }
     $total_item = DB::count('document', $condition);
     $limit = '';
     $paging = AZPagging::paging_list($limit, $total_item, 10, 10, 'page_no', '', true, 'Tài liệu', 'Trang');
     $display->add('paging', $paging);
     $condition = 'WHERE' . $condition;
     $documents = array();
     $sql = 'SELECT * FROM document ' . $condition . ' ORDER BY id DESC ' . $limit;
     $re = DB::query($sql);
     if ($re) {
         $i = 1;
         while ($row = mysql_fetch_assoc($re)) {
             $row['title'] = stripslashes($row['title']);
             $row['des'] = AZLib::remove_4_js(AZLib::plainText(html_entity_decode($row['des'], ENT_QUOTES, "UTF-8")));
             $row['des'] = str_replace(array("'", "\""), array("", " "), $row['des']);
             $row['des'] = AZLib::word_limit($row['des'], 200, '');
             if (++$i % 2) {
                 $row['bgcolor'] = "#FFFFFF";
             } else {
                 $row['bgcolor'] = "#D9D9D9";
             }
             $row['time_m'] = $row['time_m'] ? date("d/m/Y", $row['time_m']) : '';
             if (User::is_admin()) {
                 $row['change'] = AZLib::button(Url::build_current(array('cmd' => 'change', 'id' => $row['id'], "href" => urlencode(Url::build_all()))), 'style/images/unexam.gif', 'Disable');
                 $row['edit'] = AZLib::button(Url::build('document', array('cmd' => 'edit', 'id' => $row['id'], "href" => urlencode(Url::build_all()))), 'style/images/edit.gif', 'Sửa tài liệu');
                 $row['delete'] = AZLib::buttonDel(Url::build_current(array('cmd' => 'delete', 'id' => $row['id'], "href" => urlencode('?' . $_SERVER['QUERY_STRING']))), 'style/images/delete.gif', 'Sửa tài liệu');
             }
             if ($row['url']) {
                 $row['document_detail'] = $row['url'];
             } else {
                 $row['document_detail'] = WEB_DIR . "download-{$row['id']}/" . AZLib::safe_title($row['title']) . ".html";
             }
             $documents[$row['id']] = $row;
         }
     }
     $display->add('documents', $documents);
     if (User::is_admin()) {
         $display->add("is_admin", 1);
     }
     $display->output('DocumentList');
     $this->endForm();
 }
示例#9
0
文件: Build.php 项目: duynhan07/elink
 function draw()
 {
     global $display;
     $items = array();
     $bcats = array();
     $filter_groups = array();
     if (Build::$bcatid) {
         $filter_ids = trim(DB::fetch("SELECT GROUP_CONCAT(filter_ids SEPARATOR ',') AS filter_ids FROM (SELECT filter_ids FROM item WHERE " . CGlobal::$item_condition . " AND filter_ids != '') AS filter", 'filter_ids', ''));
         $pf_array = array();
         if ($filter_ids != '') {
             $f_array = array_count_values(explode(',', $filter_ids));
             foreach ($f_array as $fid => $count) {
                 if (isset(CGlobal::$allFilters[$fid])) {
                     $fgid = CGlobal::$allFilters[$fid]['fgid'];
                     if (isset(CGlobal::$all_gfilters[$fgid])) {
                         $pf_array[$fgid][$fid] = $count;
                     }
                 }
             }
         }
         //Tạo Menu Filter
         if ($this->filter_groups) {
             foreach ($this->filter_groups as $fgid => $gfilter) {
                 if (isset($pf_array[$fgid])) {
                     if ($gfilter['filters']) {
                         $group_filter = array();
                         foreach ($gfilter['filters'] as $fid => $filter) {
                             if (isset($pf_array[$fgid][$fid])) {
                                 if (!$group_filter) {
                                     $group_filter = array('name' => CGlobal::$all_gfilters[$fgid]['name'], 'filters' => array());
                                 }
                                 $link = AZRewrite::formatUrl(Url::build_all(array('min', 'max', 'filter', 'page_no')));
                                 if ($this->filter_get) {
                                     foreach ($this->filter_get as $get_gid => $get_fid) {
                                         if ($get_gid != $fgid) {
                                             $link .= "&filter[{$get_gid}]={$get_fid}";
                                         }
                                     }
                                 }
                                 if (isset($this->filter_get[$fgid]) && $this->filter_get[$fgid] == $filter['id']) {
                                     if ($this->min) {
                                         $link .= "&min=" . $this->min;
                                     }
                                     if ($this->max) {
                                         $link .= "&max=" . $this->max;
                                     }
                                     $group_filter['filters'] = array($fid => array('link' => $link, 'name' => $filter['name'], 'count' => $pf_array[$fgid][$fid], 'remove' => 1));
                                     break;
                                 } else {
                                     $link .= "&filter[{$fgid}]={$filter['id']}";
                                     //$link = str_replace(array('?filter=&','?filter=','&filter='),array('?','',''),$link);
                                     if ($this->min) {
                                         $link .= "&min=" . $this->min;
                                     }
                                     if ($this->max) {
                                         $link .= "&max=" . $this->max;
                                     }
                                 }
                                 $group_filter['filters'][$fid] = array('link' => $link, 'name' => $filter['name'], 'count' => $pf_array[$fgid][$fid]);
                             }
                         }
                         if ($group_filter) {
                             $filter_groups[$fgid] = $group_filter;
                         }
                     }
                 }
             }
         }
         $display->add('url_filter', Url::build_current(array('mode', 'bcatid' => Build::$bcatid)));
         $display->add('cat_name', CGlobal::$allCategories[Build::$bcatid]['name']);
         if (isset(Build::$cats[Build::$bcatid]['next_id']) && Build::$cats[Build::$bcatid]['next_id']) {
             $display->add('next_url', Url::build_current(array('mode', 'bcatid' => Build::$cats[Build::$bcatid]['next_id'])));
         } else {
             $display->add('next_url', Url::build_current());
         }
         $display->add('recomend', str_replace(chr(13) . chr(10), "<br />", CGlobal::$allCategories[Build::$bcatid]['recomend']));
         $display->add('filter_groups', $filter_groups);
         $display->add('filter_price', $this->filter_price);
         $sql = 'SELECT * FROM item WHERE ';
         $where = '';
         $sql .= CGlobal::$item_condition . " ORDER BY price ASC";
         $total_row = DB::count("item", CGlobal::$item_condition);
         #######################################################################################
         #Paging
         $filter_get = Url::get('filter');
         $min = Url::get('min');
         $max = Url::get('max');
         $order = Url::get('order');
         $paging = AZPagging::paging_list($limit, $total_row, 10, 10, 'page_no', '', true, 'Linh kiện', 'Trang');
         $sql .= $limit;
         #Paging
         #######################################################################################
         $re = DB::query($sql);
         if ($re) {
             while ($item = mysql_fetch_assoc($re)) {
                 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['price'] = AZLib::convertCurrency($item['price'], $item['currency_id']);
                 if ($item['price']) {
                     $item['price'] = number_format($item['price'], 0, ',', '.') . " VNĐ";
                 } else {
                     $item['price'] = 'Liên hệ';
                 }
                 if ($item['list_brief'] == '') {
                     $item['list_brief'] = $item['brief'];
                 }
                 $item['list_brief'] = AZLib::remove_4_js(AZLib::plainText(AZLib::parseBBCode(html_entity_decode($item['list_brief'], ENT_QUOTES, "UTF-8"))));
                 $item['list_brief'] = preg_replace("/\\[([\\s]*[0-9]{1,2}[\\s]*)\\]/eis", " ", $item['list_brief']);
                 $item['list_brief'] = str_replace(array("'", "\""), array("", " "), $item['list_brief']);
                 $item['list_brief'] = AZLib::word_limit($item['list_brief'], 50, '');
                 $item['select'] = Url::build_current(array('bcatid' => $item['category_id'], 'mode', 'item_id' => $item['id']));
                 $items[$item['id']] = $item;
             }
         }
         $display->add('items', $items);
         $display->add('paging', $paging);
     }
     $display->add('bcats', Build::$cats);
     if (Build::$price) {
         $display->add('total_price', number_format(Build::$price, 0, ',', '.') . " VNĐ");
     }
     $display->add('bitems', Build::$items);
     $display->add('bcatid', Build::$bcatid);
     $display->add('cur_url', $_SERVER['REQUEST_URI']);
     $display->add("print_link", Url::open_popup(Url::build('build_print'), 1000, 800, false, false, false, false, false, 1, 1));
     $build_catids = @CGlobal::$configs['BuildCatIDs']['conf_val'];
     $display->add('build_catids', $build_catids);
     $display->add('is_admin', User::is_admin());
     $display->add('begin_form', $this->beginForm(false, 'post', false, false, 1));
     $display->add('end_form', $this->endForm(1));
     $display->output('Build');
 }
示例#10
0
 function draw_from()
 {
     //mb_internal_encoding("UTF-8");
     //AZLib::getCats();
     AZLib::getProvinces();
     global $display;
     $page_no = (int) Url::get('page_no', 1);
     if ($page_no <= 0) {
         $page_no = 1;
     }
     $admin_item = FALSE;
     if (User::have_permit(ADMIN_ITEM)) {
         $admin_item = TRUE;
     }
     $item_per_page = 30;
     $sql = 'SELECT * FROM item WHERE ';
     $where = '';
     $curMainCat = CGlobal::$curMainCat;
     $curLevel2Cat = CGlobal::$curLevel2Cat;
     /*if($curLevel2Cat){
                   $where		.=($where!=''?" AND ":"")." level_2_catid = ".$curLevel2Cat['id'];
               }
               elseif($curMainCat){
                   $where		.=($where!=''?" AND ":"")." level_1_catid = ".$curMainCat['id'];
               }
     
               $where	.= ($where!=''?" AND ":"")." status=1";
     
               $sql		.= "$where ORDER BY item_order ASC";*/
     if (!CGlobal::$item_condition) {
         //Ngannv hack code trường hợp khong add module FilterMenu hoặc module Build
         if (isset($_GET['category_id']) && $_GET['category_id']) {
             CGlobal::$item_condition = " category_id = " . CGlobal::$curCategory . " ";
         }
     }
     $sql .= CGlobal::$item_condition . " ORDER BY item_order ASC";
     $total_row = DB::count("item", CGlobal::$item_condition);
     if (CGlobal::$allCategories[CGlobal::$curCategory]['parent_id'] && isset(CGlobal::$allCategories[CGlobal::$allCategories[CGlobal::$curCategory]['parent_id']])) {
         $ebname = CGlobal::$allCategories[CGlobal::$allCategories[CGlobal::$curCategory]['parent_id']]['ebname'] . '-' . CGlobal::$allCategories[CGlobal::$curCategory]['ebname'];
     } else {
         $ebname = CGlobal::$allCategories[CGlobal::$curCategory]['ebname'];
     }
     #######################################################################################
     #Paging
     $url_new = "?page=list_detail&category_id=" . CGlobal::$curCategory . "&ebname=" . $ebname;
     $url_addend = "";
     $filter_get = Url::get('filter');
     $min = Url::get('min');
     $max = Url::get('max');
     $order = Url::get('order');
     if ($filter_get) {
         foreach ($filter_get as $get_gid => $get_fid) {
             $url_addend .= ($url_addend != '' ? '&' : '?') . "filter[{$get_gid}]={$get_fid}";
         }
     }
     if ($min) {
         $url_addend .= ($url_addend != '' ? '&' : '?') . "min={$min}";
     }
     if ($max) {
         $url_addend .= ($url_addend != '' ? '&' : '?') . "max={$max}";
     }
     if ($order) {
         $url_addend .= ($url_addend != '' ? '&' : '?') . "order={$order}";
     }
     $limit = '';
     $paging = AZPagging::paging_list($limit, $total_row, $item_per_page, 10, 'page_no', $url_new, TRUE, 'Sản phẩm', 'Trang', $url_addend);
     //$paging = AZPagging::paging_list($limit,$item_per_page,'page_no',$url_new);
     $sql .= $limit;
     #Paging
     #######################################################################################
     $items = array();
     $re = DB::query($sql);
     if ($re) {
         while ($item = mysql_fetch_assoc($re)) {
             $items[$item['id']] = $this->processItem($item, $admin_item);
         }
     }
     $display->add('admin_item', $admin_item);
     $display->add('page', $page_no);
     $display->add('items', $items);
     $display->add('paging', $paging);
     $display->output("ListItem");
 }