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'); }
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'); }
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'); }
public function __construct() { if (self::$layout === NULL) { self::$layout = DB::select('zna')->from('config')->where('key', '=', DB::expr('"message_output"'))->as_object()->execute()->current()->zna; // self::$layout = Config::get('message_output'); } }
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'); }
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'); }
function indexAction() { $count = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from($this->tablename)->count_all(); $result = DB::select()->from($this->tablename)->order_by('id', 'DESC')->find_all(); $this->_filter = Widgets::get('Filter/Pages'); $this->_toolbar = Widgets::get('Toolbar/List', array('add' => 1, 'delete' => 1)); $this->_content = View::tpl(array('result' => $result, 'count' => $count, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename), $this->tpl_folder . '/Index'); }
public static function countRows($status = NULL, $filter = null) { $result = DB::select(array(DB::expr('COUNT(' . static::$table . '.id)'), 'count'))->from(static::$table)->where('role_id', '=', 1); $result = parent::setFilter($result); if ($status !== NULL) { $result->where(static::$table . '.status', '=', $status); } return $result->count_all(); }
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'); }
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'); }
public static function valid($post = array()) { if (Route::param('id') && Arr::get($post, 'email')) { if (DB::select(array(DB::expr('COUNT(id)'), 'count'))->from('users')->where('email', '=', Arr::get($post, 'email'))->where('id', '!=', Route::param('id'))->count_all()) { Message::GetMessage(0, 'Указанный E-Mail уже занят!'); return FALSE; } } if (Arr::get($_POST, 'password') and mb_strlen(Arr::get($_POST, 'password'), 'UTF-8') < Config::get('main.password_min_length')) { Message::GetMessage(0, 'Пароль должен быть не короче ' . Config::get('main.password_min_length') . ' символов!'); return FALSE; } return parent::valid($post); }
function indexAction() { $this->_seo['h1'] = 'Панель управления'; $this->_seo['title'] = 'Панель управления'; $count_catalog = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from('catalog')->count_all(); $count_orders = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from('orders')->count_all(); $count_comments = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from('catalog_comments')->count_all(); $count_subscribers = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from('subscribers')->count_all(); $count_users = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from('users')->where('role_id', '!=', 2)->count_all(); $count_banners = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from('banners')->count_all(); $count_articles = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from('articles')->count_all(); $count_news = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from('news')->count_all(); $this->_content = View::tpl(array('count_catalog' => $count_catalog, 'count_orders' => $count_orders, 'count_comments' => $count_comments, 'count_subscribers' => $count_subscribers, 'count_users' => $count_users, 'count_banners' => $count_banners, 'count_articles' => $count_articles, 'count_news' => $count_news), 'Index/Main'); }
public function indexAction() { // Get item information from database $item = DB::select('catalog.*', array('brands.name', 'brand_name'), array('brands.alias', 'brand_alias'), array('models.name', 'model_name'), array('catalog_tree.name', 'parent_name'))->from('catalog')->join('catalog_tree', 'LEFT')->on('catalog.parent_id', '=', 'catalog_tree.id')->join('brands', 'LEFT')->on('catalog.brand_id', '=', 'brands.id')->on('brands.status', '=', DB::expr('1'))->join('models', 'LEFT')->on('catalog.model_id', '=', 'models.id')->on('models.status', '=', DB::expr('1'))->where('catalog.status', '=', 1)->where('catalog.alias', '=', Route::param('alias'))->as_object()->execute()->current(); if (!$item) { return Config::error(); } Route::factory()->setParam('id', $item->id); Route::factory()->setParam('group', $item->parent_id); // Add to cookie viewed list Catalog::factory()->addViewed($item->id); // Add plus one to views DB::update('catalog')->set(array('views' => (int) $item->views + 1))->where('id', '=', $item->id)->execute(); // Seo $this->setSeoForItem($item); // Get images $images = DB::select('image')->from('catalog_images')->where('catalog_id', '=', $item->id)->order_by('sort')->as_object()->execute(); // Get item sizes $sizes = DB::select('sizes.*')->from('sizes')->join('catalog_sizes', 'LEFT')->on('catalog_sizes.size_id', '=', 'sizes.id')->where('catalog_sizes.catalog_id', '=', $item->id)->where('sizes.status', '=', 1)->order_by('sizes.name')->as_object()->execute(); // Get current item specifications list $specifications = DB::select('specifications.*')->from('specifications')->join('catalog_tree_specifications', 'LEFT')->on('catalog_tree_specifications.specification_id', '=', 'specifications.id')->where('catalog_tree_specifications.catalog_tree_id', '=', $item->parent_id)->where('specifications.status', '=', 1)->order_by('specifications.name')->as_object()->execute(); $res = DB::select()->from('specifications_values')->join('catalog_specifications_values', 'LEFT')->on('catalog_specifications_values.specification_value_id', '=', 'specifications_values.id')->where('catalog_specifications_values.catalog_id', '=', $item->id)->where('status', '=', 1)->where('catalog_specifications_values.specification_value_id', '!=', 0)->as_object()->execute(); $specValues = array(); foreach ($res as $obj) { $specValues[$obj->specification_id][] = $obj; } $spec = array(); foreach ($specifications as $obj) { if (isset($specValues[$obj->id]) and is_array($specValues[$obj->id]) and count($specValues[$obj->id])) { if ($obj->type_id == 3) { $spec[$obj->name] = ''; foreach ($specValues[$obj->id] as $o) { $spec[$obj->name] .= $o->name . ', '; } $spec[$obj->name] = substr($spec[$obj->name], 0, -2); } else { $spec[$obj->name] = $specValues[$obj->id][0]->name; } } } // Render template $this->_content = View::tpl(array('obj' => $item, 'images' => $images, 'sizes' => $sizes, 'specifications' => $spec), 'Catalog/Item'); }
public static function getWidgetRows() { 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; } } $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.main_show', '=', 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')->as_object()->execute(); return $result; }
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'); }
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'); }
function editAction() { if (!User::admin()) { HTTP::redirect('backend/' . Route::controller() . '/login'); } $user = User::info(); if ($_POST) { $post = $_POST; if (strlen(Arr::get($post, 'password')) < $this->password_length or strlen(Arr::get($post, 'new_password')) < $this->password_length or strlen(Arr::get($post, 'confirm_password')) < $this->password_length or !User::factory()->check_password(Arr::get($post, 'password'), $user->password) or Arr::get($post, 'new_password') != Arr::get($post, 'confirm_password')) { Message::GetMessage(0, 'Вы что-то напутали с паролями!'); HTTP::redirect('backend/' . Route::controller() . '/edit'); } if (!strlen(trim(Arr::get($post, 'name')))) { Message::GetMessage(0, 'Имя не может быть пустым!'); HTTP::redirect('backend/' . Route::controller() . '/edit'); } if (!strlen(trim(Arr::get($post, 'login')))) { Message::GetMessage(0, 'Логин не может быть пустым!'); HTTP::redirect('backend/' . Route::controller() . '/edit'); } $count = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from('users')->where('id', '!=', $user->id)->where('login', '=', Arr::get($post, 'login'))->count_all(); if ($count) { Message::GetMessage(0, 'Пользователь с таким логином уже существует!'); HTTP::redirect('backend/' . Route::controller() . '/edit'); } $data = array('name' => Arr::get($post, 'name'), 'login' => Arr::get($post, 'login'), 'password' => User::factory()->hash_password(Arr::get($post, 'new_password'))); Common::factory('users')->update($data, $user->id); Message::GetMessage(1, 'Вы успешно изменили данные!'); HTTP::redirect('backend/' . Route::controller() . '/edit'); } $this->_toolbar = Widgets::get('Toolbar/EditSaveOnly'); $this->_seo['h1'] = 'Мой профиль'; $this->_seo['title'] = 'Редактирование личных данных'; $this->setBreadcrumbs('Мой профиль', 'backend/' . Route::controller() . '/' . Route::action()); $this->_content = View::tpl(array('obj' => $user), 'Auth/Edit'); }
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'); }
function printAction() { $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')->where('orders.id', '=', Route::param('id'))->find(); $cart = DB::select('catalog.*', 'catalog_images.image', 'orders_items.count', array('sizes.name', 'size_name'), array('orders_items.cost', 'price'), 'orders_items.size_id')->from('orders_items')->join('catalog', 'LEFT')->on('orders_items.catalog_id', '=', 'catalog.id')->join('catalog_images', 'LEFT')->on('catalog_images.main', '=', DB::expr(1))->on('catalog_images.catalog_id', '=', 'catalog.id')->join('sizes', 'LEFT')->on('orders_items.size_id', '=', 'sizes.id')->where('orders_items.order_id', '=', Route::param('id'))->find_all(); echo View::tpl(array('order' => $result, 'list' => $cart, 'payment' => Config::get('order.payment'), 'delivery' => Config::get('order.delivery'), 'statuses' => Config::get('order.statuses')), $this->tpl_folder . '/Print'); die; }
public function updateSeatsAction() { $post = $_POST; $afisha_id = $post['afisha_id']; $list_keys = $post['list']; if (!$afisha_id or !$list_keys) { die(json_encode(array('success' => false, 'message' => 'Ошибка получения данных'))); } $afisha = DB::select()->from('afisha_orders')->where('id', '=', (int) $afisha_id)->find(); $prices = DB::select('id')->from('prices')->where('afisha_id', '=', $afisha->afisha_id)->find_all(); $keys = (array) array_filter(explode(',', $list_keys)); $pricesArr = array(); if (count($prices)) { foreach ($prices as $key => $value) { $pricesArr[] = $value->id; } // Reset old seats \Core\Common::update('seats', array('status' => 1, 'reserved_at' => DB::expr(NULL)))->where('view_key', 'IN', array_filter(explode(',', $afisha->seats_keys)))->where('price_id', 'IN', $pricesArr)->execute(); // Write new seats // Generate seats id from places list $seats = DB::select('id')->from('seats')->where('view_key', 'IN', $keys)->where('price_id', 'IN', $pricesArr)->and_where_open()->where('status', '=', 1)->or_where_open()->where('status', '=', 2)->where('reserved_at', '<', time() - 60 * 60 * 24 * Config::get('reserved_days'))->or_where_close()->and_where_close()->find_all(); $seatsId = array(); foreach ($seats as $seat) { $seatsId[] = $seat->id; } DB::update('seats')->set(array('status' => 2, 'reserved_at' => time()))->where('id', 'IN', $seatsId)->execute(); } $res = \Core\Common::update('afisha_orders', array('seats_keys' => $list_keys))->where('id', '=', (int) $afisha_id)->execute(); if ($res) { die(json_encode(array('success' => true, 'message' => 'Данные сохранены', 'reload' => true))); } else { die(json_encode(array('success' => false, 'message' => 'Ошибка обновления данных'))); } }
public function printAction() { $this->_template = 'Print'; if (!U::info()) { return Config::error(); } $result = DB::select('orders.*', array(DB::expr('SUM(orders_items.cost * orders_items.count)'), 'amount'), array(DB::expr('SUM(orders_items.count)'), 'count'))->from('orders')->join('orders_items', 'LEFT')->on('orders_items.order_id', '=', 'orders.id')->where('orders.id', '=', Route::param('id'))->as_object()->execute()->current(); $cart = DB::select('catalog.alias', 'catalog.id', 'catalog.name', 'catalog_images.image', 'orders_items.count', array('sizes.name', 'size_name'), array('orders_items.cost', 'price'), 'orders_items.size_id')->from('orders_items')->join('catalog', 'LEFT')->on('orders_items.catalog_id', '=', 'catalog.id')->join('catalog_images', 'LEFT')->on('catalog_images.main', '=', DB::expr('1'))->on('catalog_images.catalog_id', '=', 'catalog.id')->join('sizes', 'LEFT')->on('orders_items.size_id', '=', 'sizes.id')->where('orders_items.order_id', '=', Route::param('id'))->as_object()->execute(); $this->_content = View::tpl(array('order' => $result, 'list' => $cart, 'payment' => Config::get('order.payment'), 'delivery' => Config::get('order.delivery'), 'statuses' => Config::get('order.statuses')), 'User/Print'); }
public function moreAffisheAction() { $page = (int) Arr::get($_POST, 'page'); if (!isset($page)) { $this->error('Ошибка загрузки'); } // list posts 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; } } $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(Config::get('limit'))->offset(($page - 1) * (int) Config::get('limit'))->execute()->as_array(); foreach ($result as $key => $value) { $result[$key]['p_name'] = Afisha\Models\Afisha::getItemPlace($value, true); $result[$key]['cost'] = Afisha\Models\Afisha::getItemPrice($value, true); $result[$key]['event_date'] = date('j', $value['event_date']) . ' ' . Dates::month(date('n', $value['event_date'])) . ' ' . date('Y', $value['event_date']); if (!is_file(HOST . HTML::media('images/afisha/medium/' . $value['image']))) { $result[$key]['image'] = false; } } // 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; // Set view button more load $showBut = true; if ($count <= Config::get('limit') * $page) { $showBut = false; } // Render template $this->success(array('result' => $result, 'showBut' => $showBut)); }
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'); }
function deleteAction() { $id = (int) Route::param('id'); if (!$id) { Message::GetMessage(0, 'Данные не существуют!'); HTTP::redirect('backend/' . Route::controller() . '/index'); } $page = DB::select()->from($this->tablename)->where('id', '=', $id)->find(); if (!$page) { Message::GetMessage(0, 'Данные не существуют!'); HTTP::redirect('backend/' . Route::controller() . '/index'); } $countChildGroups = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from('catalog_tree')->where('parent_id', '=', $id)->count_all(); if ($countChildGroups) { Message::GetMessage(0, 'Нельзя удалить эту группу, так как у нее есть подгруппы!'); HTTP::redirect('backend/' . Route::controller() . '/index'); } $countChildItems = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from('catalog')->where('parent_id', '=', $id)->count_all(); if ($countChildItems) { Message::GetMessage(0, 'Нельзя удалить эту группу, так как в ней содержатся товары!'); HTTP::redirect('backend/' . Route::controller() . '/index'); } Files::deleteImage($this->image, $page->image); DB::delete($this->tablename)->where('id', '=', $id)->execute(); Message::GetMessage(1, 'Данные удалены!'); HTTP::redirect('backend/' . Route::controller() . '/index'); }
private function setFilter($query, $date_s, $date_po, $status, $eventId, $creatorId, $table) { if ($date_s !== NULL) { $query->where($table . '.created_at', '>=', $date_s); } if ($date_po !== NULL) { $query->where($table . '.created_at', '<=', $date_po + 24 * 60 * 60 - 1); } if ($status !== NULL) { if ($status == 'null') { $query->where($table . '.status', 'IS', DB::expr('null')); } else { $query->where($table . '.status', '=', $status); } } if ($eventId) { $query->where($table . '.afisha_id', '=', $eventId); } if ($creatorId) { $query->where($table . '.payer_id', '=', $creatorId); } return $query; }
public static function getModelsWidget() { $filter = conf::get('filter_array'); if (Arr::get($filter, 'brand')) { $brands = array(); foreach (Arr::get($filter, 'brand') as $brand) { $brands[] = ' brands.alias = "' . $brand . '" '; } if (count($brands)) { $brands = ' AND ' . implode(' AND ', $brands); } unset($add['brand']); } else { $brands = ''; } return DB::select('models.name', 'models.alias', 'models.id')->from('models')->join('catalog', 'LEFT')->on('catalog.model_id', '=', 'models.id')->join('brands', 'LEFT')->on('brands.id', '=', 'catalog.brand_id')->on('brands.status', '=', DB::expr('1'))->where('catalog.parent_id', '=', Route::param('group'))->where('catalog.status', '=', 1)->where('models.status', '=', 1)->where('brands.alias', 'IN', Arr::get($filter, 'brand', array()))->group_by('models.id')->order_by('models.name')->as_object()->execute(); }
function editAction() { $itemSizes = Arr::get($_POST, 'SIZES', array()); $specArray = Arr::get($_POST, 'SPEC', array()); if ($_POST) { $post = $_POST['FORM']; // Set default settings for some fields $post['status'] = Arr::get($_POST, 'status', 0); $post['new'] = Arr::get($_POST, 'new', 0); $post['top'] = Arr::get($_POST, 'top', 0); $post['sale'] = Arr::get($_POST, 'sale', 0); $post['available'] = Arr::get($_POST, 'available', 0); $post['sex'] = Arr::get($_POST, 'sex', 0); $post['cost'] = (int) Arr::get($post, 'cost', 0); $post['cost_old'] = (int) Arr::get($post, 'cost_old', 0); $isNew = DB::select('new')->from($this->tablename)->where('id', '=', (int) Route::param('id'))->find(); if (Arr::get($post, 'new') and (!$isNew or !$isNew->new)) { $post['new_from'] = time(); } // Check form for rude errors if (!Arr::get($post, 'alias')) { Message::GetMessage(0, 'Алиас не может быть пустым!'); } else { if (!Arr::get($post, 'name')) { Message::GetMessage(0, 'Название не может быть пустым!'); } else { if (!Arr::get($post, 'cost')) { Message::GetMessage(0, 'Цена не может быть пустой!'); } else { $post['alias'] = Common::getUniqueAlias($this->tablename, Arr::get($post, 'alias'), Arr::get($_POST, 'id')); $res = Common::update($this->tablename, $post)->where('id', '=', Arr::get($_POST, 'id'))->execute(); if ($res) { DB::delete('catalog_sizes')->where('catalog_id', '=', Arr::get($_POST, 'id'))->execute(); foreach ($itemSizes as $size_id) { DB::insert('catalog_sizes', array('catalog_id', 'size_id'))->values(array(Arr::get($_POST, 'id'), $size_id))->execute(); } DB::delete('catalog_specifications_values')->where('catalog_id', '=', Arr::get($_POST, 'id'))->execute(); foreach ($specArray as $key => $value) { if (is_array($value)) { foreach ($value as $specification_value_id) { DB::insert('catalog_specifications_values', array('catalog_id', 'specification_value_id', 'specification_id'))->values(array(Arr::get($_POST, 'id'), $specification_value_id, $key))->execute(); } } else { if ($value) { DB::insert('catalog_specifications_values', array('catalog_id', 'specification_value_id', 'specification_id'))->values(array(Arr::get($_POST, 'id'), $value, $key))->execute(); } } } Message::GetMessage(1, 'Вы успешно изменили данные!'); HTTP::redirect('/backend/' . Route::controller() . '/edit/' . Arr::get($_POST, 'id')); } else { Message::GetMessage(0, 'Не удалось изменить данные!'); } } } } $post['id'] = Arr::get($_POST, 'id'); $result = Arr::to_object($post); } else { $result = DB::select()->from($this->tablename)->where('id', '=', (int) Route::param('id'))->find(); $res = DB::select()->from('catalog_sizes')->where('catalog_id', '=', (int) Route::param('id'))->find_all(); foreach ($res as $obj) { $itemSizes[] = $obj->size_id; } $res = DB::select('catalog_specifications_values.specification_id', 'specification_value_id', 'specifications.type_id')->from('catalog_specifications_values')->join('specifications')->on('catalog_specifications_values.specification_id', '=', 'specifications.id')->where('catalog_id', '=', (int) Route::param('id'))->find_all(); foreach ($res as $obj) { if ($obj->type_id == 3) { $specArray[$obj->specification_id][] = $obj->specification_value_id; } else { $specArray[$obj->specification_id] = $obj->specification_value_id; } } } $this->_toolbar = Widgets::get('Toolbar/Edit'); $this->_seo['h1'] = 'Редактирование'; $this->_seo['title'] = 'Редактирование'; $this->setBreadcrumbs('Редактирование', 'backend/' . Route::controller() . '/edit/' . (int) Route::param('id')); $images = DB::select()->from('catalog_images')->where('catalog_id', '=', $result->id)->order_by('sort')->find_all(); $show_images = View::tpl(array('images' => $images), $this->tpl_folder . '/UploadedImages'); $brands = DB::select('brands.*')->from('brands')->join('catalog_tree_brands')->on('catalog_tree_brands.brand_id', '=', 'brands.id')->where('catalog_tree_brands.catalog_tree_id', '=', $result->parent_id)->order_by('brands.name')->find_all(); $sizes = DB::select('sizes.*')->from('sizes')->join('catalog_tree_sizes')->on('catalog_tree_sizes.size_id', '=', 'sizes.id')->where('catalog_tree_sizes.catalog_tree_id', '=', $result->parent_id)->order_by('sizes.name')->find_all(); $specifications = DB::select('specifications.*')->from('specifications')->join('catalog_tree_specifications')->on('catalog_tree_specifications.specification_id', '=', 'specifications.id')->where('catalog_tree_specifications.catalog_tree_id', '=', $result->parent_id)->order_by('specifications.name')->find_all(); $arr = array(0); foreach ($specifications as $s) { $arr[] = $s->id; } $specValues = DB::select()->from('specifications_values')->where('specification_id', 'IN', $arr)->order_by('name')->find_all(); $arr = array(); foreach ($specValues as $obj) { $arr[$obj->specification_id][] = $obj; } $this->_content = View::tpl(array('obj' => $result, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename, 'tree' => Support::getSelectOptions('Catalog/Select', 'catalog_tree', $result->parent_id), 'brands' => $brands, 'models' => DB::select()->from('models')->where('brand_id', '=', $result->brand_id)->order_by('name')->find_all(), 'show_images' => $show_images, 'countSimpleOrders' => DB::select(array(DB::expr('id'), 'count'))->from('orders_simple')->where('catalog_id', '=', $result->id)->count_all(), 'countOrders' => DB::select(array(DB::expr('COUNT(orders.id)'), 'count'))->from('orders')->join('orders_items', 'LEFT')->on('orders_items.order_id', '=', 'orders.id')->where('orders_items.catalog_id', '=', $result->id)->count_all(), 'happyCount' => DB::select(array(DB::expr('COUNT(orders_items.id)'), 'count'))->from('orders_items')->join('orders', 'LEFT')->on('orders_items.order_id', '=', 'orders.id')->on('orders.status', '=', DB::expr(1))->where('catalog_id', '=', $result->id)->count_all(), 'happyMoney' => DB::select(array(DB::expr('SUM(orders_items.count * orders_items.cost)'), 'amount'))->from('orders_items')->join('orders', 'LEFT')->on('orders.id', '=', 'orders_items.order_id')->on('orders.status', '=', DB::expr('1'))->where('orders_items.catalog_id', '=', $result->id)->group_by('orders_items.catalog_id')->find()->amount, 'itemSizes' => $itemSizes, 'sizes' => $sizes, 'specifications' => $specifications, 'specValues' => $arr, 'specArray' => $specArray), $this->tpl_folder . '/Form'); }
public function headerNew($array = array()) { $count = 0; $result = DB::select(array(DB::expr('COUNT(id)'), 'count'))->from('log')->where('deleted', '=', 0)->as_object()->execute()->current(); if ($result) { $count = $result->count; } $result = DB::select()->from('log')->where('deleted', '=', 0)->limit(7)->as_object()->execute(); return $this->_data['headerNew'] = View::widget(array('count' => $count, 'result' => $result), 'HeaderNew'); }
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'); }
public function check_cart() { if (!$this->_cart_id) { return false; } $result = DB::select(array('carts_items.catalog_id', 'catalog_id'), array('carts_items.size_id', 'size_id'), array('carts_items.count', 'count'))->from('carts_items')->join('catalog', 'LEFT')->on('catalog.id', '=', 'carts_items.catalog_id')->join('sizes', 'LEFT')->on('sizes.id', '=', 'carts_items.size_id')->on('sizes.status', '=', DB::expr('1'))->where('catalog.status', '=', 1)->where('carts_items.cart_id', '=', $this->_cart_id)->order_by('carts_items.id', 'DESC')->as_object()->execute(); foreach ($result as $obj) { $this->_cart[$obj->catalog_id . '-' . $obj->size_id] = array("id" => $obj->catalog_id, "size" => $obj->size_id, "count" => $obj->count); } return true; }