Advertisement
Guest User

Untitled

a guest
Oct 1st, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.96 KB | None | 0 0
  1. <?php
  2. class HotelReservationsController extends AppController {
  3.  
  4. var $name = 'HotelReservations';
  5. var $paginate = array('HotelReservation' => array('order' => array('HotelReservation.id' => 'asc')));
  6.  
  7. function index() {
  8. $this->HotelReservation->recursive = 0;
  9. $filter = $this->Filter->process($this);
  10. $hotels= $this->paginate(null, $filter);
  11. //debug($hotels);
  12. //die;
  13. $this->set('hotelReservations', $this->paginate(null, $filter));
  14. $customers = $this->HotelReservation->Customer->find('list');
  15. $product = $this->HotelReservation->Product->find('list');
  16. $statusReservations = $this->HotelReservation->StatusReservation->find('list');
  17. $request = $this->HotelReservation->ServiceRequest->find('list');
  18. $this->set(compact('customers','product','statusReservations','request'));
  19. if($this->RequestHandler->isAjax()) {
  20. $this->layout='ajax';
  21. $this->autoRender=false;
  22. $this->viewPath = 'elements'.DS.'hotel_reservations';
  23. $this->render('index_data');
  24. }
  25. }
  26.  
  27. function view($id = null) {
  28. if (!$id) {
  29. $this->Session->setFlash(__('Invalid hotel reservation', true));
  30. $this->redirect(array('action' => 'index'));
  31. }
  32. $this->set('hotelReservation', $this->HotelReservation->read(null, $id));
  33. }
  34.  
  35. function add() {
  36. if (!empty($this->data)) {
  37. $data= $this->Auth->user();
  38. $user_id=$data['User']['id'];
  39. $payterm=$this->HotelReservation->Customer->field('pay_term_id',array('Customer.id'=>$this->data['HotelReservation']['customer_id']));
  40. $currency=$this->HotelReservation->Customer->field('currency_id',array('Customer.id'=>$this->data['HotelReservation']['customer_id']));
  41. $branchName=$this->HotelReservation->User->Branch->field('name',array('id'=>$user_id));
  42.  
  43. $this->data['HotelReservation']['pay_term_id']=$payterm;
  44. $this->data['HotelReservation']['currency_id']=$currency;
  45.  
  46. $basic_price=0; $gross_price=0;
  47. foreach ($this->data['HotelReservationDetail'] as $index) {
  48.  
  49. $gross_price=$gross_price+(float)str_replace(".","",$index['gross_price']);
  50. $basic_price=$basic_price+(float)str_replace(".","",$index['basic_price']);
  51. }
  52. $profit=$gross_price-$basic_price;
  53.  
  54. $this->data['HotelReservation']['profit']=$profit;
  55. $this->data['HotelReservation']['gross_price']=$gross_price;
  56. $this->data['HotelReservation']['basic_price']=$basic_price;
  57.  
  58. $rst_no=$this-> _set_room_number();
  59. $this->data['HotelReservation']['res_no']=$rst_no;
  60. $this->data['HotelReservation']['user_id']=$user_id;
  61. $this->data['HotelReservation']['branch_name']=$branchName;
  62.  
  63. $this->HotelReservation->create();
  64. if ($this->HotelReservation->save($this->data)) {
  65. $hotel_id = $this->HotelReservation->id;
  66. foreach($this->data['HotelReservationDetail'] as $index => $hotelReservationDetail) {
  67. $hotelReservationDetail = array('HotelReservationDetail' =>$hotelReservationDetail);
  68. $hotelReservationDetail['HotelReservationDetail']['hotel_reservation_id'] = $hotel_id;
  69. $gross=(float)str_replace(".","",$hotelReservationDetail['HotelReservationDetail']['gross_price']);
  70. $basic=(float)str_replace(".","",$hotelReservationDetail['HotelReservationDetail']['basic_price']);
  71. $profitdetail=$gross-$basic;
  72. $hotelReservationDetail['HotelReservationDetail']['profit']=$profitdetail;
  73. $hotelReservationDetail['HotelReservationDetail']['gross_price']=$gross;
  74. $hotelReservationDetail['HotelReservationDetail']['basic_price']=$basic;
  75.  
  76. $this->HotelReservation->HotelReservationDetail->create();
  77. //debug($hotelReservationDetail);
  78. //die;
  79. $this->HotelReservation->HotelReservationDetail->set($hotelReservationDetail);
  80. $this->HotelReservation->HotelReservationDetail->save();
  81. }
  82.  
  83. $this->loadModel('Setting');
  84. $rst_lastnumber=Configure::read('__rst_last_number');
  85. $saveNumber=$rst_lastnumber+1;
  86.  
  87. $id = $this->Setting->field('id',array('key'=>'rst_last_number'));
  88. $this->Setting->id=$id;
  89. $this->Setting->updateAll(array('Setting.value'=>$saveNumber),array('key'=>'rst_last_number'));
  90.  
  91. $this->Session->setFlash(__('The hotel reservation has been saved', true));
  92. $this->redirect(array('action' => 'index'));
  93. } else {
  94. $this->Session->setFlash(__('The hotel reservation could not be saved. Please, try again.', true));
  95. }
  96. }
  97.  
  98.  
  99. $statusReservations = $this->HotelReservation->StatusReservation->find('list');
  100. $providers = $this->HotelReservation->Provider->find('list',
  101. array('conditions'=>array(
  102. 'Provider.service_type_id'=>5
  103. )));
  104. $products = $this->HotelReservation->Product->find('list',array('conditions'=>array('Product.')));
  105. $currencies = $this->HotelReservation->Currency->find('list');
  106. $customers = $this->HotelReservation->Customer->find('list');
  107. $serviceRequests = $this->HotelReservation->ServiceRequest->find('list');
  108. $currency = null;
  109. $payterm = null;
  110. $payterm_id = null;
  111. $credit_balance = null;
  112. $curr_rate = null;
  113. $credit_limit = null;
  114. $this->set(compact('statusReservations','providers', 'products', 'currencies','customers','serviceRequests','currency','payterm','payterm_id','credit_balance','curr_rate','credit_limit'));
  115. }
  116.  
  117. function edit($id = null) {
  118. if (!$id && empty($this->data)) {
  119. $this->Session->setFlash(__('Invalid hotel reservation', true));
  120. $this->redirect(array('action' => 'index'));
  121. }
  122. if (!empty($this->data)) {
  123. $gross_price=0;
  124. $basic_price=0;
  125.  
  126. foreach ($this->data['HotelReservationDetail'] as $index) {
  127. $gross_price=$gross_price+(float)str_replace(".","",$index['gross_price']);
  128. $basic_price=$basic_price+(float)str_replace(".","",$index['basic_price']);
  129. }
  130. $profit=$gross_price-$basic_price;
  131. $payterm=$this->HotelReservation->Customer->field('pay_term_id',array('Customer.id'=>$this->data['HotelReservation']['customer_id']));
  132. $this->data['HotelReservation']['pay_term_id']=$payterm;
  133. if ($this->HotelReservation->save($this->data)) {
  134. $this->HotelReservation->HotelReservationDetail->deleteAll(array('HotelReservationDetail.hotel_reservation_id' => $id));
  135. $hotel_id=$this->HotelReservation->id;
  136. foreach($this->data['HotelReservationDetail'] as $index => $hotelReservationDetail){
  137. $hotelReservationDetail = array('HotelReservationDetail' =>$hotelReservationDetail);
  138. $hotelReservationDetail['HotelReservationDetail']['hotel_reservation_id'] = $hotel_id;
  139. $gross=(float)str_replace(".","",$hotelReservationDetail['HotelReservationDetail']['gross_price']);
  140. $basic=(float)str_replace(".","",$hotelReservationDetail['HotelReservationDetail']['basic_price']);
  141. $profit=$gross-$basic;
  142. $hotelReservationDetail['HotelReservationDetail']['profit'] = $profit;
  143. $hotelReservationDetail['HotelReservationDetail']['gross_price']=$gross;
  144. $hotelReservationDetail['HotelReservationDetail']['basic_price']=$basic;
  145.  
  146. $this->HotelReservation->HotelReservationDetail->create();
  147. $this->HotelReservation->HotelReservationDetail->set($hotelReservationDetail);
  148. $this->HotelReservation->HotelReservationDetail->save();
  149. }
  150. $this->Session->setFlash(__('The hotel reservation has been saved', true));
  151. $this->redirect(array('action' => 'index'));
  152. } else {
  153. $this->Session->setFlash(__('The hotel reservation could not be saved. Please, try again.', true));
  154. }
  155. }
  156. if (empty($this->data)) {
  157. $this->data = $this->HotelReservation->read(null, $id);
  158. $statusReservations = $this->HotelReservation->StatusReservation->find('list');
  159. $products = $this->HotelReservation->Product->find('list');
  160. $customers = $this->HotelReservation->Customer->find('list');
  161. $customer_id = $this->data['HotelReservation']['customer_id'];
  162. $currency_id = $this->data['HotelReservation']['currency_id'];
  163. $payterm_id = $this->data['HotelReservation']['pay_term_id'];
  164. $curr_rate=$this->data['HotelReservation']['rate'];
  165. $credit_balance = $this->HotelReservation->Customer->field('balance',array('Customer.id'=>$customer_id));
  166. //$hotelReservationDetails = $this->HotelReservation->HotelReservationDetail->find('list');
  167. $providers = $this->HotelReservation->Provider->find('list',
  168. array('conditions'=>array(
  169. 'Provider.service_type_id'=>1,
  170. 'Provider.service_type_id'=>2,
  171.  
  172. )));
  173. $currency=$this->HotelReservation->Currency->field('code',array('Currency.id'=>$currency_id));
  174. $payterm=$this->HotelReservation->Customer->PayTerm->field('name',array('PayTerm.id'=>$payterm_id));
  175. $serviceRequests = $this->HotelReservation->ServiceRequest->find('list');
  176. $currency_name = $this->HotelReservation->Currency->field('code',array('Currency.id'=>$currency_id));
  177. $payterm_name = $this->HotelReservation->PayTerm->field('name',array('PayTerm.id'=>$payterm_id));
  178. $credit_limit = $this->HotelReservation->Customer->field('credit_limit',array('id'=>$customer_id));
  179. $this->set(compact('statusReservations', 'products', 'customers','
  180. serviceRequests','currency','currency_name','payterm_name','credit_limit','payterm','payterm_id','curr_rate','credit_balance','providers'));
  181.  
  182. }
  183. }
  184.  
  185. function insert_hoteldetail() {
  186.  
  187. //debug($this->data);
  188.  
  189. if (!empty($this->data)) {
  190. $this->loadModel('HotelReservationDetail');
  191. $this->data['HotelReservationDetail']['id']= $this->data['HotelReservation']['id'];
  192. $this->data['HotelReservationDetail']['hotel_reservation_id']= $this->data['HotelReservation']['hotel_reservation_id'];
  193. $this->data['HotelReservationDetail']['guest_name']= $this->data['HotelReservation']['guest_name'];
  194. $this->data['HotelReservationDetail']['room_number']= $this->data['HotelReservation']['room_number'];
  195. $this->data['HotelReservationDetail']['room_type']= $this->data['HotelReservation']['room_type'];
  196. $this->data['HotelReservationDetail']['check_in_date']= $this->data['HotelReservation']['check_in_date'];
  197. $this->data['HotelReservationDetail']['check_out_date']= $this->data['HotelReservation']['check_out_date'];
  198. $this->data['HotelReservationDetail']['gross_price']= $this->data['HotelReservation']['publish_fare'];
  199. $this->data['HotelReservationDetail']['basic_price']= $this->data['HotelReservation']['net_fare'];
  200.  
  201. $this->HotelReservationDetail->save($this->data);
  202.  
  203. }
  204.  
  205. if($this->RequestHandler->isAjax()) {
  206. $this->autoRender=false;
  207. $this->layout='ajax';
  208.  
  209. $this->render('edit');
  210. }
  211. }
  212.  
  213. function delete($id = null) {
  214. if (!$id) {
  215. $this->Session->setFlash(__('Invalid id for hotel reservation', true));
  216. $this->redirect(array('action'=>'index'));
  217. }
  218. if ($this->HotelReservation->delete($id)) {
  219. $this->Session->setFlash(__('Hotel reservation deleted', true));
  220. $this->redirect(array('action'=>'index'));
  221. }
  222. $this->Session->setFlash(__('Hotel reservation was not deleted', true));
  223. $this->redirect(array('action' => 'index'));
  224. }
  225.  
  226. function _set_room_number() {
  227.  
  228. $imonthNow=(idate("m"));
  229. $iyearNow = (idate("Y"));
  230. $appMonth=Configure::read('__month_period');
  231. $appYear=Configure::read('__year_period');
  232. $rst_prefix=Configure::read('__rst_prefix');
  233.  
  234. if (strlen($appMonth) == 1) {
  235. $month_number = "0" . $appMonth ;
  236. }else{
  237. $month_number = $appMonth ;
  238. }
  239.  
  240. $year_number=substr(Configure::read('__year_period'),2,2);
  241. $rst_lastnumber=Configure::read('__rst_last_number');
  242.  
  243. if ($imonthNow == $appMonth) {
  244. $rst_number = $rst_lastnumber + 1 ;
  245. }else{
  246. $rst_number=1;
  247. }
  248.  
  249.  
  250.  
  251. if (strlen($rst_number) == 1)
  252. $str_number=$rst_prefix."-".$year_number. $month_number ."-000" . $rst_number;
  253. elseif (strlen($rst_number) == 2)
  254. $str_number=$rst_prefix."-".$year_number. $month_number ."-00" . $rst_number;
  255. elseif (strlen($rst_number) == 3)
  256. $str_number=$rst_prefix."-".$year_number. $month_number ."-0" . $rst_number;
  257. else
  258. $str_number=$rst_prefix."-".$year_number. $month_number ."-" . $rst_number;
  259.  
  260.  
  261. return $str_number;
  262.  
  263.  
  264.  
  265. }
  266.  
  267. function promote_invoice() {
  268.  
  269. $tot_basic_price=0;
  270. $tot_gross_price=0;
  271. $arr_id=$_POST['rec_ids'];
  272. $i=0;
  273. $inv_no=$this-> _get_invoice_number();
  274. foreach ($arr_id as $id) {
  275.  
  276. $hotel=$this->HotelReservation->read(null,$id);
  277.  
  278. /*---------------Get Customer Invo------------------------'*/
  279. $rsv_date=$hotel['HotelReservation']['issued_date'];
  280. $cust_id=$hotel['HotelReservation']['customer_id'];
  281. $currency=$hotel['HotelReservation']['currency_id'];
  282. $payterm=$hotel['Customer']['pay_term_id'];
  283. //$branch=$hotel['HotelReservation']['branch_name'];
  284. $user=$hotel['HotelReservation']['user_id'];
  285. $point=$this->HotelReservation->field('point',array('HotelReservation.id'=>$id));
  286. $real_amount= (int)$hotel['HotelReservation']['basic_price']; //Net to Agent
  287. $amount=(int)$hotel['HotelReservation']['gross_price']; //publish fare
  288. $reservation_no=$hotel['HotelReservation']['res_no'];
  289. $tot_basic_price=$tot_basic_price+(int)$real_amount;
  290. $tot_gross_price=$tot_gross_price+(int)$amount;
  291. $tot_profit=$tot_gross_price-$tot_basic_price;
  292. $current_rate=$this->HotelReservation->Currency->field('current_rate',array('id'=>$currency));
  293. }
  294. //debug($amount);
  295. // debug($real_amount);
  296. // debug($tot_net_fare);
  297. // debug($tot_publish_fare);
  298. // debug($tot_profit);
  299. // die;
  300.  
  301. $data= $this->Auth->user();
  302. $user_id=$data['User']['id'];
  303. $branchName=$this->HotelReservation->User->Branch->field('name',array('id'=>$user_id));
  304.  
  305. $this->loadModel('Product');
  306. $this->loadModel('Invoice');
  307.  
  308. $this->data['Invoice']['inv_no']= $inv_no;
  309. $this->data['Invoice']['inv_date']= $rsv_date;
  310. $this->data['Invoice']['customer_id']=$cust_id;
  311. $this->data['Invoice']['currency_id']=$currency;
  312. $this->data['Invoice']['pay_term_id']=$payterm;
  313. //$this->data['Invoice']['branch_name']=$branch;
  314. $this->data['Invoice']['amount']=$tot_gross_price;
  315. $this->data['Invoice']['balance_due']=$tot_gross_price;
  316. $this->data['Invoice']['real_amount']=$tot_basic_price;
  317. $this->data['Invoice']['profit']= $tot_profit;
  318. $this->data['Invoice']['user_id']=$user;
  319. $this->data['Invoice']['current_rate']= $current_rate;
  320. $this->data['Invoice']['branch_name']= $branchName;
  321. $this->data['Invoice']['reservation_no']= $reservation_no;
  322. $this->data['Invoice']['point']=$point;
  323. $this->Invoice->save($this->data);
  324.  
  325.  
  326. $arr_id=$_POST['rec_ids'];
  327. foreach ($arr_id as $id) {
  328.  
  329. $hotel=$this->HotelReservation->read(null,$id);
  330. $book_no=$hotel['HotelReservation']['book_no'];
  331. $profit=$amount-$real_amount;
  332. if ($hotel)
  333. $product_id=$hotel['HotelReservation']['product_id'];
  334. $filters=array('HotelReservationDetail.hotel_reservation_id'=>$id);
  335. $hotelDetails=$this->HotelReservation->HotelReservationDetail->find('all',array(
  336. 'fields'=>array(
  337. 'HotelReservationDetail.guest_name',
  338. 'HotelReservationDetail.room_number',
  339. 'HotelReservationDetail.room_type',
  340. 'HotelReservationDetail.check_in_date',
  341. 'HotelReservationDetail.check_out_date',
  342. 'HotelReservationDetail.time_limit',
  343. 'HotelReservationDetail.gross_price',
  344. 'HotelReservationDetail.basic_price',
  345. 'HotelReservationDetail.profit',
  346. ),
  347. 'conditions'=>$filters
  348.  
  349. ));
  350.  
  351.  
  352.  
  353. //-------------inv detail-----------------//
  354. $pass="";
  355. $real_prices=0;
  356. $prices=0;
  357.  
  358.  
  359. $inv_id=$this->Invoice->id;
  360. //debug($ticketDetails);
  361. foreach ($hotelDetails as $hotelDetail) {
  362.  
  363. $room_number=$hotelDetail['HotelReservationDetail']['room_number'];
  364. $guest=$hotelDetail['HotelReservationDetail']['guest_name'];
  365.  
  366. $i++;
  367. //$pass .=$passanger;
  368. $real_prices= $hotelDetail['HotelReservationDetail']['basic_price'];
  369. $prices=$hotelDetail['HotelReservationDetail']['gross_price'];
  370. $profit=$hotelDetail['HotelReservationDetail']['profit'];
  371. $room_type=$hotelDetail['HotelReservationDetail']['room_type'];
  372. $description=' Room#:'.$room_number."/".$book_no . " ".$product_id .$room_type."/".$guest;
  373.  
  374. $data=array('item_no'=>$i,'invoice_id'=>$inv_id,'product_id'=>$product_id);
  375.  
  376. $isdeposite=$this->Product->field('isdeposite',array('id'=>$product_id));
  377. // debug($product_id);
  378. // debug($data);
  379. $this->loadModel('InvoiceDetail');
  380. $this->InvoiceDetail->create();
  381. $this->data['InvoiceDetail']['item_no']= $i;
  382. $this->data['InvoiceDetail']['invoice_id']= $inv_id;
  383. $this->data['InvoiceDetail']['product_id']=$product_id;
  384. $this->data['InvoiceDetail']['description']=$description;
  385. $this->data['InvoiceDetail']['price']=$prices;
  386. $this->data['InvoiceDetail']['real_price']=$real_prices;
  387. $this->data['InvoiceDetail']['profit']= $profit;
  388. $this->data['InvoiceDetail']['deposite']= $isdeposite;
  389. $this->InvoiceDetail->save($this->data);
  390.  
  391.  
  392. }
  393.  
  394.  
  395. $this->HotelReservation->updateAll(
  396. array('status_reservation_id'=>3),
  397. array('HotelReservation.id' => $id)
  398. );
  399. }
  400.  
  401.  
  402. $this->set('hotelReservations', $this->paginate());
  403. $customers = $this->HotelReservation->Customer->find('list');
  404. $filters=array('conditions'=>array('HotelReservation.status_reservation_id'=>3));
  405. $date_issues = $this->HotelReservation->find('list',
  406. array('fields'=>array('res_date'),$filters));
  407. $statusReservations = $this->HotelReservation->StatusReservation->find('list');
  408.  
  409. $this->set(compact('customers','statusReservations','date_issues'));
  410. $this->Session->delete('customer_id');
  411. $this->Session->delete('status_reservation_id');
  412.  
  413. if($this->RequestHandler->isAjax()) {
  414. $this->layout='ajax';
  415. $this->autoRender=false;
  416. $this->viewPath = 'elements'.DS.'hotel_reservations';
  417. $this->render('index_data');
  418. }
  419.  
  420. }
  421.  
  422. function _get_invoice_number() {
  423. $imonthNow=(idate("m"));
  424. $iyearNow = (idate("Y"));
  425. $appMonth=Configure::read('__month_period');
  426. $appYear=Configure::read('__year_period');
  427. $inv_prefix=Configure::read('__inv_prefix');
  428.  
  429.  
  430. if (strlen($appMonth) == 1) {
  431. $month_number = "0" . $appMonth ;
  432. }else{
  433. $month_number = $appMonth ;
  434. }
  435.  
  436. $year_number=substr(Configure::read('__year_period'),2,2);
  437. $inv_lastnumber=Configure::read('__inv_last_number');
  438.  
  439. if ($imonthNow == $appMonth) {
  440. $inv_number = $inv_lastnumber + 1 ;
  441. }else{
  442. $inv_number=1;
  443. }
  444.  
  445.  
  446.  
  447. if (strlen($inv_number) == 1)
  448. $str_number=$inv_prefix."-".$year_number. $month_number ."-000" . $inv_number;
  449. elseif (strlen($inv_number) == 2)
  450. $str_number=$inv_prefix."-".$year_number. $month_number ."-00" . $inv_number;
  451. elseif (strlen($inv_number) == 3)
  452. $str_number=$inv_prefix."-".$year_number. $month_number ."-0" . $inv_number;
  453. else
  454. $str_number=$inv_prefix."-".$year_number. $month_number ."-" . $inv_number;
  455.  
  456.  
  457. $saveNumber= $inv_number;
  458. $criteria="Update ota_settings set value=" . $saveNumber . " Where key='inv_last_number'" ;
  459. $this->loadModel('Setting');
  460. $this->Setting->query($criteria);
  461.  
  462. return $str_number;
  463.  
  464. }
  465.  
  466. function _set_reservation_number() {
  467.  
  468. $imonthNow=(idate("m"));
  469. $iyearNow = (idate("Y"));
  470. $appMonth=Configure::read('__month_period');
  471. $appYear=Configure::read('__year_period');
  472. $rst_prefix=Configure::read('__rst_prefix');
  473.  
  474. if (strlen($appMonth) == 1) {
  475. $month_number = "0" . $appMonth ;
  476. }else{
  477. $month_number = $appMonth ;
  478. }
  479.  
  480. $year_number=substr(Configure::read('__year_period'),2,2);
  481. $rst_lastnumber=Configure::read('__rst_last_number');
  482.  
  483. if ($imonthNow == $appMonth) {
  484. $rst_number = $rst_lastnumber + 1 ;
  485. }else{
  486. $rst_number=1;
  487. }
  488.  
  489.  
  490.  
  491. if (strlen($rst_number) == 1)
  492. $str_number=$rst_prefix."-".$year_number. $month_number ."-000" . $rst_number;
  493. elseif (strlen($rst_number) == 2)
  494. $str_number=$rst_prefix."-".$year_number. $month_number ."-00" . $rst_number;
  495. elseif (strlen($rst_number) == 3)
  496. $str_number=$rst_prefix."-".$year_number. $month_number ."-0" . $rst_number;
  497. else
  498. $str_number=$rst_prefix."-".$year_number. $month_number ."-" . $rst_number;
  499.  
  500.  
  501. return $str_number;
  502.  
  503.  
  504.  
  505. }
  506.  
  507.  
  508. function update_product() {
  509.  
  510.  
  511. if($this->RequestHandler->isAjax()) {
  512. $this->layout='ajax';
  513. $this->autoRender=false;
  514. $this->viewPath = 'elements'.DS.'ticket_reservations';
  515. $this->render('index_data');
  516. }
  517. }
  518.  
  519. function get_customer_info() {
  520.  
  521. $this->layout='ajax';
  522. $this->autoRender=false;
  523. $custID=$this->data['HotelReservation']['customer_id'];
  524.  
  525. $this->loadModel('Customer');
  526. $customers=$this->Customer->find('all',
  527. array('conditions'=>array('Customer.id'=>$custID)));
  528.  
  529. foreach ($customers as $customer) {
  530. $currency=$customer['Currency']['code'];
  531. $payterm=$customer['PayTerm']['name'];
  532. $curr_rate=$customer['Currency']['current_rate'];
  533. $payterm_id=$customer['Customer']['pay_term_id'];
  534. $credit_limit=$customer['Customer']['credit_limit'];
  535. $credit_balance=$customer['Customer']['balance'];
  536. }
  537.  
  538. $this->set(compact('currency','payterm','curr_rate','credit_limit','credit_balance','payterm_id'));
  539.  
  540. if($this->RequestHandler->isAjax()) {
  541. $this->layout='ajax';
  542. $this->autoRender=false;
  543. $this->viewPath = 'elements'.DS.'hotel_reservations';
  544. $this->render('customer_info');
  545. }
  546.  
  547. }
  548. function get_product() {
  549.  
  550. $providerID=$this->data['HotelReservation']['provider_id'];
  551. $products = $this->HotelReservation->Product->find('list',array('conditions'=>array('provider_id'=>$providerID)));
  552. $this->set('products',$products);
  553. //debug($products);
  554.  
  555. }
  556. }
  557. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement