Example #1
0
 public function mapAction()
 {
     // Get afisha post and validate
     $item = Model::getItem(Route::param('alias'));
     if (!$item->id) {
         return Config::error();
     }
     // Seo
     $this->setSeoForItem($item, true);
     $this->setBreadcrumbs('Схема зала');
     // Get seats for available places
     $seats = Model::getMapSeats($item->id);
     // Get prices list
     $prices = Model::getMapPrices($item->id, true);
     try {
         $map = Map::factory();
         $map->loadFile($item->p_filename);
         $map->addPrices($prices);
         $mapTpl = $map->parseDom($seats, true);
     } catch (\Exception $e) {
         if ($item->url != '') {
             header('Location: ' . $item->url);
         } else {
             HTTP::redirect('brone?name=' . $item->name);
         }
         exit;
     }
     $this->_content = View::tpl(array('item' => $item, 'map' => $mapTpl), 'Map/Main');
 }
Example #2
0
 public function getMapAction()
 {
     $post = $_POST;
     // Check data
     $id_place = Arr::get($post, 'id_place');
     $id_afisha = Arr::get($post, 'id_afisha');
     if (!isset($id_place)) {
         die(json_encode(array('success' => false, 'error' => 'Ошибка обработки')));
     }
     $result = DB::select()->from('places')->where('id', '=', $id_place)->find();
     if (!$result) {
         die(json_encode(array('success' => false, 'error' => 'Ошибка выборки места с БД')));
     }
     $seats = \Modules\Afisha\Models\Afisha::getMapSeats($id_afisha);
     // getMap
     try {
         $obj = \Modules\Afisha\Models\Map::factory()->loadFile($result->filename);
         // parse Data
         $map = $obj->parseDom($seats, true, true);
         $mapTpl = View::tpl(array('map' => $map), 'Map/Main');
         die(json_encode(array('success' => true, 'map' => $mapTpl)));
     } catch (\Exception $e) {
         die(json_encode(array('success' => false, 'error' => $e->getMessage(), 'code' => $e->getCode())));
     }
 }
Example #3
0
 function editAction()
 {
     $result = DB::select()->from($this->tablename)->where('id', '=', Route::param('id'))->find();
     //            Set edit access for myself orders
     if ($result->creator_id == User::info()->id) {
         User::factory()->_current_access = 'edit';
     }
     if (User::info()->role_id != 2 and $result->admin_brone == 1) {
         $this->no_access();
     }
     $afisha = DB::select('afisha.*', array('places.name', 'place'), 'places.filename')->from('afisha')->join('places')->on('afisha.place_id', '=', 'places.id')->where('afisha.id', '=', $result->afisha_id)->find();
     // Generate and parse inner map
     $orderSeats = array();
     $viewKeys = array_filter(explode(',', $result->seats_keys));
     if (count($viewKeys)) {
         $prices = DB::select()->from('prices')->where('afisha_id', '=', $result->afisha_id)->find_all();
         if (count($prices)) {
             $pricesIds = array();
             foreach ($prices as $key => $value) {
                 $pricesIds[] = $value->id;
             }
             $seatsQuery = DB::select()->from('seats')->where('view_key', 'IN', $viewKeys)->where('price_id', 'IN', $pricesIds)->execute()->as_array();
             foreach ($seatsQuery as $key => $value) {
                 $orderSeats[$value['view_key']] = $value;
             }
         }
     }
     $seatsStr = array();
     if ($afisha) {
         $seats = \Modules\Afisha\Models\Afisha::getMapSeats($result->afisha_id);
         $mapObj = Map::factory()->loadFile($afisha->filename);
         $innerMap = $mapObj->parseDomOrder($orderSeats, $seats, true, true);
         $seatsArr = array();
         foreach ($seats as $seat) {
             $seatsArr[] = $seat['view_key'];
         }
         try {
             $dom = Map::factory()->loadFile($afisha->filename)->getDomInstance();
             $gTag = $dom->getElementsByTagName('g');
             foreach ($gTag as $el) {
                 $id = $el->getAttribute('id');
                 if (in_array($id, $seatsArr)) {
                     if ($el->parentNode->hasAttribute('data-plase')) {
                         $place = $el->parentNode->getAttribute('data-plase');
                     } elseif ($el->parentNode->parentNode->hasAttribute('data-plase')) {
                         $place = $el->parentNode->parentNode->getAttribute('data-plase');
                     }
                     if ($place) {
                         $place = str_replace('(левая сторона)', '(лев. сторона)', $place);
                         $place = str_replace('(правая сторона)', '(пр. сторона)', $place);
                         $seatsStr[$id] = str_replace(array('места', 'Места'), 'место', $place);
                         $dataInit = json_decode($el->getAttribute('data-init'));
                         $seatsStr[$id] .= $dataInit->seat;
                     }
                 }
             }
         } catch (\Exception $e) {
             die('Ошибка загрузки карты');
         }
     } else {
         $innerMap = '';
         $afisha = Arr::to_object(array());
     }
     $map = View::tpl(array('map' => $innerMap), 'Map/Main');
     $payer = null;
     if ($result->payer_id != 0) {
         $payer = DB::select()->from('users')->where('id', '=', $result->payer_id)->find();
     }
     $this->_seo['h1'] = 'Заказ №' . Route::param('id');
     $this->_seo['title'] = 'Заказ №' . Route::param('id');
     $this->setBreadcrumbs('Заказ №' . Route::param('id'), 'backend/afisha_orders/edit/' . (int) Route::param('id'));
     $this->_content = View::tpl(array('obj' => $result, 'afisha' => $afisha, 'map' => $map, 'pay_statuses' => $this->pay_statuses, 'seat_statuses' => $this->seat_statuses, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename, 'seatsStr' => $seatsStr, 'payer' => $payer), $this->tpl_folder . '/Inner');
 }