예제 #1
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');
 }
예제 #2
0
 public static function getItemPlace($obj, $array = false)
 {
     if ($array !== false) {
         $obj = Arr::to_object($obj);
     }
     if (is_null($obj->place_id)) {
         return $obj->place_name;
     } else {
         return $obj->p_name;
     }
 }
예제 #3
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');
 }
예제 #4
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');
 }
예제 #5
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');
 }
예제 #6
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');
 }
예제 #7
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');
 }
예제 #8
0
 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');
 }
예제 #9
0
 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;
 }
예제 #10
0
 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');
 }
예제 #11
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');
 }
예제 #12
0
 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');
 }
예제 #13
0
 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');
 }
예제 #14
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');
 }
예제 #15
0
 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');
 }
예제 #16
0
 function printTicketAction()
 {
     if (User::get_access_for_controller('afisha_brone') != 'edit') {
         $this->no_access();
     }
     $key = Route::param('key');
     $keys = (array) explode(',', $key);
     if (count($keys) == 0) {
         Message::GetMessage(0, 'Места не выбраны!');
         HTTP::redirect('backend/afisha/index');
     }
     $printType = Route::param('printType') ? Route::param('printType') : 'base';
     $afisha = DB::select('afisha.*', array('places.name', 'place'), 'places.filename', 'places.address', 'places.city_id')->from('afisha')->join('places')->on('afisha.place_id', '=', 'places.id')->where('afisha.id', '=', (int) Route::param('id'))->find();
     if (!$afisha) {
         return Config::error();
     }
     $city = DB::select()->from('cities')->where('id', '=', $afisha->city_id)->find();
     $seatStr = array();
     $termoSeatStr = array();
     try {
         $dom = Map::factory()->loadFile($afisha->filename)->getDomInstance();
         $gTag = $dom->getElementsByTagName('g');
         foreach ($gTag as $el) {
             $id = $el->getAttribute('id');
             if (in_array($id, $keys)) {
                 if ($el->parentNode->hasAttribute('data-plase')) {
                     $originalPlace = $el->parentNode->getAttribute('data-plase');
                 } elseif ($el->parentNode->parentNode->hasAttribute('data-plase')) {
                     $originalPlace = $el->parentNode->parentNode->getAttribute('data-plase');
                 }
                 if ($originalPlace) {
                     $place = $originalPlace;
                     $place = str_replace(array('места', 'Места'), 'место', $place);
                     $place = str_replace('(левая сторона)', '(лев. сторона)', $place);
                     $place = str_replace('(правая сторона)', '(пр. сторона)', $place);
                     $place = str_replace(',', '<br />', $place);
                     $place = str_replace('ряд', 'ряд:', $place);
                     $seatStr[$id] = $place;
                     $dataInit = json_decode($el->getAttribute('data-init'));
                     $seatStr[$id] .= $dataInit->seat;
                     //                          For termo print
                     preg_match('#^(.*)?, ряд ([0-9]+)#', $originalPlace, $matches);
                     $termoSeatStr[$id]['block'] = $matches[1];
                     $termoSeatStr[$id]['block'] = str_replace('(левая сторона)', '(лев. сторона)', $termoSeatStr[$id]['block']);
                     $termoSeatStr[$id]['block'] = str_replace('(правая сторона)', '(пр. сторона)', $termoSeatStr[$id]['block']);
                     $termoSeatStr[$id]['row'] = $matches[2];
                     $termoSeatStr[$id]['seat'] = $dataInit->seat;
                 }
             }
         }
     } catch (\Exception $e) {
         die('Ошибка загрузки карты');
     }
     $tickets = array();
     foreach ($keys as $key) {
         $priceRow = DB::select('price', 'seats.id')->from('prices')->join('seats', 'LEFT')->on('prices.id', '=', 'seats.price_id')->where('afisha_id', '=', $afisha->id)->where('seats.view_key', '=', $key)->find();
         $tickets[] = Arr::to_object(array('event_name' => $afisha->name, 'print_name' => $afisha->print_name, 'print_name_small' => $afisha->print_name_small, 'event_date' => date('j', $afisha->event_date) . ' ' . Dates::month(date('m', $afisha->event_date)) . ' ' . date('Y', $afisha->event_date) . ' в ' . $afisha->event_time, 'event_place' => $afisha->place, 'event_just_date' => date('j', $afisha->event_date) . ' ' . Dates::month(date('m', $afisha->event_date)) . ' ' . date('Y', $afisha->event_date), 'event_time' => $afisha->event_time, 'event_address' => $afisha->address, 'place_string' => $seatStr[$key], 'place_block' => $termoSeatStr[$key]['block'], 'place_row' => $termoSeatStr[$key]['row'], 'place_seat' => $termoSeatStr[$key]['seat'], 'price' => $priceRow->price, 'phone' => $city->phone, 'barcode' => $afisha->id . '-' . $key));
     }
     if ($printType == 'base') {
         echo View::tpl(array('tickets' => $tickets), 'Afisha_orders/Print');
     } else {
         echo View::tpl(array('tickets' => $tickets), 'Afisha_orders/PrintTermo');
     }
     die;
 }
예제 #17
0
 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');
 }