<?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_allphotoinfo.php" ?>
<?php include "tbl_admininfo.php" ?>
<?php include "tbl_hotelinfo.php" ?>
<?php include "tbl_tourinfo.php" ?>
<?php include "tbl_travelinfo.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_allphoto_list = new ctbl_allphoto_list();
$Page =& $tbl_allphoto_list;

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

// Page main
$tbl_allphoto_list->Page_Main();
?>
<?php include "header.php" ?>
<?php if ($tbl_allphoto->Export == "") { ?>
<script type="text/javascript">
<!--

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

// page properties
tbl_allphoto_list.PageID = "list"; // page ID
tbl_allphoto_list.FormID = "ftbl_allphotolist"; // form ID
var EW_PAGE_ID = tbl_allphoto_list.PageID; // for backward compatibility

// extend page with Form_CustomValidate function
tbl_allphoto_list.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_allphoto_list.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
tbl_allphoto_list.ValidateRequired = false; // no JavaScript validation
<?php } ?>

//-->
</script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];

//-->
</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>
<?php } ?>
<?php if ($tbl_allphoto->Export == "") { ?>
<?php
$gsMasterReturnUrl = "tbl_hotellist.php";
if ($tbl_allphoto_list->sDbMasterFilter <> "" && $tbl_allphoto->getCurrentMasterTable() == "tbl_hotel") {
	if ($tbl_allphoto_list->bMasterRecordExists) {
		if ($tbl_allphoto->getCurrentMasterTable() == $tbl_allphoto->TableVar) $gsMasterReturnUrl .= "?" . EW_TABLE_SHOW_MASTER . "=";
?>
<?php include "tbl_hotelmaster.php" ?>
<?php
	}
}
?>
<?php
$gsMasterReturnUrl = "tbl_tourlist.php";
if ($tbl_allphoto_list->sDbMasterFilter <> "" && $tbl_allphoto->getCurrentMasterTable() == "tbl_tour") {
	if ($tbl_allphoto_list->bMasterRecordExists) {
		if ($tbl_allphoto->getCurrentMasterTable() == $tbl_allphoto->TableVar) $gsMasterReturnUrl .= "?" . EW_TABLE_SHOW_MASTER . "=";
?>
<?php include "tbl_tourmaster.php" ?>
<?php
	}
}
?>
<?php
$gsMasterReturnUrl = "tbl_travellist.php";
if ($tbl_allphoto_list->sDbMasterFilter <> "" && $tbl_allphoto->getCurrentMasterTable() == "tbl_travel") {
	if ($tbl_allphoto_list->bMasterRecordExists) {
		if ($tbl_allphoto->getCurrentMasterTable() == $tbl_allphoto->TableVar) $gsMasterReturnUrl .= "?" . EW_TABLE_SHOW_MASTER . "=";
?>
<?php include "tbl_travelmaster.php" ?>
<?php
	}
}
?>
<?php } ?>
<?php
	$bSelectLimit = EW_SELECT_LIMIT;
	if ($bSelectLimit) {
		$tbl_allphoto_list->lTotalRecs = $tbl_allphoto->SelectRecordCount();
	} else {
		if ($rs = $tbl_allphoto_list->LoadRecordset())
			$tbl_allphoto_list->lTotalRecs = $rs->RecordCount();
	}
	$tbl_allphoto_list->lStartRec = 1;
	if ($tbl_allphoto_list->lDisplayRecs <= 0 || ($tbl_allphoto->Export <> "" && $tbl_allphoto->ExportAll)) // Display all records
		$tbl_allphoto_list->lDisplayRecs = $tbl_allphoto_list->lTotalRecs;
	if (!($tbl_allphoto->Export <> "" && $tbl_allphoto->ExportAll))
		$tbl_allphoto_list->SetUpStartRec(); // Set up start record position
	if ($bSelectLimit)
		$rs = $tbl_allphoto_list->LoadRecordset($tbl_allphoto_list->lStartRec-1, $tbl_allphoto_list->lDisplayRecs);
