function actOrder()
 {
     global $ST, $get;
     $pg = new Page($this->getPages());
     $data = array();
     $cond = '';
     //		if($from=$this->getFilter('from')){
     //			$cond.=" AND create_time>='".dte($from,'Y-m-d')."'";
     //		}
     //		if($to=$this->getFilter('to')){
     //			$cond.=" AND create_time<='".dte($to,'Y-m-d')."'";
     //		}
     if ($from = $this->getFilter('from')) {
         $cond .= " AND date>='" . dte($from, 'Y-m-d') . "'";
     }
     if ($to = $this->getFilter('to')) {
         $cond .= " AND date<='" . dte($to, 'Y-m-d') . "'";
     }
     if (!in_array($this->getFilter('order_status'), array('all', ''))) {
         $order_status = (int) $this->getFilter('order_status');
         $cond .= " AND order_status=" . $order_status;
     }
     if ($get->exists('order_status')) {
         $cond .= " AND order_status={$get->getInt('order_status')}";
     }
     if ($this->getURIVal('pay_system')) {
         $cond .= " AND pay_system='{$this->getURIVal('pay_system')}'";
     }
     //		if($reg=$this->getUser('region')){//Привязка к региону админа
     //			$condition.=" AND o.region IN('".implode("','",explode(',',$reg))."')";
     //		}
     $query = "SELECT count(*) AS c FROM sc_shop_order AS o  WHERE 1=1 " . $cond;
     $rs = $ST->select($query);
     if ($rs->next()) {
         $pg->all = $rs->getInt('c');
     }
     $queryStr = "SELECT o.*, u.name AS u_name,u.phone AS u_phone, u.last_name AS last_name, u.first_name AS first_name, u.middle_name AS middle_name,u.type,d.value_desc AS delivery_type,p.value_desc AS pay_system FROM sc_shop_order AS o\r\n\t\t\tLEFT JOIN sc_users AS u ON u.u_id=o.userid\r\n\t\t\tLEFT JOIN (SELECT field_value,value_desc FROM sc_enum WHERE field_name='sh_delivery_type') AS d ON d.field_value=o.delivery_type\r\n\t\t\tLEFT JOIN (SELECT field_value,value_desc FROM sc_enum WHERE field_name='sh_pay_system') AS p ON p.field_value=o.pay_system\r\n\t\t\tWHERE 1=1 {$cond} \r\n\t\t\tORDER BY o.create_time DESC \r\n\t\t\tLIMIT " . $pg->getBegin() . "," . $pg->per;
     $queryStr = "SELECT o.*, u.name AS u_name,u.phone AS u_phone, u.last_name AS last_name, u.first_name AS first_name, u.middle_name AS middle_name,u.type,d.value_desc AS delivery_type,p.value_desc AS pay_system,ps.value_desc AS pay_status FROM sc_shop_order AS o\r\n\t\t\tLEFT JOIN sc_users AS u ON u.u_id=o.userid\r\n\t\t\tLEFT JOIN (SELECT field_value,value_desc FROM sc_enum WHERE field_name='sh_delivery_type') AS d ON d.field_value=o.delivery_type\r\n\t\t\tLEFT JOIN (SELECT field_value,value_desc FROM sc_enum WHERE field_name='sh_pay_system') AS p ON p.field_value=o.pay_system\r\n\t\t\tLEFT JOIN (SELECT field_value,value_desc FROM sc_enum WHERE field_name='sh_pay_status') AS ps ON ps.field_value=o.pay_status\r\n\t\t\tWHERE 1=1 {$cond} \r\n\t\t\tORDER BY o.create_time DESC \r\n\t\t\tLIMIT " . $pg->getBegin() . "," . $pg->per;
     $rs = $ST->select($queryStr);
     $data['rs'] = array();
     while ($rs->next()) {
         $data['rs'][$rs->getInt('id')] = $rs->getRow();
         if ($order_data = getJSON($rs->get('order_data'))) {
             $data['rs'][$rs->getInt('id')] += $order_data;
         }
         //			$data['rs'][$rs->getInt('id')]['perforder']=$this->getPerfOrder($rs->getInt('id'));
     }
     //		$data['delivery_type_list']=$this->delivery_type_list;
     $data['delivery_type_list'] = $this->enum('sh_delivery_type');
     $data['pay_system_list'] = $this->enum('sh_pay_system');
     $data['order_status'] = $this->getOrderStatus();
     $data['status_list'] = $this->renderStatusList();
     $data['pg'] = $pg;
     //		$data['pglist']=$this->renderPgList();
     $this->display($data, dirname(__FILE__) . '/admin_order.tpl.php');
 }
Example #2
0
 function actDefault()
 {
     $data = array('category' => 0);
     $page = new Page($this->cfg('PAGE_SIZE'));
     $condition = "b.status=1 AND date_to>='" . date('Y-m-d') . "'";
     if ($c = $this->getUriIntVal('catalog')) {
         $condition .= " AND b.category={$c}";
         $rs = DB::select("SELECT * FROM sc_shop_catalog WHERE id={$c}");
         if ($rs->next()) {
             $this->setPageTitle($rs->get('name'));
         }
         $data['category'] = $c;
     }
     if ($this->getUriIntVal('my')) {
         $condition .= " AND b.userid={$this->getUserId()}";
     }
     $queryStr = "SELECT COUNT(*) as c FROM sc_shop_board b WHERE {$condition}";
     $rs = DB::select($queryStr);
     if ($rs->next()) {
         $page->all = $rs->getInt("c");
     }
     $order = " ORDER BY time DESC";
     $queryStr = "SELECT b.*,u.name,c.name AS c_name,c.id AS c_id FROM sc_shop_board b\r\n\t\t\tLEFT JOIN sc_users u ON u.u_id=b.userid \r\n\t\t\tLEFT JOIN sc_shop_catalog c ON c.id=b.category \r\n\t\tWHERE {$condition} {$order} LIMIT " . $page->getBegin() . "," . $page->per;
     $rs = DB::select($queryStr)->toArray();
     $data['rs'] = $rs;
     $data['pg'] = $page;
     $data['catalog_tree'] = LibCatalog::getInstance()->getCatalogTree();
     $data['date_to'] = date('Y-m-d', time() + 3600 * 24 * 30);
     $this->setCommonCont();
     $this->display($data, dirname(__FILE__) . '/board.tpl.php');
 }
