Esempio n. 1
0
 function indexAction()
 {
     $status = NULL;
     if (isset($_GET['status'])) {
         $status = Arr::get($_GET, 'status', 1);
     }
     $page = (int) Route::param('page') ? (int) Route::param('page') : 1;
     $count = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from($this->tablename);
     if ($status !== NULL) {
         $count->where('status', '=', $status);
     }
     $count = $count->count_all();
     $result = DB::select()->from($this->tablename);
     if ($status !== NULL) {
         $result->where('status', '=', $status);
     }
     $result = $result->order_by('name', 'ASC')->limit($this->limit)->offset(($page - 1) * $this->limit)->find_all();
     $pager = Pager::factory($page, $count, $this->limit)->create();
     $this->_toolbar = Widgets::get('Toolbar/List', array('add' => 1, 'delete' => 1));
     $t = DB::select()->from('specifications_types')->order_by('name')->find_all();
     $types = array();
     foreach ($t as $_t) {
         $types[$_t->id] = $_t->name;
     }
     $this->_content = View::tpl(array('result' => $result, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename, 'count' => DB::select(array(DB::expr('COUNT(id)'), 'count'))->from($this->tablename)->count_all(), 'pager' => $pager, 'types' => $types, 'pageName' => 'Характеристики'), $this->tpl_folder . '/Index');
 }
Esempio n. 2
0
 function indexAction()
 {
     $date_s = NULL;
     $date_po = NULL;
     $status = NULL;
     if (Arr::get($_GET, 'date_s')) {
         $date_s = strtotime(Arr::get($_GET, 'date_s'));
     }
     if (Arr::get($_GET, 'date_po')) {
         $date_po = strtotime(Arr::get($_GET, 'date_po'));
     }
     $page = (int) Route::param('page') ? (int) Route::param('page') : 1;
     $count = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from($this->tablename);
     if ($date_s) {
         $count->where('created_at', '>=', $date_s);
     }
     if ($date_po) {
         $count->where('created_at', '<=', $date_po + 24 * 60 * 60 - 1);
     }
     $count = $count->count_all();
     $result = DB::select()->from($this->tablename);
     if ($date_s) {
         $result->where('created_at', '>=', $date_s);
     }
     if ($date_po) {
         $result->where('created_at', '<=', $date_po + 24 * 60 * 60 - 1);
     }
     $result = $result->order_by('id', 'DESC')->limit($this->limit)->offset(($page - 1) * $this->limit)->find_all();
     $pager = Pager::factory($page, $count, $this->limit)->create();
     $this->_content = View::tpl(array('result' => $result, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename, 'count' => DB::select(array(DB::expr('COUNT(id)'), 'count'))->from($this->tablename)->count_all(), 'pager' => $pager, 'pageName' => 'Рассылка писем'), $this->tpl_folder . '/Index');
 }
Esempio n. 3
0
 public function innerAction()
 {
     $this->_template = 'CatalogItemsWithoutFilter';
     $page = !(int) Route::param('page') ? 1 : (int) Route::param('page');
     // Check for existance
     $brand = DB::select()->from('brands')->where('alias', '=', Route::param('alias'))->where('status', '=', 1)->as_object()->execute()->current();
     if (!$brand) {
         return Config::error();
     }
     // Seo
     $this->_seo['h1'] = $brand->h1;
     $this->_seo['title'] = $brand->title;
     $this->_seo['keywords'] = $brand->keywords;
     $this->_seo['description'] = $brand->description;
     $this->setBreadcrumbs($brand->name);
     // Get count items per page
     $limit = (int) Arr::get($_GET, 'per_page') ? (int) Arr::get($_GET, 'per_page') : Config::get('limit');
     // Get sort type
     $sort = in_array(Arr::get($_GET, 'sort'), array('name', 'created_at', 'cost')) ? Arr::get($_GET, 'sort') : 'sort';
     $type = in_array(strtolower(Arr::get($_GET, 'type')), array('asc', 'desc')) ? strtoupper(Arr::get($_GET, 'type')) : 'ASC';
     // Get popular items
     $result = DB::select(array('catalog_images.image', 'image'), 'catalog.*')->from('catalog')->join('catalog_images', 'LEFT')->on('catalog_images.catalog_id', '=', 'catalog.id')->on('catalog_images.main', '=', DB::expr('1'))->where('catalog.brand_id', '=', $brand->id)->where('catalog.status', '=', 1)->order_by('catalog.' . $sort, $type)->limit($limit)->offset(($page - 1) * $limit)->as_object()->execute();
     // Set description of the brand to show it above the sort part
     Config::set('brand_description', View::tpl(array('brand' => $brand), 'Brands/Inner'));
     // Count of parent groups
     $count = DB::select(array(DB::expr('COUNT(catalog.id)'), 'count'))->from('catalog')->where('brand_id', '=', $brand->id)->where('status', '=', 1)->as_object()->execute()->current()->count;
     // Generate pagination
     $pager = Pager::factory($page, $count, $limit)->create();
     // Render template
     $this->_content = View::tpl(array('result' => $result, 'pager' => $pager), 'Catalog/ItemsList');
 }
