/**
  * save a record (and redirect to main page)
  * @return void
  */
 function save()
 {
     $model = $this->getModel('manageroomfeatures');
     $post = JRequest::get('post');
     if (checkIndexKey('#__hotelreservation_room_features', array('feature_name' => $post['feature_name']), 'feature_id', $post['feature_id'])) {
         $msg = '';
         JError::raiseWarning(500, JText::_('LNG_FEATURE_ROOM_NAME_EXISTENT', true));
         $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=manageroomfeatures&view=manageroomfeatures&task=add', $msg);
     } else {
         if ($model->store($post)) {
             $msg = JText::_('LNG_FEATURE_ROOM_SAVED', true);
             $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=manageroomfeatures&view=manageroomfeatures', $msg);
         } else {
             $msg = "";
             JError::raiseWarning(500, JText::_('LNG_ERROR_SAVING_FEATURE_ROOM', true));
             $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=manageroomfeatures&view=manageroomfeatures', $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('managearrivaloptions');
     $post = JRequest::get('post');
     $post['arrival_option_description'] = JRequest::getVar('arrival_option_description', '', 'post', 'string', JREQUEST_ALLOWRAW);
     if (checkIndexKey('#__hotelreservation_arrival_options', array('hotel_id' => $post['hotel_id'], 'arrival_option_name' => $post['arrival_option_name']), 'arrival_option_id', $post['arrival_option_id'])) {
         $msg = JText::_('LNG_ARRIVAL_OPTION_NAME_EXISTENT', true);
         JError::raiseWarning(500, $msg);
         $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managearrivaloptions&view=managearrivaloptions&task=add&hotel_id=' . $post['hotel_id'], $msg);
     } else {
         if ($model->store($post)) {
             $msg = JText::_('LNG_ARRIVAL_OPTION_SAVED', true);
             $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managearrivaloptions&view=managearrivaloptions&hotel_id=' . $post['hotel_id'], $msg);
         } else {
             $msg = "";
             JError::raiseWarning(500, JText::_('LNG_ERROR_SAVING_ARRIVAL_OPTIONS', true));
             $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managearrivaloptions&view=managearrivaloptions&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('managepackages');
     $post = JRequest::get('post');
     if (!isset($post['is_price_day'])) {
         $post['is_price_day'] = false;
     }
     $post['package_description'] = JRequest::getVar('package_description', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $package_prices = array();
     /*
      foreach( $post[ 'package_price_day'] as $keyPos => $valPrice )
     {
     for( $day = 1; $day <=7;$day ++ )
     {
     //dbg( 'price_day_'.$keyPos.'_'.($day) );
     if( isset( $post[ 'day_'.$keyPos.'_'.($day) ] ) )
     $package_prices[ $valPrice ][] = $day;
     }
     }
     */
     $daysWeek = array("", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN");
     foreach ($package_prices as $keyPret => $valuesDays) {
         foreach ($valuesDays as $day) {
             $post["package_price_{$day}"] = $keyPret;
             unset($daysWeek[$day]);
         }
     }
     $post['package_prices'] = $package_prices;
     if (checkIndexKey('#__hotelreservation_packages', array('hotel_id' => $post['hotel_id'], 'package_name' => $post['package_name']), 'package_id', $post['package_id'])) {
         $msg = '';
         JError::raiseWarning(500, JText::_('LNG_PACKAGE_NAME_EXISTENT', true));
         $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managepackages&view=managepackages&task=add&hotel_id=' . $post['hotel_id'], $msg);
     } else {
         if ($post['package_type_price'] == 0 && (!is_numeric($post["package_price_1"]) || $post["package_price_1"] == 0 || (!is_numeric($post["package_price_2"]) || $post["package_price_2"] == 0) || (!is_numeric($post["package_price_3"]) || $post["package_price_3"] == 0) || (!is_numeric($post["package_price_4"]) || $post["package_price_4"] == 0) || (!is_numeric($post["package_price_5"]) || $post["package_price_5"] == 0) || (!is_numeric($post["package_price_6"]) || $post["package_price_6"] == 0) || (!is_numeric($post["package_price_7"]) || $post["package_price_7"] == 0))) {
             JError::raiseWarning(500, JText::_('LNG_ERROR_PRICE_DAY_BY_DAY', true));
         } else {
             if ($post['package_type_price'] == 1 && (!is_numeric($post["package_price"]) || $post["package_price"] == 0)) {
                 JError::raiseWarning(500, JText::_('LNG_ERROR_PRICE_SAME_EVERY_DAY', true));
             } else {
                 if ($post['package_type_price'] == 2 && (!is_numeric($post["package_price_midweek"]) || $post["package_price_midweek"] == 0 || (!is_numeric($post["package_price_weekend"]) || $post["package_price_weekend"] == 0))) {
                     JError::raiseWarning(500, JText::_('LNG_ERROR_PRICE_MIDDWEEK_WEEKEND', true));
                 } else {
                     if (strlen($post['package_description']) == 0) {
                         JError::raiseWarning(500, JText::_('LNG_PLEASE_INSERT_DESCRIPTION_PACKAGE', true));
                     } else {
                         if (strlen($post['package_datas']) > 0 && strlen($post['package_datae']) > 0 && strtotime($post['package_datas']) > strtotime($post['package_datae'])) {
                             JError::raiseWarning(500, JText::_('LNG_ERROR_PERIOD_PACKAGE_DATES', true));
                         } else {
                             if ($model->store($post)) {
                                 $msg = JText::_('LNG_PACKAGE_SAVED', true);
                                 $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managepackages&view=managepackages&hotel_id=' . $post['hotel_id'], $msg);
                             } else {
                                 $msg = "";
                                 JError::raiseWarning(500, JText::_('LNG_ERROR_SAVING_PACKAGE', true));
                                 $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managepackages&view=managepackages&hotel_id=' . $post['hotel_id'], $msg);
                             }
                         }
                     }
                 }
             }
         }
     }
     // Check the table in so it can be edited.... we are done with it anyway
 }