<?php
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg7.php" ?>
<?php include "ewmysql7.php" ?>
<?php include "phpfn7.php" ?>
<?php include "tbl_hotelinfo.php" ?>
<?php include "tbl_countryinfo.php" ?>
<?php include "tbl_languageinfo.php" ?>
<?php include "tbl_hotel_originalinfo.php" ?>
<?php include "tbl_admininfo.php" ?>
<?php include "tbl_provinceinfo.php" ?>
<?php include "userfn7.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Create page object
$tbl_hotel_edit = new ctbl_hotel_edit();
$Page =& $tbl_hotel_edit;

// Page init
$tbl_hotel_edit->Page_Init();

// Page main
$tbl_hotel_edit->Page_Main();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--

// Create page object
var tbl_hotel_edit = new ew_Page("tbl_hotel_edit");

// page properties
tbl_hotel_edit.PageID = "edit"; // page ID
tbl_hotel_edit.FormID = "ftbl_hoteledit"; // form ID
var EW_PAGE_ID = tbl_hotel_edit.PageID; // for backward compatibility

// extend page with ValidateForm function
tbl_hotel_edit.ValidateForm = function(fobj) {
	ew_PostAutoSuggest(fobj);
	if (!this.ValidateRequired)
		return true; // ignore validation
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		elm = fobj.elements["x" + infix + "_hotel_or_id"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($tbl_hotel->hotel_or_id->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_language_id"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($tbl_hotel->language_id->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_country_id"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($tbl_hotel->country_id->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_province_id"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($tbl_hotel->province_id->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_category"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($tbl_hotel->category->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_photo"];
		aelm = fobj.elements["a" + infix + "_photo"];
		var chk_photo = (aelm && aelm[0])?(aelm[2].checked):true;
		if (elm && chk_photo && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($tbl_hotel->photo->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_photo"];
		if (elm && !ew_CheckFileType(elm.value))
			return ew_OnError(this, elm, ewLanguage.Phrase("WrongFileType"));
		elm = fobj.elements["x" + infix + "_hotel_name"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($tbl_hotel->hotel_name->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_descriptioin"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($tbl_hotel->descriptioin->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_order_by"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($tbl_hotel->order_by->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_order_by"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($tbl_hotel->order_by->FldErrMsg()) ?>");

		// Call Form Custom Validate event
		if (!this.Form_CustomValidate(fobj)) return false;
	}
	return true;
}

// extend page with Form_CustomValidate function
tbl_hotel_edit.Form_CustomValidate =  
 function(fobj) { // DO NOT CHANGE THIS LINE!

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
<?php if (EW_CLIENT_VALIDATE) { ?>
tbl_hotel_edit.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
tbl_hotel_edit.ValidateRequired = false; // no JavaScript validation
<?php } ?>

//-->
</script>
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
<script type="text/javascript">
<!--
_width_multiplier = 16;
_height_multiplier = 60;
var ew_DHTMLEditors = [];

// update value from editor to textarea
function ew_UpdateTextArea() {
	if (typeof ew_DHTMLEditors != 'undefined' && typeof FCKeditorAPI != 'undefined') {			
			var inst;			
			for (inst in FCKeditorAPI.__Instances)
				FCKeditorAPI.__Instances[inst].UpdateLinkedField();
	}
}

// update value from textarea to editor
function ew_UpdateDHTMLEditor(name) {
	if (typeof ew_DHTMLEditors != 'undefined' && typeof FCKeditorAPI != 'undefined') {
		var inst = FCKeditorAPI.GetInstance(name);		
		if (inst)
			inst.SetHTML(inst.LinkedField.value)
	}
}

// focus editor
function ew_FocusDHTMLEditor(name) {
	if (typeof ew_DHTMLEditors != 'undefined' && typeof FCKeditorAPI != 'undefined') {
		var inst = FCKeditorAPI.GetInstance(name);	
		if (inst && inst.EditorWindow) {
			inst.EditorWindow.focus();
		}
	}
}

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->

</script>
<p><span class="phpmaker"><?php echo $Language->Phrase("Edit") ?>&nbsp;<?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $tbl_hotel->TableCaption() ?><br><br>
<a href="<?php echo $tbl_hotel->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$tbl_hotel_edit->ShowMessage();
?>
<form name="ftbl_hoteledit" id="ftbl_hoteledit" action="<?php echo ew_CurrentPage() ?>" method="post" enctype="multipart/form-data">
<p>
<input type="hidden" name="a_table" id="a_table" value="tbl_hotel">
<input type="hidden" name="a_edit" id="a_edit" value="U">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?php if ($tbl_hotel->hotel_id->Visible) { // hotel_id ?>
	<tr<?php echo $tbl_hotel->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $tbl_hotel->hotel_id->FldCaption() ?></td>
		<td<?php echo $tbl_hotel->hotel_id->CellAttributes() ?>><span id="el_hotel_id">
<div<?php echo $tbl_hotel->hotel_id->ViewAttributes() ?>><?php echo $tbl_hotel->hotel_id->EditValue ?></div><input type="hidden" name="x_hotel_id" id="x_hotel_id" value="<?php echo ew_HtmlEncode($tbl_hotel->hotel_id->CurrentValue) ?>">
</span><?php echo $tbl_hotel->hotel_id->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($tbl_hotel->hotel_or_id->Visible) { // hotel_or_id ?>
	<tr<?php echo $tbl_hotel->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $tbl_hotel->hotel_or_id->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $tbl_hotel->hotel_or_id->CellAttributes() ?>><span id="el_hotel_or_id">
<?php if ($tbl_hotel->hotel_or_id->getSessionValue() <> "") { ?>
<div<?php echo $tbl_hotel->hotel_or_id->ViewAttributes() ?>><?php echo $tbl_hotel->hotel_or_id->ViewValue ?></div>
<input type="hidden" id="x_hotel_or_id" name="x_hotel_or_id" value="<?php echo ew_HtmlEncode($tbl_hotel->hotel_or_id->CurrentValue) ?>">
<?php } else { ?>
<select id="x_hotel_or_id" name="x_hotel_or_id" title="<?php echo $tbl_hotel->hotel_or_id->FldTitle() ?>"<?php echo $tbl_hotel->hotel_or_id->EditAttributes() ?>>
<?php
if (is_array($tbl_hotel->hotel_or_id->EditValue)) {
	$arwrk = $tbl_hotel->hotel_or_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($tbl_hotel->hotel_or_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
<?php
$sSqlWrk = "SELECT `hote_or_id`, `name`, '' AS Disp2Fld FROM `tbl_hotel_original`";
$sWhereWrk = "";
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk = TEAencrypt($sSqlWrk, EW_RANDOM_KEY);
?>
<input type="hidden" name="s_x_hotel_or_id" id="s_x_hotel_or_id" value="<?php echo $sSqlWrk; ?>">
<input type="hidden" name="lft_x_hotel_or_id" id="lft_x_hotel_or_id" value="">
<?php } ?>
</span><?php echo $tbl_hotel->hotel_or_id->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($tbl_hotel->language_id->Visible) { // language_id ?>
	<tr<?php echo $tbl_hotel->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $tbl_hotel->language_id->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $tbl_hotel->language_id->CellAttributes() ?>><span id="el_language_id">
<?php if ($tbl_hotel->language_id->getSessionValue() <> "") { ?>
<div<?php echo $tbl_hotel->language_id->ViewAttributes() ?>><?php echo $tbl_hotel->language_id->ViewValue ?></div>
<input type="hidden" id="x_language_id" name="x_language_id" value="<?php echo ew_HtmlEncode($tbl_hotel->language_id->CurrentValue) ?>">
<?php } else { ?>
<?php $tbl_hotel->language_id->EditAttrs["onchange"] = "ew_UpdateOpt('x_country_id','x_language_id',true); " . @$tbl_hotel->language_id->EditAttrs["onchange"]; ?>
<select id="x_language_id" name="x_language_id" title="<?php echo $tbl_hotel->language_id->FldTitle() ?>"<?php echo $tbl_hotel->language_id->EditAttributes() ?>>
<?php
if (is_array($tbl_hotel->language_id->EditValue)) {
	$arwrk = $tbl_hotel->language_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($tbl_hotel->language_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
<?php
$sSqlWrk = "SELECT `language_id`, `language`, '' AS Disp2Fld FROM `tbl_language`";
$sWhereWrk = "";
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk = TEAencrypt($sSqlWrk, EW_RANDOM_KEY);
?>
<input type="hidden" name="s_x_language_id" id="s_x_language_id" value="<?php echo $sSqlWrk; ?>">
<input type="hidden" name="lft_x_language_id" id="lft_x_language_id" value="">
<?php } ?>
</span><?php echo $tbl_hotel->language_id->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($tbl_hotel->country_id->Visible) { // country_id ?>
	<tr<?php echo $tbl_hotel->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $tbl_hotel->country_id->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $tbl_hotel->country_id->CellAttributes() ?>><span id="el_country_id">
<?php if ($tbl_hotel->country_id->getSessionValue() <> "") { ?>
<div<?php echo $tbl_hotel->country_id->ViewAttributes() ?>><?php echo $tbl_hotel->country_id->ViewValue ?></div>
<input type="hidden" id="x_country_id" name="x_country_id" value="<?php echo ew_HtmlEncode($tbl_hotel->country_id->CurrentValue) ?>">
<?php } else { ?>
<?php $tbl_hotel->country_id->EditAttrs["onchange"] = "ew_UpdateOpt('x_province_id','x_country_id',true); " . @$tbl_hotel->country_id->EditAttrs["onchange"]; ?>
<select id="x_country_id" name="x_country_id" title="<?php echo $tbl_hotel->country_id->FldTitle() ?>"<?php echo $tbl_hotel->country_id->EditAttributes() ?>>
<?php
if (is_array($tbl_hotel->country_id->EditValue)) {
	$arwrk = $tbl_hotel->country_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($tbl_hotel->country_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
<?php
$sSqlWrk = "SELECT `country_id`, `country_name`, '' AS Disp2Fld FROM `tbl_country`";
$sWhereWrk = "`lagnuage_id` IN ({filter_value})";
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk = TEAencrypt($sSqlWrk, EW_RANDOM_KEY);
?>
<input type="hidden" name="s_x_country_id" id="s_x_country_id" value="<?php echo $sSqlWrk; ?>">
<input type="hidden" name="lft_x_country_id" id="lft_x_country_id" value="1">
<?php } ?>
</span><?php echo $tbl_hotel->country_id->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($tbl_hotel->province_id->Visible) { // province_id ?>
	<tr<?php echo $tbl_hotel->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $tbl_hotel->province_id->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $tbl_hotel->province_id->CellAttributes() ?>><span id="el_province_id">
<?php if ($tbl_hotel->province_id->getSessionValue() <> "") { ?>
<div<?php echo $tbl_hotel->province_id->ViewAttributes() ?>><?php echo $tbl_hotel->province_id->ViewValue ?></div>
<input type="hidden" id="x_province_id" name="x_province_id" value="<?php echo ew_HtmlEncode($tbl_hotel->province_id->CurrentValue) ?>">
<?php } else { ?>
<select id="x_province_id" name="x_province_id" title="<?php echo $tbl_hotel->province_id->FldTitle() ?>"<?php echo $tbl_hotel->province_id->EditAttributes() ?>>
<?php
if (is_array($tbl_hotel->province_id->EditValue)) {
	$arwrk = $tbl_hotel->province_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($tbl_hotel->province_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
<?php
$sSqlWrk = "SELECT `province_id`, `province_name`, '' AS Disp2Fld FROM `tbl_province`";
$sWhereWrk = "`country_id` IN ({filter_value})";
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk = TEAencrypt($sSqlWrk, EW_RANDOM_KEY);
?>
<input type="hidden" name="s_x_province_id" id="s_x_province_id" value="<?php echo $sSqlWrk; ?>">
<input type="hidden" name="lft_x_province_id" id="lft_x_province_id" value="1">
<?php } ?>
</span><?php echo $tbl_hotel->province_id->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($tbl_hotel->category->Visible) { // category ?>
	<tr<?php echo $tbl_hotel->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $tbl_hotel->category->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $tbl_hotel->category->CellAttributes() ?>><span id="el_category">
<select id="x_category" name="x_category" title="<?php echo $tbl_hotel->category->FldTitle() ?>"<?php echo $tbl_hotel->category->EditAttributes() ?>>
<?php
if (is_array($tbl_hotel->category->EditValue)) {
	$arwrk = $tbl_hotel->category->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($tbl_hotel->category->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span><?php echo $tbl_hotel->category->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($tbl_hotel->photo->Visible) { // photo ?>
	<tr<?php echo $tbl_hotel->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $tbl_hotel->photo->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $tbl_hotel->photo->CellAttributes() ?>><span id="el_photo">
<div id="old_x_photo">
<?php if ($tbl_hotel->photo->HrefValue <> "" || $tbl_hotel->photo->TooltipValue <> "") { ?>
<?php if (!empty($tbl_hotel->photo->Upload->DbValue)) { ?>
<img src="<?php echo ew_UploadPathEx(FALSE, $tbl_hotel->photo->UploadPath) . $tbl_hotel->photo->Upload->DbValue ?>" border=0<?php echo $tbl_hotel->photo->ViewAttributes() ?>>
<?php } elseif (!in_array($tbl_hotel->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } else { ?>
<?php if (!empty($tbl_hotel->photo->Upload->DbValue)) { ?>
<img src="<?php echo ew_UploadPathEx(FALSE, $tbl_hotel->photo->UploadPath) . $tbl_hotel->photo->Upload->DbValue ?>" border=0<?php echo $tbl_hotel->photo->ViewAttributes() ?>>
<?php } elseif (!in_array($tbl_hotel->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } ?>
</div>
<div id="new_x_photo">
<?php if (!empty($tbl_hotel->photo->Upload->DbValue)) { ?>
<label><input type="radio" name="a_photo" id="a_photo" value="1" checked="checked"><?php echo $Language->Phrase("Keep") ?></label>&nbsp;
<label><input type="radio" name="a_photo" id="a_photo" value="2" disabled="disabled"><?php echo $Language->Phrase("Remove") ?></label>&nbsp;
<label><input type="radio" name="a_photo" id="a_photo" value="3"><?php echo $Language->Phrase("Replace") ?><br></label>
<?php $tbl_hotel->photo->EditAttrs["onchange"] = "this.form.a_photo[2].checked=true;" . @$tbl_hotel->photo->EditAttrs["onchange"]; ?>
<?php } else { ?>
<input type="hidden" name="a_photo" id="a_photo" value="3">
<?php } ?>
<input type="file" name="x_photo" id="x_photo" title="<?php echo $tbl_hotel->photo->FldTitle() ?>" size="30"<?php echo $tbl_hotel->photo->EditAttributes() ?>>
</div>
</span><?php echo $tbl_hotel->photo->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($tbl_hotel->hotel_name->Visible) { // hotel_name ?>
	<tr<?php echo $tbl_hotel->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $tbl_hotel->hotel_name->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $tbl_hotel->hotel_name->CellAttributes() ?>><span id="el_hotel_name">
<input type="text" name="x_hotel_name" id="x_hotel_name" title="<?php echo $tbl_hotel->hotel_name->FldTitle() ?>" size="75" maxlength="100" value="<?php echo $tbl_hotel->hotel_name->EditValue ?>"<?php echo $tbl_hotel->hotel_name->EditAttributes() ?>>
</span><?php echo $tbl_hotel->hotel_name->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($tbl_hotel->descriptioin->Visible) { // descriptioin ?>
	<tr<?php echo $tbl_hotel->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $tbl_hotel->descriptioin->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $tbl_hotel->descriptioin->CellAttributes() ?>><span id="el_descriptioin">
<textarea name="x_descriptioin" id="x_descriptioin" title="<?php echo $tbl_hotel->descriptioin->FldTitle() ?>" cols="35" rows="7"<?php echo $tbl_hotel->descriptioin->EditAttributes() ?>><?php echo $tbl_hotel->descriptioin->EditValue ?></textarea>
<script type="text/javascript">
<!--
ew_DHTMLEditors.push(new ew_DHTMLEditor("x_descriptioin", function() {
	var sBasePath = 'fckeditor/';
	var oFCKeditor = new FCKeditor('x_descriptioin', 35*_width_multiplier, 7*_height_multiplier);
	oFCKeditor.BasePath = sBasePath;
	oFCKeditor.ReplaceTextarea();
	this.active = true;
}));
-->
</script>
</span><?php echo $tbl_hotel->descriptioin->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($tbl_hotel->order_by->Visible) { // order_by ?>
	<tr<?php echo $tbl_hotel->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $tbl_hotel->order_by->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $tbl_hotel->order_by->CellAttributes() ?>><span id="el_order_by">
<input type="text" name="x_order_by" id="x_order_by" title="<?php echo $tbl_hotel->order_by->FldTitle() ?>" size="75" value="<?php echo $tbl_hotel->order_by->EditValue ?>"<?php echo $tbl_hotel->order_by->EditAttributes() ?>>
</span><?php echo $tbl_hotel->order_by->CustomMsg ?></td>
	</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<p>
<input type="button" name="btnAction" id="btnAction" value="<?php echo ew_BtnCaption($Language->Phrase("EditBtn")) ?>" onclick="ew_SubmitForm(tbl_hotel_edit, this.form);">
</form>
<script language="JavaScript" type="text/javascript">
<!--
ew_UpdateOpts([['x_country_id','x_language_id',false],
['x_province_id','x_country_id',false],
['x_hotel_or_id','x_hotel_or_id',false],
['x_language_id','x_language_id',false]]);

//-->
</script>
<script type="text/javascript">
<!--
ew_CreateEditor();  // Create DHTML editor(s)

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php include "footer.php" ?>
<?php
$tbl_hotel_edit->Page_Terminate();
?>
<?php

//
// Page class
//
class ctbl_hotel_edit {

	// Page ID
	var $PageID = 'edit';

	// Table name
	var $TableName = 'tbl_hotel';

	// Page object name
	var $PageObjName = 'tbl_hotel_edit';

	// Page name
	function PageName() {
		return ew_CurrentPage();
	}

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		global $tbl_hotel;
		if ($tbl_hotel->UseTokenInUrl) $PageUrl .= "t=" . $tbl_hotel->TableVar . "&"; // Add page token
		return $PageUrl;
	}

	// Page URLs
	var $AddUrl;
	var $EditUrl;
	var $CopyUrl;
	var $DeleteUrl;
	var $ViewUrl;
	var $ListUrl;

	// Export URLs
	var $ExportPrintUrl;
	var $ExportHtmlUrl;
	var $ExportExcelUrl;
	var $ExportWordUrl;
	var $ExportXmlUrl;
	var $ExportCsvUrl;

	// Update URLs
	var $InlineAddUrl;
	var $InlineCopyUrl;
	var $InlineEditUrl;
	var $GridAddUrl;
	var $GridEditUrl;
	var $MultiDeleteUrl;
	var $MultiUpdateUrl;

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Append
			$_SESSION[EW_SESSION_MESSAGE] .= "<br>" . $v;
		} else {
			$_SESSION[EW_SESSION_MESSAGE] = $v;
		}
	}

	// Show message
	function ShowMessage() {
		$sMessage = $this->getMessage();
		$this->Message_Showing($sMessage);
		if ($sMessage <> "") { // Message in Session, display
			echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}
	}

	// Validate page request
	function IsPageRequest() {
		global $objForm, $tbl_hotel;
		if ($tbl_hotel->UseTokenInUrl) {
			if ($objForm)
				return ($tbl_hotel->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($tbl_hotel->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

	//
	// Page class constructor
	//
	function ctbl_hotel_edit() {
		global $conn, $Language;

		// Language object
		$Language = new cLanguage();

		// Table object (tbl_hotel)
		$GLOBALS["tbl_hotel"] = new ctbl_hotel();

		// Table object (tbl_country)
		$GLOBALS['tbl_country'] = new ctbl_country();

		// Table object (tbl_language)
		$GLOBALS['tbl_language'] = new ctbl_language();

		// Table object (tbl_hotel_original)
		$GLOBALS['tbl_hotel_original'] = new ctbl_hotel_original();

		// Table object (tbl_admin)
		$GLOBALS['tbl_admin'] = new ctbl_admin();

		// Table object (tbl_province)
		$GLOBALS['tbl_province'] = new ctbl_province();

		// Page ID
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'edit', TRUE);

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'tbl_hotel', TRUE);

		// Start timer
		$GLOBALS["gsTimer"] = new cTimer();

		// Open connection
		$conn = ew_Connect();
	}

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
		global $tbl_hotel;

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}

		// Create form object
		$objForm = new cFormObj();

		// Global Page Loading event (in userfn*.php)
		Page_Loading();

		// Page Load event
		$this->Page_Load();
	}

	//
	// Page_Terminate
	//
	function Page_Terminate($url = "") {
		global $conn;

		// Page Unload event
		$this->Page_Unload();

		// Global Page Unloaded event (in userfn*.php)
		Page_Unloaded();

		 // Close connection
		$conn->Close();

		// Go to URL if specified
		$this->Page_Redirecting($url);
		if ($url <> "") {
			if (!EW_DEBUG_ENABLED && ob_get_length())
				ob_end_clean();
			header("Location: " . $url);
		}
		exit();
	}
	var $sDbMasterFilter;
	var $sDbDetailFilter;

	// 
	// Page main
	//
	function Page_Main() {
		global $objForm, $Language, $gsFormError, $tbl_hotel;

		// Load key from QueryString
		if (@$_GET["hotel_id"] <> "")
			$tbl_hotel->hotel_id->setQueryStringValue($_GET["hotel_id"]);

		// Set up master detail parameters
		$this->SetUpMasterDetail();
		if (@$_POST["a_edit"] <> "") {
			$tbl_hotel->CurrentAction = $_POST["a_edit"]; // Get action code
			$this->GetUploadFiles(); // Get upload files
			$this->LoadFormValues(); // Get form values

			// Validate form
			if (!$this->ValidateForm()) {
				$tbl_hotel->CurrentAction = ""; // Form error, reset action
				$this->setMessage($gsFormError);
				$tbl_hotel->EventCancelled = TRUE; // Event cancelled
				$this->RestoreFormValues();
			}
		} else {
			$tbl_hotel->CurrentAction = "I"; // Default action is display
		}

		// Check if valid key
		if ($tbl_hotel->hotel_id->CurrentValue == "")
			$this->Page_Terminate("tbl_hotellist.php"); // Invalid key, return to list
		switch ($tbl_hotel->CurrentAction) {
			case "I": // Get a record to display
				if (!$this->LoadRow()) { // Load record based on key
					$this->setMessage($Language->Phrase("NoRecord")); // No record found
					$this->Page_Terminate("tbl_hotellist.php"); // No matching record, return to list
				}
				break;
			Case "U": // Update
				$tbl_hotel->SendEmail = TRUE; // Send email on update success
				if ($this->EditRow()) { // Update record based on key
					$this->setMessage($Language->Phrase("UpdateSuccess")); // Update success
					$sReturnUrl = $tbl_hotel->getReturnUrl();
					$this->Page_Terminate($sReturnUrl); // Return to caller
				} else {
					$tbl_hotel->EventCancelled = TRUE; // Event cancelled
					$this->RestoreFormValues(); // Restore form values if update failed
				}
		}

		// Render the record
		$tbl_hotel->RowType = EW_ROWTYPE_EDIT; // Render as Edit
		$this->RenderRow();
	}

	// Get upload files
	function GetUploadFiles() {
		global $objForm, $tbl_hotel;

		// Get upload data
			if ($tbl_hotel->photo->Upload->UploadFile()) {

				// No action required
			} else {
				echo $tbl_hotel->photo->Upload->Message;
				$this->Page_Terminate();
				exit();
			}
	}

	// Load form values
	function LoadFormValues() {

		// Load from form
		global $objForm, $tbl_hotel;
		$tbl_hotel->hotel_id->setFormValue($objForm->GetValue("x_hotel_id"));
		$tbl_hotel->hotel_or_id->setFormValue($objForm->GetValue("x_hotel_or_id"));
		$tbl_hotel->language_id->setFormValue($objForm->GetValue("x_language_id"));
		$tbl_hotel->country_id->setFormValue($objForm->GetValue("x_country_id"));
		$tbl_hotel->province_id->setFormValue($objForm->GetValue("x_province_id"));
		$tbl_hotel->category->setFormValue($objForm->GetValue("x_category"));
		$tbl_hotel->hotel_name->setFormValue($objForm->GetValue("x_hotel_name"));
		$tbl_hotel->descriptioin->setFormValue($objForm->GetValue("x_descriptioin"));
		$tbl_hotel->order_by->setFormValue($objForm->GetValue("x_order_by"));
	}

	// Restore form values
	function RestoreFormValues() {
		global $objForm, $tbl_hotel;
		$this->LoadRow();
		$tbl_hotel->hotel_id->CurrentValue = $tbl_hotel->hotel_id->FormValue;
		$tbl_hotel->hotel_or_id->CurrentValue = $tbl_hotel->hotel_or_id->FormValue;
		$tbl_hotel->language_id->CurrentValue = $tbl_hotel->language_id->FormValue;
		$tbl_hotel->country_id->CurrentValue = $tbl_hotel->country_id->FormValue;
		$tbl_hotel->province_id->CurrentValue = $tbl_hotel->province_id->FormValue;
		$tbl_hotel->category->CurrentValue = $tbl_hotel->category->FormValue;
		$tbl_hotel->hotel_name->CurrentValue = $tbl_hotel->hotel_name->FormValue;
		$tbl_hotel->descriptioin->CurrentValue = $tbl_hotel->descriptioin->FormValue;
		$tbl_hotel->order_by->CurrentValue = $tbl_hotel->order_by->FormValue;
	}

	// Load row based on key values
	function LoadRow() {
		global $conn, $Security, $tbl_hotel;
		$sFilter = $tbl_hotel->KeyFilter();

		// Call Row Selecting event
		$tbl_hotel->Row_Selecting($sFilter);

		// Load SQL based on filter
		$tbl_hotel->CurrentFilter = $sFilter;
		$sSql = $tbl_hotel->SQL();
		$res = FALSE;
		$rs = ew_LoadRecordset($sSql);
		if ($rs && !$rs->EOF) {
			$res = TRUE;
			$this->LoadRowValues($rs); // Load row values

			// Call Row Selected event
			$tbl_hotel->Row_Selected($rs);
			$rs->Close();
		}
		return $res;
	}

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $tbl_hotel;
		$tbl_hotel->hotel_id->setDbValue($rs->fields('hotel_id'));
		$tbl_hotel->hotel_or_id->setDbValue($rs->fields('hotel_or_id'));
		$tbl_hotel->language_id->setDbValue($rs->fields('language_id'));
		$tbl_hotel->country_id->setDbValue($rs->fields('country_id'));
		$tbl_hotel->province_id->setDbValue($rs->fields('province_id'));
		$tbl_hotel->category->setDbValue($rs->fields('category'));
		$tbl_hotel->photo->Upload->DbValue = $rs->fields('photo');
		$tbl_hotel->hotel_name->setDbValue($rs->fields('hotel_name'));
		$tbl_hotel->descriptioin->setDbValue($rs->fields('descriptioin'));
		$tbl_hotel->order_by->setDbValue($rs->fields('order_by'));
	}

	// Render row values based on field settings
	function RenderRow() {
		global $conn, $Security, $Language, $tbl_hotel;

		// Initialize URLs
		// Call Row_Rendering event

		$tbl_hotel->Row_Rendering();

		// Common render codes for all row types
		// hotel_id

		$tbl_hotel->hotel_id->CellCssStyle = ""; $tbl_hotel->hotel_id->CellCssClass = "";
		$tbl_hotel->hotel_id->CellAttrs = array(); $tbl_hotel->hotel_id->ViewAttrs = array(); $tbl_hotel->hotel_id->EditAttrs = array();

		// hotel_or_id
		$tbl_hotel->hotel_or_id->CellCssStyle = ""; $tbl_hotel->hotel_or_id->CellCssClass = "";
		$tbl_hotel->hotel_or_id->CellAttrs = array(); $tbl_hotel->hotel_or_id->ViewAttrs = array(); $tbl_hotel->hotel_or_id->EditAttrs = array();

		// language_id
		$tbl_hotel->language_id->CellCssStyle = ""; $tbl_hotel->language_id->CellCssClass = "";
		$tbl_hotel->language_id->CellAttrs = array(); $tbl_hotel->language_id->ViewAttrs = array(); $tbl_hotel->language_id->EditAttrs = array();

		// country_id
		$tbl_hotel->country_id->CellCssStyle = ""; $tbl_hotel->country_id->CellCssClass = "";
		$tbl_hotel->country_id->CellAttrs = array(); $tbl_hotel->country_id->ViewAttrs = array(); $tbl_hotel->country_id->EditAttrs = array();

		// province_id
		$tbl_hotel->province_id->CellCssStyle = ""; $tbl_hotel->province_id->CellCssClass = "";
		$tbl_hotel->province_id->CellAttrs = array(); $tbl_hotel->province_id->ViewAttrs = array(); $tbl_hotel->province_id->EditAttrs = array();

		// category
		$tbl_hotel->category->CellCssStyle = ""; $tbl_hotel->category->CellCssClass = "";
		$tbl_hotel->category->CellAttrs = array(); $tbl_hotel->category->ViewAttrs = array(); $tbl_hotel->category->EditAttrs = array();

		// photo
		$tbl_hotel->photo->CellCssStyle = ""; $tbl_hotel->photo->CellCssClass = "";
		$tbl_hotel->photo->CellAttrs = array(); $tbl_hotel->photo->ViewAttrs = array(); $tbl_hotel->photo->EditAttrs = array();

		// hotel_name
		$tbl_hotel->hotel_name->CellCssStyle = ""; $tbl_hotel->hotel_name->CellCssClass = "";
		$tbl_hotel->hotel_name->CellAttrs = array(); $tbl_hotel->hotel_name->ViewAttrs = array(); $tbl_hotel->hotel_name->EditAttrs = array();

		// descriptioin
		$tbl_hotel->descriptioin->CellCssStyle = ""; $tbl_hotel->descriptioin->CellCssClass = "";
		$tbl_hotel->descriptioin->CellAttrs = array(); $tbl_hotel->descriptioin->ViewAttrs = array(); $tbl_hotel->descriptioin->EditAttrs = array();

		// order_by
		$tbl_hotel->order_by->CellCssStyle = ""; $tbl_hotel->order_by->CellCssClass = "";
		$tbl_hotel->order_by->CellAttrs = array(); $tbl_hotel->order_by->ViewAttrs = array(); $tbl_hotel->order_by->EditAttrs = array();
		if ($tbl_hotel->RowType == EW_ROWTYPE_VIEW) { // View row

			// hotel_id
			$tbl_hotel->hotel_id->ViewValue = $tbl_hotel->hotel_id->CurrentValue;
			$tbl_hotel->hotel_id->CssStyle = "";
			$tbl_hotel->hotel_id->CssClass = "";
			$tbl_hotel->hotel_id->ViewCustomAttributes = "";

			// hotel_or_id
			if (strval($tbl_hotel->hotel_or_id->CurrentValue) <> "") {
				$sFilterWrk = "`hote_or_id` = " . ew_AdjustSql($tbl_hotel->hotel_or_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `name` FROM `tbl_hotel_original`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$tbl_hotel->hotel_or_id->ViewValue = $rswrk->fields('name');
					$rswrk->Close();
				} else {
					$tbl_hotel->hotel_or_id->ViewValue = $tbl_hotel->hotel_or_id->CurrentValue;
				}
			} else {
				$tbl_hotel->hotel_or_id->ViewValue = NULL;
			}
			$tbl_hotel->hotel_or_id->CssStyle = "";
			$tbl_hotel->hotel_or_id->CssClass = "";
			$tbl_hotel->hotel_or_id->ViewCustomAttributes = "";

			// language_id
			if (strval($tbl_hotel->language_id->CurrentValue) <> "") {
				$sFilterWrk = "`language_id` = " . ew_AdjustSql($tbl_hotel->language_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `language` FROM `tbl_language`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$tbl_hotel->language_id->ViewValue = $rswrk->fields('language');
					$rswrk->Close();
				} else {
					$tbl_hotel->language_id->ViewValue = $tbl_hotel->language_id->CurrentValue;
				}
			} else {
				$tbl_hotel->language_id->ViewValue = NULL;
			}
			$tbl_hotel->language_id->CssStyle = "";
			$tbl_hotel->language_id->CssClass = "";
			$tbl_hotel->language_id->ViewCustomAttributes = "";

			// country_id
			if (strval($tbl_hotel->country_id->CurrentValue) <> "") {
				$sFilterWrk = "`country_id` = " . ew_AdjustSql($tbl_hotel->country_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `country_name` FROM `tbl_country`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$tbl_hotel->country_id->ViewValue = $rswrk->fields('country_name');
					$rswrk->Close();
				} else {
					$tbl_hotel->country_id->ViewValue = $tbl_hotel->country_id->CurrentValue;
				}
			} else {
				$tbl_hotel->country_id->ViewValue = NULL;
			}
			$tbl_hotel->country_id->CssStyle = "";
			$tbl_hotel->country_id->CssClass = "";
			$tbl_hotel->country_id->ViewCustomAttributes = "";

			// province_id
			if (strval($tbl_hotel->province_id->CurrentValue) <> "") {
				$sFilterWrk = "`province_id` = " . ew_AdjustSql($tbl_hotel->province_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `province_name` FROM `tbl_province`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$tbl_hotel->province_id->ViewValue = $rswrk->fields('province_name');
					$rswrk->Close();
				} else {
					$tbl_hotel->province_id->ViewValue = $tbl_hotel->province_id->CurrentValue;
				}
			} else {
				$tbl_hotel->province_id->ViewValue = NULL;
			}
			$tbl_hotel->province_id->CssStyle = "";
			$tbl_hotel->province_id->CssClass = "";
			$tbl_hotel->province_id->ViewCustomAttributes = "";

			// category
			if (strval($tbl_hotel->category->CurrentValue) <> "") {
				switch ($tbl_hotel->category->CurrentValue) {
					case "34":
						$tbl_hotel->category->ViewValue = "3 Starts Hotel";
						break;
					case "43":
						$tbl_hotel->category->ViewValue = "4 Starts Hotel";
						break;
					case "5":
						$tbl_hotel->category->ViewValue = "5 Starts Hotel";
						break;
					case "boutiqu":
						$tbl_hotel->category->ViewValue = "Boutique";
						break;
					case "eco":
						$tbl_hotel->category->ViewValue = "Eco-Lodge & Resort";
						break;
					default:
						$tbl_hotel->category->ViewValue = $tbl_hotel->category->CurrentValue;
				}
			} else {
				$tbl_hotel->category->ViewValue = NULL;
			}
			$tbl_hotel->category->CssStyle = "";
			$tbl_hotel->category->CssClass = "";
			$tbl_hotel->category->ViewCustomAttributes = "";

			// photo
			if (!ew_Empty($tbl_hotel->photo->Upload->DbValue)) {
				$tbl_hotel->photo->ViewValue = $tbl_hotel->photo->Upload->DbValue;
				$tbl_hotel->photo->ImageWidth = 180;
				$tbl_hotel->photo->ImageHeight = 0;
				$tbl_hotel->photo->ImageAlt = $tbl_hotel->photo->FldAlt();
			} else {
				$tbl_hotel->photo->ViewValue = "";
			}
			$tbl_hotel->photo->CssStyle = "";
			$tbl_hotel->photo->CssClass = "";
			$tbl_hotel->photo->ViewCustomAttributes = "";

			// hotel_name
			$tbl_hotel->hotel_name->ViewValue = $tbl_hotel->hotel_name->CurrentValue;
			$tbl_hotel->hotel_name->CssStyle = "";
			$tbl_hotel->hotel_name->CssClass = "";
			$tbl_hotel->hotel_name->ViewCustomAttributes = "";

			// descriptioin
			$tbl_hotel->descriptioin->ViewValue = $tbl_hotel->descriptioin->CurrentValue;
			$tbl_hotel->descriptioin->CssStyle = "";
			$tbl_hotel->descriptioin->CssClass = "";
			$tbl_hotel->descriptioin->ViewCustomAttributes = "";

			// order_by
			$tbl_hotel->order_by->ViewValue = $tbl_hotel->order_by->CurrentValue;
			$tbl_hotel->order_by->CssStyle = "";
			$tbl_hotel->order_by->CssClass = "";
			$tbl_hotel->order_by->ViewCustomAttributes = "";

			// hotel_id
			$tbl_hotel->hotel_id->HrefValue = "";
			$tbl_hotel->hotel_id->TooltipValue = "";

			// hotel_or_id
			$tbl_hotel->hotel_or_id->HrefValue = "";
			$tbl_hotel->hotel_or_id->TooltipValue = "";

			// language_id
			$tbl_hotel->language_id->HrefValue = "";
			$tbl_hotel->language_id->TooltipValue = "";

			// country_id
			$tbl_hotel->country_id->HrefValue = "";
			$tbl_hotel->country_id->TooltipValue = "";

			// province_id
			$tbl_hotel->province_id->HrefValue = "";
			$tbl_hotel->province_id->TooltipValue = "";

			// category
			$tbl_hotel->category->HrefValue = "";
			$tbl_hotel->category->TooltipValue = "";

			// photo
			$tbl_hotel->photo->HrefValue = "";
			$tbl_hotel->photo->TooltipValue = "";

			// hotel_name
			$tbl_hotel->hotel_name->HrefValue = "";
			$tbl_hotel->hotel_name->TooltipValue = "";

			// descriptioin
			$tbl_hotel->descriptioin->HrefValue = "";
			$tbl_hotel->descriptioin->TooltipValue = "";

			// order_by
			$tbl_hotel->order_by->HrefValue = "";
			$tbl_hotel->order_by->TooltipValue = "";
		} elseif ($tbl_hotel->RowType == EW_ROWTYPE_EDIT) { // Edit row

			// hotel_id
			$tbl_hotel->hotel_id->EditCustomAttributes = "";
			$tbl_hotel->hotel_id->EditValue = $tbl_hotel->hotel_id->CurrentValue;
			$tbl_hotel->hotel_id->CssStyle = "";
			$tbl_hotel->hotel_id->CssClass = "";
			$tbl_hotel->hotel_id->ViewCustomAttributes = "";

			// hotel_or_id
			$tbl_hotel->hotel_or_id->EditCustomAttributes = "";
			if ($tbl_hotel->hotel_or_id->getSessionValue() <> "") {
				$tbl_hotel->hotel_or_id->CurrentValue = $tbl_hotel->hotel_or_id->getSessionValue();
			if (strval($tbl_hotel->hotel_or_id->CurrentValue) <> "") {
				$sFilterWrk = "`hote_or_id` = " . ew_AdjustSql($tbl_hotel->hotel_or_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `name` FROM `tbl_hotel_original`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$tbl_hotel->hotel_or_id->ViewValue = $rswrk->fields('name');
					$rswrk->Close();
				} else {
					$tbl_hotel->hotel_or_id->ViewValue = $tbl_hotel->hotel_or_id->CurrentValue;
				}
			} else {
				$tbl_hotel->hotel_or_id->ViewValue = NULL;
			}
			$tbl_hotel->hotel_or_id->CssStyle = "";
			$tbl_hotel->hotel_or_id->CssClass = "";
			$tbl_hotel->hotel_or_id->ViewCustomAttributes = "";
			} else {
			if (trim(strval($tbl_hotel->hotel_or_id->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$sFilterWrk = "`hote_or_id` = " . ew_AdjustSql($tbl_hotel->hotel_or_id->CurrentValue) . "";
			}
			$sSqlWrk = "SELECT `hote_or_id`, `name`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `tbl_hotel_original`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$tbl_hotel->hotel_or_id->EditValue = $arwrk;
			}

			// language_id
			$tbl_hotel->language_id->EditCustomAttributes = "";
			if ($tbl_hotel->language_id->getSessionValue() <> "") {
				$tbl_hotel->language_id->CurrentValue = $tbl_hotel->language_id->getSessionValue();
			if (strval($tbl_hotel->language_id->CurrentValue) <> "") {
				$sFilterWrk = "`language_id` = " . ew_AdjustSql($tbl_hotel->language_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `language` FROM `tbl_language`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$tbl_hotel->language_id->ViewValue = $rswrk->fields('language');
					$rswrk->Close();
				} else {
					$tbl_hotel->language_id->ViewValue = $tbl_hotel->language_id->CurrentValue;
				}
			} else {
				$tbl_hotel->language_id->ViewValue = NULL;
			}
			$tbl_hotel->language_id->CssStyle = "";
			$tbl_hotel->language_id->CssClass = "";
			$tbl_hotel->language_id->ViewCustomAttributes = "";
			} else {
			if (trim(strval($tbl_hotel->language_id->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$sFilterWrk = "`language_id` = " . ew_AdjustSql($tbl_hotel->language_id->CurrentValue) . "";
			}
			$sSqlWrk = "SELECT `language_id`, `language`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `tbl_language`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$tbl_hotel->language_id->EditValue = $arwrk;
			}

			// country_id
			$tbl_hotel->country_id->EditCustomAttributes = "";
			if ($tbl_hotel->country_id->getSessionValue() <> "") {
				$tbl_hotel->country_id->CurrentValue = $tbl_hotel->country_id->getSessionValue();
			if (strval($tbl_hotel->country_id->CurrentValue) <> "") {
				$sFilterWrk = "`country_id` = " . ew_AdjustSql($tbl_hotel->country_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `country_name` FROM `tbl_country`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$tbl_hotel->country_id->ViewValue = $rswrk->fields('country_name');
					$rswrk->Close();
				} else {
					$tbl_hotel->country_id->ViewValue = $tbl_hotel->country_id->CurrentValue;
				}
			} else {
				$tbl_hotel->country_id->ViewValue = NULL;
			}
			$tbl_hotel->country_id->CssStyle = "";
			$tbl_hotel->country_id->CssClass = "";
			$tbl_hotel->country_id->ViewCustomAttributes = "";
			} else {
			if (trim(strval($tbl_hotel->country_id->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$sFilterWrk = "`country_id` = " . ew_AdjustSql($tbl_hotel->country_id->CurrentValue) . "";
			}
			$sSqlWrk = "SELECT `country_id`, `country_name`, '' AS Disp2Fld, `lagnuage_id` FROM `tbl_country`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), ""));
			$tbl_hotel->country_id->EditValue = $arwrk;
			}

			// province_id
			$tbl_hotel->province_id->EditCustomAttributes = "";
			if ($tbl_hotel->province_id->getSessionValue() <> "") {
				$tbl_hotel->province_id->CurrentValue = $tbl_hotel->province_id->getSessionValue();
			if (strval($tbl_hotel->province_id->CurrentValue) <> "") {
				$sFilterWrk = "`province_id` = " . ew_AdjustSql($tbl_hotel->province_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `province_name` FROM `tbl_province`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$tbl_hotel->province_id->ViewValue = $rswrk->fields('province_name');
					$rswrk->Close();
				} else {
					$tbl_hotel->province_id->ViewValue = $tbl_hotel->province_id->CurrentValue;
				}
			} else {
				$tbl_hotel->province_id->ViewValue = NULL;
			}
			$tbl_hotel->province_id->CssStyle = "";
			$tbl_hotel->province_id->CssClass = "";
			$tbl_hotel->province_id->ViewCustomAttributes = "";
			} else {
			if (trim(strval($tbl_hotel->province_id->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$sFilterWrk = "`province_id` = " . ew_AdjustSql($tbl_hotel->province_id->CurrentValue) . "";
			}
			$sSqlWrk = "SELECT `province_id`, `province_name`, '' AS Disp2Fld, `country_id` FROM `tbl_province`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), ""));
			$tbl_hotel->province_id->EditValue = $arwrk;
			}

			// category
			$tbl_hotel->category->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array("34", "3 Starts Hotel");
			$arwrk[] = array("43", "4 Starts Hotel");
			$arwrk[] = array("5", "5 Starts Hotel");
			$arwrk[] = array("boutiqu", "Boutique");
			$arwrk[] = array("eco", "Eco-Lodge & Resort");
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$tbl_hotel->category->EditValue = $arwrk;

			// photo
			$tbl_hotel->photo->EditCustomAttributes = "";
			if (!ew_Empty($tbl_hotel->photo->Upload->DbValue)) {
				$tbl_hotel->photo->EditValue = $tbl_hotel->photo->Upload->DbValue;
				$tbl_hotel->photo->ImageWidth = 180;
				$tbl_hotel->photo->ImageHeight = 0;
				$tbl_hotel->photo->ImageAlt = $tbl_hotel->photo->FldAlt();
			} else {
				$tbl_hotel->photo->EditValue = "";
			}

			// hotel_name
			$tbl_hotel->hotel_name->EditCustomAttributes = "";
			$tbl_hotel->hotel_name->EditValue = ew_HtmlEncode($tbl_hotel->hotel_name->CurrentValue);

			// descriptioin
			$tbl_hotel->descriptioin->EditCustomAttributes = "";
			$tbl_hotel->descriptioin->EditValue = ew_HtmlEncode($tbl_hotel->descriptioin->CurrentValue);

			// order_by
			$tbl_hotel->order_by->EditCustomAttributes = "";
			$tbl_hotel->order_by->EditValue = ew_HtmlEncode($tbl_hotel->order_by->CurrentValue);

			// Edit refer script
			// hotel_id

			$tbl_hotel->hotel_id->HrefValue = "";

			// hotel_or_id
			$tbl_hotel->hotel_or_id->HrefValue = "";

			// language_id
			$tbl_hotel->language_id->HrefValue = "";

			// country_id
			$tbl_hotel->country_id->HrefValue = "";

			// province_id
			$tbl_hotel->province_id->HrefValue = "";

			// category
			$tbl_hotel->category->HrefValue = "";

			// photo
			$tbl_hotel->photo->HrefValue = "";

			// hotel_name
			$tbl_hotel->hotel_name->HrefValue = "";

			// descriptioin
			$tbl_hotel->descriptioin->HrefValue = "";

			// order_by
			$tbl_hotel->order_by->HrefValue = "";
		}

		// Call Row Rendered event
		if ($tbl_hotel->RowType <> EW_ROWTYPE_AGGREGATEINIT)
			$tbl_hotel->Row_Rendered();
	}

	// Validate form
	function ValidateForm() {
		global $Language, $gsFormError, $tbl_hotel;

		// Initialize form error message
		$gsFormError = "";
		if (!ew_CheckFileType($tbl_hotel->photo->Upload->FileName)) {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("WrongFileType");
		}
		if ($tbl_hotel->photo->Upload->FileSize > 0 && EW_MAX_FILE_SIZE > 0 && $tbl_hotel->photo->Upload->FileSize > EW_MAX_FILE_SIZE) {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= str_replace("%s", EW_MAX_FILE_SIZE, $Language->Phrase("MaxFileSize"));
		}
		if (in_array($tbl_hotel->photo->Upload->Error, array(1, 2, 3, 6, 7, 8))) {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("PhpUploadErr" . $tbl_hotel->photo->Upload->Error);
		}

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return ($gsFormError == "");
		if (!is_null($tbl_hotel->hotel_or_id->FormValue) && $tbl_hotel->hotel_or_id->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $tbl_hotel->hotel_or_id->FldCaption();
		}
		if (!is_null($tbl_hotel->language_id->FormValue) && $tbl_hotel->language_id->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $tbl_hotel->language_id->FldCaption();
		}
		if (!is_null($tbl_hotel->country_id->FormValue) && $tbl_hotel->country_id->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $tbl_hotel->country_id->FldCaption();
		}
		if (!is_null($tbl_hotel->province_id->FormValue) && $tbl_hotel->province_id->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $tbl_hotel->province_id->FldCaption();
		}
		if (!is_null($tbl_hotel->category->FormValue) && $tbl_hotel->category->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $tbl_hotel->category->FldCaption();
		}
		if ($tbl_hotel->photo->Upload->Action == "3" && is_null($tbl_hotel->photo->Upload->Value)) {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $tbl_hotel->photo->FldCaption();
		}
		if (!is_null($tbl_hotel->hotel_name->FormValue) && $tbl_hotel->hotel_name->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $tbl_hotel->hotel_name->FldCaption();
		}
		if (!is_null($tbl_hotel->descriptioin->FormValue) && $tbl_hotel->descriptioin->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $tbl_hotel->descriptioin->FldCaption();
		}
		if (!is_null($tbl_hotel->order_by->FormValue) && $tbl_hotel->order_by->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $tbl_hotel->order_by->FldCaption();
		}
		if (!ew_CheckInteger($tbl_hotel->order_by->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $tbl_hotel->order_by->FldErrMsg();
		}

		// Return validate result
		$ValidateForm = ($gsFormError == "");

		// Call Form_CustomValidate event
		$sFormCustomError = "";
		$ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
		if ($sFormCustomError <> "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $sFormCustomError;
		}
		return $ValidateForm;
	}

	// Update record based on key values
	function EditRow() {
		global $conn, $Security, $Language, $tbl_hotel;
		$sFilter = $tbl_hotel->KeyFilter();
		$tbl_hotel->CurrentFilter = $sFilter;
		$sSql = $tbl_hotel->SQL();
		$conn->raiseErrorFn = 'ew_ErrorFn';
		$rs = $conn->Execute($sSql);
		$conn->raiseErrorFn = '';
		if ($rs === FALSE)
			return FALSE;
		if ($rs->EOF) {
			$EditRow = FALSE; // Update Failed
		} else {

			// Save old values
			$rsold =& $rs->fields;
			$rsnew = array();

			// hotel_or_id
			$tbl_hotel->hotel_or_id->SetDbValueDef($rsnew, $tbl_hotel->hotel_or_id->CurrentValue, 0, FALSE);

			// language_id
			$tbl_hotel->language_id->SetDbValueDef($rsnew, $tbl_hotel->language_id->CurrentValue, 0, FALSE);

			// country_id
			$tbl_hotel->country_id->SetDbValueDef($rsnew, $tbl_hotel->country_id->CurrentValue, 0, FALSE);

			// province_id
			$tbl_hotel->province_id->SetDbValueDef($rsnew, $tbl_hotel->province_id->CurrentValue, 0, FALSE);

			// category
			$tbl_hotel->category->SetDbValueDef($rsnew, $tbl_hotel->category->CurrentValue, "", FALSE);

			// photo
			$tbl_hotel->photo->Upload->SaveToSession(); // Save file value to Session
						if ($tbl_hotel->photo->Upload->Action == "2" || $tbl_hotel->photo->Upload->Action == "3") { // Update/Remove
			$tbl_hotel->photo->Upload->DbValue = $rs->fields('photo'); // Get original value
			if (is_null($tbl_hotel->photo->Upload->Value)) {
				$rsnew['photo'] = NULL;
			} else {
				if ($tbl_hotel->photo->Upload->FileName == $tbl_hotel->photo->Upload->DbValue) { // Upload file name same as old file name
					$rsnew['photo'] = $tbl_hotel->photo->Upload->FileName;
				} else {
					$rsnew['photo'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $tbl_hotel->photo->UploadPath), $tbl_hotel->photo->Upload->FileName);
				}
			}
			$tbl_hotel->photo->ImageWidth = 180; // Resize width
			$tbl_hotel->photo->ImageHeight = 120; // Resize height
			}

			// hotel_name
			$tbl_hotel->hotel_name->SetDbValueDef($rsnew, $tbl_hotel->hotel_name->CurrentValue, "", FALSE);

			// descriptioin
			$tbl_hotel->descriptioin->SetDbValueDef($rsnew, $tbl_hotel->descriptioin->CurrentValue, "", FALSE);

			// order_by
			$tbl_hotel->order_by->SetDbValueDef($rsnew, $tbl_hotel->order_by->CurrentValue, 0, FALSE);

			// Call Row Updating event
			$bUpdateRow = $tbl_hotel->Row_Updating($rsold, $rsnew);
			if ($bUpdateRow) {
			if (!ew_Empty($tbl_hotel->photo->Upload->Value)) {
				$tbl_hotel->photo->Upload->RestoreFromSession(); // Restore original value
				$tbl_hotel->photo->Upload->Resize($tbl_hotel->photo->ImageWidth, $tbl_hotel->photo->ImageHeight, 75);
			}
			$tbl_hotel->photo->ImageWidth = 0; // Reset image width
			$tbl_hotel->photo->ImageHeight = 0; // Reset image height
			if (!ew_Empty($tbl_hotel->photo->Upload->Value)) {
				if ($tbl_hotel->photo->Upload->FileName == $tbl_hotel->photo->Upload->DbValue) { // Overwrite if same file name
					$tbl_hotel->photo->Upload->SaveToFile($tbl_hotel->photo->UploadPath, $rsnew['photo'], TRUE);
					$tbl_hotel->photo->Upload->DbValue = ""; // No need to delete any more
				} else {
					$tbl_hotel->photo->Upload->SaveToFile($tbl_hotel->photo->UploadPath, $rsnew['photo'], FALSE);
				}
			}
			if ($tbl_hotel->photo->Upload->Action == "2" || $tbl_hotel->photo->Upload->Action == "3") { // Update/Remove
				if ($tbl_hotel->photo->Upload->DbValue <> "")
					@unlink(ew_UploadPathEx(TRUE, $tbl_hotel->photo->UploadPath) . $tbl_hotel->photo->Upload->DbValue);
			}
				$conn->raiseErrorFn = 'ew_ErrorFn';
				$EditRow = $conn->Execute($tbl_hotel->UpdateSQL($rsnew));
				$conn->raiseErrorFn = '';
			} else {
				if ($tbl_hotel->CancelMessage <> "") {
					$this->setMessage($tbl_hotel->CancelMessage);
					$tbl_hotel->CancelMessage = "";
				} else {
					$this->setMessage($Language->Phrase("UpdateCancelled"));
				}
				$EditRow = FALSE;
			}
		}

		// Call Row_Updated event
		if ($EditRow)
			$tbl_hotel->Row_Updated($rsold, $rsnew);
		$rs->Close();

		// photo
		$tbl_hotel->photo->Upload->RemoveFromSession(); // Remove file value from Session
		return $EditRow;
	}

	// Set up master/detail based on QueryString
	function SetUpMasterDetail() {
		global $tbl_hotel;
		$bValidMaster = FALSE;

		// Get the keys for master table
		if (@$_GET[EW_TABLE_SHOW_MASTER] <> "") {
			$sMasterTblVar = $_GET[EW_TABLE_SHOW_MASTER];
			if ($sMasterTblVar == "") {
				$bValidMaster = TRUE;
				$this->sDbMasterFilter = "";
				$this->sDbDetailFilter = "";
			}
			if ($sMasterTblVar == "tbl_hotel_original") {
				$bValidMaster = TRUE;
				$this->sDbMasterFilter = $tbl_hotel->SqlMasterFilter_tbl_hotel_original();
				$this->sDbDetailFilter = $tbl_hotel->SqlDetailFilter_tbl_hotel_original();
				if (@$_GET["hote_or_id"] <> "") {
					$GLOBALS["tbl_hotel_original"]->hote_or_id->setQueryStringValue($_GET["hote_or_id"]);
					$tbl_hotel->hotel_or_id->setQueryStringValue($GLOBALS["tbl_hotel_original"]->hote_or_id->QueryStringValue);
					$tbl_hotel->hotel_or_id->setSessionValue($tbl_hotel->hotel_or_id->QueryStringValue);
					if (!is_numeric($GLOBALS["tbl_hotel_original"]->hote_or_id->QueryStringValue)) $bValidMaster = FALSE;
					$this->sDbMasterFilter = str_replace("@hote_or_id@", ew_AdjustSql($GLOBALS["tbl_hotel_original"]->hote_or_id->QueryStringValue), $this->sDbMasterFilter);
					$this->sDbDetailFilter = str_replace("@hotel_or_id@", ew_AdjustSql($GLOBALS["tbl_hotel_original"]->hote_or_id->QueryStringValue), $this->sDbDetailFilter);
				} else {
					$bValidMaster = FALSE;
				}
			}
			if ($sMasterTblVar == "tbl_language") {
				$bValidMaster = TRUE;
				$this->sDbMasterFilter = $tbl_hotel->SqlMasterFilter_tbl_language();
				$this->sDbDetailFilter = $tbl_hotel->SqlDetailFilter_tbl_language();
				if (@$_GET["language_id"] <> "") {
					$GLOBALS["tbl_language"]->language_id->setQueryStringValue($_GET["language_id"]);
					$tbl_hotel->language_id->setQueryStringValue($GLOBALS["tbl_language"]->language_id->QueryStringValue);
					$tbl_hotel->language_id->setSessionValue($tbl_hotel->language_id->QueryStringValue);
					if (!is_numeric($GLOBALS["tbl_language"]->language_id->QueryStringValue)) $bValidMaster = FALSE;
					$this->sDbMasterFilter = str_replace("@language_id@", ew_AdjustSql($GLOBALS["tbl_language"]->language_id->QueryStringValue), $this->sDbMasterFilter);
					$this->sDbDetailFilter = str_replace("@language_id@", ew_AdjustSql($GLOBALS["tbl_language"]->language_id->QueryStringValue), $this->sDbDetailFilter);
				} else {
					$bValidMaster = FALSE;
				}
			}
			if ($sMasterTblVar == "tbl_country") {
				$bValidMaster = TRUE;
				$this->sDbMasterFilter = $tbl_hotel->SqlMasterFilter_tbl_country();
				$this->sDbDetailFilter = $tbl_hotel->SqlDetailFilter_tbl_country();
				if (@$_GET["country_id"] <> "") {
					$GLOBALS["tbl_country"]->country_id->setQueryStringValue($_GET["country_id"]);
					$tbl_hotel->country_id->setQueryStringValue($GLOBALS["tbl_country"]->country_id->QueryStringValue);
					$tbl_hotel->country_id->setSessionValue($tbl_hotel->country_id->QueryStringValue);
					if (!is_numeric($GLOBALS["tbl_country"]->country_id->QueryStringValue)) $bValidMaster = FALSE;
					$this->sDbMasterFilter = str_replace("@country_id@", ew_AdjustSql($GLOBALS["tbl_country"]->country_id->QueryStringValue), $this->sDbMasterFilter);
					$this->sDbDetailFilter = str_replace("@country_id@", ew_AdjustSql($GLOBALS["tbl_country"]->country_id->QueryStringValue), $this->sDbDetailFilter);
				} else {
					$bValidMaster = FALSE;
				}
			}
			if ($sMasterTblVar == "tbl_province") {
				$bValidMaster = TRUE;
				$this->sDbMasterFilter = $tbl_hotel->SqlMasterFilter_tbl_province();
				$this->sDbDetailFilter = $tbl_hotel->SqlDetailFilter_tbl_province();
				if (@$_GET["province_id"] <> "") {
					$GLOBALS["tbl_province"]->province_id->setQueryStringValue($_GET["province_id"]);
					$tbl_hotel->province_id->setQueryStringValue($GLOBALS["tbl_province"]->province_id->QueryStringValue);
					$tbl_hotel->province_id->setSessionValue($tbl_hotel->province_id->QueryStringValue);
					if (!is_numeric($GLOBALS["tbl_province"]->province_id->QueryStringValue)) $bValidMaster = FALSE;
					$this->sDbMasterFilter = str_replace("@province_id@", ew_AdjustSql($GLOBALS["tbl_province"]->province_id->QueryStringValue), $this->sDbMasterFilter);
					$this->sDbDetailFilter = str_replace("@province_id@", ew_AdjustSql($GLOBALS["tbl_province"]->province_id->QueryStringValue), $this->sDbDetailFilter);
				} else {
					$bValidMaster = FALSE;
				}
			}
		}
		if ($bValidMaster) {

			// Save current master table
			$tbl_hotel->setCurrentMasterTable($sMasterTblVar);

			// Reset start record counter (new master key)
			$this->lStartRec = 1;
			$tbl_hotel->setStartRecordNumber($this->lStartRec);
			$tbl_hotel->setMasterFilter($this->sDbMasterFilter); // Set up master filter
			$tbl_hotel->setDetailFilter($this->sDbDetailFilter); // Set up detail filter

			// Clear previous master key from Session
			if ($sMasterTblVar <> "tbl_hotel_original") {
				if ($tbl_hotel->hotel_or_id->QueryStringValue == "") $tbl_hotel->hotel_or_id->setSessionValue("");
			}
			if ($sMasterTblVar <> "tbl_language") {
				if ($tbl_hotel->language_id->QueryStringValue == "") $tbl_hotel->language_id->setSessionValue("");
			}
			if ($sMasterTblVar <> "tbl_country") {
				if ($tbl_hotel->country_id->QueryStringValue == "") $tbl_hotel->country_id->setSessionValue("");
			}
			if ($sMasterTblVar <> "tbl_province") {
				if ($tbl_hotel->province_id->QueryStringValue == "") $tbl_hotel->province_id->setSessionValue("");
			}
		} else {
			$this->sDbMasterFilter = $tbl_hotel->getMasterFilter(); //  Restore master filter
			$this->sDbDetailFilter = $tbl_hotel->getDetailFilter(); // Restore detail filter
		}
	}

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Page Redirecting event
	function Page_Redirecting(&$url) {

		// Example:
		//$url = "your URL";

	}

	// Message Showing event
	function Message_Showing(&$msg) {

		// Example:
		//$msg = "your new message";

	}

	// Form Custom Validate event
	function Form_CustomValidate(&$CustomError) {

		// Return error message in CustomError
		return TRUE;
	}
}
?>