Example #3
0
 function actDefault()
 {
     global $ST;
     if ($id = $this->getURIIntVal($this->getType())) {
         $this->actView();
         return;
     }
     $page = new Page($this->cfg('PAGE_SIZE'));
     //		$page=new Page(2);
     $condition = "state='public' AND type='" . $this->getType() . "'";
     if ($c = $this->getURIIntVal('category')) {
         $condition .= " AND category={$c}";
     }
     $queryStr = "SELECT COUNT(*) as c FROM sc_news WHERE {$condition}";
     $rs = $ST->select($queryStr);
     if ($rs->next()) {
         $page->all = $rs->getInt("c");
     }
     $order = " ORDER BY date DESC,position DESC";
     if ($this->getType() == 'article') {
         $order = " ORDER BY position DESC, view DESC";
     }
     $queryStr = "SELECT *,value_desc AS category_desc FROM sc_news n\r\n\t\tLEFT JOIN (SELECT field_value,value_desc FROM sc_enum WHERE field_name='" . $this->getType() . "_category') AS c ON c.field_value=n.category\r\n\t\tWHERE {$condition} {$order} LIMIT " . $page->getBegin() . "," . $page->per;
     $rs = $ST->select($queryStr)->toArray();
     $data = array('rs' => $rs, 'pg' => $page);
     $data['category_list'] = $this->enum("{$this->getType()}_category");
     $this->setCommonCont();
     if ($tpl = $this->getTpl($this->getType() . '.tpl.php')) {
         $this->display($data, $tpl);
     } else {
         $this->display($data, $this->getTpl('news.tpl.php'));
     }
 }
Example #4
0
 function actDefault()
 {
     global $ST;
     if ($id = $this->getURIIntVal($this->getType())) {
         $this->actView();
         return;
     }
     $page = new Page($this->cfg('PAGE_SIZE'));
     //		$page=new Page(2);
     $condition = "state='public' AND type='" . $this->getType() . "'";
     $queryStr = "SELECT COUNT(*) as c FROM sc_news WHERE {$condition}";
     $rs = $ST->select($queryStr);
     if ($rs->next()) {
         $page->all = $rs->getInt("c");
     }
     $order = " ORDER BY date DESC,position DESC";
     if ($this->getType() == 'article') {
         $order = " ORDER BY position DESC, view DESC";
     }
     $queryStr = "SELECT * FROM sc_news \r\n\t\tWHERE {$condition} {$order} LIMIT " . $page->getBegin() . "," . $page->per;
     $rs = $ST->select($queryStr)->toArray();
     $data = array('rs' => $rs, 'pg' => $page);
     if ($tpl = $this->getTpl($this->getType() . '.tpl.php')) {
         $this->display($data, $tpl);
     } else {
         $this->display($data, $this->getTpl('news.tpl.php'));
     }
 }
Example #5
0
 function actDefault()
 {
     global $ST;
     if (preg_match('|^/([^/]+)|', $this->getURI(), $res)) {
         $this->type = $this->getType();
     }
     $page = new Page($this->cfg('PAGE_SIZE'));
     $condition = "state='public' AND type='" . $this->type . "'";
     $queryStr = "SELECT COUNT(*) as c FROM sc_faq WHERE {$condition}";
     $rs = $ST->select($queryStr);
     if ($rs->next()) {
         $page->all = $rs->getInt("c");
     }
     $order = " ORDER BY pos DESC,time";
     $queryStr = "SELECT * FROM sc_faq WHERE {$condition} {$order} LIMIT " . $page->getBegin() . "," . $page->per;
     $rs = $ST->select($queryStr)->toArray();
     $data = array('rs' => $rs, 'pg' => $page);
     $data['theme_list'] = $this->enum("{$this->type}_theme");
     $this->setCommonCont();
     if (file_exists(dirname(__FILE__) . '/' . $this->type . '.tpl.php')) {
         $this->display($data, dirname(__FILE__) . '/' . $this->type . '.tpl.php');
     } else {
         $this->display($data, dirname(__FILE__) . '/faq.tpl.php');
     }
 }
Example #6
0
 function actView($id = 0)
 {
     global $ST;
     $type = trim($this->mod_uri, '/');
     $rs = $ST->select("SELECT * FROM sc_gallery WHERE id=" . $id);
     if ($rs->next()) {
         $data = $rs->getRow();
         $data['pg'] = $pg = new Page($this->cfg('PAGE_SIZE'));
         //			$data['pg']=$pg=new Page(3);
         $this->setPageTitle($rs->get('name'));
         $data['images'] = array();
         $pg->all = 0;
         $images = array();
         $rs = $ST->select("SELECT * FROM sc_gallery_img WHERE gallery_id={$id} ORDER BY pos");
         while ($rs->next()) {
             $images[] = $rs->getRow();
         }
         if ($images) {
             $pg->all = count($images);
             $data['images'] = array_slice($images, $pg->getBegin(), $pg->per);
         }
         $data['label_list'] = $ST->select("SELECT gl.*,l.value_desc AS l_desc FROM sc_gallery_label gl\r\n\t\t\t\tLEFT JOIN (SELECT * FROM sc_enum WHERE field_name='gal_{$type}_label') AS l ON l.field_value=gl.label_id\r\n\t\t\tWHERE gallery_id={$id}")->toArray();
     }
     $this->setCommonCont();
     $tpl = dirname(__FILE__) . '/' . $type . '_view.tpl.php';
     if (file_exists($tpl)) {
         $this->display($data, $tpl);
         return;
     }
     $this->display($data, dirname(__FILE__) . '/gallery_view.tpl.php');
 }
