Location: PHPKode > projects > Science Lab Inventory & Order Management > sciencelabinv/order_detailview.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 "order_detailinfo.php" ?>
<?php include "ordersinfo.php" ?>
<?php include "itemsinfo.php" ?>
<?php include "unitinfo.php" ?>
<?php include "useraccountsinfo.php" ?>
<?php include "userfn7.php" ?>
<?php

// Create page object
$order_detail_view = new corder_detail_view();
$Page =& $order_detail_view;

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

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

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

// page properties
order_detail_view.PageID = "view"; // page ID
order_detail_view.FormID = "forder_detailview"; // form ID
var EW_PAGE_ID = order_detail_view.PageID; // for backward compatibility

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

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

// multi page properties
order_detail_view.MultiPage = new ew_MultiPage();
order_detail_view.MultiPage.AddElement("x_id", 1);
order_detail_view.MultiPage.AddElement("x_order_id", 1);
order_detail_view.MultiPage.AddElement("x_item_id", 1);
order_detail_view.MultiPage.AddElement("x_quantity", 1);
order_detail_view.MultiPage.AddElement("x_unit", 1);
order_detail_view.MultiPage.AddElement("x_concentration", 1);
order_detail_view.MultiPage.AddElement("x_note", 2);

//-->
</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 } ?>
<p><span class="phpmaker"><?php echo $Language->Phrase("View") ?>&nbsp;<?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $order_detail->TableCaption() ?>
<br><br>
<?php if ($order_detail->Export == "") { ?>
<a href="<?php echo $order_detail_view->ListUrl ?>"><?php echo $Language->Phrase("BackToList") ?></a>&nbsp;
<?php if ($Security->CanAdd()) { ?>
<a href="<?php echo $order_detail_view->AddUrl ?>"><?php echo $Language->Phrase("ViewPageAddLink") ?></a>&nbsp;
<?php } ?>
<?php if ($Security->CanEdit()) { ?>
<a href="<?php echo $order_detail_view->EditUrl ?>"><?php echo $Language->Phrase("ViewPageEditLink") ?></a>&nbsp;
<?php } ?>
<?php if ($Security->CanAdd()) { ?>
<a href="<?php echo $order_detail_view->CopyUrl ?>"><?php echo $Language->Phrase("ViewPageCopyLink") ?></a>&nbsp;
<?php } ?>
<?php if ($Security->CanDelete()) { ?>
<a href="<?php echo $order_detail_view->DeleteUrl ?>"><?php echo $Language->Phrase("ViewPageDeleteLink") ?></a>&nbsp;
<?php } ?>
<?php } ?>
</span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$order_detail_view->ShowMessage();
?>
<p>
<?php if ($order_detail->Export == "") { ?>
<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($order_detail_view->Pager)) $order_detail_view->Pager = new cPrevNextPager($order_detail_view->lStartRec, $order_detail_view->lDisplayRecs, $order_detail_view->lTotalRecs) ?>
<?php if ($order_detail_view->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 ($order_detail_view->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $order_detail_view->PageUrl() ?>start=<?php echo $order_detail_view->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 ($order_detail_view->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $order_detail_view->PageUrl() ?>start=<?php echo $order_detail_view->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 $order_detail_view->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($order_detail_view->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $order_detail_view->PageUrl() ?>start=<?php echo $order_detail_view->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 ($order_detail_view->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $order_detail_view->PageUrl() ?>start=<?php echo $order_detail_view->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 $order_detail_view->Pager->PageCount ?></span></td>
	</tr></table>
<?php } else { ?>
	<?php if ($Security->CanList()) { ?>
	<?php if ($order_detail_view->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 } else { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("NoPermission") ?></span>
	<?php } ?>
<?php } ?>
		</td>
	</tr>
</table>
</form>
<br>
<?php } ?>
<?php if ($order_detail->Export == "") { ?>
<table cellspacing="0" cellpadding="0"><tr><td>
<div id="order_detail_view" class="yui-navset">
	<ul class="yui-nav">
		<li class="selected"><a href="#tab_order_detail_1"><em><?php echo $order_detail->PageCaption(1) ?></em></a></li>
		<li><a href="#tab_order_detail_2"><em><?php echo $order_detail->PageCaption(2) ?></em></a></li>
	</ul>            
	<div class="yui-content">
<?php } ?>
		<div id="tab_order_detail_1">
<table cellspacing="0" class="ewGrid" style="width: 100%"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?php if ($order_detail->id->Visible) { // id ?>
	<tr<?php echo $order_detail->id->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $order_detail->id->FldCaption() ?></td>
		<td<?php echo $order_detail->id->CellAttributes() ?>>
<div<?php echo $order_detail->id->ViewAttributes() ?>><?php echo $order_detail->id->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($order_detail->order_id->Visible) { // order_id ?>
	<tr<?php echo $order_detail->order_id->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $order_detail->order_id->FldCaption() ?></td>
		<td<?php echo $order_detail->order_id->CellAttributes() ?>>
<div<?php echo $order_detail->order_id->ViewAttributes() ?>><?php echo $order_detail->order_id->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($order_detail->item_id->Visible) { // item_id ?>
	<tr<?php echo $order_detail->item_id->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $order_detail->item_id->FldCaption() ?></td>
		<td<?php echo $order_detail->item_id->CellAttributes() ?>>
<div<?php echo $order_detail->item_id->ViewAttributes() ?>>
<?php if ($order_detail->item_id->HrefValue <> "" || $order_detail->item_id->TooltipValue <> "" || $order_detail->note->ViewValue <> "") { ?>
<a href="javascript:void(0);" onmouseover="ew_ShowTooltip(this, 'tt_order_detail_x_item_id');" onmouseout="ew_HideTooltip();"><?php echo $order_detail->item_id->ViewValue ?></a>
<?php } else { ?>
<?php echo $order_detail->item_id->ViewValue ?>
<?php } ?>
</div><div id="tt_order_detail_x_item_id" style="display: none">
<?php if ($order_detail->item_id->TooltipValue <> "") { ?>
<?php echo $order_detail->item_id->TooltipValue ?>
<?php } else { ?>
<div<?php echo $order_detail->note->ViewAttributes() ?>><?php echo $order_detail->note->ViewValue ?></div>
<?php } ?>
</div></td>
	</tr>
<?php } ?>
<?php if ($order_detail->quantity->Visible) { // quantity ?>
	<tr<?php echo $order_detail->quantity->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $order_detail->quantity->FldCaption() ?></td>
		<td<?php echo $order_detail->quantity->CellAttributes() ?>>
<div<?php echo $order_detail->quantity->ViewAttributes() ?>><?php echo $order_detail->quantity->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($order_detail->unit->Visible) { // unit ?>
	<tr<?php echo $order_detail->unit->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $order_detail->unit->FldCaption() ?></td>
		<td<?php echo $order_detail->unit->CellAttributes() ?>>
<div<?php echo $order_detail->unit->ViewAttributes() ?>><?php echo $order_detail->unit->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($order_detail->concentration->Visible) { // concentration ?>
	<tr<?php echo $order_detail->concentration->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $order_detail->concentration->FldCaption() ?></td>
		<td<?php echo $order_detail->concentration->CellAttributes() ?>>
<div<?php echo $order_detail->concentration->ViewAttributes() ?>><?php echo $order_detail->concentration->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($order_detail->room_id->Visible) { // room_id ?>
	<tr<?php echo $order_detail->room_id->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $order_detail->room_id->FldCaption() ?></td>
		<td<?php echo $order_detail->room_id->CellAttributes() ?>>
<div<?php echo $order_detail->room_id->ViewAttributes() ?>><?php echo $order_detail->room_id->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($order_detail->store_id->Visible) { // store_id ?>
	<tr<?php echo $order_detail->store_id->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $order_detail->store_id->FldCaption() ?></td>
		<td<?php echo $order_detail->store_id->CellAttributes() ?>>
<div<?php echo $order_detail->store_id->ViewAttributes() ?>><?php echo $order_detail->store_id->ViewValue ?></div></td>
	</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
		</div>
		<div id="tab_order_detail_2">
<table cellspacing="0" class="ewGrid" style="width: 100%"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?php if ($order_detail->note->Visible) { // note ?>
	<tr<?php echo $order_detail->note->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $order_detail->note->FldCaption() ?></td>
		<td<?php echo $order_detail->note->CellAttributes() ?>>
<div<?php echo $order_detail->note->ViewAttributes() ?>><?php echo $order_detail->note->ViewValue ?></div></td>
	</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
		</div>
<?php if ($order_detail->Export == "") { ?>
	</div>
</div>
</td></tr></table>
<?php } ?>
<?php if ($order_detail->Export == "") { ?>
<script type="text/javascript">
<!--
ew_TabView(order_detail_view);

//-->
</script>
<?php } ?>
<?php if ($order_detail->Export == "") { ?>
<br>
<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($order_detail_view->Pager)) $order_detail_view->Pager = new cPrevNextPager($order_detail_view->lStartRec, $order_detail_view->lDisplayRecs, $order_detail_view->lTotalRecs) ?>
<?php if ($order_detail_view->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 ($order_detail_view->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $order_detail_view->PageUrl() ?>start=<?php echo $order_detail_view->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 ($order_detail_view->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $order_detail_view->PageUrl() ?>start=<?php echo $order_detail_view->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 $order_detail_view->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($order_detail_view->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $order_detail_view->PageUrl() ?>start=<?php echo $order_detail_view->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 ($order_detail_view->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $order_detail_view->PageUrl() ?>start=<?php echo $order_detail_view->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 $order_detail_view->Pager->PageCount ?></span></td>
	</tr></table>
<?php } else { ?>
	<?php if ($Security->CanList()) { ?>
	<?php if ($order_detail_view->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 } else { ?>
	<span class="phpmaker"><?php echo $Language->Phrase("NoPermission") ?></span>
	<?php } ?>
<?php } ?>
		</td>
	</tr>
</table>
</form>
<?php } ?>
<p>
<?php if ($order_detail->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
$order_detail_view->Page_Terminate();
?>
<?php

//
// Page class
//
class corder_detail_view {

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

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

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

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

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

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

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

		// Table object (order_detail)
		$GLOBALS["order_detail"] = new corder_detail();

		// Table object (orders)
		$GLOBALS['orders'] = new corders();

		// Table object (items)
		$GLOBALS['items'] = new citems();

		// Table object (unit)
		$GLOBALS['unit'] = new cunit();

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

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

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

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

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

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

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		$Security->TablePermission_Loading();
		$Security->LoadCurrentUserLevel($this->TableName);
		$Security->TablePermission_Loaded();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		if (!$Security->CanView()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("order_detaillist.php");
		}
		$Security->UserID_Loading();
		if ($Security->IsLoggedIn()) $Security->LoadUserID();
		$Security->UserID_Loaded();

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

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

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

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

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

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

		// Go to URL if specified
		$this->Page_Redirecting($url);
		if ($url <> "") {
			if (!EW_DEBUG_ENABLED && ob_get_length())
				ob_end_clean();
			header("Location: " . $url);
		}
		exit();
	}
	var $lDisplayRecs = 1;
	var $lStartRec;
	var $lStopRec;
	var $lTotalRecs = 0;
	var $lRecRange = 10;
	var $lRecCnt;
	var $arRecKey = array();

	//
	// Page main
	//
	function Page_Main() {
		global $Language, $order_detail;

		// Load current record
		$bLoadCurrentRecord = FALSE;
		$sReturnUrl = "";
		$bMatchRecord = FALSE;
		if ($this->IsPageRequest()) { // Validate request
			if (@$_GET["id"] <> "") {
				$order_detail->id->setQueryStringValue($_GET["id"]);
				$this->arRecKey["id"] = $order_detail->id->QueryStringValue;
			} else {
				$bLoadCurrentRecord = TRUE;
			}

			// Get action
			$order_detail->CurrentAction = "I"; // Display form
			switch ($order_detail->CurrentAction) {
				case "I": // Get a record to display
					$this->lStartRec = 1; // Initialize start position
					if ($rs = $this->LoadRecordset()) // Load records
						$this->lTotalRecs = $rs->RecordCount(); // Get record count
					if ($this->lTotalRecs <= 0) { // No record found
						$this->setMessage($Language->Phrase("NoRecord")); // Set no record message
						$this->Page_Terminate("order_detaillist.php"); // Return to list page
					} elseif ($bLoadCurrentRecord) { // Load current record position
						$this->SetUpStartRec(); // Set up start record position

						// Point to current record
						if (intval($this->lStartRec) <= intval($this->lTotalRecs)) {
							$bMatchRecord = TRUE;
							$rs->Move($this->lStartRec-1);
						}
					} else { // Match key values
						while (!$rs->EOF) {
							if (strval($order_detail->id->CurrentValue) == strval($rs->fields('id'))) {
								$order_detail->setStartRecordNumber($this->lStartRec); // Save record position
								$bMatchRecord = TRUE;
								break;
							} else {
								$this->lStartRec++;
								$rs->MoveNext();
							}
						}
					}
					if (!$bMatchRecord) {
						$this->setMessage($Language->Phrase("NoRecord")); // Set no record message
						$sReturnUrl = "order_detaillist.php"; // No matching record, return to list
					} else {
						$this->LoadRowValues($rs); // Load row values
					}
			}
		} else {
			$sReturnUrl = "order_detaillist.php"; // Not page request, return to list
		}
		if ($sReturnUrl <> "")
			$this->Page_Terminate($sReturnUrl);

		// Render row
		$order_detail->RowType = EW_ROWTYPE_VIEW;
		$this->RenderRow();
	}

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

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

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

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

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

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

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

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

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

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

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $order_detail;
		$order_detail->id->setDbValue($rs->fields('id'));
		$order_detail->order_id->setDbValue($rs->fields('order_id'));
		$order_detail->item_id->setDbValue($rs->fields('item_id'));
		$order_detail->quantity->setDbValue($rs->fields('quantity'));
		$order_detail->unit->setDbValue($rs->fields('unit'));
		$order_detail->concentration->setDbValue($rs->fields('concentration'));
		$order_detail->note->setDbValue($rs->fields('note'));
		$order_detail->room_id->setDbValue($rs->fields('room_id'));
		$order_detail->store_id->setDbValue($rs->fields('store_id'));
	}

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

		// Initialize URLs
		$this->ExportPrintUrl = $this->PageUrl() . "export=print&" . "id=" . urlencode($order_detail->id->CurrentValue);
		$this->ExportHtmlUrl = $this->PageUrl() . "export=html&" . "id=" . urlencode($order_detail->id->CurrentValue);
		$this->ExportExcelUrl = $this->PageUrl() . "export=excel&" . "id=" . urlencode($order_detail->id->CurrentValue);
		$this->ExportWordUrl = $this->PageUrl() . "export=word&" . "id=" . urlencode($order_detail->id->CurrentValue);
		$this->ExportXmlUrl = $this->PageUrl() . "export=xml&" . "id=" . urlencode($order_detail->id->CurrentValue);
		$this->ExportCsvUrl = $this->PageUrl() . "export=csv&" . "id=" . urlencode($order_detail->id->CurrentValue);
		$this->AddUrl = $order_detail->AddUrl();
		$this->EditUrl = $order_detail->EditUrl();
		$this->CopyUrl = $order_detail->CopyUrl();
		$this->DeleteUrl = $order_detail->DeleteUrl();
		$this->ListUrl = $order_detail->ListUrl();

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

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

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

		// order_id
		$order_detail->order_id->CellCssStyle = ""; $order_detail->order_id->CellCssClass = "";
		$order_detail->order_id->CellAttrs = array(); $order_detail->order_id->ViewAttrs = array(); $order_detail->order_id->EditAttrs = array();

		// item_id
		$order_detail->item_id->CellCssStyle = ""; $order_detail->item_id->CellCssClass = "";
		$order_detail->item_id->CellAttrs = array(); $order_detail->item_id->ViewAttrs = array(); $order_detail->item_id->EditAttrs = array();

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

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

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

		// note
		$order_detail->note->CellCssStyle = ""; $order_detail->note->CellCssClass = "";
		$order_detail->note->CellAttrs = array(); $order_detail->note->ViewAttrs = array(); $order_detail->note->EditAttrs = array();

		// room_id
		$order_detail->room_id->CellCssStyle = ""; $order_detail->room_id->CellCssClass = "";
		$order_detail->room_id->CellAttrs = array(); $order_detail->room_id->ViewAttrs = array(); $order_detail->room_id->EditAttrs = array();

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

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

			// order_id
			if (strval($order_detail->order_id->CurrentValue) <> "") {
				$sFilterWrk = "`id` = " . ew_AdjustSql($order_detail->order_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `teacher`, `lesson` FROM `orders`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `request_date` Desc";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$order_detail->order_id->ViewValue = $rswrk->fields('teacher');
					$order_detail->order_id->ViewValue .= ew_ValueSeparator(0) . $rswrk->fields('lesson');
					$rswrk->Close();
				} else {
					$order_detail->order_id->ViewValue = $order_detail->order_id->CurrentValue;
				}
			} else {
				$order_detail->order_id->ViewValue = NULL;
			}
			$order_detail->order_id->CssStyle = "font-weight:bold;";
			$order_detail->order_id->CssClass = "";
			$order_detail->order_id->ViewCustomAttributes = "";

			// item_id
			if (strval($order_detail->item_id->CurrentValue) <> "") {
				$sFilterWrk = "`id` = " . ew_AdjustSql($order_detail->item_id->CurrentValue) . "";
			$sSqlWrk = "SELECT DISTINCT `name` FROM `items`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `name` Asc";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$order_detail->item_id->ViewValue = $rswrk->fields('name');
					$rswrk->Close();
				} else {
					$order_detail->item_id->ViewValue = $order_detail->item_id->CurrentValue;
				}
			} else {
				$order_detail->item_id->ViewValue = NULL;
			}
			$order_detail->item_id->CssStyle = "";
			$order_detail->item_id->CssClass = "";
			$order_detail->item_id->ViewCustomAttributes = "";

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

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

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

			// note
			$order_detail->note->ViewValue = $order_detail->note->CurrentValue;
			$order_detail->note->CssStyle = "";
			$order_detail->note->CssClass = "";
			$order_detail->note->ViewCustomAttributes = "";

			// room_id
			$order_detail->room_id->ViewValue = $order_detail->room_id->CurrentValue;
			$order_detail->room_id->CssStyle = "font-weight:bold;font-style:italic;";
			$order_detail->room_id->CssClass = "";
			$order_detail->room_id->ViewCustomAttributes = "";

			// store_id
			$order_detail->store_id->ViewValue = $order_detail->store_id->CurrentValue;
			$order_detail->store_id->CssStyle = "font-weight:bold;font-style:italic;";
			$order_detail->store_id->CssClass = "";
			$order_detail->store_id->ViewCustomAttributes = "";

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

			// order_id
			$order_detail->order_id->HrefValue = "";
			$order_detail->order_id->TooltipValue = "";

			// item_id
			$order_detail->item_id->HrefValue = "";
			$order_detail->item_id->TooltipValue = $order_detail->note->CurrentValue;

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

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

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

			// note
			$order_detail->note->HrefValue = "";
			$order_detail->note->TooltipValue = "";

			// room_id
			$order_detail->room_id->HrefValue = "";
			$order_detail->room_id->TooltipValue = "";

			// store_id
			$order_detail->store_id->HrefValue = "";
			$order_detail->store_id->TooltipValue = "";
		}

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

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

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