function editAction() { if ($_POST) { $post = $_POST['FORM']; $post['status'] = Arr::get($_POST, 'status', 0); $post['updated_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'), Arr::get($_POST, 'id')); $res = Common::update($this->tablename, $post)->where('id', '=', Arr::get($_POST, 'id'))->execute(); if ($res) { Message::GetMessage(1, 'Вы успешно изменили данные!'); HTTP::redirect('backend/' . 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'); $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 ($_POST) { $post = $_POST['FORM']; $post['status'] = Arr::get($_POST, 'status', 0); if (!filter_var(Arr::get($post, 'email'), FILTER_VALIDATE_EMAIL)) { Message::GetMessage(0, 'Поле "E-Mail" введено некорректно!'); } else { $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/' . 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 ($_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) { $filename = Files::uploadImage($this->image); if ($filename) { DB::update($this->tablename)->set(array('image' => $filename))->where('id', '=', Arr::get($_POST, 'id'))->execute(); } Message::GetMessage(1, 'Вы успешно изменили данные!'); HTTP::redirect('backend/' . 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'); $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 ($_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'); }
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; }
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'); }
function editAction() { 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 (isset($_POST['FORM']['alias'])) { if (!trim(Arr::get($post, 'alias'))) { Message::GetMessage(0, 'Алиас не может быть пустым!'); $error = 1; } $post['alias'] = Common::getUniqueAlias($this->tablename, Arr::get($post, 'alias'), Arr::get($_POST, 'id')); } if (!$error) { $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'))->as_object()->execute()->current(); } $this->_toolbar = Widgets::get('Toolbar/Edit'); Config::set('colls', 'column-2'); $this->_seo['h1'] = 'Редактирование'; $this->_seo['title'] = 'Редактирование'; $this->setBreadcrumbs('Редактирование', 'backend/' . Route::controller() . '/' . Route::action() . '/' . Route::param('id')); $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 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::update('users', $data)->where('id', '=', $user->id)->execute(); Message::GetMessage(1, 'Вы успешно изменили данные!'); HTTP::redirect('backend/' . Route::controller() . '/edit'); } $this->_toolbar = Widgets::get('Toolbar/Edit'); $this->_seo['h1'] = 'Мой профиль'; $this->_seo['title'] = 'Редактирование личных данных'; $this->setBreadcrumbs('Мой профиль', 'backend/' . Route::controller() . '/' . Route::action()); $this->_content = View::tpl(array('obj' => $user), 'Auth/Edit'); }
function editAction() { 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($post['event_date'] . ' ' . $post['event_time']); 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'), Arr::get($_POST, 'id')); $res = Common::update($this->tablename, $post)->where('id', '=', Arr::get($_POST, 'id'))->execute(); $places = $_POST['PLACES']; // Get list places DB::delete('prices')->where('afisha_id', '=', Arr::get($_POST, 'id'))->execute(); 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(Arr::get($_POST, 'id'), $cost, $places['color'][$key]))->execute(); // insert all places (seats) if ($resPrice and $places['place'][$key] != '') { $priceId = $resPrice[0]; DB::delete('seats')->where('price_id', '=', $priceId)->execute(); $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', '=', Arr::get($_POST, 'id'))->execute(); } Message::GetMessage(1, 'Вы успешно изменили данные!'); HTTP::redirect('backend/' . 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'); $this->_seo['h1'] = 'Редактирование'; $this->_seo['title'] = 'Редактирование'; $this->setBreadcrumbs('Редактирование', 'backend/' . Route::controller() . '/edit/' . Route::param('id')); // current city ID $currentCityId = DB::select()->from('places')->where('id', '=', $result->place_id)->as_object()->execute()->current()->city_id; // select places list $allPlaces = DB::select()->from('places')->where('city_id', '=', $currentCityId)->as_object()->execute(); if (count($allPlaces)) { $vPlaces = View::tpl(array('result' => $allPlaces, 'current' => $result->place_id), 'Afisha/SelectPlace'); } $prices = DB::select()->from('prices')->where('afisha_id', '=', (int) Route::param('id'))->as_object()->execute(); $arr = array(); foreach ($prices as $key => $item) { $arr[$item->sector_id]['status'] = $item->status; $arr[$item->sector_id]['price'] = $item->price; } $cities = array(); $citiesObj = DB::select()->from('cities')->find_all(); foreach ($citiesObj as $key => $city) { $cities[$key]['id'] = $city->id; $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, 'currentCityId' => $currentCityId, 'places_list' => DB::select()->from('places')->where('status', '=', 1)->find_all(), 'places' => $vPlaces, 'sectors' => $vSectors, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename, 'organizers' => DB::select()->from('users')->where('status', '=', 1)->where('role_id', '=', 9)->find_all()), $this->tpl_folder . '/Form'); }
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))); }
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'); }
function editAction() { $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); 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'), Arr::get($_POST, 'id')); $res = Common::update($this->tablename, $post)->where('id', '=', Arr::get($_POST, 'id'))->execute(); if ($res) { $filename = Files::uploadImage($this->image); if ($filename) { DB::update($this->tablename)->set(array('image' => $filename))->where('id', '=', Arr::get($_POST, 'id'))->execute(); } DB::delete('catalog_tree_brands')->where('catalog_tree_id', '=', Arr::get($_POST, 'id'))->execute(); foreach ($groupBrands as $brand_id) { DB::insert('catalog_tree_brands', array('catalog_tree_id', 'brand_id'))->values(array(Arr::get($_POST, 'id'), $brand_id))->execute(); } DB::delete('catalog_tree_sizes')->where('catalog_tree_id', '=', Arr::get($_POST, 'id'))->execute(); foreach ($groupSizes as $size_id) { DB::insert('catalog_tree_sizes', array('catalog_tree_id', 'size_id'))->values(array(Arr::get($_POST, 'id'), $size_id))->execute(); } DB::delete('catalog_tree_specifications')->where('catalog_tree_id', '=', Arr::get($_POST, 'id'))->execute(); foreach ($groupSpec as $specification_id) { DB::insert('catalog_tree_specifications', array('catalog_tree_id', 'specification_id'))->values(array(Arr::get($_POST, 'id'), $specification_id))->execute(); } Message::GetMessage(1, 'Вы успешно изменили данные!'); HTTP::redirect('backend/' . 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(); $res = DB::select()->from('catalog_tree_brands')->where('catalog_tree_id', '=', (int) Route::param('id'))->find_all(); foreach ($res as $obj) { $groupBrands[] = $obj->brand_id; } $res = DB::select()->from('catalog_tree_sizes')->where('catalog_tree_id', '=', (int) Route::param('id'))->find_all(); foreach ($res as $obj) { $groupSizes[] = $obj->size_id; } $res = DB::select()->from('catalog_tree_specifications')->where('catalog_tree_id', '=', (int) Route::param('id'))->find_all(); foreach ($res as $obj) { $groupSpec[] = $obj->specification_id; } } $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, 'tree' => Support::getSelectOptions('Groups/Select', 'catalog_tree', $result->parent_id, $result->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 editAction() { $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); $isNew = DB::select('new')->from($this->tablename)->where('id', '=', (int) Route::param('id'))->find(); if (Arr::get($post, 'new') and (!$isNew or !$isNew->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'), Arr::get($_POST, 'id')); $res = Common::update($this->tablename, $post)->where('id', '=', Arr::get($_POST, 'id'))->execute(); if ($res) { DB::delete('catalog_sizes')->where('catalog_id', '=', Arr::get($_POST, 'id'))->execute(); foreach ($itemSizes as $size_id) { DB::insert('catalog_sizes', array('catalog_id', 'size_id'))->values(array(Arr::get($_POST, 'id'), $size_id))->execute(); } DB::delete('catalog_specifications_values')->where('catalog_id', '=', Arr::get($_POST, '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(Arr::get($_POST, 'id'), $specification_value_id, $key))->execute(); } } else { if ($value) { DB::insert('catalog_specifications_values', array('catalog_id', 'specification_value_id', 'specification_id'))->values(array(Arr::get($_POST, 'id'), $value, $key))->execute(); } } } Message::GetMessage(1, 'Вы успешно изменили данные!'); HTTP::redirect('/backend/' . 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(); $res = DB::select()->from('catalog_sizes')->where('catalog_id', '=', (int) Route::param('id'))->find_all(); foreach ($res as $obj) { $itemSizes[] = $obj->size_id; } $res = DB::select('catalog_specifications_values.specification_id', 'specification_value_id', 'specifications.type_id')->from('catalog_specifications_values')->join('specifications')->on('catalog_specifications_values.specification_id', '=', 'specifications.id')->where('catalog_id', '=', (int) Route::param('id'))->find_all(); foreach ($res as $obj) { if ($obj->type_id == 3) { $specArray[$obj->specification_id][] = $obj->specification_value_id; } else { $specArray[$obj->specification_id] = $obj->specification_value_id; } } } $this->_toolbar = Widgets::get('Toolbar/Edit'); $this->_seo['h1'] = 'Редактирование'; $this->_seo['title'] = 'Редактирование'; $this->setBreadcrumbs('Редактирование', 'backend/' . Route::controller() . '/edit/' . (int) Route::param('id')); $images = DB::select()->from('catalog_images')->where('catalog_id', '=', $result->id)->order_by('sort')->find_all(); $show_images = View::tpl(array('images' => $images), $this->tpl_folder . '/UploadedImages'); $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', '=', $result->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', '=', $result->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, 'models' => DB::select()->from('models')->where('brand_id', '=', $result->brand_id)->order_by('name')->find_all(), 'show_images' => $show_images, 'countSimpleOrders' => DB::select(array(DB::expr('id'), 'count'))->from('orders_simple')->where('catalog_id', '=', $result->id)->count_all(), 'countOrders' => DB::select(array(DB::expr('COUNT(orders.id)'), 'count'))->from('orders')->join('orders_items', 'LEFT')->on('orders_items.order_id', '=', 'orders.id')->where('orders_items.catalog_id', '=', $result->id)->count_all(), 'happyCount' => DB::select(array(DB::expr('COUNT(orders_items.id)'), 'count'))->from('orders_items')->join('orders', 'LEFT')->on('orders_items.order_id', '=', 'orders.id')->on('orders.status', '=', DB::expr(1))->where('catalog_id', '=', $result->id)->count_all(), 'happyMoney' => DB::select(array(DB::expr('SUM(orders_items.count * orders_items.cost)'), 'amount'))->from('orders_items')->join('orders', 'LEFT')->on('orders.id', '=', 'orders_items.order_id')->on('orders.status', '=', DB::expr('1'))->where('orders_items.catalog_id', '=', $result->id)->group_by('orders_items.catalog_id')->find()->amount, 'itemSizes' => $itemSizes, 'sizes' => $sizes, 'specifications' => $specifications, 'specValues' => $arr, 'specArray' => $specArray), $this->tpl_folder . '/Form'); }
function printAction() { if (User::get_access_for_controller('afisha_brone') != 'edit') { $this->no_access(); } $seats = (array) $_POST['SEATS']; $printType = $_POST['print-type'] ? $_POST['print-type'] : 'base'; if (count($seats) == 0) { Message::GetMessage(0, 'Места не выбраны!'); HTTP::redirect('backend/afisha_orders/edit/' . Route::param('id')); } $order = DB::select()->from($this->tablename)->where('id', '=', Route::param('id'))->find(); if (!$order) { return Config::error(); } $afisha = DB::select('afisha.*', array('places.name', 'place'), 'places.filename', 'places.address', 'places.city_id')->from('afisha')->join('places')->on('afisha.place_id', '=', 'places.id')->where('afisha.id', '=', $order->afisha_id)->find(); if (!$afisha) { return Config::error(); } $city = DB::select()->from('cities')->where('id', '=', $afisha->city_id)->find(); $seatStr = array(); $termoSeatStr = array(); try { $dom = Map::factory()->loadFile($afisha->filename)->getDomInstance(); $gTag = $dom->getElementsByTagName('g'); foreach ($gTag as $el) { $id = $el->getAttribute('id'); if (in_array($id, $seats)) { if ($el->parentNode->hasAttribute('data-plase')) { $originalPlace = $el->parentNode->getAttribute('data-plase'); } elseif ($el->parentNode->parentNode->hasAttribute('data-plase')) { $originalPlace = $el->parentNode->parentNode->getAttribute('data-plase'); } if ($originalPlace) { $place = str_replace('(левая сторона)', '(лев. сторона)', $originalPlace); $place = str_replace('(правая сторона)', '(пр. сторона)', $place); $place = str_replace(',', '<br />', $place); $place = str_replace('ряд', 'ряд:', $place); $seatStr[$id] = str_replace(array('места', 'Места'), 'место', $place); $dataInit = json_decode($el->getAttribute('data-init')); $seatStr[$id] .= $dataInit->seat; // For termo print preg_match('#^(.*)?, ряд ([0-9]+)#', $originalPlace, $matches); $termoSeatStr[$id]['block'] = $matches[1]; $termoSeatStr[$id]['row'] = $matches[2]; $termoSeatStr[$id]['seat'] = $dataInit->seat; $termoSeatStr[$id]['block'] = str_replace('(левая сторона)', '(лев. сторона)', $termoSeatStr[$id]['block']); $termoSeatStr[$id]['block'] = str_replace('(правая сторона)', '(пр. сторона)', $termoSeatStr[$id]['block']); } } } } catch (\Exception $e) { die('Ошибка загрузки карты'); } $tickets = array(); foreach ($seats as $seat) { if (User::info()->role_id != 2 && User::get_access_for_controller('afisha_print_unlimit') == 'edit' && strpos($order->printed_seats, $seat) !== false) { continue; } $priceRow = DB::select('price')->from('prices')->join('seats', 'LEFT')->on('prices.id', '=', 'seats.price_id')->where('afisha_id', '=', $order->afisha_id)->where('seats.view_key', '=', $seat)->find(); $tickets[] = Arr::to_object(array('event_name' => $afisha->name, 'print_name' => $afisha->print_name, 'print_name_small' => $afisha->print_name_small, 'event_date' => date('d', $afisha->event_date) . ' ' . Dates::month(date('m', $afisha->event_date)) . ' ' . date('Y', $afisha->event_date) . ' в ' . $afisha->event_time, 'event_place' => $afisha->place, 'event_just_date' => date('j', $afisha->event_date) . ' ' . Dates::month(date('m', $afisha->event_date)) . ' ' . date('Y', $afisha->event_date), 'event_time' => $afisha->event_time, 'event_address' => $afisha->address, 'place_string' => $seatStr[$seat], 'place_block' => $termoSeatStr[$seat]['block'], 'place_row' => $termoSeatStr[$seat]['row'], 'place_seat' => $termoSeatStr[$seat]['seat'], 'price' => $priceRow->price, 'phone' => $city->phone, 'barcode' => $afisha->id . '-' . $order->id . '-' . $seat)); } // Update print seats keys if (User::info()->role_id != 2 && User::get_access_for_controller('afisha_print_unlimit') == 'edit') { $oldSeats = $order->printed_seats; $newSeats = array(); if (strlen($oldSeats)) { $oldSeats = explode(',', $oldSeats); if (count($oldSeats)) { $newSeats = (array) $oldSeats; } } foreach ($seats as $seat) { $newSeats[] = $seat; } $newSeats = array_filter(array_unique($newSeats)); $newSeats = implode(',', $newSeats); DB::update($this->tablename)->set(array('printed_seats' => $newSeats))->where('id', '=', $order->id)->execute(); } // Update order status $newOrder = DB::select()->from('afisha_orders')->where('id', '=', $order->id)->find(); $printedAllSeats = true; $printedSeats = array_filter(explode(',', $newOrder->printed_seats)); foreach (array_filter(explode(',', $newOrder->seats_keys)) as $seat) { if (!in_array($seat, $printedSeats)) { $printedAllSeats = false; } } if (User::info()->role_id != 2 && $printedAllSeats) { \Core\Common::update('afisha_orders', array('status' => 'success'))->where('id', '=', (int) $order->id)->execute(); $prices = DB::select('id')->from('prices')->where('afisha_id', '=', $order->afisha_id)->find_all(); $pricesArr = array(); if (count($prices)) { foreach ($prices as $key => $value) { $pricesArr[] = $value->id; } \Core\Common::update('seats', array('status' => 3))->where('view_key', 'IN', array_filter(explode(',', $order->seats_keys)))->where('price_id', 'IN', $pricesArr)->execute(); } } if ($printType == 'base') { echo View::tpl(array('tickets' => $tickets), 'Afisha_orders/Print'); } else { echo View::tpl(array('tickets' => $tickets), 'Afisha_orders/PrintTermo'); } die; }