Example #7
0
 function getOrder($arh = false, $id = 0)
 {
     include 'modules/catalog/Basket.class.php';
     global $ST;
     $status_list = $this->getOrderStatus();
     $data = array('arh' => $arh, 'ps' => array());
     $condition = "userid=" . $this->getUserId() . "";
     if ($arh !== null) {
         if ($arh) {
             $condition .= " AND order_status NOT IN (0,1)";
         } else {
             $condition .= " AND order_status IN (0,1)";
         }
     }
     if ($id) {
         $condition .= " AND id={$id}";
     }
     /*$ps=array();
     		$rs=$ST->select("SELECT * FROM sc_pay_system");
     		while ($rs->next()) {
     			$class="PS".ucfirst($rs->get('name'));
     			$ps[$rs->get('name')]=new $class(unserialize($rs->get('config')));
     //			$ps[$rs->get('name')]->setType('pay');
     //			$ps[$rs->get('name')]->setUserId($this->getUserId());
     //			$ps[$rs->get('name')]->setEmail($this->getUser('mail'));
     		}
     		$ps['payonline']->ReturnUrl='/cabinet/order/';
     		$ps['payonline']->params['UserId']=$this->getUserId();;
     			
     		$data['ps']=&$ps;*/
     $pg = new Page(5);
     $rs = $ST->select("SELECT COUNT(id) AS c FROM sc_shop_order WHERE {$condition}");
     if ($rs->next()) {
         $pg->all = $rs->getInt('c');
     }
     $queryStr = "SELECT * FROM sc_shop_order  \r\n\t\t\tWHERE {$condition} \r\n\t\t\tORDER BY id DESC LIMIT " . $pg->getBegin() . ', ' . $pg->per;
     $rs = $ST->select($queryStr);
     $data['rs'] = array();
     while ($rs->next()) {
         $data['rs'][$rs->getInt('id')] = $rs->getRow();
         $data['rs'][$rs->getInt('id')]['order_status_desc'] = @$status_list[$rs->get('order_status')];
         $orderItem = array();
         $rs1 = $ST->select("SELECT oi.*,i.name,i.img,i.description,i.category\r\n\t\t\t\tFROM sc_shop_order_item AS oi\r\n\t\t\t\t\r\n\t\t\t\tLEFT JOIN sc_shop_item AS i ON i.id=oi.itemid\r\n\t\t\t\tLEFT JOIN sc_shop_catalog AS c ON c.id=i.category\r\n\t\t\t\tLEFT JOIN sc_shop_proposal AS p ON oi.proposalid=p.id  \r\n\t\t\t\tWHERE  oi.orderid=" . $rs->getInt('id'));
         while ($rs1->next()) {
             $orderItem[] = array('id' => $rs1->get('itemid'), 'proposalid' => $rs1->get('proposalid'), 'img' => $rs1->get('img'), 'name' => $rs1->get('name'), 'description' => $rs1->get('description'), 'count' => $rs1->get('count'), 'price' => $rs1->get('price'), 'sum' => $rs1->get('price') * $rs1->get('count'));
         }
         $basket = new Basket($orderItem);
         $basket->delivery = $rs->get('delivery');
         $basket->discount = $rs->get('discount');
         $data['rs'][$rs->getInt('id')]['orderContent'] = $this->render(array('orderContent' => $basket, 'date' => $rs->get('create_time'), 'arh' => $arh, 'id' => $rs->getInt('id')), dirname(__FILE__) . '/ordercontent.tpl.php');
         //			foreach ($ps as $ps_name=>$pay_system) {
         ////				$pay_system->setOrderNum($rs->getInt('id'));
         ////				$pay_system->setSumm($rs->getInt('total_price'));
         //				$data['rs'][$rs->getInt('id')]['ps'][$ps_name]=$pay_system;
         //			}
     }
     $data['pg'] = $pg;
     return $data;
 }
 function actDefault()
 {
     global $ST;
     $data = array('pg' => &$pg, 'form' => trim($this->mod_alias, '/'));
     $pg = new Page($this->getPages());
     $queryStr = "SELECT count(*) AS c FROM sc_forms";
     $rs = $ST->select($queryStr);
     if ($rs->next()) {
         $pg->all = $rs->getInt("c");
     }
     $order = "ORDER BY id DESC";
     $queryStr = "SELECT *,t.value_desc AS type_desc,s.value_desc AS status_desc\r\n\t\t\tFROM (SELECT * FROM sc_forms {$order} LIMIT " . $pg->getBegin() . "," . $pg->per . ")  AS c \r\n\t\t\tLEFT JOIN (SELECT field_value,value_desc FROM sc_enum WHERE field_name='f_type') AS t ON t.field_value=c.form::varchar\r\n\t\t\tLEFT JOIN (SELECT field_value,value_desc FROM sc_enum WHERE field_name='f_status') AS s ON s.field_value=c.status::varchar \r\n\t\t";
     $this->rs = $ST->select($queryStr);
     $this->display($data, dirname(__FILE__) . '/admin_forms.tpl.php');
 }
Example #9
0
 function actDefault()
 {
     global $ST, $get;
     $this->search = $get->getString('search');
     if (empty($this->search)) {
         header('Location: /');
         exit;
     }
     $data = array('rs' => array(), 'type_search' => '');
     if ($data['type_search'] = $type_search = $this->getURIVal('search')) {
         if (isset($this->result[$type_search])) {
             $pg = new Page();
             $query = $this->getQuery($type_search);
             $rs = $ST->select($query[1]);
             if ($rs->next()) {
                 $pg->all = $rs->getInt('c');
             }
             $rs = $ST->select($query[0] . ' LIMIT ' . $pg->getBegin() . ',' . $pg->per);
             while ($rs->next()) {
                 $data['rs'][] = $rs->getRow();
             }
             $data['href'] = $query[2];
             $data['title'] = $query[3];
             $data['pg'] = $pg;
         } else {
             header('Location: /');
             exit;
         }
     } else {
         foreach ($this->result as $key => $result) {
             $query = $this->getQuery($key);
             $rs = $ST->select($query[1]);
             if ($rs->next()) {
                 $data['rs'][$key]['count'] = $rs->getInt('c');
             }
             $rs = $ST->select($query[0] . ' LIMIT ' . $this->type_size);
             while ($rs->next()) {
                 $data['rs'][$key]['result'][] = $rs->getRow();
             }
             $data['rs'][$key]['href'] = $query[2];
             $data['rs'][$key]['title'] = $query[3];
         }
     }
     $this->setCommonCont();
     $this->display($data, dirname(__FILE__) . '/search.tpl.php');
 }
