示例#1
0
 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');
 }
示例#2
0
 public function indexAction()
 {
     $page = !(int) Route::param('page') ? 1 : (int) Route::param('page');
     // Seo
     $this->_seo['h1'] = 'Карта сайта';
     $this->_seo['title'] = 'Карта сайта';
     $this->_seo['keywords'] = 'Карта сайта';
     $this->_seo['description'] = 'Карта сайта';
     $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');
 }
示例#3
0
 public function indexAction()
 {
     $this->_template = 'CatalogItemsWithoutFilter';
     $page = !(int) Route::param('page') ? 1 : (int) Route::param('page');
     // Seo
     $this->_seo['h1'] = 'Поиск';
     $this->_seo['title'] = 'Поиск';
     $this->_seo['keywords'] = 'Поиск';
     $this->_seo['description'] = 'Поиск';
     $this->setBreadcrumbs('Поиск');
     // Check query
     $query = Arr::get($_GET, 'query');
     if (!$query) {
         return $this->_content = $this->noResults();
     }
     // Get count items per page
     $limit = (int) Arr::get($_GET, 'per_page') ? (int) Arr::get($_GET, 'per_page') : conf::get('limit');
     // Get sort type
     $sort = in_array(Arr::get($_GET, 'sort'), array('name', 'created_at', 'cost')) ? Arr::get($_GET, 'sort') : 'sort';
     $type = in_array(strtolower(Arr::get($_GET, 'type')), array('asc', 'desc')) ? strtoupper(Arr::get($_GET, 'type')) : 'ASC';
     // Get items list
     $result = DB::select(array('catalog_images.image', 'image'), 'catalog.*')->from('catalog')->join('catalog_images', 'LEFT')->on('catalog_images.catalog_id', '=', 'catalog.id')->on('catalog_images.main', '=', DB::expr('1'))->or_where_open()->or_where('catalog.name', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where('catalog.artikul', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where_close()->where('catalog.status', '=', 1)->order_by('catalog.' . $sort, $type)->limit($limit, ($page - 1) * $limit)->as_object()->execute();
     // Check for empty list
     if (!count($result)) {
         return $this->_content = $this->noResults();
     }
     // Count of parent groups
     $count = DB::select(array(DB::expr('COUNT(catalog.id)'), 'count'))->from('catalog')->or_where_open()->or_where('catalog.name', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where('catalog.artikul', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where_close()->where('catalog.status', '=', 1)->as_object()->execute()->current()->count;
     // Generate pagination
     $pager = Pager::factory($page, $count, $limit)->create();
     // Render page
     $this->_content = View::tpl(array('result' => $result, 'pager' => $pager), 'Catalog/ItemsList');
 }
示例#4
0
 public function innerAction()
 {
     $this->_template = 'CatalogItemsWithoutFilter';
     $page = !(int) Route::param('page') ? 1 : (int) Route::param('page');
     // Check for existance
     $brand = DB::select()->from('brands')->where('alias', '=', Route::param('alias'))->where('status', '=', 1)->as_object()->execute()->current();
     if (!$brand) {
         return Config::error();
     }
     // Seo
     $this->_seo['h1'] = $brand->h1;
     $this->_seo['title'] = $brand->title;
     $this->_seo['keywords'] = $brand->keywords;
     $this->_seo['description'] = $brand->description;
     $this->setBreadcrumbs($brand->name);
     // Get count items per page
     $limit = (int) Arr::get($_GET, 'per_page') ? (int) Arr::get($_GET, 'per_page') : Config::get('limit');
     // Get sort type
     $sort = in_array(Arr::get($_GET, 'sort'), array('name', 'created_at', 'cost')) ? Arr::get($_GET, 'sort') : 'sort';
     $type = in_array(strtolower(Arr::get($_GET, 'type')), array('asc', 'desc')) ? strtoupper(Arr::get($_GET, 'type')) : 'ASC';
     // Get popular items
     $result = DB::select(array('catalog_images.image', 'image'), 'catalog.*')->from('catalog')->join('catalog_images', 'LEFT')->on('catalog_images.catalog_id', '=', 'catalog.id')->on('catalog_images.main', '=', DB::expr('1'))->where('catalog.brand_id', '=', $brand->id)->where('catalog.status', '=', 1)->order_by('catalog.' . $sort, $type)->limit($limit)->offset(($page - 1) * $limit)->as_object()->execute();
     // Set description of the brand to show it above the sort part
     Config::set('brand_description', View::tpl(array('brand' => $brand), 'Brands/Inner'));
     // Count of parent groups
     $count = DB::select(array(DB::expr('COUNT(catalog.id)'), 'count'))->from('catalog')->where('brand_id', '=', $brand->id)->where('status', '=', 1)->as_object()->execute()->current()->count;
     // Generate pagination
     $pager = Pager::factory($page, $count, $limit)->create();
     // Render template
     $this->_content = View::tpl(array('result' => $result, 'pager' => $pager), 'Catalog/ItemsList');
 }
示例#5
0
 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;
 }
示例#6
0
 function logoutAction()
 {
     if (!User::factory()->_admin) {
         HTTP::redirect('backend/' . Route::controller() . '/login');
     }
     User::factory()->logout();
     HTTP::redirect('backend/' . Route::controller() . '/login');
 }
示例#7
0
 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');
 }
示例#8
0
 public function read()
 {
     $tasks = file('static/task.txt');
     foreach ($tasks as $str) {
         $tasks1[$str] = substr($str, 2);
     }
     \Models\Task::addTask($tasks1);
     $redirect = $_SERVER['HTTP_REFERER'];
     \Core\Route::redirectTo($redirect);
 }
示例#9
0
 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('/');
 }
示例#10
0
 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');
 }
