public function endAction() { $orderId = (int) Route::param('id'); if ($orderId and isset($_POST) and count($_POST) > 0) { $data = json_decode(base64_decode($_POST['data']), true); $order = DB::select()->from('afisha_orders')->where('id', '=', $orderId)->find(); if (!$order) { return Config::error(); } // update status if ($data['status'] && $data['status'] == 'success') { Common::update('afisha_orders', array('status' => 'success', 'updated_at' => time()))->where('id', '=', $orderId)->execute(); // Change status for seats $prices = DB::select('id')->from('prices')->where('afisha_id', '=', $order->afisha_id)->find_all(); $pricesArr = array(); if (count($prices)) { foreach ($prices as $key => $value) { $pricesArr[] = $value->id; } $res2 = \Core\Common::update('seats', array('status' => 3))->where('view_key', 'IN', array_filter(explode(',', $order->seats_keys)))->where('price_id', 'IN', $pricesArr)->execute(); } } } // HTTP::redirect('after_payment/'); return; }
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() { $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 pages $result = DB::select()->from('content')->where('status', '=', 1)->order_by('sort')->as_object()->execute(); $pages = array(); foreach ($result as $obj) { $pages[$obj->parent_id][] = $obj; } // Get catalog groups $result = DB::select()->from('catalog_tree')->where('status', '=', 1)->order_by('sort')->as_object()->execute(); $groups = array(); foreach ($result as $obj) { $groups[$obj->parent_id][] = $obj; } // Get catalog groups $brands = DB::select()->from('brands')->where('status', '=', 1)->order_by('sort')->as_object()->execute(); // Get news $news = DB::select()->from('news')->where('status', '=', 1)->order_by('date', 'DESC')->as_object()->execute(); // Get articles $articles = DB::select()->from('articles')->where('status', '=', 1)->order_by('id', 'DESC')->as_object()->execute(); // Render page $this->_content = View::tpl(array('pages' => $pages, 'groups' => $groups, 'news' => $news, 'articles' => $articles, 'brands' => $brands), 'Sitemap/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 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'); }
public function comments($array = array()) { $id = Route::param('id'); if (!$id) { return $this->_data['comments'] = ''; } $result = DB::select()->from('catalog_comments')->where('status', '=', 1)->where('catalog_id', '=', $id)->order_by('date', 'DESC')->as_object()->execute(); return $this->_data['comments'] = View::widget(array('result' => $result), 'Comments'); }
public function indexAction() { $subscriber = DB::select()->from('subscribers')->where('hash', '=', Route::param('hash'))->where('status', '=', 1)->as_object()->execute()->current(); if (!$subscriber) { Message::GetMessage(0, 'Вы не подписаны на рассылку с нашего сайта!'); HTTP::redirect('/'); } DB::update('subscribers')->set(array('status' => 0, 'updated_at' => time()))->where('id', '=', $subscriber->id)->execute(); Message::GetMessage(1, 'Вы успешно отписались от рассылки новостей с нашего сайта!'); HTTP::redirect('/'); }
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); }
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 function innerAction() { Config::set('content_class', 'new_block'); // Check for existance $obj = DB::select()->from('articles')->where('alias', '=', Route::param('alias'))->where('status', '=', 1)->find(); if (!$obj) { return Config::error(); } // Seo $this->_seo['h1'] = $obj->h1; $this->_seo['title'] = $obj->title; $this->_seo['keywords'] = $obj->keywords; $this->_seo['description'] = $obj->description; $this->setBreadcrumbs($obj->name); // Add plus one to views DB::update('articles')->set(array('views' => $obj->views + 1))->where('id', '=', $obj->id)->execute(); // Render template $this->_content = View::tpl(array('obj' => $obj), 'Articles/Inner'); }
public static function getSelectOptions($filename, $table, $parentID = NULL, $currentElement = 0, $sort = 'sort', $parentAlias = 'parent_id') { if ($filename != 'catalog/select') { $current = Route::param('id'); } else { $current = 0; } $tree = array(); $result = DB::select()->from($table)->order_by($sort)->as_object()->execute(); foreach ($result as $obj) { if (!$current) { $tree[$obj->{$parentAlias}][] = $obj; } else { if ($obj->parent_id != $current and $obj->id != $current) { $tree[$obj->{$parentAlias}][] = $obj; } } } return View::tpl(array('result' => $tree, 'currentParent' => 0, 'space' => '', 'filename' => $filename, 'parentID' => $parentID, 'parentAlias' => $parentAlias, 'currentID' => $currentElement), $filename); }
public function indexAction() { // Check for existance $page = DB::select()->from('content')->where('alias', '=', Route::param('alias'))->where('status', '=', 1)->as_object()->execute()->current(); if (!$page) { return Config::error(); } // Seo $this->_seo['h1'] = $page->h1; $this->_seo['title'] = $page->title; $this->_seo['keywords'] = $page->keywords; $this->_seo['description'] = $page->description; $this->generateParentBreadcrumbs($page->parent_id, 'content', 'parent_id'); $this->setBreadcrumbs($page->name); // Add plus one to views DB::update('content')->set(array('views' => $page->views + 1))->where('id', '=', $page->id)->execute(); // Get content page children $kids = DB::select()->from('content')->where('status', '=', 1)->where('parent_id', '=', $page->id)->order_by('sort', 'ASC')->as_object()->execute(); // Render template $this->_content = View::tpl(array('text' => $page->text, 'kids' => $kids), 'Content/Page'); }
function editAction() { if ($_POST) { $post = $_POST['FORM']; $post['status'] = Arr::get($_POST, 'status', 0); $res = Common::update($this->tablename, $post)->where('id', '=', Arr::get($_POST, 'id'))->execute(); if ($res) { Message::GetMessage(1, 'Вы успешно изменили данные!'); HTTP::redirect('backend/' . Route::controller() . '/edit/' . (int) Route::param('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(); } $this->_toolbar = Widgets::get('Toolbar/Edit'); $this->_seo['h1'] = 'Редактирование'; $this->_seo['title'] = 'Редактирование'; $this->setBreadcrumbs('Редактирование', 'backend/' . Route::controller() . '/edit/' . (int) Route::param('id')); $this->_content = View::tpl(array('obj' => $result, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename), $this->tpl_folder . '/Form'); }
function printAction() { if (User::get_access_for_controller('afisha_brone') != 'edit') { $this->no_access(); } $seats = (array) $_POST['SEATS']; $printType = $_POST['print-type'] ? $_POST['print-type'] : 'base'; if (count($seats) == 0) { Message::GetMessage(0, 'Места не выбраны!'); HTTP::redirect('backend/afisha_orders/edit/' . Route::param('id')); } $order = DB::select()->from($this->tablename)->where('id', '=', Route::param('id'))->find(); if (!$order) { return Config::error(); } $afisha = DB::select('afisha.*', array('places.name', 'place'), 'places.filename', 'places.address', 'places.city_id')->from('afisha')->join('places')->on('afisha.place_id', '=', 'places.id')->where('afisha.id', '=', $order->afisha_id)->find(); if (!$afisha) { return Config::error(); } $city = DB::select()->from('cities')->where('id', '=', $afisha->city_id)->find(); $seatStr = array(); $termoSeatStr = array(); try { $dom = Map::factory()->loadFile($afisha->filename)->getDomInstance(); $gTag = $dom->getElementsByTagName('g'); foreach ($gTag as $el) { $id = $el->getAttribute('id'); if (in_array($id, $seats)) { if ($el->parentNode->hasAttribute('data-plase')) { $originalPlace = $el->parentNode->getAttribute('data-plase'); } elseif ($el->parentNode->parentNode->hasAttribute('data-plase')) { $originalPlace = $el->parentNode->parentNode->getAttribute('data-plase'); } if ($originalPlace) { $place = str_replace('(левая сторона)', '(лев. сторона)', $originalPlace); $place = str_replace('(правая сторона)', '(пр. сторона)', $place); $place = str_replace(',', '<br />', $place); $place = str_replace('ряд', 'ряд:', $place); $seatStr[$id] = str_replace(array('места', 'Места'), 'место', $place); $dataInit = json_decode($el->getAttribute('data-init')); $seatStr[$id] .= $dataInit->seat; // For termo print preg_match('#^(.*)?, ряд ([0-9]+)#', $originalPlace, $matches); $termoSeatStr[$id]['block'] = $matches[1]; $termoSeatStr[$id]['row'] = $matches[2]; $termoSeatStr[$id]['seat'] = $dataInit->seat; $termoSeatStr[$id]['block'] = str_replace('(левая сторона)', '(лев. сторона)', $termoSeatStr[$id]['block']); $termoSeatStr[$id]['block'] = str_replace('(правая сторона)', '(пр. сторона)', $termoSeatStr[$id]['block']); } } } } catch (\Exception $e) { die('Ошибка загрузки карты'); } $tickets = array(); foreach ($seats as $seat) { if (User::info()->role_id != 2 && User::get_access_for_controller('afisha_print_unlimit') == 'edit' && strpos($order->printed_seats, $seat) !== false) { continue; } $priceRow = DB::select('price')->from('prices')->join('seats', 'LEFT')->on('prices.id', '=', 'seats.price_id')->where('afisha_id', '=', $order->afisha_id)->where('seats.view_key', '=', $seat)->find(); $tickets[] = Arr::to_object(array('event_name' => $afisha->name, 'print_name' => $afisha->print_name, 'print_name_small' => $afisha->print_name_small, 'event_date' => date('d', $afisha->event_date) . ' ' . Dates::month(date('m', $afisha->event_date)) . ' ' . date('Y', $afisha->event_date) . ' в ' . $afisha->event_time, 'event_place' => $afisha->place, 'event_just_date' => date('j', $afisha->event_date) . ' ' . Dates::month(date('m', $afisha->event_date)) . ' ' . date('Y', $afisha->event_date), 'event_time' => $afisha->event_time, 'event_address' => $afisha->address, 'place_string' => $seatStr[$seat], 'place_block' => $termoSeatStr[$seat]['block'], 'place_row' => $termoSeatStr[$seat]['row'], 'place_seat' => $termoSeatStr[$seat]['seat'], 'price' => $priceRow->price, 'phone' => $city->phone, 'barcode' => $afisha->id . '-' . $order->id . '-' . $seat)); } // Update print seats keys if (User::info()->role_id != 2 && User::get_access_for_controller('afisha_print_unlimit') == 'edit') { $oldSeats = $order->printed_seats; $newSeats = array(); if (strlen($oldSeats)) { $oldSeats = explode(',', $oldSeats); if (count($oldSeats)) { $newSeats = (array) $oldSeats; } } foreach ($seats as $seat) { $newSeats[] = $seat; } $newSeats = array_filter(array_unique($newSeats)); $newSeats = implode(',', $newSeats); DB::update($this->tablename)->set(array('printed_seats' => $newSeats))->where('id', '=', $order->id)->execute(); } // Update order status $newOrder = DB::select()->from('afisha_orders')->where('id', '=', $order->id)->find(); $printedAllSeats = true; $printedSeats = array_filter(explode(',', $newOrder->printed_seats)); foreach (array_filter(explode(',', $newOrder->seats_keys)) as $seat) { if (!in_array($seat, $printedSeats)) { $printedAllSeats = false; } } if (User::info()->role_id != 2 && $printedAllSeats) { \Core\Common::update('afisha_orders', array('status' => 'success'))->where('id', '=', (int) $order->id)->execute(); $prices = DB::select('id')->from('prices')->where('afisha_id', '=', $order->afisha_id)->find_all(); $pricesArr = array(); if (count($prices)) { foreach ($prices as $key => $value) { $pricesArr[] = $value->id; } \Core\Common::update('seats', array('status' => 3))->where('view_key', 'IN', array_filter(explode(',', $order->seats_keys)))->where('price_id', 'IN', $pricesArr)->execute(); } } if ($printType == 'base') { echo View::tpl(array('tickets' => $tickets), 'Afisha_orders/Print'); } else { echo View::tpl(array('tickets' => $tickets), 'Afisha_orders/PrintTermo'); } die; }
<?php $arr = explode('?', $_SERVER['REQUEST_URI']); $url = $arr[0]; $url = (int) \Core\Route::param('page') > 1 ? str_replace('/page/' . \Core\Route::param('page'), '', $url) : $url; $arr = explode('/', trim($url, '/')); ?> <div class="sideBar sideBarFixed sideBarSize"> <div class="mCustomScrollbar fluid sideBarScrollSize"> <div class="sideBarContent"> <ul class="navLeft"> <?php foreach ((array) $result[0] as $obj) { ?> <?php if (isset($result[$obj->id]) and count($result[$obj->id])) { ?> <?php $check = false; ?> <?php foreach ($result[$obj->id] as $_obj) { ?> <?php if ($arr[1] . '/' . $arr[2] == $_obj->link || $arr[1] . '/index' == $_obj->link || $arr[1] == $_obj->link) { ?> <?php $check = true; ?> <?php }
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 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 static function getSpecificationsWidget() { $result = DB::select('specifications_values.id', 'specifications_values.name', 'specifications_values.color', 'specifications_values.alias', array('specifications.name', 'specification_name'), array('specifications.alias', 'specification_alias'), array('specifications.id', 'specification_id'), array('specifications.type_id', 'specification_type_id'))->from('specifications_values')->join('catalog_specifications_values', 'LEFT')->on('catalog_specifications_values.specification_value_id', '=', 'specifications_values.id')->join('specifications', 'LEFT')->on('specifications.id', '=', 'catalog_specifications_values.specification_id')->join('catalog', 'LEFT')->on('catalog_specifications_values.catalog_id', '=', 'catalog.id')->where('catalog.parent_id', '=', Route::param('group'))->where('catalog.status', '=', 1)->group_by('specifications.alias')->group_by('specifications_values.alias')->order_by('specifications.name')->as_object()->execute(); $specifications = array(); $values = array(); foreach ($result as $obj) { $values[$obj->specification_alias][] = $obj; $specifications[$obj->specification_alias] = $obj->specification_name; } return array('list' => $specifications, 'values' => $values); }
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'); } DB::delete($this->tablename)->where('id', '=', $id)->execute(); Message::GetMessage(1, 'Данные удалены!'); HTTP::redirect('backend/' . Route::controller() . '/index'); }
function detailed_exportAction() { $poster = Model::getPoster(Route::param('id')); if (!$poster) { return Config::error(); } $detailed = Model::getFullDetailed($poster); Model::getFullExcel($detailed, $poster); }
function exportAction() { $afishaId = (int) Route::param('id'); // Select current user $cassier = DB::select()->from($this->tablename)->where($this->tablename . '.id', '=', (int) Route::param('user_id'))->find(); // Select afisha $afisha = DB::select()->from('afisha')->where('id', '=', $afishaId)->find(); if (!$cassier or !$afisha) { return Config::error(); } $orders = DB::select()->from('afisha_orders')->where('payer_id', '=', $cassier->id)->where('afisha_id', '=', $afishaId)->order_by('id', 'DESC')->find_all(); Model::getExcel($orders, $afisha); }
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'); } $images = DB::select()->from('catalog_images')->where('catalog_id', '=', $id)->find_all(); foreach ($images as $im) { @unlink(HOST . HTML::media('images/catalog/small/' . $im->image)); @unlink(HOST . HTML::media('images/catalog/medium/' . $im->image)); @unlink(HOST . HTML::media('images/catalog/big/' . $im->image)); @unlink(HOST . HTML::media('images/catalog/original/' . $im->image)); } DB::delete($this->tablename)->where('id', '=', $id)->execute(); Message::GetMessage(1, 'Данные удалены!'); HTTP::redirect('backend/' . Route::controller() . '/index'); }
public function mapAction() { // Get afisha post and validate $item = Model::getItem(Route::param('alias')); if (!$item->id) { return Config::error(); } // Seo $this->setSeoForItem($item, true); $this->setBreadcrumbs('Схема зала'); // Get seats for available places $seats = Model::getMapSeats($item->id); // Get prices list $prices = Model::getMapPrices($item->id, true); try { $map = Map::factory(); $map->loadFile($item->p_filename); $map->addPrices($prices); $mapTpl = $map->parseDom($seats, true); } catch (\Exception $e) { if ($item->url != '') { header('Location: ' . $item->url); } else { HTTP::redirect('brone?name=' . $item->name); } exit; } $this->_content = View::tpl(array('item' => $item, 'map' => $mapTpl), 'Map/Main'); }
function deleteAction() { $id = (int) Route::param('id'); $page = Model::getRow($id); if (!$page) { Message::GetMessage(0, 'Данные не существуют!'); HTTP::redirect('backend/' . Route::controller() . '/index'); } Model::delete($id); Message::GetMessage(1, 'Данные удалены!'); HTTP::redirect('backend/' . Route::controller() . '/index'); }
function createOrderAction() { if (User::get_access_for_controller('afisha_brone') != 'edit') { $this->no_access(); } $key = Route::param('key'); $keys = (array) explode(',', $key); $keys = array_filter($keys); if (count($keys) == 0) { Message::GetMessage(0, 'Места не выбраны!'); HTTP::redirect('backend/afisha/index'); } $afisha = DB::select('afisha.*', array('places.name', 'place'), 'places.filename', 'places.address')->from('afisha')->join('places')->on('afisha.place_id', '=', 'places.id')->where('afisha.id', '=', (int) Route::param('id'))->find(); if (!$afisha) { return Config::error(); } // Get prices by afisha ID $prices = DB::select('id')->from('prices')->where('afisha_id', '=', $afisha->id)->find_all(); if (count($prices) == 0) { Message::GetMessage(0, 'Ошибка создания заказа (выборка цен)'); HTTP::redirect('backend/afisha/index'); } $pricesIds = array(); foreach ($prices as $price) { $pricesIds[] = $price->id; } // Generate seats id from places list $seats = DB::select('id')->from('seats')->where('view_key', 'IN', $keys)->where('price_id', 'IN', $pricesIds)->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(); if (count($seats) == 0) { Message::GetMessage(0, 'Ошибка создания заказа (выборка мест)'); HTTP::redirect('backend/afisha/index'); } $seatsId = array(); foreach ($seats as $seat) { $seatsId[] = $seat->id; } $orderType = (int) Route::param('orderType'); $data = array('afisha_id' => $afisha->id, 'is_admin' => User::info()->role_id == 2 ? 1 : 0, 'admin_brone' => $orderType, 'creator_id' => User::info()->id, 'seats_keys' => implode(',', $keys), 'created_at' => time(), 'first_created_at' => time(), 'status' => ''); $res = DB::insert('afisha_orders', array_keys($data))->values(array_values($data))->execute(); if ($res) { // Update status $res2 = DB::update('seats')->set(array('status' => $orderType == 1 ? 3 : 2, 'reserved_at' => time()))->where('id', 'IN', $seatsId)->execute(); Message::GetMessage(1, 'Заказ успешно создан!'); HTTP::redirect('backend/afisha_orders/edit/' . $res[0]); } else { Message::GetMessage(0, 'Ошибка создания заказа!'); HTTP::redirect('backend/afisha/index'); } }
function archiveAction() { $id = (int) Route::param('id'); $page = Model::getRow($id); if (!$page) { Message::GetMessage(0, 'Данные не существуют!'); HTTP::redirect('backend/' . Route::controller() . '/index'); } if ($page->deleted) { Message::GetMessage(1, 'Данные уже в архиве!'); HTTP::redirect('backend/archive/admins'); } Model::update(Model::$table, array('deleted' => 1))->where('id', '=', $id)->execute(); Message::GetMessage(1, 'Данные перемещены в архив!'); HTTP::redirect('backend/' . Route::controller() . '/index'); }
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'); }