Exemple #1
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');
 }
Exemple #2
0
 function addAction()
 {
     if ($_POST) {
         $post = $_POST['FORM'];
         $post['status'] = Arr::get($_POST, 'status', 0);
         $res = Common::insert($this->tablename, $post)->execute();
         if ($res) {
             $filename = Files::uploadImage($this->image);
             if ($filename) {
                 DB::update($this->tablename)->set(array('image' => $filename))->where('id', '=', $res[0])->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), $this->tpl_folder . '/Form');
 }
Exemple #3
0
 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, 'url'))) {
                 Message::GetMessage(0, 'Ссылка не может быть пустой!');
             } else {
                 $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), $this->tpl_folder . '/Form');
 }
Exemple #4
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');
 }
Exemple #5
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');
 }
Exemple #6
0
 public function setURI()
 {
     $uri = Arr::get($_SERVER, 'REQUEST_URI');
     $uri = explode('?', $uri);
     $this->_get = Arr::get($uri, 1, NULL) ? '?' . Arr::get($uri, 1, NULL) : NULL;
     $this->_uri = Arr::get($uri, 0, NULL);
     if (preg_match('/\\/page\\/' . $this->_current . '/', $this->_uri, $matches)) {
         $this->_uri = str_replace($matches, '', $this->_uri);
     }
 }
Exemple #7
0
 public function before()
 {
     parent::before();
     $this->_template = 'Afisha';
     $this->setBreadcrumbs('Афиша', 'afisha');
     // Set parameters for list items by $_GET
     // Get count items per page
     $this->limit = (int) Arr::get($_GET, 'per_page') ? (int) Arr::get($_GET, 'per_page') : Config::get('limit');
     // Get sort type
     $this->sort = 'afisha.' . (in_array(Arr::get($_GET, 'sort'), array('name', 'created_at', 'cost')) ? Arr::get($_GET, 'sort') : 'id');
     $this->type = in_array(strtolower(Arr::get($_GET, 'type')), array('asc', 'desc')) ? strtoupper(Arr::get($_GET, 'type')) : 'DESC';
 }
Exemple #8
0
 /**
  *  Delete image
  *  @param string $mainFolder - name of th block in Config/images.php
  *  @param string $filename   - name of the file we delete
  *  @return bool
  */
 public static function deleteImage($mainFolder, $filename)
 {
     $need = Config::get('images.' . $mainFolder);
     if (!$need) {
         return false;
     }
     foreach ($need as $one) {
         $file = HOST . HTML::media('/images/' . $mainFolder . '/' . Arr::get($one, 'path') . '/' . $filename);
         @unlink($file);
     }
     return true;
 }
Exemple #9
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);
 }
Exemple #10
0
 public function moreAffisheAction()
 {
     $page = (int) Arr::get($_POST, 'page');
     if (!isset($page)) {
         $this->error('Ошибка загрузки');
     }
     // list posts
     if (isset($_SESSION['idCity'])) {
         // select places id
         $places = DB::select('id')->from('places')->where('city_id', '=', $_SESSION['idCity'])->where('status', '=', DB::expr(1))->as_object()->execute();
         $ids = array();
         foreach ($places as $key => $value) {
             $ids[] = $value->id;
         }
         if (count($ids) == 0) {
             $ids[] = 0;
         }
     }
     $dbObj = DB::select('afisha.*', array('places.name', 'p_name'), array(DB::expr('MIN(prices.price)'), 'p_from'), array(DB::expr('MAX(prices.price)'), 'p_to'))->from('afisha')->join('places', 'left outer')->on('afisha.place_id', '=', 'places.id')->on('places.status', '=', DB::expr(1))->join('prices', 'left outer')->on('afisha.id', '=', 'prices.afisha_id')->where('afisha.status', '=', 1)->where('afisha.event_date', '>', DB::expr(time()));
     if (isset($_SESSION['idCity'])) {
         $dbObj->where_open()->where('afisha.place_id', 'IN', $ids)->or_where('afisha.city_id', '=', $_SESSION['idCity'])->where_close();
     }
     $result = $dbObj->group_by('afisha.id')->order_by('afisha.event_date')->limit(Config::get('limit'))->offset(($page - 1) * (int) Config::get('limit'))->execute()->as_array();
     foreach ($result as $key => $value) {
         $result[$key]['p_name'] = Afisha\Models\Afisha::getItemPlace($value, true);
         $result[$key]['cost'] = Afisha\Models\Afisha::getItemPrice($value, true);
         $result[$key]['event_date'] = date('j', $value['event_date']) . ' ' . Dates::month(date('n', $value['event_date'])) . ' ' . date('Y', $value['event_date']);
         if (!is_file(HOST . HTML::media('images/afisha/medium/' . $value['image']))) {
             $result[$key]['image'] = false;
         }
     }
     // Count of all posts
     $dbObj = DB::select(array(DB::expr('COUNT(afisha.id)'), 'count'))->from('afisha');
     if (isset($_SESSION['idCity'])) {
         $dbObj->where_open()->where('afisha.place_id', 'IN', $ids)->or_where('afisha.city_id', '=', $_SESSION['idCity'])->where_close();
     }
     $count = $dbObj->where('afisha.status', '=', 1)->where('afisha.event_date', '>', DB::expr(time()))->as_object()->execute()->current()->count;
     // Set view button more load
     $showBut = true;
     if ($count <= Config::get('limit') * $page) {
         $showBut = false;
     }
     // Render template
     $this->success(array('result' => $result, 'showBut' => $showBut));
 }
