function save() { $model = $this->getModel('manageemailsdefault'); $post = JRequest::get('post'); $post['email_default_content'] = JRequest::getVar('email_default_content', '', 'post', 'string', JREQUEST_ALLOWRAW); $task = $this->getTask(); if (JHotelUtil::checkIndexKey('#__hotelreservation_emails_default', array('email_default_name' => $post['email_default_name']), 'email_default_id', $post['email_default_id'])) { $msg = ''; JError::raiseWarning(500, JText::_('LNG_EMAIL_NAME_EXISTENT', true)); $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=manageemailsdefault&view=manageemailsdefault&task=add', ''); } else { if ($model->store($post)) { $post["default_email_id"] = $model->_default_email_id; $model->saveEmailContent($post); } else { $msg = ""; JError::raiseWarning(500, JText::_('LNG_ERROR_SAVING_EMAIL', true)); $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=manageemailsdefault&view=manageemailsdefault', ''); } } switch ($task) { case 'apply': // Set the row data in the session. $msg = JText::_('LNG_EMAIL_SAVED', true); $this->setRedirect('index.php?option=' . getBookingExtName() . '&task=manageemailsdefault.edit&email_default_id[]=' . $model->_default_email_id, $msg); break; default: $msg = JText::_('LNG_EMAIL_SAVED', true); // Redirect to the list screen. $this->setRedirect('index.php?option=' . getBookingExtName() . '&task=manageemailsdefault.show', $msg); break; } // Check the table in so it can be edited.... we are done with it anyway }
/** * save a record (and redirect to main page) * @return void */ function save() { $model = $this->getModel('manageroomdiscounts'); $post = JRequest::get('post'); if (!isset($post['hotel_id'])) { $post['hotel_id'] = 0; } $post['discount_room_ids'] = implode(',', $post['discount_room_ids']); $post['offer_ids'] = implode(',', $post['offer_ids']); $post['excursion_ids'] = implode(',', $post['excursion_ids']); if (JHotelUtil::checkIndexKey('#__hotelreservation_discounts', array('hotel_id' => $post['hotel_id'], 'discount_name' => $post['discount_name']), 'discount_id', $post['discount_id'])) { $msg = ''; JError::raiseWarning(500, JText::_('LNG_DISCOUNT_PERIOD_INTERSECT', true)); $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=manageroomdiscounts&view=manageroomdiscounts&task=add&hotel_id=' . $post['hotel_id'], ''); } else { if ($model->store($post)) { $msg = JText::_('LNG_DISCOUNT_SAVED', true); $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=manageroomdiscounts&view=manageroomdiscounts&hotel_id=' . $post['hotel_id'], $msg); } else { $msg = ""; JError::raiseWarning(500, JText::_('LNG_ERROR_SAVING_DISCOUNT', true)); $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=manageroomdiscounts&view=manageroomdiscounts&hotel_id=' . $post['hotel_id'], ''); } } // Check the table in so it can be edited.... we are done with it anyway }
function saveHotel() { $model = $this->getModel('hotel'); $post = JRequest::get('post'); $post['hotel_description'] = JRequest::getVar('hotel_description', '', 'post', 'string', JREQUEST_ALLOWRAW); $post['hotel_selling_points'] = JRequest::getVar('hotel_selling_points', '', 'post', 'string', JREQUEST_ALLOWRAW); /*------------------------------------------------------------------------------------------------------------*/ /*MICOD En éste bloque estoy concatenando los rango de las edades para insertarla en tres (3) campos diferentes en la tabla (kqzro_hotelreservation_hotel_informations) de la base de datos */ $post["niños_libre_tarifas"] = $post["edad_libre_min"] . "|" . $post["edad_libre_max"] . "|" . $post["activ_desactiv_libre"]; $post["niños_tarifa_ajustada"] = $post["edad_tarifa_min"] . "|" . $post["edad_tarifa_max"] . "|" . $post["valor_tarifa_ajustada"] . "|" . $post["porcent_tarifa_ajustada"] . "|" . $post["activ_desactiv_ajust"]; $post["edad_tarifa_adult"] = $post["edad_tarifa_adult"] . "|" . $post["activ_desactiv_adult"]; /*------------------------------------------------------------------------------------------------------------*/ if (strlen($post['hotel_website']) > 1) { $post['hotel_website'] = str_replace("http://", "", $post['hotel_website']); $post['hotel_website'] = "http://" . $post['hotel_website']; } //save images $pictures = array(); foreach ($post as $key => $value) { if (strpos($key, 'hotel_picture_info') !== false || strpos($key, 'hotel_picture_path') !== false || strpos($key, 'hotel_picture_enable') !== false) { foreach ($value as $k => $v) { if (!isset($pictures[$k])) { $pictures[$k] = array('hotel_picture_info' => '', 'hotel_picture_path' => '', 'hotel_picture_enable' => 1); } $pictures[$k][$key] = $v; } } } //dmp($pictures); //exit; $post['pictures'] = $pictures; //dmp($post); //exit; $reservation_cost_val = $post['reservation_cost_val']; $reservation_cost_proc = $post['reservation_cost_proc']; $post['hotel_name'] = mysql_escape_string($post['hotel_name']); // save hotel description for each language if (JHotelUtil::checkIndexKey('#__hotelreservation_hotels', array('hotel_name' => $post['hotel_name']), 'hotel_id', $post['hotel_id'])) { $msg = JText::_('LNG_HOTEL_NAME_EXISTENT', true); JError::raiseWarning(500, $msg); //$this->setRedirect( 'index.php?option='.getBookingExtName().'&task=hotel.edit&hotel_id='.$post['hotel_id'], '' ); } else { if ($model->store($post)) { $post["hotel_id"] = $model->_hotel_id; JRequest::setVar('hotel_id', $model->_hotel_id); $this->saveHotelDescriptions($post); $msg = JText::_('LNG_HOTEL_SAVED', true); } else { $msg = ""; JError::raiseWarning(500, JText::_('LNG_ERROR_SAVING_HOTEL', true)); $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=hotels&view=hotels&task=edit&hotel_id=' . $post['hotel_id'], ''); } } return $msg; }
function saveHotel() { $model = $this->getModel('hotel'); $post = JRequest::get('post'); $post['hotel_description'] = JRequest::getVar('hotel_description', '', 'post', 'string', JREQUEST_ALLOWRAW); $post['hotel_selling_points'] = JRequest::getVar('hotel_selling_points', '', 'post', 'string', JREQUEST_ALLOWRAW); if (strlen($post['hotel_website']) > 1) { $post['hotel_website'] = str_replace("http://", "", $post['hotel_website']); $post['hotel_website'] = "http://" . $post['hotel_website']; } //save images $pictures = array(); foreach ($post as $key => $value) { if (strpos($key, 'hotel_picture_info') !== false || strpos($key, 'hotel_picture_path') !== false || strpos($key, 'hotel_picture_enable') !== false) { foreach ($value as $k => $v) { if (!isset($pictures[$k])) { $pictures[$k] = array('hotel_picture_info' => '', 'hotel_picture_path' => '', 'hotel_picture_enable' => 1); } $pictures[$k][$key] = $v; } } } //dmp($pictures); //exit; $post['pictures'] = $pictures; //dmp($post); //exit; $reservation_cost_val = $post['reservation_cost_val']; $reservation_cost_proc = $post['reservation_cost_proc']; $post['hotel_name'] = mysql_escape_string($post['hotel_name']); // save hotel description for each language if (JHotelUtil::checkIndexKey('#__hotelreservation_hotels', array('hotel_name' => $post['hotel_name']), 'hotel_id', $post['hotel_id'])) { $msg = JText::_('LNG_HOTEL_NAME_EXISTENT', true); JError::raiseWarning(500, $msg); //$this->setRedirect( 'index.php?option='.getBookingExtName().'&task=hotel.edit&hotel_id='.$post['hotel_id'], '' ); } else { if ($model->store($post)) { $post["hotel_id"] = $model->_hotel_id; JRequest::setVar('hotel_id', $model->_hotel_id); $this->saveHotelDescriptions($post); $msg = JText::_('LNG_HOTEL_SAVED', true); } else { $msg = ""; JError::raiseWarning(500, JText::_('LNG_ERROR_SAVING_HOTEL', true)); $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=hotels&view=hotels&task=edit&hotel_id=' . $post['hotel_id'], ''); } } return $msg; }
/** * save a record (and redirect to main page) * @return void */ function save() { $model = $this->getModel('paymentsettings'); $post = JRequest::get('post'); if (JHotelUtil::checkIndexKey('#__hotelreservation_paymentsettings', array('hotel_id' => $post['hotel_id'], 'payment_type_id' => $post['payment_type_id']), 'payment_id', $post['payment_id'])) { $msg = JText::_('LNG_PAYMENT_NAME_EXISTENT', true); JError::raiseWarning(500, $msg); $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=paymentsettings&view=paymentsettings&task=add&hotel_id=' . $post['hotel_id']); } else { if ($model->store($post)) { $msg = JText::_('LNG_PAYMENT_SAVED', true); $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=paymentsettings&view=paymentsettings&hotel_id=' . $post['hotel_id'], $msg); } else { $msg = JText::_('LNG_ERROR_SAVING_PAYMENT', true); //JError::raiseWarning( 500, $msg); $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=paymentsettings&view=paymentsettings&hotel_id=' . $post['hotel_id']); } } // Check the table in so it can be edited.... we are done with it anyway }
/** * save a record (and redirect to main page) * @return void */ function save() { $model = $this->getModel('manageairlines'); $post = JRequest::get('post'); $post['airline_description'] = JRequest::getVar('airline_description', '', 'post', 'string', JREQUEST_ALLOWRAW); if (JHotelUtil::checkIndexKey('#__hotelreservation_airlines', array('hotel_id' => $post['hotel_id'], 'airline_name' => $post['airline_name']), 'airline_id', $post['airline_id'])) { $msg = JText::_('LNG_AIRLINE_NAME_EXISTENT', true); JError::raiseWarning(500, $msg); $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=manageairlines&view=manageairlines&task=add&hotel_id=' . $post['hotel_id'], $msg); } else { if ($model->store($post)) { $msg = JText::_('LNG_AIRLINE_SAVED', true); $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=manageairlines&view=manageairlines&hotel_id=' . $post['hotel_id'], $msg); } else { $msg = ""; JError::raiseWarning(500, JText::_('LNG_ERROR_SAVING_AIRLINE', true)); $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=manageairlines&view=manageairlines&hotel_id=' . $post['hotel_id'], $msg); } } // Check the table in so it can be edited.... we are done with it anyway }
/** * save a record (and redirect to main page) * @return void */ function save() { $model = $this->getModel('managecurrencies'); $post = JRequest::get('post'); $post["currency_symbol"] = JRequest::getVar('currency_symbol', '', 'post', 'string', JREQUEST_ALLOWRAW); if (JHotelUtil::checkIndexKey('#__hotelreservation_currencies', array('description' => $post['description']), 'currency_id', $post['currency_id'])) { $msg = ''; JError::raiseWarning(500, JText::_('LNG_CURRENCY_NAME_EXISTENT', true)); $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managecurrencies&view=managecurrencies&task=add', $msg); } else { if ($model->store($post)) { $msg = JText::_('LNG_CURRENCY_SAVED', true); $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managecurrencies&view=managecurrencies', $msg); } else { $msg = ''; JError::raiseWarning(500, JText::_('LNG_ERROR_SAVING_CURRENCY', true)); $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managecurrencies&view=managecurrencies', $msg); } } $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managecurrencies&view=managecurrencies', $msg); }
/** * save a record (and redirect to main page) * @return void */ function save() { $model = $this->getModel('managerooms'); $post = JRequest::get('post'); $post['room_details'] = JRequest::getVar('room_details', '', 'post', 'string', JREQUEST_ALLOWRAW); $post['room_short_description'] = JRequest::getVar('room_short_description', '', 'post', 'string', JREQUEST_ALLOWRAW); $post['room_main_description'] = JRequest::getVar('room_main_description', '', 'post', 'string', JREQUEST_ALLOWRAW); $option_ids = array(); $pictures = array(); $room_intervals_numbers['nrs'] = array(); $room_intervals_numbers['nre'] = array(); $room_intervals_numbers['is_ignore_duplicate'] = array(); $room_intervals_numbers['datas'] = array(); $room_intervals_numbers['datae'] = array(); $room_intervals_numbers['datai'] = array(); foreach ($post as $key => $value) { if (strpos($key, 'option_ids') !== false) { foreach ($value as $v) { $option_ids[] = $v; } } else { if (strpos($key, 'room_picture_info') !== false || strpos($key, 'room_picture_path') !== false || strpos($key, 'room_picture_enable') !== false) { foreach ($value as $k => $v) { if (!isset($pictures[$k])) { $pictures[$k] = array('room_picture_info' => '', 'room_picture_path' => '', 'room_picture_enable' => 1); } $pictures[$k][$key] = $v; } } else { if (strpos($key, 'room_number_start_') !== false) { $room_intervals_numbers['nrs'][] = $value; } else { if (strpos($key, 'room_number_stop_') !== false) { $room_intervals_numbers['nre'][] = $value; } else { if (strpos($key, 'is_ignore_duplicate_') !== false) { $room_intervals_numbers['is_ignore_duplicate'][] = $value; /* foreach( $value as $v ) { if( $v != '' && is_numeric($v) ) $room_intervals_numbers['nre'][] = $v+0; } */ } else { if (strpos($key, 'room_number_datas_') !== false) { // foreach( $value as $v ) // { // if( $v != '' && is_numeric($v) ) // $room_intervals_numbers['datas'][] = $v+0; // } $room_intervals_numbers['datas'][] = $value; } else { if (strpos($key, 'room_number_datae_') !== false) { // foreach( $value as $v ) // { // if( $v != '' && is_numeric($v) ) // $room_intervals_numbers['datae'][] = $v+0; // } $room_intervals_numbers['datae'][] = $value; } else { if (strpos($key, 'room_number_datai_') !== false) { // foreach( $value as $v ) // { // if( $v != '' && is_numeric($v) ) // $room_intervals_numbers['datai'][] = $v+0; // } $room_intervals_numbers['datai'][] = $value; } } } } } } } } } //clean all necessary $c = count($room_intervals_numbers['nrs']); foreach ($room_intervals_numbers['nrs'] as $i => $valTmp) { if ($room_intervals_numbers['nrs'][$i] == '' && $room_intervals_numbers['nre'][$i] == '') { unset($room_intervals_numbers['nrs'][$i]); unset($room_intervals_numbers['nre'][$i]); unset($room_intervals_numbers['is_ignore_duplicate'][$i]); unset($room_intervals_numbers['datas'][$i]); unset($room_intervals_numbers['datae'][$i]); unset($room_intervals_numbers['datai'][$i]); continue; } } //clean all necessary //dmp($room_intervals_numbers); $numbers = array(); $numbers_2_check = array(); $datai = array(); $room_prices = array(); if (count($room_intervals_numbers['nrs']) > 0) { $c = count($room_intervals_numbers['nrs']); for ($i = 0; $i < $c; $i++) { if ($room_intervals_numbers['nrs'][$i] > $room_intervals_numbers['nre'][$i]) { continue; } for ($d = $room_intervals_numbers['nrs'][$i]; $d <= $room_intervals_numbers['nre'][$i]; $d++) { $numbers[] = $d; if ($room_intervals_numbers['is_ignore_duplicate'][$i] == 0) { $numbers_2_check[] = $d; } $datai[$d] = $room_intervals_numbers['datai'][$i]; } } } $daysWeek = array("", "LNG_MON", "LNG_TUE", "LNG_WED", "LNG_THU", "LNG_FRI", "LNG_SAT", "LNG_SUN"); foreach ($room_prices as $keyPret => $valuesDays) { foreach ($valuesDays as $day) { $post["room_price_{$day}"] = $keyPret; unset($daysWeek[$day]); } } // dmp($numbers_2_check); // exit; // dmp($room_intervals_numbers['nrs']); // dmp($room_intervals_numbers['nre']); $post['option_ids'] = $option_ids; $post['pictures'] = $pictures; $post['room_prices'] = $room_prices; $post['room_intervals_numbers'] = $room_intervals_numbers; $post['numbers'] = $numbers; $post['numbers_2_check'] = $numbers_2_check; $post['datai'] = $datai; $post['room_order'] = $this->getLastRoom($post); if (JHotelUtil::checkIndexKey('#__hotelreservation_rooms', array('room_name' => $post['room_name'], 'hotel_id' => $post['hotel_id']), 'room_id', $post['room_id'])) { $msg = ''; JError::raiseWarning(500, JText::_('LNG_ROOM_NAME_EXISTENT', true)); //$this->setRedirect( 'index.php?option='.getBookingExtName().'&controller=managerooms&view=managerooms', $msg ); } else { if ($post['type_price'] == 0 && (!is_numeric($post["room_price_1"]) || $post["room_price_1"] == 0 || (!is_numeric($post["room_price_2"]) || $post["room_price_2"] == 0) || (!is_numeric($post["room_price_3"]) || $post["room_price_3"] == 0) || (!is_numeric($post["room_price_4"]) || $post["room_price_4"] == 0) || (!is_numeric($post["room_price_5"]) || $post["room_price_5"] == 0) || (!is_numeric($post["room_price_6"]) || $post["room_price_6"] == 0) || (!is_numeric($post["room_price_7"]) || $post["room_price_7"] == 0))) { JError::raiseWarning(500, JText::_('LNG_ERROR_PRICE_DAY_BY_DAY', true)); } else { if ($post['type_price'] == 1 && (!is_numeric($post["room_price"]) || $post["room_price"] == 0)) { JError::raiseWarning(500, JText::_('LNG_ERROR_PRICE_SAME_EVERY_DAY', true)); } else { if ($post['type_price'] == 2 && (!is_numeric($post["room_price_midweek"]) || $post["room_price_midweek"] == 0 || (!is_numeric($post["room_price_weekend"]) || $post["room_price_weekend"] == 0))) { JError::raiseWarning(500, JText::_('LNG_ERROR_PRICE_MIDDWEEK_WEEKEND', true)); } else { if (!$model->validNumbers($post['room_intervals_numbers'], $msg)) { JError::raiseWarning(500, $msg); //$this->setRedirect( 'index.php?option='.getBookingExtName().'&controller=managerooms&view=managerooms&task=add&is_error_save=1&room_id[]='.$post['room_id'], ''); } else { if (count($post['numbers']) != $post['number_of_rooms']) { $msg = ''; JError::raiseWarning(500, JText::_('LNG_ERROR_COUNT_NR_ROOM_VS_NUMBERS', true)); //$this->setRedirect( 'index.php?option='.getBookingExtName().'&controller=managerooms&view=managerooms', '' ); } else { if ($model->checkDuplicateNumbers($post['numbers'], $msg)) { JError::raiseWarning(500, $msg); //$this->setRedirect( 'index.php?option='.getBookingExtName().'&controller=managerooms&view=managerooms', '' ); } else { if (JHotelUtil::checkIndexKey('#__hotelreservation_rooms', array('hotel_id' => $post['hotel_id'], 'room_name' => $post['room_name']), 'room_id', $post['room_id'])) { $msg = ''; JError::raiseWarning(500, JText::_('LNG_ROOM_NAME_EXISTENT', true)); // $this->setRedirect( 'index.php?option='.getBookingExtName().'&controller=managerooms&view=managerooms&hotel_id='.$post['hotel_id'], $msg ); } else { if (!$model->checkNumbers($post['hotel_id'], $post['room_id'], $post['numbers_2_check'], $msg)) { JError::raiseWarning(500, $msg); //$this->setRedirect( 'index.php?option='.getBookingExtName().'&controller=managerooms&view=managerooms', '' ); } else { if ($post['room_id'] != "" && !$model->checkNumbersUnAssigned2Reservation($post['hotel_id'], $post['room_id'], $post['numbers'], $msg)) { JError::raiseWarning(500, $msg); //$this->setRedirect( 'index.php?option='.getBookingExtName().'&controller=managerooms&view=managerooms', '' ); } else { if ($model->store($post)) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::_('LNG_ROOM_SAVED', true)); $post["room_id"] = $model->_room_id; $this->saveRoomDescriptions($post); if (JRequest::getVar('task') == 'apply') { $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managerooms&view=managerooms&task=edit&hotel_id=' . $post['hotel_id'] . '&room_id[]=' . $model->_room_id, $msg); } else { $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managerooms&view=managerooms&hotel_id=' . $post['hotel_id'], $msg); } } else { $msg = ""; JError::raiseWarning(500, JText::_('LNG_ERROR_SAVING_ROOM', true)); //$this->setRedirect( 'index.php?option='.getBookingExtName().'&controller=managerooms&view=managerooms&hotel_id='.$post['hotel_id'], '' ); } } } } } } } } } } } }