public function postProcess() { if (Tools::getValue('error')) { if (Tools::getValue('error') == 1) { $msg = Tools::displayError('Parent feature name is required.'); } else { if (Tools::getValue('error') == 2) { $msg = Tools::displayError('Position is required.'); } else { if (Tools::getValue('error') == 3) { $msg = Tools::displayError('Please add atleast one Child features are required.'); } else { if (Tools::getValue('error') == 4) { $msg = Tools::displayError('Some error occured. Please try again.'); } else { if (Tools::getValue('error') == 2) { $msg = Tools::displayError('Position is required.'); } } } } } $this->errors[] = Tools::displayError($msg); $this->context->smarty->assign("errors", $this->errors); } if (Tools::isSubmit('submit_add_btn_feature')) { $parent_feature = Tools::getValue('parent_ftr'); $child_features = Tools::getValue('child_featurs'); $pos = Tools::getValue('position'); if (!$parent_feature) { $error = 1; } else { if (!$pos) { $error = 2; } else { if (!$child_features) { $error = 3; } } } if (!isset($error)) { $obj_feature = new HotelFeatures(); $obj_feature->name = $parent_feature; $obj_feature->active = 1; $obj_feature->position = $pos; $obj_feature->parent_feature_id = 0; $obj_feature->save(); $parent_feature_id = $obj_feature->id; if ($parent_feature_id) { if ($child_features) { foreach ($child_features as $val) { $obj_feature = new HotelFeatures(); $obj_feature->name = $this->l($val); $obj_feature->active = 1; $obj_feature->parent_feature_id = $parent_feature_id; $obj_feature->save(); } Tools::redirectAdmin(self::$currentIndex . '&add' . $this->table . '&token=' . $this->token . '&addfeatures=1'); } } else { Tools::redirectAdmin(self::$currentIndex . '&error=4&add' . $this->table . '&token=' . $this->token . '&addfeatures=1'); } } else { Tools::redirectAdmin(self::$currentIndex . '&error=' . $error . '&add' . $this->table . '&token=' . $this->token . '&addfeatures=1'); } } if (Tools::isSubmit('submit_edit_btn_feature')) { $chld_features_form = Tools::getValue('child_featurs'); $parent_ftr = Tools::getValue('parent_ftr'); $position = Tools::getValue('position'); $prnt_ftr_id = Tools::getValue('parent_ftr_id'); if (!$parent_ftr) { $error = 1; } else { if (!$position) { $error = 2; } else { if (!$chld_features_form) { $error = 3; } } } if (!isset($error)) { $update_prnt_ftr = Db::getInstance()->update('htl_features', array('name' => $parent_ftr, 'position' => $position), 'id=' . $prnt_ftr_id); $child_features_data = Db::getInstance()->executeS('SELECT id FROM `' . _DB_PREFIX_ . 'htl_features` WHERE parent_feature_id=' . (int) $prnt_ftr_id); if ($child_features_data) { $i = 0; foreach ($child_features_data as $val) { $flag = 0; foreach ($chld_features_form as $value) { if (is_numeric($value)) { if ($val['id'] == $value) { $flag = 1; } } else { if ($i == 0) { $obj_feature = new HotelFeatures(); $obj_feature->name = $value; $obj_feature->active = 1; $obj_feature->parent_feature_id = $prnt_ftr_id; $obj_feature->save(); } } } if (!$flag) { $del_arr[] = $val['id']; } $i++; } if (isset($del_arr) && $del_arr) { foreach ($del_arr as $value) { $delete_ftr = Db::getInstance()->delete('htl_features', 'id=' . $value); } } Tools::redirectAdmin(self::$currentIndex . '&add' . $this->table . '&token=' . $this->token . '&addfeatures=1'); } else { Tools::redirectAdmin(self::$currentIndex . '&error=4&add' . $this->table . '&token=' . $this->token . '&addfeatures=1'); } } else { Tools::redirectAdmin(self::$currentIndex . '&error=' . $error . '&add' . $this->table . '&token=' . $this->token . '&addfeatures=1'); } } parent::postProcess(); }
public function insertHotelCommonFeatures() { $parent_features_arr = array('Business Services' => array('Business Center', 'Audio-Visual Equipment', 'Board room', 'Conference Facilities', 'Secretaial Services', 'Fax Machine', 'Internet Access'), 'Complementry' => array('Internet Access Free', 'Transfer Available', 'NewsPaper In Lobby', 'Shopping Drop Facility', 'Welcome Drinks'), 'Entertainment' => array('DiscoTheatre', 'Casino', ' Amphitheatre', 'Dance Performances(On Demand)', 'Karoke', 'Mini Theatre', 'Night Club'), 'Facilities' => array('Laundary Service', 'Power BackUp', 'ATM/Banking', 'Currency Exchange', 'Dry Cleaning', 'Library', 'Doctor On Call', 'Party Hall', 'Yoga Hall', 'Pets Allowed', 'Kids Play Zone', 'Wedding Services Facilities', 'Fire Place Available'), 'General Services' => array('Room Service', 'Cook Service', 'Car Rental', 'Door Man', 'Grocery', 'Medical Assistance', 'Postal Services', 'Spa Services', 'Multilingual Staff'), 'Indoors' => array('Parking', 'Solarium', 'Veranda'), 'Internet' => array('Internet Access-Surcharge', 'Internet / Fax (Reception area only)'), 'Outdoors' => array('Gardens', 'Outdoor Parking - Secured', 'Barbecue AreaCampfire / Bon Fire', 'Childrens Park', 'Fishing', 'Golf Course', 'Outdoor Parking - Non Secured', 'Private Beach', 'Rooftop Garden'), 'Parking' => array('Parking (Surcharge)', 'Parking Facilities Available', 'Valet service'), 'Sports And Recreation' => array('Health Club / Gym Facility Available', 'Bike on Rent', 'Badminttion Court', 'Basketball Court', 'Billiards', 'Boating', 'Bowling', 'Camel Ride', 'Clubhouse', 'Fitness Equipment', 'Fun Floats', 'Games Zone', 'Horse Ride ( Chargeable )', 'Marina On Site', 'Nature Walk', 'Pool Table', 'Safari', 'Skiing Facility', 'Available Spa Services', 'NearbySquash court', 'Table Tennis', 'Tennis Court', 'Virtual Golf'), 'Water Amenites' => array('Swimming Pool', 'Jacuzzi', 'Private / Plunge Pool', 'Sauna', 'Whirlpool Bath / Shower Cubicle'), 'Wine And Dine' => array('Bar / Lounge', 'Multi Cuisine Restaurant', 'Catering', 'Coffee Shop / Cafe', 'Food Facility', 'Hookah Lounge', 'Kitchen available (home cook food on request)', 'Open Air Restaurant / Dining', 'Pool Cafe', 'Poolside Bar', 'Restaurant Veg / Non Veg Kitchens Separate', 'Vegetarian Food / Jain Food Available')); $i = 1; foreach ($parent_features_arr as $key => $value) { $obj_feature = new HotelFeatures(); $obj_feature->name = $this->l($key); $obj_feature->active = 1; $obj_feature->position = $i; $obj_feature->parent_feature_id = 0; $obj_feature->save(); $parent_feature_id = $obj_feature->id; foreach ($value as $val) { $obj_feature = new HotelFeatures(); $obj_feature->name = $this->l($val); $obj_feature->active = 1; $obj_feature->parent_feature_id = $parent_feature_id; $obj_feature->save(); } $i++; } return true; }