示例#11
0
 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);
 }
示例#12
0
文件: App.php 项目: bhshawon/elomelo
 public function __construct()
 {
     $this->setupAutoload();
     $url = $this->parseURL();
     foreach (RouteCollection::getCollection() as $key) {
         $routeParams = Route::GetRoutParams($key['url'], $url);
         if ($routeParams !== FALSE && strcmp($this->action, $key["action"]) == 0) {
             $name = "controllers\\" . $key["controller"];
             $this->controller = new $name();
             $this->method = $key["method"];
             $this->controller->{$this->method}($this->params);
             break;
         }
     }
 }
示例#13
0
 public function access()
 {
     if (!User::info()) {
         return false;
     }
     $this->_access = User::caccess();
     if (in_array(Route::controller(), array('ajax', 'form')) or in_array(Route::action(), array('printTicket', 'print', 'createOrder')) or Route::controller() == 'orders' && Route::action() == 'delete') {
         return true;
     }
     if ($this->_access == 'no') {
         $this->no_access();
     }
     if ($this->_access == 'view' && Route::action() != 'index' && Route::action() != 'edit') {
         $this->no_access();
     }
 }
示例#14
0
 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');
 }
示例#15
0
 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');
 }
示例#16
0
 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);
 }
示例#17
0
 public static function uploadTask($data)
 {
     $uploaddir = 'static/';
     $extension = strrchr(basename($data['name']), ".");
     $name = 'task';
     $task_name = $name . $extension;
     $uploadfile = $uploaddir . $task_name;
     if (!move_uploaded_file($data['tmp_name'], $uploadfile)) {
         return false;
     } else {
         $tasks = file('static/task.txt');
         $tasks1 = [];
         foreach ($tasks as $str) {
             $tasks1[$str] = substr($str, 2);
         }
         \Models\Task::addTask($tasks1);
         $redirect = $_SERVER['HTTP_REFERER'];
         \Core\Route::redirectTo($redirect);
     }
 }
示例#18
0
 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');
 }
示例#19
0
 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');
 }
示例#20
0
 public static function uploadAvatar($data)
 {
     if (!self::checkForError($data['error'])) {
         return false;
     }
     if (!self::checkMimeType($data['type'])) {
         return false;
     }
     if (!self::checkBlackListExtensions($data['name'])) {
         return false;
     }
     $uploaddir = 'avatar/';
     $extension = strrchr(basename($data['name']), ".");
     $id = $_SESSION['auth']['id'];
     $avatar_name = $id . $extension;
     $uploadfile = $uploaddir . $avatar_name;
     if (!move_uploaded_file($data['tmp_name'], $uploadfile)) {
         return false;
     } else {
         $redirect = $_SERVER['HTTP_REFERER'];
         \Core\Route::redirectTo($redirect);
         return true;
     }
 }
示例#21
0
文件: init.php 项目: Ksarat/miritec
<?php

use core\Route;
// our router, using to manage our route
$p = new Route();
$p->start();
示例#22
0
<?php

use Core\Route;
require_once 'autoload.php';
Route::init();
示例#23
0
 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');
     }
 }
示例#24
0
 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');
 }
示例#25
0
 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);
 }
示例#26
0
 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');
 }
示例#27
0
            ?>
/edit/<?php 
            echo $obj->id;
            ?>
" title="Редактировать"><i class="fa-pencil"></i> Редактировать</a>
											</li>
										<?php 
        }
        ?>
										<?php 
        if (Core\User::caccess() == 'edit') {
            ?>
											<li class="divider"></li>
											<li>
												<a onclick="return confirm('Это действие необратимо. Продолжить?');" href="/backend/<?php 
            echo \Core\Route::controller();
            ?>
/delete/<?php 
            echo $obj->id;
            ?>
" title="Удалить"><i class="fa-trash-o text-danger"></i> Удалить</a>
											</li>
										<?php 
        }
        ?>
		                            </ul>
		                        </li>
		                    </ul>
		                </td>
		            </tr>
				</table>
示例#28
0
 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');
 }
示例#29
0
 function detailed_exportAction()
 {
     $poster = Model::getPoster(Route::param('id'));
     if (!$poster) {
         return Config::error();
     }
     $detailed = Model::getFullDetailed($poster);
     Model::getFullExcel($detailed, $poster);
 }
示例#30
0
 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');
 }