Example #10
0
 function actDefault()
 {
     global $ST;
     $pg = new Page(10);
     $data = array();
     $rs = $ST->select("SELECT field_value,value_desc FROM sc_enum WHERE field_name='fb_score' ORDER BY position DESC");
     while ($rs->next()) {
         $data['score'][] = $rs->getRow();
     }
     $rs = $ST->select("SELECT COUNT(*) AS c FROM sc_guestbook WHERE status=1");
     while ($rs->next()) {
         $pg->all = $rs->getInt('c');
     }
     $data['rs'] = $ST->select("SELECT * FROM sc_guestbook WHERE status=1 ORDER BY time LIMIT {$pg->getBegin()},{$pg->per}")->toArray();
     $data['pg'] = $pg;
     $this->display($data, dirname(__FILE__) . '/guestbook.tpl.php');
 }
Example #11
0
 function actDefault()
 {
     global $ST;
     $pg = new Page($this->cfg('PAGE_SIZE'));
     $data = array('rs' => array(), 'pg' => &$pg);
     $condition = "type='feedback' AND status=1";
     $queryStr = "SELECT COUNT(*) as c FROM sc_feedback WHERE {$condition}";
     $rs = $ST->select($queryStr);
     if ($rs->next()) {
         $pg->all = $rs->getInt("c");
     }
     $rs = $ST->select("SELECT * FROM sc_feedback WHERE {$condition} ORDER BY id DESC LIMIT " . $pg->getBegin() . "," . $pg->per);
     while ($rs->next()) {
         $data['rs'][] = $rs->getRow();
     }
     $data['FB_CAN_SEND_MSG'] = $this->cfg('FB_CAN_SEND_MSG') == 'true';
     $this->setCommonCont();
     $this->display($data, dirname(__FILE__) . '/feedback.tpl.php');
 }
Example #12
0
<?php 
include "../include/database.inc";
include "../include/common.inc";
include "../include/page.inc";
$id = $_GET['id'];
$pageNo = $_GET['pageNo'];
$seac_i = $_GET['seac_i'];
$seac_t = $_GET['seac_t'];
$page = new Page();
if ($pageNo) {
    $page->pageNo = $pageNo;
}
$page->pagename = "list.php?id={$id}&";
$menuT = getTableById("menu", $id);
$seac_sql = $seac_i ? " and " . $seac_t . " like '%" . $seac_i . "%' " : "";
$list = getTableByConList("content", "menu = {$id} " . $seac_sql . " order by in_date desc limit " . $page->getBegin() . ",{$page->pageSize}");
$page->pageCount = getTableCount("content", "menu = {$id} " . $seac_sql);
$menu = getTableByConList("menuset", "id = {$id} and isIndex = 1");
$menuAll = getTableByConList("menuset", "id = {$id}");
?>
<body>
<div class="commonDiv">
<div class="commontop">模块【<?php 
echo $menuT->menuname;
?>
】</div>
<table border="0" align="center" cellpadding="0" cellspacing="0" class="commonTable" >
	<tr>
        <th width="100" height="28">序号</th>
        <th width="150">标题</th>
        <?php 
Example #13
0
 function actSubscribe()
 {
     $page = new Page($this->getPages());
     parent::refresh();
     $cond = " WHERE 1=1 ";
     $query = "SELECT count(*) AS c FROM sc_subscribe " . $cond;
     $rs = DB::select($query);
     if ($rs->next()) {
         $page->all = $rs->getInt('c');
     }
     $order = 'ORDER BY ';
     $ord = $this->getURIVal('ord') != 'asc' ? 'asc' : 'desc';
     if (in_array($this->getURIVal('sort'), array('login', 'mail'))) {
         $order .= $this->getURIVal('sort') . ' ' . $ord;
     } else {
         $order .= " mail";
     }
     $data = array();
     $queryStr = "SELECT s.*,u.login FROM sc_subscribe s\r\n\t\tLEFT JOIN sc_users u ON s.mail=u.mail\r\n\t\t\r\n\t\t{$cond} {$order} LIMIT " . $page->getBegin() . "," . $page->per;
     $data['rs'] = DB::select($queryStr);
     $data['pg'] = $page;
     $this->setPageTitle('Подписка');
     $this->display($data, dirname(__FILE__) . '/subscribe.tpl.php');
 }
Example #14
0
 function actOrdersPopup()
 {
     global $ST, $post;
     $status = 5;
     $pg = new Page(isset($_COOKIE['pages']) && $_COOKIE['pages'] ? intval($_COOKIE['pages']) : 15);
     $cond = "order_status={$status}";
     if ($status > 1) {
         $cond .= " AND perfid IN(" . $this->getUserId() . ")";
     }
     $order = "create_time DESC";
     $rs = $ST->select("SELECT COUNT(*) AS c FROM sc_shop_order WHERE {$cond}");
     if ($rs->next()) {
         $pg->all = $rs->getInt('c');
     }
     $rs = $ST->select("SELECT * FROM sc_shop_order o \r\n\t\t\tWHERE {$cond}\r\n\t\t\tORDER BY {$order} \r\n\t\t\tLIMIT {$pg->getBegin()},{$pg->per}")->toArray();
     $data = array('pg' => $pg, 'rs' => $rs);
     $data['PAGE_SELECT'] = $this->render(array('list' => array(20, 50, 100, 500, 1000), 'current' => $this->popupPageSize), dirname(__FILE__) . '/pages_select.tpl.php');
     $this->tplContainer = 'core/tpl/admin/admin_popup.php';
     $this->display($data, dirname(__FILE__) . '/orders_popup.tpl.php');
 }
