Esempio n. 1
0
 function FilterMenuSearch($row)
 {
     Module::Module($row);
     AZLib::getFilters();
     require_once 'forms/FilterMenuSearch.php';
     $this->add_form(new FilterMenuSearchForm());
 }
Esempio n. 2
0
 function on_submit()
 {
     $gfsubmit = Url::get("gfsubmit");
     if ($gfsubmit) {
         $fgroup_id = (int) implode(array_keys($gfsubmit));
         if ($fgroup_id) {
             $fgroup = DB::select("filter_group", "id={$fgroup_id}");
             if ($fgroup) {
                 $gf_name = Url::get('gf_name');
                 $gf_pos = Url::get('gf_pos');
                 if (isset($gf_name[$fgroup_id], $gf_pos[$fgroup_id]) && $gf_name[$fgroup_id] && $gf_pos[$fgroup_id]) {
                     $gf_name = $gf_name[$fgroup_id];
                     $gf_pos = $gf_pos[$fgroup_id];
                     if ($fgroup['name'] != $gf_name || $fgroup['pos'] != $gf_pos) {
                         $max_pos = (int) DB::fetch("SELECT max(pos) AS max_pos FROM filter_group", 'max_pos', 0);
                         if ($gf_pos > $max_pos) {
                             $gf_pos = $max_pos;
                         } elseif ($gf_pos <= 0) {
                             $gf_pos = $fgroup['pos'];
                         }
                         DB::update('filter_group', array("name" => $gf_name, "pos" => $gf_pos), "id={$fgroup_id}");
                         if (DB::select('filter_group', "pos={$gf_pos} AND id!={$fgroup_id}")) {
                             DB::query("UPDATE filter_group SET pos=pos+1 WHERE pos>={$gf_pos} AND pos<={$fgroup['pos']} AND id!={$fgroup_id}");
                         }
                         AZLib::getFilters(1);
                     }
                 }
             }
         }
         Url::redirect_current(array('cmd'));
     }
     $submit = Url::get("submit");
     if ($submit == "Thêm nhóm thuộc tính") {
         $gfilter_name = Url::get('gfilter_name');
         $gfilter_pos = Url::get('gfilter_pos');
         if ($gfilter_name != '' && $gfilter_pos) {
             $gfilter_group = array('name' => $gfilter_name, 'catids' => $this->cat['id'], 'pos' => $gfilter_pos);
             $max_pos = (int) DB::fetch("SELECT max(pos) AS max_pos FROM filter_group", 'max_pos', 0);
             if ($gfilter_pos > $max_pos || $gfilter_pos <= 0) {
                 $gfilter_pos = $max_pos + 1;
             }
             $gfilter_group['pos'] = $gfilter_pos;
             $id = DB::insert('filter_group', $gfilter_group);
             if ($id && DB::select('filter_group', 'pos="' . $gfilter_pos . '" AND id!=' . $id)) {
                 DB::query('UPDATE filter_group SET pos=pos+1 WHERE pos>=' . $gfilter_pos . ' AND id!=' . $id);
             }
         }
         AZLib::getFilters(1);
         Url::redirect_current(array('cmd'));
     }
     Url::redirect_current(array('cmd'));
 }
Esempio n. 3
0
 function add_filter()
 {
     $data = array('msg' => '');
     if (User::is_login()) {
         if (User::have_permit(ADMIN_ITEM)) {
             AZLib::getFilters();
             $fgid = (int) Url::get("fgid");
             $f_name = trim(Url::get("f_name"));
             if ($fgid && isset(CGlobal::$all_gfilters[$fgid])) {
                 if ($f_name != '') {
                     $f_pos = 1 + (int) DB::fetch("SELECT max(pos) AS max_pos FROM filter WHERE fgid={$fgid}", 'max_pos', 0);
                     $filter = array('name' => $f_name, 'fgid' => $fgid, 'pos' => $f_pos);
                     $id = DB::insert('filter', $filter);
                     AZLib::getFilters(1);
                     $data['id'] = $id;
                     echo json_encode($data);
                     exit;
                 } else {
                     $data = array('msg' => 'Bạn chưa nhập tên cho thuộc tính!');
                     echo json_encode($data);
                     exit;
                 }
             } else {
                 $data = array('msg' => 'Nhóm thuộc tính không tồn tại!');
                 echo json_encode($data);
                 exit;
             }
         }
     } else {
         $data['msg'] = 'not_login';
         echo json_encode($data);
         exit;
     }
     $data['msg'] = 'no_perm';
     echo json_encode($data);
     exit;
 }
