/application/modules/user/controllers/AddinformationController.php
PHP | 422 lines | 403 code | 14 blank | 5 comment | 17 complexity | 833581d8287a39cdc94f3684018b3bf5 MD5 | raw file
- <?php
- require_once 'Reward/Mvc/BaseUserController.php' ;
- require_once 'Reward/Util.php' ;
- require_once 'security/AES.class.php' ;
-
- require_once 'Zend/Json.php' ;
- require_once 'Reward/Mvc/BaseController.php';
- class AddInformationController extends BaseUserController{
-
- public function init(){
- parent::init();
- //$this->_helper->layout()->setLayout('layoutview');
- $this->_helper->layout()->setLayout('layoutclient');
- $bootstrap = $this->getInvokeArg('bootstrap');
- $this->config = $bootstrap->getOptions();
- }
-
-
- public function indexAction(){
- //$this->_helper->layout()->setLayout('layoutfooter');
- if(isset($_GET['HotelID']) && $_GET['HotelID'] != ""){
- $hotelID = $_GET['HotelID'];
- }
- $user = $this->getSessionUser();
- if(!isset($user) && !$this->isAdminLoggedin()){
- $this->_redirect('/login/index');
- }
- $tblEdit = new User_Model_EditInformation();
- $roomtype = $tblEdit->getRoomTypeByHotelID($hotelID);
- $this->view->assign('roomtype',$roomtype);
-
- if($this->isAdminLoggedin() ){
- $admin = $this->getSessionAdmin();
-
-
-
- $hotelID = $_POST['hotelID'];
- $this->view->assign('typeUser','Admin');
- $this->view->assign('urlUser','/admin');
- }else if(isset($user)){
- $this->view->assign('typeUser','Client');
- $this->view->assign('urlUser','/viewbooking/index');
- }
-
- }
-
-
- public function requestAction(){
- $request = $this->getRequest();
- $postData = $request->getPost();
- //**************ko load layout**************
- $this->getHelper('layout')->disableLayout();
- $this->getHelper('viewRenderer')->setNoRender();
- //******************************************
- $request->isPost();
- $tblEdit = new User_Model_EditInformation();
- if($request->getParam('id') != NULL && $request->getParam('id') != 0){
-
- $RoomID = $request->getParam('id');
- $SubRooms = $tblEdit->getSubRoomByRoomID($RoomID);
- if(isset($SubRooms) && $SubRooms != NULL && $SubRooms != ""){
- echo "<table border='1' style='background:#E1F1FD;margin-top:10px;'>
- <tr>
- <th>RoomID</th>
- <th>RoomName</th>
-
- </tr>";
- foreach($SubRooms as $test){
- echo '<tr>
- <td>'.$test['SubRoomID'].'</td>
-
- <td><input type="text" id="SubID_'.$test['SubRoomID'].'" name="SubID_'.$test['SubRoomID'].'" value="'.$test['SubRoomName'].'"></input></td>
- </tr>
-
- ';
- }
- 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>';
- //echo '<tr ><td colspan="2" align="center"><img style="width:" onclick="document.submitform.submit();" src="/images/final/add-button-md.png"/></td></tr>';
- echo '</table>';
-
- }else{
- echo "Data don't have in database";
- }
-
-
- }else{
- echo "Please choose Room Type";
- }
-
-
-
- }
-
-
-
- public function confirmAction(){
- echo '<script>alert(nam)</script>';
- //$this->_helper->layout()->setLayout('layoutfooter');
- $session = new Zend_Session_Namespace(User_Model_Common::STR_NAMESPACE);
- $session_book = new Zend_Session_Namespace(BOOK_NAMESPACE);
- $ReservationCode = '1320204059';
-
- $tblHotDeal = new User_Model_HotDeal();
- $hoteld = $tblHotDeal->getRoomPrice();
- $tblHotel = new User_Model_Hotel();
- $tblRoom = new User_Model_Room();
-
- $session = new Zend_Session_Namespace(IP_NAMESPACE);
-
- //*********************************** Customer Information ***************************************\\
- $tblInfor = new User_Model_Information();
- $information = array();
- if(isset($ReservationCode) && $ReservationCode != NULL){
- $information = $tblInfor->getInformationByReservation($ReservationCode);
- $this->view->assign('infor', $information);
-
- }
- //*************************************************************************************************\\
-
-
- }
-
- public function errorAction(){
- //$this->_helper->layout()->setLayout('layoutsuccess');
- $this->view->error = "";
- if(isset($_GET['error']))
- $this->view->error = $_GET['error'];
- }
-
- public function successAction(){
- $this->_helper->layout()->setLayout('layoutclient');
- $tblEdit = new User_Model_EditInformation();
- $hotelID = $this->getSessionUser();
-
- $tblEdit = new User_Model_EditInformation();
- $subroom = $tblEdit->getAllSubRoom();
-
- foreach($subroom as $sub){
- //nho check null
-
- if(isset($_POST['SubID_'.$sub['SubRoomID']])){
- //echo $_POST['SubID_'.$sub['SubRoomID']];
- $string = 'SubID_'.$sub['SubRoomID'];
- $temp = explode('_', $string);
- $name = $_POST['SubID_'.$sub['SubRoomID']];
- $id = $temp[1];
-
- $tblEdit->updateSubRooms($id,$name);
- }
- }
-
- $user = $this->getSessionUser();
- if($this->isAdminLoggedin() ){
- $admin = $this->getSessionAdmin();
-
-
-
- $hotelID = $_POST['hotelID'];
- $this->view->assign('typeUser','Admin');
- $this->view->assign('urlUser','/admin');
- }else if(isset($user)){
- $this->view->assign('typeUser','Client');
- $this->view->assign('urlUser','/viewbooking/index');
- }
-
-
- //$this->_helper->layout()->setLayout('layoutfooter');\
- /*
- $session = new Zend_Session_Namespace(User_Model_Common::STR_NAMESPACE);
- $session_book = new Zend_Session_Namespace(BOOK_NAMESPACE);
- $this->view->url = $session_book->url;
- if(isset($session->data)){
- $data = $session->data;
- $roomArray = $session->roomArray;
-
- $tbRoom = new User_Model_Room();
- $result_2 = $tbRoom->getRoombyID($data['RoomID']);
-
- $tbHotel = new User_Model_Hotel();
- $result = $tbHotel->getHotelByID($data['HotelID']);
-
- $result_3 = $tbRoom->getAllBed($data['RoomID']);
- $str='';
- foreach($result_3 as $row)
- {
- $str.= $row['BedType'].": ".$row['NumbBed']." | ";
- }
-
- $body = ' <div style="margin-left:20px;float:left;font-weight: bold;font-style: italic;font-size: 14px;">';
- $body .= ' >>THANK YOU for using my service<br/>
- We hope to serve you again in the future';
- $body .= ' </div>';
- $body .= ' <div style="margin-right:20px;float:right;font-weight: bold;font-size: 14px;border: 2px solid black;padding: 10px 10px 10px 10px;">';
- $body .= ' RewardHotel Contact :<br/>
- Tel : +61(2) 9725 6649<br/>
- Email : infor@rewardhotel.com.au';
- $body .= ' </div>';
-
- $body .= ' <div style="text-align: center;font-weight: bold;font-size: 24px;clear:right;">';
- $body .= ' <br/>Booking Confirmation';
- $body .= ' </div>';
- $body .= ' <table border="2" align="center" cellpadding="10">';
- $body .= ' <tr valign="top">';
- $body .= ' <td>
- <div style="text-align: center;font-weight: bold;font-size: 16px;">
- Hotel Information
- </div>
- <div style="font-size:12px;padding-left:20px;padding-right:20px;">
- <b>Property Name : </b>'.$result['PropertyName'].'<br>
- <b>Address : </b>'.$result['PropertyStreetNum'].' '.$result['PropertyStreetName'].' '.$result['PropertyStreetLocality'].' '.$result['PropertyState'].'<br>
- </div>
- </td>';
- $body .= ' <td>
- <div style="text-align: center;font-weight: bold;font-size: 16px;">
- Customer Information
- </div>
- <div style="font-size:12px;padding-left:20px;padding-right:20px;">
- <b>Booking Name : </b>'.$roomArray[0]['FirstName'].' '.$roomArray[0]['LastName'].'<br>
- <b>Contact Phone : </b>'.$data['Phone'].'<br>
- </div>
- </td>';
- $body .= ' </tr>';
- $body .= ' <tr valign="top">';
- $body .= ' <td>
- <div style="text-align: center;font-weight: bold;font-size: 16px;">
- Room Information
- </div>
- <div style="font-size:12px;padding-left:20px;padding-right:20px;">
- <b>No. of Room : </b>'.$data['NumberOfRoom'].'<br>
- <b>Room Type : </b>'.$result_2['roomtype'].'<br>
- </div>
- </td>';
- $body .= ' <td>
- <div style="text-align: center;font-weight: bold;font-size: 16px;">
- Booking Schedule
- </div>
- <div style="font-size:12px;padding-left:20px;padding-right:20px;">';
- for($i=1;$i<=$data['NumberOfRoom'];$i++)
- $body .= ' <b>Room '.$i.' : </b>'.date("d/m/Y",$data['CheckIn']).' to '.date("d/m/Y",$data['CheckOut']).'<br>';
- $body .= ' </div>
- </td>';
- $body .= ' </tr>';
- for($i=1;$i<=$data['NumberOfRoom'];$i++)
- {
- $body .= '<tr>
- <td colspan="2">';
- $body .= ' <u><b>Room '.$i.'</b></u><br>';
- $body .= ' <div style="font-size:12px;padding-left:20px;padding-right:20px;">
- <b>Arrive Approx : </b>'.((int)($roomArray[$i-1]['EstimateCheckin'])/100).' hrs<br>
- <b>Special Request : </b>'.(trim($roomArray[$i-1]['SpecialRequest'])==""?"none":$roomArray[$i-1]['SpecialRequest']).'<br>
- <b>Bed Type : </b>'.$str.'<br>
- <b>Price : </b>$'.round(($data['CostSubTotal']+$data['CostCardFee'])/$data['NumberOfRoom'],1).'<br>
- </div>';
- $body .= ' </td>
- </tr>';
- }
- $body .= ' <tr valign="top" align="right">';
- $body .= ' <td colspan="2">
- <div style="font-size:14px;padding-left:20px;padding-right:20px;color:blue;">
- <b>Total : </b>$'.($data['CostSubTotal']+$data['CostCardFee']).' (GST inclusive)<br>
- </div>
- </td>
- </tr>';
- $body .= ' <tr valign="center">';
- $body .= ' <td colspan="2" style="max-width:90%">
- <div style="font-size:14px;padding-left:20px;padding-right:20px;">
- <b>Terms & Conditions : </b>This term and condition will be different form one hotel to another.<br>
- I will provide more information on this area later.
- </div>
- </td>
- </tr>';
- $body .= ' <tr valign="center">';
- $body .= ' <td colspan="2" style="max-width:80%">
- <div style="font-size:14px;padding-left:20px;padding-right:20px;">
- <b>Cancellation Policy : </b>This policy is also depends on individual hotel.<br>
- I will provide this information later.
- </div>
- </td>
- </tr>';
- $body .= ' </table>';
-
- // send to customer
- $mailinfo = array(
- 'mailTo' => $data['Email'],
- 'nameTo' => $roomArray[0]['FirstName']." ".$roomArray[0]['LastName']
- );
- $mailcontent = array(
- 'subject' => 'Payment Reward',
- 'body' => $body
- );
- User_Model_Common::sendMailtoMember($mailinfo,$mailcontent,$this->config);
-
- // send to client
- $mailinfo = array(
- 'mailTo' => $result['ContactReserEmail'],
- 'nameTo' => $result['ContactReserName']
- );
- $mailcontent = array(
- 'subject' => 'Payment Reward',
- 'body' => str_replace('We hope to serve you again in the future','',$body)
- );
- User_Model_Common::sendMailtoMember($mailinfo,$mailcontent,$this->config);
-
- unset($session->data);
- unset($session->roomArray);
- //unset($session_book->url);
- //print_r($body);
- }*/
- }
-
- /**
- *
- * Function encrypt data
- * @param $number ,$key1, $key2
- */
- private function encryptCreditCard($number, $key1, $key2) {
- $cipher = new AES(AES::AES256);
- $key = sha1($key1).sha1($key2);
- return $cipher->encryptContent($number, $key);
- }
-
- /**
- * Funtion to get list of room price by date
- * @param : $RoomID,$NumberOfRoom,$startDate,$toDate
- */
- Function getListPriceOfRoom($RoomID,$NumberOfRoom,$startDate,$toDate,$roomRate){
- $tblRoom = new User_Model_Room();
-
- $roomInfor = $tblRoom->getInforByDate($RoomID,$startDate);
-
- $list = array();
- for($i = 0; $i < $toDate ; $i++){
- $temp = $startDate + (24*60*60)*$i;
- $check = false;
- $idx = 0;
-
- for($j =0;$j<count($roomInfor);$j++){
- if($roomInfor[$j]['StayDate'] == $temp){
- $check = true;
- $idx = $j;
- break;
- }
-
- }
-
- if($check == true && $roomInfor[$idx]['Active'] == 1){
- if($roomInfor[$idx]['StockRoom'] == 0 && $roomInfor[$idx]['SoldRoom'] >= $NumberOfRoom){
- $list[$i] = array('price' => 'SOLD','stock' => '0');
- }else{
- if($roomInfor[$idx]['Price'] != NULL && $roomInfor[$idx]['Price'] > 0){
- $list[$i] = array('price' => $roomInfor[$idx]['Price'],'stock' => $roomInfor[$idx]['StockRoom']);
- }else{
- $list[$i] = array('price' => $roomRate,'stock' => $roomInfor[$idx]['StockRoom'] );
- }
- }
- }else{
- $list[$i] = array('price' => '0','stock' => '0');
- }
- }
-
- return $list;
- }
-
- /**
- *
- * Function to get list of Date
- * @param $startDate ,$toDate
- */
-
- function getListDate($startDate,$toDate){
- $list = array();
- for($i = 0 ; $i < $toDate ;$i++){
- $temp = $startDate + (24*60*60)*$i;
- $list[$i] = array(
- 'date' => date('D',$temp)." <br />".date('d M',$temp),
- 'time' => mktime(0,0,0,date('m',$temp),date('d',$temp),date('y',$temp))
- );
- }
-
- return $list;
- }
-
- function getNearByHotel($hotelID,$suburb,$time){
- $tblHotel = new User_Model_Hotel();
- $tblRoom = new User_Model_Room();
- $tblCurrency = new User_Model_Currency();
- $listNearBy = array();
-
- $hotel = $tblHotel->getNearByHotel($hotelID,$suburb);
-
- foreach ($hotel as $h){
- $room = $tblRoom->getRoomByHotelID($h['HotelID'],$time);
- $currency = $tblCurrency->getHotelCurrency($h['HotelID']);
- if(count($room)>0){
- if($room['Price'] == -1)
- {
- $t = $tblRoom->getRoombyTypicalPrice($room['RoomID']);
- $price = $t['roomprice'];
- }
- else
- $price = $room['Price'];
- $listNearBy[] = array(
- 'name' => $h['PropertyName'],
- 'rate' => round($h['PropertyStarRating'],1),
- 'suburb'=> $h['PropertySuburb'],
- 'state' => $h['PropertyState'],
- 'price' => $currency['CurrencyText'].''.$price,
- 'link' => "/view/index?hotelID=".$h['HotelID']."&date=".$time
- );
- }
-
- }
- if(count($listNearBy) > 30){
- $t = array_slice($listNearBy,0,30);
- }else{
- $t = $listNearBy;
- }
- return $t;
-
- }
-
- }