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

// Create page object
$useraccounts_view = new cuseraccounts_view();
$Page =& $useraccounts_view;

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

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

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

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

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

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
useraccounts_view.SelectAllKey = function(elem) {
	ew_SelectAll(elem);
	ew_ClickAll(elem);
}
<?php if (EW_CLIENT_VALIDATE) { ?>
useraccounts_view.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
useraccounts_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 $useraccounts->TableCaption() ?>
<br><br>
<?php if ($useraccounts->Export == "") { ?>
<a href="<?php echo $useraccounts_view->ListUrl ?>"><?php echo $Language->Phrase("BackToList") ?></a>&nbsp;
<?php if ($Security->CanAdd()) { ?>
<?php if ($useraccounts_view->ShowOptionLink()) { ?>
<a href="<?php echo $useraccounts_view->AddUrl ?>"><?php echo $Language->Phrase("ViewPageAddLink") ?></a>&nbsp;
<?php } ?>
<?php } ?>
<?php if ($Security->CanEdit()) { ?>
<?php if ($useraccounts_view->ShowOptionLink()) { ?>
<a href="<?php echo $useraccounts_view->EditUrl ?>"><?php echo $Language->Phrase("ViewPageEditLink") ?></a>&nbsp;
<?php } ?>
<?php } ?>
<?php if ($Security->CanAdd()) { ?>
<?php if ($useraccounts_view->ShowOptionLink()) { ?>
<a href="<?php echo $useraccounts_view->CopyUrl ?>"><?php echo $Language->Phrase("ViewPageCopyLink") ?></a>&nbsp;
<?php } ?>
<?php } ?>
<?php if ($Security->CanDelete()) { ?>
<?php if ($useraccounts_view->ShowOptionLink()) { ?>
<a href="<?php echo $useraccounts_view->DeleteUrl ?>"><?php echo $Language->Phrase("ViewPageDeleteLink") ?></a>&nbsp;
<?php } ?>
<?php } ?>
<?php if ($Security->AllowList('orders')) { ?>
<?php if ($useraccounts_view->ShowOptionLink()) { ?>
<a href="orderslist.php?<?php echo EW_TABLE_SHOW_MASTER ?>=useraccounts&username=<?php echo urlencode(strval($useraccounts->username->CurrentValue)) ?>"><?php echo $Language->Phrase("ViewPageDetailLink") ?><?php echo $Language->TablePhrase("orders", "TblCaption") ?>
</a>
&nbsp;
<?php } ?>
<?php } ?>
<a href="orders_date_teacherreport.php?<?php echo EW_TABLE_SHOW_MASTER ?>=useraccounts&username=<?php echo urlencode(strval($useraccounts->username->CurrentValue)) ?>"><?php echo $Language->Phrase("ViewPageDetailLink") ?><?php echo $Language->TablePhrase("orders_date_teacher", "TblCaption") ?>
</a>
&nbsp;
<?php } ?>
</span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$useraccounts_view->ShowMessage();
?>
<p>
<?php if ($useraccounts->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($useraccounts_view->Pager)) $useraccounts_view->Pager = new cPrevNextPager($useraccounts_view->lStartRec, $useraccounts_view->lDisplayRecs, $useraccounts_view->lTotalRecs) ?>
<?php if ($useraccounts_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 ($useraccounts_view->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $useraccounts_view->PageUrl() ?>start=<?php echo $useraccounts_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 ($useraccounts_view->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $useraccounts_view->PageUrl() ?>start=<?php echo $useraccounts_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 $useraccounts_view->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($useraccounts_view->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $useraccounts_view->PageUrl() ?>start=<?php echo $useraccounts_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 ($useraccounts_view->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $useraccounts_view->PageUrl() ?>start=<?php echo $useraccounts_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 $useraccounts_view->Pager->PageCount ?></span></td>
	</tr></table>
<?php } else { ?>
	<?php if ($Security->CanList()) { ?>
	<?php if ($useraccounts_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 } ?>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?php if ($useraccounts->username->Visible) { // username ?>
	<tr<?php echo $useraccounts->username->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $useraccounts->username->FldCaption() ?></td>
		<td<?php echo $useraccounts->username->CellAttributes() ?>>
<div<?php echo $useraccounts->username->ViewAttributes() ?>><?php echo $useraccounts->username->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($useraccounts->password->Visible) { // password ?>
	<tr<?php echo $useraccounts->password->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $useraccounts->password->FldCaption() ?></td>
		<td<?php echo $useraccounts->password->CellAttributes() ?>>
<div<?php echo $useraccounts->password->ViewAttributes() ?>><?php echo $useraccounts->password->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($useraccounts->userlevel->Visible) { // userlevel ?>
	<tr<?php echo $useraccounts->userlevel->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $useraccounts->userlevel->FldCaption() ?></td>
		<td<?php echo $useraccounts->userlevel->CellAttributes() ?>>
<div<?php echo $useraccounts->userlevel->ViewAttributes() ?>><?php echo $useraccounts->userlevel->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($useraccounts->zemail->Visible) { // email ?>
	<tr<?php echo $useraccounts->zemail->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $useraccounts->zemail->FldCaption() ?></td>
		<td<?php echo $useraccounts->zemail->CellAttributes() ?>>
<div<?php echo $useraccounts->zemail->ViewAttributes() ?>><?php echo $useraccounts->zemail->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($useraccounts->Activated->Visible) { // Activated ?>
	<tr<?php echo $useraccounts->Activated->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $useraccounts->Activated->FldCaption() ?></td>
		<td<?php echo $useraccounts->Activated->CellAttributes() ?>>
<?php if (ew_ConvertToBool($useraccounts->Activated->CurrentValue)) { ?>
<input type="checkbox" value="<?php echo $useraccounts->Activated->ViewValue ?>" checked="checked" onclick="this.form.reset();" disabled="disabled">
<?php } else { ?>
<input type="checkbox" value="<?php echo $useraccounts->Activated->ViewValue ?>" onclick="this.form.reset();" disabled="disabled">
<?php } ?></td>
	</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<?php if ($useraccounts->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($useraccounts_view->Pager)) $useraccounts_view->Pager = new cPrevNextPager($useraccounts_view->lStartRec, $useraccounts_view->lDisplayRecs, $useraccounts_view->lTotalRecs) ?>
<?php if ($useraccounts_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 ($useraccounts_view->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $useraccounts_view->PageUrl() ?>start=<?php echo $useraccounts_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 ($useraccounts_view->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $useraccounts_view->PageUrl() ?>start=<?php echo $useraccounts_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 $useraccounts_view->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($useraccounts_view->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $useraccounts_view->PageUrl() ?>start=<?php echo $useraccounts_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 ($useraccounts_view->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $useraccounts_view->PageUrl() ?>start=<?php echo $useraccounts_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 $useraccounts_view->Pager->PageCount ?></span></td>
	</tr></table>
<?php } else { ?>
	<?php if ($Security->CanList()) { ?>
	<?php if ($useraccounts_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 ($useraccounts->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
$useraccounts_view->Page_Terminate();
?>
<?php

//
// Page class
//
class cuseraccounts_view {

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

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

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

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

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

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

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

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

		// 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("useraccountslist.php");
		}
		$Security->UserID_Loading();
		if ($Security->IsLoggedIn()) $Security->LoadUserID();
		$Security->UserID_Loaded();
		if ($Security->IsLoggedIn() && $Security->CurrentUserID() == "") {
			$_SESSION[EW_SESSION_MESSAGE] = $Language->Phrase("NoPermission");
			$this->Page_Terminate("useraccountslist.php");
		}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $useraccounts;
		$useraccounts->username->setDbValue($rs->fields('username'));
		$useraccounts->password->setDbValue($rs->fields('password'));
		$useraccounts->userlevel->setDbValue($rs->fields('userlevel'));
		$useraccounts->zemail->setDbValue($rs->fields('email'));
		$useraccounts->Activated->setDbValue($rs->fields('Activated'));
	}

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

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

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

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

		$useraccounts->username->CellCssStyle = ""; $useraccounts->username->CellCssClass = "";
		$useraccounts->username->CellAttrs = array(); $useraccounts->username->ViewAttrs = array(); $useraccounts->username->EditAttrs = array();

		// password
		$useraccounts->password->CellCssStyle = ""; $useraccounts->password->CellCssClass = "";
		$useraccounts->password->CellAttrs = array(); $useraccounts->password->ViewAttrs = array(); $useraccounts->password->EditAttrs = array();

		// userlevel
		$useraccounts->userlevel->CellCssStyle = ""; $useraccounts->userlevel->CellCssClass = "";
		$useraccounts->userlevel->CellAttrs = array(); $useraccounts->userlevel->ViewAttrs = array(); $useraccounts->userlevel->EditAttrs = array();

		// email
		$useraccounts->zemail->CellCssStyle = ""; $useraccounts->zemail->CellCssClass = "";
		$useraccounts->zemail->CellAttrs = array(); $useraccounts->zemail->ViewAttrs = array(); $useraccounts->zemail->EditAttrs = array();

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

			// username
			$useraccounts->username->ViewValue = $useraccounts->username->CurrentValue;
			$useraccounts->username->CssStyle = "";
			$useraccounts->username->CssClass = "";
			$useraccounts->username->ViewCustomAttributes = "";

			// password
			$useraccounts->password->ViewValue = "********";
			$useraccounts->password->CssStyle = "";
			$useraccounts->password->CssClass = "";
			$useraccounts->password->ViewCustomAttributes = "";

			// userlevel
			if ($Security->CanAdmin()) { // System admin
			if (strval($useraccounts->userlevel->CurrentValue) <> "") {
				switch ($useraccounts->userlevel->CurrentValue) {
					case "-1":
						$useraccounts->userlevel->ViewValue = "Administrator";
						break;
					case "0":
						$useraccounts->userlevel->ViewValue = "Default";
						break;
					default:
						$useraccounts->userlevel->ViewValue = $useraccounts->userlevel->CurrentValue;
				}
			} else {
				$useraccounts->userlevel->ViewValue = NULL;
			}
			} else {
				$useraccounts->userlevel->ViewValue = "********";
			}
			$useraccounts->userlevel->CssStyle = "";
			$useraccounts->userlevel->CssClass = "";
			$useraccounts->userlevel->ViewCustomAttributes = "";

			// email
			$useraccounts->zemail->ViewValue = $useraccounts->zemail->CurrentValue;
			$useraccounts->zemail->CssStyle = "";
			$useraccounts->zemail->CssClass = "";
			$useraccounts->zemail->ViewCustomAttributes = "";

			// Activated
			if (ew_ConvertToBool($useraccounts->Activated->CurrentValue)) {
				$useraccounts->Activated->ViewValue = "Y";
			} else {
				$useraccounts->Activated->ViewValue = "N";
			}
			$useraccounts->Activated->CssStyle = "";
			$useraccounts->Activated->CssClass = "";
			$useraccounts->Activated->ViewCustomAttributes = "";

			// username
			$useraccounts->username->HrefValue = "";
			$useraccounts->username->TooltipValue = "";

			// password
			$useraccounts->password->HrefValue = "";
			$useraccounts->password->TooltipValue = "";

			// userlevel
			$useraccounts->userlevel->HrefValue = "";
			$useraccounts->userlevel->TooltipValue = "";

			// email
			$useraccounts->zemail->HrefValue = "";
			$useraccounts->zemail->TooltipValue = "";

			// Activated
			$useraccounts->Activated->HrefValue = "";
			$useraccounts->Activated->TooltipValue = "";
		}

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

	// Show link optionally based on User ID
	function ShowOptionLink() {
		global $Security, $useraccounts;
		if ($Security->IsLoggedIn()) {
			if (!$Security->IsAdmin()) {
				return $Security->IsValidUserID($useraccounts->username->CurrentValue);
			}
		}
		return TRUE;
	}

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