Esempio n. 4
0
 function on_submit()
 {
     $gfsubmit = Url::get("gfsubmit");
     if ($gfsubmit) {
         $fgroup_id = (int) implode(array_keys($gfsubmit));
         if ($fgroup_id) {
             $fgroup = DB::select("filter_group", "id={$fgroup_id}");
             if ($fgroup) {
                 $gf_name = Url::get('gf_name');
                 $gf_pos = Url::get('gf_pos');
                 if (isset($gf_name[$fgroup_id], $gf_pos[$fgroup_id]) && $gf_name[$fgroup_id] && $gf_pos[$fgroup_id]) {
                     $gf_name = $gf_name[$fgroup_id];
                     $gf_pos = $gf_pos[$fgroup_id];
                     if ($fgroup['name'] != $gf_name || $fgroup['pos'] != $gf_pos) {
                         $max_pos = (int) DB::fetch("SELECT max(pos) AS max_pos FROM filter_group", 'max_pos', 0);
                         if ($gf_pos > $max_pos) {
                             $gf_pos = $max_pos;
                         } elseif ($gf_pos <= 0) {
                             $gf_pos = $fgroup['pos'];
                         }
                         DB::update('filter_group', array("name" => $gf_name, "pos" => $gf_pos), "id={$fgroup_id}");
                         if (DB::select('filter_group', "pos={$gf_pos} AND id!={$fgroup_id}")) {
                             DB::query("UPDATE filter_group SET pos=pos+1 WHERE pos>={$gf_pos} AND pos<={$fgroup['pos']} AND id!={$fgroup_id}");
                         }
                         AZLib::getFilters(1);
                     }
                 }
             }
         }
         Url::redirect_current(array('cmd', 'id'));
     }
     $submit = Url::get("submit");
     if ($submit == "Thêm nhóm thuộc tính") {
         $gfilter_name = Url::get('gfilter_name');
         $gfilter_pos = Url::get('gfilter_pos');
         if ($gfilter_name != '' && $gfilter_pos) {
             $gfilter_group = array('name' => $gfilter_name, 'catids' => $this->cat['id'], 'pos' => $gfilter_pos);
             $max_pos = (int) DB::fetch("SELECT max(pos) AS max_pos FROM filter_group", 'max_pos', 0);
             if ($gfilter_pos > $max_pos || $gfilter_pos <= 0) {
                 $gfilter_pos = $max_pos + 1;
             }
             $gfilter_group['pos'] = $gfilter_pos;
             $id = DB::insert('filter_group', $gfilter_group);
             if ($id && DB::select('filter_group', 'pos="' . $gfilter_pos . '" AND id!=' . $id)) {
                 DB::query('UPDATE filter_group SET pos=pos+1 WHERE pos>=' . $gfilter_pos . ' AND id!=' . $id);
             }
         }
         AZLib::getFilters(1);
         Url::redirect_current(array('cmd', 'id'));
     }
     $name = Url::get('name');
     $brief_name = Url::get('brief_name');
     $keywords = Url::get('keywords');
     $description = Url::get('description');
     $parent_id = Url::get('parent_id');
     $zoneids = Url::get('zoneids');
     $ref_id = Url::get('ref_id');
     $status = Url::get('status', 'HIDE');
     $position = Url::get('position');
     $tag_search = Url::get('tag_search');
     $price_str = trim(Url::get('price_str'));
     $recomend = trim(Url::get('recomend'));
     if ($price_str) {
         function check_price_str($price)
         {
             return Url::cdouble(trim($price));
         }
         $price_ar = array_unique(array_map('check_price_str', explode(",", $price_str)));
         $price_str = '';
         if ($price_ar) {
             asort($price_ar);
             foreach ($price_ar as $price) {
                 if ($price > 0) {
                     $price_str .= ($price_str != '' ? ',' : '') . $price;
                 }
             }
         }
     }
     $this->checkFormInput('Tên Danh mục', 'name', $name, 'str', true, '', 1, 255);
     $this->checkFormInput('Tên vắn tắt', 'brief_name', $brief_name, 'str', false, '', 1, 255);
     //$this->checkFormInput('Từ khoá','keywords',$keywords,'str',false,'',0,20);
     $this->checkFormInput('Mô tả', 'description', $description, 'str', false, '', 0, 250);
     if (Url::get('cmd') == 'edit' && $this->cat['parent_id'] == 0 && $parent_id && DB::select("category", 'parent_id=' . $this->cat['id'])) {
         $this->setFormError("parent_id", 'Không thể chuyển "Danh mục có danh mục con" thành một "Danh mục con" của "Danh mục khác" được!');
     }
     if (!$this->errNum) {
         $new_row = array('name' => $name, 'brief_name' => $brief_name ? $brief_name : $name, 'keywords' => AZLib::word_limit($keywords, 20, ''), 'description' => $description, 'parent_id' => $parent_id, 'ref_id' => $ref_id, 'status' => $status, 'tag_search' => $tag_search, 'img_server' => IMAGE_SERVER_NO, 'price_str' => $price_str, 'recomend' => $recomend);
         if (Url::get('cmd') == 'edit') {
             if ($position > 0 && $position != $this->cat['position']) {
                 $max_pos = (int) DB::fetch("SELECT max(position) AS max_pos FROM category WHERE parent_id=" . $parent_id, 'max_pos');
                 if ($position > $max_pos) {
                     $position = $max_pos + 1;
                 }
                 $new_row['position'] = $position;
             } else {
                 $position = $this->cat['position'];
             }
             $id = $this->cat['id'];
             DB::update('category', $new_row, 'id=' . $this->cat['id']);
             /*if($this->cat['parent_id']==0 && $parent_id){
             			DB::update('category', array('parent_id'=>0),'parent_id='.$this->cat['parent_id']);
             		}*/
         } else {
             $max_pos = (int) DB::fetch("SELECT max(position) AS max_pos FROM category WHERE parent_id=" . $parent_id, 'max_pos');
             if ($position > $max_pos || $position == 0) {
                 $position = $max_pos + 1;
             }
             $new_row['position'] = $position;
             $id = DB::insert('category', $new_row);
         }
         if ($_FILES['cat_image']['tmp_name']) {
             if (Url::get('cmd') == 'edit') {
                 AZLib::ftp_image_delete_file('category/' . $this->cat['id'] . '.gif', $this->cat['img_server']);
             }
             /*if(AZLib::ftp_image_connect(IMAGE_SERVER_NO)){
             			if(!AZLib::ftp_check_dir('category/',true,IMAGE_SERVER_NO)){
             				break ;
             			}
             				
             			$file_name	='category/'.$id.'.gif';
             			$sourceName =$_FILES['cat_image']['tmp_name'];
             			AZLib::ftp_image_put_file($file_name,$sourceName,IMAGE_SERVER_NO);
             			//@fopen('http://'.IMAGE_PATH.'?del_cat=1',"r");
             		}*/
             if (AZLib::ftp_check_dir('category/', true, IMAGE_SERVER_NO)) {
                 $file_name = 'category/' . $id . '.gif';
                 $sourceName = $_FILES['cat_image']['tmp_name'];
                 AZLib::ftp_image_put_file($file_name, $sourceName, IMAGE_SERVER_NO);
                 //@fopen('http://'.IMAGE_PATH.'?del_cat=1',"r");
             }
         }
         if ($id && DB::select('category', 'position="' . $position . '" AND id!="' . $id . '" AND parent_id="' . $parent_id . '"')) {
             DB::query('UPDATE category SET position=position+1 WHERE position>=' . $position . ' AND position<=' . $this->cat['position'] . ' AND parent_id="' . $parent_id . '" AND id!=' . $id);
         }
         $all_zones = $this->zones;
         $sql_inset = "";
         if ($zoneids) {
             foreach ($zoneids as $zoneid) {
                 if (isset($all_zones[$zoneid])) {
                     unset($all_zones[$zoneid]);
                 } else {
                     $sql_inset .= ($sql_inset != '' ? ',' : '') . "({$zoneid},{$id})";
                 }
             }
         }
         if ($sql_inset) {
             $sql_inset = "INSERT INTO category_zone_cat (zoneid, catid) VALUES " . $sql_inset;
             DB::query($sql_inset);
         }
         if ($all_zones) {
             $zoneids = implode(",", array_keys($all_zones));
             if ($zoneids) {
                 DB::query("DELETE FROM category_zone_cat WHERE catid={$id} AND zoneid IN({$zoneids})");
             }
         }
         //AZLib::del_cache_zone_cat();
         AZLib::getCats(1, true);
         if (Url::get('cmd') == 'edit' && $this->cat['parent_id'] != $parent_id) {
             //đổi danh mục cha => cập nhật lại tin
             $catid = $this->cat['id'];
             $level_1 = 0;
             $level_2 = 0;
             if ($parent_id) {
                 if (CGlobal::$allCategories[$parent_id]['parent_id']) {
                     $level_1 = CGlobal::$allCategories[$parent_id]['parent_id'];
                     $level_2 = $parent_id;
                 } else {
                     $level_1 = $parent_id;
                     $level_2 = $catid;
                 }
             } else {
                 $level_1 = $catid;
                 $level_2 = 0;
             }
             DB::update("item", array("level_1_catid" => $level_1, "level_2_catid" => $level_2), "category_id={$catid}");
             if (MEMCACHE_ON) {
                 AZMemcache::clear();
             }
         }
         if ($this->cat) {
             Url::redirect_current();
         } else {
             Url::redirect_current(array('cmd'));
         }
     }
 }
