PageRenderTime 26ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 1ms

/application/modules/user/controllers/AddinformationController.php

http://rewardvn.googlecode.com/
PHP | 422 lines | 403 code | 14 blank | 5 comment | 17 complexity | 833581d8287a39cdc94f3684018b3bf5 MD5 | raw file
  1. <?php
  2. require_once 'Reward/Mvc/BaseUserController.php' ;
  3. require_once 'Reward/Util.php' ;
  4. require_once 'security/AES.class.php' ;
  5. require_once 'Zend/Json.php' ;
  6. require_once 'Reward/Mvc/BaseController.php';
  7. class AddInformationController extends BaseUserController{
  8. public function init(){
  9. parent::init();
  10. //$this->_helper->layout()->setLayout('layoutview');
  11. $this->_helper->layout()->setLayout('layoutclient');
  12. $bootstrap = $this->getInvokeArg('bootstrap');
  13. $this->config = $bootstrap->getOptions();
  14. }
  15. public function indexAction(){
  16. //$this->_helper->layout()->setLayout('layoutfooter');
  17. if(isset($_GET['HotelID']) && $_GET['HotelID'] != ""){
  18. $hotelID = $_GET['HotelID'];
  19. }
  20. $user = $this->getSessionUser();
  21. if(!isset($user) && !$this->isAdminLoggedin()){
  22. $this->_redirect('/login/index');
  23. }
  24. $tblEdit = new User_Model_EditInformation();
  25. $roomtype = $tblEdit->getRoomTypeByHotelID($hotelID);
  26. $this->view->assign('roomtype',$roomtype);
  27. if($this->isAdminLoggedin() ){
  28. $admin = $this->getSessionAdmin();
  29. $hotelID = $_POST['hotelID'];
  30. $this->view->assign('typeUser','Admin');
  31. $this->view->assign('urlUser','/admin');
  32. }else if(isset($user)){
  33. $this->view->assign('typeUser','Client');
  34. $this->view->assign('urlUser','/viewbooking/index');
  35. }
  36. }
  37. public function requestAction(){
  38. $request = $this->getRequest();
  39. $postData = $request->getPost();
  40. //**************ko load layout**************
  41. $this->getHelper('layout')->disableLayout();
  42. $this->getHelper('viewRenderer')->setNoRender();
  43. //******************************************
  44. $request->isPost();
  45. $tblEdit = new User_Model_EditInformation();
  46. if($request->getParam('id') != NULL && $request->getParam('id') != 0){
  47. $RoomID = $request->getParam('id');
  48. $SubRooms = $tblEdit->getSubRoomByRoomID($RoomID);
  49. if(isset($SubRooms) && $SubRooms != NULL && $SubRooms != ""){
  50. echo "<table border='1' style='background:#E1F1FD;margin-top:10px;'>
  51. <tr>
  52. <th>RoomID</th>
  53. <th>RoomName</th>
  54. </tr>";
  55. foreach($SubRooms as $test){
  56. echo '<tr>
  57. <td>'.$test['SubRoomID'].'</td>
  58. <td><input type="text" id="SubID_'.$test['SubRoomID'].'" name="SubID_'.$test['SubRoomID'].'" value="'.$test['SubRoomName'].'"></input></td>
  59. </tr>
  60. ';
  61. }
  62. echo '<tr ><td align="center"><img onclick="document.submitform.submit();" src="/images/final/button_edit_grey.gif"/></td><td align="center"><img style="width:20px;height:20px;" onclick="add(this.value)" src="/images/final/add_button.png"/></td></tr>';
  63. //echo '<tr ><td colspan="2" align="center"><img style="width:" onclick="document.submitform.submit();" src="/images/final/add-button-md.png"/></td></tr>';
  64. echo '</table>';
  65. }else{
  66. echo "Data don't have in database";
  67. }
  68. }else{
  69. echo "Please choose Room Type";
  70. }
  71. }
  72. public function confirmAction(){
  73. echo '<script>alert(nam)</script>';
  74. //$this->_helper->layout()->setLayout('layoutfooter');
  75. $session = new Zend_Session_Namespace(User_Model_Common::STR_NAMESPACE);
  76. $session_book = new Zend_Session_Namespace(BOOK_NAMESPACE);
  77. $ReservationCode = '1320204059';
  78. $tblHotDeal = new User_Model_HotDeal();
  79. $hoteld = $tblHotDeal->getRoomPrice();
  80. $tblHotel = new User_Model_Hotel();
  81. $tblRoom = new User_Model_Room();
  82. $session = new Zend_Session_Namespace(IP_NAMESPACE);
  83. //*********************************** Customer Information ***************************************\\
  84. $tblInfor = new User_Model_Information();
  85. $information = array();
  86. if(isset($ReservationCode) && $ReservationCode != NULL){
  87. $information = $tblInfor->getInformationByReservation($ReservationCode);
  88. $this->view->assign('infor', $information);
  89. }
  90. //*************************************************************************************************\\
  91. }
  92. public function errorAction(){
  93. //$this->_helper->layout()->setLayout('layoutsuccess');
  94. $this->view->error = "";
  95. if(isset($_GET['error']))
  96. $this->view->error = $_GET['error'];
  97. }
  98. public function successAction(){
  99. $this->_helper->layout()->setLayout('layoutclient');
  100. $tblEdit = new User_Model_EditInformation();
  101. $hotelID = $this->getSessionUser();
  102. $tblEdit = new User_Model_EditInformation();
  103. $subroom = $tblEdit->getAllSubRoom();
  104. foreach($subroom as $sub){
  105. //nho check null
  106. if(isset($_POST['SubID_'.$sub['SubRoomID']])){
  107. //echo $_POST['SubID_'.$sub['SubRoomID']];
  108. $string = 'SubID_'.$sub['SubRoomID'];
  109. $temp = explode('_', $string);
  110. $name = $_POST['SubID_'.$sub['SubRoomID']];
  111. $id = $temp[1];
  112. $tblEdit->updateSubRooms($id,$name);
  113. }
  114. }
  115. $user = $this->getSessionUser();
  116. if($this->isAdminLoggedin() ){
  117. $admin = $this->getSessionAdmin();
  118. $hotelID = $_POST['hotelID'];
  119. $this->view->assign('typeUser','Admin');
  120. $this->view->assign('urlUser','/admin');
  121. }else if(isset($user)){
  122. $this->view->assign('typeUser','Client');
  123. $this->view->assign('urlUser','/viewbooking/index');
  124. }
  125. //$this->_helper->layout()->setLayout('layoutfooter');\
  126. /*
  127. $session = new Zend_Session_Namespace(User_Model_Common::STR_NAMESPACE);
  128. $session_book = new Zend_Session_Namespace(BOOK_NAMESPACE);
  129. $this->view->url = $session_book->url;
  130. if(isset($session->data)){
  131. $data = $session->data;
  132. $roomArray = $session->roomArray;
  133. $tbRoom = new User_Model_Room();
  134. $result_2 = $tbRoom->getRoombyID($data['RoomID']);
  135. $tbHotel = new User_Model_Hotel();
  136. $result = $tbHotel->getHotelByID($data['HotelID']);
  137. $result_3 = $tbRoom->getAllBed($data['RoomID']);
  138. $str='';
  139. foreach($result_3 as $row)
  140. {
  141. $str.= $row['BedType'].": ".$row['NumbBed']." | ";
  142. }
  143. $body = ' <div style="margin-left:20px;float:left;font-weight: bold;font-style: italic;font-size: 14px;">';
  144. $body .= ' &gt;&gt;THANK YOU for using my service<br/>
  145. We hope to serve you again in the future';
  146. $body .= ' </div>';
  147. $body .= ' <div style="margin-right:20px;float:right;font-weight: bold;font-size: 14px;border: 2px solid black;padding: 10px 10px 10px 10px;">';
  148. $body .= ' RewardHotel Contact :<br/>
  149. Tel : +61(2) 9725 6649<br/>
  150. Email : infor@rewardhotel.com.au';
  151. $body .= ' </div>';
  152. $body .= ' <div style="text-align: center;font-weight: bold;font-size: 24px;clear:right;">';
  153. $body .= ' <br/>Booking Confirmation';
  154. $body .= ' </div>';
  155. $body .= ' <table border="2" align="center" cellpadding="10">';
  156. $body .= ' <tr valign="top">';
  157. $body .= ' <td>
  158. <div style="text-align: center;font-weight: bold;font-size: 16px;">
  159. Hotel Information
  160. </div>
  161. <div style="font-size:12px;padding-left:20px;padding-right:20px;">
  162. <b>Property Name : </b>'.$result['PropertyName'].'<br>
  163. <b>Address : </b>'.$result['PropertyStreetNum'].' '.$result['PropertyStreetName'].' '.$result['PropertyStreetLocality'].' '.$result['PropertyState'].'<br>
  164. </div>
  165. </td>';
  166. $body .= ' <td>
  167. <div style="text-align: center;font-weight: bold;font-size: 16px;">
  168. Customer Information
  169. </div>
  170. <div style="font-size:12px;padding-left:20px;padding-right:20px;">
  171. <b>Booking Name : </b>'.$roomArray[0]['FirstName'].' '.$roomArray[0]['LastName'].'<br>
  172. <b>Contact Phone : </b>'.$data['Phone'].'<br>
  173. </div>
  174. </td>';
  175. $body .= ' </tr>';
  176. $body .= ' <tr valign="top">';
  177. $body .= ' <td>
  178. <div style="text-align: center;font-weight: bold;font-size: 16px;">
  179. Room Information
  180. </div>
  181. <div style="font-size:12px;padding-left:20px;padding-right:20px;">
  182. <b>No. of Room : </b>'.$data['NumberOfRoom'].'<br>
  183. <b>Room Type : </b>'.$result_2['roomtype'].'<br>
  184. </div>
  185. </td>';
  186. $body .= ' <td>
  187. <div style="text-align: center;font-weight: bold;font-size: 16px;">
  188. Booking Schedule
  189. </div>
  190. <div style="font-size:12px;padding-left:20px;padding-right:20px;">';
  191. for($i=1;$i<=$data['NumberOfRoom'];$i++)
  192. $body .= ' <b>Room '.$i.' : </b>'.date("d/m/Y",$data['CheckIn']).' to '.date("d/m/Y",$data['CheckOut']).'<br>';
  193. $body .= ' </div>
  194. </td>';
  195. $body .= ' </tr>';
  196. for($i=1;$i<=$data['NumberOfRoom'];$i++)
  197. {
  198. $body .= '<tr>
  199. <td colspan="2">';
  200. $body .= ' <u><b>Room '.$i.'</b></u><br>';
  201. $body .= ' <div style="font-size:12px;padding-left:20px;padding-right:20px;">
  202. <b>Arrive Approx : </b>'.((int)($roomArray[$i-1]['EstimateCheckin'])/100).' hrs<br>
  203. <b>Special Request : </b>'.(trim($roomArray[$i-1]['SpecialRequest'])==""?"none":$roomArray[$i-1]['SpecialRequest']).'<br>
  204. <b>Bed Type : </b>'.$str.'<br>
  205. <b>Price : </b>$'.round(($data['CostSubTotal']+$data['CostCardFee'])/$data['NumberOfRoom'],1).'<br>
  206. </div>';
  207. $body .= ' </td>
  208. </tr>';
  209. }
  210. $body .= ' <tr valign="top" align="right">';
  211. $body .= ' <td colspan="2">
  212. <div style="font-size:14px;padding-left:20px;padding-right:20px;color:blue;">
  213. <b>Total : </b>$'.($data['CostSubTotal']+$data['CostCardFee']).' (GST inclusive)<br>
  214. </div>
  215. </td>
  216. </tr>';
  217. $body .= ' <tr valign="center">';
  218. $body .= ' <td colspan="2" style="max-width:90%">
  219. <div style="font-size:14px;padding-left:20px;padding-right:20px;">
  220. <b>Terms & Conditions : </b>This term and condition will be different form one hotel to another.<br>
  221. I will provide more information on this area later.
  222. </div>
  223. </td>
  224. </tr>';
  225. $body .= ' <tr valign="center">';
  226. $body .= ' <td colspan="2" style="max-width:80%">
  227. <div style="font-size:14px;padding-left:20px;padding-right:20px;">
  228. <b>Cancellation Policy : </b>This policy is also depends on individual hotel.<br>
  229. I will provide this information later.
  230. </div>
  231. </td>
  232. </tr>';
  233. $body .= ' </table>';
  234. // send to customer
  235. $mailinfo = array(
  236. 'mailTo' => $data['Email'],
  237. 'nameTo' => $roomArray[0]['FirstName']." ".$roomArray[0]['LastName']
  238. );
  239. $mailcontent = array(
  240. 'subject' => 'Payment Reward',
  241. 'body' => $body
  242. );
  243. User_Model_Common::sendMailtoMember($mailinfo,$mailcontent,$this->config);
  244. // send to client
  245. $mailinfo = array(
  246. 'mailTo' => $result['ContactReserEmail'],
  247. 'nameTo' => $result['ContactReserName']
  248. );
  249. $mailcontent = array(
  250. 'subject' => 'Payment Reward',
  251. 'body' => str_replace('We hope to serve you again in the future','',$body)
  252. );
  253. User_Model_Common::sendMailtoMember($mailinfo,$mailcontent,$this->config);
  254. unset($session->data);
  255. unset($session->roomArray);
  256. //unset($session_book->url);
  257. //print_r($body);
  258. }*/
  259. }
  260. /**
  261. *
  262. * Function encrypt data
  263. * @param $number ,$key1, $key2
  264. */
  265. private function encryptCreditCard($number, $key1, $key2) {
  266. $cipher = new AES(AES::AES256);
  267. $key = sha1($key1).sha1($key2);
  268. return $cipher->encryptContent($number, $key);
  269. }
  270. /**
  271. * Funtion to get list of room price by date
  272. * @param : $RoomID,$NumberOfRoom,$startDate,$toDate
  273. */
  274. Function getListPriceOfRoom($RoomID,$NumberOfRoom,$startDate,$toDate,$roomRate){
  275. $tblRoom = new User_Model_Room();
  276. $roomInfor = $tblRoom->getInforByDate($RoomID,$startDate);
  277. $list = array();
  278. for($i = 0; $i < $toDate ; $i++){
  279. $temp = $startDate + (24*60*60)*$i;
  280. $check = false;
  281. $idx = 0;
  282. for($j =0;$j<count($roomInfor);$j++){
  283. if($roomInfor[$j]['StayDate'] == $temp){
  284. $check = true;
  285. $idx = $j;
  286. break;
  287. }
  288. }
  289. if($check == true && $roomInfor[$idx]['Active'] == 1){
  290. if($roomInfor[$idx]['StockRoom'] == 0 && $roomInfor[$idx]['SoldRoom'] >= $NumberOfRoom){
  291. $list[$i] = array('price' => 'SOLD','stock' => '0');
  292. }else{
  293. if($roomInfor[$idx]['Price'] != NULL && $roomInfor[$idx]['Price'] > 0){
  294. $list[$i] = array('price' => $roomInfor[$idx]['Price'],'stock' => $roomInfor[$idx]['StockRoom']);
  295. }else{
  296. $list[$i] = array('price' => $roomRate,'stock' => $roomInfor[$idx]['StockRoom'] );
  297. }
  298. }
  299. }else{
  300. $list[$i] = array('price' => '0','stock' => '0');
  301. }
  302. }
  303. return $list;
  304. }
  305. /**
  306. *
  307. * Function to get list of Date
  308. * @param $startDate ,$toDate
  309. */
  310. function getListDate($startDate,$toDate){
  311. $list = array();
  312. for($i = 0 ; $i < $toDate ;$i++){
  313. $temp = $startDate + (24*60*60)*$i;
  314. $list[$i] = array(
  315. 'date' => date('D',$temp)." <br />".date('d M',$temp),
  316. 'time' => mktime(0,0,0,date('m',$temp),date('d',$temp),date('y',$temp))
  317. );
  318. }
  319. return $list;
  320. }
  321. function getNearByHotel($hotelID,$suburb,$time){
  322. $tblHotel = new User_Model_Hotel();
  323. $tblRoom = new User_Model_Room();
  324. $tblCurrency = new User_Model_Currency();
  325. $listNearBy = array();
  326. $hotel = $tblHotel->getNearByHotel($hotelID,$suburb);
  327. foreach ($hotel as $h){
  328. $room = $tblRoom->getRoomByHotelID($h['HotelID'],$time);
  329. $currency = $tblCurrency->getHotelCurrency($h['HotelID']);
  330. if(count($room)>0){
  331. if($room['Price'] == -1)
  332. {
  333. $t = $tblRoom->getRoombyTypicalPrice($room['RoomID']);
  334. $price = $t['roomprice'];
  335. }
  336. else
  337. $price = $room['Price'];
  338. $listNearBy[] = array(
  339. 'name' => $h['PropertyName'],
  340. 'rate' => round($h['PropertyStarRating'],1),
  341. 'suburb'=> $h['PropertySuburb'],
  342. 'state' => $h['PropertyState'],
  343. 'price' => $currency['CurrencyText'].''.$price,
  344. 'link' => "/view/index?hotelID=".$h['HotelID']."&date=".$time
  345. );
  346. }
  347. }
  348. if(count($listNearBy) > 30){
  349. $t = array_slice($listNearBy,0,30);
  350. }else{
  351. $t = $listNearBy;
  352. }
  353. return $t;
  354. }
  355. }