Location: PHPKode > projects > Science Lab Inventory & Order Management > sciencelabinv/itemsdelete.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_delete = new citems_delete();
$Page =& $items_delete;

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

// Page main
$items_delete->Page_Main();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--

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

// page properties
items_delete.PageID = "delete"; // page ID
items_delete.FormID = "fitemsdelete"; // form ID
var EW_PAGE_ID = items_delete.PageID; // for backward compatibility

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

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
items_delete.SelectAllKey = function(elem) {
	ew_SelectAll(elem);
	ew_ClickAll(elem);
}
<?php if (EW_CLIENT_VALIDATE) { ?>
items_delete.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
items_delete.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

// Load records for display
if ($rs = $items_delete->LoadRecordset())
	$items_deletelTotalRecs = $rs->RecordCount(); // Get record count
if ($items_deletelTotalRecs <= 0) { // No record found, exit
	if ($rs)
		$rs->Close();
	$items_delete->Page_Terminate("itemslist.php"); // Return to list
}
?>
<p><span class="phpmaker"><?php echo $Language->Phrase("Delete") ?>&nbsp;<?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $items->TableCaption() ?><br><br>
<a href="<?php echo $items->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$items_delete->ShowMessage();
?>
<form action="<?php echo ew_CurrentPage() ?>" method="post">
<p>
<input type="hidden" name="t" id="t" value="items">
<input type="hidden" name="a_delete" id="a_delete" value="D">
<?php foreach ($items_delete->arRecKeys as $key) { ?>
<input type="hidden" name="key_m[]" id="key_m[]" value="<?php echo ew_HtmlEncode($key) ?>">
<?php } ?>
<table class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable ewTableSeparate">
<?php echo $items->TableCustomInnerHtml ?>
	<thead>
	<tr class="ewTableHeader">
		<td valign="top"><?php echo $items->id->FldCaption() ?></td>
		<td valign="top"><?php echo $items->name->FldCaption() ?></td>
		<td valign="top"><?php echo $items->type_id->FldCaption() ?></td>
		<td valign="top"><?php echo $items->room_id->FldCaption() ?></td>
		<td valign="top"><?php echo $items->store_id->FldCaption() ?></td>
		<td valign="top"><?php echo $items->unit->FldCaption() ?></td>
		<td valign="top"><?php echo $items->quantity->FldCaption() ?></td>
		<td valign="top"><?php echo $items->consumption->FldCaption() ?></td>
		<td valign="top"><?php echo $items->vendor->FldCaption() ?></td>
		<td valign="top"><?php echo $items->catno->FldCaption() ?></td>
		<td valign="top"><?php echo $items->arrived->FldCaption() ?></td>
		<td valign="top"><?php echo $items->expires->FldCaption() ?></td>
	</tr>
	</thead>
	<tbody>
<?php
$items_delete->lRecCnt = 0;
$i = 0;
while (!$rs->EOF) {
	$items_delete->lRecCnt++;

	// Set row properties
	$items->CssClass = "";
	$items->CssStyle = "";
	$items->RowAttrs = array();
	$items->RowType = EW_ROWTYPE_VIEW; // View

	// Get the field contents
	$items_delete->LoadRowValues($rs);

	// Render row
	$items_delete->RenderRow();
?>
	<tr<?php echo $items->RowAttributes() ?>>
		<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->ListViewValue() ?></a>
<?php } else { ?>
<?php echo $items->id->ListViewValue() ?>
<?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>
		<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->ListViewValue() ?></a>
<?php } else { ?>
<?php echo $items->name->ListViewValue() ?>
<?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>
		<td<?php echo $items->type_id->CellAttributes() ?>>
<div<?php echo $items->type_id->ViewAttributes() ?>><?php echo $items->type_id->ListViewValue() ?></div></td>
		<td<?php echo $items->room_id->CellAttributes() ?>>
<div<?php echo $items->room_id->ViewAttributes() ?>><?php echo $items->room_id->ListViewValue() ?></div></td>
		<td<?php echo $items->store_id->CellAttributes() ?>>
<div<?php echo $items->store_id->ViewAttributes() ?>><?php echo $items->store_id->ListViewValue() ?></div></td>
		<td<?php echo $items->unit->CellAttributes() ?>>
<div<?php echo $items->unit->ViewAttributes() ?>><?php echo $items->unit->ListViewValue() ?></div></td>
		<td<?php echo $items->quantity->CellAttributes() ?>>
<div<?php echo $items->quantity->ViewAttributes() ?>><?php echo $items->quantity->ListViewValue() ?></div></td>
		<td<?php echo $items->consumption->CellAttributes() ?>>
<div<?php echo $items->consumption->ViewAttributes() ?>><?php echo $items->consumption->ListViewValue() ?></div></td>
		<td<?php echo $items->vendor->CellAttributes() ?>>
<div<?php echo $items->vendor->ViewAttributes() ?>><?php echo $items->vendor->ListViewValue() ?></div></td>
		<td<?php echo $items->catno->CellAttributes() ?>>
<div<?php echo $items->catno->ViewAttributes() ?>><?php echo $items->catno->ListViewValue() ?></div></td>
		<td<?php echo $items->arrived->CellAttributes() ?>>
<div<?php echo $items->arrived->ViewAttributes() ?>><?php echo $items->arrived->ListViewValue() ?></div></td>
		<td<?php echo $items->expires->CellAttributes() ?>>
<div<?php echo $items->expires->ViewAttributes() ?>><?php echo $items->expires->ListViewValue() ?></div></td>
	</tr>
<?php
	$rs->MoveNext();
}
$rs->Close();
?>
</tbody>
</table>
</div>
</td></tr></table>
<p>
<input type="submit" name="Action" id="Action" value="<?php echo ew_BtnCaption($Language->Phrase("DeleteBtn")) ?>">
</form>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php include "footer.php" ?>
<?php
$items_delete->Page_Terminate();
?>
<?php

//
// Page class
//
class citems_delete {

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

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

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

	// 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_delete() {
		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", 'delete', 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();
		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->CanDelete()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("itemslist.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 $lTotalRecs = 0;
	var $lRecCnt;
	var $arRecKeys = array();

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

		// Load key parameters
		$sKey = "";
		$bSingleDelete = TRUE; // Initialize as single delete
		$nKeySelected = 0; // Initialize selected key count
		$sFilter = "";
		if (@$_GET["id"] <> "") {
			$items->id->setQueryStringValue($_GET["id"]);
			if (!is_numeric($items->id->QueryStringValue))
				$this->Page_Terminate("itemslist.php"); // Prevent SQL injection, exit
			$sKey .= $items->id->QueryStringValue;
		} else {
			$bSingleDelete = FALSE;
		}
		if ($bSingleDelete) {
			$nKeySelected = 1; // Set up key selected count
			$this->arRecKeys[0] = $sKey;
		} else {
			if (isset($_POST["key_m"])) { // Key in form
				$nKeySelected = count($_POST["key_m"]); // Set up key selected count
				$this->arRecKeys = ew_StripSlashes($_POST["key_m"]);
			}
		}
		if ($nKeySelected <= 0)
			$this->Page_Terminate("itemslist.php"); // No key specified, return to list

		// Build filter
		foreach ($this->arRecKeys as $sKey) {
			$sFilter .= "(";

			// Set up key field
			$sKeyFld = $sKey;
			if (!is_numeric($sKeyFld))
				$this->Page_Terminate("itemslist.php"); // Prevent SQL injection, return to list
			$sFilter .= "`id`=" . ew_AdjustSql($sKeyFld) . " AND ";
			if (substr($sFilter, -5) == " AND ") $sFilter = substr($sFilter, 0, strlen($sFilter)-5) . ") OR ";
		}
		if (substr($sFilter, -4) == " OR ") $sFilter = substr($sFilter, 0, strlen($sFilter)-4);

		// Set up filter (SQL WHHERE clause) and get return SQL
		// SQL constructor in items class, itemsinfo.php

		$items->CurrentFilter = $sFilter;

		// Get action
		if (@$_POST["a_delete"] <> "") {
			$items->CurrentAction = $_POST["a_delete"];
		} else {
			$items->CurrentAction = "I"; // Display record
		}
		switch ($items->CurrentAction) {
			case "D": // Delete
				$items->SendEmail = TRUE; // Send email on delete success
				if ($this->DeleteRows()) { // delete rows
					$this->setMessage($Language->Phrase("DeleteSuccess")); // Set up success message
					$this->Page_Terminate($items->getReturnUrl()); // Return to caller
				}
		}
	}

	//
	// Delete records based on current filter
	//
	function DeleteRows() {
		global $conn, $Language, $Security, $items;
		$DeleteRows = TRUE;
		$sWrkFilter = $items->CurrentFilter;

		// Set up filter (SQL WHERE clause) and get return SQL
		// SQL constructor in items class, itemsinfo.php

		$items->CurrentFilter = $sWrkFilter;
		$sSql = $items->SQL();
		$conn->raiseErrorFn = 'ew_ErrorFn';
		$rs = $conn->Execute($sSql);
		$conn->raiseErrorFn = '';
		if ($rs === FALSE) {
			return FALSE;
		} elseif ($rs->EOF) {
			$this->setMessage($Language->Phrase("NoRecord")); // No record found
			$rs->Close();
			return FALSE;
		}
		$conn->BeginTrans();

		// Clone old rows
		$rsold = ($rs) ? $rs->GetRows() : array();
		if ($rs)
			$rs->Close();

		// Call row deleting event
		if ($DeleteRows) {
			foreach ($rsold as $row) {
				$DeleteRows = $items->Row_Deleting($row);
				if (!$DeleteRows) break;
			}
		}
		if ($DeleteRows) {
			$sKey = "";
			foreach ($rsold as $row) {
				$sThisKey = "";
				if ($sThisKey <> "") $sThisKey .= EW_COMPOSITE_KEY_SEPARATOR;
				$sThisKey .= $row['id'];
				@unlink(ew_UploadPathEx(TRUE, $items->image->UploadPath) . $row['image']);
				$conn->raiseErrorFn = 'ew_ErrorFn';
				$DeleteRows = $conn->Execute($items->DeleteSQL($row)); // Delete
				$conn->raiseErrorFn = '';
				if ($DeleteRows === FALSE)
					break;
				if ($sKey <> "") $sKey .= ", ";
				$sKey .= $sThisKey;
			}
		} else {

			// Set up error message
			if ($items->CancelMessage <> "") {
				$this->setMessage($items->CancelMessage);
				$items->CancelMessage = "";
			} else {
				$this->setMessage($Language->Phrase("DeleteCancelled"));
			}
		}
		if ($DeleteRows) {
			$conn->CommitTrans(); // Commit the changes
		} else {
			$conn->RollbackTrans(); // Rollback changes
		}

		// Call Row Deleted event
		if ($DeleteRows) {
			foreach ($rsold as $row) {
				$items->Row_Deleted($row);
			}	
		}
		return $DeleteRows;
	}

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

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