Esempio n. 4
0
 public function indexAction()
 {
     $this->_template = 'CatalogItemsWithoutFilter';
     $page = !(int) Route::param('page') ? 1 : (int) Route::param('page');
     // Seo
     $this->_seo['h1'] = 'Поиск';
     $this->_seo['title'] = 'Поиск';
     $this->_seo['keywords'] = 'Поиск';
     $this->_seo['description'] = 'Поиск';
     $this->setBreadcrumbs('Поиск');
     // Check query
     $query = Arr::get($_GET, 'query');
     if (!$query) {
         return $this->_content = $this->noResults();
     }
     // Get count items per page
     $limit = (int) Arr::get($_GET, 'per_page') ? (int) Arr::get($_GET, 'per_page') : conf::get('limit');
     // Get sort type
     $sort = in_array(Arr::get($_GET, 'sort'), array('name', 'created_at', 'cost')) ? Arr::get($_GET, 'sort') : 'sort';
     $type = in_array(strtolower(Arr::get($_GET, 'type')), array('asc', 'desc')) ? strtoupper(Arr::get($_GET, 'type')) : 'ASC';
     // Get items list
     $result = DB::select(array('catalog_images.image', 'image'), 'catalog.*')->from('catalog')->join('catalog_images', 'LEFT')->on('catalog_images.catalog_id', '=', 'catalog.id')->on('catalog_images.main', '=', DB::expr('1'))->or_where_open()->or_where('catalog.name', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where('catalog.artikul', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where_close()->where('catalog.status', '=', 1)->order_by('catalog.' . $sort, $type)->limit($limit, ($page - 1) * $limit)->as_object()->execute();
     // Check for empty list
     if (!count($result)) {
         return $this->_content = $this->noResults();
     }
     // Count of parent groups
     $count = DB::select(array(DB::expr('COUNT(catalog.id)'), 'count'))->from('catalog')->or_where_open()->or_where('catalog.name', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where('catalog.artikul', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where_close()->where('catalog.status', '=', 1)->as_object()->execute()->current()->count;
     // Generate pagination
     $pager = Pager::factory($page, $count, $limit)->create();
     // Render page
     $this->_content = View::tpl(array('result' => $result, 'pager' => $pager), 'Catalog/ItemsList');
 }
Esempio n. 5
0
 function indexAction()
 {
     $status = NULL;
     if (isset($_GET['status'])) {
         $status = Arr::get($_GET, 'status', 1);
     }
     $page = (int) Route::param('page') ? (int) Route::param('page') : 1;
     $count = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from($this->tablename);
     if ($status !== NULL) {
         $count->where('status', '=', $status);
     }
     $count = $count->count_all();
     // $result = DB::select()->from($this->tablename);
     // $result = $result->order_by('created_at', 'DESC')->limit($this->limit)->offset(($page - 1) * $this->limit)->find_all();
     $result = DB::select()->from($this->tablename);
     if ($status !== NULL) {
         $result->where('status', '=', $status);
     }
     $result = $result->order_by('sort', 'ASC')->find_all();
     $arr = array();
     foreach ($result as $obj) {
         $arr[$obj->parent_id][] = $obj;
     }
     $pager = Pager::factory($page, $count, $this->limit)->create();
     $this->_toolbar = Widgets::get('Toolbar/List', array('add' => 1, 'delete' => 1));
     $this->_content = View::tpl(array('result' => $arr, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename, 'count' => DB::select(array(DB::expr('COUNT(id)'), 'count'))->from($this->tablename)->count_all(), 'pager' => $pager, 'pageName' => 'Управление городами'), $this->tpl_folder . '/Index');
 }
Esempio n. 6
0
 function indexAction()
 {
     $page = (int) Route::param('page') ? (int) Route::param('page') : 1;
     $count = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from($this->tablename)->count_all();
     $result = DB::select()->from($this->tablename)->order_by('id', 'DESC')->limit($this->limit)->offset(($page - 1) * $this->limit)->find_all();
     $pager = Pager::factory($page, $count, $this->limit)->create();
     $this->_filter = Widgets::get('Filter/Pages');
     $this->_toolbar = Widgets::get('Toolbar/List', array('addLink' => '/backend/seo/' . Route::controller() . '/add', 'delete' => 1));
     $this->_content = View::tpl(array('result' => $result, 'count' => $count, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename, 'pager' => $pager), $this->tpl_folder . '/Index');
 }
Esempio n. 7
0
 public function indexAction()
 {
     Config::set('content_class', 'news_block');
     $page = !(int) Route::param('page') ? 1 : (int) Route::param('page');
     $result = DB::select()->from('articles')->where('status', '=', 1)->order_by('id', 'DESC')->limit((int) Config::get('limit_articles'))->offset(($page - 1) * (int) Config::get('limit_articles'))->find_all();
     // Count of articles
     $count = DB::select(array(DB::expr('COUNT(articles.id)'), 'count'))->from('articles')->where('status', '=', 1)->count_all();
     // Generate pagination
     $pager = Pager::factory($page, $count, Config::get('limit_articles'))->create();
     // Render template
     $this->_content = View::tpl(array('result' => $result, 'pager' => $pager), 'Articles/List');
 }
Esempio n. 8
0
 function indexAction()
 {
     $status = NULL;
     if (isset($_GET['status'])) {
         $status = Arr::get($_GET, 'status', 1);
     }
     $page = (int) Route::param('page') ? (int) Route::param('page') : 1;
     $count = Model::countRows($status);
     $result = Model::getRows($status, 'users.id', 'DESC', $this->limit, ($page - 1) * $this->limit);
     $pager = Pager::factory($page, $count, $this->limit)->create();
     $this->_toolbar = Widgets::get('Toolbar/List', array('addLink' => '/backend/admins/add'));
     $this->_content = View::tpl(array('result' => $result, 'tpl_folder' => $this->tpl_folder, 'tablename' => Model::$table, 'count' => $count, 'pager' => $pager, 'pageName' => $this->_seo['h1'], 'roles' => $this->aroles), $this->tpl_folder . '/Index');
 }
Esempio n. 9
0
 function indexAction()
 {
     $date_s = NULL;
     $date_po = NULL;
     $status = NULL;
     if (Arr::get($_GET, 'date_s')) {
         $date_s = strtotime(Arr::get($_GET, 'date_s'));
     }
     if (Arr::get($_GET, 'date_po')) {
         $date_po = strtotime(Arr::get($_GET, 'date_po'));
     }
     if (isset($_GET['status'])) {
         $status = Arr::get($_GET, 'status', 1);
     }
     $page = (int) Route::param('page') ? (int) Route::param('page') : 1;
     $count = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from($this->tablename);
     if ($date_s) {
         $count->where('created_at', '>=', $date_s);
     }
     if ($date_po) {
         $count->where('created_at', '<=', $date_po + 24 * 60 * 60 - 1);
     }
     if ($status !== NULL) {
         $count->where('status', '=', $status);
     }
     $count = $count->count_all();
     $result = DB::select()->from($this->tablename);
     if ($date_s) {
         $result->where('created_at', '>=', $date_s);
     }
     if ($date_po) {
         $result->where('created_at', '<=', $date_po + 24 * 60 * 60 - 1);
     }
     if ($status !== NULL) {
         $result->where('status', '=', $status);
     }
     $result = $result->order_by('created_at', 'DESC')->limit($this->limit)->offset(($page - 1) * $this->limit)->find_all();
     $pager = Pager::factory($page, $count, $this->limit)->create();
     $this->_toolbar = Widgets::get('Toolbar/List', array('delete' => 1));
     $this->_content = View::tpl(array('result' => $result, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename, 'count' => DB::select(array(DB::expr('COUNT(id)'), 'count'))->from($this->tablename)->count_all(), 'pager' => $pager, 'pageName' => 'Письма директору'), $this->tpl_folder . '/Index');
 }
Esempio n. 10
0
 function indexAction()
 {
     $date_s = NULL;
     $date_po = NULL;
     $status = NULL;
     if (Arr::get($_GET, 'date_s')) {
         $date_s = strtotime(Arr::get($_GET, 'date_s'));
     }
     if (Arr::get($_GET, 'date_po')) {
         $date_po = strtotime(Arr::get($_GET, 'date_po'));
     }
     if (isset($this->statuses[Arr::get($_GET, 'status')])) {
         $status = Arr::get($_GET, 'status', 1);
     }
     $page = (int) Route::param('page') ? (int) Route::param('page') : 1;
     $count = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from($this->tablename);
     if ($date_s !== NULL) {
         $count->where('created_at', '>=', $date_s);
     }
     if ($date_po !== NULL) {
         $count->where('created_at', '<=', $date_po + 24 * 60 * 60 - 1);
     }
     if ($status !== NULL) {
         $count->where('status', '=', $status);
     }
     $count = $count->count_all();
     $result = DB::select('orders.*', array(DB::expr('SUM(orders_items.count)'), 'count'), array(DB::expr('SUM(orders_items.cost * orders_items.count)'), 'amount'))->from('orders')->join('orders_items', 'LEFT')->on('orders_items.order_id', '=', 'orders.id');
     if ($date_s) {
         $result->where('created_at', '>=', $date_s);
     }
     if ($date_po) {
         $result->where('created_at', '<=', $date_po + 24 * 60 * 60 - 1);
     }
     if ($status !== NULL) {
         $result->where('status', '=', $status);
     }
     $result = $result->group_by('orders.id')->order_by('created_at', 'DESC')->limit($this->limit)->offset(($page - 1) * $this->limit)->find_all();
     $pager = Pager::factory($page, $count, $this->limit)->create();
     $this->_toolbar = Widgets::get('Toolbar/List', array('add' => 1));
     $this->_content = View::tpl(array('result' => $result, 'pager' => $pager, 'status' => $status, 'date_s' => $date_s, 'date_po' => $date_po, 'statuses' => $this->statuses, 'count' => DB::select(array(DB::expr('COUNT(id)'), 'count'))->from($this->tablename)->count_all()), 'Orders/Index');
 }
Esempio n. 11
0
 function indexAction()
 {
     $status = NULL;
     if (isset($_GET['status'])) {
         $status = Arr::get($_GET, 'status', 1);
     }
     $page = (int) Route::param('page') ? (int) Route::param('page') : 1;
     $count = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from($this->tablename);
     if ($status !== NULL) {
         $count->where('status', '=', $status);
     }
     $count = $count->count_all();
     $result = DB::select('models.*', array('brands.name', 'brand_name'))->from($this->tablename)->join('brands', 'LEFT')->on('brands.id', '=', 'models.brand_id');
     if ($status !== NULL) {
         $result->where('models.status', '=', $status);
     }
     $result = $result->order_by('models.name', 'ASC')->limit($this->limit)->offset(($page - 1) * $this->limit)->find_all();
     $pager = Pager::factory($page, $count, $this->limit)->create();
     $this->_toolbar = Widgets::get('Toolbar/List', array('add' => 1, 'delete' => 1));
     $this->_content = View::tpl(array('result' => $result, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename, 'count' => DB::select(array(DB::expr('COUNT(id)'), 'count'))->from($this->tablename)->count_all(), 'pager' => $pager, 'pageName' => 'Модели'), $this->tpl_folder . '/Index');
 }
Esempio n. 12
0
 public function indexAction()
 {
     $page = !(int) Route::param('page') ? 1 : (int) Route::param('page');
     // Seo
     $this->_seo['h1'] = 'Афиша';
     $this->_seo['title'] = 'Афиша';
     $this->_seo['keywords'] = 'Афиша';
     $this->_seo['description'] = 'Афиша';
     if (isset($_SESSION['idCity'])) {
         // select places id
         $places = DB::select('id')->from('places')->where('city_id', '=', $_SESSION['idCity'])->where('status', '=', DB::expr(1))->as_object()->execute();
         $ids = array();
         foreach ($places as $key => $value) {
             $ids[] = $value->id;
         }
         if (count($ids) == 0) {
             $ids[] = 0;
         }
     }
     // list posts first page
     $dbObj = DB::select('afisha.*', array('places.name', 'p_name'), array(DB::expr('MIN(prices.price)'), 'p_from'), array(DB::expr('MAX(prices.price)'), 'p_to'))->from('afisha')->join('places', 'left outer')->on('afisha.place_id', '=', 'places.id')->on('places.status', '=', DB::expr(1))->join('prices', 'left outer')->on('afisha.id', '=', 'prices.afisha_id')->where('afisha.status', '=', 1)->where('afisha.event_date', '>', DB::expr(time()));
     if (isset($_SESSION['idCity'])) {
         $dbObj->where_open()->where('afisha.place_id', 'IN', $ids)->or_where('afisha.city_id', '=', $_SESSION['idCity'])->where_close();
     }
     $result = $dbObj->group_by('afisha.id')->order_by('afisha.event_date')->limit($this->limit)->offset(($page - 1) * (int) $this->limit)->as_object()->execute();
     // Count of all posts
     $dbObj = DB::select(array(DB::expr('COUNT(afisha.id)'), 'count'))->from('afisha');
     if (isset($_SESSION['idCity'])) {
         $dbObj->where_open()->where('afisha.place_id', 'IN', $ids)->or_where('afisha.city_id', '=', $_SESSION['idCity'])->where_close();
     }
     $count = $dbObj->where('afisha.status', '=', 1)->where('afisha.event_date', '>', DB::expr(time()))->as_object()->execute()->current()->count;
     // Generate pagination
     $pager = Pager::factory($page, $count, $this->limit)->create();
     // Render template
     $this->_content = View::tpl(array('result' => $result, 'pager' => $pager), 'Afisha/List');
 }
Esempio n. 13
0
 function indexAction()
 {
     $date_s = NULL;
     $date_po = NULL;
     $status = NULL;
     $name = null;
     $place = null;
     $city = null;
     if (Arr::get($_GET, 'date_s')) {
         $date_s = strtotime(Arr::get($_GET, 'date_s'));
     }
     if (Arr::get($_GET, 'date_po')) {
         $date_po = strtotime(Arr::get($_GET, 'date_po'));
     }
     if (isset($_GET['status']) && $_GET['status'] != '') {
         $status = Arr::get($_GET, 'status') == 'published' ? 1 : 0;
     }
     if (Arr::get($_GET, 'name')) {
         $name = urldecode(Arr::get($_GET, 'name'));
     }
     if (Arr::get($_GET, 'city')) {
         $city = (int) Arr::get($_GET, 'city');
     }
     if (Arr::get($_GET, 'place')) {
         $place = Arr::get($_GET, 'place') == 'null' ? null : (int) Arr::get($_GET, 'place');
     }
     //            Count
     $count = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from($this->tablename);
     if ($date_s) {
         $count->where($this->tablename . '.event_date', '>=', $date_s);
     }
     if ($date_po) {
         $count->where($this->tablename . '.event_date', '<=', $date_po + 24 * 60 * 60 - 1);
     }
     if ($status !== NULL) {
         $count->where($this->tablename . '.status', '=', $status);
     }
     if ($name !== NULL) {
         $count->where($this->tablename . '.name', 'LIKE', "%{$name}%");
     }
     if ($_GET['place'] != '') {
         $count->where($this->tablename . '.place_id', '=', $place);
     }
     if ($city !== NULL) {
         $count->where_open()->where($this->tablename . '.city_id', '=', $city)->or_where($this->tablename . '.place_id', 'IN', DB::expr('(SELECT id FROM places WHERE city_id = ' . $city . ')'))->where_close();
     }
     $count = $count->count_all();
     //            Pager
     $page = (int) Route::param('page') ? (int) Route::param('page') : 1;
     $pager = Pager::factory($page, $count, $this->limit)->create();
     //            Result
     $result = DB::select($this->tablename . '.*', array('places.name', 'p_name'), array(DB::expr('MIN(prices.price)'), 'p_from'), array(DB::expr('MAX(prices.price)'), 'p_to'))->from($this->tablename)->join('places', 'left outer')->on($this->tablename . '.place_id', '=', 'places.id')->on('places.status', '=', DB::expr(1))->join('prices', 'left outer')->on($this->tablename . '.id', '=', 'prices.afisha_id')->group_by('afisha.id');
     if ($status !== NULL) {
         $result->where($this->tablename . '.status', '=', $status);
     }
     if ($date_s) {
         $result->where($this->tablename . '.event_date', '>=', $date_s);
     }
     if ($date_po) {
         $result->where($this->tablename . '.event_date', '<=', $date_po + 24 * 60 * 60 - 1);
     }
     if ($name !== NULL) {
         $result->where($this->tablename . '.name', 'LIKE', "%{$name}%");
     }
     if ($_GET['place'] != '') {
         $result->where($this->tablename . '.place_id', '=', $place);
     }
     if ($city !== NULL) {
         $result->where_open()->where($this->tablename . '.city_id', '=', $city)->or_where($this->tablename . '.place_id', 'IN', DB::expr('(SELECT id FROM places WHERE city_id = ' . $city . ')'))->where_close();
     }
     $result = $result->order_by($this->tablename . '.sort', 'asc')->limit($this->limit)->offset(($page - 1) * $this->limit)->find_all();
     $arr = array();
     foreach ($result as $obj) {
         $arr[$obj->parent_id][] = $obj;
     }
     $this->_toolbar = Widgets::get('Toolbar/List', array('add' => 1, 'delete' => 1));
     $this->_content = View::tpl(array('result' => $arr, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename, 'count' => DB::select(array(DB::expr('COUNT(id)'), 'count'))->from($this->tablename)->count_all(), 'pager' => $pager, 'pageName' => 'Афиши', 'places' => DB::select()->from('places')->find_all(), 'cities' => DB::select()->from('cities')->order_by('sort')->find_all()), $this->tpl_folder . '/Index');
 }
Esempio n. 14
0
 function indexAction()
 {
     $date_s = NULL;
     $date_po = NULL;
     $status = NULL;
     $eventId = null;
     $creatorId = null;
     if (Arr::get($_GET, 'date_s')) {
         $date_s = strtotime(Arr::get($_GET, 'date_s'));
     }
     if (Arr::get($_GET, 'date_po')) {
         $date_po = strtotime(Arr::get($_GET, 'date_po'));
     }
     if (isset($this->pay_statuses[Arr::get($_GET, 'status')])) {
         $status = Arr::get($_GET, 'status');
     }
     if (Arr::get($_GET, 'event') != 0) {
         $eventId = Arr::get($_GET, 'event');
     }
     if (Arr::get($_GET, 'creator_id') != 0) {
         $creatorId = Arr::get($_GET, 'creator_id');
     }
     //            Count
     $count = DB::select(array(DB::expr('COUNT(*)'), 'count'))->from($this->tablename);
     if (User::info()->role_id != 2) {
         $count->where('admin_brone', '=', 0);
     }
     if ($date_s !== NULL) {
         $count->where($this->tablename . '.first_created_at', '>=', $date_s);
     }
     if ($date_po !== NULL) {
         $count->where($this->tablename . '.first_created_at', '<=', $date_po + 24 * 60 * 60 - 1);
     }
     if ($status !== NULL) {
         switch ($status) {
             case 'brone':
                 $count->where($this->tablename . '.first_created_at', '>', time() - Config::get('reserved_days') * 24 * 60 * 60)->where($this->tablename . '.status', '!=', 'success');
                 break;
             case 'expired':
                 $count->where($this->tablename . '.first_created_at', '<', time() - Config::get('reserved_days') * 24 * 60 * 60)->and_where_open()->where($this->tablename . '.status', '!=', 'success')->or_where($this->tablename . '.status', 'is', null)->and_where_close();
                 break;
             case 'success':
                 $count->where($this->tablename . '.status', '=', $status);
                 break;
         }
     }
     if ($eventId) {
         $count->where($this->tablename . '.afisha_id', '=', $eventId);
     }
     if ($creatorId) {
         $count->where($this->tablename . '.creator_id', '=', $creatorId);
     }
     $count = $count->count_all();
     //            Pager
     $page = (int) Route::param('page') ? (int) Route::param('page') : 1;
     $pager = Pager::factory($page, $count, $this->limit)->create();
     //            Result
     $result = DB::select($this->tablename . '.*', array('users.name', 'creator_name'))->from($this->tablename)->join('users', 'LEFT OUTER')->on('users.id', '=', $this->tablename . '.creator_id');
     if ($date_s) {
         $result->where($this->tablename . '.created_at', '>=', $date_s);
     }
     if ($date_po) {
         $result->where($this->tablename . '.created_at', '<=', $date_po + 24 * 60 * 60 - 1);
     }
     //            if (User::info()->role_id != 2) { $result->where($this->tablename.'.creator_id', '=', User::info()->id);}
     if (User::info()->role_id != 2) {
         $result->where('admin_brone', '=', 0);
     }
     if ($status !== NULL) {
         switch ($status) {
             case 'brone':
                 $result->where($this->tablename . '.created_at', '>', time() - Config::get('reserved_days') * 24 * 60 * 60)->where($this->tablename . '.status', '!=', 'success');
                 break;
             case 'expired':
                 $result->where($this->tablename . '.created_at', '<', time() - Config::get('reserved_days') * 24 * 60 * 60)->and_where_open()->where($this->tablename . '.status', '!=', 'success')->or_where($this->tablename . '.status', 'is', null)->and_where_close();
                 break;
             case 'success':
                 $result->where($this->tablename . '.status', '=', $status);
                 break;
         }
     }
     if ($eventId) {
         $result->where($this->tablename . '.afisha_id', '=', $eventId);
     }
     if ($creatorId) {
         $result->where($this->tablename . '.creator_id', '=', $creatorId);
     }
     $result = $result->order_by($this->tablename . '.id', 'DESC')->limit($this->limit)->offset(($page - 1) * $this->limit)->find_all();
     //            Creators
     $creators = DB::select()->from('users')->where('status', '=', 1)->find_all();
     //            Render
     $this->_content = View::tpl(array('result' => $result, 'pager' => $pager, 'status' => $status, 'date_s' => $date_s, 'date_po' => $date_po, 'pay_statuses' => $this->pay_statuses, 'count' => $count, 'events' => DB::select()->from('afisha')->where('place_id', 'IS NOT', null)->find_all(), 'creators' => $creators), $this->tpl_folder . '/Index');
 }
Esempio n. 15
0
 public function viewedAction()
 {
     $this->_template = 'CatalogItemsWithoutFilter';
     $page = !(int) Route::param('page') ? 1 : (int) Route::param('page');
     // Seo
     $this->_seo['h1'] = 'Недавно просмотренные товары';
     $this->_seo['title'] = 'Недавно просмотренные товары';
     $this->_seo['keywords'] = 'Недавно просмотренные товары';
     $this->_seo['description'] = 'Недавно просмотренные товары';
     $this->setBreadcrumbs('Недавно просмотренные товары');
     // Get viewed items IDs array
     $ids = Catalog::factory()->getViewedIDs();
     // Check for empty array
     if (!$ids) {
         $ids = array(0);
     }
     // Get viewed items list
     $result = DB::select('catalog_images.image', 'catalog.*')->from('catalog')->join('catalog_images', 'LEFT')->on('catalog_images.catalog_id', '=', 'catalog.id')->on('catalog_images.main', '=', DB::expr('1'))->where('id', 'IN', $ids)->order_by($this->sort, $this->type)->limit($this->limit)->offset(($page - 1) * $this->limit)->as_object()->execute();
     // Count of parent groups
     $count = DB::select(array(DB::expr('COUNT(catalog.id)'), 'count'))->from('catalog')->where('id', 'IN', $ids)->where('status', '=', 1)->as_object()->execute()->current()->count;
     // Generate pagination
     $pager = Pager::factory($page, $count, $this->limit)->create();
     // Render template
     $this->_content = View::tpl(array('result' => $result, 'pager' => $pager), 'Catalog/ItemsList');
 }