Location: PHPKode > projects > Science Lab Inventory & Order Management > sciencelabinv/roomslist.php
<?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 "roomsinfo.php" ?>
<?php include "useraccountsinfo.php" ?>
<?php include "userfn7.php" ?>
<?php

// Create page object
$rooms_list = new crooms_list();
$Page =& $rooms_list;

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

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

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

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

// extend page with ValidateForm function
rooms_list.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;
	var addcnt = 0;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		var chkthisrow = true;
		if (fobj.a_list && fobj.a_list.value == "gridinsert")
			chkthisrow = !(this.EmptyRow(fobj, infix));
		else
			chkthisrow = true;
		if (chkthisrow) {
			addcnt += 1;
		elm = fobj.elements["x" + infix + "_id"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($rooms->id->FldCaption()) ?>");

		// Call Form Custom Validate event
		if (!this.Form_CustomValidate(fobj)) return false;
		} // End Grid Add checking
	}
	if (fobj.a_list && fobj.a_list.value == "gridinsert" && addcnt == 0) { // No row added
		alert(ewLanguage.Phrase("NoAddRecord"));
		return false;
	}
	return true;
}

// Extend page with empty row check
rooms_list.EmptyRow = function(fobj, infix) {
	if (ew_ValueChanged(fobj, infix, "id", false)) return false;
	if (ew_ValueChanged(fobj, infix, "name", false)) return false;
	if (ew_ValueChanged(fobj, infix, "description", false)) return false;
	return true;
}

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

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
rooms_list.SelectAllKey = function(elem) {
	ew_SelectAll(elem);
	ew_ClickAll(elem);
}
<?php if (EW_CLIENT_VALIDATE) { ?>
rooms_list.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
rooms_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 ($rooms->Export == "") { ?>
<?php } ?>
<?php
if ($rooms->CurrentAction == "gridadd") {
	$rooms->CurrentFilter = "0=1";
	$rooms_list->lStartRec = 1;
	if ($rooms_list->lDisplayRecs <= 0)
		$rooms_list->lDisplayRecs = 10;
	$rooms_list->lTotalRecs = $rooms_list->lDisplayRecs;
	$rooms_list->lStopRec = $rooms_list->lDisplayRecs;
} else {
	$bSelectLimit = EW_SELECT_LIMIT;
	if ($bSelectLimit) {
		$rooms_list->lTotalRecs = $rooms->SelectRecordCount();
	} else {
		if ($rs = $rooms_list->LoadRecordset())
			$rooms_list->lTotalRecs = $rs->RecordCount();
	}
	$rooms_list->lStartRec = 1;
	if ($rooms_list->lDisplayRecs <= 0 || ($rooms->Export <> "" && $rooms->ExportAll)) // Display all records
		$rooms_list->lDisplayRecs = $rooms_list->lTotalRecs;
	if (!($rooms->Export <> "" && $rooms->ExportAll))
		$rooms_list->SetUpStartRec(); // Set up start record position
	if ($bSelectLimit)
		$rs = $rooms_list->LoadRecordset($rooms_list->lStartRec-1, $rooms_list->lDisplayRecs);
}
?>
<p><span class="phpmaker" style="white-space: nowrap;"><?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $rooms->TableCaption() ?>
<?php if ($rooms->Export == "" && $rooms->CurrentAction == "") { ?>
&nbsp;&nbsp;<a href="<?php echo $rooms_list->ExportPrintUrl ?>"><?php echo $Language->Phrase("PrinterFriendly") ?></a>
&nbsp;&nbsp;<a href="<?php echo $rooms_list->ExportHtmlUrl ?>"><?php echo $Language->Phrase("ExportToHtml") ?></a>
&nbsp;&nbsp;<a href="<?php echo $rooms_list->ExportExcelUrl ?>"><?php echo $Language->Phrase("ExportToExcel") ?></a>
&nbsp;&nbsp;<a href="<?php echo $rooms_list->ExportWordUrl ?>"><?php echo $Language->Phrase("ExportToWord") ?></a>
&nbsp;&nbsp;<a href="<?php echo $rooms_list->ExportCsvUrl ?>"><?php echo $Language->Phrase("ExportToCsv") ?></a>
&nbsp;&nbsp;<a name="emf_rooms" id="emf_rooms" href="javascript:void(0);" onclick="ew_EmailDialogShow({lnk:'emf_rooms',hdr:ewLanguage.Phrase('ExportToEmail'),f:document.froomslist,sel:false});"><?php echo $Language->Phrase("ExportToEmail") ?></a>
<?php } ?>
</span></p>
<?php if ($rooms->Export == "" && $rooms->CurrentAction == "") { ?>
<a href="javascript:ew_ToggleSearchPanel(rooms_list);" style="text-decoration: none;"><img id="rooms_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="rooms_list_SearchPanel">
<form name="froomslistsrch" id="froomslistsrch" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
<input type="hidden" id="t" name="t" value="rooms">
<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($rooms->getSessionBasicSearchKeyword()) ?>">
			<input type="Submit" name="Submit" id="Submit" value="<?php echo ew_BtnCaption($Language->Phrase("QuickSearchBtn")) ?>">&nbsp;
			<a href="<?php echo $rooms_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 ($rooms->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 ($rooms->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 ($rooms->getSessionBasicSearchType() == "OR") { ?> checked="checked"<?php } ?>><?php echo $Language->Phrase("AnyWord") ?></label></span></td>
	</tr>
</table>
</form>
</div>
<?php } ?>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$rooms_list->ShowMessage();
?>
<br>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<?php if ($rooms->Export == "") { ?>
<div class="ewGridUpperPanel">
<?php if ($rooms->CurrentAction <> "gridadd" && $rooms->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>
<?php if (!isset($rooms_list->Pager)) $rooms_list->Pager = new cPrevNextPager($rooms_list->lStartRec, $rooms_list->lDisplayRecs, $rooms_list->lTotalRecs) ?>
<?php if ($rooms_list->Pager->RecordCount > 0) { ?>
	<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpmaker"><?php echo $Language->Phrase("Page") ?>&nbsp;</span></td>
<!--first page button-->
	<?php if ($rooms_list->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $rooms_list->PageUrl() ?>start=<?php echo $rooms_list->Pager->FirstButton->Start ?>"><img src="images/first.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/firstdisab.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--previous page button-->
	<?php if ($rooms_list->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $rooms_list->PageUrl() ?>start=<?php echo $rooms_list->Pager->PrevButton->Start ?>"><img src="images/prev.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/prevdisab.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--current page number-->
	<td><input type="text" name="<?php echo EW_TABLE_PAGE_NO ?>" id="<?php echo EW_TABLE_PAGE_NO ?>" value="<?php echo $rooms_list->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($rooms_list->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $rooms_list->PageUrl() ?>start=<?php echo $rooms_list->Pager->NextButton->Start ?>"><img src="images/next.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/nextdisab.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--last page button-->
	<?php if ($rooms_list->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $rooms_list->PageUrl() ?>start=<?php echo $rooms_list->Pager->LastButton->Start ?>"><img src="images/last.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/lastdisab.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
	<td><span class="phpmaker">&nbsp;<?php echo $Language->Phrase("of") ?>&nbsp;<?php echo $rooms_list->Pager->PageCount ?></span></td>
	</tr></table>
	</td>	
	<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
	<td>
	<span class="phpmaker"><?php echo $Language->Phrase("Record") ?>&nbsp;<?php echo $rooms_list->Pager->FromIndex ?>&nbsp;<?php echo $Language->Phrase("To") ?>&nbsp;<?php echo $rooms_list->Pager->ToIndex ?>&nbsp;<?php echo $Language->Phrase("Of") ?>&nbsp;<?php echo $rooms_list->Pager->RecordCount ?></span>
<?php } else { ?>
	<?php if ($rooms_list->sSrchWhere == "0=101") { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("EnterSearchCriteria") ?></span>
	<?php } else { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("NoRecord") ?></span>
	<?php } ?>
<?php } ?>
		</td>
<?php if ($rooms_list->lTotalRecs > 0) { ?>
		<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
		<td><table border="0" cellspacing="0" cellpadding="0"><tr><td><?php echo $Language->Phrase("RecordsPerPage") ?>&nbsp;</td><td>
<input type="hidden" id="t" name="t" value="rooms">
<select name="<?php echo EW_TABLE_REC_PER_PAGE ?>" id="<?php echo EW_TABLE_REC_PER_PAGE ?>" onchange="this.form.submit();" class="phpmaker">
<option value="10"<?php if ($rooms_list->lDisplayRecs == 10) { ?> selected="selected"<?php } ?>>10</option>
<option value="25"<?php if ($rooms_list->lDisplayRecs == 25) { ?> selected="selected"<?php } ?>>25</option>
<option value="50"<?php if ($rooms_list->lDisplayRecs == 50) { ?> selected="selected"<?php } ?>>50</option>
<option value="ALL"<?php if ($rooms->getRecordsPerPage() == -1) { ?> selected="selected"<?php } ?>><?php echo $Language->Phrase("AllRecords") ?></option>
</select></td></tr></table>
		</td>
<?php } ?>
	</tr>
</table>
</form>
<?php } ?>
<span class="phpmaker">
<?php if ($rooms->CurrentAction <> "gridadd" && $rooms->CurrentAction <> "gridedit") { // Not grid add/edit mode ?>
<?php if ($Security->CanAdd()) { ?>
<a href="<?php echo $rooms_list->AddUrl ?>"><?php echo $Language->Phrase("AddLink") ?></a>&nbsp;&nbsp;
<a href="<?php echo $rooms_list->GridAddUrl ?>"><?php echo $Language->Phrase("GridAddLink") ?></a>&nbsp;&nbsp;
<?php } ?>
<?php if ($Security->CanEdit()) { ?>
<?php if ($rooms_list->lTotalRecs > 0) { ?>
<a href="<?php echo $rooms_list->GridEditUrl ?>"><?php echo $Language->Phrase("GridEditLink") ?></a>&nbsp;&nbsp;
<?php } ?>
<?php } ?>
<?php if ($rooms_list->lTotalRecs > 0) { ?>
<?php if ($Security->CanDelete()) { ?>
<a href="" onclick="ew_SubmitSelected(document.froomslist, '<?php echo $rooms_list->MultiDeleteUrl ?>');return false;"><?php echo $Language->Phrase("DeleteSelectedLink") ?></a>&nbsp;&nbsp;
<?php } ?>
<?php } ?>
<?php } else { // Grid add/edit mode ?>
<?php if ($rooms->CurrentAction == "gridadd") { ?>
<a href="" onclick="f=document.froomslist;if(rooms_list.ValidateForm(f))f.submit();return false;"><?php echo $Language->Phrase("GridInsertLink") ?></a>&nbsp;&nbsp;
<a href="<?php echo $rooms_list->PageUrl() ?>a=cancel"><?php echo $Language->Phrase("GridCancelLink") ?></a>&nbsp;&nbsp;
<?php } ?>
<?php if ($rooms->CurrentAction == "gridedit") { ?>
<a href="" onclick="f=document.froomslist;if(rooms_list.ValidateForm(f))f.submit();return false;"><?php echo $Language->Phrase("GridSaveLink") ?></a>&nbsp;&nbsp;
<a href="<?php echo $rooms_list->PageUrl() ?>a=cancel"><?php echo $Language->Phrase("GridCancelLink") ?></a>&nbsp;&nbsp;
<?php } ?>
<?php } ?>
</span>
</div>
<?php } ?>
<form name="froomslist" id="froomslist" class="ewForm" action="<?php echo ew_CurrentPage() ?>" method="post">
<input type="hidden" name="t" id="t" value="rooms">
<div id="gmp_rooms" class="ewGridMiddlePanel">
<?php if ($rooms_list->lTotalRecs > 0) { ?>
<table cellspacing="0" rowhighlightclass="ewTableHighlightRow" rowselectclass="ewTableSelectRow" roweditclass="ewTableEditRow" class="ewTable ewTableSeparate">
<?php echo $rooms->TableCustomInnerHtml ?>
<thead><!-- Table header -->
	<tr class="ewTableHeader">
<?php

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

// Render list options (header, left)
$rooms_list->ListOptions->Render("header", "left");
?>
<?php if ($rooms->id->Visible) { // id ?>
	<?php if ($rooms->SortUrl($rooms->id) == "") { ?>
		<td><?php echo $rooms->id->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $rooms->SortUrl($rooms->id) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $rooms->id->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($rooms->id->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($rooms->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 ($rooms->name->Visible) { // name ?>
	<?php if ($rooms->SortUrl($rooms->name) == "") { ?>
		<td><?php echo $rooms->name->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $rooms->SortUrl($rooms->name) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $rooms->name->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($rooms->name->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($rooms->name->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($rooms->description->Visible) { // description ?>
	<?php if ($rooms->SortUrl($rooms->description) == "") { ?>
		<td><?php echo $rooms->description->FldCaption() ?></td>
	<?php } else { ?>
		<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $rooms->SortUrl($rooms->description) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $rooms->description->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($rooms->description->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($rooms->description->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)
$rooms_list->ListOptions->Render("header", "right");
?>
	</tr>
</thead>
<?php
if ($rooms->ExportAll && $rooms->Export <> "") {
	$rooms_list->lStopRec = $rooms_list->lTotalRecs;
} else {
	$rooms_list->lStopRec = $rooms_list->lStartRec + $rooms_list->lDisplayRecs - 1; // Set the last record to display
}
$rooms_list->lRecCount = $rooms_list->lStartRec - 1;
if ($rs && !$rs->EOF) {
	$rs->MoveFirst();
	if (!$bSelectLimit && $rooms_list->lStartRec > 1)
		$rs->Move($rooms_list->lStartRec - 1);
}

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

	// Init row class and style
	$rooms->CssClass = "";
	$rooms->CssStyle = "";
	$rooms->RowAttrs = array('onmouseover'=>'ew_MouseOver(event, this);', 'onmouseout'=>'ew_MouseOut(event, this);', 'onclick'=>'ew_Click(event, this);');
	if ($rooms->CurrentAction == "gridadd") {
		$rooms_list->LoadDefaultValues(); // Load default values
	} else {
		$rooms_list->LoadRowValues($rs); // Load row values
	}
	$rooms->RowType = EW_ROWTYPE_VIEW; // Render view
	if ($rooms->CurrentAction == "gridadd") // Grid add
		$rooms->RowType = EW_ROWTYPE_ADD; // Render add
	if ($rooms->CurrentAction == "gridadd" && $rooms->EventCancelled) // Insert failed
		$rooms_list->RestoreCurrentRowFormValues($rooms_list->lRowIndex); // Restore form values
	if ($rooms->CurrentAction == "gridedit") { // Grid edit
		$rooms->RowType = EW_ROWTYPE_EDIT; // Render edit
	}
	if ($rooms->RowType == EW_ROWTYPE_EDIT && $rooms->EventCancelled) { // Update failed
		if ($rooms->CurrentAction == "gridedit")
			$rooms_list->RestoreCurrentRowFormValues($rooms_list->lRowIndex); // Restore form values
	}
	if ($rooms->RowType == EW_ROWTYPE_EDIT) // Edit row
		$rooms_list->lEditRowCnt++;
	if ($rooms->RowType == EW_ROWTYPE_ADD || $rooms->RowType == EW_ROWTYPE_EDIT) { // Add / Edit row
		$rooms->RowAttrs = array_merge($rooms->RowAttrs, array('onmouseover'=>'this.edit=true;ew_MouseOver(event, this);', 'onmouseout'=>'ew_MouseOut(event, this);', 'onclick'=>'ew_Click(event, this);'));
		$rooms->CssClass = "ewTableEditRow";
	}

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

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

// Render list options (body, left)
$rooms_list->ListOptions->Render("body", "left");
?>
	<?php if ($rooms->id->Visible) { // id ?>
		<td<?php echo $rooms->id->CellAttributes() ?>>
<?php if ($rooms->RowType == EW_ROWTYPE_ADD) { // Add record ?>
<input type="text" name="x<?php echo $rooms_list->lRowIndex ?>_id" id="x<?php echo $rooms_list->lRowIndex ?>_id" title="<?php echo $rooms->id->FldTitle() ?>" size="30" maxlength="5" value="<?php echo $rooms->id->EditValue ?>"<?php echo $rooms->id->EditAttributes() ?>>
<input type="hidden" name="o<?php echo $rooms_list->lRowIndex ?>_id" id="o<?php echo $rooms_list->lRowIndex ?>_id" value="<?php echo ew_HtmlEncode($rooms->id->OldValue) ?>">
<?php } ?>
<?php if ($rooms->RowType == EW_ROWTYPE_EDIT) { // Edit record ?>
<div<?php echo $rooms->id->ViewAttributes() ?>><?php echo $rooms->id->EditValue ?></div><input type="hidden" name="x<?php echo $rooms_list->lRowIndex ?>_id" id="x<?php echo $rooms_list->lRowIndex ?>_id" value="<?php echo ew_HtmlEncode($rooms->id->CurrentValue) ?>">
<?php } ?>
<?php if ($rooms->RowType == EW_ROWTYPE_VIEW) { // View record ?>
<div<?php echo $rooms->id->ViewAttributes() ?>><?php echo $rooms->id->ListViewValue() ?></div>
<?php } ?>
</td>
	<?php } ?>
	<?php if ($rooms->name->Visible) { // name ?>
		<td<?php echo $rooms->name->CellAttributes() ?>>
<?php if ($rooms->RowType == EW_ROWTYPE_ADD) { // Add record ?>
<input type="text" name="x<?php echo $rooms_list->lRowIndex ?>_name" id="x<?php echo $rooms_list->lRowIndex ?>_name" title="<?php echo $rooms->name->FldTitle() ?>" size="30" maxlength="25" value="<?php echo $rooms->name->EditValue ?>"<?php echo $rooms->name->EditAttributes() ?>>
<input type="hidden" name="o<?php echo $rooms_list->lRowIndex ?>_name" id="o<?php echo $rooms_list->lRowIndex ?>_name" value="<?php echo ew_HtmlEncode($rooms->name->OldValue) ?>">
<?php } ?>
<?php if ($rooms->RowType == EW_ROWTYPE_EDIT) { // Edit record ?>
<input type="text" name="x<?php echo $rooms_list->lRowIndex ?>_name" id="x<?php echo $rooms_list->lRowIndex ?>_name" title="<?php echo $rooms->name->FldTitle() ?>" size="30" maxlength="25" value="<?php echo $rooms->name->EditValue ?>"<?php echo $rooms->name->EditAttributes() ?>>
<?php } ?>
<?php if ($rooms->RowType == EW_ROWTYPE_VIEW) { // View record ?>
<div<?php echo $rooms->name->ViewAttributes() ?>><?php echo $rooms->name->ListViewValue() ?></div>
<?php } ?>
</td>
	<?php } ?>
	<?php if ($rooms->description->Visible) { // description ?>
		<td<?php echo $rooms->description->CellAttributes() ?>>
<?php if ($rooms->RowType == EW_ROWTYPE_ADD) { // Add record ?>
<input type="text" name="x<?php echo $rooms_list->lRowIndex ?>_description" id="x<?php echo $rooms_list->lRowIndex ?>_description" title="<?php echo $rooms->description->FldTitle() ?>" size="30" maxlength="50" value="<?php echo $rooms->description->EditValue ?>"<?php echo $rooms->description->EditAttributes() ?>>
<input type="hidden" name="o<?php echo $rooms_list->lRowIndex ?>_description" id="o<?php echo $rooms_list->lRowIndex ?>_description" value="<?php echo ew_HtmlEncode($rooms->description->OldValue) ?>">
<?php } ?>
<?php if ($rooms->RowType == EW_ROWTYPE_EDIT) { // Edit record ?>
<input type="text" name="x<?php echo $rooms_list->lRowIndex ?>_description" id="x<?php echo $rooms_list->lRowIndex ?>_description" title="<?php echo $rooms->description->FldTitle() ?>" size="30" maxlength="50" value="<?php echo $rooms->description->EditValue ?>"<?php echo $rooms->description->EditAttributes() ?>>
<?php } ?>
<?php if ($rooms->RowType == EW_ROWTYPE_VIEW) { // View record ?>
<div<?php echo $rooms->description->ViewAttributes() ?>><?php echo $rooms->description->ListViewValue() ?></div>
<?php } ?>
</td>
	<?php } ?>
<?php

// Render list options (body, right)
$rooms_list->ListOptions->Render("body", "right");
?>
	</tr>
<?php if ($rooms->RowType == EW_ROWTYPE_ADD) { ?>
<?php } ?>
<?php if ($rooms->RowType == EW_ROWTYPE_EDIT) { ?>
<?php } ?>
<?php
	}
	if ($rooms->CurrentAction <> "gridadd")
		$rs->MoveNext();
}
?>
</tbody>
</table>
<?php } ?>
<?php if ($rooms->CurrentAction == "gridadd") { ?>
<input type="hidden" name="a_list" id="a_list" value="gridinsert">
<input type="hidden" name="key_count" id="key_count" value="<?php echo $rooms_list->lRowIndex ?>">
<?php } ?>
<?php if ($rooms->CurrentAction == "gridedit") { ?>
<input type="hidden" name="a_list" id="a_list" value="gridupdate">
<input type="hidden" name="key_count" id="key_count" value="<?php echo $rooms_list->lRowIndex ?>">
<?php echo $rooms_list->sMultiSelectKey ?>
<?php } ?>
</div>
</form>
<?php

// Close recordset
if ($rs)
	$rs->Close();
?>
<?php if ($rooms_list->lTotalRecs > 0) { ?>
<?php if ($rooms->Export == "") { ?>
<div class="ewGridLowerPanel">
<?php if ($rooms->CurrentAction <> "gridadd" && $rooms->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>
<?php if (!isset($rooms_list->Pager)) $rooms_list->Pager = new cPrevNextPager($rooms_list->lStartRec, $rooms_list->lDisplayRecs, $rooms_list->lTotalRecs) ?>
<?php if ($rooms_list->Pager->RecordCount > 0) { ?>
	<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpmaker"><?php echo $Language->Phrase("Page") ?>&nbsp;</span></td>
<!--first page button-->
	<?php if ($rooms_list->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $rooms_list->PageUrl() ?>start=<?php echo $rooms_list->Pager->FirstButton->Start ?>"><img src="images/first.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/firstdisab.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--previous page button-->
	<?php if ($rooms_list->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $rooms_list->PageUrl() ?>start=<?php echo $rooms_list->Pager->PrevButton->Start ?>"><img src="images/prev.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/prevdisab.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--current page number-->
	<td><input type="text" name="<?php echo EW_TABLE_PAGE_NO ?>" id="<?php echo EW_TABLE_PAGE_NO ?>" value="<?php echo $rooms_list->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($rooms_list->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $rooms_list->PageUrl() ?>start=<?php echo $rooms_list->Pager->NextButton->Start ?>"><img src="images/next.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/nextdisab.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
<!--last page button-->
	<?php if ($rooms_list->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $rooms_list->PageUrl() ?>start=<?php echo $rooms_list->Pager->LastButton->Start ?>"><img src="images/last.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/lastdisab.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
	<?php } ?>
	<td><span class="phpmaker">&nbsp;<?php echo $Language->Phrase("of") ?>&nbsp;<?php echo $rooms_list->Pager->PageCount ?></span></td>
	</tr></table>
	</td>	
	<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
	<td>
	<span class="phpmaker"><?php echo $Language->Phrase("Record") ?>&nbsp;<?php echo $rooms_list->Pager->FromIndex ?>&nbsp;<?php echo $Language->Phrase("To") ?>&nbsp;<?php echo $rooms_list->Pager->ToIndex ?>&nbsp;<?php echo $Language->Phrase("Of") ?>&nbsp;<?php echo $rooms_list->Pager->RecordCount ?></span>
<?php } else { ?>
	<?php if ($rooms_list->sSrchWhere == "0=101") { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("EnterSearchCriteria") ?></span>
	<?php } else { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("NoRecord") ?></span>
	<?php } ?>
<?php } ?>
		</td>
<?php if ($rooms_list->lTotalRecs > 0) { ?>
		<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
		<td><table border="0" cellspacing="0" cellpadding="0"><tr><td><?php echo $Language->Phrase("RecordsPerPage") ?>&nbsp;</td><td>
<input type="hidden" id="t" name="t" value="rooms">
<select name="<?php echo EW_TABLE_REC_PER_PAGE ?>" id="<?php echo EW_TABLE_REC_PER_PAGE ?>" onchange="this.form.submit();" class="phpmaker">
<option value="10"<?php if ($rooms_list->lDisplayRecs == 10) { ?> selected="selected"<?php } ?>>10</option>
<option value="25"<?php if ($rooms_list->lDisplayRecs == 25) { ?> selected="selected"<?php } ?>>25</option>
<option value="50"<?php if ($rooms_list->lDisplayRecs == 50) { ?> selected="selected"<?php } ?>>50</option>
<option value="ALL"<?php if ($rooms->getRecordsPerPage() == -1) { ?> selected="selected"<?php } ?>><?php echo $Language->Phrase("AllRecords") ?></option>
</select></td></tr></table>
		</td>
<?php } ?>
	</tr>
</table>
</form>
<?php } ?>
<?php //if ($rooms_list->lTotalRecs > 0) { ?>
<span class="phpmaker">
<?php if ($rooms->CurrentAction <> "gridadd" && $rooms->CurrentAction <> "gridedit") { // Not grid add/edit mode ?>
<?php if ($Security->CanAdd()) { ?>
<a href="<?php echo $rooms_list->AddUrl ?>"><?php echo $Language->Phrase("AddLink") ?></a>&nbsp;&nbsp;
<a href="<?php echo $rooms_list->GridAddUrl ?>"><?php echo $Language->Phrase("GridAddLink") ?></a>&nbsp;&nbsp;
<?php } ?>
<?php if ($Security->CanEdit()) { ?>
<?php if ($rooms_list->lTotalRecs > 0) { ?>
<a href="<?php echo $rooms_list->GridEditUrl ?>"><?php echo $Language->Phrase("GridEditLink") ?></a>&nbsp;&nbsp;
<?php } ?>
<?php } ?>
<?php if ($rooms_list->lTotalRecs > 0) { ?>
<?php if ($Security->CanDelete()) { ?>
<a href="" onclick="ew_SubmitSelected(document.froomslist, '<?php echo $rooms_list->MultiDeleteUrl ?>');return false;"><?php echo $Language->Phrase("DeleteSelectedLink") ?></a>&nbsp;&nbsp;
<?php } ?>
<?php } ?>
<?php } else { // Grid add/edit mode ?>
<?php if ($rooms->CurrentAction == "gridadd") { ?>
<a href="" onclick="f=document.froomslist;if(rooms_list.ValidateForm(f))f.submit();return false;"><?php echo $Language->Phrase("GridInsertLink") ?></a>&nbsp;&nbsp;
<a href="<?php echo $rooms_list->PageUrl() ?>a=cancel"><?php echo $Language->Phrase("GridCancelLink") ?></a>&nbsp;&nbsp;
<?php } ?>
<?php if ($rooms->CurrentAction == "gridedit") { ?>
<a href="" onclick="f=document.froomslist;if(rooms_list.ValidateForm(f))f.submit();return false;"><?php echo $Language->Phrase("GridSaveLink") ?></a>&nbsp;&nbsp;
<a href="<?php echo $rooms_list->PageUrl() ?>a=cancel"><?php echo $Language->Phrase("GridCancelLink") ?></a>&nbsp;&nbsp;
<?php } ?>
<?php } ?>
</span>
<?php //} ?>
</div>
<?php } ?>
<?php } ?>
</td></tr></table>
<?php if ($rooms->Export == "" && $rooms->CurrentAction == "") { ?>
<script type="text/javascript">
<!--
ew_ToggleSearchPanel(rooms_list); // Init search panel as collapsed

//-->
</script>
<?php } ?>
<?php if ($rooms->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
$rooms_list->Page_Terminate();
?>
<?php

//
// Page class
//
class crooms_list {

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

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

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

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

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

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

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

		// Table object (rooms)
		$GLOBALS["rooms"] = new crooms();

		// 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["rooms"]->AddUrl();
		$this->InlineAddUrl = $this->PageUrl() . "a=add";
		$this->GridAddUrl = $this->PageUrl() . "a=gridadd";
		$this->GridEditUrl = $this->PageUrl() . "a=gridedit";
		$this->MultiDeleteUrl = "roomsdelete.php";
		$this->MultiUpdateUrl = "roomsupdate.php";

		// Table object (useraccounts)
		$GLOBALS['useraccounts'] = new cuseraccounts();

		// 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", 'rooms', 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 $rooms;

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		$Security->TablePermission_Loading();
		$Security->LoadCurrentUserLevel($this->TableName);
		$Security->TablePermission_Loaded();
		$Security->UserID_Loading();
		if ($Security->IsLoggedIn()) $Security->LoadUserID();
		$Security->UserID_Loaded();

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

		// Get export parameters
		if (@$_GET["export"] <> "") {
			$rooms->Export = $_GET["export"];
		} elseif (ew_IsHttpPost()) {
			if (@$_POST["exporttype"] <> "")
				$rooms->Export = $_POST["exporttype"];
		} else {
			$rooms->setExportReturnUrl(ew_CurrentUrl());
		}
		$gsExport = $rooms->Export; // Get export parameter, used in header
		$gsExportFile = $rooms->TableVar; // Get export file, used in header
		if (in_array($rooms->Export, array("html", "email", "excel", "word")))
			echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";
		if ($rooms->Export == "excel") {
			header('Content-Type: application/vnd.ms-excel;charset=utf-8');
			header('Content-Disposition: attachment; filename=' . $gsExportFile .'.xls');
		}
		if ($rooms->Export == "word") {
			header('Content-Type: application/vnd.ms-word;charset=utf-8');
			header('Content-Disposition: attachment; filename=' . $gsExportFile .'.doc');
		}
		if ($rooms->Export == "csv") {
			header('Content-Type: application/csv;charset=utf-8');
			header('Content-Disposition: attachment; filename=' . $gsExportFile .'.csv');
		}

		// 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 = 10;
	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, $rooms;

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

			// Set up records per page
			$this->SetUpDisplayRecs();

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

			// Check QueryString parameters
			if (@$_GET["a"] <> "") {
				$rooms->CurrentAction = $_GET["a"];

				// Clear inline mode
				if ($rooms->CurrentAction == "cancel")
					$this->ClearInlineMode();

				// Switch to grid edit mode
				if ($rooms->CurrentAction == "gridedit")
					$this->GridEditMode();

				// Switch to grid add mode
				if ($rooms->CurrentAction == "gridadd")
					$this->GridAddMode();
			} else {
				if (@$_POST["a_list"] <> "") {
					$rooms->CurrentAction = $_POST["a_list"]; // Get action

					// Grid Update
					if (($rooms->CurrentAction == "gridupdate" || $rooms->CurrentAction == "gridoverwrite") && @$_SESSION[EW_SESSION_INLINE_MODE] == "gridedit")
						$this->GridUpdate();

					// Grid Insert
					if ($rooms->CurrentAction == "gridinsert" && @$_SESSION[EW_SESSION_INLINE_MODE] == "gridadd")
						$this->GridInsert();
				}
			}

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

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

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

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

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

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

		// Restore display records
		if ($rooms->getRecordsPerPage() <> "") {
			$this->lDisplayRecs = $rooms->getRecordsPerPage(); // Restore from Session
		} else {
			$this->lDisplayRecs = 10; // 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
		$rooms->Recordset_Searching($this->sSrchWhere);

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

		// Build filter
		$sFilter = "";
		if ($this->sDbDetailFilter <> "")
			$sFilter = ($sFilter <> "") ? "(" . $sFilter . ") AND (" . $this->sDbDetailFilter . ")" : $this->sDbDetailFilter;
		if ($this->sSrchWhere <> "")
			$sFilter = ($sFilter <> "") ? "(" . $sFilter . ") AND (". $this->sSrchWhere . ")" : $this->sSrchWhere;

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

		// Export data only
		if (in_array($rooms->Export, array("html","word","excel","xml","csv","email"))) {
			$this->ExportData();
			if ($rooms->Export <> "email")
				$this->Page_Terminate(); // Terminate response
			exit();
		}
	}

	// Set up number of records displayed per page
	function SetUpDisplayRecs() {
		global $rooms;
		$sWrk = @$_GET[EW_TABLE_REC_PER_PAGE];
		if ($sWrk <> "") {
			if (is_numeric($sWrk)) {
				$this->lDisplayRecs = intval($sWrk);
			} else {
				if (strtolower($sWrk) == "all") { // Display all records
					$this->lDisplayRecs = -1;
				} else {
					$this->lDisplayRecs = 10; // Non-numeric, load default
				}
			}
			$rooms->setRecordsPerPage($this->lDisplayRecs); // Save to Session

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

	//  Exit inline mode
	function ClearInlineMode() {
		global $rooms;
		$rooms->CurrentAction = ""; // Clear action
		$_SESSION[EW_SESSION_INLINE_MODE] = ""; // Clear inline mode
	}

	// Switch to Grid Add mode
	function GridAddMode() {
		$_SESSION[EW_SESSION_INLINE_MODE] = "gridadd"; // Enabled grid add
	}

	// Switch to Grid Edit mode
	function GridEditMode() {
		$_SESSION[EW_SESSION_INLINE_MODE] = "gridedit"; // Enable grid edit
	}

	// Perform update to grid
	function GridUpdate() {
		global $conn, $Language, $objForm, $gsFormError, $rooms;
		$rowindex = 1;
		$bGridUpdate = TRUE;

		// Begin transaction
		$conn->BeginTrans();

		// Get old recordset
		$rooms->CurrentFilter = $this->BuildKeyFilter();
		$sSql = $rooms->SQL();
		if ($rs = $conn->Execute($sSql)) {
			$rsold = $rs->GetRows();
			$rs->Close();
		}
		$sKey = "";

		// Update row index and get row key
		$objForm->Index = $rowindex;
		$sThisKey = strval($objForm->GetValue("k_key"));

		// Update all rows based on key
		while ($sThisKey <> "") {

			// Load all values and keys
			$this->LoadFormValues(); // Get form values

			// Validate form
			if (!$this->ValidateForm()) {
				$bGridUpdate = FALSE; // Form error, reset action
				$this->setMessage($gsFormError);
			} else {
				if ($this->SetupKeyValues($sThisKey)) { // Set up key values
					$rooms->SendEmail = FALSE; // Do not send email on update success
					$bGridUpdate = $this->EditRow(); // Update this row
				} else {
					$bGridUpdate = FALSE; // update failed
				}
			}
			if ($bGridUpdate) {
				if ($sKey <> "") $sKey .= ", ";
				$sKey .= $sThisKey;
			} else {
				break;
			}

			// Update row index and get row key
			$rowindex++; // next row
			$objForm->Index = $rowindex;
			$sThisKey = strval($objForm->GetValue("k_key"));
		}
		if ($bGridUpdate) {
			$conn->CommitTrans(); // Commit transaction

			// Get new recordset
			if ($rs = $conn->Execute($sSql)) {
				$rsnew = $rs->GetRows();
				$rs->Close();
			}
			$this->setMessage($Language->Phrase("UpdateSuccess")); // Set update success message
			$this->ClearInlineMode(); // Clear inline edit mode
		} else {
			$conn->RollbackTrans(); // Rollback transaction
			if ($this->getMessage() == "")
				$this->setMessage($Language->Phrase("UpdateFailed")); // Set update failed message
			$rooms->EventCancelled = TRUE; // Set event cancelled
			$rooms->CurrentAction = "gridedit"; // Stay in Grid Edit mode
		}
	}

	// Build filter for all keys
	function BuildKeyFilter() {
		global $objForm, $rooms;
		$sWrkFilter = "";

		// Update row index and get row key
		$rowindex = 1;
		$objForm->Index = $rowindex;
		$sThisKey = strval($objForm->GetValue("k_key"));
		while ($sThisKey <> "") {
			if ($this->SetupKeyValues($sThisKey)) {
				$sFilter = $rooms->KeyFilter();
				if ($sWrkFilter <> "") $sWrkFilter .= " OR ";
				$sWrkFilter .= $sFilter;
			} else {
				$sWrkFilter = "0=1";
				break;
			}

			// Update row index and get row key
			$rowindex++; // next row
			$objForm->Index = $rowindex;
			$sThisKey = strval($objForm->GetValue("k_key"));
		}
		return $sWrkFilter;
	}

	// Set up key values
	function SetupKeyValues($key) {
		global $rooms;
		$arrKeyFlds = explode(EW_COMPOSITE_KEY_SEPARATOR, $key);
		if (count($arrKeyFlds) >= 1) {
			$rooms->id->setFormValue($arrKeyFlds[0]);
		}
		return TRUE;
	}

	// Perform Grid Add
	function GridInsert() {
		global $conn, $Language, $objForm, $gsFormError, $rooms;
		$rowindex = 1;
		$bGridInsert = FALSE;

		// Begin transaction
		$conn->BeginTrans();

		// Init key filter
		$sWrkFilter = "";
		$addcnt = 0;
		$sKey = "";

		// Get row count
		$objForm->Index = 0;
		$rowcnt = strval($objForm->GetValue("key_count"));
		if ($rowcnt == "" || !is_numeric($rowcnt))
			$rowcnt = 0;

		// Insert all rows
		for ($rowindex = 1; $rowindex <= $rowcnt; $rowindex++) {

			// Load current row values
			$objForm->Index = $rowindex;
			$this->LoadFormValues(); // Get form values
			if (!$this->EmptyRow()) {
				$addcnt++;
				$rooms->SendEmail = FALSE; // Do not send email on insert success

				// Validate form
				if (!$this->ValidateForm()) {
					$bGridInsert = FALSE; // Form error, reset action
					$this->setMessage($gsFormError);
				} else {
					$bGridInsert = $this->AddRow(); // Insert this row
				}
				if ($bGridInsert) {
					if ($sKey <> "") $sKey .= EW_COMPOSITE_KEY_SEPARATOR;
					$sKey .= $rooms->id->CurrentValue;

					// Add filter for this record
					$sFilter = $rooms->KeyFilter();
					if ($sWrkFilter <> "") $sWrkFilter .= " OR ";
					$sWrkFilter .= $sFilter;
				} else {
					break;
				}
			}
		}
		if ($bGridInsert) {
			$conn->CommitTrans(); // Commit transaction

			// Get new recordset
			$rooms->CurrentFilter = $sWrkFilter;
			$sSql = $rooms->SQL();
			if ($rs = $conn->Execute($sSql)) {
				$rsnew = $rs->GetRows();
				$rs->Close();
			}
			$this->setMessage($Language->Phrase("InsertSuccess")); // Set insert success message
			$this->ClearInlineMode(); // Clear grid add mode
		} else {
			$conn->RollbackTrans(); // Rollback transaction
			if ($addcnt == 0) { // No record inserted
				$this->setMessage($Language->Phrase("NoAddRecord"));
			} elseif ($this->getMessage() == "") {
				$this->setMessage($Language->Phrase("InsertFailed")); // Set insert failed message
			}
			$rooms->EventCancelled = TRUE; // Set event cancelled
			$rooms->CurrentAction = "gridadd"; // Stay in gridadd mode
		}
	}

	// Check if empty row
	function EmptyRow() {
		global $rooms;
		if ($rooms->id->CurrentValue <> $rooms->id->OldValue)
			return FALSE;
		if ($rooms->name->CurrentValue <> $rooms->name->OldValue)
			return FALSE;
		if ($rooms->description->CurrentValue <> $rooms->description->OldValue)
			return FALSE;
		return TRUE;
	}

	// Restore form values for current row
	function RestoreCurrentRowFormValues($idx) {
		global $objForm, $rooms;

		// Get row based on current index
		$objForm->Index = $idx;
		if ($rooms->CurrentAction == "gridadd")
			$this->LoadFormValues(); // Load form values
		if ($rooms->CurrentAction == "gridedit") {
			$sKey = strval($objForm->GetValue("k_key"));
			$arrKeyFlds = explode(EW_COMPOSITE_KEY_SEPARATOR, $sKey);
			if (count($arrKeyFlds) >= 1) {
				if (strval($arrKeyFlds[0]) == strval($rooms->id->CurrentValue)) {
					$this->LoadFormValues(); // Load form values
				}
			}
		}
	}

	// Return basic search SQL
	function BasicSearchSQL($Keyword) {
		global $rooms;
		$sKeyword = ew_AdjustSql($Keyword);
		$sWhere = "";
		$this->BuildBasicSearchSQL($sWhere, $rooms->id, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $rooms->name, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $rooms->description, $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, $rooms;
		$sSearchStr = "";
		$sSearchKeyword = $rooms->BasicSearchKeyword;
		$sSearchType = $rooms->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 <> "") {
			$rooms->setSessionBasicSearchKeyword($sSearchKeyword);
			$rooms->setSessionBasicSearchType($sSearchType);
		}
		return $sSearchStr;
	}

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

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

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

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

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

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

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

		// Check for "order" parameter
		if (@$_GET["order"] <> "") {
			$rooms->CurrentOrder = ew_StripSlashes(@$_GET["order"]);
			$rooms->CurrentOrderType = @$_GET["ordertype"];
			$rooms->UpdateSort($rooms->id); // id
			$rooms->UpdateSort($rooms->name); // name
			$rooms->UpdateSort($rooms->description); // description
			$rooms->setStartRecordNumber(1); // Reset start position
		}
	}

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

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

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

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

			// Reset sorting order
			if (strtolower($sCmd) == "resetsort") {
				$sOrderBy = "";
				$rooms->setSessionOrderBy($sOrderBy);
				$rooms->id->setSort("");
				$rooms->name->setSort("");
				$rooms->description->setSort("");
			}

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

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

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

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

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

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

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

		// "checkbox"
		$this->ListOptions->Add("checkbox");
		$item =& $this->ListOptions->Items["checkbox"];
		$item->CssStyle = "white-space: nowrap;";
		$item->Visible = $Security->CanDelete();
		$item->OnLeft = FALSE;
		$item->Header = "<input type=\"checkbox\" name=\"key\" id=\"key\" class=\"phpmaker\" onclick=\"rooms_list.SelectAllKey(this);\">";

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

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

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

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

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

		// "detail_stores"
		$oListOpt =& $this->ListOptions->Items["detail_stores"];
		if (True) {
			$oListOpt->Body = $Language->Phrase("DetailLink") . $Language->TablePhrase("stores", "TblCaption");
			$oListOpt->Body = "<a href=\"storeslist.php?" . EW_TABLE_SHOW_MASTER . "=rooms&id=" . urlencode(strval($rooms->id->CurrentValue)) . "\">" . $oListOpt->Body . "</a>";
		}

		// "detail_orders"
		$oListOpt =& $this->ListOptions->Items["detail_orders"];
		if ($Security->AllowList('orders')) {
			$oListOpt->Body = $Language->Phrase("DetailLink") . $Language->TablePhrase("orders", "TblCaption");
			$oListOpt->Body = "<a href=\"orderslist.php?" . EW_TABLE_SHOW_MASTER . "=rooms&id=" . urlencode(strval($rooms->id->CurrentValue)) . "\">" . $oListOpt->Body . "</a>";
		}

		// "checkbox"
		$oListOpt =& $this->ListOptions->Items["checkbox"];
		if ($Security->CanDelete() && $oListOpt->Visible)
			$oListOpt->Body = "<input type=\"checkbox\" name=\"key_m[]\" id=\"key_m[]\" value=\"" . ew_HtmlEncode($rooms->id->CurrentValue) . "\" class=\"phpmaker\" onclick='ew_ClickMultiCheckbox(this);'>";
		if ($rooms->CurrentAction == "gridedit")
			$this->sMultiSelectKey .= "<input type=\"hidden\" name=\"k" . $this->lRowIndex . "_key\" id=\"k" . $this->lRowIndex . "_key\" value=\"" . $rooms->id->CurrentValue . "\">";
		$this->RenderListOptionsExt();

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

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

	// Set up starting record parameters
	function SetUpStartRec() {
		global $rooms;
		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];
				$rooms->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;
					}
					$rooms->setStartRecordNumber($this->lStartRec);
				}
			}
		}
		$this->lStartRec = $rooms->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
			$rooms->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
			$rooms->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
			$rooms->setStartRecordNumber($this->lStartRec);
		}
	}

	// Load default values
	function LoadDefaultValues() {
		global $rooms;
	}

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

	// Load form values
	function LoadFormValues() {

		// Load from form
		global $objForm, $rooms;
		$rooms->id->setFormValue($objForm->GetValue("x_id"));
		$rooms->id->setOldValue($objForm->GetValue("o_id"));
		$rooms->name->setFormValue($objForm->GetValue("x_name"));
		$rooms->name->setOldValue($objForm->GetValue("o_name"));
		$rooms->description->setFormValue($objForm->GetValue("x_description"));
		$rooms->description->setOldValue($objForm->GetValue("o_description"));
	}

	// Restore form values
	function RestoreFormValues() {
		global $objForm, $rooms;
		$rooms->id->CurrentValue = $rooms->id->FormValue;
		$rooms->name->CurrentValue = $rooms->name->FormValue;
		$rooms->description->CurrentValue = $rooms->description->FormValue;
	}

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

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

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

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

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

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

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

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

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

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $rooms;
		$rooms->id->setDbValue($rs->fields('id'));
		$rooms->name->setDbValue($rs->fields('name'));
		$rooms->description->setDbValue($rs->fields('description'));
	}

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

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

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

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

		$rooms->id->CellCssStyle = ""; $rooms->id->CellCssClass = "";
		$rooms->id->CellAttrs = array(); $rooms->id->ViewAttrs = array(); $rooms->id->EditAttrs = array();

		// name
		$rooms->name->CellCssStyle = ""; $rooms->name->CellCssClass = "";
		$rooms->name->CellAttrs = array(); $rooms->name->ViewAttrs = array(); $rooms->name->EditAttrs = array();

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

			// id
			$rooms->id->ViewValue = $rooms->id->CurrentValue;
			$rooms->id->CssStyle = "";
			$rooms->id->CssClass = "";
			$rooms->id->ViewCustomAttributes = "";

			// name
			$rooms->name->ViewValue = $rooms->name->CurrentValue;
			$rooms->name->CssStyle = "";
			$rooms->name->CssClass = "";
			$rooms->name->ViewCustomAttributes = "";

			// description
			$rooms->description->ViewValue = $rooms->description->CurrentValue;
			$rooms->description->CssStyle = "";
			$rooms->description->CssClass = "";
			$rooms->description->ViewCustomAttributes = "";

			// id
			$rooms->id->HrefValue = "";
			$rooms->id->TooltipValue = "";

			// name
			$rooms->name->HrefValue = "";
			$rooms->name->TooltipValue = "";

			// description
			$rooms->description->HrefValue = "";
			$rooms->description->TooltipValue = "";
		} elseif ($rooms->RowType == EW_ROWTYPE_ADD) { // Add row

			// id
			$rooms->id->EditCustomAttributes = "";
			$rooms->id->EditValue = ew_HtmlEncode($rooms->id->CurrentValue);

			// name
			$rooms->name->EditCustomAttributes = "";
			$rooms->name->EditValue = ew_HtmlEncode($rooms->name->CurrentValue);

			// description
			$rooms->description->EditCustomAttributes = "";
			$rooms->description->EditValue = ew_HtmlEncode($rooms->description->CurrentValue);
		} elseif ($rooms->RowType == EW_ROWTYPE_EDIT) { // Edit row

			// id
			$rooms->id->EditCustomAttributes = "";
			$rooms->id->EditValue = $rooms->id->CurrentValue;
			$rooms->id->CssStyle = "";
			$rooms->id->CssClass = "";
			$rooms->id->ViewCustomAttributes = "";

			// name
			$rooms->name->EditCustomAttributes = "";
			$rooms->name->EditValue = ew_HtmlEncode($rooms->name->CurrentValue);

			// description
			$rooms->description->EditCustomAttributes = "";
			$rooms->description->EditValue = ew_HtmlEncode($rooms->description->CurrentValue);

			// Edit refer script
			// id

			$rooms->id->HrefValue = "";

			// name
			$rooms->name->HrefValue = "";

			// description
			$rooms->description->HrefValue = "";
		}

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

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

		// Initialize form error message
		$gsFormError = "";

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return ($gsFormError == "");
		if (!is_null($rooms->id->FormValue) && $rooms->id->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $rooms->id->FldCaption();
		}

		// 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, $rooms;
		$sFilter = $rooms->KeyFilter();
		$rooms->CurrentFilter = $sFilter;
		$sSql = $rooms->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();

			// id
			// name

			$rooms->name->SetDbValueDef($rsnew, $rooms->name->CurrentValue, NULL, FALSE);

			// description
			$rooms->description->SetDbValueDef($rsnew, $rooms->description->CurrentValue, NULL, FALSE);

			// Call Row Updating event
			$bUpdateRow = $rooms->Row_Updating($rsold, $rsnew);
			if ($bUpdateRow) {
				$conn->raiseErrorFn = 'ew_ErrorFn';
				$EditRow = $conn->Execute($rooms->UpdateSQL($rsnew));
				$conn->raiseErrorFn = '';
			} else {
				if ($rooms->CancelMessage <> "") {
					$this->setMessage($rooms->CancelMessage);
					$rooms->CancelMessage = "";
				} else {
					$this->setMessage($Language->Phrase("UpdateCancelled"));
				}
				$EditRow = FALSE;
			}
		}

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

	// Add record
	function AddRow() {
		global $conn, $Language, $Security, $rooms;

		// Check if key value entered
		if ($rooms->id->CurrentValue == "") {
			$this->setMessage($Language->Phrase("InvalidKeyValue"));
			return FALSE;
		}

		// Check for duplicate key
		$bCheckKey = TRUE;
		$sFilter = $rooms->KeyFilter();
		if ($bCheckKey) {
			$rsChk = $rooms->LoadRs($sFilter);
			if ($rsChk && !$rsChk->EOF) {
				$sKeyErrMsg = str_replace("%f", $sFilter, $Language->Phrase("DupKey"));
				$this->setMessage($sKeyErrMsg);
				$rsChk->Close();
				return FALSE;
			}
		}
		$rsnew = array();

		// id
		$rooms->id->SetDbValueDef($rsnew, $rooms->id->CurrentValue, "", FALSE);

		// name
		$rooms->name->SetDbValueDef($rsnew, $rooms->name->CurrentValue, NULL, FALSE);

		// description
		$rooms->description->SetDbValueDef($rsnew, $rooms->description->CurrentValue, NULL, FALSE);

		// Call Row Inserting event
		$bInsertRow = $rooms->Row_Inserting($rsnew);
		if ($bInsertRow) {
			$conn->raiseErrorFn = 'ew_ErrorFn';
			$AddRow = $conn->Execute($rooms->InsertSQL($rsnew));
			$conn->raiseErrorFn = '';
		} else {
			if ($rooms->CancelMessage <> "") {
				$this->setMessage($rooms->CancelMessage);
				$rooms->CancelMessage = "";
			} else {
				$this->setMessage($Language->Phrase("InsertCancelled"));
			}
			$AddRow = FALSE;
		}
		if ($AddRow) {

			// Call Row Inserted event
			$rooms->Row_Inserted($rsnew);
		}
		return $AddRow;
	}

	// Export data in HTML/CSV/Word/Excel/XML/Email format
	function ExportData() {
		global $rooms;
		$utf8 = TRUE;
		$bSelectLimit = EW_SELECT_LIMIT;

		// Load recordset
		if ($bSelectLimit) {
			$this->lTotalRecs = $rooms->SelectRecordCount();
		} else {
			if ($rs = $this->LoadRecordset())
				$this->lTotalRecs = $rs->RecordCount();
		}
		$this->lStartRec = 1;

		// Export all
		if ($rooms->ExportAll) {
			$this->lDisplayRecs = $this->lTotalRecs;
			$this->lStopRec = $this->lTotalRecs;
		} else { // Export one page only
			$this->SetUpStartRec(); // Set up start record position

			// Set the last record to display
			if ($this->lDisplayRecs < 0) {
				$this->lStopRec = $this->lTotalRecs;
			} else {
				$this->lStopRec = $this->lStartRec + $this->lDisplayRecs - 1;
			}
		}
		if ($bSelectLimit)
			$rs = $this->LoadRecordset($this->lStartRec-1, $this->lDisplayRecs);
		if (!$rs) {
			header("Content-Type:"); // Remove header
			header("Content-Disposition:");
			$this->ShowMessage();
			return;
		}
		if ($rooms->Export == "xml") {
			$XmlDoc = new cXMLDocument(EW_XML_ENCODING);
			$XmlDoc->AddRoot();
		} else {
			$ExportDoc = new cExportDocument($rooms, "h");
			$ExportDoc->ExportHeader();
			if ($ExportDoc->Horizontal) { // Horizontal format, write header
				$ExportDoc->BeginExportRow();
				$ExportDoc->ExportCaption($rooms->id);
				$ExportDoc->ExportCaption($rooms->name);
				$ExportDoc->ExportCaption($rooms->description);
				$ExportDoc->EndExportRow();
			}
		}

		// Move to first record
		$this->lRecCnt = $this->lStartRec - 1;
		if (!$rs->EOF) {
			$rs->MoveFirst();
			if (!$bSelectLimit && $this->lStartRec > 1)
				$rs->Move($this->lStartRec - 1);
		}
		while (!$rs->EOF && $this->lRecCnt < $this->lStopRec) {
			$this->lRecCnt++;
			if (intval($this->lRecCnt) >= intval($this->lStartRec)) {
				$this->LoadRowValues($rs);

				// Render row
				$rooms->CssClass = "";
				$rooms->CssStyle = "";
				$rooms->RowType = EW_ROWTYPE_VIEW; // Render view
				$this->RenderRow();
				if ($rooms->Export == "xml") {
					$XmlDoc->AddRow();
					$XmlDoc->AddField('id', $rooms->id->ExportValue($rooms->Export, $rooms->ExportOriginalValue));
					$XmlDoc->AddField('name', $rooms->name->ExportValue($rooms->Export, $rooms->ExportOriginalValue));
					$XmlDoc->AddField('description', $rooms->description->ExportValue($rooms->Export, $rooms->ExportOriginalValue));
				} else {
					$ExportDoc->BeginExportRow(TRUE); // Allow CSS styles if enabled
					$ExportDoc->ExportField($rooms->id);
					$ExportDoc->ExportField($rooms->name);
					$ExportDoc->ExportField($rooms->description);
					$ExportDoc->EndExportRow();
				}
			}
			$rs->MoveNext();
		}
		if ($rooms->Export <> "xml")
			$ExportDoc->ExportFooter();

		// Close recordset
		$rs->Close();

		// Clean output buffer
		if (!EW_DEBUG_ENABLED && ob_get_length())
			ob_end_clean();

		// Write BOM if utf-8
		if ($utf8 && !in_array($rooms->Export, array("email", "xml")))
			echo "\xEF\xBB\xBF";

		// Write debug message if enabled
		if (EW_DEBUG_ENABLED)
			echo ew_DebugMsg();

		// Output data
		if ($rooms->Export == "xml") {
			header("Content-Type: text/xml");
			echo $XmlDoc->XML();
		} elseif ($rooms->Export == "email") {
			$this->ExportEmail($ExportDoc->Text);
			$this->Page_Terminate($rooms->ExportReturnUrl());
		} else {
			echo $ExportDoc->Text;
		}
	}

	// Export email
	function ExportEmail($EmailContent) {
		global $Language, $rooms;
		$sSender = @$_GET["sender"];
		$sRecipient = @$_GET["recipient"];
		$sCc = @$_GET["cc"];
		$sBcc = @$_GET["bcc"];
		$sContentType = @$_GET["contenttype"];

		// Subject
		$sSubject = ew_StripSlashes(@$_GET["subject"]);
		$sEmailSubject = $sSubject;

		// Message
		$sContent = ew_StripSlashes(@$_GET["message"]);
		$sEmailMessage = $sContent;

		// Check sender
		if ($sSender == "") {
			$this->setMessage($Language->Phrase("EnterSenderEmail"));
			return;
		}
		if (!ew_CheckEmail($sSender)) {
			$this->setMessage($Language->Phrase("EnterProperSenderEmail"));
			return;
		}

		// Check recipient
		if (!ew_CheckEmailList($sRecipient, EW_MAX_EMAIL_RECIPIENT)) {
			$this->setMessage($Language->Phrase("EnterProperRecipientEmail"));
			return;
		}

		// Check cc
		if (!ew_CheckEmailList($sCc, EW_MAX_EMAIL_RECIPIENT)) {
			$this->setMessage($Language->Phrase("EnterProperCcEmail"));
			return;
		}

		// Check bcc
		if (!ew_CheckEmailList($sBcc, EW_MAX_EMAIL_RECIPIENT)) {
			$this->setMessage($Language->Phrase("EnterProperBccEmail"));
			return;
		}

		// Check email sent count
		if (!isset($_SESSION[EW_EXPORT_EMAIL_COUNTER]))
			$_SESSION[EW_EXPORT_EMAIL_COUNTER] = 0;
		if (intval($_SESSION[EW_EXPORT_EMAIL_COUNTER]) > EW_MAX_EMAIL_SENT_COUNT) {
			$this->setMessage($Language->Phrase("ExceedMaxEmailExport"));
			return;
		}
		if ($sEmailMessage <> "") {
			$sEmailMessage = ew_RemoveXSS($sEmailMessage);
			$sEmailMessage .= ($sContentType == "url") ? "\r\n\r\n" : "<br><br>";
		}
		if ($sContentType == "url") {
			$sUrl = ew_ConvertFullUrl(ew_CurrentPage() . "?" . $this->ExportQueryString());
			$sEmailMessage .= $sUrl; // send URL only
		} else {
			$sEmailMessage .= $EmailContent; // send HTML
		}

		// Send email
		$Email = new cEmail();
		$Email->Sender = $sSender; // Sender
		$Email->Recipient = $sRecipient; // Recipient
		$Email->Cc = $sCc; // Cc
		$Email->Bcc = $sBcc; // Bcc
		$Email->Subject = $sEmailSubject; // Subject
		$Email->Content = $sEmailMessage; // Content
		$Email->Format = ($sContentType == "url") ? "text" : "html";
		$Email->Charset = EW_EMAIL_CHARSET;
		$EventArgs = array();
		$bEmailSent = FALSE;
		if ($rooms->Email_Sending($Email, $EventArgs))
			$bEmailSent = $Email->Send();

		// Check email sent status
		if ($bEmailSent) {

			// Update email sent count
			$_SESSION[EW_EXPORT_EMAIL_COUNTER]++;

			// Sent email success
			$this->setMessage($Language->Phrase("SendEmailSuccess"));
		} else {

			// Sent email failure
			$this->setMessage($Email->SendErrDescription);
		}
	}

	// Export QueryString
	function ExportQueryString() {
		global $rooms;

		// Initialize
		$sQry = "export=html";

		// Build QueryString for search
		if ($rooms->getSessionBasicSearchKeyword() <> "") {
			$sQry .= "&" . EW_TABLE_BASIC_SEARCH . "=" . $rooms->getSessionBasicSearchKeyword() . "&" . EW_TABLE_BASIC_SEARCH_TYPE . "=" . $rooms->getSessionBasicSearchType();
		}

		// Build QueryString for pager
		$sQry .= "&" . EW_TABLE_REC_PER_PAGE . "=" . $rooms->getRecordsPerPage() . "&" . EW_TABLE_START_REC . "=" . $rooms->getStartRecordNumber();
		return $sQry;
	}

	// Add search QueryString
	function AddSearchQueryString(&$Qry, &$Fld) {
		global $rooms;
		$FldParm = substr($Fld->FldVar, 2);
		$FldSearchValue = $rooms->GetAdvancedSearch("x_" . $FldParm);
		if (strval($FldSearchValue) <> "") {
			$Qry .= "&x_" . $FldParm . "=" . FldSearchValue .
				"&z_" . $FldParm . "=" . $rooms->GetAdvancedSearch("z_" . $FldParm);
		}
		$FldSearchValue2 = $rooms->GetAdvancedSearch("y_" . $FldParm);
		if (strval($FldSearchValue2) <> "") {
			$Qry .= "&v_" . $FldParm . "=" . $rooms->GetAdvancedSearch("v_" . $FldParm) .
				"&y_" . $FldParm . "=" . $FldSearchValue2 .
				"&w_" . $FldParm . "=" . $rooms->GetAdvancedSearch("w_" . $FldParm);
		}
	}

	// 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";

	}
}
?>
Return current item: Science Lab Inventory & Order Management