Esempio n. 5
0
 static function remove_cat_group_filer($catid, $fgid)
 {
     AZLib::getFilters();
     if ($catid && $fgid && isset(CGlobal::$allCategories[$catid], CGlobal::$all_gfilters[$fgid])) {
         $filter_group = DB::select('filter_group', 'id=' . $fgid);
         if ($filter_group && $filter_group['catids']) {
             $arr = explode(',', $filter_group['catids']);
             if (in_array($catid, $arr)) {
                 $arr = array_unique(array_flip($arr));
                 unset($arr[$catid]);
                 $catids = '';
                 if ($arr) {
                     $catids = implode(',', array_flip($arr));
                 }
                 DB::update("filter_group", array("catids" => $catids), "id={$fgid}");
             }
         }
         AZLib::getFilters(1);
     }
 }
Esempio n. 6
0
 function __construct()
 {
     //check secrurity
     if (!$_SERVER["HTTP_ACCEPT_ENCODING"] && !$_SERVER["HTTP_ACCEPT_LANGUAGE"]) {
         Url::redirect('home');
     }
     Form::Form('PostItemForm');
     AZLib::getCats();
     CGlobal::$website_title = 'Đăng sản phẩm';
     $this->link_css('style/postItem.css');
     $this->link_css('style/gallery.css');
     //$this->link_js('javascript/jquery/jquery-1.3.2.js');
     $this->link_js('javascript/jquery/jquery.livequery.js');
     $this->link_js('javascript/jquery/jquery.jcache.js');
     $this->link_js('javascript/jquery/jquery.form.js');
     $this->link_js('javascript/jquery/jquery.ui.js');
     $this->link_js('javascript/jquery/ui.draggable.js');
     $this->link_js('javascript/jquery/ui.droppable.js');
     // For checking flash version of browser
     $this->link_js('javascript/AC_RunActiveContent.js');
     // For ajax upload when use IE or other browser has no flash
     $this->link_js('javascript/si.files.js');
     $this->link_js('javascript/ajaxfileupload.js');
     // For flash upload
     $this->link_js('javascript/swfupload/swfupload.js');
     $this->link_js('javascript/swfupload/js/swfupload.swfobject.js');
     $this->link_js('javascript/swfupload/js/swfupload.queue.js');
     $this->link_js('javascript/swfupload/js/fileprogress.js');
     $this->link_js('javascript/post_item_handlers.js');
     if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
         $this->browser_is_ie = 1;
     } else {
         $this->browser_is_ie = 0;
     }
     $this->link_js('javascript/jquery/jquery.event.drag-1.0.js');
     $this->link_js('javascript/post_item.js');
     if ((int) ini_get("memory_limit") < 64) {
         @ini_set("memory_limit", "64M");
     }
     //$this->no_image = AZLib::getImageSrc('',70,70);
     $this->no_image = STATIC_URL . 'style/images/no-images-69x53.jpg';
     $index = 1;
     for ($i = 1; $i <= $this->max_image_page; $i++) {
         //trang ảnh
         $this->item_images[$i] = array();
         for ($n = 1; $n <= $this->images_per_page; $n++) {
             //số ảnh trên trang
             $this->item_images[$i][$n]['stt'] = $index;
             if (isset($_POST['img_new'][$index]) && $_POST['img_new'][$index]) {
                 //$this->item_images[$i][$n]['image_url']	=AZLib::getImageThumb($_POST['image_url'][$index],80,80);
                 //$this->item_images[$i][$n]['image_url']	= $this->no_image;
                 $this->jsImages[$index]['w180'] = 'thumb_w/180/';
                 $this->jsImages[$index]['img_server'] = $_POST['i_server'][$index];
                 //$this->jsImages[$index]['server_address'] = CGlobal::$img_server[$_POST['i_server'][$index]];
                 $this->jsImages[$index]['img_url'] = $_POST['i_url'][$index];
                 $this->jsImages[$index]['image_url'] = AZLib::getImageThumb($_POST['i_url'][$index], 80, 80, 0, $_POST['i_server'][$index]);
                 $this->item_images[$i][$n]['img_server'] = $_POST['i_server'][$index];
                 $this->item_images[$i][$n]['i_url'] = $_POST['i_url'][$index];
                 $this->item_images[$i][$n]['image_url'] = AZLib::getImageThumb($_POST['i_url'][$index], 80, 80, 0, $_POST['i_server'][$index]);
                 $this->item_images[$i][$n]['title'] = $_POST['image_title'][$index];
                 $this->item_images[$i][$n]['id'] = '0';
                 $this->item_images[$i][$n]['img_new_id'] = $_POST['img_new'][$index];
                 $this->item_images[$i][$n]['have_img'] = 1;
                 $this->item_images[$i][$n]['img_del_id'] = 0;
             } else {
                 $this->item_images[$i][$n]['img_server'] = 0;
                 $this->item_images[$i][$n]['image_url'] = $this->no_image;
                 $this->item_images[$i][$n]['i_url'] = '';
                 $this->item_images[$i][$n]['title'] = 'Ghi chú ảnh';
                 $this->item_images[$i][$n]['id'] = '';
                 $this->item_images[$i][$n]['img_new_id'] = 0;
                 $this->item_images[$i][$n]['have_img'] = 0;
                 $this->item_images[$i][$n]['img_del_id'] = 0;
             }
             $index++;
         }
     }
     AZLib::getFilters();
 }
