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

// Create page object
$items_view = new citems_view();
$Page =& $items_view;

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

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

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

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

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

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

//-->
</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 $items->TableCaption() ?>
<br><br>
<?php if ($items->Export == "") { ?>
<a href="<?php echo $items_view->ListUrl ?>"><?php echo $Language->Phrase("BackToList") ?></a>&nbsp;
<?php if ($Security->CanAdd()) { ?>
<a href="<?php echo $items_view->AddUrl ?>"><?php echo $Language->Phrase("ViewPageAddLink") ?></a>&nbsp;
<?php } ?>
<?php if ($Security->CanEdit()) { ?>
<a href="<?php echo $items_view->EditUrl ?>"><?php echo $Language->Phrase("ViewPageEditLink") ?></a>&nbsp;
<?php } ?>
<?php if ($Security->CanAdd()) { ?>
<a href="<?php echo $items_view->CopyUrl ?>"><?php echo $Language->Phrase("ViewPageCopyLink") ?></a>&nbsp;
<?php } ?>
<?php if ($Security->CanDelete()) { ?>
<a href="<?php echo $items_view->DeleteUrl ?>"><?php echo $Language->Phrase("ViewPageDeleteLink") ?></a>&nbsp;
<?php } ?>
<?php if ($Security->AllowList('order_detail')) { ?>
<a href="order_detaillist.php?<?php echo EW_TABLE_SHOW_MASTER ?>=items&id=<?php echo urlencode(strval($items->id->CurrentValue)) ?>"><?php echo $Language->Phrase("ViewPageDetailLink") ?><?php echo $Language->TablePhrase("order_detail", "TblCaption") ?>
</a>
&nbsp;
<?php } ?>
<?php } ?>
</span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$items_view->ShowMessage();
?>
<p>
<?php if ($items->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($items_view->Pager)) $items_view->Pager = new cPrevNextPager($items_view->lStartRec, $items_view->lDisplayRecs, $items_view->lTotalRecs) ?>
<?php if ($items_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 ($items_view->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $items_view->PageUrl() ?>start=<?php echo $items_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 ($items_view->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $items_view->PageUrl() ?>start=<?php echo $items_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 $items_view->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($items_view->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $items_view->PageUrl() ?>start=<?php echo $items_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 ($items_view->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $items_view->PageUrl() ?>start=<?php echo $items_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 $items_view->Pager->PageCount ?></span></td>
	</tr></table>
<?php } else { ?>
	<?php if ($items_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 } ?>
		</td>
	</tr>
</table>
</form>
<br>
<?php } ?>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?php if ($items->id->Visible) { // id ?>
	<tr<?php echo $items->id->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $items->id->FldCaption() ?></td>
		<td<?php echo $items->id->CellAttributes() ?>>
<div<?php echo $items->id->ViewAttributes() ?>>
<?php if ($items->id->HrefValue <> "" || $items->id->TooltipValue <> "" || $items->comments->ViewValue <> "") { ?>
<a href="javascript:void(0);" onmouseover="ew_ShowTooltip(this, 'tt_items_x_id');" onmouseout="ew_HideTooltip();"><?php echo $items->id->ViewValue ?></a>
<?php } else { ?>
<?php echo $items->id->ViewValue ?>
<?php } ?>
</div><div id="tt_items_x_id" style="display: none">
<?php if ($items->id->TooltipValue <> "") { ?>
<?php echo $items->id->TooltipValue ?>
<?php } else { ?>
<div<?php echo $items->comments->ViewAttributes() ?>><?php echo $items->comments->ViewValue ?></div>
<?php } ?>
</div></td>
	</tr>
<?php } ?>
<?php if ($items->name->Visible) { // name ?>
	<tr<?php echo $items->name->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $items->name->FldCaption() ?></td>
		<td<?php echo $items->name->CellAttributes() ?>>
<div<?php echo $items->name->ViewAttributes() ?>>
<?php if ($items->name->HrefValue <> "" || $items->name->TooltipValue <> "" || !is_null($items->image->Upload->DbValue)) { ?>
<a href="javascript:void(0);" onmouseover="ew_ShowTooltip(this, 'tt_items_x_name');" onmouseout="ew_HideTooltip();"><?php echo $items->name->ViewValue ?></a>
<?php } else { ?>
<?php echo $items->name->ViewValue ?>
<?php } ?>
</div><div id="tt_items_x_name" style="display: none">
<?php if ($items->name->TooltipValue <> "") { ?>
<?php echo $items->name->TooltipValue ?>
<?php } else { ?>
<img src="<?php echo ew_UploadPathEx(FALSE, $items->image->UploadPath) . $items->image->Upload->DbValue ?>" border=0<?php echo $items->image->ViewAttributes() ?>>
<?php } ?>
</div></td>
	</tr>
<?php } ?>
<?php if ($items->type_id->Visible) { // type_id ?>
	<tr<?php echo $items->type_id->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $items->type_id->FldCaption() ?></td>
		<td<?php echo $items->type_id->CellAttributes() ?>>
<div<?php echo $items->type_id->ViewAttributes() ?>><?php echo $items->type_id->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($items->room_id->Visible) { // room_id ?>
	<tr<?php echo $items->room_id->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $items->room_id->FldCaption() ?></td>
		<td<?php echo $items->room_id->CellAttributes() ?>>
<div<?php echo $items->room_id->ViewAttributes() ?>><?php echo $items->room_id->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($items->store_id->Visible) { // store_id ?>
	<tr<?php echo $items->store_id->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $items->store_id->FldCaption() ?></td>
		<td<?php echo $items->store_id->CellAttributes() ?>>
<div<?php echo $items->store_id->ViewAttributes() ?>><?php echo $items->store_id->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($items->unit->Visible) { // unit ?>
	<tr<?php echo $items->unit->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $items->unit->FldCaption() ?></td>
		<td<?php echo $items->unit->CellAttributes() ?>>
<div<?php echo $items->unit->ViewAttributes() ?>><?php echo $items->unit->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($items->quantity->Visible) { // quantity ?>
	<tr<?php echo $items->quantity->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $items->quantity->FldCaption() ?></td>
		<td<?php echo $items->quantity->CellAttributes() ?>>
<div<?php echo $items->quantity->ViewAttributes() ?>><?php echo $items->quantity->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($items->consumption->Visible) { // consumption ?>
	<tr<?php echo $items->consumption->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $items->consumption->FldCaption() ?></td>
		<td<?php echo $items->consumption->CellAttributes() ?>>
<div<?php echo $items->consumption->ViewAttributes() ?>><?php echo $items->consumption->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($items->vendor->Visible) { // vendor ?>
	<tr<?php echo $items->vendor->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $items->vendor->FldCaption() ?></td>
		<td<?php echo $items->vendor->CellAttributes() ?>>
<div<?php echo $items->vendor->ViewAttributes() ?>><?php echo $items->vendor->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($items->catno->Visible) { // catno ?>
	<tr<?php echo $items->catno->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $items->catno->FldCaption() ?></td>
		<td<?php echo $items->catno->CellAttributes() ?>>
<div<?php echo $items->catno->ViewAttributes() ?>><?php echo $items->catno->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($items->arrived->Visible) { // arrived ?>
	<tr<?php echo $items->arrived->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $items->arrived->FldCaption() ?></td>
		<td<?php echo $items->arrived->CellAttributes() ?>>
<div<?php echo $items->arrived->ViewAttributes() ?>><?php echo $items->arrived->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($items->expires->Visible) { // expires ?>
	<tr<?php echo $items->expires->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $items->expires->FldCaption() ?></td>
		<td<?php echo $items->expires->CellAttributes() ?>>
<div<?php echo $items->expires->ViewAttributes() ?>><?php echo $items->expires->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($items->image->Visible) { // image ?>
	<tr<?php echo $items->image->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $items->image->FldCaption() ?></td>
		<td<?php echo $items->image->CellAttributes() ?>>
<?php if ($items->image->HrefValue <> "" || $items->image->TooltipValue <> "") { ?>
<?php if (!empty($items->image->Upload->DbValue)) { ?>
<img src="<?php echo ew_UploadPathEx(FALSE, $items->image->UploadPath) . $items->image->Upload->DbValue ?>" border=0<?php echo $items->image->ViewAttributes() ?>>
<?php } elseif (!in_array($items->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } else { ?>
<?php if (!empty($items->image->Upload->DbValue)) { ?>
<img src="<?php echo ew_UploadPathEx(FALSE, $items->image->UploadPath) . $items->image->Upload->DbValue ?>" border=0<?php echo $items->image->ViewAttributes() ?>>
<?php } elseif (!in_array($items->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } ?>
</td>
	</tr>
<?php } ?>
<?php if ($items->comments->Visible) { // comments ?>
	<tr<?php echo $items->comments->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $items->comments->FldCaption() ?></td>
		<td<?php echo $items->comments->CellAttributes() ?>>
<div<?php echo $items->comments->ViewAttributes() ?>><?php echo $items->comments->ViewValue ?></div></td>
	</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<?php if ($items->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($items_view->Pager)) $items_view->Pager = new cPrevNextPager($items_view->lStartRec, $items_view->lDisplayRecs, $items_view->lTotalRecs) ?>
<?php if ($items_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 ($items_view->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $items_view->PageUrl() ?>start=<?php echo $items_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 ($items_view->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $items_view->PageUrl() ?>start=<?php echo $items_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 $items_view->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($items_view->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $items_view->PageUrl() ?>start=<?php echo $items_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 ($items_view->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $items_view->PageUrl() ?>start=<?php echo $items_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 $items_view->Pager->PageCount ?></span></td>
	</tr></table>
<?php } else { ?>
	<?php if ($items_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 } ?>
		</td>
	</tr>
</table>
</form>
<?php } ?>
<p>
<?php if ($items->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
$items_view->Page_Terminate();
?>
<?php

//
// Page class
//
class citems_view {

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

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

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

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

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

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

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

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

		// Table object (stores)
		$GLOBALS['stores'] = new cstores();

		// Table object (types)
		$GLOBALS['types'] = new ctypes();

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

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

		// 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, $items;

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

			// Get action
			$items->CurrentAction = "I"; // Display form
			switch ($items->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("itemslist.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($items->id->CurrentValue) == strval($rs->fields('id'))) {
								$items->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 = "itemslist.php"; // No matching record, return to list
					} else {
						$this->LoadRowValues($rs); // Load row values
					}
			}
		} else {
			$sReturnUrl = "itemslist.php"; // Not page request, return to list
		}
		if ($sReturnUrl <> "")
			$this->Page_Terminate($sReturnUrl);

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

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

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

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

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

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

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

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

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

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

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

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $items;
		$items->id->setDbValue($rs->fields('id'));
		$items->name->setDbValue($rs->fields('name'));
		$items->type_id->setDbValue($rs->fields('type_id'));
		$items->room_id->setDbValue($rs->fields('room_id'));
		$items->store_id->setDbValue($rs->fields('store_id'));
		$items->unit->setDbValue($rs->fields('unit'));
		$items->quantity->setDbValue($rs->fields('quantity'));
		$items->consumption->setDbValue($rs->fields('consumption'));
		$items->vendor->setDbValue($rs->fields('vendor'));
		$items->catno->setDbValue($rs->fields('catno'));
		$items->arrived->setDbValue($rs->fields('arrived'));
		$items->expires->setDbValue($rs->fields('expires'));
		$items->image->Upload->DbValue = $rs->fields('image');
		$items->comments->setDbValue($rs->fields('comments'));
	}

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

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

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

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

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

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

		// type_id
		$items->type_id->CellCssStyle = ""; $items->type_id->CellCssClass = "";
		$items->type_id->CellAttrs = array(); $items->type_id->ViewAttrs = array(); $items->type_id->EditAttrs = array();

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

		// store_id
		$items->store_id->CellCssStyle = ""; $items->store_id->CellCssClass = "";
		$items->store_id->CellAttrs = array(); $items->store_id->ViewAttrs = array(); $items->store_id->EditAttrs = array();

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

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

		// consumption
		$items->consumption->CellCssStyle = ""; $items->consumption->CellCssClass = "";
		$items->consumption->CellAttrs = array(); $items->consumption->ViewAttrs = array(); $items->consumption->EditAttrs = array();

		// vendor
		$items->vendor->CellCssStyle = ""; $items->vendor->CellCssClass = "";
		$items->vendor->CellAttrs = array(); $items->vendor->ViewAttrs = array(); $items->vendor->EditAttrs = array();

		// catno
		$items->catno->CellCssStyle = ""; $items->catno->CellCssClass = "";
		$items->catno->CellAttrs = array(); $items->catno->ViewAttrs = array(); $items->catno->EditAttrs = array();

		// arrived
		$items->arrived->CellCssStyle = ""; $items->arrived->CellCssClass = "";
		$items->arrived->CellAttrs = array(); $items->arrived->ViewAttrs = array(); $items->arrived->EditAttrs = array();

		// expires
		$items->expires->CellCssStyle = ""; $items->expires->CellCssClass = "";
		$items->expires->CellAttrs = array(); $items->expires->ViewAttrs = array(); $items->expires->EditAttrs = array();

		// image
		$items->image->CellCssStyle = ""; $items->image->CellCssClass = "";
		$items->image->CellAttrs = array(); $items->image->ViewAttrs = array(); $items->image->EditAttrs = array();

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

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

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

			// type_id
			if (strval($items->type_id->CurrentValue) <> "") {
				$sFilterWrk = "`id` = " . ew_AdjustSql($items->type_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `name` FROM `types`";
			$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
					$items->type_id->ViewValue = $rswrk->fields('name');
					$rswrk->Close();
				} else {
					$items->type_id->ViewValue = $items->type_id->CurrentValue;
				}
			} else {
				$items->type_id->ViewValue = NULL;
			}
			$items->type_id->CssStyle = "";
			$items->type_id->CssClass = "";
			$items->type_id->ViewCustomAttributes = "";

			// room_id
			if (strval($items->room_id->CurrentValue) <> "") {
				$sFilterWrk = "`id` = '" . ew_AdjustSql($items->room_id->CurrentValue) . "'";
			$sSqlWrk = "SELECT `name` FROM `rooms`";
			$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
					$items->room_id->ViewValue = $rswrk->fields('name');
					$rswrk->Close();
				} else {
					$items->room_id->ViewValue = $items->room_id->CurrentValue;
				}
			} else {
				$items->room_id->ViewValue = NULL;
			}
			$items->room_id->CssStyle = "";
			$items->room_id->CssClass = "";
			$items->room_id->ViewCustomAttributes = "";

			// store_id
			if (strval($items->store_id->CurrentValue) <> "") {
				$sFilterWrk = "`id` = '" . ew_AdjustSql($items->store_id->CurrentValue) . "'";
			$sSqlWrk = "SELECT `name` FROM `stores`";
			$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
					$items->store_id->ViewValue = $rswrk->fields('name');
					$rswrk->Close();
				} else {
					$items->store_id->ViewValue = $items->store_id->CurrentValue;
				}
			} else {
				$items->store_id->ViewValue = NULL;
			}
			$items->store_id->CssStyle = "";
			$items->store_id->CssClass = "";
			$items->store_id->ViewCustomAttributes = "";

			// unit
			if (strval($items->unit->CurrentValue) <> "") {
				$sFilterWrk = "`unit` = '" . ew_AdjustSql($items->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
					$items->unit->ViewValue = $rswrk->fields('unit');
					$rswrk->Close();
				} else {
					$items->unit->ViewValue = $items->unit->CurrentValue;
				}
			} else {
				$items->unit->ViewValue = NULL;
			}
			$items->unit->CssStyle = "";
			$items->unit->CssClass = "";
			$items->unit->ViewCustomAttributes = "";

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

			// consumption
			$items->consumption->ViewValue = $items->consumption->CurrentValue;
			$items->consumption->CssStyle = "";
			$items->consumption->CssClass = "";
			$items->consumption->ViewCustomAttributes = "";

			// vendor
			$items->vendor->ViewValue = $items->vendor->CurrentValue;
			$items->vendor->CssStyle = "";
			$items->vendor->CssClass = "";
			$items->vendor->ViewCustomAttributes = "";

			// catno
			$items->catno->ViewValue = $items->catno->CurrentValue;
			$items->catno->CssStyle = "";
			$items->catno->CssClass = "";
			$items->catno->ViewCustomAttributes = "";

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

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

			// image
			if (!ew_Empty($items->image->Upload->DbValue)) {
				$items->image->ViewValue = $items->image->Upload->DbValue;
				$items->image->ImageAlt = $items->image->FldAlt();
			} else {
				$items->image->ViewValue = "";
			}
			$items->image->CssStyle = "";
			$items->image->CssClass = "";
			$items->image->ViewCustomAttributes = "";

			// comments
			$items->comments->ViewValue = $items->comments->CurrentValue;
			$items->comments->CssStyle = "";
			$items->comments->CssClass = "";
			$items->comments->ViewCustomAttributes = "";

			// id
			$items->id->HrefValue = "";
			$items->id->TooltipValue = $items->comments->CurrentValue;

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

			// type_id
			$items->type_id->HrefValue = "";
			$items->type_id->TooltipValue = "";

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

			// store_id
			$items->store_id->HrefValue = "";
			$items->store_id->TooltipValue = "";

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

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

			// consumption
			$items->consumption->HrefValue = "";
			$items->consumption->TooltipValue = "";

			// vendor
			$items->vendor->HrefValue = "";
			$items->vendor->TooltipValue = "";

			// catno
			$items->catno->HrefValue = "";
			$items->catno->TooltipValue = "";

			// arrived
			$items->arrived->HrefValue = "";
			$items->arrived->TooltipValue = "";

			// expires
			$items->expires->HrefValue = "";
			$items->expires->TooltipValue = "";

			// image
			$items->image->HrefValue = "";
			$items->image->TooltipValue = "";

			// comments
			$items->comments->HrefValue = "";
			$items->comments->TooltipValue = "";
		}

		// Call Row Rendered event
		if ($items->RowType <> EW_ROWTYPE_AGGREGATEINIT)
			$items->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