function remove() { $cids = JRequest::getVar('room_id', array(0), 'post', 'array'); try { $query = " \tSELECT \r\n\t\t\t\t\t\t\t* \r\n\t\t\t\t\t\tFROM #__hotelreservation_confirmations\t\t\t\tc\r\n\t\t\t\t\t\tINNER JOIN #__hotelreservation_confirmations_rooms\thr USING( confirmation_id )\r\n\t\t\t\t\t\tWHERE \r\n\t\t\t\t\t\t\thr.room_id IN (" . implode(',', $cids) . ") AND c.reservation_status NOT IN (" . CANCELED_ID . ", " . CHECKEDOUT_ID . " )\r\n\t\t\t\t\t\t"; $checked_records = $this->_getList($query); if (count($checked_records) > 0) { JError::raiseWarning(500, JText::_('LNG_SKIP_ROOM_REMOVE', true)); return false; } $query = "START TRANSACTION"; $this->_db->setQuery($query); $this->_db->queryBatch(); if (count($cids)) { foreach ($cids as $cid) { $query = " DELETE FROM #__hotelreservation_rooms WHERE room_id = " . $cid; $this->_db->setQuery($query); if (!$this->_db->query()) { throw new Exception($this->_db->getErrorMsg()); } $query = " DELETE FROM #__hotelreservation_rooms_intervals_numbers WHERE room_id = " . $cid; $this->_db->setQuery($query); if (!$this->_db->query()) { throw new Exception($this->_db->getErrorMsg()); } $query = " DELETE FROM #__hotelreservation_rooms_numbers WHERE room_id = " . $cid; $this->_db->setQuery($query); if (!$this->_db->query()) { throw new Exception($this->_db->getErrorMsg()); } $query = " DELETE FROM #__hotelreservation_rooms_pictures WHERE room_id = " . $cid; $this->_db->setQuery($query); if (!$this->_db->query()) { throw new Exception($this->_db->getErrorMsg()); } $query = " DELETE FROM #__hotelreservation_rooms_numbers_date_ignored WHERE room_id = " . $cid; $this->_db->setQuery($query); if (!$this->_db->query()) { throw new Exception($this->_db->getErrorMsg()); } $query = " DELETE FROM #__hotelreservation_rooms_seasons WHERE room_id = " . $cid; $this->_db->setQuery($query); if (!$this->_db->query()) { throw new Exception($this->_db->getErrorMsg()); } $query = " DELETE FROM #__hotelreservation_rooms_seasons_date_ignored WHERE room_id = " . $cid; $this->_db->setQuery($query); if (!$this->_db->query()) { throw new Exception($this->_db->getErrorMsg()); } if (is_dir(JPATH_COMPONENT . PATH_ROOM_PICTURES . $cid)) { $files = glob(JHotelUtil::makePathFile(JPATH_COMPONENT . PATH_ROOM_PICTURES . $cid . "/" . "*.*")); foreach ($files as $pic) { if (!@unlink($pic)) { throw new Exception($this->_db->getErrorMsg()); } } if (!@rmdir(JPATH_COMPONENT . PATH_ROOM_PICTURES . $cid)) { throw new Exception($this->_db->getErrorMsg()); } } } } $query = "COMMIT"; $this->_db->setQuery($query); $this->_db->queryBatch(); } catch (Exception $ex) { // dmp($ex); // exit; $query = "ROLLBACK"; $this->_db->setQuery($query); $this->_db->queryBatch(); $msg = JText::_('LNG_ERROR_DELETE_ROOM', true); return false; } return true; }
if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { echo "filename: $file : filetype: " . filetype($dir . $file) . "\n"; } closedir($dh); } } */ } else { //dmp('Am '.$dir); } $_target_tmp .= $e . DIRECTORY_SEPARATOR; } if ($is_error == false) { $_target = $_root_app . $_target . basename($_FILES['uploadedfile']['name']); $file_tmp = JHotelUtil::makePathFile($_target); /* if( is_file($file_tmp) ) { $p = ''; $n = basename( $file_tmp); $i = 'This file exist !'; $e = 1; } else { */ //dmp($_FILES['uploadedfile']['name']); if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $file_tmp)) { if ($resizeImage) { $image = new Resize_Image(); $image->ratio = true; $ratio = PICTURE_WIDTH / PICTURE_HEIGHT;
public function savePictures($data) { //prepare photos $path_old = JHotelUtil::makePathFile(JPATH_ROOT . DS . PATH_PICTURES . PATH_EXCURSION_PICTURES . ($data['excursion_id'] + 0) . "/"); $files = glob($path_old . "*.*"); $data['id'] = $this->getState('excursion.id'); $path_new = JHotelUtil::makePathFile(JPATH_ROOT . DS . PATH_PICTURES . PATH_EXCURSION_PICTURES . ($data['excursion_id'] + 0) . "/"); $picture_ids = array(); foreach ($data['pictures'] as $value) { $row = $this->getTable('ExcursionPictures'); // dmp($key); $pic = new stdClass(); $pic->picture_id = 0; $pic->excursion_id = $data['excursion_id']; $pic->picture_info = $value['excursion_picture_info']; $pic->picture_path = $value['excursion_picture_path']; $pic->picture_enable = $value['excursion_picture_enable']; $file_tmp = JHotelUtil::makePathFile($path_old . basename($pic->picture_path)); if (!is_file($file_tmp)) { continue; } if (!is_dir($path_new)) { if (!@mkdir($path_new)) { throw new Exception($this->_db->getErrorMsg()); } } // dmp(($path_old.basename($pic->excursion_picture_path).",".$path_new.basename($pic->excursion_picture_path))); // exit; if ($path_old . basename($pic->excursion_picture_path) != $path_new . basename($pic->excursion_picture_path)) { if (@rename($path_old . basename($pic->excursion_picture_path), $path_new . basename($pic->excursion_picture_path))) { $pic->excursion_picture_path = PATH_EXCURSION_PICTURES . ($data['excursion_id'] + 0) . '/' . basename($pic->excursion_picture_path); //@unlink($path_old.basename($pic->excursion_picture_path)); } else { throw new Exception($this->_db->getErrorMsg()); } } if (!$row->bind($pic)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); return false; } // Make sure the record is valid if (!$row->check()) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); return false; } // Store the web link table to the database if (!$row->store()) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); return false; } $picture_ids[] = $this->_db->insertid(); } $files = glob($path_new . "*.*"); foreach ($files as $pic) { $is_find = false; foreach ($data['pictures'] as $value) { //echo $pic."==".JHotelUtil::makePathFile(JPATH_ROOT.DS.PATH_PICTURES.$value['excursion_picture_path']); if ($pic == JHotelUtil::makePathFile(JPATH_ROOT . DS . PATH_PICTURES . $value['excursion_picture_path'])) { $is_find = true; break; } } /*if( $is_find == false ) @unlink( JHotelUtil::makePathFile(JPATH_ROOT.DS.PATH_PICTURES.DS.$value['excursion_picture_path']) );*/ } $query = " DELETE FROM #__hotelreservation_excursion_pictures\r\n\t\tWHERE excursion_id = '" . $data['excursion_id'] . "'\r\n\t\t" . (count($picture_ids) > 0 ? " AND picture_id NOT IN (" . implode(',', $picture_ids) . ")" : ""); // dmp($query); // exit; $this->_db->setQuery($query); if (!$this->_db->query()) { throw new Exception($this->_db->getErrorMsg()); } //~prepare photos return true; }
$_pos = ''; $is_error = false; if (!isset($_GET['_pos']) || $_GET['_filename'] == '' || !isset($_GET['_filename']) || $_GET['_root_app'] == '' || !isset($_GET['_root_app'])) { $f = $n = ''; $i = 'Invalid params !'; $e = 2; $is_error = true; } if ($is_error == false) { $_root_app = $_GET['_root_app']; $_filename = $_GET['_filename']; $_pos = $_GET['_pos']; if ($_root_app[strlen($_root_app) - 1] != '/' && $_filename[strlen($_filename) - 1] != '/') { $_root_app .= '/'; } $file_tmp = JHotelUtil::makePathFile($_root_app . $_filename); // dmp($file_tmp); if (!is_file($file_tmp)) { $f = $file_tmp; $n = basename($file_tmp); $i = 'This file doesn\'t exist !'; $e = 0; // this must be set to 0 - it wont delete a record that exists only in the database } else { if (@unlink($file_tmp)) { $f = htmlentities($file_tmp); $n = basename($file_tmp); $i = $file_tmp; $e = 0; //print_r( array( htmlentities( $_uri.$_target), "") ); } else {
function storePictures($data) { //prepare photos $path_old = JHotelUtil::makePathFile(JPATH_ROOT . DS . PATH_PICTURES . PATH_OFFER_PICTURES . ($data['offer_id'] + 0) . "/"); $files = glob($path_old . "*.*"); $path_new = JHotelUtil::makePathFile(JPATH_ROOT . DS . PATH_PICTURES . PATH_OFFER_PICTURES . ($data['offer_id'] + 0) . "/"); $picture_ids = array(); foreach ($data['pictures'] as $value) { $row = $this->getTable('ManageOfferPictures', 'Table'); // dmp($key); $pic = new stdClass(); $pic->offer_picture_id = 0; $pic->offer_id = $data['offer_id']; $pic->offer_picture_info = $value['offer_picture_info']; $pic->offer_picture_path = $value['offer_picture_path']; $pic->offer_picture_enable = $value['offer_picture_enable']; //dmp($pic); $file_tmp = JHotelUtil::makePathFile($path_old . basename($pic->offer_picture_path)); if (!is_file($file_tmp)) { continue; } if (!is_dir($path_new)) { if (!@mkdir($path_new)) { throw new Exception($this->_db->getErrorMsg()); } } if ($path_old . basename($pic->offer_picture_path) != $path_new . basename($pic->offer_picture_path)) { if (@rename($path_old . basename($pic->offer_picture_path), $path_new . basename($pic->offer_picture_path))) { $pic->offer_picture_path = PATH_OFFER_PICTURES . ($data['room_id'] + 0) . '/' . basename($pic->offer_picture_path); //@unlink($path_old.basename($pic->offer_picture_path)); } else { throw new Exception($this->_db->getErrorMsg()); } } if (!$row->bind($pic)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Make sure the record is valid if (!$row->check()) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Store the web link table to the database if (!$row->store()) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } $picture_ids[] = $this->_db->insertid(); } $files = glob($path_new . "*.*"); foreach ($files as $pic) { $is_find = false; foreach ($data['pictures'] as $value) { if ($pic == JHotelUtil::makePathFile(JPATH_ROOT . $value['offer_picture_path'])) { $is_find = true; break; } } //if( $is_find == false ) // @unlink( JHotelUtil::makePathFile(JPATH_COMPONENT.$value['offer_picture_path']) ); } $query = " DELETE FROM #__hotelreservation_offers_pictures\r\n\t\t\t\t\t\tWHERE offer_id = '" . $data['offer_id'] . "'\r\n\t\t\t\t\t\t" . (count($picture_ids) > 0 ? " AND offer_picture_id NOT IN (" . implode(',', $picture_ids) . ")" : ""); // dmp($query); // exit; $this->_db->setQuery($query); if (!$this->_db->query()) { throw new Exception($this->_db->getErrorMsg()); } //~prepare photos }
function storePicture($picturePath, $id, $oldId) { //prepare photos $path_old = JHotelUtil::makePathFile(JPATH_ROOT . DS . PATH_PICTURES . EXTRA_OPTISON_PICTURE_PATH . $picturePath); $files = glob($path_old . "*.*"); $path_new = JHotelUtil::makePathFile(JPATH_ROOT . DS . PATH_PICTURES . EXTRA_OPTISON_PICTURE_PATH . $id . "/"); $file_tmp = JHotelUtil::makePathFile($path_old); if (!is_file($file_tmp)) { return; } //dmp("is file"); if (!is_dir($path_new)) { if (!@mkdir($path_new)) { throw new Exception($this->_db->getErrorMsg()); } } //dmp(($path_old.basename($picturePath).",".$path_new.basename($picturePath))); // exit; if ($path_old . basename($picturePath) != $path_new . basename($picturePath)) { //dmp($file_tmp); //dmp($picturePath); //dmp(strpos($file_tmp,"\\0\\")); if (strpos($file_tmp, "\\0\\") > 0 && $oldId == 0 && @rename($path_old, $path_new . basename($picturePath))) { //dmp(1); $picturePath = $id . '/' . basename($picturePath); } else { if (strpos($file_tmp, "\\0\\") == false && @copy($path_old, $path_new . basename($picturePath))) { //dmp(2); $picturePath = $id . '/' . basename($picturePath); } else { //throw( new Exception($this->_db->getErrorMsg()) ); } } //dmp($picturePath); } $data = array(); $data["image_path"] = $picturePath; // Get a row instance. $table = $this->getTable(); // Load the row if saving an existing item. if ($id > 0) { $table->load($id); $isNew = false; } // Bind the data. if (!$table->bind($data)) { $this->setError($table->getError()); return false; } // Check the data. if (!$table->check()) { $this->setError($table->getError()); return false; } // Store the data. if (!$table->store()) { $this->setError($table->getError()); return false; } return true; }
function store($data) { try { $this->_db->BeginTrans(); $row = $this->getTable('hotels'); //$data["hotel_description"]= strip_tags($data["hotel_description"]); $this->checkHotelRestrictions($data['hotel_id']); $data['start_date'] = JHotelUtil::convertToMysqlFormat($data['start_date']); $data['end_date'] = JHotelUtil::convertToMysqlFormat($data['end_date']); //dmp($data); //exit; // Bind the form fields to the table if (!$row->bind($data)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); // return false; } // Make sure the record is valid if (!$row->check()) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); // return false; } // Store the web link table to the database if (!$row->store()) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); // return false; } if ($data['hotel_id'] == '' || $data['hotel_id'] == 0 || $data['hotel_id'] == null) { $data['hotel_id'] = $this->_db->insertid(); $this->_hotel_id = $data['hotel_id']; self::copyEmailContent($this->_hotel_id); } //prepare photos $managePictures = JRequest::getVar("manage_pictures", null); if (!empty($managePictures)) { $path_old = JHotelUtil::makePathFile(JPATH_ROOT . DS . PATH_HOTEL_PICTURES . ($data['hotel_id'] + 0) . "/"); $files = glob($path_old . "*.*"); $path_new = JHotelUtil::makePathFile(JPATH_ROOT . DS . PATH_HOTEL_PICTURES . ($data['hotel_id'] + 0) . "/"); //dmp($data); //dmp($data['pictures']); //exit; $picture_ids = array(); foreach ($data['pictures'] as $value) { $row = $this->getTable('ManageHotelPictures'); //dmp($key); $pic = new stdClass(); $pic->hotel_picture_id = 0; $pic->hotel_id = $data['hotel_id']; $pic->hotel_picture_info = $value['hotel_picture_info']; $pic->hotel_picture_path = $value['hotel_picture_path']; $pic->hotel_picture_enable = $value['hotel_picture_enable']; $file_tmp = JHotelUtil::makePathFile($path_old . basename($pic->hotel_picture_path)); if (!is_file($file_tmp)) { continue; } if (!is_dir($path_new)) { if (!@mkdir($path_new)) { throw new Exception($this->_db->getErrorMsg()); } } //dmp(($path_old.basename($pic->hotel_picture_path).",".$path_new.basename($pic->hotel_picture_path))); //exit; if ($path_old . basename($pic->hotel_picture_path) != $path_new . basename($pic->hotel_picture_path)) { if (@rename($path_old . basename($pic->hotel_picture_path), $path_new . basename($pic->hotel_picture_path))) { $pic->hotel_picture_path = PATH_HOTEL_PICTURES . ($data['hotel_id'] + 0) . '/' . basename($pic->hotel_picture_path); //@unlink($path_old.basename($pic->room_picture_path)); } else { throw new Exception($this->_db->getErrorMsg()); } } if (!$row->bind($pic)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Make sure the record is valid if (!$row->check()) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Store the web link table to the database if (!$row->store()) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } $picture_ids[] = $this->_db->insertid(); } //dmp($picture_ids); $files = glob($path_new . "*.*"); foreach ($files as $pic) { $is_find = false; foreach ($data['pictures'] as $value) { $path = JHotelUtil::makePathFile(JPATH_ROOT . DS . $value['hotel_picture_path']); if ($pic == JHotelUtil::makePathFile(JPATH_ROOT . DS . $value['hotel_picture_path'])) { $is_find = true; break; } } //if( $is_find == false ) //@unlink( $pic ); } $query = " DELETE FROM #__hotelreservation_hotel_pictures\n\t\t\t\t\t\t\tWHERE hotel_id = '" . $data['hotel_id'] . "'\n\t\t\t\t\t\t\t" . (count($picture_ids) > 0 ? " AND hotel_picture_id NOT IN (" . implode(',', $picture_ids) . ")" : ""); //dmp($query); //exit; $this->_db->setQuery($query); if (!$this->_db->query()) { throw new Exception($this->_db->getErrorMsg()); } } //~prepare photos //prepare payments default /* $query = " INSERT INTO #__hotelreservation_paymentsettings ( hotel_id, payment_type_id, payment_name, payment_percent, payment_value, payment_days, payment_order, payment_status, is_check_days, is_available ) SELECT ".$data['hotel_id'].", h1.payment_type_id , h1.payment_name, h1.payment_percent, h1.payment_value, h1.payment_days, h1.payment_order, h1.payment_status, h1.is_check_days, h1.is_available FROM #__hotelreservation_paymentsettings h1 WHERE h1.payment_type_id NOT IN ( SELECT h2.payment_type_id FROM #__hotelreservation_paymentsettings h2 WHERE h2.hotel_id = ".$data['hotel_id']." ) AND h1.hotel_id = 0 "; */ //dmp($query); //exit; /* $this->_db->setQuery( $query ); if (!$this->_db->query()) { throw( new Exception($this->_db->getErrorMsg()) ); } */ //~prepare payments default $query = " DELETE FROM #__hotelreservation_hotel_facility_relation WHERE hotelId = " . $data['hotel_id']; //dmp($query); // exit; $this->_db->setQuery($query); if (!$this->_db->query()) { throw new Exception($this->_db->getErrorMsg()); } if (isset($data['facilities'])) { //prepare facilities //dmp($data['facilities']); foreach ($data['facilities'] as $facility) { $row = $this->getTable('ManageHotelFacilityRelation'); $facilityRelation->hotelId = $data['hotel_id']; $facilityRelation->facilityId = $facility; //dmp($facilityRelation); if (!$row->bind($facilityRelation)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Make sure the record is valid if (!$row->check()) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Store the web link table to the database if (!$row->store(true)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } } } $query = " DELETE FROM #__hotelreservation_hotel_type_relation\r\n\t\t\tWHERE hotelId = " . $data['hotel_id']; // dmp($query); // exit; $this->_db->setQuery($query); if (!$this->_db->query()) { throw new Exception($this->_db->getErrorMsg()); } if (isset($data['types'])) { //prepare types //dmp($data['types']); foreach ($data['types'] as $type) { //dmp("step"); $row = $this->getTable('ManageHotelTypeRelation'); $typeRelation->hotelId = $data['hotel_id']; $typeRelation->typeId = $type; //dmp($typeRelation); if (!$row->bind($typeRelation)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Make sure the record is valid if (!$row->check()) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Store the web link table to the database if (!$row->store(true)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } } } $query = " DELETE FROM #__hotelreservation_hotel_accommodation_type_relation\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE hotelId = " . $data['hotel_id']; $this->_db->setQuery($query); if (!$this->_db->query()) { throw new Exception($this->_db->getErrorMsg()); } if (isset($data['accommodationtypes'])) { //prepare accommodationTypes //dmp($data['accommodationtypes']); foreach ($data['accommodationtypes'] as $type) { $row = $this->getTable('ManageHotelAccommodationTypeRelation'); $accommodationTypeRelation->hotelId = $data['hotel_id']; $accommodationTypeRelation->accommodationtypeId = $type; //dmp($accommodationTypeRelation); if (!$row->bind($accommodationTypeRelation)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Make sure the record is valid if (!$row->check()) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Store the web link table to the database if (!$row->store(true)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } } } //prepare environments //dmp($data['environments']); $query = " DELETE FROM #__hotelreservation_hotel_environment_relation\r\n\t\t\t\t\t\tWHERE hotelId = " . $data['hotel_id']; // dmp($query); // exit; $this->_db->setQuery($query); if (!$this->_db->query()) { throw new Exception($this->_db->getErrorMsg()); } if (isset($data['environments'])) { foreach ($data['environments'] as $environment) { $row = $this->getTable('ManageHotelEnvironmentRelation'); $environmentRelation->hotelId = $data['hotel_id']; $environmentRelation->environmentId = $environment; //dmp($environmentRelation); if (!$row->bind($environmentRelation)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Make sure the record is valid if (!$row->check()) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Store the web link table to the database if (!$row->store(true)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } } } //prepare regions // dmp($data['regions']); $query = " DELETE FROM #__hotelreservation_hotel_region_relation\r\n\t\t\t\t\t\tWHERE hotelId = " . $data['hotel_id']; // dmp($query); // exit; $this->_db->setQuery($query); if (!$this->_db->query()) { throw new Exception($this->_db->getErrorMsg()); } if (isset($data['regions'])) { foreach ($data['regions'] as $region) { $row = $this->getTable('ManageHotelRegionRelation'); $regionRelation->hotelId = $data['hotel_id']; $regionRelation->regionId = $region; // dmp($regionRelation); if (!$row->bind($regionRelation)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Make sure the record is valid if (!$row->check()) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Store the web link table to the database if (!$row->store(true)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } } } $data["id"] = $data["informationId"]; //dmp($data); //exit; $row = $this->getTable('managehotelinformations'); if (!$row->bind($data)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Make sure the record is valid if (!$row->check()) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Store the web link table to the database if (!$row->store(true)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } $data["id"] = $data["contactId"]; $row = $this->getTable('hotelcontact'); if (!$row->bind($data)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Make sure the record is valid if (!$row->check()) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Store the web link table to the database if (!$row->store(true)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } //prepare payment options //dmp($data['regions']); if (isset($data['paymentOptions'])) { $query = " DELETE FROM #__hotelreservation_hotel_payment_option_relation\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE hotelId = " . $data['hotel_id']; //dmp($query); $this->_db->setQuery($query); if (!$this->_db->query()) { throw new Exception($this->_db->getErrorMsg()); } foreach ($data['paymentOptions'] as $paymentOption) { $row = $this->getTable('managehotelpaymentoptionrelation'); $paymentRelation->hotelId = $data['hotel_id']; $paymentRelation->paymentOptionId = $paymentOption; if (!$row->bind($paymentRelation)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Make sure the record is valid if (!$row->check()) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } // Store the web link table to the database if (!$row->store(true)) { throw new Exception($this->_db->getErrorMsg()); $this->setError($this->_db->getErrorMsg()); } } } //save channel manager data $user = $data["cubilis_user"]; $password = $data["cubilis_password"]; if (isset($user) && isset($password)) { $channel = CHANNEL_MANAGER_CUBILIS; $hotel_id = $data['hotel_id']; $query = "INSERT INTO #__hotelreservation_hotel_channel_manager (hotel_id, service, user, password) VALUES ({$hotel_id}, '{$channel}', '{$user}','{$password}')\t\n\t\t\t\t\t\t ON DUPLICATE KEY UPDATE user = '******', password = '******' "; $this->_db->setQuery($query); if (!$this->_db->query()) { $ret = false; $e = 'INSERT / UPDATE sql STATEMENT error !'; } } $this->_db->CommitTrans(); } catch (Exception $ex) { dmp($ex); exit; $this->_db->RollbackTrans(); return false; } return true; }