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

// Create page object
$orders_detail_view_list = new corders_detail_view_list();
$Page =& $orders_detail_view_list;

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

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

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

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

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

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
orders_detail_view_list.SelectAllKey = function(elem) {
	ew_SelectAll(elem);
	ew_ClickAll(elem);
}
<?php if (EW_CLIENT_VALIDATE) { ?>
orders_detail_view_list.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
orders_detail_view_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 ($orders_detail_view->Export == "") { ?>
<?php } ?>
<?php
	$bSelectLimit = EW_SELECT_LIMIT;
	if ($bSelectLimit) {
		$orders_detail_view_list->lTotalRecs = $orders_detail_view->SelectRecordCount();
	} else {
		if ($rs = $orders_detail_view_list->LoadRecordset())
			$orders_detail_view_list->lTotalRecs = $rs->RecordCount();
	}
	$orders_detail_view_list->lStartRec = 1;
	if ($orders_detail_view_list->lDisplayRecs <= 0 || ($orders_detail_view->Export <> "" && $orders_detail_view->ExportAll)) // Display all records
		$orders_detail_view_list->lDisplayRecs = $orders_detail_view_list->lTotalRecs;
	if (!($orders_detail_view->Export <> "" && $orders_detail_view->ExportAll))
		$orders_detail_view_list->SetUpStartRec(); // Set up start record position
	if ($bSelectLimit)
		$rs = $orders_detail_view_list->LoadRecordset($orders_detail_view_list->lStartRec-1, $orders_detail_view_list->lDisplayRecs);
?>
<p><span class="phpmaker" style="white-space: nowrap;"><?php echo $Language->Phrase("TblTypeVIEW") ?><?php echo $orders_detail_view->TableCaption() ?>
<?php if ($orders_detail_view->Export == "" && $orders_detail_view->CurrentAction == "") { ?>
&nbsp;&nbsp;<a href="<?php echo $orders_detail_view_list->ExportPrintUrl ?>"><?php echo $Language->Phrase("PrinterFriendly") ?></a>
&nbsp;&nbsp;<a href="<?php echo $orders_detail_view_list->ExportHtmlUrl ?>"><?php echo $Language->Phrase("ExportToHtml") ?></a>
&nbsp;&nbsp;<a href="<?php echo $orders_detail_view_list->ExportExcelUrl ?>"><?php echo $Language->Phrase("ExportToExcel") ?></a>
&nbsp;&nbsp;<a href="<?php echo $orders_detail_view_list->ExportWordUrl ?>"><?php echo $Language->Phrase("ExportToWord") ?></a>
&nbsp;&nbsp;<a href="<?php echo $orders_detail_view_list->ExportCsvUrl ?>"><?php echo $Language->Phrase("ExportToCsv") ?></a>
&nbsp;&nbsp;<a name="emf_orders_detail_view" id="emf_orders_detail_view" href="javascript:void(0);" onclick="ew_EmailDialogShow({lnk:'emf_orders_detail_view',hdr:ewLanguage.Phrase('ExportToEmail'),f:document.forders_detail_viewlist,sel:false});"><?php echo $Language->Phrase("ExportToEmail") ?></a>
<?php } ?>
</span></p>
<?php if ($orders_detail_view->Export == "" && $orders_detail_view->CurrentAction == "") { ?>
<a href="javascript:ew_ToggleSearchPanel(orders_detail_view_list);" style="text-decoration: none;"><img id="orders_detail_view_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="orders_detail_view_list_SearchPanel">
<form name="forders_detail_viewlistsrch" id="forders_detail_viewlistsrch" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
<input type="hidden" id="t" name="t" value="orders_detail_view">
<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($orders_detail_view->getSessionBasicSearchKeyword()) ?>">
			<input type="Submit" name="Submit" id="Submit" value="<?php echo ew_BtnCaption($Language->Phrase("QuickSearchBtn")) ?>">&nbsp;
			<a href="<?php echo $orders_detail_view_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 ($orders_detail_view->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 ($orders_detail_view->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 ($orders_detail_view->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();
$orders_detail_view_list->ShowMessage();
?>
<br>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<?php if ($orders_detail_view->Export == "") { ?>
<div class="ewGridUpperPanel">
<?php if ($orders_detail_view->CurrentAction <> "gridadd" && $orders_detail_view->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($orders_detail_view_list->Pager)) $orders_detail_view_list->Pager = new cPrevNextPager($orders_detail_view_list->lStartRec, $orders_detail_view_list->lDisplayRecs, $orders_detail_view_list->lTotalRecs) ?>
<?php if ($orders_detail_view_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 ($orders_detail_view_list->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $orders_detail_view_list->PageUrl() ?>start=<?php echo $orders_detail_view_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 ($orders_detail_view_list->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $orders_detail_view_list->PageUrl() ?>start=<?php echo $orders_detail_view_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 $orders_detail_view_list->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($orders_detail_view_list->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $orders_detail_view_list->PageUrl() ?>start=<?php echo $orders_detail_view_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 ($orders_detail_view_list->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $orders_detail_view_list->PageUrl() ?>start=<?php echo $orders_detail_view_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 $orders_detail_view_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 $orders_detail_view_list->Pager->FromIndex ?>&nbsp;<?php echo $Language->Phrase("To") ?>&nbsp;<?php echo $orders_detail_view_list->Pager->ToIndex ?>&nbsp;<?php echo $Language->Phrase("Of") ?>&nbsp;<?php echo $orders_detail_view_list->Pager->RecordCount ?></span>
<?php } else { ?>
	<?php if ($orders_detail_view_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 ($orders_detail_view_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="orders_detail_view">
<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 ($orders_detail_view_list->lDisplayRecs == 10) { ?> selected="selected"<?php } ?>>10</option>
<option value="25"<?php if ($orders_detail_view_list->lDisplayRecs == 25) { ?> selected="selected"<?php } ?>>25</option>
<option value="50"<?php if ($orders_detail_view_list->lDisplayRecs == 50) { ?> selected="selected"<?php } ?>>50</option>
<option value="ALL"<?php if ($orders_detail_view->getRecordsPerPage() == -1) { ?> selected="selected"<?php } ?>><?php echo $Language->Phrase("AllRecords") ?></option>
</select></td></tr></table>
		</td>
<?php } ?>
	</tr>
</table>
</form>
<?php } ?>
<span class="phpmaker">
</span>
</div>
<?php } ?>
<form name="forders_detail_viewlist" id="forders_detail_viewlist" class="ewForm" action="" method="post">
<div id="gmp_orders_detail_view" class="ewGridMiddlePanel">
<?php if ($orders_detail_view_list->lTotalRecs > 0) { ?>
<table cellspacing="0" rowhighlightclass="ewTableHighlightRow" rowselectclass="ewTableSelectRow" roweditclass="ewTableEditRow" class="ewTable ewTableSeparate">
<?php echo $orders_detail_view->TableCustomInnerHtml ?>
<thead><!-- Table header -->
	<tr class="ewTableHeader">
<?php

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

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

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

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

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

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

// Render list options (body, left)
$orders_detail_view_list->ListOptions->Render("body", "left");
?>
	<?php if ($orders_detail_view->id->Visible) { // id ?>
		<td<?php echo $orders_detail_view->id->CellAttributes() ?>>
<div<?php echo $orders_detail_view->id->ViewAttributes() ?>><?php echo $orders_detail_view->id->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($orders_detail_view->teacher->Visible) { // teacher ?>
		<td<?php echo $orders_detail_view->teacher->CellAttributes() ?>>
<div<?php echo $orders_detail_view->teacher->ViewAttributes() ?>>
<?php if ($orders_detail_view->teacher->HrefValue <> "" || $orders_detail_view->teacher->TooltipValue <> "" || $orders_detail_view->order_note->ViewValue <> "") { ?>
<a href="javascript:void(0);" onmouseover="ew_ShowTooltip(this, 'tt_orders_detail_view_x<?php echo $orders_detail_view_list->lRowCnt ?>_teacher');" onmouseout="ew_HideTooltip();"><?php echo $orders_detail_view->teacher->ListViewValue() ?></a>
<?php } else { ?>
<?php echo $orders_detail_view->teacher->ListViewValue() ?>
<?php } ?>
</div><div id="tt_orders_detail_view_x<?php echo $orders_detail_view_list->lRowCnt ?>_teacher" style="display: none">
<?php if ($orders_detail_view->teacher->TooltipValue <> "") { ?>
<?php echo $orders_detail_view->teacher->TooltipValue ?>
<?php } else { ?>
<div<?php echo $orders_detail_view->order_note->ViewAttributes() ?>><?php echo $orders_detail_view->order_note->ViewValue ?></div>
<?php } ?>
</div>
</td>
	<?php } ?>
	<?php if ($orders_detail_view->lesson->Visible) { // lesson ?>
		<td<?php echo $orders_detail_view->lesson->CellAttributes() ?>>
<div<?php echo $orders_detail_view->lesson->ViewAttributes() ?>><?php echo $orders_detail_view->lesson->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($orders_detail_view->room->Visible) { // room ?>
		<td<?php echo $orders_detail_view->room->CellAttributes() ?>>
<div<?php echo $orders_detail_view->room->ViewAttributes() ?>><?php echo $orders_detail_view->room->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($orders_detail_view->request_date->Visible) { // request_date ?>
		<td<?php echo $orders_detail_view->request_date->CellAttributes() ?>>
<div<?php echo $orders_detail_view->request_date->ViewAttributes() ?>><?php echo $orders_detail_view->request_date->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($orders_detail_view->item->Visible) { // item ?>
		<td<?php echo $orders_detail_view->item->CellAttributes() ?>>
<div<?php echo $orders_detail_view->item->ViewAttributes() ?>>
<?php if ($orders_detail_view->item->HrefValue <> "" || $orders_detail_view->item->TooltipValue <> "" || $orders_detail_view->detail_note->ViewValue <> "") { ?>
<a href="javascript:void(0);" onmouseover="ew_ShowTooltip(this, 'tt_orders_detail_view_x<?php echo $orders_detail_view_list->lRowCnt ?>_item');" onmouseout="ew_HideTooltip();"><?php echo $orders_detail_view->item->ListViewValue() ?></a>
<?php } else { ?>
<?php echo $orders_detail_view->item->ListViewValue() ?>
<?php } ?>
</div><div id="tt_orders_detail_view_x<?php echo $orders_detail_view_list->lRowCnt ?>_item" style="display: none">
<?php if ($orders_detail_view->item->TooltipValue <> "") { ?>
<?php echo $orders_detail_view->item->TooltipValue ?>
<?php } else { ?>
<div<?php echo $orders_detail_view->detail_note->ViewAttributes() ?>><?php echo $orders_detail_view->detail_note->ViewValue ?></div>
<?php } ?>
</div>
</td>
	<?php } ?>
	<?php if ($orders_detail_view->quantity->Visible) { // quantity ?>
		<td<?php echo $orders_detail_view->quantity->CellAttributes() ?>>
<div<?php echo $orders_detail_view->quantity->ViewAttributes() ?>><?php echo $orders_detail_view->quantity->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($orders_detail_view->unit->Visible) { // unit ?>
		<td<?php echo $orders_detail_view->unit->CellAttributes() ?>>
<div<?php echo $orders_detail_view->unit->ViewAttributes() ?>><?php echo $orders_detail_view->unit->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($orders_detail_view->concentration->Visible) { // concentration ?>
		<td<?php echo $orders_detail_view->concentration->CellAttributes() ?>>
<div<?php echo $orders_detail_view->concentration->ViewAttributes() ?>><?php echo $orders_detail_view->concentration->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($orders_detail_view->in_room->Visible) { // in room ?>
		<td<?php echo $orders_detail_view->in_room->CellAttributes() ?>>
<div<?php echo $orders_detail_view->in_room->ViewAttributes() ?>><?php echo $orders_detail_view->in_room->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($orders_detail_view->in_store->Visible) { // in store ?>
		<td<?php echo $orders_detail_view->in_store->CellAttributes() ?>>
<div<?php echo $orders_detail_view->in_store->ViewAttributes() ?>><?php echo $orders_detail_view->in_store->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($orders_detail_view->return_date->Visible) { // return_date ?>
		<td<?php echo $orders_detail_view->return_date->CellAttributes() ?>>
<div<?php echo $orders_detail_view->return_date->ViewAttributes() ?>><?php echo $orders_detail_view->return_date->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($orders_detail_view->order_date->Visible) { // order_date ?>
		<td<?php echo $orders_detail_view->order_date->CellAttributes() ?>>
<div<?php echo $orders_detail_view->order_date->ViewAttributes() ?>><?php echo $orders_detail_view->order_date->ListViewValue() ?></div>
</td>
	<?php } ?>
<?php

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

// Close recordset
if ($rs)
	$rs->Close();
?>
<?php if ($orders_detail_view_list->lTotalRecs > 0) { ?>
<?php if ($orders_detail_view->Export == "") { ?>
<div class="ewGridLowerPanel">
<?php if ($orders_detail_view->CurrentAction <> "gridadd" && $orders_detail_view->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($orders_detail_view_list->Pager)) $orders_detail_view_list->Pager = new cPrevNextPager($orders_detail_view_list->lStartRec, $orders_detail_view_list->lDisplayRecs, $orders_detail_view_list->lTotalRecs) ?>
<?php if ($orders_detail_view_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 ($orders_detail_view_list->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $orders_detail_view_list->PageUrl() ?>start=<?php echo $orders_detail_view_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 ($orders_detail_view_list->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $orders_detail_view_list->PageUrl() ?>start=<?php echo $orders_detail_view_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 $orders_detail_view_list->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($orders_detail_view_list->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $orders_detail_view_list->PageUrl() ?>start=<?php echo $orders_detail_view_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 ($orders_detail_view_list->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $orders_detail_view_list->PageUrl() ?>start=<?php echo $orders_detail_view_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 $orders_detail_view_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 $orders_detail_view_list->Pager->FromIndex ?>&nbsp;<?php echo $Language->Phrase("To") ?>&nbsp;<?php echo $orders_detail_view_list->Pager->ToIndex ?>&nbsp;<?php echo $Language->Phrase("Of") ?>&nbsp;<?php echo $orders_detail_view_list->Pager->RecordCount ?></span>
<?php } else { ?>
	<?php if ($orders_detail_view_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 ($orders_detail_view_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="orders_detail_view">
<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 ($orders_detail_view_list->lDisplayRecs == 10) { ?> selected="selected"<?php } ?>>10</option>
<option value="25"<?php if ($orders_detail_view_list->lDisplayRecs == 25) { ?> selected="selected"<?php } ?>>25</option>
<option value="50"<?php if ($orders_detail_view_list->lDisplayRecs == 50) { ?> selected="selected"<?php } ?>>50</option>
<option value="ALL"<?php if ($orders_detail_view->getRecordsPerPage() == -1) { ?> selected="selected"<?php } ?>><?php echo $Language->Phrase("AllRecords") ?></option>
</select></td></tr></table>
		</td>
<?php } ?>
	</tr>
</table>
</form>
<?php } ?>
<?php //if ($orders_detail_view_list->lTotalRecs > 0) { ?>
<span class="phpmaker">
</span>
<?php //} ?>
</div>
<?php } ?>
<?php } ?>
</td></tr></table>
<?php if ($orders_detail_view->Export == "" && $orders_detail_view->CurrentAction == "") { ?>
<script type="text/javascript">
<!--
ew_ToggleSearchPanel(orders_detail_view_list); // Init search panel as collapsed

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

//
// Page class
//
class corders_detail_view_list {

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

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

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

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

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

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

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

		// Table object (orders_detail_view)
		$GLOBALS["orders_detail_view"] = new corders_detail_view();

		// 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["orders_detail_view"]->AddUrl();
		$this->InlineAddUrl = $this->PageUrl() . "a=add";
		$this->GridAddUrl = $this->PageUrl() . "a=gridadd";
		$this->GridEditUrl = $this->PageUrl() . "a=gridedit";
		$this->MultiDeleteUrl = "orders_detail_viewdelete.php";
		$this->MultiUpdateUrl = "orders_detail_viewupdate.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", 'orders_detail_view', 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 $orders_detail_view;

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

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

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

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

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

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

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

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

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

		// Restore display records
		if ($orders_detail_view->getRecordsPerPage() <> "") {
			$this->lDisplayRecs = $orders_detail_view->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
		$orders_detail_view->Recordset_Searching($this->sSrchWhere);

		// Save search criteria
		if ($this->sSrchWhere <> "") {
			if ($sSrchBasic == "")
				$this->ResetBasicSearchParms();
			$orders_detail_view->setSearchWhere($this->sSrchWhere); // Save to Session
			if (!$this->RestoreSearch) {
				$this->lStartRec = 1; // Reset start record counter
				$orders_detail_view->setStartRecordNumber($this->lStartRec);
			}
		} else {
			$this->sSrchWhere = $orders_detail_view->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
		$orders_detail_view->setSessionWhere($sFilter);
		$orders_detail_view->CurrentFilter = "";

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

	// Set up number of records displayed per page
	function SetUpDisplayRecs() {
		global $orders_detail_view;
		$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
				}
			}
			$orders_detail_view->setRecordsPerPage($this->lDisplayRecs); // Save to Session

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

	// Return basic search SQL
	function BasicSearchSQL($Keyword) {
		global $orders_detail_view;
		$sKeyword = ew_AdjustSql($Keyword);
		$sWhere = "";
		$this->BuildBasicSearchSQL($sWhere, $orders_detail_view->teacher, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $orders_detail_view->room, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $orders_detail_view->order_note, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $orders_detail_view->item, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $orders_detail_view->unit, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $orders_detail_view->concentration, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $orders_detail_view->detail_note, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $orders_detail_view->in_room, $Keyword);
		$this->BuildBasicSearchSQL($sWhere, $orders_detail_view->in_store, $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, $orders_detail_view;
		$sSearchStr = "";
		$sSearchKeyword = $orders_detail_view->BasicSearchKeyword;
		$sSearchType = $orders_detail_view->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 <> "") {
			$orders_detail_view->setSessionBasicSearchKeyword($sSearchKeyword);
			$orders_detail_view->setSessionBasicSearchType($sSearchType);
		}
		return $sSearchStr;
	}

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

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

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

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

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

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

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

		// Check for "order" parameter
		if (@$_GET["order"] <> "") {
			$orders_detail_view->CurrentOrder = ew_StripSlashes(@$_GET["order"]);
			$orders_detail_view->CurrentOrderType = @$_GET["ordertype"];
			$orders_detail_view->UpdateSort($orders_detail_view->id); // id
			$orders_detail_view->UpdateSort($orders_detail_view->teacher); // teacher
			$orders_detail_view->UpdateSort($orders_detail_view->lesson); // lesson
			$orders_detail_view->UpdateSort($orders_detail_view->room); // room
			$orders_detail_view->UpdateSort($orders_detail_view->request_date); // request_date
			$orders_detail_view->UpdateSort($orders_detail_view->item); // item
			$orders_detail_view->UpdateSort($orders_detail_view->quantity); // quantity
			$orders_detail_view->UpdateSort($orders_detail_view->unit); // unit
			$orders_detail_view->UpdateSort($orders_detail_view->concentration); // concentration
			$orders_detail_view->UpdateSort($orders_detail_view->in_room); // in room
			$orders_detail_view->UpdateSort($orders_detail_view->in_store); // in store
			$orders_detail_view->UpdateSort($orders_detail_view->return_date); // return_date
			$orders_detail_view->UpdateSort($orders_detail_view->order_date); // order_date
			$orders_detail_view->setStartRecordNumber(1); // Reset start position
		}
	}

	// Load sort order parameters
	function LoadSortOrder() {
		global $orders_detail_view;
		$sOrderBy = $orders_detail_view->getSessionOrderBy(); // Get ORDER BY from Session
		if ($sOrderBy == "") {
			if ($orders_detail_view->SqlOrderBy() <> "") {
				$sOrderBy = $orders_detail_view->SqlOrderBy();
				$orders_detail_view->setSessionOrderBy($sOrderBy);
				$orders_detail_view->request_date->setSort("DESC");
				$orders_detail_view->lesson->setSort("ASC");
				$orders_detail_view->teacher->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 $orders_detail_view;

		// 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 = "";
				$orders_detail_view->setSessionOrderBy($sOrderBy);
				$orders_detail_view->id->setSort("");
				$orders_detail_view->teacher->setSort("");
				$orders_detail_view->lesson->setSort("");
				$orders_detail_view->room->setSort("");
				$orders_detail_view->request_date->setSort("");
				$orders_detail_view->item->setSort("");
				$orders_detail_view->quantity->setSort("");
				$orders_detail_view->unit->setSort("");
				$orders_detail_view->concentration->setSort("");
				$orders_detail_view->in_room->setSort("");
				$orders_detail_view->in_store->setSort("");
				$orders_detail_view->return_date->setSort("");
				$orders_detail_view->order_date->setSort("");
			}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $orders_detail_view;
		$orders_detail_view->id->setDbValue($rs->fields('id'));
		$orders_detail_view->teacher->setDbValue($rs->fields('teacher'));
		$orders_detail_view->lesson->setDbValue($rs->fields('lesson'));
		$orders_detail_view->room->setDbValue($rs->fields('room'));
		$orders_detail_view->request_date->setDbValue($rs->fields('request_date'));
		$orders_detail_view->order_note->setDbValue($rs->fields('order note'));
		$orders_detail_view->item->setDbValue($rs->fields('item'));
		$orders_detail_view->quantity->setDbValue($rs->fields('quantity'));
		$orders_detail_view->unit->setDbValue($rs->fields('unit'));
		$orders_detail_view->concentration->setDbValue($rs->fields('concentration'));
		$orders_detail_view->detail_note->setDbValue($rs->fields('detail note'));
		$orders_detail_view->in_room->setDbValue($rs->fields('in room'));
		$orders_detail_view->in_store->setDbValue($rs->fields('in store'));
		$orders_detail_view->return_date->setDbValue($rs->fields('return_date'));
		$orders_detail_view->order_date->setDbValue($rs->fields('order_date'));
	}

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

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

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

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

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

		// teacher
		$orders_detail_view->teacher->CellCssStyle = ""; $orders_detail_view->teacher->CellCssClass = "";
		$orders_detail_view->teacher->CellAttrs = array(); $orders_detail_view->teacher->ViewAttrs = array(); $orders_detail_view->teacher->EditAttrs = array();

		// lesson
		$orders_detail_view->lesson->CellCssStyle = ""; $orders_detail_view->lesson->CellCssClass = "";
		$orders_detail_view->lesson->CellAttrs = array(); $orders_detail_view->lesson->ViewAttrs = array(); $orders_detail_view->lesson->EditAttrs = array();

		// room
		$orders_detail_view->room->CellCssStyle = ""; $orders_detail_view->room->CellCssClass = "";
		$orders_detail_view->room->CellAttrs = array(); $orders_detail_view->room->ViewAttrs = array(); $orders_detail_view->room->EditAttrs = array();

		// request_date
		$orders_detail_view->request_date->CellCssStyle = ""; $orders_detail_view->request_date->CellCssClass = "";
		$orders_detail_view->request_date->CellAttrs = array(); $orders_detail_view->request_date->ViewAttrs = array(); $orders_detail_view->request_date->EditAttrs = array();

		// item
		$orders_detail_view->item->CellCssStyle = ""; $orders_detail_view->item->CellCssClass = "";
		$orders_detail_view->item->CellAttrs = array(); $orders_detail_view->item->ViewAttrs = array(); $orders_detail_view->item->EditAttrs = array();

		// quantity
		$orders_detail_view->quantity->CellCssStyle = ""; $orders_detail_view->quantity->CellCssClass = "";
		$orders_detail_view->quantity->CellAttrs = array(); $orders_detail_view->quantity->ViewAttrs = array(); $orders_detail_view->quantity->EditAttrs = array();

		// unit
		$orders_detail_view->unit->CellCssStyle = ""; $orders_detail_view->unit->CellCssClass = "";
		$orders_detail_view->unit->CellAttrs = array(); $orders_detail_view->unit->ViewAttrs = array(); $orders_detail_view->unit->EditAttrs = array();

		// concentration
		$orders_detail_view->concentration->CellCssStyle = ""; $orders_detail_view->concentration->CellCssClass = "";
		$orders_detail_view->concentration->CellAttrs = array(); $orders_detail_view->concentration->ViewAttrs = array(); $orders_detail_view->concentration->EditAttrs = array();

		// in room
		$orders_detail_view->in_room->CellCssStyle = ""; $orders_detail_view->in_room->CellCssClass = "";
		$orders_detail_view->in_room->CellAttrs = array(); $orders_detail_view->in_room->ViewAttrs = array(); $orders_detail_view->in_room->EditAttrs = array();

		// in store
		$orders_detail_view->in_store->CellCssStyle = ""; $orders_detail_view->in_store->CellCssClass = "";
		$orders_detail_view->in_store->CellAttrs = array(); $orders_detail_view->in_store->ViewAttrs = array(); $orders_detail_view->in_store->EditAttrs = array();

		// return_date
		$orders_detail_view->return_date->CellCssStyle = ""; $orders_detail_view->return_date->CellCssClass = "";
		$orders_detail_view->return_date->CellAttrs = array(); $orders_detail_view->return_date->ViewAttrs = array(); $orders_detail_view->return_date->EditAttrs = array();

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

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

			// teacher
			$orders_detail_view->teacher->ViewValue = $orders_detail_view->teacher->CurrentValue;
			$orders_detail_view->teacher->CssStyle = "font-weight:bold;";
			$orders_detail_view->teacher->CssClass = "";
			$orders_detail_view->teacher->ViewCustomAttributes = "";

			// lesson
			$orders_detail_view->lesson->ViewValue = $orders_detail_view->lesson->CurrentValue;
			$orders_detail_view->lesson->CssStyle = "";
			$orders_detail_view->lesson->CssClass = "";
			$orders_detail_view->lesson->ViewCustomAttributes = "";

			// room
			$orders_detail_view->room->ViewValue = $orders_detail_view->room->CurrentValue;
			$orders_detail_view->room->CssStyle = "";
			$orders_detail_view->room->CssClass = "";
			$orders_detail_view->room->ViewCustomAttributes = "";

			// request_date
			$orders_detail_view->request_date->ViewValue = $orders_detail_view->request_date->CurrentValue;
			$orders_detail_view->request_date->ViewValue = ew_FormatDateTime($orders_detail_view->request_date->ViewValue, 5);
			$orders_detail_view->request_date->CssStyle = "";
			$orders_detail_view->request_date->CssClass = "";
			$orders_detail_view->request_date->ViewCustomAttributes = "";

			// item
			$orders_detail_view->item->ViewValue = $orders_detail_view->item->CurrentValue;
			$orders_detail_view->item->CssStyle = "font-weight:bold;";
			$orders_detail_view->item->CssClass = "";
			$orders_detail_view->item->ViewCustomAttributes = "";

			// quantity
			$orders_detail_view->quantity->ViewValue = $orders_detail_view->quantity->CurrentValue;
			$orders_detail_view->quantity->CssStyle = "";
			$orders_detail_view->quantity->CssClass = "";
			$orders_detail_view->quantity->ViewCustomAttributes = "";

			// unit
			$orders_detail_view->unit->ViewValue = $orders_detail_view->unit->CurrentValue;
			$orders_detail_view->unit->CssStyle = "";
			$orders_detail_view->unit->CssClass = "";
			$orders_detail_view->unit->ViewCustomAttributes = "";

			// concentration
			$orders_detail_view->concentration->ViewValue = $orders_detail_view->concentration->CurrentValue;
			$orders_detail_view->concentration->CssStyle = "";
			$orders_detail_view->concentration->CssClass = "";
			$orders_detail_view->concentration->ViewCustomAttributes = "";

			// in room
			$orders_detail_view->in_room->ViewValue = $orders_detail_view->in_room->CurrentValue;
			$orders_detail_view->in_room->CssStyle = "";
			$orders_detail_view->in_room->CssClass = "";
			$orders_detail_view->in_room->ViewCustomAttributes = "";

			// in store
			$orders_detail_view->in_store->ViewValue = $orders_detail_view->in_store->CurrentValue;
			$orders_detail_view->in_store->CssStyle = "";
			$orders_detail_view->in_store->CssClass = "";
			$orders_detail_view->in_store->ViewCustomAttributes = "";

			// return_date
			$orders_detail_view->return_date->ViewValue = $orders_detail_view->return_date->CurrentValue;
			$orders_detail_view->return_date->ViewValue = ew_FormatDateTime($orders_detail_view->return_date->ViewValue, 5);
			$orders_detail_view->return_date->CssStyle = "";
			$orders_detail_view->return_date->CssClass = "";
			$orders_detail_view->return_date->ViewCustomAttributes = "";

			// order_date
			$orders_detail_view->order_date->ViewValue = $orders_detail_view->order_date->CurrentValue;
			$orders_detail_view->order_date->ViewValue = ew_FormatDateTime($orders_detail_view->order_date->ViewValue, 5);
			$orders_detail_view->order_date->CssStyle = "";
			$orders_detail_view->order_date->CssClass = "";
			$orders_detail_view->order_date->ViewCustomAttributes = "";

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

			// teacher
			$orders_detail_view->teacher->HrefValue = "";
			$orders_detail_view->teacher->TooltipValue = $orders_detail_view->order_note->CurrentValue;

			// lesson
			$orders_detail_view->lesson->HrefValue = "";
			$orders_detail_view->lesson->TooltipValue = "";

			// room
			$orders_detail_view->room->HrefValue = "";
			$orders_detail_view->room->TooltipValue = "";

			// request_date
			$orders_detail_view->request_date->HrefValue = "";
			$orders_detail_view->request_date->TooltipValue = "";

			// item
			$orders_detail_view->item->HrefValue = "";
			$orders_detail_view->item->TooltipValue = $orders_detail_view->detail_note->CurrentValue;

			// quantity
			$orders_detail_view->quantity->HrefValue = "";
			$orders_detail_view->quantity->TooltipValue = "";

			// unit
			$orders_detail_view->unit->HrefValue = "";
			$orders_detail_view->unit->TooltipValue = "";

			// concentration
			$orders_detail_view->concentration->HrefValue = "";
			$orders_detail_view->concentration->TooltipValue = "";

			// in room
			$orders_detail_view->in_room->HrefValue = "";
			$orders_detail_view->in_room->TooltipValue = "";

			// in store
			$orders_detail_view->in_store->HrefValue = "";
			$orders_detail_view->in_store->TooltipValue = "";

			// return_date
			$orders_detail_view->return_date->HrefValue = "";
			$orders_detail_view->return_date->TooltipValue = "";

			// order_date
			$orders_detail_view->order_date->HrefValue = "";
			$orders_detail_view->order_date->TooltipValue = "";
		}

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

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

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

		// Export all
		if ($orders_detail_view->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 ($orders_detail_view->Export == "xml") {
			$XmlDoc = new cXMLDocument(EW_XML_ENCODING);
			$XmlDoc->AddRoot();
		} else {
			$ExportDoc = new cExportDocument($orders_detail_view, "h");
			$ExportDoc->ExportHeader();
			if ($ExportDoc->Horizontal) { // Horizontal format, write header
				$ExportDoc->BeginExportRow();
				$ExportDoc->ExportCaption($orders_detail_view->id);
				$ExportDoc->ExportCaption($orders_detail_view->teacher);
				$ExportDoc->ExportCaption($orders_detail_view->lesson);
				$ExportDoc->ExportCaption($orders_detail_view->room);
				$ExportDoc->ExportCaption($orders_detail_view->request_date);
				$ExportDoc->ExportCaption($orders_detail_view->item);
				$ExportDoc->ExportCaption($orders_detail_view->quantity);
				$ExportDoc->ExportCaption($orders_detail_view->unit);
				$ExportDoc->ExportCaption($orders_detail_view->concentration);
				$ExportDoc->ExportCaption($orders_detail_view->in_room);
				$ExportDoc->ExportCaption($orders_detail_view->in_store);
				$ExportDoc->ExportCaption($orders_detail_view->return_date);
				$ExportDoc->ExportCaption($orders_detail_view->order_date);
				$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
				$orders_detail_view->CssClass = "";
				$orders_detail_view->CssStyle = "";
				$orders_detail_view->RowType = EW_ROWTYPE_VIEW; // Render view
				$this->RenderRow();
				if ($orders_detail_view->Export == "xml") {
					$XmlDoc->AddRow();
					$XmlDoc->AddField('id', $orders_detail_view->id->ExportValue($orders_detail_view->Export, $orders_detail_view->ExportOriginalValue));
					$XmlDoc->AddField('teacher', $orders_detail_view->teacher->ExportValue($orders_detail_view->Export, $orders_detail_view->ExportOriginalValue));
					$XmlDoc->AddField('lesson', $orders_detail_view->lesson->ExportValue($orders_detail_view->Export, $orders_detail_view->ExportOriginalValue));
					$XmlDoc->AddField('room', $orders_detail_view->room->ExportValue($orders_detail_view->Export, $orders_detail_view->ExportOriginalValue));
					$XmlDoc->AddField('request_date', $orders_detail_view->request_date->ExportValue($orders_detail_view->Export, $orders_detail_view->ExportOriginalValue));
					$XmlDoc->AddField('item', $orders_detail_view->item->ExportValue($orders_detail_view->Export, $orders_detail_view->ExportOriginalValue));
					$XmlDoc->AddField('quantity', $orders_detail_view->quantity->ExportValue($orders_detail_view->Export, $orders_detail_view->ExportOriginalValue));
					$XmlDoc->AddField('unit', $orders_detail_view->unit->ExportValue($orders_detail_view->Export, $orders_detail_view->ExportOriginalValue));
					$XmlDoc->AddField('concentration', $orders_detail_view->concentration->ExportValue($orders_detail_view->Export, $orders_detail_view->ExportOriginalValue));
					$XmlDoc->AddField('in_room', $orders_detail_view->in_room->ExportValue($orders_detail_view->Export, $orders_detail_view->ExportOriginalValue));
					$XmlDoc->AddField('in_store', $orders_detail_view->in_store->ExportValue($orders_detail_view->Export, $orders_detail_view->ExportOriginalValue));
					$XmlDoc->AddField('return_date', $orders_detail_view->return_date->ExportValue($orders_detail_view->Export, $orders_detail_view->ExportOriginalValue));
					$XmlDoc->AddField('order_date', $orders_detail_view->order_date->ExportValue($orders_detail_view->Export, $orders_detail_view->ExportOriginalValue));
				} else {
					$ExportDoc->BeginExportRow(TRUE); // Allow CSS styles if enabled
					$ExportDoc->ExportField($orders_detail_view->id);
					$ExportDoc->ExportField($orders_detail_view->teacher);
					$ExportDoc->ExportField($orders_detail_view->lesson);
					$ExportDoc->ExportField($orders_detail_view->room);
					$ExportDoc->ExportField($orders_detail_view->request_date);
					$ExportDoc->ExportField($orders_detail_view->item);
					$ExportDoc->ExportField($orders_detail_view->quantity);
					$ExportDoc->ExportField($orders_detail_view->unit);
					$ExportDoc->ExportField($orders_detail_view->concentration);
					$ExportDoc->ExportField($orders_detail_view->in_room);
					$ExportDoc->ExportField($orders_detail_view->in_store);
					$ExportDoc->ExportField($orders_detail_view->return_date);
					$ExportDoc->ExportField($orders_detail_view->order_date);
					$ExportDoc->EndExportRow();
				}
			}
			$rs->MoveNext();
		}
		if ($orders_detail_view->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($orders_detail_view->Export, array("email", "xml")))
			echo "\xEF\xBB\xBF";

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

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

	// Export email
	function ExportEmail($EmailContent) {
		global $Language, $orders_detail_view;
		$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 ($orders_detail_view->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 $orders_detail_view;

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

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

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

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