?>
<p><span class="phpmaker" style="white-space: nowrap;"><?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $tbl_allphoto->TableCaption() ?>
</span></p>
<?php if ($Security->IsLoggedIn()) { ?>
<?php if ($tbl_allphoto->Export == "" && $tbl_allphoto->CurrentAction == "") { ?>
<a href="javascript:ew_ToggleSearchPanel(tbl_allphoto_list);" style="text-decoration: none;"><img id="tbl_allphoto_list_SearchImage" src="images/collapse.gif" alt="" width="9" height="9" border="0"></a><span class="phpmaker">&nbsp;<?php echo $Language->Phrase("Search") ?></span><br>
<div id="tbl_allphoto_list_SearchPanel">
<form name="ftbl_allphotolistsrch" id="ftbl_allphotolistsrch" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
<input type="hidden" id="t" name="t" value="tbl_allphoto">
<table class="ewBasicSearch">
	<tr>
		<td><span class="phpmaker">
			<input type="text" name="<?php echo EW_TABLE_BASIC_SEARCH ?>" id="<?php echo EW_TABLE_BASIC_SEARCH ?>" size="20" value="<?php echo ew_HtmlEncode($tbl_allphoto->getSessionBasicSearchKeyword()) ?>">
			<input type="Submit" name="Submit" id="Submit" value="<?php echo ew_BtnCaption($Language->Phrase("QuickSearchBtn")) ?>">&nbsp;
			<a href="<?php echo $tbl_allphoto_list->PageUrl() ?>cmd=reset"><?php echo $Language->Phrase("ShowAll") ?></a>&nbsp;
		</span></td>
	</tr>
	<tr>
	<td><span class="phpmaker"><label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value=""<?php if ($tbl_allphoto->getSessionBasicSearchType() == "") { ?> checked="checked"<?php } ?>><?php echo $Language->Phrase("ExactPhrase") ?></label>&nbsp;&nbsp;<label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="AND"<?php if ($tbl_allphoto->getSessionBasicSearchType() == "AND") { ?> checked="checked"<?php } ?>><?php echo $Language->Phrase("AllWord") ?></label>&nbsp;&nbsp;<label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="OR"<?php if ($tbl_allphoto->getSessionBasicSearchType() == "OR") { ?> checked="checked"<?php } ?>><?php echo $Language->Phrase("AnyWord") ?></label></span></td>
	</tr>
</table>
</form>
</div>
<?php } ?>
<?php } ?>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$tbl_allphoto_list->ShowMessage();
?>
<br>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<form name="ftbl_allphotolist" id="ftbl_allphotolist" class="ewForm" action="" method="post">
<div id="gmp_tbl_allphoto" class="ewGridMiddlePanel">
<?php if ($tbl_allphoto_list->lTotalRecs > 0) { ?>
<table cellspacing="0" rowhighlightclass="ewTableHighlightRow" rowselectclass="ewTableSelectRow" roweditclass="ewTableEditRow" class="ewTable ewTableSeparate">
<?php echo $tbl_allphoto->TableCustomInnerHtml ?>
<thead><!-- Table header -->
	<tr class="ewTableHeader">
<?php

// Render list options
$tbl_allphoto_list->RenderListOptions();

// Render list options (header, left)
$tbl_allphoto_list->ListOptions->Render("header", "left");
?>
<?php if ($tbl_allphoto->hotel_id->Visible) { // hotel_id ?>
	<?php if ($tbl_allphoto->SortUrl($tbl_allphoto->hotel_id) == "") { ?>
		<td><?php echo $tbl_allphoto->hotel_id->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $tbl_allphoto->SortUrl($tbl_allphoto->hotel_id) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $tbl_allphoto->hotel_id->FldCaption() ?></td><td style="width: 10px;"><?php if ($tbl_allphoto->hotel_id->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($tbl_allphoto->hotel_id->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($tbl_allphoto->tour_id->Visible) { // tour_id ?>
	<?php if ($tbl_allphoto->SortUrl($tbl_allphoto->tour_id) == "") { ?>
		<td><?php echo $tbl_allphoto->tour_id->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $tbl_allphoto->SortUrl($tbl_allphoto->tour_id) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $tbl_allphoto->tour_id->FldCaption() ?></td><td style="width: 10px;"><?php if ($tbl_allphoto->tour_id->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($tbl_allphoto->tour_id->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($tbl_allphoto->travel_id->Visible) { // travel_id ?>
	<?php if ($tbl_allphoto->SortUrl($tbl_allphoto->travel_id) == "") { ?>
		<td><?php echo $tbl_allphoto->travel_id->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $tbl_allphoto->SortUrl($tbl_allphoto->travel_id) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $tbl_allphoto->travel_id->FldCaption() ?></td><td style="width: 10px;"><?php if ($tbl_allphoto->travel_id->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($tbl_allphoto->travel_id->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($tbl_allphoto->photo->Visible) { // photo ?>
	<?php if ($tbl_allphoto->SortUrl($tbl_allphoto->photo) == "") { ?>
		<td><?php echo $tbl_allphoto->photo->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $tbl_allphoto->SortUrl($tbl_allphoto->photo) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $tbl_allphoto->photo->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($tbl_allphoto->photo->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($tbl_allphoto->photo->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($tbl_allphoto->photo_thum->Visible) { // photo_thum ?>
	<?php if ($tbl_allphoto->SortUrl($tbl_allphoto->photo_thum) == "") { ?>
		<td><?php echo $tbl_allphoto->photo_thum->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $tbl_allphoto->SortUrl($tbl_allphoto->photo_thum) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $tbl_allphoto->photo_thum->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($tbl_allphoto->photo_thum->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($tbl_allphoto->photo_thum->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($tbl_allphoto->order_by->Visible) { // order_by ?>
	<?php if ($tbl_allphoto->SortUrl($tbl_allphoto->order_by) == "") { ?>
		<td><?php echo $tbl_allphoto->order_by->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $tbl_allphoto->SortUrl($tbl_allphoto->order_by) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $tbl_allphoto->order_by->FldCaption() ?></td><td style="width: 10px;"><?php if ($tbl_allphoto->order_by->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($tbl_allphoto->order_by->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php

// Render list options (header, right)
$tbl_allphoto_list->ListOptions->Render("header", "right");
?>
	</tr>
</thead>
<?php
if ($tbl_allphoto->ExportAll && $tbl_allphoto->Export <> "") {
	$tbl_allphoto_list->lStopRec = $tbl_allphoto_list->lTotalRecs;
} else {
	$tbl_allphoto_list->lStopRec = $tbl_allphoto_list->lStartRec + $tbl_allphoto_list->lDisplayRecs - 1; // Set the last record to display
}
$tbl_allphoto_list->lRecCount = $tbl_allphoto_list->lStartRec - 1;
if ($rs && !$rs->EOF) {
	$rs->MoveFirst();
	if (!$bSelectLimit && $tbl_allphoto_list->lStartRec > 1)
		$rs->Move($tbl_allphoto_list->lStartRec - 1);
}

// Initialize aggregate
$tbl_allphoto->RowType = EW_ROWTYPE_AGGREGATEINIT;
$tbl_allphoto_list->RenderRow();
$tbl_allphoto_list->lRowCnt = 0;
while (($tbl_allphoto->CurrentAction == "gridadd" || !$rs->EOF) &&
	$tbl_allphoto_list->lRecCount < $tbl_allphoto_list->lStopRec) {
	$tbl_allphoto_list->lRecCount++;
	if (intval($tbl_allphoto_list->lRecCount) >= intval($tbl_allphoto_list->lStartRec)) {
		$tbl_allphoto_list->lRowCnt++;

	// Init row class and style
	$tbl_allphoto->CssClass = "";
	$tbl_allphoto->CssStyle = "";
	$tbl_allphoto->RowAttrs = array('onmouseover'=>'ew_MouseOver(event, this);', 'onmouseout'=>'ew_MouseOut(event, this);', 'onclick'=>'ew_Click(event, this);');
	if ($tbl_allphoto->CurrentAction == "gridadd") {
		$tbl_allphoto_list->LoadDefaultValues(); // Load default values
	} else {
		$tbl_allphoto_list->LoadRowValues($rs); // Load row values
	}
	$tbl_allphoto->RowType = EW_ROWTYPE_VIEW; // Render view

	// Render row
	$tbl_allphoto_list->RenderRow();

	// Render list options
	$tbl_allphoto_list->RenderListOptions();
?>
	<tr<?php echo $tbl_allphoto->RowAttributes() ?>>
<?php

// Render list options (body, left)
$tbl_allphoto_list->ListOptions->Render("body", "left");
?>
	<?php if ($tbl_allphoto->hotel_id->Visible) { // hotel_id ?>
		<td<?php echo $tbl_allphoto->hotel_id->CellAttributes() ?>>
<div<?php echo $tbl_allphoto->hotel_id->ViewAttributes() ?>><?php echo $tbl_allphoto->hotel_id->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($tbl_allphoto->tour_id->Visible) { // tour_id ?>
		<td<?php echo $tbl_allphoto->tour_id->CellAttributes() ?>>
<div<?php echo $tbl_allphoto->tour_id->ViewAttributes() ?>><?php echo $tbl_allphoto->tour_id->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($tbl_allphoto->travel_id->Visible) { // travel_id ?>
		<td<?php echo $tbl_allphoto->travel_id->CellAttributes() ?>>
<div<?php echo $tbl_allphoto->travel_id->ViewAttributes() ?>><?php echo $tbl_allphoto->travel_id->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($tbl_allphoto->photo->Visible) { // photo ?>
		<td<?php echo $tbl_allphoto->photo->CellAttributes() ?>>
<div<?php echo $tbl_allphoto->photo->ViewAttributes() ?>><?php echo $tbl_allphoto->photo->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($tbl_allphoto->photo_thum->Visible) { // photo_thum ?>
		<td<?php echo $tbl_allphoto->photo_thum->CellAttributes() ?>>
<div<?php echo $tbl_allphoto->photo_thum->ViewAttributes() ?>><?php echo $tbl_allphoto->photo_thum->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($tbl_allphoto->order_by->Visible) { // order_by ?>
		<td<?php echo $tbl_allphoto->order_by->CellAttributes() ?>>
<div<?php echo $tbl_allphoto->order_by->ViewAttributes() ?>><?php echo $tbl_allphoto->order_by->ListViewValue() ?></div>
</td>
	<?php } ?>
<?php

// Render list options (body, right)
$tbl_allphoto_list->ListOptions->Render("body", "right");
?>
	</tr>
<?php
	}
	if ($tbl_allphoto->CurrentAction <> "gridadd")
		$rs->MoveNext();
}
?>
</tbody>
</table>
<?php } ?>
</div>
</form>
<?php

// Close recordset
if ($rs)
	$rs->Close();
?>
<?php if ($tbl_allphoto->Export == "") { ?>
<div class="ewGridLowerPanel">
<?php if ($tbl_allphoto->CurrentAction <> "gridadd" && $tbl_allphoto->CurrentAction <> "gridedit") { ?>
<form name="ewpagerform" id="ewpagerform" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
<table border="0" cellspacing="0" cellpadding="0" class="ewPager">
	<tr>
		<td nowrap>
<span class="phpmaker">
<?php if (!isset($tbl_allphoto_list->Pager)) $tbl_allphoto_list->Pager = new cNumericPager($tbl_allphoto_list->lStartRec, $tbl_allphoto_list->lDisplayRecs, $tbl_allphoto_list->lTotalRecs, $tbl_allphoto_list->lRecRange) ?>
<?php if ($tbl_allphoto_list->Pager->RecordCount > 0) { ?>
	<?php if ($tbl_allphoto_list->Pager->FirstButton->Enabled) { ?>
	<a href="<?php echo $tbl_allphoto_list->PageUrl() ?>start=<?php echo $tbl_allphoto_list->Pager->FirstButton->Start ?>"><b><?php echo $Language->Phrase("PagerFirst") ?></b></a>&nbsp;
	<?php } ?>
	<?php if ($tbl_allphoto_list->Pager->PrevButton->Enabled) { ?>
	<a href="<?php echo $tbl_allphoto_list->PageUrl() ?>start=<?php echo $tbl_allphoto_list->Pager->PrevButton->Start ?>"><b><?php echo $Language->Phrase("PagerPrevious") ?></b></a>&nbsp;
	<?php } ?>
	<?php foreach ($tbl_allphoto_list->Pager->Items as $PagerItem) { ?>
		<?php if ($PagerItem->Enabled) { ?><a href="<?php echo $tbl_allphoto_list->PageUrl() ?>start=<?php echo $PagerItem->Start ?>"><?php } ?><b><?php echo $PagerItem->Text ?></b><?php if ($PagerItem->Enabled) { ?></a><?php } ?>&nbsp;
	<?php } ?>
	<?php if ($tbl_allphoto_list->Pager->NextButton->Enabled) { ?>
	<a href="<?php echo $tbl_allphoto_list->PageUrl() ?>start=<?php echo $tbl_allphoto_list->Pager->NextButton->Start ?>"><b><?php echo $Language->Phrase("PagerNext") ?></b></a>&nbsp;
	<?php } ?>
	<?php if ($tbl_allphoto_list->Pager->LastButton->Enabled) { ?>
	<a href="<?php echo $tbl_allphoto_list->PageUrl() ?>start=<?php echo $tbl_allphoto_list->Pager->LastButton->Start ?>"><b><?php echo $Language->Phrase("PagerLast") ?></b></a>&nbsp;
	<?php } ?>
	<?php if ($tbl_allphoto_list->Pager->ButtonCount > 0) { ?>&nbsp;&nbsp;&nbsp;&nbsp;<?php } ?>
	<?php echo $Language->Phrase("Record") ?>&nbsp;<?php echo $tbl_allphoto_list->Pager->FromIndex ?>&nbsp;<?php echo $Language->Phrase("To") ?>&nbsp;<?php echo $tbl_allphoto_list->Pager->ToIndex ?>&nbsp;<?php echo $Language->Phrase("Of") ?>&nbsp;<?php echo $tbl_allphoto_list->Pager->RecordCount ?>
<?php } else { ?>	
	<?php if ($tbl_allphoto_list->sSrchWhere == "0=101") { ?>
	<?php echo $Language->Phrase("EnterSearchCriteria") ?>
	<?php } else { ?>
	<?php echo $Language->Phrase("NoRecord") ?>
	<?php } ?>
<?php } ?>
</span>
		</td>
	</tr>
</table>
</form>
<?php } ?>
<?php //if ($tbl_allphoto_list->lTotalRecs > 0) { ?>
<span class="phpmaker">
<?php if ($Security->IsLoggedIn()) { ?>
<a href="<?php echo $tbl_allphoto_list->AddUrl ?>"><?php echo $Language->Phrase("AddLink") ?></a>&nbsp;&nbsp;
<?php } ?>
</span>
<?php //} ?>
</div>
<?php } ?>
</td></tr></table>
<?php if ($tbl_allphoto->Export == "" && $tbl_allphoto->CurrentAction == "") { ?>
<?php } ?>
<?php if ($tbl_allphoto->Export == "") { ?>
<script language="JavaScript" type="text/javascript">
<!--

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

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

//
// Page class
//
class ctbl_allphoto_list {

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

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

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

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

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		global $tbl_allphoto;
		if ($tbl_allphoto->UseTokenInUrl) $PageUrl .= "t=" . $tbl_allphoto->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_allphoto;
		if ($tbl_allphoto->UseTokenInUrl) {
			if ($objForm)
				return ($tbl_allphoto->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($tbl_allphoto->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

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

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

		// Table object (tbl_allphoto)
		$GLOBALS["tbl_allphoto"] = new ctbl_allphoto();

		// Initialize URLs
		$this->ExportPrintUrl = $this->PageUrl() . "export=print";
		$this->ExportExcelUrl = $this->PageUrl() . "export=excel";
		$this->ExportWordUrl = $this->PageUrl() . "export=word";
		$this->ExportHtmlUrl = $this->PageUrl() . "export=html";
		$this->ExportXmlUrl = $this->PageUrl() . "export=xml";
		$this->ExportCsvUrl = $this->PageUrl() . "export=csv";
		$this->AddUrl = $GLOBALS["tbl_allphoto"]->AddUrl();
		$this->InlineAddUrl = $this->PageUrl() . "a=add";
		$this->GridAddUrl = $this->PageUrl() . "a=gridadd";
		$this->GridEditUrl = $this->PageUrl() . "a=gridedit";
		$this->MultiDeleteUrl = "tbl_allphotodelete.php";
		$this->MultiUpdateUrl = "tbl_allphotoupdate.php";

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

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

		// Table object (tbl_tour)
		$GLOBALS['tbl_tour'] = new ctbl_tour();

		// Table object (tbl_travel)
		$GLOBALS['tbl_travel'] = new ctbl_travel();

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

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

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

		// Open connection
		$conn = ew_Connect();

		// List options
		$this->ListOptions = new cListOptions();
	}

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

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

		// Get export parameters
		if (@$_GET["export"] <> "") {
			$tbl_allphoto->Export = $_GET["export"];
		} elseif (ew_IsHttpPost()) {
			if (@$_POST["exporttype"] <> "")
				$tbl_allphoto->Export = $_POST["exporttype"];
		} else {
			$tbl_allphoto->setExportReturnUrl(ew_CurrentUrl());
		}
		$gsExport = $tbl_allphoto->Export; // Get export parameter, used in header
		$gsExportFile = $tbl_allphoto->TableVar; // Get export file, used in header

		// 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();
	}

	// Class variables
	var $ListOptions; // List options
	var $lDisplayRecs = 15;
	var $lStartRec;
	var $lStopRec;
	var $lTotalRecs = 0;
	var $lRecRange = 10;
	var $sSrchWhere = ""; // Search WHERE clause
	var $lRecCnt = 0; // Record count
	var $lEditRowCnt;
	var $lRowCnt;
	var $lRowIndex; // Row index
	var $lRecPerRow = 0;
	var $lColCnt = 0;
	var $sDbMasterFilter = ""; // Master filter
	var $sDbDetailFilter = ""; // Detail filter
	var $bMasterRecordExists;	
	var $sMultiSelectKey;
	var $RestoreSearch;

	//
	// Page main
	//
	function Page_Main() {
		global $objForm, $Language, $gsSearchError, $Security, $tbl_allphoto;

		// Search filters
		$sSrchAdvanced = ""; // Advanced search filter
		$sSrchBasic = ""; // Basic search filter
		$sFilter = "";
		if ($this->IsPageRequest()) { // Validate request

			// Handle reset command
			$this->ResetCmd();

			// Set up master detail parameters
			$this->SetUpMasterDetail();

			// Set up list options
			$this->SetupListOptions();

			// Get basic search values
			$this->LoadBasicSearchValues();

			// Restore search parms from Session
			$this->RestoreSearchParms();

			// Call Recordset SearchValidated event
			$tbl_allphoto->Recordset_SearchValidated();

			// Set up sorting order
			$this->SetUpSortOrder();

			// Get basic search criteria
			if ($gsSearchError == "")
				$sSrchBasic = $this->BasicSearchWhere();
		}

		// Restore display records
		if ($tbl_allphoto->getRecordsPerPage() <> "") {
			$this->lDisplayRecs = $tbl_allphoto->getRecordsPerPage(); // Restore from Session
		} else {
			$this->lDisplayRecs = 15; // Load default
		}

		// Load Sorting Order
		$this->LoadSortOrder();

		// Build search criteria
		if ($sSrchAdvanced <> "")
			$this->sSrchWhere = ($this->sSrchWhere <> "") ? "(" . $this->sSrchWhere . ") AND (" . $sSrchAdvanced . ")" : $sSrchAdvanced;
		if ($sSrchBasic <> "")
			$this->sSrchWhere = ($this->sSrchWhere <> "") ? "(" . $this->sSrchWhere . ") AND (" . $sSrchBasic. ")" : $sSrchBasic;

		// Call Recordset_Searching event
		$tbl_allphoto->Recordset_Searching($this->sSrchWhere);

		// Save search criteria
		if ($this->sSrchWhere <> "") {
			if ($sSrchBasic == "")
				$this->ResetBasicSearchParms();
			$tbl_allphoto->setSearchWhere($this->sSrchWhere); // Save to Session
			if (!$this->RestoreSearch) {
				$this->lStartRec = 1; // Reset start record counter
				$tbl_allphoto->setStartRecordNumber($this->lStartRec);
			}
		} else {
			$this->sSrchWhere = $tbl_allphoto->getSearchWhere();
		}

		// Build filter
		$sFilter = "";

		// Restore master/detail filter
		$this->sDbMasterFilter = $tbl_allphoto->getMasterFilter(); // Restore master filter
		$this->sDbDetailFilter = $tbl_allphoto->getDetailFilter(); // Restore detail filter
		if ($this->sDbDetailFilter <> "")
			$sFilter = ($sFilter <> "") ? "(" . $sFilter . ") AND (" . $this->sDbDetailFilter . ")" : $this->sDbDetailFilter;
		if ($this->sSrchWhere <> "")
			$sFilter = ($sFilter <> "") ? "(" . $sFilter . ") AND (". $this->sSrchWhere . ")" : $this->sSrchWhere;

		// Load master record
		if ($tbl_allphoto->getMasterFilter() <> "" && $tbl_allphoto->getCurrentMasterTable() == "tbl_hotel") {
			global $tbl_hotel;
			$rsmaster = $tbl_hotel->LoadRs($this->sDbMasterFilter);
			$this->bMasterRecordExists = ($rsmaster && !$rsmaster->EOF);
			if (!$this->bMasterRecordExists) {
				$tbl_allphoto->setMasterFilter(""); // Clear master filter
				$tbl_allphoto->setDetailFilter(""); // Clear detail filter
				$this->setMessage($Language->Phrase("NoRecord")); // Set no record found
				$this->Page_Terminate($tbl_allphoto->getReturnUrl()); // Return to caller
			} else {
				$tbl_hotel->LoadListRowValues($rsmaster);
				$tbl_hotel->RowType = EW_ROWTYPE_MASTER; // Master row
				$tbl_hotel->RenderListRow();
				$rsmaster->Close();
			}
		}

		// Load master record
		if ($tbl_allphoto->getMasterFilter() <> "" && $tbl_allphoto->getCurrentMasterTable() == "tbl_tour") {
			global $tbl_tour;
			$rsmaster = $tbl_tour->LoadRs($this->sDbMasterFilter);
			$this->bMasterRecordExists = ($rsmaster && !$rsmaster->EOF);
			if (!$this->bMasterRecordExists) {
				$tbl_allphoto->setMasterFilter(""); // Clear master filter
				$tbl_allphoto->setDetailFilter(""); // Clear detail filter
				$this->setMessage($Language->Phrase("NoRecord")); // Set no record found
				$this->Page_Terminate($tbl_allphoto->getReturnUrl()); // Return to caller
			} else {
				$tbl_tour->LoadListRowValues($rsmaster);
				$tbl_tour->RowType = EW_ROWTYPE_MASTER; // Master row
				$tbl_tour->RenderListRow();
				$rsmaster->Close();
			}
		}

		// Load master record
		if ($tbl_allphoto->getMasterFilter() <> "" && $tbl_allphoto->getCurrentMasterTable() == "tbl_travel") {
			global $tbl_travel;
			$rsmaster = $tbl_travel->LoadRs($this->sDbMasterFilter);
			$this->bMasterRecordExists = ($rsmaster && !$rsmaster->EOF);
			if (!$this->bMasterRecordExists) {
				$tbl_allphoto->setMasterFilter(""); // Clear master filter
				$tbl_allphoto->setDetailFilter(""); // Clear detail filter
				$this->setMessage($Language->Phrase("NoRecord")); // Set no record found
				$this->Page_Terminate($tbl_allphoto->getReturnUrl()); // Return to caller
			} else {
				$tbl_travel->LoadListRowValues($rsmaster);
				$tbl_travel->RowType = EW_ROWTYPE_MASTER; // Master row
				$tbl_travel->RenderListRow();
				$rsmaster->Close();
			}
		}

		// Set up filter in session
		$tbl_allphoto->setSessionWhere($sFilter);
		$tbl_allphoto->CurrentFilter = "";
	}

	// Return basic search SQL
	function BasicSearchSQL($Keyword) {
		global $tbl_allphoto;
		$sKeyword = ew_AdjustSql($Keyword);
		$sWhere = "";
		$this->BuildBasicSearchSQL($sWhere, $tbl_allphoto->photo, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $tbl_allphoto->photo_thum, $Keyword);
		return $sWhere;
	}

	// Build basic search SQL
	function BuildBasicSearchSql(&$Where, &$Fld, $Keyword) {
		$sFldExpression = ($Fld->FldVirtualExpression <> "") ? $Fld->FldVirtualExpression : $Fld->FldExpression;
		$lFldDataType = ($Fld->FldIsVirtual) ? EW_DATATYPE_STRING : $Fld->FldDataType;
		if ($lFldDataType == EW_DATATYPE_NUMBER) {
			$sWrk = $sFldExpression . " = " . ew_QuotedValue($Keyword, $lFldDataType);
		} else {
			$sWrk = $sFldExpression . " LIKE " . ew_QuotedValue("%" . $Keyword . "%", $lFldDataType);
		}
		if ($Where <> "") $Where .= " OR ";
		$Where .= $sWrk;
	}

	// Return basic search WHERE clause based on search keyword and type
	function BasicSearchWhere() {
		global $Security, $tbl_allphoto;
		$sSearchStr = "";
		$sSearchKeyword = $tbl_allphoto->BasicSearchKeyword;
		$sSearchType = $tbl_allphoto->BasicSearchType;
		if ($sSearchKeyword <> "") {
			$sSearch = trim($sSearchKeyword);
			if ($sSearchType <> "") {
				while (strpos($sSearch, "  ") !== FALSE)
					$sSearch = str_replace("  ", " ", $sSearch);
				$arKeyword = explode(" ", trim($sSearch));
				foreach ($arKeyword as $sKeyword) {
					if ($sSearchStr <> "") $sSearchStr .= " " . $sSearchType . " ";
					$sSearchStr .= "(" . $this->BasicSearchSQL($sKeyword) . ")";
				}
			} else {
				$sSearchStr = $this->BasicSearchSQL($sSearch);
			}
		}
		if ($sSearchKeyword <> "") {
			$tbl_allphoto->setSessionBasicSearchKeyword($sSearchKeyword);
			$tbl_allphoto->setSessionBasicSearchType($sSearchType);
		}
		return $sSearchStr;
	}

	// Clear all search parameters
	function ResetSearchParms() {
		global $tbl_allphoto;

		// Clear search WHERE clause
		$this->sSrchWhere = "";
		$tbl_allphoto->setSearchWhere($this->sSrchWhere);

		// Clear basic search parameters
		$this->ResetBasicSearchParms();
	}

	// Clear all basic search parameters
	function ResetBasicSearchParms() {
		global $tbl_allphoto;
		$tbl_allphoto->setSessionBasicSearchKeyword("");
		$tbl_allphoto->setSessionBasicSearchType("");
	}

	// Restore all search parameters
	function RestoreSearchParms() {
		global $tbl_allphoto;
		$bRestore = TRUE;
		if (@$_GET[EW_TABLE_BASIC_SEARCH] <> "") $bRestore = FALSE;
		$this->RestoreSearch = $bRestore;
		if ($bRestore) {

			// Restore basic search values
			$tbl_allphoto->BasicSearchKeyword = $tbl_allphoto->getSessionBasicSearchKeyword();
			$tbl_allphoto->BasicSearchType = $tbl_allphoto->getSessionBasicSearchType();
		}
	}

	// Set up sort parameters
	function SetUpSortOrder() {
		global $tbl_allphoto;

		// Check for "order" parameter
		if (@$_GET["order"] <> "") {
			$tbl_allphoto->CurrentOrder = ew_StripSlashes(@$_GET["order"]);
			$tbl_allphoto->CurrentOrderType = @$_GET["ordertype"];
			$tbl_allphoto->UpdateSort($tbl_allphoto->hotel_id); // hotel_id
			$tbl_allphoto->UpdateSort($tbl_allphoto->tour_id); // tour_id
			$tbl_allphoto->UpdateSort($tbl_allphoto->travel_id); // travel_id
			$tbl_allphoto->UpdateSort($tbl_allphoto->photo); // photo
			$tbl_allphoto->UpdateSort($tbl_allphoto->photo_thum); // photo_thum
			$tbl_allphoto->UpdateSort($tbl_allphoto->order_by); // order_by
			$tbl_allphoto->setStartRecordNumber(1); // Reset start position
		}
	}

	// Load sort order parameters
	function LoadSortOrder() {
		global $tbl_allphoto;
		$sOrderBy = $tbl_allphoto->getSessionOrderBy(); // Get ORDER BY from Session
		if ($sOrderBy == "") {
			if ($tbl_allphoto->SqlOrderBy() <> "") {
				$sOrderBy = $tbl_allphoto->SqlOrderBy();
				$tbl_allphoto->setSessionOrderBy($sOrderBy);
			}
		}
	}

	// Reset command
	// cmd=reset (Reset search parameters)
	// cmd=resetall (Reset search and master/detail parameters)
	// cmd=resetsort (Reset sort parameters)
	function ResetCmd() {
		global $tbl_allphoto;

		// Get reset command
		if (@$_GET["cmd"] <> "") {
			$sCmd = $_GET["cmd"];

			// Reset search criteria
			if (strtolower($sCmd) == "reset" || strtolower($sCmd) == "resetall")
				$this->ResetSearchParms();

			// Reset master/detail keys
			if (strtolower($sCmd) == "resetall") {
				$tbl_allphoto->getCurrentMasterTable = ""; // Clear master table
				$tbl_allphoto->setMasterFilter(""); // Clear master filter
				$this->sDbMasterFilter = "";
				$tbl_allphoto->setDetailFilter(""); // Clear detail filter
				$this->sDbDetailFilter = "";
				$tbl_allphoto->hotel_id->setSessionValue("");
				$tbl_allphoto->tour_id->setSessionValue("");
				$tbl_allphoto->tour_id->setSessionValue("");
			}

			// Reset sorting order
			if (strtolower($sCmd) == "resetsort") {
				$sOrderBy = "";
				$tbl_allphoto->setSessionOrderBy($sOrderBy);
				$tbl_allphoto->hotel_id->setSort("");
				$tbl_allphoto->tour_id->setSort("");
				$tbl_allphoto->travel_id->setSort("");
				$tbl_allphoto->photo->setSort("");
				$tbl_allphoto->photo_thum->setSort("");
				$tbl_allphoto->order_by->setSort("");
			}

			// Reset start position
			$this->lStartRec = 1;
			$tbl_allphoto->setStartRecordNumber($this->lStartRec);
		}
	}

	// Set up list options
	function SetupListOptions() {
		global $Security, $tbl_allphoto;

		// "view"
		$this->ListOptions->Add("view");
		$item =& $this->ListOptions->Items["view"];
		$item->CssStyle = "white-space: nowrap;";
		$item->Visible = $Security->IsLoggedIn();
		$item->OnLeft = FALSE;

		// "edit"
		$this->ListOptions->Add("edit");
		$item =& $this->ListOptions->Items["edit"];
		$item->CssStyle = "white-space: nowrap;";
		$item->Visible = $Security->IsLoggedIn();
		$item->OnLeft = FALSE;

		// "copy"
		$this->ListOptions->Add("copy");
		$item =& $this->ListOptions->Items["copy"];
		$item->CssStyle = "white-space: nowrap;";
		$item->Visible = $Security->IsLoggedIn();
		$item->OnLeft = FALSE;

		// "delete"
		$this->ListOptions->Add("delete");
		$item =& $this->ListOptions->Items["delete"];
		$item->CssStyle = "white-space: nowrap;";
		$item->Visible = $Security->IsLoggedIn();
		$item->OnLeft = FALSE;

		// Call ListOptions_Load event
		$this->ListOptions_Load();
		if ($tbl_allphoto->Export <> "" ||
			$tbl_allphoto->CurrentAction == "gridadd" ||
			$tbl_allphoto->CurrentAction == "gridedit")
			$this->ListOptions->HideAllOptions();
	}

	// Render list options
	function RenderListOptions() {
		global $Security, $Language, $tbl_allphoto;
		$this->ListOptions->LoadDefault();

		// "view"
		$oListOpt =& $this->ListOptions->Items["view"];
		if ($Security->IsLoggedIn() && $oListOpt->Visible)
			$oListOpt->Body = "<a href=\"" . $this->ViewUrl . "\">" . $Language->Phrase("ViewLink") . "</a>";

		// "edit"
		$oListOpt =& $this->ListOptions->Items["edit"];
		if ($Security->IsLoggedIn() && $oListOpt->Visible) {
			$oListOpt->Body = "<a href=\"" . $this->EditUrl . "\">" . $Language->Phrase("EditLink") . "</a>";
		}

		// "copy"
		$oListOpt =& $this->ListOptions->Items["copy"];
		if ($Security->IsLoggedIn() && $oListOpt->Visible) {
			$oListOpt->Body = "<a href=\"" . $this->CopyUrl . "\">" . $Language->Phrase("CopyLink") . "</a>";
		}

		// "delete"
		$oListOpt =& $this->ListOptions->Items["delete"];
		if ($Security->IsLoggedIn() && $oListOpt->Visible)
			$oListOpt->Body = "<a" . " onclick=\"ew_ClickDelete(this);return ew_ConfirmDelete(ewLanguage.Phrase('DeleteConfirmMsg'), this);\"" . " href=\"" . $this->DeleteUrl . "\">" . $Language->Phrase("DeleteLink") . "</a>";
		$this->RenderListOptionsExt();

		// Call ListOptions_Rendered event
		$this->ListOptions_Rendered();
	}

	function RenderListOptionsExt() {
		global $Security, $Language, $tbl_allphoto;
	}

	// Set up starting record parameters
	function SetUpStartRec() {
		global $tbl_allphoto;
		if ($this->lDisplayRecs == 0)
			return;
		if ($this->IsPageRequest()) { // Validate request
			if (@$_GET[EW_TABLE_START_REC] <> "") { // Check for "start" parameter
				$this->lStartRec = $_GET[EW_TABLE_START_REC];
				$tbl_allphoto->setStartRecordNumber($this->lStartRec);
			} elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
				$this->nPageNo = $_GET[EW_TABLE_PAGE_NO];
				if (is_numeric($this->nPageNo)) {
					$this->lStartRec = ($this->nPageNo-1)*$this->lDisplayRecs+1;
					if ($this->lStartRec <= 0) {
						$this->lStartRec = 1;
					} elseif ($this->lStartRec >= intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1) {
						$this->lStartRec = intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1;
					}
					$tbl_allphoto->setStartRecordNumber($this->lStartRec);
				}
			}
		}
		$this->lStartRec = $tbl_allphoto->getStartRecordNumber();

		// Check if correct start record counter
		if (!is_numeric($this->lStartRec) || $this->lStartRec == "") { // Avoid invalid start record counter
			$this->lStartRec = 1; // Reset start record counter
			$tbl_allphoto->setStartRecordNumber($this->lStartRec);
		} elseif (intval($this->lStartRec) > intval($this->lTotalRecs)) { // Avoid starting record > total records
			$this->lStartRec = intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1; // Point to last page first record
			$tbl_allphoto->setStartRecordNumber($this->lStartRec);
		} elseif (($this->lStartRec-1) % $this->lDisplayRecs <> 0) {
			$this->lStartRec = intval(($this->lStartRec-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1; // Point to page boundary
			$tbl_allphoto->setStartRecordNumber($this->lStartRec);
		}
	}

	// Load basic search values
	function LoadBasicSearchValues() {
		global $tbl_allphoto;
		$tbl_allphoto->BasicSearchKeyword = @$_GET[EW_TABLE_BASIC_SEARCH];
		$tbl_allphoto->BasicSearchType = @$_GET[EW_TABLE_BASIC_SEARCH_TYPE];
	}

	// Load recordset
	function LoadRecordset($offset = -1, $rowcnt = -1) {
		global $conn, $tbl_allphoto;

		// Call Recordset Selecting event
		$tbl_allphoto->Recordset_Selecting($tbl_allphoto->CurrentFilter);

		// Load List page SQL
		$sSql = $tbl_allphoto->SelectSQL();
		if ($offset > -1 && $rowcnt > -1)
			$sSql .= " LIMIT $offset, $rowcnt";

		// Load recordset
		$rs = ew_LoadRecordset($sSql);

		// Call Recordset Selected event
		$tbl_allphoto->Recordset_Selected($rs);
		return $rs;
	}

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

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

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

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

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $tbl_allphoto;
		$tbl_allphoto->all_id->setDbValue($rs->fields('all_id'));
		$tbl_allphoto->hotel_id->setDbValue($rs->fields('hotel_id'));
		$tbl_allphoto->tour_id->setDbValue($rs->fields('tour_id'));
		$tbl_allphoto->travel_id->setDbValue($rs->fields('travel_id'));
		$tbl_allphoto->photo->setDbValue($rs->fields('photo'));
		$tbl_allphoto->photo_thum->setDbValue($rs->fields('photo_thum'));
		$tbl_allphoto->order_by->setDbValue($rs->fields('order_by'));
	}

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

		// Initialize URLs
		$this->ViewUrl = $tbl_allphoto->ViewUrl();
		$this->EditUrl = $tbl_allphoto->EditUrl();
		$this->InlineEditUrl = $tbl_allphoto->InlineEditUrl();
		$this->CopyUrl = $tbl_allphoto->CopyUrl();
		$this->InlineCopyUrl = $tbl_allphoto->InlineCopyUrl();
		$this->DeleteUrl = $tbl_allphoto->DeleteUrl();

		// Call Row_Rendering event
		$tbl_allphoto->Row_Rendering();

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

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

		// tour_id
		$tbl_allphoto->tour_id->CellCssStyle = ""; $tbl_allphoto->tour_id->CellCssClass = "";
		$tbl_allphoto->tour_id->CellAttrs = array(); $tbl_allphoto->tour_id->ViewAttrs = array(); $tbl_allphoto->tour_id->EditAttrs = array();

		// travel_id
		$tbl_allphoto->travel_id->CellCssStyle = ""; $tbl_allphoto->travel_id->CellCssClass = "";
		$tbl_allphoto->travel_id->CellAttrs = array(); $tbl_allphoto->travel_id->ViewAttrs = array(); $tbl_allphoto->travel_id->EditAttrs = array();

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

		// photo_thum
		$tbl_allphoto->photo_thum->CellCssStyle = ""; $tbl_allphoto->photo_thum->CellCssClass = "";
		$tbl_allphoto->photo_thum->CellAttrs = array(); $tbl_allphoto->photo_thum->ViewAttrs = array(); $tbl_allphoto->photo_thum->EditAttrs = array();

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

			// all_id
			$tbl_allphoto->all_id->ViewValue = $tbl_allphoto->all_id->CurrentValue;
			$tbl_allphoto->all_id->CssStyle = "";
			$tbl_allphoto->all_id->CssClass = "";
			$tbl_allphoto->all_id->ViewCustomAttributes = "";

			// hotel_id
			if (strval($tbl_allphoto->hotel_id->CurrentValue) <> "") {
				$sFilterWrk = "`hotel_id` = " . ew_AdjustSql($tbl_allphoto->hotel_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `hotel_name` FROM `tbl_hotel`";
			$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_allphoto->hotel_id->ViewValue = $rswrk->fields('hotel_name');
					$rswrk->Close();
				} else {
					$tbl_allphoto->hotel_id->ViewValue = $tbl_allphoto->hotel_id->CurrentValue;
				}
			} else {
				$tbl_allphoto->hotel_id->ViewValue = NULL;
			}
			$tbl_allphoto->hotel_id->CssStyle = "";
			$tbl_allphoto->hotel_id->CssClass = "";
			$tbl_allphoto->hotel_id->ViewCustomAttributes = "";

			// tour_id
			if (strval($tbl_allphoto->tour_id->CurrentValue) <> "") {
				$sFilterWrk = "`tour_id` = " . ew_AdjustSql($tbl_allphoto->tour_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `tour_name` FROM `tbl_tour`";
			$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_allphoto->tour_id->ViewValue = $rswrk->fields('tour_name');
					$rswrk->Close();
				} else {
					$tbl_allphoto->tour_id->ViewValue = $tbl_allphoto->tour_id->CurrentValue;
				}
			} else {
				$tbl_allphoto->tour_id->ViewValue = NULL;
			}
			$tbl_allphoto->tour_id->CssStyle = "";
			$tbl_allphoto->tour_id->CssClass = "";
			$tbl_allphoto->tour_id->ViewCustomAttributes = "";

			// travel_id
			if (strval($tbl_allphoto->travel_id->CurrentValue) <> "") {
				$sFilterWrk = "`travel_id` = " . ew_AdjustSql($tbl_allphoto->travel_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `category` FROM `tbl_travel`";
			$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_allphoto->travel_id->ViewValue = $rswrk->fields('category');
					$rswrk->Close();
				} else {
					$tbl_allphoto->travel_id->ViewValue = $tbl_allphoto->travel_id->CurrentValue;
				}
			} else {
				$tbl_allphoto->travel_id->ViewValue = NULL;
			}
			$tbl_allphoto->travel_id->CssStyle = "";
			$tbl_allphoto->travel_id->CssClass = "";
			$tbl_allphoto->travel_id->ViewCustomAttributes = "";

			// photo
			$tbl_allphoto->photo->ViewValue = $tbl_allphoto->photo->CurrentValue;
			$tbl_allphoto->photo->CssStyle = "";
			$tbl_allphoto->photo->CssClass = "";
			$tbl_allphoto->photo->ViewCustomAttributes = "";

			// photo_thum
			$tbl_allphoto->photo_thum->ViewValue = $tbl_allphoto->photo_thum->CurrentValue;
			$tbl_allphoto->photo_thum->CssStyle = "";
			$tbl_allphoto->photo_thum->CssClass = "";
			$tbl_allphoto->photo_thum->ViewCustomAttributes = "";

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

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

			// tour_id
			$tbl_allphoto->tour_id->HrefValue = "";
			$tbl_allphoto->tour_id->TooltipValue = "";

			// travel_id
			$tbl_allphoto->travel_id->HrefValue = "";
			$tbl_allphoto->travel_id->TooltipValue = "";

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

			// photo_thum
			$tbl_allphoto->photo_thum->HrefValue = "";
			$tbl_allphoto->photo_thum->TooltipValue = "";

			// order_by
			$tbl_allphoto->order_by->HrefValue = "";
			$tbl_allphoto->order_by->TooltipValue = "";
		}

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

	// Set up master/detail based on QueryString
	function SetUpMasterDetail() {
		global $tbl_allphoto;
		$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") {
				$bValidMaster = TRUE;
				$this->sDbMasterFilter = $tbl_allphoto->SqlMasterFilter_tbl_hotel();
				$this->sDbDetailFilter = $tbl_allphoto->SqlDetailFilter_tbl_hotel();
				if (@$_GET["hotel_id"] <> "") {
					$GLOBALS["tbl_hotel"]->hotel_id->setQueryStringValue($_GET["hotel_id"]);
					$tbl_allphoto->hotel_id->setQueryStringValue($GLOBALS["tbl_hotel"]->hotel_id->QueryStringValue);
					$tbl_allphoto->hotel_id->setSessionValue($tbl_allphoto->hotel_id->QueryStringValue);
					if (!is_numeric($GLOBALS["tbl_hotel"]->hotel_id->QueryStringValue)) $bValidMaster = FALSE;
					$this->sDbMasterFilter = str_replace("@hotel_id@", ew_AdjustSql($GLOBALS["tbl_hotel"]->hotel_id->QueryStringValue), $this->sDbMasterFilter);
					$this->sDbDetailFilter = str_replace("@hotel_id@", ew_AdjustSql($GLOBALS["tbl_hotel"]->hotel_id->QueryStringValue), $this->sDbDetailFilter);
				} else {
					$bValidMaster = FALSE;
				}
			}
			if ($sMasterTblVar == "tbl_tour") {
				$bValidMaster = TRUE;
				$this->sDbMasterFilter = $tbl_allphoto->SqlMasterFilter_tbl_tour();
				$this->sDbDetailFilter = $tbl_allphoto->SqlDetailFilter_tbl_tour();
				if (@$_GET["tour_id"] <> "") {
					$GLOBALS["tbl_tour"]->tour_id->setQueryStringValue($_GET["tour_id"]);
					$tbl_allphoto->tour_id->setQueryStringValue($GLOBALS["tbl_tour"]->tour_id->QueryStringValue);
					$tbl_allphoto->tour_id->setSessionValue($tbl_allphoto->tour_id->QueryStringValue);
					if (!is_numeric($GLOBALS["tbl_tour"]->tour_id->QueryStringValue)) $bValidMaster = FALSE;
					$this->sDbMasterFilter = str_replace("@tour_id@", ew_AdjustSql($GLOBALS["tbl_tour"]->tour_id->QueryStringValue), $this->sDbMasterFilter);
					$this->sDbDetailFilter = str_replace("@tour_id@", ew_AdjustSql($GLOBALS["tbl_tour"]->tour_id->QueryStringValue), $this->sDbDetailFilter);
				} else {
					$bValidMaster = FALSE;
				}
			}
			if ($sMasterTblVar == "tbl_travel") {
				$bValidMaster = TRUE;
				$this->sDbMasterFilter = $tbl_allphoto->SqlMasterFilter_tbl_travel();
				$this->sDbDetailFilter = $tbl_allphoto->SqlDetailFilter_tbl_travel();
				if (@$_GET["travel_id"] <> "") {
					$GLOBALS["tbl_travel"]->travel_id->setQueryStringValue($_GET["travel_id"]);
					$tbl_allphoto->tour_id->setQueryStringValue($GLOBALS["tbl_travel"]->travel_id->QueryStringValue);
					$tbl_allphoto->tour_id->setSessionValue($tbl_allphoto->tour_id->QueryStringValue);
					if (!is_numeric($GLOBALS["tbl_travel"]->travel_id->QueryStringValue)) $bValidMaster = FALSE;
					$this->sDbMasterFilter = str_replace("@travel_id@", ew_AdjustSql($GLOBALS["tbl_travel"]->travel_id->QueryStringValue), $this->sDbMasterFilter);
					$this->sDbDetailFilter = str_replace("@tour_id@", ew_AdjustSql($GLOBALS["tbl_travel"]->travel_id->QueryStringValue), $this->sDbDetailFilter);
				} else {
					$bValidMaster = FALSE;
				}
			}
		}
		if ($bValidMaster) {

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

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

			// Clear previous master key from Session
			if ($sMasterTblVar <> "tbl_hotel") {
				if ($tbl_allphoto->hotel_id->QueryStringValue == "") $tbl_allphoto->hotel_id->setSessionValue("");
			}
			if ($sMasterTblVar <> "tbl_tour") {
				if ($tbl_allphoto->tour_id->QueryStringValue == "") $tbl_allphoto->tour_id->setSessionValue("");
			}
			if ($sMasterTblVar <> "tbl_travel") {
				if ($tbl_allphoto->tour_id->QueryStringValue == "") $tbl_allphoto->tour_id->setSessionValue("");
			}
		} else {
			$this->sDbMasterFilter = $tbl_allphoto->getMasterFilter(); //  Restore master filter
			$this->sDbDetailFilter = $tbl_allphoto->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;
	}

	// ListOptions Load event
	function ListOptions_Load() {

		// Example: 
		//$this->ListOptions->Add("new");
		//$this->ListOptions->Items["new"]->OnLeft = TRUE; // Link on left
		//$this->ListOptions->MoveItem("new", 0); // Move to first column

	}

	// ListOptions Rendered event
	function ListOptions_Rendered() {

		// Example: 
		//$this->ListOptions->Items["new"]->Body = "xxx";

	}
}
?>
