/application/modules/hotel/controllers/profile.php
PHP | 659 lines | 479 code | 93 blank | 87 comment | 50 complexity | fcd652bcac44dbf7a3bfc8359b516465 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
- <?php
- if (!defined('BASEPATH'))
- exit('No direct script access allowed');
- class Profile extends Base_Controller
- {
- /**
- * Constructor for profile page
- *
- */
- function __construct()
- {
- parent::__construct('Hotel');
- }
- public function display($id)
- {
- $object = $this -> model -> myGet($id);
- $this -> template -> write('page_header', $object -> title);
- if ($cacheRes = $this -> maintaincache -> getCache('views/hotels/hotel-' . $id . '.txt'))
- {
- $data['markup'] = $cacheRes;
- $this -> template -> write('sheet', $data['markup']);
- }
- else
- {
- $data['object'] = $object;
- //$data['object_children'] = $object->mySubGets($object->id);
- //$data['object_parent'] = $object->myGet($object->parenthotel);
- $data['object_gallerys'] = $this -> model -> gallerys($object);
- $data['object_sliders'] = $this -> model -> sliders($object);
- $d = new Destination($object -> subdestination);
- $data['subDestination'] = $d -> displayLink($d);
- $d = new Destination($object -> majordestination);
- $data['majorDestination'] = $d -> displayLink($d);
- $rt = $this -> load -> view('hotel/profile', $data, true);
- $this -> template -> write('sheet', $rt);
- $this -> maintaincache -> setCache('views/hotels/hotel-' . $id . '.txt', $rt);
- }
- // Render template
- $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
- }
- public function frontend_view($majorslug, $subslug, $hotelslug)
- {
- $this -> setTemplate('viewhotels');
- $hotelModel = new hotel();
- $object = $hotelModel -> myGetBySlug($hotelslug);
- $destinationModel = new Destination();
- $destination_major_object = $destinationModel -> myGetBySlug($majorslug);
- $destination_sub_object = $destinationModel -> myGetBySlug($subslug);
- $this -> template -> write('page_header', $object -> title . ' hotels');
- if (0)//$cacheRes = $this -> maintaincache -> getCache('views/destinations/frontend-destination-' . $object->id . '.txt'))
- {
- echo $cacheRes;
- }
- else
- {
- $data['object'] = $object;
- $data['object_gallerys'] = $hotelModel -> gallerys($object);
- $data['object_sliders'] = $hotelModel -> sliders($object);
- //$data['object_otherhotels'] = $destinationModel -> otherhotels($destination_sub_object, $object->id);
- $data['object_expert'] = $hotelModel -> expert($object);
- $this -> teamleaf -> expertFlashSet($data['object_expert'] -> id);
- $data['object_major_destination'] = $destination_major_object;
- $data['object_sub_destination'] = $destination_sub_object;
- $data['object_otherhotels'] = new Hotel();
- $data['object_otherhotels'] -> where('subdestination', $object -> subdestination);
- $data['object_otherhotels'] -> where('id !=', $object -> id);
- $data['object_otherhotels'] -> limit(12);
- $data['object_otherhotels'] -> get();
- $data['object_sliders_markup'] = $this -> teamleaf -> getCacheView('views/hotels', 'hotel_slider-' . $object -> id, 'hotel', 'frontend_hotelslider', $data);
- //$data['object_hotels_markup'] = $this -> teamleaf -> getCacheView('views/hotels', 'top-hotels-' . $object -> id, 'hotel', 'frontend_tophotels', $data);
- $data['object_minigallery_markup'] = $this -> teamleaf -> getCacheView('views/hotels', 'minigallery-' . $object -> id, 'hotel', 'frontend_minigallery', $data);
- $data['travelexpert'] = $this -> teamleaf -> getCacheView('views/users', 'travelexpertbox-' . $object -> expertID . '-' . $object -> expertID . '-hotel-' . $object -> id, 'user', 'frontend_travelexpert_mini', $data);
- $data['object_otherhotels_markup'] = $this -> teamleaf -> getCacheView('views/hotels', 'otherhotels-' . $object -> id, 'hotel', 'frontend_otherhotels', $data);
- $this -> template -> write_view('content', 'hotel/frontend_view', $data);
- // Save Cache
- $toCache = $this -> template -> render($region = NULL, $buffer = TRUE, $parse = FALSE);
- $this -> maintaincache -> setCache('views/hotelsviews/frontend-hotels-view-' . $object -> id . '.txt', $toCache);
- }
- // Render template
- $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
- }
- public function index()
- {
- $this -> display($username = '');
- }
- public function view()
- {
- $this -> template -> write('page_header', l('_D_MY') . ' ' . l('_D_QUESTIONS'));
- $this -> load -> library('session');
- $this -> load -> helper('url');
- $userid = $this -> session -> userdata('userid');
- $data['assets'] = $this -> model -> getAssets();
- // super chain!
- $this -> template -> write_view('sheet', 'asset/view', $data);
- $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
- }
- /**
- * Creates a User
- *
- */
- public function edit($id)
- {
- $this -> create($id, true);
- }
- public function create($id = null, $edit = false)
- {
- $this -> template -> write('page_header', 'Edit/Create Hotel');
- $formdropdowns = '';
- $createDropDowns = false;
- if ($id)
- {
- $object = new Hotel($id);
- $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms', 'hotel');
- }
- else
- {
- $object = new Hotel();
- $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms', 'hotel');
- }
- if ($this -> input -> post())
- {
- // If posted and form validation passes
- if ($this -> form_validation -> run() == TRUE)
- {
- $data = $this -> input -> post();
- $path = 'hotels/profileimages';
- $this -> teamleaf -> checkpath($path);
- $fileresult = $this -> xml_forms -> uploadfiles(1, $path);
- if ($fileresult['result'])
- {
- $data['profileimage'] = @$fileresult[1]['file_name'];
- }
- //$userid = $this -> session -> userdata('userid');
- $saved = DMZ_Array::from_array($object, $data, null, true);
- // this saves this automatically to the Task Object (e.g. same as $user->save());
- // Save the task
- if ($saved)
- {
- $parentD = new Destination($object -> subdestination);
- $parentD -> save($object);
- $this -> maintaincache -> hotel($object -> id);
- if ($object -> meta_keywords == '')
- {
- redirect(base_url() . 'admin/hotel/autocreate_seo/' . $object -> id);
- }
- else
- {
- redirect(base_url() . 'admin/hotel/display/' . $object -> id);
- }
- }
- else
- {
- $this -> template -> write('validation_errors', 'Failed to save Hotel');
- }
- }
- else
- {
- $createDropDowns = true;
- $this -> template -> write('validation_errors', validation_errors());
- // with some errors!
- }
- }
- else
- {
- $createDropDowns = true;
- }
- if ($createDropDowns)
- {
- // we need any drop downs to be created here
- $destinations = new Destination();
- $formdropdowns['majordestination'] = $destinations -> getMajorOptions($object -> majordestination);
- $formdropdowns['subdestination'] = $destinations -> getSubOptions($object -> subdestination);
- $u = new User();
- $formdropdowns['expertID'] = $u -> getUserOptions($object -> expertID);
- }
- $form = $this -> xml_forms -> createform($formdata['xml'], $object, $formdropdowns, array());
- $this -> template -> write('sheet', $form);
- $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
- }
- public function microsite_general($id = null, $edit = false)
- {
- $this -> template -> write('page_header', 'Edit/Create Hotel');
- $formdropdowns = '';
- $createDropDowns = false;
- if ($id)
- {
- $object = new Hotel($id);
- $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'general');
- }
- else
- {
- $object = new Hotel();
- $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'general');
- }
- if ($this -> input -> post())
- {
- // If posted and form validation passes
- if ($this -> form_validation -> run() == TRUE)
- {
- $data = $this -> input -> post();
-
- //print_r($_FILES);
- $path = 'hotels/'.$id.'/microsite-logo';
- $this -> teamleaf -> checkpath($path);
- $fileresult = $this -> xml_forms -> uploadfiles(1, $path);
- if ($fileresult['result'])
- {
- $data['logoimage'] = @$fileresult[1]['file_name'];
- }
- else {
- //print_r($fileresult);
- //die();
- }
- //$userid = $this -> session -> userdata('userid');
- $saved = DMZ_Array::from_array($object, $data, null, true);
- // this saves this automatically to the Task Object (e.g. same as $user->save());
- // Save the task
- if ($saved)
- {
- redirect(base_url() . 'admin/hotel/display/' . $object -> id);
- }
- else
- {
- $this -> template -> write('validation_errors', 'Failed to save Hotel Microsite - General');
- }
- }
- else
- {
- $createDropDowns = true;
- $this -> template -> write('validation_errors', validation_errors());
- // with some errors!
- }
- }
- else
- {
- $createDropDowns = true;
- }
- if ($createDropDowns)
- {
- // we need any drop downs to be created here
- $destinations = new Destination();
- $formdropdowns['microsite_state'] = $object -> getStateOptions($object -> microsite_state);
- }
- $form = $this -> xml_forms -> createform($formdata['xml'], $object, $formdropdowns, array());
- $this -> template -> write('sheet', $form);
- $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
- }
- public function microsite_dining($id = null, $edit = false)
- {
- $this -> template -> write('page_header', 'Edit/Create Hotel');
- $formdropdowns = '';
- $createDropDowns = false;
- if ($id)
- {
- $object = new Hotel($id);
- $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'dining');
- }
- else
- {
- $object = new Hotel();
- $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'dining');
- }
- if ($this -> input -> post())
- {
- // If posted and form validation passes
- if ($this -> form_validation -> run() == TRUE)
- {
- $data = $this -> input -> post();
-
- $path = 'hotels/'.$id.'/dining';
- $this -> teamleaf -> checkpath($path);
-
- $fileFields = array();
- $fileFields[] = 'microsite_dining_tab1file1';
- $fileFields[] = 'microsite_dining_tab1file2';
- $fileFields[] = 'microsite_dining_tab2file1';
- $fileFields[] = 'microsite_dining_tab2file2';
- $fileFields[] = 'microsite_dining_tab3file1';
- $fileFields[] = 'microsite_dining_tab3file2';
- $fileFields[] = 'microsite_dining_tab4file1';
- $fileFields[] = 'microsite_dining_tab4file2';
-
-
- $fileresult = $this -> xml_forms -> uploadfiles($fileFields, $path);
- if ($fileresult['result'])
- {
- foreach($fileFields as $filee)
- {
- $data[$filee] = @$fileresult[$filee]['file_name'];
- }
-
- }
- else {
- //print_r($fileresult);
- //die();
- }
- //$userid = $this -> session -> userdata('userid');
- $saved = DMZ_Array::from_array($object, $data, null, true);
- // this saves this automatically to the Task Object (e.g. same as $user->save());
- // Save the task
- if ($saved)
- {
- redirect(base_url() . 'admin/hotel/display/' . $object -> id);
- }
- else
- {
- $this -> template -> write('validation_errors', 'Failed to save Hotel Microsite - General');
- }
- }
- else
- {
- $createDropDowns = true;
- $this -> template -> write('validation_errors', validation_errors());
- // with some errors!
- }
- }
- else
- {
- $createDropDowns = true;
- }
- if ($createDropDowns)
- {
- // we need any drop downs to be created here
- $destinations = new Destination();
- $formdropdowns['microsite_state'] = $object -> getStateOptions($object -> microsite_state);
- }
- $form = $this -> xml_forms -> createform($formdata['xml'], $object, $formdropdowns, array());
- $this -> template -> write('sheet', $form);
- $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
- }
- public function microsite_facilities($id = null, $edit = false)
- {
- $this -> template -> write('page_header', 'Edit/Create Hotel');
- $formdropdowns = '';
- $createDropDowns = false;
- if ($id)
- {
- $object = new Hotel($id);
- $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'facilities');
- }
- else
- {
- $object = new Hotel();
- $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'facilities');
- }
- if ($this -> input -> post())
- {
- // If posted and form validation passes
- if ($this -> form_validation -> run() == TRUE)
- {
- $data = $this -> input -> post();
-
- $path = 'hotels/'.$id.'/facilities';
- $this -> teamleaf -> checkpath($path);
-
- /*
- $fileFields = array();
- $fileFields[] = 'microsite_facilities_tab1file1';
- $fileFields[] = 'microsite_facilities_tab1file2';
- $fileFields[] = 'microsite_facilities_tab2file1';
- $fileFields[] = 'microsite_facilities_tab2file2';
- $fileFields[] = 'microsite_facilities_tab3file1';
- $fileFields[] = 'microsite_facilities_tab3file2';
- $fileFields[] = 'microsite_facilities_tab4file1';
- $fileFields[] = 'microsite_facilities_tab4file2';
-
-
- $fileresult = $this -> xml_forms -> uploadfiles($fileFields, $path);
- if ($fileresult['result'])
- {
- foreach($fileFields as $filee)
- {
- $data[$filee] = @$fileresult[$filee]['file_name'];
- }
-
- }
- else {
- //print_r($fileresult);
- //die();
- }
-
- */
- //$userid = $this -> session -> userdata('userid');
- $saved = DMZ_Array::from_array($object, $data, null, true);
- // this saves this automatically to the Task Object (e.g. same as $user->save());
- // Save the task
- if ($saved)
- {
- redirect(base_url() . 'admin/hotel/display/' . $object -> id);
- }
- else
- {
- $this -> template -> write('validation_errors', 'Failed to save Hotel Microsite - General');
- }
- }
- else
- {
- $createDropDowns = true;
- $this -> template -> write('validation_errors', validation_errors());
- // with some errors!
- }
- }
- else
- {
- $createDropDowns = true;
- }
- if ($createDropDowns)
- {
- // we need any drop downs to be created here
- $destinations = new Destination();
- $formdropdowns['microsite_state'] = $object -> getStateOptions($object -> microsite_state);
- }
- $form = $this -> xml_forms -> createform($formdata['xml'], $object, $formdropdowns, array());
- $this -> template -> write('sheet', $form);
- $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
- }
- public function microsite_local($id = null, $edit = false)
- {
- $this -> template -> write('page_header', 'Edit/Create Hotel');
- $formdropdowns = '';
- $createDropDowns = false;
- if ($id)
- {
- $object = new Hotel($id);
- $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'local');
- }
- else
- {
- $object = new Hotel();
- $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'local');
- }
- if ($this -> input -> post())
- {
- // If posted and form validation passes
- if ($this -> form_validation -> run() == TRUE)
- {
- $data = $this -> input -> post();
-
- $path = 'hotels/'.$id.'/local';
- $this -> teamleaf -> checkpath($path);
-
- $fileFields = array();
- $fileFields[] = 'microsite_local_tab1file1';
- $fileFields[] = 'microsite_local_tab1file2';
- $fileFields[] = 'microsite_local_tab2file1';
- $fileFields[] = 'microsite_local_tab2file2';
- $fileFields[] = 'microsite_local_tab3file1';
- $fileFields[] = 'microsite_local_tab3file2';
- $fileFields[] = 'microsite_local_tab4file1';
- $fileFields[] = 'microsite_local_tab4file2';
-
-
- $fileresult = $this -> xml_forms -> uploadfiles($fileFields, $path);
- if ($fileresult['result'])
- {
- foreach($fileFields as $filee)
- {
- $data[$filee] = @$fileresult[$filee]['file_name'];
- }
-
- }
- else {
- //print_r($fileresult);
- //die();
- }
-
- //$userid = $this -> session -> userdata('userid');
- $saved = DMZ_Array::from_array($object, $data, null, true);
- // this saves this automatically to the Task Object (e.g. same as $user->save());
- // Save the task
- if ($saved)
- {
- redirect(base_url() . 'admin/hotel/display/' . $object -> id);
- }
- else
- {
- $this -> template -> write('validation_errors', 'Failed to save Hotel Microsite - General');
- }
- }
- else
- {
- $createDropDowns = true;
- $this -> template -> write('validation_errors', validation_errors());
- // with some errors!
- }
- }
- else
- {
- $createDropDowns = true;
- }
- if ($createDropDowns)
- {
- // we need any drop downs to be created here
- $destinations = new Destination();
- $formdropdowns['microsite_state'] = $object -> getStateOptions($object -> microsite_state);
- }
- $form = $this -> xml_forms -> createform($formdata['xml'], $object, $formdropdowns, array());
- $this -> template -> write('sheet', $form);
- $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
- }
- public function microsite_rooms($id = null, $edit = false)
- {
- $this -> template -> write('page_header', 'Edit/Create Hotel');
- $formdropdowns = '';
- $createDropDowns = false;
- if ($id)
- {
- $object = new Hotel($id);
- $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'rooms');
- }
- else
- {
- $object = new Hotel();
- $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'rooms');
- }
- if ($this -> input -> post())
- {
- // If posted and form validation passes
- if ($this -> form_validation -> run() == TRUE)
- {
- $data = $this -> input -> post();
-
- $path = 'hotels/'.$id.'/rooms';
- $this -> teamleaf -> checkpath($path);
-
- $fileFields = array();
- $fileFields[] = 'microsite_rooms_tab1file1';
- $fileFields[] = 'microsite_rooms_tab1file2';
- $fileFields[] = 'microsite_rooms_tab2file1';
- $fileFields[] = 'microsite_rooms_tab2file2';
- $fileFields[] = 'microsite_rooms_tab3file1';
- $fileFields[] = 'microsite_rooms_tab3file2';
- $fileFields[] = 'microsite_rooms_tab4file1';
- $fileFields[] = 'microsite_rooms_tab4file2';
-
-
- $fileresult = $this -> xml_forms -> uploadfiles($fileFields, $path);
- if ($fileresult['result'])
- {
- foreach($fileFields as $filee)
- {
- $data[$filee] = @$fileresult[$filee]['file_name'];
- }
-
- }
- else {
- print_r($fileresult);
- die();
- }
- //$userid = $this -> session -> userdata('userid');
- $saved = DMZ_Array::from_array($object, $data, null, true);
- // this saves this automatically to the Task Object (e.g. same as $user->save());
- // Save the task
- if ($saved)
- {
- redirect(base_url() . 'admin/hotel/display/' . $object -> id);
- }
- else
- {
- $this -> template -> write('validation_errors', 'Failed to save Hotel Microsite - General');
- }
- }
- else
- {
- $createDropDowns = true;
- $this -> template -> write('validation_errors', validation_errors());
- // with some errors!
- }
- }
- else
- {
- $createDropDowns = true;
- }
- if ($createDropDowns)
- {
- // we need any drop downs to be created here
- $destinations = new Destination();
- $formdropdowns['microsite_state'] = $object -> getStateOptions($object -> microsite_state);
- }
- $form = $this -> xml_forms -> createform($formdata['xml'], $object, $formdropdowns, array());
- $this -> template -> write('sheet', $form);
- $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
- }
- }
- //end class