Esempio n. 7
0
 function BuildForm()
 {
     Form::Form('BuildForm');
     CGlobal::$website_title = "Xây dựng cấu hình máy tính";
     if (Build::$bcatid) {
         $this->filter_get = Url::get('filter');
         AZLib::getFilters();
         if (isset(CGlobal::$filters[Build::$bcatid])) {
             $this->filter_groups = CGlobal::$filters[Build::$bcatid];
         }
         #############################################################################################################################################
         #Search condition
         CGlobal::$item_condition = "category_id = " . Build::$bcatid . " AND quantity>0 AND status = 1 AND price>0 AND quantity>0";
         //CGlobal::$item_condition .="status = 1 AND filter_ids != ''";
         $filter_str = '';
         if (isset(CGlobal::$filters[Build::$bcatid])) {
             $this->filter_groups = CGlobal::$filters[Build::$bcatid];
             $filter_get = $this->filter_get;
             $this->filter_get = array();
             if ($this->filter_groups) {
                 foreach ($this->filter_groups as $fgid => $gfilter) {
                     if ($filter_get && isset($filter_get[$fgid]) && $filter_get[$fgid]) {
                         $fid = $filter_get[$fgid];
                         if ($gfilter['filters'] && in_array($fid, array_keys($gfilter['filters']))) {
                             CGlobal::$no_paging = true;
                             $this->filter_get[$fgid] = $fid;
                             $filter_str .= ($filter_str == '' ? '+' : ' +') . "g{$fgid}f{$fid}f";
                         }
                     }
                 }
             }
         }
         $price_str = CGlobal::$allCategories[Build::$bcatid]['price_str'];
         if ($price_str) {
             $filter_price = array();
             $arr = explode(',', $price_str);
             $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) {
                     $link .= "&filter[{$get_gid}]={$get_fid}";
                 }
             }
             //SELECT 	SUM((price < 2000000 AND currency_id=1) OR ((price* 18000)< 200000 AND currency_id=2)) AS filter,
             //SUM((price >= 2000000 AND price< 5000000  AND currency_id=1) OR ((price* 18000) >= 200000 AND (price* 18000) < 500000 AND currency_id=2)) AS filter
             //FROM products
             $last_price = 0;
             $get_min = (int) Url::get('min', 0);
             $get_max = (int) Url::get('max', 0);
             $i = 1;
             foreach ($arr as $price) {
                 if ($last_price == 0) {
                     $this->price_cout_str .= ($this->price_cout_str != '' ? ',' : '') . " SUM((price < {$price} AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") < {$price} AND currency_id=2)) AS `0`";
                 } else {
                     $this->price_cout_str .= ($this->price_cout_str != '' ? ',' : '') . " SUM((price >= {$last_price} AND price < {$price} AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") >= {$last_price} AND (price * " . CGlobal::$exchange . ") < {$price} AND currency_id=2)) AS `{$last_price}`";
                 }
                 if ($get_min == $last_price && $get_max == $price) {
                     $this->min = $get_min;
                     $this->max = $get_max;
                 }
                 $filter_price[] = array('min' => $last_price, 'max' => $price);
                 $last_price = $price;
                 $i++;
             }
             if ($last_price) {
                 if ($get_min == $last_price && $get_max == 0) {
                     $this->min = $get_min;
                     $this->max = 0;
                 }
                 $this->price_cout_str .= ($this->price_cout_str != '' ? ',' : '') . "SUM((price >= {$last_price} AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") >= {$last_price} AND currency_id=2)) AS `{$last_price}`";
                 $filter_price[] = array('min' => $last_price, 'max' => 0);
                 $last_price = $price;
             }
             if ($this->min) {
                 CGlobal::$item_condition .= " AND ((price >= " . $this->min . " AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") >= " . $this->min . " AND currency_id=2))";
             }
             if ($this->max) {
                 CGlobal::$item_condition .= " AND ((price < " . $this->max . " AND currency_id=1) OR ((price * " . CGlobal::$exchange . ") < " . $this->max . " AND currency_id=2))";
             }
         }
         if ($filter_str) {
             CGlobal::$item_condition .= " AND MATCH(filter_search) AGAINST ('{$filter_str}' IN BOOLEAN MODE)";
         }
         #############################################################################################################################################
         if ($this->price_cout_str) {
             $this->filter_price = array('name' => "Giới hạn theo giá (VNĐ)", 'filters' => array());
             $price_cout_arr = DB::fetch("SELECT " . $this->price_cout_str . " FROM item WHERE " . CGlobal::$item_condition);
             if ($filter_price) {
                 foreach ($filter_price as $fprice) {
                     $min = $fprice['min'];
                     $max = $fprice['max'];
                     if ($price_cout_arr[$min]) {
                         if ($min && $max) {
                             $link2 = "{$link}&min={$min}&max={$max}";
                             $name = AZLib::money($min) . " - " . AZLib::money($max);
                         } elseif (!$max) {
                             $link2 = "{$link}&min={$min}";
                             $name = "Trên " . AZLib::money($min);
                         } elseif (!$min) {
                             $link2 = "{$link}&max={$max}";
                             $name = "Dưới " . AZLib::money($max);
                         }
                         if ($this->min == $min && $this->max == $max) {
                             $this->filter_price['filters'][] = array('link' => $link, 'name' => $name, 'count' => $price_cout_arr[$min], 'remove' => 1);
                         } else {
                             $this->filter_price['filters'][] = array('link' => $link2, 'name' => $name, 'count' => $price_cout_arr[$min], 'remove' => 0);
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 8
0
 function __construct()
 {
     Form::Form('PostItemForm');
     $this->item = DB::select("item", "id=" . (int) Url::get('id', 0));
     //$this->item = Item::get_item(intval(Url::get('id',0)));
     if (!$this->item || !User::have_permit(ADMIN_ITEM)) {
         if (Url::get('ref')) {
             Url::redirect('manage_item');
         } else {
             Url::redirect('home');
         }
     }
     // Nếu ko fải là admin
     if (!User::have_permit(ADMIN_ITEM)) {
         if ($this->item['user_id'] != User::id() || $this->item['status'] == 4) {
             // neu khong phai chu topic
             Url::redirect('item_detail', array('id' => $this->item['id'], 'ebname' => AZLib::safe_title($this->item['name'])));
         }
     }
     CGlobal::$website_title = 'Sửa sản phẩm';
     $this->link_css('style/ItemDetail.css');
     $this->link_css('style/postItem.css');
     $this->link_css('style/gallery.css');
     //$this->link_js('javascript/jquery/jquery-1.3.2.js');
     $this->link_js('javascript/jquery/jquery.livequery.js');
     $this->link_js('javascript/jquery/jquery.jcache.js');
     $this->link_js('javascript/jquery/jquery.form.js');
     $this->link_js('javascript/jquery/jquery.ui.js');
     $this->link_js('javascript/jquery/ui.draggable.js');
     $this->link_js('javascript/jquery/ui.droppable.js');
     $this->link_js('javascript/count_character.js');
     // For checking flash version of browser
     $this->link_js('javascript/AC_RunActiveContent.js');
     // For ajax upload when use IE or other browser has no flash
     $this->link_js('javascript/si.files.js');
     $this->link_js('javascript/ajaxfileupload.js');
     // For flash upload
     $this->link_js('javascript/swfupload/swfupload.js');
     $this->link_js('javascript/swfupload/js/swfupload.swfobject.js');
     $this->link_js('javascript/swfupload/js/swfupload.queue.js');
     $this->link_js('javascript/swfupload/js/fileprogress.js');
     $this->link_js('javascript/post_item_handlers.js');
     $this->link_js('javascript/jquery/jquer y.event.drag-1.0.js');
     $this->link_js('javascript/post_item.js');
     if ((int) ini_get("memory_limit") < 64) {
         @ini_set("memory_limit", "64M");
     }
     //$this->no_image			 =AZLib::getImageSrc('',70,70);
     $this->no_image = STATIC_URL . 'style/images/no-images-69x53.jpg';
     //$re = DB::query('SELECT * FROM item_image WHERE item_id = '.$this->item['id'].' AND user_id = '.$this->item['user_id'].' ORDER BY position');
     $re = DB::query('SELECT * FROM item_image WHERE item_id = ' . $this->item['id'] . ' ORDER BY position');
     $this->images = array();
     $position_images = array();
     if ($re) {
         while ($img = mysql_fetch_assoc($re)) {
             if ($img['user_id'] == $this->item['user_id']) {
                 $img['title'] = str_replace(array('"'), array('&quot;'), stripslashes($img['title']));
                 $this->images[$img['id']] = $img;
                 if (!$img['user_id'] || !$img['user_name'] || !$img['time']) {
                     //Nếu ảnh cũ chưa được cập nhật một số thông tin
                     $img['user_id'] = $this->item['user_id'];
                     $img['user_name'] = $this->item['user_name'];
                     $img['time'] = $this->item['created_time'];
                     DB::update('item_image', $img, 'id=' . $img['id']);
                 }
                 $img['title'] = str_replace(array('"'), array('&quot;'), stripslashes($img['title']));
                 //$this->jsImages[$img['position']]['w180']= CGlobal::$img_server[$img['img_server']] . 'thumb_w/180/' . $img['img_url'];
                 $this->jsImages[$img['position']]['id'] = $img['id'];
                 $this->jsImages[$img['position']]['img_server'] = $img['img_server'];
                 $this->jsImages[$img['position']]['img_url'] = $img['img_url'];
                 $position_images[$img['position']] = $img;
                 $this->images[$img['id']] = $img;
             }
         }
     }
     $i = 1;
     if ($this->images) {
         foreach ($this->images as $image) {
             $i = $image['position'];
             $image['title'] = str_replace(array('"'), array('&quot;'), stripslashes($image['title']));
             $this->images_[$i] = $image;
         }
     }
     $index = 1;
     for ($i = 1; $i <= $this->max_image_page; $i++) {
         //trang ảnh
         $this->item_images[$i] = array();
         for ($n = 1; $n <= $this->images_per_page; $n++) {
             //số ảnh trên trang
             $this->item_images[$i][$n]['stt'] = $index;
             if (isset($_POST['img_new'][$index]) && $_POST['img_new'][$index]) {
                 $this->jsImages[$index]['w180'] = 'thumb_w/180/';
                 $this->jsImages[$index]['img_server'] = $_POST['i_server'][$index];
                 $this->jsImages[$index]['img_url'] = $_POST['i_url'][$index];
                 //$this->jsImages[$index]['server_address'] = CGlobal::$img_server[$_POST['i_server'][$index]];
                 $this->jsImages[$index]['image_url'] = AZLib::getImageThumb($_POST['i_url'][$index], 80, 80, 0, $_POST['i_server'][$index]);
                 $this->item_images[$i][$n]['id'] = '0';
                 $this->item_images[$i][$n]['img_server'] = $_POST['i_server'][$index];
                 $this->item_images[$i][$n]['i_url'] = $_POST['i_url'][$index];
                 $this->item_images[$i][$n]['image_url'] = AZLib::getImageThumb($_POST['i_url'][$index], 80, 80, 0, $_POST['i_server'][$index]);
                 $this->item_images[$i][$n]['title'] = $_POST['image_title'][$index];
                 $this->item_images[$i][$n]['img_new_id'] = $_POST['img_new'][$index];
                 $this->item_images[$i][$n]['have_img'] = 1;
                 if (isset($position_images[$index])) {
                     $this->item_images[$i][$n]['img_del_id'] = $position_images[$index]['id'];
                 } else {
                     $this->item_images[$i][$n]['img_del_id'] = 0;
                 }
             } elseif (isset($position_images[$index])) {
                 $this->item_images[$i][$n]['id'] = $position_images[$index]['id'];
                 $this->item_images[$i][$n]['img_server'] = $position_images[$index]['img_server'];
                 $this->item_images[$i][$n]['i_url'] = $position_images[$index]['img_url'];
                 $this->item_images[$i][$n]['image_url'] = AZLib::getImageThumb($position_images[$index]['img_url'], 80, 80, 0, $position_images[$index]['img_server']);
                 $this->item_images[$i][$n]['title'] = $position_images[$index]['title'];
                 $this->item_images[$i][$n]['img_new_id'] = 0;
                 $this->item_images[$i][$n]['have_img'] = 1;
                 $this->item_images[$i][$n]['img_del_id'] = 0;
             } else {
                 $this->item_images[$i][$n]['img_server'] = 0;
                 $this->item_images[$i][$n]['image_url'] = $this->no_image;
                 $this->item_images[$i][$n]['i_url'] = '';
                 $this->item_images[$i][$n]['title'] = 'Ghi chú ảnh';
                 $this->item_images[$i][$n]['id'] = '';
                 $this->item_images[$i][$n]['img_new_id'] = 0;
                 $this->item_images[$i][$n]['have_img'] = 0;
                 $this->item_images[$i][$n]['img_del_id'] = 0;
             }
             $index++;
         }
     }
     AZLib::getFilters();
 }