</td> <td class='title_room_number' align="center">#</td> <?php $startDate = $this->state->get('filter.start_date'); $endDate = $this->state->get('filter.end_date'); for ($d = strtotime($startDate); $d <= strtotime($endDate);) { $dayString = date('d-m-Y', $d); ?> <td align=center colspan='2' class='<?php echo date('d-m-Y') == $dayString ? "td_crt_data" : "td_data"; ?> ' > <?php echo JHotelUtil::convertToFormat($dayString); ?> </td> <?php $d = strtotime(date('d-m-Y', $d) . ' + 1 day '); } ?> </tr> <tr> <?php for ($d = strtotime($startDate); $d <= strtotime($endDate);) { $dayString = date('d-m-Y', $d); ?>
/** * Overrides the getItems method to attach additional metrics to the list. * * @return mixed An array of data items on success, false on failure. * * @since 1.6.1 */ public function getItems() { // Get a storage key. $store = $this->getStoreId('getItems'); // Try to load the data from internal storage. //if (!empty($this->cache[$store])) //{ // return $this->cache[$store]; //} // Load the list items. $items = parent::getItems(); // If emtpy or an error, just return. $month = $this->getState('filter.month'); $year = $month < date("n") ? date("Y") + 1 : date("Y"); $startDate = date("Y-m-d", mktime(0, 0, 0, $month, 1, $year)); $endDate = date("Y-m-d", mktime(0, 0, 0, $month + 1, 0, $year)); $app = JFactory::getApplication('administrator'); $hotelId = $app->getUserState('com_jhotelreservation.excursions.filter.hotel_id'); $excursionId = $app->getUserState('com_jhotelreservation.edit.excursion.id'); if (empty($excursionId)) { $excursionId = JRequest::getVar("excursion_id"); } $excursionId = $excursionId[0]; if (empty($items)) { $items = $this->getDefaultRates($month, $year); $this->setState('filter.newRates', true); } $this->setState('filter.start_date', JHotelUtil::convertToFormat($startDate)); $this->setState('filter.end_date', JHotelUtil::convertToFormat($endDate)); JRequest::setVar("filter_start_date", $startDate); JRequest::setVar("filter_end_date", $endDate); JRequest::setVar("filter_excursion_type", $endDate); JRequest::setVar("hotel_id", $hotelId); foreach ($items as $item) { //dmp($item->date); $item->booked = 0; $item->available = 0; } // Add the items to the internal cache. $this->cache[$store] = $items; return $this->cache[$store]; }
<?php $startDate = JHotelUtil::convertToFormat($this->item->reservationData->userData->start_date); ?> <?php echo JHTML::_('calendar', $startDate == $this->appSettings->defaultDateValue ? '' : $startDate, 'start_date', 'start_date_i', $this->appSettings->calendarFormat, array('class' => 'inputbox', 'size' => '10', 'maxlength' => '10')); ?> </td> </tr> <tr> <td width=10% nowrap class="key"><?php echo JText::_('LNG_DEPARTURE', true); ?> </td> <td> <?php $endDate = JHotelUtil::convertToFormat($this->item->reservationData->userData->end_date); ?> <?php echo JHTML::_('calendar', $endDate == $this->appSettings->defaultDateValue ? '' : $endDate, 'end_date', 'end_date_i', $this->appSettings->calendarFormat, array('class' => 'inputbox', 'size' => '10', 'maxlength' => '10')); ?> </td> </tr> <tr> <tr> <td colspan="2"> <?php echo JText::_('LNG_PRICE_CHOOSE', true); ?> </td> </tr> <tr>
function &getData() { // Load the data if (empty($this->_data)) { $query = ' SELECT * FROM #__hotelreservation_rooms' . ' WHERE room_id = ' . $this->_room_id; $this->_db->setQuery($query); $this->_data = $this->_db->loadObject(); if ($this->_data) { $this->_data->option_ids = explode(',', $this->_data->option_ids); } } if (!$this->_data) { $this->_data = new stdClass(); $this->_data->room_id = null; $this->_data->hotel_id = null; $this->_data->room_name = null; $this->_data->type_price = null; $this->_data->room_price_1 = null; $this->_data->room_price_2 = null; $this->_data->room_price_3 = null; $this->_data->room_price_4 = null; $this->_data->room_price_5 = null; $this->_data->room_price_6 = null; $this->_data->room_price_7 = null; $this->_data->room_price = null; $this->_data->room_price_midweek = null; $this->_data->room_price_weekend = null; $this->_data->room_capacity = null; $this->_data->number_of_rooms = null; $this->_data->room_description = null; $this->_data->room_short_description = null; $this->_data->room_main_description = null; $this->_data->room_details = null; $this->_data->is_available = null; // $this->_data->room_datas = date('Y-m-d'); // $this->_data->room_datae = date('Y-m-d'); $this->_data->option_ids = null; $this->_data->pers_price = null; $this->_data->front_display = null; $this->_data->single_discount = null; $this->_data->single_supplement = null; $this->_data->has_breakfast = null; //check temporary files $pictures = JHotelUtil::makePathFile(JPATH_COMPONENT . PATH_ROOM_PICTURES . ($this->_data->room_id + 0) . "/*.*"); $files = glob($pictures); if (is_array($files) && count($files) > 0) { sort($files); } //~check temporary files $this->_data->pictures = array(); $this->_data->dates_room = array(); $this->_data->seasons = array(); if (is_array($files) && count($files) > 0) { foreach ($files as $value) { $this->_data->pictures[] = array('room_picture_info' => 'add from cache', 'room_picture_path' => PATH_ROOM_PICTURES . ($this->_data->room_id + 0) . '/' . basename($value), 'room_picture_enable' => 1); } } $obj = new stdClass(); $obj->nrs = ''; $obj->nre = ''; $obj->datas = ''; $obj->datae = ''; $obj->datai = ''; $obj->is_ignore_duplicate = true; $this->_data->room_intervals_numbers[] = $obj; //clean all temporary seasons if (JRequest::getVar('is_error') == "0" || JRequest::getVar('is_error') == null) { $query = " DELETE FROM #__hotelreservation_rooms_seasons WHERE room_id =0 "; $this->_db->setQuery($query); $this->_db->query(); $query = " DELETE FROM #__hotelreservation_rooms_seasons_date_ignored WHERE room_id =0 "; $this->_db->setQuery($query); $this->_db->query(); } //clean all temporary seasons } else { $query = "\r\n\t\t\t\t\tSELECT \r\n\t\t\t\t\t\t*\r\n\t\t\t\t\tFROM #__hotelreservation_rooms_seasons\r\n\t\t\t\t\tWHERE room_id ='" . $this->_data->room_id . "'\r\n\t\t\t\t\tORDER BY room_season_datas, room_season_name "; // dmp($query); //$this->_db->setQuery( $query ); $this->_data->seasons = $this->_getList($query); $query = "\r\n\t\t\t\t\tSELECT \r\n\t\t\t\t\t\t*\r\n\t\t\t\t\tFROM #__hotelreservation_rooms_intervals_numbers\r\n\t\t\t\t\tWHERE room_id =" . $this->_data->room_id . "\r\n\t\t\t\t\tORDER BY nrs, nre "; // dmp($query); //$this->_db->setQuery( $query ); $this->_data->room_intervals_numbers = $this->_getList($query); if (count($this->_data->room_intervals_numbers) == 0) { $obj = new stdClass(); $obj->nrs = ''; $obj->nre = ''; $obj->datas = ''; $obj->datae = ''; $obj->datai = ''; $obj->is_ignore_duplicate = true; $this->_data->room_intervals_numbers[] = $obj; } //check temporary files $query = "\r\n\t\t\t\t\tSELECT \r\n\t\t\t\t\t\t*\r\n\t\t\t\t\tFROM #__hotelreservation_rooms_pictures\r\n\t\t\t\t\tWHERE room_id =" . $this->_data->room_id . "\r\n\t\t\t\t\tORDER BY room_picture_id "; // dmp($query); //$this->_db->setQuery( $query ); $files = $this->_getList($query); $this->_data->pictures = array(); foreach ($files as $value) { $this->_data->pictures[] = array('room_picture_info' => $value->room_picture_info, 'room_picture_path' => $value->room_picture_path, 'room_picture_enable' => $value->room_picture_enable); } } //prepare price days $this->_data->room_prices = null; $this->_data->room_prices[$this->_data->room_price_1][] = 1; $this->_data->room_prices[$this->_data->room_price_2][] = 2; $this->_data->room_prices[$this->_data->room_price_3][] = 3; $this->_data->room_prices[$this->_data->room_price_4][] = 4; $this->_data->room_prices[$this->_data->room_price_5][] = 5; $this->_data->room_prices[$this->_data->room_price_6][] = 6; $this->_data->room_prices[$this->_data->room_price_7][] = 7; // dmp($this->_data->room_prices); //~prepare price days if (JRequest::getVar('is_error') == "1") { //dmp($this->_data); $post = JRequest::get('post'); if (count($post) > 0) { $this->_data->option_ids = array(); $this->_data->room_intervals_numbers = array(); $this->_data->pictures = array(); $query = "\r\n\t\t\t\t\t\tSELECT \r\n\t\t\t\t\t\t\t*\r\n\t\t\t\t\t\tFROM #__hotelreservation_rooms_seasons\r\n\t\t\t\t\t\tWHERE room_id ='" . $this->_data->room_id . "'\r\n\t\t\t\t\t\tORDER BY room_season_datas, room_season_name "; // dmp($query); //$this->_db->setQuery( $query ); $this->_data->seasons = $this->_getList($query); foreach ($post as $key => $value) { //dmp($key.' >> '.$this->_data->$key.' | '.(property_exists($this->_data,$key)? "1" : "0")); if (property_exists($this->_data, $key)) { if (!is_array($value)) { $this->_data->{$key} = $value; } else { } } else { if (strpos($key, "option_ids") !== false) { if (is_array($value)) { foreach ($value as $v) { $this->_data->option_ids[] = $v; } } else { $this->_data->option_ids[] = $value[0]; } } else { if (strpos($key, "room_picture_info") !== false) { foreach ($value as $k => $v) { if (!isset($this->_data->pictures[$k])) { $this->_data->pictures[$k] = array('room_picture_info' => '', 'room_picture_path' => '', 'room_picture_enable' => ''); } $this->_data->pictures[$k]['room_picture_info'] = $v; } } else { if (strpos($key, "room_picture_enable") !== false) { foreach ($value as $k => $v) { if (!isset($this->_data->pictures[$k])) { $this->_data->pictures[$k] = array('room_picture_info' => '', 'room_picture_path' => '', 'room_picture_enable' => ''); } $this->_data->pictures[$k]['room_picture_enable'] = $v; } } else { if (strpos($key, "room_picture_path") !== false) { foreach ($value as $k => $v) { if (!isset($this->_data->pictures[$k])) { $this->_data->pictures[$k] = array('room_picture_info' => '', 'room_picture_path' => '', 'room_picture_enable' => ''); } $this->_data->pictures[$k]['room_picture_path'] = $v; } } else { if (strpos($key, "room_number_start") !== false) { $key_new = str_replace("room_number_start_", "", $key); if (!isset($this->_data->room_intervals_numbers[$key_new])) { $nr = new stdClass(); $nr->room_interval_number_id = ''; $nr->room_id = ''; $nr->nrs = ''; $nr->nre = ''; $nr->datas = ''; $nr->datae = ''; $nr->datai = ''; $nr->is_ignore_duplicate = true; $this->_data->room_intervals_numbers[$key_new] = $nr; } $this->_data->room_intervals_numbers[$key_new]->nrs = $value; } else { if (strpos($key, "room_number_stop") !== false) { $key_new = str_replace("room_number_stop_", "", $key); if (!isset($this->_data->room_intervals_numbers[$key_new])) { $nr = new stdClass(); $nr->room_interval_number_id = ''; $nr->room_id = ''; $nr->nrs = ''; $nr->nre = ''; $nr->datas = ''; $nr->datae = ''; $nr->datai = ''; $nr->is_ignore_duplicate = true; $this->_data->room_intervals_numbers[$key_new] = $nr; } $this->_data->room_intervals_numbers[$key_new]->nre = $value; } else { if (strpos($key, "is_ignore_duplicate") !== false) { $key_new = str_replace("is_ignore_duplicate_", "", $key); if (!isset($this->_data->room_intervals_numbers[$key_new])) { $nr = new stdClass(); $nr->room_interval_number_id = ''; $nr->room_id = ''; $nr->nrs = ''; $nr->nre = ''; $nr->datas = ''; $nr->datae = ''; $nr->datai = ''; $nr->is_ignore_duplicate = true; $this->_data->room_intervals_numbers[$key_new] = $nr; } $this->_data->room_intervals_numbers[$key_new]->is_ignore_duplicate = $value; } else { if (strpos($key, "room_number_datas") !== false) { $key_new = str_replace("room_number_datas_", "", $key); if (!isset($this->_data->room_intervals_numbers[$key_new])) { $nr = new stdClass(); $nr->room_interval_number_id = ''; $nr->room_id = ''; $nr->nrs = ''; $nr->nre = ''; $nr->datas = ''; $nr->datae = ''; $nr->datai = ''; $nr->is_ignore_duplicate = true; $this->_data->room_intervals_numbers[$key_new] = $nr; } $this->_data->room_intervals_numbers[$key_new]->datas = JHotelUtil::convertToFormat($value); } else { if (strpos($key, "room_number_datae") !== false) { $key_new = str_replace("room_number_datae_", "", $key); if (!isset($this->_data->room_intervals_numbers[$key_new])) { $nr = new stdClass(); $nr->room_interval_number_id = ''; $nr->room_id = ''; $nr->nrs = ''; $nr->nre = ''; $nr->datas = ''; $nr->datae = ''; $nr->datai = ''; $nr->is_ignore_duplicate = true; $this->_data->room_intervals_numbers[$key_new] = $nr; } //convert date format $this->_data->room_intervals_numbers[$key_new]->datae = JHotelUtil::convertToFormat($value); } else { if (strpos($key, "room_number_datai") !== false) { $key_new = str_replace("room_number_datai_", "", $key); if (!isset($this->_data->room_intervals_numbers[$key_new])) { $nr = new stdClass(); $nr->room_interval_number_id = ''; $nr->room_id = ''; $nr->nrs = ''; $nr->nre = ''; $nr->datas = ''; $nr->datae = ''; $nr->datai = ''; $nr->is_ignore_duplicate = true; $this->_data->room_intervals_numbers[$key_new] = $nr; } $this->_data->room_intervals_numbers[$key_new]->datai = $value; } else { if (strpos($key, "price_day") !== false) { $this->_data->room_prices = array(); foreach ($post['price_day'] as $keyPos => $valPrice) { for ($day = 1; $day <= 7; $day++) { //dmp( 'price_day_'.$keyPos.'_'.($day) ); if (isset($post['day_' . $keyPos . '_' . $day])) { $this->_data->room_prices[$valPrice][] = $day; } } } } } } } } } } } } } } } } } } //clean unnecessary files $files = glob(JHotelUtil::makePathFile(JPATH_COMPONENT . PATH_ROOM_PICTURES . $this->_data->room_id . "/" . "*.*")); if (is_array($files) && count($files) > 0) { foreach ($files as $pic) { $is_find = false; foreach ($this->_data->pictures as $value) { if ($pic == JHotelUtil::makePathFile(JPATH_COMPONENT . $value['room_picture_path'])) { $is_find = true; break; } } if ($is_find == false) { @unlink($pic); } } } //~clean unnecessary files //dmp($this->_data->option_ids); //dmp($this->_data); return $this->_data; }
function sendGuestList() { $reservationService = new ReservationService(); $startDate = date('Y-m-d', strtotime(date('Y-m-d') . ' + 1 day')); $endDate = date('Y-m-d', strtotime($startDate . ' + 1 day')); $confirmationTable = $this->getTable('Confirmations'); $reservations = $confirmationTable->getReservationList($startDate, $startDate); $guestDetailsList = "<tr style='text-align: left;'><th>" . JText::_("LNG_NAME") . "</th><th>" . JText::_("LNG_ARRIVAL") . "</th><th>" . JText::_("LNG_DEPARTURE") . "</th><th>" . JText::_("LNG_ADULTS") . " </th><th>" . JText::_("LNG_ROOMS") . " </th><th>" . JText::_("LNG_OFFERS") . "</th></tr>"; if (count($reservations) > 0) { $hotelId = $reservations[0]->hotel_id; $guestDetailsList .= "<tr>"; $guestDetailsList .= "<td>" . $reservations[0]->last_name . ' ' . $reservations[0]->first_name . " </td><td nowrap='nowrap'>" . JHotelUtil::convertToFormat($reservations[0]->start_date) . " </td><td nowrap='nowrap'>" . JHotelUtil::convertToFormat($reservations[0]->end_date) . " </td><td>" . $reservations[0]->adults . " </td><td>" . $reservations[0]->number_rooms . " </td><td>" . $reservations[0]->offer_names . " </td>"; $guestDetailsList .= "</tr>"; foreach ($reservations as $reservation) { if ($hotelId != $reservation->hotel_id || next($reservations) === false) { $guestDetailsList .= "<tr>"; $guestDetailsList .= "<td>" . $reservation->last_name . ' ' . $reservation->first_name . " </td><td nowrap='nowrap'>" . JHotelUtil::convertToFormat($reservation->start_date) . " </td><td nowrap='nowrap'>" . JHotelUtil::convertToFormat($reservation->end_date) . " </td><td>" . $reservation->adults . " </td><td>" . $reservation->number_rooms . " </td><td>" . $reservation->offer_names . " </td>"; $guestDetailsList .= "</tr>"; $guestDetailsList = "<table style=text-align:left'>" . $guestDetailsList . "</table>"; EmailService::sendGuestListEmail($reservation->hotel_id, $reservation->hotel_name, $reservation->hotel_email, $guestDetailsList, $startDate); $guestDetailsList = "<tr style='text-align: left;'><th>" . JText::_("LNG_NAME") . "</th><th>" . JText::_("LNG_ARRIVAL") . "</th><th>" . JText::_("LNG_DEPARTURE") . "</th><th>" . JText::_("LNG_ADULTS") . " </th><th>" . JText::_("LNG_ROOMS") . " </th><th>" . JText::_("LNG_OFFERS") . "</th></tr>"; $hotelId = $reservation->hotel_id; break; } $guestDetailsList .= "<tr>"; $guestDetailsList .= "<td>" . $reservation->last_name . ' ' . $reservation->first_name . " </td><td nowrap='nowrap'>" . JHotelUtil::convertToFormat($reservation->start_date) . " </td><td nowrap='nowrap'>" . JHotelUtil::convertToFormat($reservation->end_date) . " </td><td>" . $reservation->adults . " </td><td>" . $reservation->number_rooms . " </td><td>" . $reservation->offer_names . " </td>"; $guestDetailsList .= "</tr>"; } } }
<?php $hotel = $this->hotel; //create dates & default values $startDate = $this->userData->start_date; $endDate = $this->userData->end_date; $startDate = JHotelUtil::convertToFormat($startDate); $endDate = JHotelUtil::convertToFormat($endDate); $log = Logger::getInstance(JPATH_COMPONENT . "/logs/site-log-" . date("d-m-Y") . '.log', 1); $log->LogDebug("Archivo \\components\\com_jhotelreservation\views\\hotel\tmpl\\hoteloverview.php"); $log->LogDebug("Accedió"); $habit = $this->userData->rooms; ?> <!--////////////////////////////////////////////////////////////////--> <!--MICOD Aqui importo el archivo JS donde se encuentra el código AJAX para enviar datos por POST--> <!--<script type="text/javascript" src="ajax_filtro.js"></script>--> <!--////////////////////////////////////////////////////////////////--> <?php if ($this->appSettings->enable_hotel_tabs == 1) { ?> <div class="hotel-image-gallery"> <div class="image-preview-cnt"> <img id="image-preview" alt="<?php if (isset($hotel->pictures[0])) { echo isset($hotel->pictures[0]->hotel_picture_info) ? $hotel->pictures[0]->hotel_picture_info : ''; } ?> " src='<?php if (isset($hotel->pictures[0])) {
function generateBookingsListHTML($invoice) { //if invoice details are defined only invoice details are sent $bookingsList = ''; $style = "\"border:1px solid #333\""; //dmp($invoice->invoiceDetails); if (isset($invoice->invoiceDetails)) { foreach ($invoice->invoiceDetails as $detail) { $bookingsList = $bookingsList . "<TR>\r\n\t\t\t\t\t\t\t\t\t\t\t<TD style={$style}>\r\n\t\t\t\t\t\t\t\t\t\t\t\t" . $detail->reservationId . "\r\n\t\t\t\t\t\t\t\t\t\t\t</TD>\r\n\t\t\t\t\t\t\t\t\t\t\t<TD style={$style}>" . $detail->name . "</TD>\r\n\t\t\t\t\t\t\t\t\t\t\t<TD style={$style}>" . JHotelUtil::convertToFormat($detail->arrival) . "</TD>\r\n\t\t\t\t\t\t\t\t\t\t\t<TD style={$style}>" . JHotelUtil::convertToFormat($detail->departure) . "</TD>\r\n\t\t\t\t\t\t\t\t\t\t\t<TD style={$style} nowrap='nowrap'> € " . $detail->amount . " </TD>\r\n\t\t\t\t\t\t\t\t\t\t\t<TD style={$style} nowrap='nowrap'> € " . $detail->commissionAmount . "</TD>\r\n\t\t\t\t\t\t\t\t\t\t</TR>\r\n\t\t\t\t\t\t\t\t\t\t"; } $bookingsList = "<TABLE width=\"100%\" cellspacing=\"0\" cellpadding=\"6\" class=\"adminlist\" align=center border=0>\r\n\t\t\t\t\t\t\t\t\t\t<thead>\r\n\t\t\t\t\t\t\t\t\t\t\t<th style={$style} width='10%' align=center><B>" . ucfirst(JText::_('LNG_RESERVATION_NUMBER', true)) . "</B></th>\r\n\t\t\t\t\t\t\t\t\t\t\t<th style={$style} width='30%' align=center ><B>" . ucfirst(JText::_('LNG_NAME', true)) . "</B></th>\r\n\t\t\t\t\t\t\t\t\t\t\t<th style={$style} width='20%' align=center><B>" . ucfirst(JText::_('LNG_ARRIVAL', true)) . "</B></th>\r\n\t\t\t\t\t\t\t\t\t\t\t<th style={$style} width='20%' align=center><B>" . ucfirst(JText::_('LNG_DEPARTURE', true)) . "</B></th>\r\n\t\t\t\t\t\t\t\t\t\t\t<th style={$style} width='10%' align=center><B>" . ucfirst(JText::_('LNG_AMOUNT', true)) . "</B></th>\r\n\t\t\t\t\t\t\t\t\t\t\t<th style={$style} width='10%' align=center><B>" . ucfirst(JText::_('LNG_COMMISSION', true)) . "</B></th>\r\n\t\t\t\t\t\t\t\t\t\t</thead>\r\n\t\t\t\t\t\t\t\t\t\t<tbody>" . $bookingsList . "\r\n\t\t\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t\t\t<td colspan=\"3\"> </td>\r\n\t\t\t\t\t\t\t\t\t\t\t\t<td nowrap='nowrap' align=\"right\"><strong>" . JText::_('LNG_TOTAL', true) . ": </strong></td>\r\n\t\t\t\t\t\t\t\t\t\t\t\t<td nowrap='nowrap' id=\"total-amount\" style=\"border-top:1px solid #333\"> € " . $invoice->reservationAmount . "</td>\r\n\t\t\t\t\t\t\t\t\t\t\t\t<td nowrap='nowrap' id=\"total-commission\"style=\"border-top:1px solid #333\"> € " . $invoice->commissionAmount . "</td>\r\n\t\t\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t</tbody>\r\n\t\t\t\t\t\t\t\t</TABLE>\r\n\t\t\t\t\t"; } dmp($bookingsList); return $bookingsList; }
/** * Overrides the getItems method to attach additional metrics to the list. * * @return mixed An array of data items on success, false on failure. * * @since 1.6.1 */ public function getItems() { // Get a storage key. $store = $this->getStoreId('getItems'); // Try to load the data from internal storage. //if (!empty($this->cache[$store])) //{ // return $this->cache[$store]; //} // Load the list items. $items = parent::getItems(); // Getting the following metric by joins is WAY TOO SLOW. // Faster to do three queries for very large menu trees. // If emtpy or an error, just return. $month = $this->getState('filter.month'); $year = $month < date("n") ? date("Y") + 1 : date("Y"); if (empty($items)) { return $this->getDefaultRates($month, $year); } else { foreach ($items as $item) { $item->booked = 0; $item->available = 0; } } $startDate = date("Y-m-d", mktime(0, 0, 0, $month, 1, $year)); $endDate = date("Y-m-d", mktime(0, 0, 0, $month + 1, 0, $year)); $this->setState('filter.start_date', JHotelUtil::convertToFormat($startDate)); $this->setState('filter.end_date', JHotelUtil::convertToFormat($endDate)); // Add the items to the internal cache. $this->cache[$store] = $items; return $this->cache[$store]; }
/** * Overrides the getItems method to attach additional metrics to the list. * * @return mixed An array of data items on success, false on failure. * * @since 1.6.1 */ public function getItems() { // Get a storage key. $store = $this->getStoreId('getItems'); // Try to load the data from internal storage. //if (!empty($this->cache[$store])) //{ // return $this->cache[$store]; //} // Load the list items. $items = parent::getItems(); // If emtpy or an error, just return. $month = $this->getState('filter.month'); $year = $month < date("n") ? date("Y") + 1 : date("Y"); $startDate = date("Y-m-d", mktime(0, 0, 0, $month, 1, $year)); $endDate = date("Y-m-d", mktime(0, 0, 0, $month + 1, 0, $year)); $app = JFactory::getApplication('administrator'); $hotelId = $app->getUserState('com_jhotelreservation.rooms.filter.hotel_id'); $roomId = $app->getUserState('com_jhotelreservation.edit.room.room_id'); $rId = JRequest::getVar("room_id", null); if (!empty($rId)) { $roomId = $rId; $app->setUserState('com_jhotelreservation.edit.room.room_id', $roomId); } if (empty($items)) { $items = $this->getDefaultRates($month, $year); $this->setState('filter.newRates', true); } $this->setState('filter.start_date', JHotelUtil::convertToFormat($startDate)); $this->setState('filter.end_date', JHotelUtil::convertToFormat($endDate)); JRequest::setVar("filter_start_date", $startDate); JRequest::setVar("filter_end_date", $endDate); JRequest::setVar("filter_room_type", $endDate); JRequest::setVar("hotel_id", $hotelId); JRequest::setVar("filter_room_type", $roomId); $hotelAvailability = HotelService::getHotelAvailabilyPerDay($hotelId, $startDate, $endDate); //dmp($roomId); $report = new JHotelReservationModelReports(); $availabilty = $report->getAvailabilityReport(); //dmp($availabilty); //dmp($roomId); foreach ($items as $item) { //dmp($item->date); if (isset($availabilty[$item->date][$roomId])) { $item->booked = $availabilty[$item->date][$roomId][1]; } else { $item->booked = 0; } //dmp($item->booked); if (isset($availabilty[$item->date][$roomId])) { $item->available = intval($item->availability) - intval($availabilty[$item->date][$roomId][1]); } else { $item->available = $item->availability; } $item->isHotelAvailable = $hotelAvailability[$item->date]; } // Add the items to the internal cache. $this->cache[$store] = $items; return $this->cache[$store]; }
/** * Method to get a menu item. * * @param integer The id of the menu item to get. * * @return mixed Menu item data object on success, false on failure. */ public function getItem($itemId = null) { // Initialise variables. $itemId = !empty($itemId) ? $itemId : (int) $this->getState('offer.offer_id'); $false = false; // Get a menu item row instance. $table = $this->getTable('ManageOffers', 'Table'); // Attempt to load the row. $return = $table->load($itemId); // Check for a table object error. if ($return === false && $table->getError()) { $this->setError($table->getError()); return $false; } if (!empty($table->offer_id)) { $this->setState('offer.hotel_id', $table->hotel_id); } $properties = $table->getProperties(1); $value = JArrayHelper::toObject($properties, 'JObject'); $value->itemRooms = $this->getOfferRooms(); $value->itemExcursions = $this->getOfferExcursions($this->getState('offer.offer_id')); $query = ' SELECT * FROM #__hotelreservation_offers_themes ORDER BY name'; $value->themes = $this->_getList($query); $query = ' SELECT * FROM #__hotelreservation_offers_themes_relation where offerId=' . $this->getState('offer.offer_id'); $value->selectedThemes = $this->_getList($query); $query = " SELECT * FROM #__hotelreservation_offers_vouchers where offerId = " . $this->getState('offer.offer_id') . " ORDER BY voucher"; $value->vouchers = $this->_getList($query); $value->offer_datas = JHotelUtil::convertToFormat($value->offer_datas); $value->offer_datae = JHotelUtil::convertToFormat($value->offer_datae); $value->offer_datasf = JHotelUtil::convertToFormat($value->offer_datasf); $value->offer_dataef = JHotelUtil::convertToFormat($value->offer_dataef); return $value; }
function initFilterParams() { $post = JRequest::get('post'); if (isset($post['filter_datas'])) { $post['filter_datas'] = JHotelUtil::convertToMysqlFormat($post['filter_datas']); } if (isset($post['filter_datae'])) { $post['filter_datae'] = JHotelUtil::convertToMysqlFormat($post['filter_datae']); } if (isset($post['hotel_id'])) { $this->hotel_id = $post['hotel_id']; } else { $this->hotel_id = $post['hotel_id'] = 0; } if (isset($post['filter_room_types'])) { $this->filter_room_types = $post['filter_room_types']; } else { $this->filter_room_types = $post['filter_room_types'] = 0; } if (isset($post['filter_datas'])) { $this->filter_datas = $post['filter_datas']; } else { $this->filter_datas = $post['filter_datas'] = date('Y-m-01'); } if (isset($post['filter_datae'])) { $this->filter_datae = $post['filter_datae']; } else { $this->filter_datae = $post['filter_datae'] = date('Y-m-t'); } if (isset($post['filter_report_type'])) { $this->filter_report_type = $post['filter_report_type']; } else { $this->filter_report_type = "MONTH"; } $this->filter_datas = JHotelUtil::convertToFormat($this->filter_datas); $this->filter_datae = JHotelUtil::convertToFormat($this->filter_datae); $hotels = $this->get('Hotels'); $hotels = checkHotels(JFactory::getUser()->id, $hotels); $this->hotels = $hotels; return $post; }
public static function sendNoAvailabilityEmail($hotelId, $startDate, $endDate) { $log = Logger::getInstance(); $log->LogDebug("No availabaility " . $hotelId . " " . $startDate . " " . $endDate); $hotel = HotelService::getHotel($hotelId); $appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $datas = JHotelUtil::convertToFormat($startDate); $datae = JHotelUtil::convertToFormat($endDate); $mode = 1; //html $emailContent = JText::_('LNG_NO_AVAILABILITY_EMAIL', true); $emailContent = str_replace("<<hotel>>", $hotel->hotel_name, $emailContent); $emailContent = str_replace("<<start_date>>", $datas, $emailContent); $emailContent = str_replace("<<end_date>>", $datae, $emailContent); $email_subject = JText::_('LNG_NO_AVAILABILITY_EMAIL_SUBJECT', true); $email_subject = str_replace("<<hotel>>", $hotel->hotel_name, $email_subject); return self::sendEmail($appSettings->company_email, $appSettings->company_name, null, $appSettings->company_email, null, null, $email_subject, $emailContent, $mode); }
/** * Method to get a menu item. * * @param integer The id of the menu item to get. * * @return mixed Menu item data object on success, false on failure. */ public function &getItem($itemId = null) { $itemId = !empty($itemId) ? $itemId : (int) $this->getState('extraoption.id'); $intialId = $itemId; if ($this->getState('source.id')) { $itemId = $this->getState('source.id'); } $false = false; // Get a menu item row instance. $table = $this->getTable(); // Attempt to load the row. $return = $table->load($itemId); // Check for a table object error. if ($return === false && $table->getError()) { $this->setError($table->getError()); return $false; } $properties = $table->getProperties(1); $value = JArrayHelper::toObject($properties, 'JObject'); $value->id = $intialId; $value->start_date = JHotelUtil::convertToFormat($value->start_date); $value->end_date = JHotelUtil::convertToFormat($value->end_date); $value->rooms = $this->getRooms(); $value->offers = $this->getOffers($value->offer_ids); return $value; }
} else { if (isset($endDate) && strlen($endDate) > 0) { $jhotelreservation_datae = $params->get('end-date'); if (strtotime($jhotelreservation_datae) < strtotime(date("Y-m-d"))) { $jhotelreservation_datae = date("Y-m-d"); } } else { if (isset($userData->end_date)) { $jhotelreservation_datae = $userData->end_date; } else { $jhotelreservation_datae = date('Y-m-d', strtotime(' + 1 day ')); } } } } $jhotelreservation_datae = JHotelUtil::convertToFormat($jhotelreservation_datae); $jhotelreservation_rooms = JRequest::getVar('jhotelreservation_rooms'); $jhotelreservation_guest_adult = JRequest::getVar('jhotelreservation_guest_adult'); $jhotelreservation_guest_child = JRequest::getVar('jhotelreservation_guest_child'); $jhotelreservation_hotel_id = JRequest::getVar('jhotelreservation_hotel_id'); //$getHotelItems= JRequest::getVar('getHotelItems'); // var_dump($getHotelItems); if (strlen($jhotelreservation_rooms) == 0) { if (JRequest::getVar('rooms') != '') { $jhotelreservation_rooms = JRequest::getVar('rooms'); } else { $jhotelreservation_rooms = 1; } } if (strlen($jhotelreservation_guest_adult) == 0) { if (JRequest::getVar('guest_adult') != '') {
/** * Method to get applicationsettings * @return object with data */ function &getData() { // Load the data if (empty($this->_data)) { $query = ' SELECT * FROM #__hotelreservation_hotels' . ' WHERE hotel_id = ' . $this->_hotel_id; $this->_db->setQuery($query); $this->_data = $this->_db->loadObject(); //dmp($this->_data); } if (!$this->_data) { $row = $this->getTable('hotels'); $properties = $row->getProperties(1); $this->_data = JArrayHelper::toObject($properties, 'JObject'); //~check temporary files $this->_data->pictures = array(); $this->_data->facilities = array(); $this->_data->selectedFacilities = array(); $this->_data->types = array(); $this->_data->selectedTypes = array(); $this->_data->accommodationTypes = array(); $this->_data->selectedAccommodationTypes = array(); $this->_data->environments = array(); $this->_data->selectedEnvironments = array(); $this->_data->regions = array(); $this->_data->selectedRegions = array(); $this->_data->selectedPaymentOptions = null; } else { //get pictures $query = "SELECT *\n\t\t\t\t\tFROM #__hotelreservation_hotel_pictures\n\t\t\t\t\tWHERE hotel_id =" . $this->_data->hotel_id . "\n\t\t\t\t\tORDER BY hotel_picture_id "; // dmp($query); //$this->_db->setQuery( $query ); $files = $this->_getList($query); $this->_data->pictures = array(); foreach ($files as $value) { $this->_data->pictures[] = array('hotel_picture_info' => $value->hotel_picture_info, 'hotel_picture_path' => $value->hotel_picture_path, 'hotel_picture_enable' => $value->hotel_picture_enable); } } //convert date format $this->_data->start_date = JHotelUtil::convertToFormat($this->_data->start_date); $this->_data->end_date = JHotelUtil::convertToFormat($this->_data->end_date); $query = 'SELECT * FROM #__hotelreservation_countries ORDER BY country_name'; $this->_data->countries = $this->_getList($query); $query = 'SELECT * FROM #__hotelreservation_hotel_facilities ORDER BY name'; $this->_data->facilities = $this->_getList($query); $query = 'SELECT * FROM #__hotelreservation_hotel_facility_relation where hotelId = ' . $this->_data->hotel_id; if (isset($this->_data->hotel_id)) { $this->_data->selectedFacilities = $this->_getList($query); } $query = 'SELECT * FROM #__hotelreservation_hotel_types ORDER BY name'; $this->_data->types = $this->_getList($query); $query = 'SELECT * FROM #__hotelreservation_hotel_type_relation where hotelId =' . $this->_data->hotel_id; if (isset($this->_data->hotel_id)) { $this->_data->selectedTypes = $this->_getList($query); } $query = 'SELECT * FROM #__hotelreservation_hotel_accommodation_types ORDER BY name'; $this->_data->accommodationTypes = $this->_getList($query); $query = 'SELECT * FROM #__hotelreservation_hotel_accommodation_type_relation where hotelId =' . $this->_data->hotel_id; if (isset($this->_data->hotel_id)) { $this->_data->selectedAccommodationTypes = $this->_getList($query); } $query = 'SELECT * FROM #__hotelreservation_hotel_environments ORDER BY name'; $this->_data->environments = $this->_getList($query); $query = 'SELECT * FROM #__hotelreservation_hotel_environment_relation where hotelId=' . $this->_data->hotel_id; if (isset($this->_data->hotel_id)) { $this->_data->selectedEnvironments = $this->_getList($query); } $query = 'SELECT * FROM #__hotelreservation_hotel_regions ORDER BY name'; $this->_data->regions = $this->_getList($query); $query = 'SELECT * FROM #__hotelreservation_hotel_region_relation where hotelId=' . $this->_data->hotel_id; if (isset($this->_data->hotel_id)) { $this->_data->selectedRegions = $this->_getList($query); } $query = 'SELECT * FROM #__hotelreservation_hotel_payment_options ORDER BY name'; $this->_data->paymentOptions = $this->_getList($query); $query = 'SELECT * FROM #__hotelreservation_hotel_payment_option_relation where hotelId=' . $this->_data->hotel_id; if (isset($this->_data->hotel_id)) { $this->_data->selectedPaymentOptions = $this->_getList($query); } $query = 'SELECT * FROM #__hotelreservation_hotel_channel_manager where hotel_id = ' . $this->_data->hotel_id; if (isset($this->_data->hotel_id)) { $channelManagers = $this->_getList($query); } $channelManagersArray = array(); if (isset($channelManagers) && count($channelManagers) > 0) { foreach ($channelManagers as $channelManager) { $channelManagersArray[$channelManager->service] = $channelManager; } } $this->_data->channelManagers = $channelManagersArray; $query = ' SELECT currency_id, description FROM #__hotelreservation_currencies'; $this->_data->currencies = $this->_getList($query); $informationsTable = $this->getTable('ManageHotelInformations'); $properties = $informationsTable->getProperties(1); $this->_data->informations = JArrayHelper::toObject($properties, 'JObject'); if (isset($this->_data->hotel_id)) { $this->_data->informations = $informationsTable->getHotelInformations($this->_data->hotel_id); } $contactTable = $this->getTable('HotelContact'); $properties = $contactTable->getProperties(1); $this->_data->contact = JArrayHelper::toObject($properties, 'JObject'); if (isset($this->_data->hotel_id)) { $this->_data->contact = $contactTable->getHotelContacts($this->_data->hotel_id); } return $this->_data; }
function &getData() { // Load the data if (empty($this->_data)) { $query = ' SELECT d.*, GROUP_CONCAT( r.room_name ORDER BY r.room_name ) AS discount_rooms FROM #__hotelreservation_discounts d' . ' LEFT JOIN #__hotelreservation_rooms r ON FIND_IN_SET(r.room_id, d.discount_room_ids)' . ' WHERE discount_id = ' . $this->discount_id . ' GROUP BY discount_id'; $this->_db->setQuery($query); $this->_data = $this->_db->loadObject(); } if (!$this->_data) { $this->_data = new stdClass(); $this->_data->discount_id = null; $this->_data->hotel_id = null; $this->_data->discount_name = null; $this->_data->discount_room_ids = null; $this->_data->discount_datas = gmdate('Y-m-d'); $this->_data->discount_datae = gmdate('Y-m-d'); $this->_data->discount_value = null; $this->_data->percent = 0; $this->_data->is_available = null; $this->_data->minimum_number_persons = null; $this->_data->minimum_number_days = null; $this->_data->minimum_amount = null; $this->_data->maximum_number_days = null; $this->_data->code = null; $this->_data->offer_ids = null; $this->_data->excursion_ids = null; $this->_data->only_on_offers = 0; $this->_data->price_type = 0; $this->_data->check_full_code = 0; } $query = " \tSELECT \r\n\t\t\t\t\t\tr.room_id,\r\n\t\t\t\t\t\tr.room_name\t,\r\n\t\t\t\t\t\tIF( ISNULL(d.discount_id), 0, 1)\t\tAS is_sel\t\t\t\t\t\t\t\r\n\t\t\t\t\tFROM #__hotelreservation_rooms r\r\n\t\t\t\t\tLEFT JOIN \r\n\t\t\t\t\t( \t\r\n\t\t\t\t\t\tSELECT * FROM #__hotelreservation_discounts WHERE discount_id = " . $this->discount_id . " \r\n\t\t\t\t\t) d ON FIND_IN_SET(r.room_id, d.discount_room_ids) \r\n\t\t\t\t\tWHERE r.is_available = 1 AND r.hotel_id = " . $this->_hotel_id . "\r\n\t\t\t\t\t"; // dmp($query); $this->_data->itemRooms = $this->_getList($query); $query = "\t\r\n\t\t \t\tselect o.offer_id, o.offer_name\t \r\n\t\t \t\tfrom #__hotelreservation_rooms r\r\n\t\t\t\tinner join #__hotelreservation_offers_rooms \t\t\thor \tON hor.room_id\t \t= r.room_id\r\n\t\t\t\tinner join #__hotelreservation_offers\t\t \t\t\to \t\tON hor.offer_id \t= o.offer_id\r\n\t\t\t\twhere FIND_IN_SET(r.room_id,\r\n\t\t\t\t(\r\n\t\t\t\t SELECT discount_room_ids FROM #__hotelreservation_discounts WHERE discount_id = {$this->discount_id}\r\n\t\t\t\t))\r\n\t\t\t"; $this->_data->offers = $this->_getList($query); $selectedOffers = $this->_data->offer_ids; //dmp($selectedOffers); if (isset($selectedOffers)) { $selectedOffers = explode(",", $selectedOffers); foreach ($this->_data->offers as &$offer) { $offer->is_sel = 0; if (in_array($offer->offer_id, $selectedOffers)) { $offer->is_sel = 1; } } } $query = " \tSELECT \r\n\t\t\t\t\t\tr.id,\r\n\t\t\t\t\t\tr.name as excursion_name\t,\r\n\t\t\t\t\t\tIF( ISNULL(d.discount_id), 0, 1)\t\tAS is_sel\t\t\t\t\t\t\t\r\n\t\t\t\t\tFROM #__hotelreservation_excursions r\r\n\t\t\t\t\tLEFT JOIN \r\n\t\t\t\t\t( \t\r\n\t\t\t\t\t\tSELECT * FROM #__hotelreservation_discounts WHERE discount_id = " . $this->discount_id . " \r\n\t\t\t\t\t) d ON FIND_IN_SET(r.id, d.excursion_ids) \r\n\t\t\t\t\tWHERE r.is_available = 1 AND r.hotel_id = " . $this->_hotel_id . "\r\n\t\t\t\t\t"; $this->_data->excursions = $this->_getList($query); //dmp($this->_db->getErrorMsg()); //exit; $this->_data->discount_datas = JHotelUtil::convertToFormat($this->_data->discount_datas); $this->_data->discount_datae = JHotelUtil::convertToFormat($this->_data->discount_datae); return $this->_data; }