Exemple #11
0
 private function seo()
 {
     if (!Config::get('error')) {
         $seo = DB::select('h1', 'title', 'keywords', 'description', 'text')->from('seo_links')->where('status', '=', 1)->where('link', '=', Arr::get($_SERVER, 'REQUEST_URI'))->as_object()->execute()->current();
         if ($seo) {
             $this->_seo['h1'] = $seo->h1;
             $this->_seo['title'] = $seo->title;
             $this->_seo['keywords'] = $seo->keywords;
             $this->_seo['description'] = $seo->description;
             $this->_seo['seo_text'] = $seo->text;
         }
     } else {
         $this->_seo['h1'] = 'Ошибка 404! Страница не найдена';
         $this->_seo['title'] = 'Ошибка 404! Страница не найдена';
         $this->_seo['keywords'] = 'Ошибка 404! Страница не найдена';
         $this->_seo['description'] = 'Ошибка 404! Страница не найдена';
         $this->_seo['seo_text'] = NULL;
     }
 }
Exemple #12
0
 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');
 }
Exemple #13
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() . '/' . Route::action() . '/' . 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');
 }
Exemple #14
0
 /**
  * @return array
  */
 public function execute()
 {
     $r = new \Core\Validation\Rules();
     foreach ($this->_rules as $field => $rules) {
         if (is_array($rules) && count($rules)) {
             foreach ($rules as $rule) {
                 $method = Arr::get($rule, 'key');
                 if (!method_exists($r, $method)) {
                     continue;
                 }
                 if (in_array($rule['key'], array('regex', 'min_length', 'max_length'))) {
                     $success = $r::$method(trim(Arr::get($this->_data, $field)), Arr::get($rule, 'value'));
                 } else {
                     $success = $r::$method(trim(Arr::get($this->_data, $field)));
                 }
                 if (!$success) {
                     $this->_errors[] = $rule['error'];
                 }
             }
         }
     }
     return $this->_errors;
 }
Exemple #15
0
 function addAction()
 {
     $access = array();
     if ($_POST) {
         $post = $_POST['FORM'];
         unset($_POST['FORM']);
         $access = $_POST;
         if (Model::valid($post)) {
             $post['alias'] = 'admin';
             $res = Model::insert(Model::$table, $post)->execute();
             if ($res[1]) {
                 Model::setAccess($access, $res[0]);
                 Message::GetMessage(1, 'Вы успешно добавили данные!');
                 if (Arr::get($_POST, 'button', 'save') == 'save-close') {
                     HTTP::redirect('backend/' . Route::controller() . '/index');
                 } else {
                     if (Arr::get($_POST, 'button', 'save') == 'save-add') {
                         HTTP::redirect('backend/' . Route::controller() . '/add');
                     } else {
                         HTTP::redirect('backend/' . Route::controller() . '/edit/' . $res[0]);
                     }
                 }
             } 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, 'access' => $access), $this->tpl_folder . '/Form');
 }
Exemple #16
0
 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');
 }
Exemple #17
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');
 }
Exemple #18
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');
 }
Exemple #19
0
 public function extendBroneAction()
 {
     $order = (int) Arr::get($_POST, 'order');
     $date = Arr::get($_POST, 'date');
     $time = Arr::get($_POST, 'time');
     if (!$order or !$date or !$time) {
         die(json_encode(array('success' => false, 'message' => 'Ошибка получения данных')));
     }
     $tS = strtotime($date . ' ' . $time . ':00');
     $newTS = $tS - Config::get('reserved_days') * 24 * 60 * 60;
     \Core\Common::update('afisha_orders', array('created_at' => $newTS))->where('id', '=', $order)->execute();
     // Get current order
     $afisha = DB::select()->from('afisha_orders')->where('id', '=', $order)->find();
     $prices = DB::select('id')->from('prices')->where('afisha_id', '=', $afisha->afisha_id)->find_all();
     $pricesArr = array();
     if ($prices->count()) {
         foreach ($prices as $key => $value) {
             $pricesArr[] = $value->id;
         }
         \Core\Common::update('seats', array('reserved_at' => $newTS))->where('view_key', 'IN', array_filter(explode(',', $afisha->seats_keys)))->where('price_id', 'IN', $pricesArr)->execute();
     }
     die(json_encode(array('success' => true, 'message' => 'Данные сохранены', 'reload' => true)));
 }
Exemple #20
0
 function indexAction()
 {
     $date_s = NULL;
     $date_po = NULL;
     $status = NULL;
     $eventId = null;
     $creatorId = null;
     if (Arr::get($_GET, 'date_s')) {
         $date_s = strtotime(Arr::get($_GET, 'date_s'));
     }
     if (Arr::get($_GET, 'date_po')) {
         $date_po = strtotime(Arr::get($_GET, 'date_po'));
     }
     if (isset($this->pay_statuses[Arr::get($_GET, 'status')])) {
         $status = Arr::get($_GET, 'status');
     }
     if (Arr::get($_GET, 'event') != 0) {
         $eventId = Arr::get($_GET, 'event');
     }
     if (Arr::get($_GET, 'creator_id') != 0) {
         $creatorId = Arr::get($_GET, 'creator_id');
     }
     //            Count
     $count = DB::select(array(DB::expr('COUNT(*)'), 'count'))->from($this->tablename);
     if (User::info()->role_id != 2) {
         $count->where('admin_brone', '=', 0);
     }
     if ($date_s !== NULL) {
         $count->where($this->tablename . '.first_created_at', '>=', $date_s);
     }
     if ($date_po !== NULL) {
         $count->where($this->tablename . '.first_created_at', '<=', $date_po + 24 * 60 * 60 - 1);
     }
     if ($status !== NULL) {
         switch ($status) {
             case 'brone':
                 $count->where($this->tablename . '.first_created_at', '>', time() - Config::get('reserved_days') * 24 * 60 * 60)->where($this->tablename . '.status', '!=', 'success');
                 break;
             case 'expired':
                 $count->where($this->tablename . '.first_created_at', '<', time() - Config::get('reserved_days') * 24 * 60 * 60)->and_where_open()->where($this->tablename . '.status', '!=', 'success')->or_where($this->tablename . '.status', 'is', null)->and_where_close();
                 break;
             case 'success':
                 $count->where($this->tablename . '.status', '=', $status);
                 break;
         }
     }
     if ($eventId) {
         $count->where($this->tablename . '.afisha_id', '=', $eventId);
     }
     if ($creatorId) {
         $count->where($this->tablename . '.creator_id', '=', $creatorId);
     }
     $count = $count->count_all();
     //            Pager
     $page = (int) Route::param('page') ? (int) Route::param('page') : 1;
     $pager = Pager::factory($page, $count, $this->limit)->create();
     //            Result
     $result = DB::select($this->tablename . '.*', array('users.name', 'creator_name'))->from($this->tablename)->join('users', 'LEFT OUTER')->on('users.id', '=', $this->tablename . '.creator_id');
     if ($date_s) {
         $result->where($this->tablename . '.created_at', '>=', $date_s);
     }
     if ($date_po) {
         $result->where($this->tablename . '.created_at', '<=', $date_po + 24 * 60 * 60 - 1);
     }
     //            if (User::info()->role_id != 2) { $result->where($this->tablename.'.creator_id', '=', User::info()->id);}
     if (User::info()->role_id != 2) {
         $result->where('admin_brone', '=', 0);
     }
     if ($status !== NULL) {
         switch ($status) {
             case 'brone':
                 $result->where($this->tablename . '.created_at', '>', time() - Config::get('reserved_days') * 24 * 60 * 60)->where($this->tablename . '.status', '!=', 'success');
                 break;
             case 'expired':
                 $result->where($this->tablename . '.created_at', '<', time() - Config::get('reserved_days') * 24 * 60 * 60)->and_where_open()->where($this->tablename . '.status', '!=', 'success')->or_where($this->tablename . '.status', 'is', null)->and_where_close();
                 break;
             case 'success':
                 $result->where($this->tablename . '.status', '=', $status);
                 break;
         }
     }
     if ($eventId) {
         $result->where($this->tablename . '.afisha_id', '=', $eventId);
     }
     if ($creatorId) {
         $result->where($this->tablename . '.creator_id', '=', $creatorId);
     }
     $result = $result->order_by($this->tablename . '.id', 'DESC')->limit($this->limit)->offset(($page - 1) * $this->limit)->find_all();
     //            Creators
     $creators = DB::select()->from('users')->where('status', '=', 1)->find_all();
     //            Render
     $this->_content = View::tpl(array('result' => $result, 'pager' => $pager, 'status' => $status, 'date_s' => $date_s, 'date_po' => $date_po, 'pay_statuses' => $this->pay_statuses, 'count' => $count, 'events' => DB::select()->from('afisha')->where('place_id', 'IS NOT', null)->find_all(), 'creators' => $creators), $this->tpl_folder . '/Index');
 }
