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'); }
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'); }
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'); }
public function no_access() { $this->_breadcrumbs = HTML::backendBreadcrumbs($this->_breadcrumbs); $data = array(); foreach ($this as $key => $value) { $data[$key] = $value; } $data['_seo']['h1'] = 'Ошибка'; $data['_content'] = \Core\Widgets::get('NoAccess'); ob_start(); extract($data, EXTR_SKIP); include HOST . APPLICATION . '/Views/Main.php'; echo ob_get_clean(); die; }
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'); }
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 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'); }
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 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'); }
function addAction() { if ($_POST) { $post = $_POST['FORM']; $post['status'] = Arr::get($_POST, 'status', 0); $post['password'] = trim(Arr::get($_POST, 'password')); if (Model::valid($post)) { if ($post['password']) { $post['password'] = User::factory()->hash_password($post['password']); } $res = Model::insert(Model::$table, $post)->execute(); if ($res[1]) { 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, 'Не удалось добавить данные!'); } } unset($post['password']); $result = Arr::to_object($post); } else { $result = Model::getRow(Route::param('id')); } $this->_toolbar = Widgets::get('Toolbar/Edit'); $this->_seo['h1'] = 'Редактирование'; $this->_seo['title'] = 'Редактирование'; $this->setBreadcrumbs('Редактирование', 'backend/' . Route::controller() . '/edit/' . Route::param('id')); $this->_content = View::tpl(array('obj' => $result, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/Form'); }
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'); }
function editAction() { if ($_POST) { $post = $_POST['FORM']; $post['status'] = Arr::get($_POST, 'status', 0); $post['see_all_cashier_stat'] = Arr::get($_POST, 'see_all_cashier_stat', 0); if (Model::valid($post)) { $res = Model::update(Model::$table, $post)->where('id', '=', Route::param('id'))->execute(); if ($res) { if (trim(Arr::get($_POST, 'password'))) { User::factory()->update_password(Route::param('id'), Arr::get($_POST, 'password')); } Message::GetMessage(1, 'Вы успешно изменили данные!'); HTTP::redirect('backend/admins/edit/' . Route::param('id')); } else { Message::GetMessage(0, 'Не удалось изменить данные!'); } } $result = Arr::to_object($post); } else { $result = Model::getRow(Route::param('id')); } if (isset($result->deleted) && $result->deleted) { $this->_toolbar = Widgets::get('Toolbar/Edit', array('list_link' => '/backend/archive/admins')); } else { $this->_toolbar = Widgets::get('Toolbar/Edit', array('list_link' => '/backend/admins/index')); } $this->_seo['h1'] = 'Редактирование'; $this->_seo['title'] = 'Редактирование'; $this->setBreadcrumbs('Редактирование', 'backend/admins/edit/' . Route::param('id')); $this->_content = View::tpl(array('obj' => $result, 'tpl_folder' => $this->tpl_folder, 'roles' => $this->aroles), $this->tpl_folder . '/Form'); }
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'); }
function addPositionAction() { $result = array(); if ($_POST) { $post = $_POST; if (!Route::param('id')) { Message::GetMessage(0, 'Нельзя добавить товар несуществующему заказу!'); } else { if (!Arr::get($post, 'catalog_id')) { Message::GetMessage(0, 'Нужно выбрать товар для добавления!'); } else { if (!Arr::get($post, 'count')) { Message::GetMessage(0, 'Укажите количество товара больше 0!'); } else { $item = DB::select('cost')->from('catalog')->where('id', '=', Arr::get($post, 'catalog_id'))->find(); if (!$item) { Message::GetMessage(0, 'Нужно выбрать существующий товар для добавления!'); } else { $data = array('order_id' => (int) Route::param('id'), 'catalog_id' => Arr::get($post, 'catalog_id'), 'size_id' => Arr::get($post, 'size_id'), 'count' => Arr::get($post, 'count'), 'cost' => (int) $item->cost); $res = Common::insert($this->tablename, $post)->execute(); Message::GetMessage(1, 'Позиция добавлена!'); HTTP::redirect('/backend/orders/add_position/' . Route::param('id')); } } } } $result = Arr::to_object($post); } $back_link = '/backend/' . Route::controller() . '/edit/' . (int) Route::param('id'); $this->_toolbar = Widgets::get('Toolbar/Edit', array('list_link' => $back_link)); $this->_seo['h1'] = 'Добавление позиции в заказ №' . Route::param('id'); $this->_seo['title'] = 'Добавление позиции в заказ №' . Route::param('id'); $this->setBreadcrumbs('Заказ №' . (int) Route::param('id'), $back_link); $this->setBreadcrumbs('Добавление позиции в заказ №' . Route::param('id'), 'backend/' . Route::controller() . '/add_position/' . (int) Route::param('id')); $sizes = DB::select('sizes.*')->from('sizes')->join('catalog_tree_sizes')->on('catalog_tree_sizes.size_id', '=', 'sizes.id')->where('catalog_tree_sizes.catalog_tree_id', '=', $result->parent_id)->order_by('sizes.name')->find_all(); $this->_content = View::tpl(array('obj' => $result, 'statuses' => $this->statuses, 'payment' => $this->payment, 'delivery' => $this->delivery, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename, 'tree' => Support::getSelectOptions('Catalog/Select', 'catalog_tree', $result->parent_id), 'sizes' => $sizes), $this->tpl_folder . '/AddPosition'); }
function editAction() { if ($_POST) { $post = $_POST['FORM']; $post['status'] = Arr::get($_POST, 'status', 0); $post['updated_at'] = time(); $arr = explode('/', $post['link']); if ($arr[0] == 'http') { unset($arr[0], $arr[1]); $post['link'] = implode('/', $arr); } $post['link'] = '/' . trim($post['link'], '/'); if (!trim(Arr::get($post, 'name'))) { Message::GetMessage(0, 'Поле "Название" не может быть пустым!'); } else { $res = Common::update($this->tablename, $post)->where('id', '=', Arr::get($_POST, 'id'))->execute(); if ($res) { Message::GetMessage(1, 'Вы успешно изменили данные!'); HTTP::redirect('backend/seo/' . Route::controller() . '/edit/' . Arr::get($_POST, 'id')); } else { Message::GetMessage(0, 'Не удалось изменить данные!'); } } $post['id'] = Arr::get($_POST, 'id'); $result = Arr::to_object($post); } else { $result = DB::select()->from($this->tablename)->where('id', '=', (int) Route::param('id'))->find(); } $this->_toolbar = Widgets::get('Toolbar/Edit', array('list_link' => '/backend/seo/links/index')); $this->_seo['h1'] = 'Редактирование'; $this->_seo['title'] = 'Редактирование'; $this->setBreadcrumbs('Редактирование', 'backend/' . Route::controller() . '/edit/' . Route::param('id')); $this->_content = View::tpl(array('obj' => $result, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename), $this->tpl_folder . '/Form'); }
function addAction() { if ($_POST) { $error = 0; $post = $_POST['FORM']; $post['status'] = Arr::get($_POST, 'status', 0); if (!trim(Arr::get($post, 'name'))) { Message::GetMessage(0, 'Наименование страницы не может быть пустым!'); $error = 1; } if (!trim(Arr::get($post, 'alias'))) { Message::GetMessage(0, 'Алиас не может быть пустым!'); $error = 1; } if (!$error) { $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() . '/' . Route::action()); } else { Message::GetMessage(0, 'Не удалось добавить данные!'); } } $result = Arr::to_object($post); } else { $result = array(); } $this->_toolbar = Widgets::get('Toolbar/Edit'); Config::set('colls', 'column-2'); $this->_seo['h1'] = 'Добавление'; $this->_seo['title'] = 'Добавление'; $this->setBreadcrumbs('Добавление', 'backend/' . Route::controller() . '/' . Route::action()); $this->_content = View::tpl(array('obj' => $result, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename, 'tree' => Support::getSelectOptions('Content/Select', 'content', $result->parent_id)), $this->tpl_folder . '/Form'); }
function before() { parent::before(); $this->_toolbar = Widgets::get('Toolbar/Edit'); Config::set('colls', 'column-2'); }
function addAction() { if ($_POST) { $post = $_POST['FORM']; $post['status'] = Arr::get($_POST, 'status', 0); $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'); }
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'); }
function addAction() { if ($_POST) { $post = $_POST['FORM']; $post['status'] = Arr::get($_POST, 'status', 0); $post['show_image'] = Arr::get($_POST, 'show_image', 0); 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) { $filename = Files::uploadImage('news'); 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'); }