PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/application/modules/hotel/controllers/profile.php

https://bitbucket.org/matyhaty/senses-designertravelv3
PHP | 659 lines | 479 code | 93 blank | 87 comment | 50 complexity | fcd652bcac44dbf7a3bfc8359b516465 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
  1. <?php
  2. if (!defined('BASEPATH'))
  3. exit('No direct script access allowed');
  4. class Profile extends Base_Controller
  5. {
  6. /**
  7. * Constructor for profile page
  8. *
  9. */
  10. function __construct()
  11. {
  12. parent::__construct('Hotel');
  13. }
  14. public function display($id)
  15. {
  16. $object = $this -> model -> myGet($id);
  17. $this -> template -> write('page_header', $object -> title);
  18. if ($cacheRes = $this -> maintaincache -> getCache('views/hotels/hotel-' . $id . '.txt'))
  19. {
  20. $data['markup'] = $cacheRes;
  21. $this -> template -> write('sheet', $data['markup']);
  22. }
  23. else
  24. {
  25. $data['object'] = $object;
  26. //$data['object_children'] = $object->mySubGets($object->id);
  27. //$data['object_parent'] = $object->myGet($object->parenthotel);
  28. $data['object_gallerys'] = $this -> model -> gallerys($object);
  29. $data['object_sliders'] = $this -> model -> sliders($object);
  30. $d = new Destination($object -> subdestination);
  31. $data['subDestination'] = $d -> displayLink($d);
  32. $d = new Destination($object -> majordestination);
  33. $data['majorDestination'] = $d -> displayLink($d);
  34. $rt = $this -> load -> view('hotel/profile', $data, true);
  35. $this -> template -> write('sheet', $rt);
  36. $this -> maintaincache -> setCache('views/hotels/hotel-' . $id . '.txt', $rt);
  37. }
  38. // Render template
  39. $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
  40. }
  41. public function frontend_view($majorslug, $subslug, $hotelslug)
  42. {
  43. $this -> setTemplate('viewhotels');
  44. $hotelModel = new hotel();
  45. $object = $hotelModel -> myGetBySlug($hotelslug);
  46. $destinationModel = new Destination();
  47. $destination_major_object = $destinationModel -> myGetBySlug($majorslug);
  48. $destination_sub_object = $destinationModel -> myGetBySlug($subslug);
  49. $this -> template -> write('page_header', $object -> title . ' hotels');
  50. if (0)//$cacheRes = $this -> maintaincache -> getCache('views/destinations/frontend-destination-' . $object->id . '.txt'))
  51. {
  52. echo $cacheRes;
  53. }
  54. else
  55. {
  56. $data['object'] = $object;
  57. $data['object_gallerys'] = $hotelModel -> gallerys($object);
  58. $data['object_sliders'] = $hotelModel -> sliders($object);
  59. //$data['object_otherhotels'] = $destinationModel -> otherhotels($destination_sub_object, $object->id);
  60. $data['object_expert'] = $hotelModel -> expert($object);
  61. $this -> teamleaf -> expertFlashSet($data['object_expert'] -> id);
  62. $data['object_major_destination'] = $destination_major_object;
  63. $data['object_sub_destination'] = $destination_sub_object;
  64. $data['object_otherhotels'] = new Hotel();
  65. $data['object_otherhotels'] -> where('subdestination', $object -> subdestination);
  66. $data['object_otherhotels'] -> where('id !=', $object -> id);
  67. $data['object_otherhotels'] -> limit(12);
  68. $data['object_otherhotels'] -> get();
  69. $data['object_sliders_markup'] = $this -> teamleaf -> getCacheView('views/hotels', 'hotel_slider-' . $object -> id, 'hotel', 'frontend_hotelslider', $data);
  70. //$data['object_hotels_markup'] = $this -> teamleaf -> getCacheView('views/hotels', 'top-hotels-' . $object -> id, 'hotel', 'frontend_tophotels', $data);
  71. $data['object_minigallery_markup'] = $this -> teamleaf -> getCacheView('views/hotels', 'minigallery-' . $object -> id, 'hotel', 'frontend_minigallery', $data);
  72. $data['travelexpert'] = $this -> teamleaf -> getCacheView('views/users', 'travelexpertbox-' . $object -> expertID . '-' . $object -> expertID . '-hotel-' . $object -> id, 'user', 'frontend_travelexpert_mini', $data);
  73. $data['object_otherhotels_markup'] = $this -> teamleaf -> getCacheView('views/hotels', 'otherhotels-' . $object -> id, 'hotel', 'frontend_otherhotels', $data);
  74. $this -> template -> write_view('content', 'hotel/frontend_view', $data);
  75. // Save Cache
  76. $toCache = $this -> template -> render($region = NULL, $buffer = TRUE, $parse = FALSE);
  77. $this -> maintaincache -> setCache('views/hotelsviews/frontend-hotels-view-' . $object -> id . '.txt', $toCache);
  78. }
  79. // Render template
  80. $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
  81. }
  82. public function index()
  83. {
  84. $this -> display($username = '');
  85. }
  86. public function view()
  87. {
  88. $this -> template -> write('page_header', l('_D_MY') . ' ' . l('_D_QUESTIONS'));
  89. $this -> load -> library('session');
  90. $this -> load -> helper('url');
  91. $userid = $this -> session -> userdata('userid');
  92. $data['assets'] = $this -> model -> getAssets();
  93. // super chain!
  94. $this -> template -> write_view('sheet', 'asset/view', $data);
  95. $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
  96. }
  97. /**
  98. * Creates a User
  99. *
  100. */
  101. public function edit($id)
  102. {
  103. $this -> create($id, true);
  104. }
  105. public function create($id = null, $edit = false)
  106. {
  107. $this -> template -> write('page_header', 'Edit/Create Hotel');
  108. $formdropdowns = '';
  109. $createDropDowns = false;
  110. if ($id)
  111. {
  112. $object = new Hotel($id);
  113. $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms', 'hotel');
  114. }
  115. else
  116. {
  117. $object = new Hotel();
  118. $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms', 'hotel');
  119. }
  120. if ($this -> input -> post())
  121. {
  122. // If posted and form validation passes
  123. if ($this -> form_validation -> run() == TRUE)
  124. {
  125. $data = $this -> input -> post();
  126. $path = 'hotels/profileimages';
  127. $this -> teamleaf -> checkpath($path);
  128. $fileresult = $this -> xml_forms -> uploadfiles(1, $path);
  129. if ($fileresult['result'])
  130. {
  131. $data['profileimage'] = @$fileresult[1]['file_name'];
  132. }
  133. //$userid = $this -> session -> userdata('userid');
  134. $saved = DMZ_Array::from_array($object, $data, null, true);
  135. // this saves this automatically to the Task Object (e.g. same as $user->save());
  136. // Save the task
  137. if ($saved)
  138. {
  139. $parentD = new Destination($object -> subdestination);
  140. $parentD -> save($object);
  141. $this -> maintaincache -> hotel($object -> id);
  142. if ($object -> meta_keywords == '')
  143. {
  144. redirect(base_url() . 'admin/hotel/autocreate_seo/' . $object -> id);
  145. }
  146. else
  147. {
  148. redirect(base_url() . 'admin/hotel/display/' . $object -> id);
  149. }
  150. }
  151. else
  152. {
  153. $this -> template -> write('validation_errors', 'Failed to save Hotel');
  154. }
  155. }
  156. else
  157. {
  158. $createDropDowns = true;
  159. $this -> template -> write('validation_errors', validation_errors());
  160. // with some errors!
  161. }
  162. }
  163. else
  164. {
  165. $createDropDowns = true;
  166. }
  167. if ($createDropDowns)
  168. {
  169. // we need any drop downs to be created here
  170. $destinations = new Destination();
  171. $formdropdowns['majordestination'] = $destinations -> getMajorOptions($object -> majordestination);
  172. $formdropdowns['subdestination'] = $destinations -> getSubOptions($object -> subdestination);
  173. $u = new User();
  174. $formdropdowns['expertID'] = $u -> getUserOptions($object -> expertID);
  175. }
  176. $form = $this -> xml_forms -> createform($formdata['xml'], $object, $formdropdowns, array());
  177. $this -> template -> write('sheet', $form);
  178. $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
  179. }
  180. public function microsite_general($id = null, $edit = false)
  181. {
  182. $this -> template -> write('page_header', 'Edit/Create Hotel');
  183. $formdropdowns = '';
  184. $createDropDowns = false;
  185. if ($id)
  186. {
  187. $object = new Hotel($id);
  188. $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'general');
  189. }
  190. else
  191. {
  192. $object = new Hotel();
  193. $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'general');
  194. }
  195. if ($this -> input -> post())
  196. {
  197. // If posted and form validation passes
  198. if ($this -> form_validation -> run() == TRUE)
  199. {
  200. $data = $this -> input -> post();
  201. //print_r($_FILES);
  202. $path = 'hotels/'.$id.'/microsite-logo';
  203. $this -> teamleaf -> checkpath($path);
  204. $fileresult = $this -> xml_forms -> uploadfiles(1, $path);
  205. if ($fileresult['result'])
  206. {
  207. $data['logoimage'] = @$fileresult[1]['file_name'];
  208. }
  209. else {
  210. //print_r($fileresult);
  211. //die();
  212. }
  213. //$userid = $this -> session -> userdata('userid');
  214. $saved = DMZ_Array::from_array($object, $data, null, true);
  215. // this saves this automatically to the Task Object (e.g. same as $user->save());
  216. // Save the task
  217. if ($saved)
  218. {
  219. redirect(base_url() . 'admin/hotel/display/' . $object -> id);
  220. }
  221. else
  222. {
  223. $this -> template -> write('validation_errors', 'Failed to save Hotel Microsite - General');
  224. }
  225. }
  226. else
  227. {
  228. $createDropDowns = true;
  229. $this -> template -> write('validation_errors', validation_errors());
  230. // with some errors!
  231. }
  232. }
  233. else
  234. {
  235. $createDropDowns = true;
  236. }
  237. if ($createDropDowns)
  238. {
  239. // we need any drop downs to be created here
  240. $destinations = new Destination();
  241. $formdropdowns['microsite_state'] = $object -> getStateOptions($object -> microsite_state);
  242. }
  243. $form = $this -> xml_forms -> createform($formdata['xml'], $object, $formdropdowns, array());
  244. $this -> template -> write('sheet', $form);
  245. $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
  246. }
  247. public function microsite_dining($id = null, $edit = false)
  248. {
  249. $this -> template -> write('page_header', 'Edit/Create Hotel');
  250. $formdropdowns = '';
  251. $createDropDowns = false;
  252. if ($id)
  253. {
  254. $object = new Hotel($id);
  255. $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'dining');
  256. }
  257. else
  258. {
  259. $object = new Hotel();
  260. $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'dining');
  261. }
  262. if ($this -> input -> post())
  263. {
  264. // If posted and form validation passes
  265. if ($this -> form_validation -> run() == TRUE)
  266. {
  267. $data = $this -> input -> post();
  268. $path = 'hotels/'.$id.'/dining';
  269. $this -> teamleaf -> checkpath($path);
  270. $fileFields = array();
  271. $fileFields[] = 'microsite_dining_tab1file1';
  272. $fileFields[] = 'microsite_dining_tab1file2';
  273. $fileFields[] = 'microsite_dining_tab2file1';
  274. $fileFields[] = 'microsite_dining_tab2file2';
  275. $fileFields[] = 'microsite_dining_tab3file1';
  276. $fileFields[] = 'microsite_dining_tab3file2';
  277. $fileFields[] = 'microsite_dining_tab4file1';
  278. $fileFields[] = 'microsite_dining_tab4file2';
  279. $fileresult = $this -> xml_forms -> uploadfiles($fileFields, $path);
  280. if ($fileresult['result'])
  281. {
  282. foreach($fileFields as $filee)
  283. {
  284. $data[$filee] = @$fileresult[$filee]['file_name'];
  285. }
  286. }
  287. else {
  288. //print_r($fileresult);
  289. //die();
  290. }
  291. //$userid = $this -> session -> userdata('userid');
  292. $saved = DMZ_Array::from_array($object, $data, null, true);
  293. // this saves this automatically to the Task Object (e.g. same as $user->save());
  294. // Save the task
  295. if ($saved)
  296. {
  297. redirect(base_url() . 'admin/hotel/display/' . $object -> id);
  298. }
  299. else
  300. {
  301. $this -> template -> write('validation_errors', 'Failed to save Hotel Microsite - General');
  302. }
  303. }
  304. else
  305. {
  306. $createDropDowns = true;
  307. $this -> template -> write('validation_errors', validation_errors());
  308. // with some errors!
  309. }
  310. }
  311. else
  312. {
  313. $createDropDowns = true;
  314. }
  315. if ($createDropDowns)
  316. {
  317. // we need any drop downs to be created here
  318. $destinations = new Destination();
  319. $formdropdowns['microsite_state'] = $object -> getStateOptions($object -> microsite_state);
  320. }
  321. $form = $this -> xml_forms -> createform($formdata['xml'], $object, $formdropdowns, array());
  322. $this -> template -> write('sheet', $form);
  323. $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
  324. }
  325. public function microsite_facilities($id = null, $edit = false)
  326. {
  327. $this -> template -> write('page_header', 'Edit/Create Hotel');
  328. $formdropdowns = '';
  329. $createDropDowns = false;
  330. if ($id)
  331. {
  332. $object = new Hotel($id);
  333. $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'facilities');
  334. }
  335. else
  336. {
  337. $object = new Hotel();
  338. $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'facilities');
  339. }
  340. if ($this -> input -> post())
  341. {
  342. // If posted and form validation passes
  343. if ($this -> form_validation -> run() == TRUE)
  344. {
  345. $data = $this -> input -> post();
  346. $path = 'hotels/'.$id.'/facilities';
  347. $this -> teamleaf -> checkpath($path);
  348. /*
  349. $fileFields = array();
  350. $fileFields[] = 'microsite_facilities_tab1file1';
  351. $fileFields[] = 'microsite_facilities_tab1file2';
  352. $fileFields[] = 'microsite_facilities_tab2file1';
  353. $fileFields[] = 'microsite_facilities_tab2file2';
  354. $fileFields[] = 'microsite_facilities_tab3file1';
  355. $fileFields[] = 'microsite_facilities_tab3file2';
  356. $fileFields[] = 'microsite_facilities_tab4file1';
  357. $fileFields[] = 'microsite_facilities_tab4file2';
  358. $fileresult = $this -> xml_forms -> uploadfiles($fileFields, $path);
  359. if ($fileresult['result'])
  360. {
  361. foreach($fileFields as $filee)
  362. {
  363. $data[$filee] = @$fileresult[$filee]['file_name'];
  364. }
  365. }
  366. else {
  367. //print_r($fileresult);
  368. //die();
  369. }
  370. */
  371. //$userid = $this -> session -> userdata('userid');
  372. $saved = DMZ_Array::from_array($object, $data, null, true);
  373. // this saves this automatically to the Task Object (e.g. same as $user->save());
  374. // Save the task
  375. if ($saved)
  376. {
  377. redirect(base_url() . 'admin/hotel/display/' . $object -> id);
  378. }
  379. else
  380. {
  381. $this -> template -> write('validation_errors', 'Failed to save Hotel Microsite - General');
  382. }
  383. }
  384. else
  385. {
  386. $createDropDowns = true;
  387. $this -> template -> write('validation_errors', validation_errors());
  388. // with some errors!
  389. }
  390. }
  391. else
  392. {
  393. $createDropDowns = true;
  394. }
  395. if ($createDropDowns)
  396. {
  397. // we need any drop downs to be created here
  398. $destinations = new Destination();
  399. $formdropdowns['microsite_state'] = $object -> getStateOptions($object -> microsite_state);
  400. }
  401. $form = $this -> xml_forms -> createform($formdata['xml'], $object, $formdropdowns, array());
  402. $this -> template -> write('sheet', $form);
  403. $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
  404. }
  405. public function microsite_local($id = null, $edit = false)
  406. {
  407. $this -> template -> write('page_header', 'Edit/Create Hotel');
  408. $formdropdowns = '';
  409. $createDropDowns = false;
  410. if ($id)
  411. {
  412. $object = new Hotel($id);
  413. $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'local');
  414. }
  415. else
  416. {
  417. $object = new Hotel();
  418. $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'local');
  419. }
  420. if ($this -> input -> post())
  421. {
  422. // If posted and form validation passes
  423. if ($this -> form_validation -> run() == TRUE)
  424. {
  425. $data = $this -> input -> post();
  426. $path = 'hotels/'.$id.'/local';
  427. $this -> teamleaf -> checkpath($path);
  428. $fileFields = array();
  429. $fileFields[] = 'microsite_local_tab1file1';
  430. $fileFields[] = 'microsite_local_tab1file2';
  431. $fileFields[] = 'microsite_local_tab2file1';
  432. $fileFields[] = 'microsite_local_tab2file2';
  433. $fileFields[] = 'microsite_local_tab3file1';
  434. $fileFields[] = 'microsite_local_tab3file2';
  435. $fileFields[] = 'microsite_local_tab4file1';
  436. $fileFields[] = 'microsite_local_tab4file2';
  437. $fileresult = $this -> xml_forms -> uploadfiles($fileFields, $path);
  438. if ($fileresult['result'])
  439. {
  440. foreach($fileFields as $filee)
  441. {
  442. $data[$filee] = @$fileresult[$filee]['file_name'];
  443. }
  444. }
  445. else {
  446. //print_r($fileresult);
  447. //die();
  448. }
  449. //$userid = $this -> session -> userdata('userid');
  450. $saved = DMZ_Array::from_array($object, $data, null, true);
  451. // this saves this automatically to the Task Object (e.g. same as $user->save());
  452. // Save the task
  453. if ($saved)
  454. {
  455. redirect(base_url() . 'admin/hotel/display/' . $object -> id);
  456. }
  457. else
  458. {
  459. $this -> template -> write('validation_errors', 'Failed to save Hotel Microsite - General');
  460. }
  461. }
  462. else
  463. {
  464. $createDropDowns = true;
  465. $this -> template -> write('validation_errors', validation_errors());
  466. // with some errors!
  467. }
  468. }
  469. else
  470. {
  471. $createDropDowns = true;
  472. }
  473. if ($createDropDowns)
  474. {
  475. // we need any drop downs to be created here
  476. $destinations = new Destination();
  477. $formdropdowns['microsite_state'] = $object -> getStateOptions($object -> microsite_state);
  478. }
  479. $form = $this -> xml_forms -> createform($formdata['xml'], $object, $formdropdowns, array());
  480. $this -> template -> write('sheet', $form);
  481. $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
  482. }
  483. public function microsite_rooms($id = null, $edit = false)
  484. {
  485. $this -> template -> write('page_header', 'Edit/Create Hotel');
  486. $formdropdowns = '';
  487. $createDropDowns = false;
  488. if ($id)
  489. {
  490. $object = new Hotel($id);
  491. $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'rooms');
  492. }
  493. else
  494. {
  495. $object = new Hotel();
  496. $formdata = $this -> xml_forms -> loadXML(APPPATH . 'modules/hotel/forms/microsite', 'rooms');
  497. }
  498. if ($this -> input -> post())
  499. {
  500. // If posted and form validation passes
  501. if ($this -> form_validation -> run() == TRUE)
  502. {
  503. $data = $this -> input -> post();
  504. $path = 'hotels/'.$id.'/rooms';
  505. $this -> teamleaf -> checkpath($path);
  506. $fileFields = array();
  507. $fileFields[] = 'microsite_rooms_tab1file1';
  508. $fileFields[] = 'microsite_rooms_tab1file2';
  509. $fileFields[] = 'microsite_rooms_tab2file1';
  510. $fileFields[] = 'microsite_rooms_tab2file2';
  511. $fileFields[] = 'microsite_rooms_tab3file1';
  512. $fileFields[] = 'microsite_rooms_tab3file2';
  513. $fileFields[] = 'microsite_rooms_tab4file1';
  514. $fileFields[] = 'microsite_rooms_tab4file2';
  515. $fileresult = $this -> xml_forms -> uploadfiles($fileFields, $path);
  516. if ($fileresult['result'])
  517. {
  518. foreach($fileFields as $filee)
  519. {
  520. $data[$filee] = @$fileresult[$filee]['file_name'];
  521. }
  522. }
  523. else {
  524. print_r($fileresult);
  525. die();
  526. }
  527. //$userid = $this -> session -> userdata('userid');
  528. $saved = DMZ_Array::from_array($object, $data, null, true);
  529. // this saves this automatically to the Task Object (e.g. same as $user->save());
  530. // Save the task
  531. if ($saved)
  532. {
  533. redirect(base_url() . 'admin/hotel/display/' . $object -> id);
  534. }
  535. else
  536. {
  537. $this -> template -> write('validation_errors', 'Failed to save Hotel Microsite - General');
  538. }
  539. }
  540. else
  541. {
  542. $createDropDowns = true;
  543. $this -> template -> write('validation_errors', validation_errors());
  544. // with some errors!
  545. }
  546. }
  547. else
  548. {
  549. $createDropDowns = true;
  550. }
  551. if ($createDropDowns)
  552. {
  553. // we need any drop downs to be created here
  554. $destinations = new Destination();
  555. $formdropdowns['microsite_state'] = $object -> getStateOptions($object -> microsite_state);
  556. }
  557. $form = $this -> xml_forms -> createform($formdata['xml'], $object, $formdropdowns, array());
  558. $this -> template -> write('sheet', $form);
  559. $this -> template -> render($region = NULL, $buffer = FALSE, $parse = FALSE);
  560. }
  561. }
  562. //end class