Exemple #21
0
 public static function generateLink($key, $value = NULL, $fakeLink = NULL)
 {
     $link = $fakeLink ? $fakeLink : Arr::get($_SERVER, 'REQUEST_URI');
     $uri = explode('?', $link);
     $__get = array();
     if (count($uri) > 1) {
         $arr = explode('&', $uri[1]);
         foreach ($arr as $_a) {
             $g = urldecode($_a);
             $g = strip_tags($g);
             $g = stripslashes($g);
             $g = trim($g);
             $___get = explode('=', $g);
             $__get[$___get[0]] = $___get[1];
         }
     }
     if ($value === NULL) {
         if (!isset($__get[$key])) {
             return $link;
         }
         $arr = explode('&', $uri[1]);
         $get = array();
         foreach ($arr as $el) {
             $h = explode('=', $el);
             if ($key != $h[0]) {
                 $get[] = $h[0] . '=' . $h[1];
             }
         }
         $uri[1] = implode('&', $get);
         if ($uri[1]) {
             return $uri[0] . '?' . $uri[1];
         }
         return $uri[0];
     }
     if (!isset($__get[$key])) {
         if (isset($uri[1])) {
             return Arr::get($uri, 0) . '?' . Arr::get($uri, 1) . '&' . $key . '=' . $value;
         }
         return Arr::get($uri, 0) . '?' . $key . '=' . $value;
     }
     if (Arr::get($__get, $key) == $value) {
         return $link;
     }
     $arr = explode('&', $uri[1]);
     $get = array();
     foreach ($arr as $el) {
         $h = explode('=', $el);
         if ($key == $h[0]) {
             $get[] = $key . '=' . $value;
         } else {
             $get[] = $h[0] . '=' . $h[1];
         }
     }
     $uri[1] = implode('&', $get);
     return $uri[0] . '?' . $uri[1];
 }
Exemple #22
0
 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');
 }
Exemple #23
0
 function sendAction()
 {
     $id = (int) Route::param('id');
     $user = Model::getRow($id);
     if (!$user) {
         Message::GetMessage(0, 'Пользователь не существуют!');
         HTTP::redirect('backend/admins/index');
     }
     if ($user->deleted || $user->status == 0) {
         Message::GetMessage(1, 'Пользователь удален или заблокирован!');
         HTTP::redirect('backend/admins/index');
     }
     if (!filter_var($user->email, FILTER_VALIDATE_EMAIL)) {
         Message::GetMessage(1, 'E-Mail пользователя некорректен!');
         HTTP::redirect('backend/admins/index');
     }
     // Generate new password for user and save it to his account
     $password = User::factory()->generate_random_password();
     User::factory()->update_password($user->id, $password);
     // Send E-Mail to user with instructions how recover password
     $mail = Common::factory('mail_templates')->getRow(5);
     if ($mail) {
         $from = array('{{site}}', '{{ip}}', '{{date}}', '{{password}}');
         $to = array(Arr::get($_SERVER, 'HTTP_HOST'), System::getRealIP(), date('d.m.Y H:i'), $password);
         $subject = str_replace($from, $to, $mail->subject);
         $text = str_replace($from, $to, $mail->text);
         Email::send($subject, $text, $user->email);
     }
     Message::GetMessage(1, 'Новый пароль отправлен на E-Mail пользователя!');
     HTTP::redirect('backend/admins/index');
 }
Exemple #24
0
 /**
  *      Delete goods from the cart
  *      @param $catalog_id - goods ID
  */
 public function delete($catalog_id, $size_id)
 {
     if (Arr::get($this->_cart, $catalog_id . '-' . $size_id, false)) {
         unset($this->_cart[$catalog_id . '-' . $size_id]);
         DB::delete('carts_items')->where("catalog_id", "=", $catalog_id)->where("size_id", "=", $size_id)->where("cart_id", "=", $this->_cart_id)->execute();
         $this->recount();
     }
 }
Exemple #25
0
 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');
 }
Exemple #26
0
 public function sidebarBackend($array = array())
 {
     $result = DB::select()->from('menu')->where('status', '=', 1)->order_by('sort')->as_object()->execute();
     $arr = array();
     if (User::god()) {
         foreach ($result as $obj) {
             $arr[$obj->id_parent][] = $obj;
         }
     } else {
         $access = User::access();
         $_arr = array();
         foreach ($result as $obj) {
             $r = explode('/', trim($obj->link, '/'));
             if ($r[0] == 'seo') {
                 array_splice($r, 0, 1);
             }
             if (!$obj->link || Arr::get($access, $r[0], 'no') == 'edit' || Arr::get($access, $r[0]) == 'view' && Arr::get($r, 1) == 'index') {
                 $_arr[$obj->id_parent][] = $obj;
             } else {
                 if (!$obj->link || Arr::get($access, str_replace('seo_', '', $r[0]), 'no') == 'edit' || Arr::get($access, str_replace('seo_', '', $r[0])) == 'view' && Arr::get($r, 1) == 'index') {
                     $_arr[$obj->id_parent][] = $obj;
                 }
             }
         }
         $arr = array();
         foreach ($_arr[0] as $el) {
             if ($el->link || count(Arr::get($_arr, $el->id, array()))) {
                 $arr[0][] = $el;
             }
         }
         foreach ($_arr as $key => $el) {
             if ($key != 0) {
                 $arr[$key] = $el;
             }
         }
     }
     return $this->_data['sidebar'] = View::widget(array('result' => $arr, 'counts' => array()), 'Sidebar');
 }
Exemple #27
0
 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']);
 }
Exemple #28
0
 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');
 }
Exemple #29
0
 function addAction()
 {
     if ($_POST) {
         $post = $_POST['FORM'];
         $post['status'] = Arr::get($_POST, 'status', 0);
         $post['main_show'] = Arr::get($_POST, 'main_show', 0);
         $post['event_date'] = strtotime(Arr::get($_POST['FORM'], 'event_date') . ' ' . Arr::get($_POST['FORM'], 'event_time'));
         $post['place_id'] = Arr::get($post, 'place_id', null);
         if ($post['place_id'] == 'another') {
             $post['place_id'] = 'null';
         } else {
             $post['city_id'] = 'null';
         }
         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();
                 $places = $_POST['PLACES'];
                 // Get list places
                 if (count($places['cost']) > 1) {
                     foreach ($places['cost'] as $key => $cost) {
                         if ($cost == '') {
                             continue;
                         }
                         // insert new price
                         $resPrice = DB::insert('prices', array('afisha_id', 'price', 'color'))->values(array($res[0], $cost, $places['color'][$key]))->execute();
                         // insert all places (seats)
                         if ($resPrice and $places['place'][$key] != '') {
                             $priceId = $resPrice[0];
                             $seatsStr = $places['place'][$key];
                             $seatsArr = json_decode($seatsStr);
                             if (count($seatsArr)) {
                                 foreach ($seatsArr as $seat) {
                                     DB::insert('seats', array('price_id', 'view_key', 'status', 'reserved_at'))->values(array($priceId, $seat->view_key, $seat->status, $seat->reserved_at))->execute();
                                 }
                             }
                         }
                     }
                 }
                 if ($res) {
                     $filename = Files::uploadImage($this->image);
                     if ($filename) {
                         DB::update($this->tablename)->set(array('image' => $filename))->where('id', '=', $res[0])->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');
     $cities = array();
     $citiesObj = DB::select()->from('cities')->find_all();
     foreach ($citiesObj as $key => $city) {
         $cities[$key]['name'] = $city->name;
         $cities[$key]['places'] = DB::select()->from('places')->where('city_id', '=', $city->id)->find_all();
     }
     $this->_content = View::tpl(array('obj' => $result, 'cities' => $cities, 'tpl_folder' => $this->tpl_folder, 'places_list' => DB::select()->from('places')->where('status', '=', 1)->find_all(), 'tablename' => $this->tablename, 'organizers' => DB::select()->from('users')->where('status', '=', 1)->where('role_id', '=', 9)->find_all()), $this->tpl_folder . '/Form');
 }
Exemple #30
0
 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');
 }