Example #15
0
 function displayGoods($id)
 {
     global $ST, $get;
     $par = 0;
     $data['parentid'] = 0;
     $data['parentname'] = $this->mod_name;
     $data['description'] = '';
     $data['action'] = array();
     $data['id'] = 0;
     $page = new Page($this->getPageSize(), $this->cfg('PAGE_SIZE_SELECT'));
     //		$page=new Page(1);
     //		$page=new Page($this->cfg('PAGE_SIZE'));
     $catIds = array();
     if ($prop = $this->getURIIntVal('prop')) {
         $rs = $ST->select("SELECT * FROM sc_shop_prop WHERE id={$prop}");
         if ($rs->next()) {
             $this->explorer[] = array('name' => $rs->get('name'), 'url' => $this->mod_uri . $this->getURIIntVal('catalog') . '/prop/' . $rs->get('id') . '/');
             $this->setTitle($rs->get('name'));
             $this->setHeader($rs->get('name'));
         }
     }
     $condition = "WHERE i.price>0";
     if ($id && is_int($id)) {
         $par = $id;
         if ($man = $this->getURIVal('man')) {
             $this->explorer[] = array('name' => $man, 'url' => $this->mod_uri . $this->getURIIntVal('catalog') . '/man/' . $man . '/');
         }
         $rs = $ST->select("SELECT * FROM sc_shop_catalog WHERE id=" . $id);
         if ($rs->next()) {
             $data['description'] = $rs->get('description');
             $data['id'] = $rs->get('id');
             if (trim($rs->get('cache_child_catalog_ids'))) {
                 $catIds = explode(',', $rs->get('cache_child_catalog_ids'));
             }
             //				$this->actCatalog[]=$id;
             //				if(!empty($catIds[0])){
             //
             //					$id=$catIds[0];
             //					$rs=$ST->select("SELECT * FROM sc_shop_catalog WHERE id=".$id);
             //					if($rs->next()){
             //						$catIds=array();
             //					}
             //					$this->actCatalog[]=$id;
             //				}
             $this->explorer[] = array('name' => $rs->get('name'), 'url' => $this->mod_uri . $rs->get('id') . '/');
             $this->setTitle($rs->get('name'));
             $this->setHeader($rs->get('name'));
             //Хлебные крошки
             $parent = $data['parentid'] = $rs->get('parentid');
             //				$this->actCatalog[]=$parent;
             while ($parent) {
                 $rs1 = $ST->select("SELECT id,name,parentid FROM sc_shop_catalog WHERE id=" . $parent);
                 if ($rs1->next()) {
                     $parent = $rs1->getInt('parentid');
                     $this->actCatalog[] = $parent;
                     $this->explorer[] = array('name' => $rs1->get('name'), 'url' => $this->mod_uri . $rs1->get('id') . '/');
                 } else {
                     break;
                 }
             }
             if (!empty($this->explorer[1])) {
                 $data['parentname'] = $this->explorer[1]['name'];
             }
         }
         $catIds[] = $id;
     }
     //		$condition="WHERE of.itemid=i.id AND i.price>=0 AND of.in_stock>0 AND of.region='{$this->getRegion()}'";/*Раздельное наличие*/
     $condition .= " AND i.in_stock>-1";
     //Не показывать удалённые
     //		$condition.=" AND i.category IN (SELECT id FROM sc_shop_catalog WHERE state>0)";
     if ($this->cfg('SHOP_GOODS_IN_STOCK_ONLY') == 'true') {
         //Настройка показывать только в наличии
         $condition .= " AND i.in_stock>0";
     }
     if ($this->cfg('SHOP_GOODS_W_IMG_ONLY') == 'true') {
         //Настройка показывать только с картинками
         $condition .= " AND i.img<>''";
     }
     if ($this->cfg('SHOP_GOODS_CHECKED_ONLY')) {
         //Настройка показывать только в подтверждённые
         $condition .= " AND i.confirm=1";
     }
     if (preg_match('/(\\d*)\\D*-(\\d*)\\D*/', $this->getURIVal('price'), $res)) {
         if ($res[1] > 0) {
             $condition .= " AND i.price>={$res[1]}";
         }
         if ($res[2] > 0) {
             $condition .= " AND i.price<={$res[2]}";
         }
     }
     //		if($univ=$this->getURIIntVal('universal')){
     //			$condition.=" AND (i.id=$univ OR i.universal=$univ)";
     //		}
     if ($this->getURIVal('catalog') == 'fav') {
         if ($arr = $this->getFavoriteData()) {
             $condition .= " AND i.id IN('" . implode("','", $arr) . "')";
         }
     }
     if ($this->getURIVal('catalog') == 'new') {
         $condition .= " AND i.sort3>0";
         $this->setPageTitle('Новинки');
     }
     if ($this->getURIVal('catalog') == 'special') {
         $condition .= " AND i.sort>0";
         $this->setPageTitle('СПЕЦИАЛЬНОЕ ПРЕДЛОЖЕНИЕ');
     }
     //		if($this->getURIVal('catalog')=='action'){
     //			$condition.=" AND i.sort1>0";
     //			$this->setPageTitle('СПЕЦИАЛЬНОЕ ПРЕДЛОЖЕНИЕ');
     //		}
     if ($action = $this->getURIIntVal('action')) {
         $rs = $ST->select("SELECT * FROM sc_news WHERE type='action' AND state='public' AND id={$action}");
         if ($rs->next()) {
             $data['action'] = $rs->getRow();
             $this->setPageTitle($rs->get('title'), "/catalog/action/{$action}/");
             $condition .= " AND i.sort1={$action}";
         }
         //			$this->setPageTitle('СПЕЦИАЛЬНОЕ ПРЕДЛОЖЕНИЕ');
     }
     if ($catIds) {
         $condition .= " \r\n\t\t\t\r\n\t\t\t\tAND (\r\n\t\t\t\tEXISTS(SELECT id FROM sc_shop_catalog AS sc WHERE sort>-1 AND sc.id IN(" . trim(implode(",", $catIds), ',') . ") AND i.category=sc.id  )\r\n\t\t\t\t \r\n\t\t\t\tOR EXISTS(SELECT itemid FROM sc_shop_item2cat,sc_shop_catalog sc WHERE sort>-1 AND sc.id=catid AND itemid=i.id AND sc.id IN(" . trim(implode(",", $catIds), ',') . ")  )\r\n\t\t\t)\r\n\t\t\t";
     }
     if ($prop = trim($this->getURIVal('prop'))) {
         $p_c = array();
         if ($prop = explode(',', $prop)) {
             foreach ($prop as $p) {
                 $p_c[] = " EXISTS (SELECT item_id FROM sc_shop_prop_val WHERE prop_id=" . intval($p) . " AND i.id=item_id)";
             }
         }
         if ($p_c) {
             $condition .= " AND (" . implode(' AND ', $p_c) . ")";
         }
         //			$condition.=" AND EXISTS (SELECT item_id FROM sc_shop_prop_val WHERE prop_id={$prop} AND i.id=item_id)";
     }
     if (preg_match('/(\\d+),(\\d+)/', $this->getURIVal('rel'), $res)) {
         $condition .= " AND EXISTS (SELECT ch FROM sc_shop_relation WHERE par={$res[1]} AND type={$res[2]} AND i.id=ch )";
     }
     $prop_condition = '';
     $prop2_condition = '';
     if ($prop = $get->getArray('p')) {
         $c3 = array();
         $c4 = array();
         foreach ($prop as $pid => $val) {
             $pr = array_diff(array_keys($prop), array($pid));
             if (is_array($val)) {
                 foreach ($val as &$v) {
                     $v = SQL::slashes($v);
                 }
                 $c3[] = " AND EXISTS(SELECT item_id FROM sc_shop_prop_val WHERE i.id=item_id AND prop_id={$pid} AND value IN('" . implode("','", $val) . "'))";
                 $c4[] = " AND EXISTS(SELECT item_id FROM sc_shop_prop_val WHERE i.id=item_id AND ((prop_id={$pid} AND value IN('" . implode("','", $val) . "')) OR prop_id NOT IN('" . implode("','", $pr) . "') ))";
             } else {
                 $val = trim($val);
                 if (preg_match('/^([\\d\\.]+)-([\\d\\.]+)$/', $val, $res)) {
                     $c3[] = " AND EXISTS(SELECT item_id FROM sc_shop_prop_val WHERE i.id=item_id AND prop_id={$pid} AND value>={$res[1]} AND value<={$res[2]})";
                     $c4[] = " AND EXISTS(SELECT item_id FROM sc_shop_prop_val WHERE i.id=item_id AND ((prop_id={$pid} AND value>={$res[1]} AND value<={$res[2]}) OR prop_id NOT IN('" . implode("','", $pr) . "') ))";
                 } elseif ($val) {
                     $c3[] = " AND EXISTS(SELECT item_id FROM sc_shop_prop_val WHERE i.id=item_id AND prop_id={$pid} AND value='" . SQL::slashes($val) . "')";
                     $c4[] = " AND EXISTS(SELECT item_id FROM sc_shop_prop_val WHERE i.id=item_id AND ((prop_id={$pid} AND value='" . SQL::slashes($val) . "') OR prop_id NOT IN('" . implode("','", $pr) . "') ))";
                 }
             }
         }
         $prop_condition .= implode('', $c3);
         $prop2_condition .= implode('', $c4);
     }
     //		if($prop=$get->getArray('p')){
     //			$c3=array();
     //			foreach ($prop as $pid=>$val) {
     //				$c3[(int)$pid]=$pid."=".SQL::slashes($val);
     //				$c3[(int)$pid]=" prop_id::varchar||'='||value = '$pid=".SQL::slashes($val)."'";
     //			}
     ////			$prop_condition.= " AND EXISTS(SELECT item_id FROM sc_shop_prop_val WHERE i.id=item_id AND prop_id IN(".implode(',',array_keys($c3)).") AND prop_id::varchar||'='||value IN('".implode("','",$c3)."'))";;
     //			$prop_condition.= " AND EXISTS(SELECT item_id FROM sc_shop_prop_val WHERE i.id=item_id
     //				AND prop_id IN(".implode(',',array_keys($c3)).")
     //				AND ".implode(" AND ",$c3)."
     //			)";
     //		}
     //		if($prop=$get->getArray('type')){//Тип устройства
     //			$c3=array();
     //			foreach ($prop as $pid) {
     //				$c3[]=(int)$pid;
     //			}
     //			$prop_condition.= " AND EXISTS(SELECT item_id FROM sc_shop_prop_val WHERE i.id=item_id AND prop_id IN (".implode(',',$c3)."))";
     //		}
     //		if($prop=$get->getArray('max')){
     //			$c3=array();
     //			foreach ($prop as $pid=>$val) {
     //				$c3[]=" AND EXISTS(SELECT item_id FROM sc_shop_prop_val WHERE i.id=item_id AND prop_id=$pid AND value::numeric<=".floatval($val).")";
     //			}
     //			$prop_condition.= implode('',$c3);
     //		}
     //		if($prop=$get->getArray('min')){
     //			$c3=array();
     //			foreach ($prop as $pid=>$val) {
     //				$c3[]=" AND EXISTS(SELECT item_id FROM sc_shop_prop_val WHERE i.id=item_id AND prop_id=$pid AND value::numeric>=".floatval($val).")";
     //			}
     //			$prop_condition.= implode('',$c3);
     //		}
     $man_condition = '';
     if (($man = $this->getURIVal('man')) && ($man = explode(',', $man))) {
         $man_condition .= " AND i.manufacturer IN('" . trim(implode("','", $man), ',') . "')";
     }
     if (($man = $this->getURIVal('manid')) && ($man = explode(',', $man))) {
         $man_condition .= " AND i.manufacturer_id IN('" . trim(implode("','", $man), ',') . "')";
     }
     if ($man = $get->getArray('man')) {
         foreach ($man as &$m) {
             $m = SQL::slashes($m);
         }
         $man_condition .= " AND i.manufacturer IN('" . trim(implode("','", $man), ',') . "')";
     }
     if ($man = $get->getArray('manid')) {
         foreach ($man as &$m) {
             $m = SQL::slashes($m);
         }
         $man_condition .= " AND i.manufacturer_id IN('" . trim(implode("','", $man), ',') . "')";
     }
     $p_condition = '';
     if ($get->getInt('minp')) {
         $p_condition .= " AND i.price >={$get->getInt('minp')}";
     }
     if ($get->getInt('maxp')) {
         $p_condition .= " AND i.price <={$get->getInt('maxp')}";
     }
     $sh_arr = array('hit' => 'sort', 'new' => 'sort1', 'act' => 'sort2');
     $s_condition = '';
     if ($show = $this->getURIVal('show')) {
         $s_condition = " AND {$sh_arr[$show]} >0";
     }
     $q = trim(strtolower(SQL::slashes(urldecode($get->get('search')))));
     if ($q) {
         if ($words = Rumor::getAllForms($q)) {
             $or = array();
             foreach ($words as $w) {
                 $or[] = "i.name LIKE '%" . $w . "%'";
             }
             $condition .= " AND (" . implode(' OR ', $or) . ")";
         } else {
             $condition .= " AND (i.name LIKE '%" . SQL::slashes($q) . "%')";
         }
         //$condition.=" AND lower(i.name) LIKE '%" . $q . "%'";
     }
     //		$query="SELECT count(*) AS c FROM sc_shop_item i,sc_shop_offer of $condition $man_condition $p_condition $prop_condition $s_condition" ;
     $query = "SELECT count(*) AS c FROM sc_shop_item i {$condition} {$man_condition} {$p_condition} {$prop_condition} {$s_condition}";
     $rs = $ST->select($query);
     if ($rs->next()) {
         $page->all = $rs->getInt('c');
     }
     $order = '';
     $sort = 'DESC';
     if ($this->getURIVal('sort') == 'desc') {
         $sort = 'DESC';
     } elseif ($this->getURIVal('sort') == 'asc') {
         $sort = 'ASC';
     }
     //		$order.='sort DESC,name';
     //		$order.='category,views DESC,name';
     $order .= 'sort DESC,name';
     if ($this->getURIVal('price')) {
         $order = 'price DESC';
     }
     if ($this->getURIVal('catalog') == 'new') {
         $order = 'sort3 DESC';
     }
     $ord = $this->getURIVal('ord');
     if (in_array($ord, array('price', 'manufacturer', 'name', 'views', 'sort1', 'sort2', 'sort3'))) {
         $order = $ord . ' ' . $sort;
     }
     if ($ord == 'hit') {
         $order = 'sort2 DESC';
     }
     if ($ord == 'updated') {
         $order = 'sort_print DESC';
     }
     if ($ord == 'default') {
         $order = 'sort DESC, name ' . $sort;
         $order = 'name ' . $sort;
         if ($show) {
             $order = "{$sh_arr[$show]} DESC, name " . $sort;
         }
     }
     //		$queryStr="SELECT i.*,coalesce(cn.c,0) AS cnt FROM sc_shop_item i
     //		LEFT JOIN(SELECT COUNT(itemid) AS c,itemid FROM sc_shop_order_item oi,sc_shop_order o WHERE o.id=oi.orderid AND o.order_status=8 GROUP BY itemid) AS cn ON cn.itemid=i.id,
     //		sc_shop_offer of
     //		$condition $man_condition $p_condition $prop_condition ORDER BY $order LIMIT ".$page->getBegin().",".$page->per ;
     //		$queryStr="SELECT i.* FROM sc_shop_item i,
     //		sc_shop_offer of
     //		$condition $man_condition $p_condition $prop_condition $s_condition ORDER BY $order LIMIT ".$page->getBegin().",".$page->per ;
     $queryStr = "SELECT i.*,r,c FROM sc_shop_item i\r\n\t\t\r\n\t\tLEFT JOIN(SELECT COUNT(DISTINCT commentid) AS c,AVG(rating) AS r,itemid  FROM sc_comment,sc_comment_rait r \r\n\t\t\t\t\tWHERE commentid=id  AND TRIM(comment)<>'' AND status=1 AND type IN('','goods') GROUP BY itemid) AS rait ON rait.itemid=i.id\r\n\t\t\t\r\n\t\t\r\n\t\t{$condition} {$man_condition} {$p_condition} {$prop_condition} {$s_condition} ORDER BY {$order} LIMIT " . $page->getBegin() . "," . $page->per;
     $data['manufacturer_list'] = array();
     $data['type_list'] = array();
     $data['prop_list'] = array();
     $data['show_list'] = array(0, 0, 0);
     $data['min_max_price'] = array(0, 0, 0, 0);
     //			$q_vendor="SELECT DISTINCT manufacturer FROM sc_shop_item i,sc_shop_offer of $condition AND manufacturer<>''";
     //			$rs=$ST->select($q_vendor);
     //			while ($rs->next()) {
     //				$data['manufacturer_list'][]=$rs->get('manufacturer');
     //			}
     //			if(count($data['manufacturer_list'])<2){
     //				$data['manufacturer_list']=array();
     //			}
     $q_vendor = "SELECT m.name,m.id,COUNT(m.id) AS c FROM sc_shop_item i,sc_manufacturer m {$condition} AND i.manufacturer_id=m.id GROUP BY m.name,m.id";
     $rs = $ST->select($q_vendor);
     while ($rs->next()) {
         $data['manufacturer_list'][] = $rs->getRow();
     }
     //			$this->data=&$data;
     $rs = $ST->select($queryStr);
     $data['catalog'] = array();
     $data['page'] = $page;
     $units = $this->enum('sh_unit');
     while ($rs->next()) {
         $row = $rs->getRow();
         //			if($row['pack_size']>1){
         //				$row['price_pack']=$row['price']*$row['pack_size']*$discount;
         //			}
         $row['unit'] = @$units[$row['unit']];
         //			if($row['sort']>0){
         //				$row['hit']=true;
         //			}
         //			if($row['sort']>0){
         //				$row['new']=true;
         //			}
         $data['catalog'][$row['id']] = $row;
     }
     if ($data['catalog']) {
         $ids = array_keys($data['catalog']);
         $q = "SELECT * FROM sc_shop_item_nmn WHERE itemid IN (" . implode(',', $ids) . ") AND hidden=0 ORDER BY price";
         $rs = $ST->select($q);
         while ($rs->next()) {
             $data['catalog'][$rs->getInt('itemid')]['nmn'][$rs->getInt('id')] = $rs->getRow();
         }
     }
     $data['children'] = $this->getChildCategory($par);
     $data['children_man'] = array();
     if (count(explode(',', $this->getUriVal('manid'))) == 1) {
         $rs = $ST->select("SELECT c.id FROM sc_manufacturer m,sc_shop_catalog c WHERE m.name=c.name AND m.id={$this->getUriIntVal('manid')}");
         if ($rs->next()) {
             $data['children_man'] = $this->getChildCategory($rs->getInt('id'));
         }
     }
     $data['in_basket'] = array();
     $basket = $this->getBasket();
     foreach ($basket as $item) {
         $data['in_basket'][$item['id']] = $item['count'];
     }
     /* Свойства */
     $q_prop = "SELECT DISTINCT p.id AS pid,p.sort,p.name,p.type,pv.value FROM sc_shop_item i,sc_shop_prop as p,sc_shop_prop_val pv \r\n\t\t\t{$condition} \r\n\t\t\tAND i.category={$id}\r\n\t\t\tAND i.id=pv.item_id\r\n\t\t\tAND pv.prop_id=p.id\r\n\t\t\tAND p.grp<>0  \r\n\t\t\tAND p.sort<>0 ORDER BY p.sort DESC, value";
     //		$prop2_condition
     //			$q_prop="SELECT DISTINCT p.id AS pid,p.sort,p.name,p.type,pv.value FROM sc_shop_item i,sc_shop_prop as p,sc_shop_prop_val pv
     //			$condition
     //			$prop_condition
     //			AND i.category=$id
     //			AND i.id=pv.item_id
     //			AND pv.prop_id=p.id
     //			AND p.grp<>0
     //			AND p.sort<>0 ORDER BY p.sort, value";
     //
     //			$rs=$ST->select($q_prop);
     //			while ($rs->next()) {
     //				$data['prop_list'][$rs->get('pid')]['name']=$rs->get('name');
     //				$data['prop_list'][$rs->get('pid')]['sort']=$rs->get('sort');
     //				$data['prop_list'][$rs->get('pid')]['type']=$rs->get('type');
     //				$data['prop_list'][$rs->get('pid')]['v'][]=$rs->get('value');
     //			}
     $q_prop = "SELECT p.id AS pid,p.sort,p.name,p.type,pv.value,pv.item_id FROM sc_shop_item i,sc_shop_prop as p,sc_shop_prop_val pv \r\n\t\t\t{$condition} \r\n\t\t\t{$prop_condition}\r\n\t\t\tAND i.category={$id}\r\n\t\t\tAND i.id=pv.item_id\r\n\t\t\tAND pv.prop_id=p.id\r\n\t\t\tAND p.grp<>0  \r\n\t\t\tAND p.sort<>0 ORDER BY p.sort,p.name,value";
     $rs = $ST->select($q_prop);
     $pl = array();
     //			$pl_item=array();
     while ($rs->next()) {
         $pl[$rs->get('pid')]['name'] = $rs->get('name');
         $pl[$rs->get('pid')]['sort'] = $rs->get('sort');
         $pl[$rs->get('pid')]['type'] = $rs->get('type');
         if (empty($pl[$rs->get('pid')]['v'][$rs->get('value')])) {
             //					$pl[$rs->get('pid')]['v'][$rs->get('value')]=array();
             $pl[$rs->get('pid')]['v'][$rs->get('value')] = 0;
         }
         //				$pl[$rs->get('pid')]['v'][$rs->get('value')][]=$rs->getInt('item_id');
         $pl[$rs->get('pid')]['v'][$rs->get('value')]++;
         //				$pl_item[$rs->getInt('item_id')][$rs->get('pid')]=$rs->get('value');
     }
     foreach ($pl as $pid => &$p) {
         if ($p['type'] == 4) {
             $list = $this->enum('sh_prop_list_' . $pid);
             $v = array();
             foreach ($list as $val) {
                 if (isset($p['v'][$val])) {
                     $v[$val] = $p['v'][$val];
                 }
             }
             $p['v'] = $v;
         }
     }
     $data['prop_list2'] = $pl;
     //			$q_pr="SELECT MAX(i.price) AS maxp, MIN(i.price) AS minp FROM sc_shop_item i,sc_shop_offer of $condition ";
     //			$q_pr="SELECT MAX(i.price) AS maxp, MIN(i.price) AS minp FROM sc_shop_item i $condition ";
     //			$rs=$ST->select($q_pr);
     //			if($rs->next()){
     //				$data['min_max_price']=array($rs->get('minp'),$rs->get('maxp'),$rs->get('minp'),$rs->get('maxp'));
     //
     //				if($data['min_max_price'][1]==$data['min_max_price'][0]){
     //					$data['min_max_price'][0]=0;
     //					$data['min_max_price'][2]=0;
     //				}
     //
     //			}
     //			if($get->getInt('minp')){
     //				$data['min_max_price'][0]=$get->getInt('minp');
     //			}
     //			if($get->getInt('maxp')){
     //				$data['min_max_price'][1]=$get->getInt('maxp');
     //			}
     $this->tplLeftComponent = dirname(__FILE__) . "/catalog_left.tpl.php";
     $this->display($data, dirname(__FILE__) . '/catalog.tpl.php');
 }