function addAction() { if ($_POST) { $post = $_POST['FORM']; $post['status'] = Arr::get($_POST, 'status', 0); $post['created_at'] = time(); if (!trim(Arr::get($post, 'name'))) { Message::GetMessage(0, 'Поле "Название" не может быть пустым!'); } else { $res = Common::insert($this->tablename, $post)->execute(); if ($res) { Message::GetMessage(1, 'Вы успешно добавили данные!'); HTTP::redirect('backend/seo/' . Route::controller() . '/add'); } else { Message::GetMessage(0, 'Не удалось добавить данные!'); } } $result = Arr::to_object($post); } else { $result = array(); } $this->_toolbar = Widgets::get('Toolbar/Edit', array('list_link' => '/backend/seo/metrika/index')); $this->_seo['h1'] = 'Добавление'; $this->_seo['title'] = 'Добавление'; $this->setBreadcrumbs('Добавление', 'backend/' . Route::controller() . '/add'); $this->_content = View::tpl(array('obj' => $result, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename), $this->tpl_folder . '/Form'); }
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; 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('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'); $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 indexAction() { // Seo $this->_seo['h1'] = 'Корзина'; $this->_seo['title'] = 'Корзина'; $this->_seo['keywords'] = 'Корзина'; $this->_seo['description'] = 'Корзина'; // Get cart items $cart = C::factory()->get_list_for_basket(); // Render template $this->_content = View::tpl(array('cart' => $cart, 'payment' => Config::get('order.payment'), 'delivery' => Config::get('order.delivery')), 'Cart/Index'); }
function editAction() { if ($_POST) { foreach ($_POST['FORM'] as $key => $value) { $res = Common::update($this->tablename, array('zna' => $value))->where('id', '=', $key)->execute(); } Message::GetMessage(1, 'Вы успешно изменили данные!'); HTTP::redirect('backend/' . Route::controller() . '/edit'); } $result = DB::select()->from($this->tablename)->where('status', '=', 1)->order_by('sort')->find_all(); $this->_toolbar = Widgets::get('Toolbar/EditSaveOnly'); $this->_content = View::tpl(array('result' => $result, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/Edit'); }
private function render() { if (Config::get('error')) { $this->_template = '404'; } $this->_breadcrumbs = HTML::breadcrumbs($this->_breadcrumbs); $data = array(); foreach ($this as $key => $value) { $data[$key] = $value; } echo View::tpl($data, $this->_template); echo System::global_massage(); }
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() { // Check for existance $page = DB::select('h1', 'title', 'keywords', 'description', 'text', 'name')->from('control')->where('alias', '=', 'contact')->as_object()->execute()->current(); if (!$page) { return conf::error(); } // Seo $this->_seo['h1'] = $page->h1; $this->_seo['title'] = $page->title; $this->_seo['keywords'] = $page->keywords; $this->_seo['description'] = $page->description; $this->setBreadcrumbs($page->name); // Render template $this->_content = View::tpl(array('text' => $page->text, 'kids' => array()), 'Contact/Index'); }
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 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'); }
function innerAction() { if (User::info()->role_id != 2 && User::info()->id != Route::param('id')) { $this->no_access(); } // Select current user $organizer = Model::getOrganizerById(Route::param('id'), 1); if (!$organizer) { $this->no_access(); } $this->_seo['h1'] = 'Отчет организатора: ' . $organizer->name; $this->_seo['title'] = 'Отчет организатора: ' . $organizer->name; $this->setBreadcrumbs('Отчет организатора: ' . $organizer->name); // Set filter vars $date_s = NULL; $date_po = NULL; $eventId = 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 (Arr::get($_GET, 'event') != 0) { $eventId = Arr::get($_GET, 'event'); } if (Arr::get($_GET, 'status') != 'null') { $status = Arr::get($_GET, 'status'); } $filter = array('date_s' => $date_s, 'date_po' => $date_po, 'status' => $status, 'event_id' => $eventId, 'organizer_id' => $organizer->id, 'order' => array('created_at', 'DESC')); $posters = Model::getPosters($filter); // Make array with all need data $result = array(); foreach ($posters as $poster) { $result[$poster->id]['poster'] = $poster; $result[$poster->id]['detailed'] = Model::getDetailed($poster); } // Rendering $this->_content = View::tpl(array('result' => $result, 'pay_statuses' => $this->pay_statuses, 'events' => DB::select()->from('afisha')->where('place_id', 'IS NOT', null)->where('organizer_id', '=', $organizer->id)->find_all(), 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/Inner'); }
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'); }
public function indexAction() { // Seo $this->_seo['h1'] = 'Оплата'; $this->_seo['title'] = 'Оплата'; $this->_seo['keywords'] = 'Оплата'; $this->_seo['description'] = 'Оплата'; // Check $order = DB::select()->from('afisha_orders')->where('id', '=', (int) Route::param('id'))->find(); if (!$order) { return Config::error(); } $afisha = DB::select()->from('afisha')->where('id', '=', $order->afisha_id)->find(); $amount = 0; $prices = DB::select()->from('prices')->where('afisha_id', '=', $afisha->id)->find_all(); if (count($prices)) { $pricesId = array(); foreach ($prices as $key => $value) { $pricesId[] = $value->id; } $seats = DB::select('prices.price')->from('seats')->join('prices', 'LEFT')->on('prices.id', '=', 'seats.price_id')->where('price_id', 'IN', $pricesId)->where('view_key', 'IN', array_filter(explode(',', $order->seats_keys)))->find_all(); if (count($seats)) { foreach ($seats as $key => $value) { $amount += $value->price; } } } $percent = Config::get('liq_pay_percent'); if ($percent > 0) { $amount = $amount + $amount / 100 * $percent; } $dataArr = array('version' => 3, 'public_key' => Config::get('public_key'), 'amount' => $amount, 'currency' => 'UAH', 'description' => 'Оплата за покупку мест на мероприятии: ' . $afisha->name, 'order_id' => $order->id . time(), 'result_url' => 'http://' . $_SERVER['HTTP_HOST'] . '/payment/end/' . $order->id, 'server_url' => 'http://' . $_SERVER['HTTP_HOST'] . '/payment/end/' . $order->id, 'language' => 'ru'); $data = base64_encode(json_encode($dataArr)); $privateKey = Config::get('private_key'); $signature = base64_encode(sha1($privateKey . $data . $privateKey, 1)); // Render template $this->_content = View::tpl(array('data' => $data, 'signature' => $signature), 'Payment/Link'); }
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 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'); }
function printTicketAction() { if (User::get_access_for_controller('afisha_brone') != 'edit') { $this->no_access(); } $key = Route::param('key'); $keys = (array) explode(',', $key); if (count($keys) == 0) { Message::GetMessage(0, 'Места не выбраны!'); HTTP::redirect('backend/afisha/index'); } $printType = Route::param('printType') ? Route::param('printType') : 'base'; $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', '=', (int) Route::param('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, $keys)) { 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 = $originalPlace; $place = str_replace(array('места', 'Места'), 'место', $place); $place = str_replace('(левая сторона)', '(лев. сторона)', $place); $place = str_replace('(правая сторона)', '(пр. сторона)', $place); $place = str_replace(',', '<br />', $place); $place = str_replace('ряд', 'ряд:', $place); $seatStr[$id] = $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]['block'] = str_replace('(левая сторона)', '(лев. сторона)', $termoSeatStr[$id]['block']); $termoSeatStr[$id]['block'] = str_replace('(правая сторона)', '(пр. сторона)', $termoSeatStr[$id]['block']); $termoSeatStr[$id]['row'] = $matches[2]; $termoSeatStr[$id]['seat'] = $dataInit->seat; } } } } catch (\Exception $e) { die('Ошибка загрузки карты'); } $tickets = array(); foreach ($keys as $key) { $priceRow = DB::select('price', 'seats.id')->from('prices')->join('seats', 'LEFT')->on('prices.id', '=', 'seats.price_id')->where('afisha_id', '=', $afisha->id)->where('seats.view_key', '=', $key)->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('j', $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[$key], 'place_block' => $termoSeatStr[$key]['block'], 'place_row' => $termoSeatStr[$key]['row'], 'place_seat' => $termoSeatStr[$key]['seat'], 'price' => $priceRow->price, 'phone' => $city->phone, 'barcode' => $afisha->id . '-' . $key)); } if ($printType == 'base') { echo View::tpl(array('tickets' => $tickets), 'Afisha_orders/Print'); } else { echo View::tpl(array('tickets' => $tickets), 'Afisha_orders/PrintTermo'); } die; }
function sendAction() { $emails = array(); $list = array(); if ($_POST) { $post = $_POST['FORM']; $subscribers = DB::select('email', 'hash', 'name')->from('subscribers')->where('status', '=', 1)->find_all(); foreach ($subscribers as $obj) { if (filter_var($obj->email, FILTER_VALIDATE_EMAIL) and !in_array($obj->email, $emails)) { $emails[] = $obj; $list[] = $obj->email; } } if (!trim(Arr::get($post, 'subject'))) { Message::GetMessage(0, 'Поле "Тема" не может быть пустым!'); } else { if (!trim(Arr::get($post, 'text'))) { Message::GetMessage(0, 'Поле "Содержание" не может быть пустым!'); } else { if (empty($emails)) { Message::GetMessage(0, 'Список выбраных E-Mail для рассылки пуст!'); } else { $data = $post; $data['count_emails'] = count($list); $data['emails'] = implode(';', $list); $res = Common::insert($this->tablename, $data)->execute(); foreach ($emails as $obj) { $link = 'http://' . Arr::get($_SERVER, 'HTTP_HOST') . '/unsubscribe/hash/' . $obj->hash; $from = array('{{unsubscribe}}', '{{user_name}}', '{{site}}', '{{date}}'); $to = array($link, $obj->name, Arr::get($_SERVER, 'HTTP_HOST'), date('d.m.Y')); $message = str_replace($from, $to, Arr::get($post, 'text')); $subject = str_replace($from, $to, Arr::get($post, 'subject')); if (!Config::get('main.cron')) { Email::send($subject, $message, $obj->email); } else { $data = array('subject' => $subject, 'text' => $message, 'email' => $obj->email); $res = Common::insert(Config::get('main.tableCron'), $data)->execute(); } } Message::GetMessage(1, 'Письмо успешно разослано ' . $data['count_emails'] . ' подписчикам!'); HTTP::redirect('backend/' . Route::controller() . '/' . Route::action()); } } } $result = Arr::to_object($post); } else { $result = Arr::to_object(array('subscribers' => 1)); } $this->_toolbar = Widgets::get('Toolbar/Subscribe'); $this->_seo['h1'] = 'Отправка письма'; $this->_seo['title'] = 'Отправка письма'; $this->setBreadcrumbs('Отправка письма', 'backend/' . Route::controller() . '/add'); $this->_content = View::tpl(array('obj' => $result, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename), $this->tpl_folder . '/Send'); }
public function getMapAction() { $post = $_POST; // Check data $id_place = Arr::get($post, 'id_place'); $id_afisha = Arr::get($post, 'id_afisha'); if (!isset($id_place)) { die(json_encode(array('success' => false, 'error' => 'Ошибка обработки'))); } $result = DB::select()->from('places')->where('id', '=', $id_place)->find(); if (!$result) { die(json_encode(array('success' => false, 'error' => 'Ошибка выборки места с БД'))); } $seats = \Modules\Afisha\Models\Afisha::getMapSeats($id_afisha); // getMap try { $obj = \Modules\Afisha\Models\Map::factory()->loadFile($result->filename); // parse Data $map = $obj->parseDom($seats, true, true); $mapTpl = View::tpl(array('map' => $map), 'Map/Main'); die(json_encode(array('success' => true, 'map' => $mapTpl))); } catch (\Exception $e) { die(json_encode(array('success' => false, 'error' => $e->getMessage(), 'code' => $e->getCode()))); } }
public function change_passwordAction() { if (!U::info()) { return Config::error(); } $this->addMeta('Изменить пароль'); $this->_content = View::tpl(array(), 'User/ChangePassword'); }
function after_paymentAction() { 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() . '/' . Route::action()); } else { Message::GetMessage(0, 'Не удалось изменить данные!'); } $post['id'] = Arr::get($_POST, 'id'); $result = Arr::to_object($post); } else { $result = DB::select()->from($this->tablename)->where('id', '=', 6)->find(); } $this->_seo['h1'] = 'Управление страницей после оплаты'; $this->_seo['title'] = 'Управление страницей после оплаты'; $this->setBreadcrumbs('Управление страницей после оплаты', 'backend/' . Route::controller() . '/index'); $this->_content = View::tpl(array('obj' => $result, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename), $this->tpl_folder . '/Form'); }
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); }
private function render() { $this->_breadcrumbs = HTML::backendBreadcrumbs($this->_breadcrumbs); $data = array(); foreach ($this as $key => $value) { $data[$key] = $value; } echo View::tpl($data, $this->_template); echo System::global_massage(); }
function addAction() { if ($_POST) { $post = $_POST['FORM']; $post['status'] = Arr::get($_POST, 'status', 0); $post['created_at'] = time(); if (!trim(Arr::get($post, 'name'))) { Message::GetMessage(0, 'Наименование страницы не может быть пустым!'); } else { if (!trim(Arr::get($post, 'alias'))) { Message::GetMessage(0, 'Алиас не может быть пустым!'); } else { if (!trim(Arr::get($post, 'brand_id'))) { Message::GetMessage(0, 'Модель не может существовать без бренда!'); } else { $post['alias'] = Common::getUniqueAlias($this->tablename, Arr::get($post, 'alias')); $res = Common::insert($this->tablename, $post)->execute(); if ($res) { Message::GetMessage(1, 'Вы успешно добавили данные!'); HTTP::redirect('backend/' . Route::controller() . '/add'); } else { Message::GetMessage(0, 'Не удалось добавить данные!'); } } } } $result = Arr::to_object($post); } else { $result = array(); } $this->_toolbar = Widgets::get('Toolbar/Edit'); $this->_seo['h1'] = 'Добавление'; $this->_seo['title'] = 'Добавление'; $this->setBreadcrumbs('Добавление', 'backend/' . Route::controller() . '/add'); $this->_content = View::tpl(array('obj' => $result, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename, 'brands' => DB::select()->from('brands')->order_by('name')->find_all()), $this->tpl_folder . '/Form'); }
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'); }
public static function sendOrderMessageUser(array $data) { $ip = \Core\System::getRealIP(); $mail = DB::select()->from('mail_templates')->where('status', '=', 1)->where('id', '=', 12)->find(); if (count($mail) == 0) { return false; } $dataTpl = \Core\View::tpl(array('order' => $data['order'], 'order_text' => $data['order_text']), 'Orders/Email'); $from = array('{{site}}', '{{order_number}}', '{{link_user}}', '{{data}}', '{{ip}}', '{{date}}', '{{event_name}}'); $to = array(Arr::get($_SERVER, 'HTTP_HOST'), $data['id_order'], '<a href="http://' . Arr::get($_SERVER, 'HTTP_HOST') . '/payment/' . $data['id_order'] . '">Ссылка</a>', $dataTpl, $ip, date('d.m.Y H:i'), $data['order']['event_name']); $subject = str_replace($from, $to, $mail->subject); $text = str_replace($from, $to, $mail->text); Email::send($subject, $text, $data['order']['email']); }
function addAction() { $groupBrands = Arr::get($_POST, 'BRANDS', array()); $groupSizes = Arr::get($_POST, 'SIZES', array()); $groupSpec = Arr::get($_POST, 'SPEC', array()); if ($_POST) { $post = $_POST['FORM']; $post['status'] = Arr::get($_POST, 'status', 0); $post['created_at'] = time(); if (!trim(Arr::get($post, 'name'))) { Message::GetMessage(0, 'Наименование страницы не может быть пустым!'); } else { if (!trim(Arr::get($post, 'alias'))) { Message::GetMessage(0, 'Алиас не может быть пустым!'); } else { $post['alias'] = Common::getUniqueAlias($this->tablename, Arr::get($post, 'alias')); $res = Common::insert($this->tablename, $post)->execute(); if ($res) { $id = $res[0]; $filename = Files::uploadImage($this->image); if ($filename) { DB::update($this->tablename)->set(array('image' => $filename))->where('id', '=', $id)->execute(); } foreach ($groupBrands as $brand_id) { DB::insert('catalog_tree_brands', array('catalog_tree_id', 'brand_id'))->values(array($id, $brand_id))->execute(); } foreach ($groupSizes as $size_id) { DB::insert('catalog_tree_sizes', array('catalog_tree_id', 'size_id'))->values(array($id, $size_id))->execute(); } foreach ($groupSpec as $specification_id) { DB::insert('catalog_tree_specifications', array('catalog_tree_id', 'specification_id'))->values(array($id, $specification_id))->execute(); } Message::GetMessage(1, 'Вы успешно добавили данные!'); HTTP::redirect('backend/' . Route::controller() . '/add'); } else { Message::GetMessage(0, 'Не удалось добавить данные!'); } } } $result = Arr::to_object($post); } else { $result = array(); } $this->_toolbar = Widgets::get('Toolbar/Edit'); $this->_seo['h1'] = 'Добавление'; $this->_seo['title'] = 'Добавление'; $this->setBreadcrumbs('Добавление', 'backend/' . Route::controller() . '/add'); $this->_content = View::tpl(array('obj' => $result, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename, 'tree' => Support::getSelectOptions('Groups/Select', 'catalog_tree', $result->parent_id), 'brands' => DB::select()->from('brands')->order_by('name')->find_all(), 'sizes' => DB::select()->from('sizes')->order_by('name')->find_all(), 'specifications' => DB::select()->from('specifications')->order_by('name')->find_all(), 'groupBrands' => $groupBrands, 'groupSizes' => $groupSizes, 'groupSpec' => $groupSpec), $this->tpl_folder . '/Form'); }
function innerAction() { if (User::info()->role_id != 2 && User::info()->id != Route::param('id') && User::info()->see_all_cashier_stat == 0) { $this->no_access(); } // Set filter vars $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', 1); } if (Arr::get($_GET, 'status') == 'null') { $status = 'null'; } if (Arr::get($_GET, 'event') != 0) { $eventId = Arr::get($_GET, 'event'); } if (Arr::get($_GET, 'creator_id') != 0) { $creatorId = Arr::get($_GET, 'creator_id'); } // Select current user $cassier = DB::select()->from($this->tablename)->where($this->tablename . '.id', '=', Route::param('id'))->find(); $this->_seo['h1'] = 'Статистика по ' . $cassier->name; $this->_seo['title'] = 'Статистика по ' . $cassier->name; $this->setBreadcrumbs('Статистика по ' . $cassier->name); $ordersQuery = DB::select()->from('afisha_orders')->where('payer_id', '=', $cassier->id); $this->setFilter($ordersQuery, $date_s, $date_po, $status, $eventId, $creatorId, 'afisha_orders'); $orders = $ordersQuery->order_by('created_at', 'DESC')->find_all(); // Make array with all need data $afishaGroups = array(); foreach ($orders as $order) { $afisha = DB::select()->from('afisha')->where('id', '=', $order->afisha_id)->find(); $afishaGroups[$order->afisha_id]['afisha'] = $afisha; $afishaGroups[$order->afisha_id]['orders'][$order->id] = $order; } // Rendering $this->_content = View::tpl(array('afishaGroups' => $afishaGroups, 'pay_statuses' => $this->pay_statuses, 'events' => DB::select()->from('afisha')->where('place_id', 'IS NOT', null)->find_all(), 'creators' => array(), 'pager' => '', 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/Inner'); }
function addAction() { $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); $post['created_at'] = time(); if (Arr::get($post, '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')); $res = Common::insert($this->tablename, $post)->execute(); if ($res) { $id = $res[0]; foreach ($itemSizes as $size_id) { DB::insert('catalog_sizes', array('catalog_id', 'size_id'))->values(array($id, $size_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($id, $specification_value_id, $key))->execute(); } } else { if ($value) { DB::insert('catalog_specifications_values', array('catalog_id', 'specification_value_id', 'specification_id'))->values(array($id, $value, $key))->execute(); } } } Message::GetMessage(1, 'Вы успешно добавили данные!'); HTTP::redirect('/backend/' . Route::controller() . '/edit/' . $id); } else { Message::GetMessage(0, 'Не удалось добавить данные!'); } } } } $result = Arr::to_object($post); $parent_id = $result->parent_id; $models = DB::select()->from('models')->where('brand_id', '=', $result->brand_id)->find_all(); } else { $result = array(); $models = array(); $parent_id = 0; } $this->_toolbar = Widgets::get('Toolbar/Edit'); $this->_seo['h1'] = 'Добавление'; $this->_seo['title'] = 'Добавление'; $this->setBreadcrumbs('Добавление', 'backend/' . Route::controller() . '/add'); $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', '=', $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', '=', $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, 'sizes' => $sizes, 'models' => $models, 'itemSizes' => $itemSizes, 'specifications' => $specifications, 'specValues' => $arr, 'specArray' => $specArray), $this->tpl_folder . '/Form'); }