public function renderForm() { if (Tools::getValue('addfeatures')) { $obj_hotel_features = new HotelFeatures(); $features_list = $obj_hotel_features->HotelAllCommonFeaturesArray(); $this->context->smarty->assign('features_list', $features_list); $this->context->smarty->assign('addfeatures', 1); } if ($this->display == 'add') { $obj_hotel_features = new HotelFeatures(); $features_list = $obj_hotel_features->HotelAllCommonFeaturesArray(); $hotel_info_obj = new HotelBranchInformation(); $unassigned_ftrs_hotels = $hotel_info_obj->getUnassignedFeaturesHotelIds(); $this->context->smarty->assign('hotels', $unassigned_ftrs_hotels); $this->context->smarty->assign('features_list', $features_list); } elseif ($this->display == 'edit') { $id = Tools::getValue('id'); $this->context->smarty->assign('edit', 1); $obj_hotel_features = new HotelFeatures(); $hotel_info_obj = new HotelBranchInformation(); $features_hotel = $hotel_info_obj->getFeaturesOfHotelByHotelId(Tools::getValue('id')); $features_list = $obj_hotel_features->HotelBranchSelectedFeaturesArray($features_hotel); $hotels = $hotel_info_obj->hotelsNameAndId(); $this->context->smarty->assign('hotel_id', $id); $this->context->smarty->assign('hotels', $hotels); $this->context->smarty->assign('features_list', $features_list); } $this->fields_form = array('submit' => array('title' => $this->l('Save'))); return parent::renderForm(); }
/** * @param Product $obj * @throws Exception * @throws PrestaShopException * @throws SmartyException */ public function initFormConfiguration($obj) { $data = $this->createTemplate($this->tpl_form); if ($obj->id) { if ($this->product_exists_in_shop) { $obj_htl_info = new HotelBranchInformation(); $htl_info = $obj_htl_info->hotelsNameAndId(); if ($htl_info) { $obj_room_status = new HotelRoomStatus(); $rm_status = $obj_room_status->getAllRoomStatus(); $obj_room_type = new HotelRoomType(); $htl_room_type = $obj_room_type->getRoomTypeInfoByIdProduct($obj->id); if ($htl_room_type) { $data->assign('htl_room_type', $htl_room_type); $htl_full_info = $obj_htl_info->hotelBranchInfoById($htl_room_type['id_hotel']); $data->assign('htl_full_info', $htl_full_info); $obj_room_info = new HotelRoomInformation(); $htl_room_info = $obj_room_info->getHotelRoomInfo($obj->id, $htl_room_type['id_hotel']); if ($htl_room_info) { $data->assign('htl_room_info', $htl_room_info); } } $data->assign(array('product' => $obj, 'htl_info' => $htl_info, 'rm_status' => $rm_status)); } else { $this->displayWarning($this->l('Add Hotel Before configurate this product.')); } } else { $this->displayWarning($this->l('You must save the product in this shop before managing hotel configuration.')); } } else { $this->displayWarning($this->l('You must save this product before managing hotel configuration.')); } $this->tpl_form_vars['custom_form'] = $data->fetch(); }
public function renderView() { $check_calender_var = 0; $obj_booking_dtl = new HotelBookingDetail(); $obj_htl_info = new HotelBranchInformation(); $obj_rm_type = new HotelRoomType(); $obj_cart_book_data = new HotelCartBookingData(); $id_cart = $this->context->cart->id; $id_guest = $this->context->cookie->id_guest; $this->context->smarty->assign(array('id_cart' => $id_cart, 'id_guest' => $id_guest)); $cart_bdata = $obj_cart_book_data->getCartBookingDetailsByIdCartIdGuest($id_cart, $id_guest); if ($cart_bdata) { $cart_tamount = $this->context->cart->getOrderTotal(); $this->context->smarty->assign(array('cart_bdata' => $cart_bdata, 'cart_tamount' => $cart_tamount)); } // No use of adult, child, num_rooms $adult = 0; $children = 0; $num_rooms = 1; if (Tools::isSubmit('search_hotel_list')) { $date_from = Tools::getValue('from_date'); $date_to = Tools::getValue('to_date'); $hotel_id = Tools::getValue('hotel_id'); $room_type = Tools::getValue('room_type'); if ($date_from == '') { $this->errors[] = Tools::displayError('Date From is required field.'); } if ($date_to == '') { $this->errors[] = Tools::displayError('Date To is required field.'); } if ($date_to <= $date_from) { $this->errors[] = Tools::displayError('Date To should be greater than Date From.'); } if ($hotel_id == '') { $this->errors[] = Tools::displayError('Hotel name is required field.'); } $booking_data = array(); $booking_calendar_data = array(); $check_css_condition_var = ''; if (!count($this->errors)) { $booking_data = $obj_booking_dtl->getBookingData($date_from, $date_to, $hotel_id, $room_type, $adult, $children, $num_rooms, 0, 1, 1, 1, 1, $id_cart, $id_guest, 1); if ($booking_data) { foreach ($booking_data['rm_data'] as $key => $value) { if ($value['data']['partially_available']) { foreach ($value['data']['partially_available'] as $key1 => $value1) { if ($value1['avai_dates']) { foreach ($value1['avai_dates'] as $key2 => $value2) { $explode_date = explode(' ', $value2); $date_start = date('Y-m-d', strtotime($explode_date[0])); $date_end = date('Y-m-d', strtotime($explode_date[2])); $result = $obj_cart_book_data->checkExistanceOfRoomInCurrentCart($value1['id_room'], $date_start, $date_end, $id_cart, $id_guest); if ($result) { $room_in_cart = true; } else { $room_in_cart = false; } $booking_data['rm_data'][$key]['data']['partially_available'][$key1]['check_cart'][$key2]['in_current_cart'] = $room_in_cart; $booking_data['rm_data'][$key]['data']['partially_available'][$key1]['check_cart'][$key2]['id_cart'] = $this->context->cart->id; $booking_data['rm_data'][$key]['data']['partially_available'][$key1]['check_cart'][$key2]['cart_booking_data_id'] = $result; } } } } } foreach ($booking_data['rm_data'] as $avil_k => $avail_v) { if ($avail_v['data']['available']) { foreach ($avail_v['data']['available'] as $avil_k1 => $avail_v1) { $result = $obj_cart_book_data->checkExistanceOfRoomInCurrentCart($avail_v1['id_room'], $date_from, $date_to, $id_cart, $id_guest); if ($result) { $room_in_cart = true; } else { $room_in_cart = false; } $booking_data['rm_data'][$avil_k]['data']['available'][$avil_k1]['in_current_cart'] = $room_in_cart; $booking_data['rm_data'][$avil_k]['data']['available'][$avil_k1]['id_cart'] = $this->context->cart->id; $booking_data['rm_data'][$avil_k]['data']['available'][$avil_k1]['cart_booking_data_id'] = $result; } } } foreach ($booking_data['rm_data'] as $booked_k => $booked_v) { if ($booked_v['data']['booked']) { foreach ($booked_v['data']['booked'] as $booked_k1 => $booked_v1) { $cust_obj = new Customer($booked_v1['id_customer']); $booking_data['rm_data'][$booked_k]['data']['booked'][$booked_k1]['alloted_cust_name'] = $cust_obj->firstname . ' ' . $cust_obj->lastname; $booking_data['rm_data'][$booked_k]['data']['booked'][$booked_k1]['alloted_cust_email'] = $cust_obj->email; $booking_data['rm_data'][$booked_k]['data']['booked'][$booked_k1]['avail_rooms_to_swap'] = $obj_booking_dtl->getAvailableRoomsForSwaping($booked_v1['date_from'], $booked_v1['date_to'], $booked_v1['id_product'], $booked_v1['id_hotel']); } } } } //sumit to show info of every date $start_date = $date_from; // hard-coded '01' for first day $last_day_this_month = $date_to; while ($start_date <= $last_day_this_month) { $cal_date_from = $start_date; $cal_date_to = date('Y-m-d', strtotime($cal_date_from) + 86400); $booking_calendar_data[$cal_date_from] = $obj_booking_dtl->getBookingData($cal_date_from, $cal_date_to, $hotel_id, $room_type, $adult, $children, $num_rooms, 1, 1, 1, 1, 1, $id_cart, $id_guest, 1); $start_date = date('Y-m-d', strtotime($start_date) + 86400); } if ($num_rooms <= $booking_data['stats']['num_avail']) { $check_css_condition_var = 'available'; } else { if ($num_rooms <= $booking_data['stats']['num_part_avai']) { $check_css_condition_var = 'part_available'; } else { $check_css_condition_var = 'unavailable'; } } } } else { $check_calender_var = 1; $date_from = date('Y-m-d'); $date_to = date('Y-m-d', strtotime($date_from) + 86400); $hotel_id = 1; $room_type = 0; $booking_data = $obj_booking_dtl->getBookingData($date_from, $date_to, $hotel_id, $room_type, $adult, $children, $num_rooms, 0, 1, 1, 1, 1, $id_cart, $id_guest, 1); // ddd($booking_data); if ($booking_data) { foreach ($booking_data['rm_data'] as $key => $value) { if ($value['data']['partially_available']) { foreach ($value['data']['partially_available'] as $key1 => $value1) { if ($value1['avai_dates']) { foreach ($value1['avai_dates'] as $key2 => $value2) { $explode_date = explode(' ', $value2); $date_start = date('Y-m-d', strtotime($explode_date[0])); $date_end = date('Y-m-d', strtotime($explode_date[2])); $result = $obj_cart_book_data->checkExistanceOfRoomInCurrentCart($value1['id_room'], $date_start, $date_end, $id_cart, $id_guest); if ($result) { $room_in_cart = true; } else { $room_in_cart = false; } $booking_data['rm_data'][$key]['data']['partially_available'][$key1]['check_cart'][$key2]['in_current_cart'] = $room_in_cart; $booking_data['rm_data'][$key]['data']['partially_available'][$key1]['check_cart'][$key2]['id_cart'] = $this->context->cart->id; $booking_data['rm_data'][$key]['data']['partially_available'][$key1]['check_cart'][$key2]['cart_booking_data_id'] = $result; } } } } } foreach ($booking_data['rm_data'] as $avil_k => $avail_v) { if ($avail_v['data']['available']) { foreach ($avail_v['data']['available'] as $avil_k1 => $avail_v1) { $result = $obj_cart_book_data->checkExistanceOfRoomInCurrentCart($avail_v1['id_room'], $date_from, $date_to, $id_cart, $id_guest); if ($result) { $room_in_cart = true; } else { $room_in_cart = false; } $booking_data['rm_data'][$avil_k]['data']['available'][$avil_k1]['in_current_cart'] = $room_in_cart; $booking_data['rm_data'][$avil_k]['data']['available'][$avil_k1]['id_cart'] = $this->context->cart->id; $booking_data['rm_data'][$avil_k]['data']['available'][$avil_k1]['cart_booking_data_id'] = $result; } } } foreach ($booking_data['rm_data'] as $booked_k => $booked_v) { if ($booked_v['data']['booked']) { foreach ($booked_v['data']['booked'] as $booked_k1 => $booked_v1) { $cust_obj = new Customer($booked_v1['id_customer']); $booking_data['rm_data'][$booked_k]['data']['booked'][$booked_k1]['alloted_cust_name'] = $cust_obj->firstname . ' ' . $cust_obj->lastname; $booking_data['rm_data'][$booked_k]['data']['booked'][$booked_k1]['alloted_cust_email'] = $cust_obj->email; $booking_data['rm_data'][$booked_k]['data']['booked'][$booked_k1]['avail_rooms_to_swap'] = $obj_booking_dtl->getAvailableRoomsForSwaping($booked_v1['date_from'], $booked_v1['date_to'], $booked_v1['id_product'], $booked_v1['id_hotel']); } } } } //sumit to show info of every date $start_date = date('Y-m-01'); // hard-coded '01' for first day $last_day_this_month = date('Y-m-t'); while ($start_date <= $last_day_this_month) { $cal_date_from = $start_date; $cal_date_to = date('Y-m-d', strtotime($cal_date_from) + 86400); $booking_calendar_data[$cal_date_from] = $obj_booking_dtl->getBookingData($cal_date_from, $cal_date_to, $hotel_id, $room_type, $adult, $children, $num_rooms, 1, 1, 1, 1, 1, $id_cart, $id_guest, 1); $start_date = date('Y-m-d', strtotime($start_date) + 86400); } if ($num_rooms <= $booking_data['stats']['num_avail']) { $check_css_condition_var = 'default_available'; } else { if ($num_rooms <= $booking_data['stats']['num_part_avai']) { $check_css_condition_var = 'default_part_available'; } else { $check_css_condition_var = 'default_unavailable'; } } } $currency = new Currency((int) Configuration::get('PS_CURRENCY_DEFAULT')); $hotel_name = $obj_htl_info->hotelsNameAndId(); $all_room_type = $obj_rm_type->getRoomTypeByHotelId($hotel_id); $rms_in_cart = $obj_cart_book_data->getCountRoomsInCart($id_cart, $id_guest); $this->tpl_view_vars = array('check_calender_var' => $check_calender_var, 'date_from' => $date_from, 'date_to' => $date_to, 'hotel_id' => $hotel_id, 'room_type' => $room_type, 'adult' => $adult, 'children' => $children, 'num_rooms' => $num_rooms, 'booking_data' => $booking_data, 'booking_calendar_data' => $booking_calendar_data, 'check_css_condition_var' => $check_css_condition_var, 'hotel_name' => $hotel_name, 'all_room_type' => $all_room_type, 'currency' => $currency, 'rms_in_cart' => $rms_in_cart); return parent::renderView(); }