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

// Create page object
$orders_delete = new corders_delete();
$Page =& $orders_delete;

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

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

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

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

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

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
orders_delete.SelectAllKey = function(elem) {
	ew_SelectAll(elem);
	ew_ClickAll(elem);
}
<?php if (EW_CLIENT_VALIDATE) { ?>
orders_delete.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
orders_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 = $orders_delete->LoadRecordset())
	$orders_deletelTotalRecs = $rs->RecordCount(); // Get record count
if ($orders_deletelTotalRecs <= 0) { // No record found, exit
	if ($rs)
		$rs->Close();
	$orders_delete->Page_Terminate("orderslist.php"); // Return to list
}
?>
<p><span class="phpmaker"><?php echo $Language->Phrase("Delete") ?>&nbsp;<?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $orders->TableCaption() ?><br><br>
<a href="<?php echo $orders->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$orders_delete->ShowMessage();
?>
<form action="<?php echo ew_CurrentPage() ?>" method="post">
<p>
<input type="hidden" name="t" id="t" value="orders">
<input type="hidden" name="a_delete" id="a_delete" value="D">
<?php foreach ($orders_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 $orders->TableCustomInnerHtml ?>
	<thead>
	<tr class="ewTableHeader">
		<td valign="top"><?php echo $orders->lesson->FldCaption() ?></td>
		<td valign="top"><?php echo $orders->title->FldCaption() ?></td>
		<td valign="top"><?php echo $orders->room->FldCaption() ?></td>
		<td valign="top"><?php echo $orders->order_date->FldCaption() ?></td>
		<td valign="top"><?php echo $orders->request_date->FldCaption() ?></td>
		<td valign="top"><?php echo $orders->return_date->FldCaption() ?></td>
		<td valign="top"><?php echo $orders->teacher->FldCaption() ?></td>
		<td valign="top"><?php echo $orders->attachment->FldCaption() ?></td>
	</tr>
	</thead>
	<tbody>
<?php
$orders_delete->lRecCnt = 0;
$i = 0;
while (!$rs->EOF) {
	$orders_delete->lRecCnt++;

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

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

	// Render row
	$orders_delete->RenderRow();
?>
	<tr<?php echo $orders->RowAttributes() ?>>
		<td<?php echo $orders->lesson->CellAttributes() ?>>
<div<?php echo $orders->lesson->ViewAttributes() ?>>
<?php if ($orders->lesson->HrefValue <> "" || $orders->lesson->TooltipValue <> "" || $orders->note->ViewValue <> "") { ?>
<a href="javascript:void(0);" onmouseover="ew_ShowTooltip(this, 'tt_orders_x_lesson');" onmouseout="ew_HideTooltip();"><?php echo $orders->lesson->ListViewValue() ?></a>
<?php } else { ?>
<?php echo $orders->lesson->ListViewValue() ?>
<?php } ?>
</div><div id="tt_orders_x_lesson" style="display: none">
<?php if ($orders->lesson->TooltipValue <> "") { ?>
<?php echo $orders->lesson->TooltipValue ?>
<?php } else { ?>
<div<?php echo $orders->note->ViewAttributes() ?>><?php echo $orders->note->ViewValue ?></div>
<?php } ?>
</div></td>
		<td<?php echo $orders->title->CellAttributes() ?>>
<div<?php echo $orders->title->ViewAttributes() ?>><?php echo $orders->title->ListViewValue() ?></div></td>
		<td<?php echo $orders->room->CellAttributes() ?>>
<div<?php echo $orders->room->ViewAttributes() ?>><?php echo $orders->room->ListViewValue() ?></div></td>
		<td<?php echo $orders->order_date->CellAttributes() ?>>
<div<?php echo $orders->order_date->ViewAttributes() ?>><?php echo $orders->order_date->ListViewValue() ?></div></td>
		<td<?php echo $orders->request_date->CellAttributes() ?>>
<div<?php echo $orders->request_date->ViewAttributes() ?>><?php echo $orders->request_date->ListViewValue() ?></div></td>
		<td<?php echo $orders->return_date->CellAttributes() ?>>
<div<?php echo $orders->return_date->ViewAttributes() ?>><?php echo $orders->return_date->ListViewValue() ?></div></td>
		<td<?php echo $orders->teacher->CellAttributes() ?>>
<div<?php echo $orders->teacher->ViewAttributes() ?>><?php echo $orders->teacher->ListViewValue() ?></div></td>
		<td<?php echo $orders->attachment->CellAttributes() ?>>
<?php if ($orders->attachment->HrefValue <> "" || $orders->attachment->TooltipValue <> "") { ?>
<?php if (!empty($orders->attachment->Upload->DbValue)) { ?>
<a href="<?php echo $orders->attachment->HrefValue ?>"><?php echo $orders->attachment->ListViewValue() ?></a>
<?php } elseif (!in_array($orders->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } else { ?>
<?php if (!empty($orders->attachment->Upload->DbValue)) { ?>
<?php echo $orders->attachment->ListViewValue() ?>
<?php } elseif (!in_array($orders->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } ?>
</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
$orders_delete->Page_Terminate();
?>
<?php

//
// Page class
//
class corders_delete {

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

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

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

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

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		global $orders;
		if ($orders->UseTokenInUrl) $PageUrl .= "t=" . $orders->TableVar . "&"; // Add page token
		return $PageUrl;
	}

	// Page URLs
	var $AddUrl;
	var $EditUrl;
	var $CopyUrl;
	var $DeleteUrl;
	var $ViewUrl;
	var $ListUrl;

	// Export URLs
	var $ExportPrintUrl;
	var $ExportHtmlUrl;
	var $ExportExcelUrl;
	var $ExportWordUrl;
	var $ExportXmlUrl;
	var $ExportCsvUrl;

	// Update URLs
	var $InlineAddUrl;
	var $InlineCopyUrl;
	var $InlineEditUrl;
	var $GridAddUrl;
	var $GridEditUrl;
	var $MultiDeleteUrl;
	var $MultiUpdateUrl;

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Append
			$_SESSION[EW_SESSION_MESSAGE] .= "<br>" . $v;
		} else {
			$_SESSION[EW_SESSION_MESSAGE] = $v;
		}
	}

	// Show message
	function ShowMessage() {
		$sMessage = $this->getMessage();
		$this->Message_Showing($sMessage);
		if ($sMessage <> "") { // Message in Session, display
			echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}
	}

	// Validate page request
	function IsPageRequest() {
		global $objForm, $orders;
		if ($orders->UseTokenInUrl) {
			if ($objForm)
				return ($orders->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($orders->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

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

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

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

		// Table object (rooms)
		$GLOBALS['rooms'] = new crooms();

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

		// Table object (lesson)
		$GLOBALS['lesson'] = new clesson();

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

		// 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("orderslist.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("orderslist.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 $lTotalRecs = 0;
	var $lRecCnt;
	var $arRecKeys = array();

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

		// Load key parameters
		$sKey = "";
		$bSingleDelete = TRUE; // Initialize as single delete
		$nKeySelected = 0; // Initialize selected key count
		$sFilter = "";
		if (@$_GET["id"] <> "") {
			$orders->id->setQueryStringValue($_GET["id"]);
			if (!is_numeric($orders->id->QueryStringValue))
				$this->Page_Terminate("orderslist.php"); // Prevent SQL injection, exit
			$sKey .= $orders->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("orderslist.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("orderslist.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 orders class, ordersinfo.php

		$orders->CurrentFilter = $sFilter;

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

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

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

		$orders->CurrentFilter = $sWrkFilter;
		$sSql = $orders->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 = $orders->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, $orders->attachment->UploadPath) . $row['attachment']);
				$conn->raiseErrorFn = 'ew_ErrorFn';
				$DeleteRows = $conn->Execute($orders->DeleteSQL($row)); // Delete
				$conn->raiseErrorFn = '';
				if ($DeleteRows === FALSE)
					break;
				if ($sKey <> "") $sKey .= ", ";
				$sKey .= $sThisKey;
			}
		} else {

			// Set up error message
			if ($orders->CancelMessage <> "") {
				$this->setMessage($orders->CancelMessage);
				$orders->CancelMessage = "";
			} else {
				$this->setMessage($Language->Phrase("DeleteCancelled"));
			}
		}
		if ($DeleteRows) {
			$conn->CommitTrans(); // Commit the changes
			$sFn = "txt/notify.txt";
			$sTable = 'orders';
			$sSubject = $sTable . " " . $Language->Phrase("RecordDeleted");
			$sAction = $Language->Phrase("ActionDeleted");
			$Email = new cEmail();
			$Email->Load($sFn);
			$Email->ReplaceSender(EW_SENDER_EMAIL); // Replace Sender
			$Email->ReplaceRecipient(EW_RECIPIENT_EMAIL); // Replace Recipient
			$Email->ReplaceSubject($sSubject); // Replace Subject
			$Email->ReplaceContent("<!--table-->", $sTable);
			$Email->ReplaceContent("<!--key-->", $sKey);
			$Email->ReplaceContent("<!--action-->", $sAction);
			$Email->Charset = EW_EMAIL_CHARSET;
			$Args = array();
			$Args["rs"] =& $rsold;
			$bEmailSent = FALSE;
			if ($orders->Email_Sending($Email, $Args))
				$bEmailSent = $Email->Send();
			if (!$bEmailSent)
				$this->setMessage($Email->SendErrDescription);
		} else {
			$conn->RollbackTrans(); // Rollback changes
		}

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

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

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

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

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

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

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

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

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

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

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $orders;
		$orders->id->setDbValue($rs->fields('id'));
		$orders->lesson->setDbValue($rs->fields('lesson'));
		$orders->title->setDbValue($rs->fields('title'));
		$orders->room->setDbValue($rs->fields('room'));
		$orders->order_date->setDbValue($rs->fields('order_date'));
		$orders->request_date->setDbValue($rs->fields('request_date'));
		$orders->return_date->setDbValue($rs->fields('return_date'));
		$orders->teacher->setDbValue($rs->fields('teacher'));
		$orders->attachment->Upload->DbValue = $rs->fields('attachment');
		$orders->note->setDbValue($rs->fields('note'));
	}

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

		// Initialize URLs
		// Call Row_Rendering event

		$orders->Row_Rendering();

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

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

		// title
		$orders->title->CellCssStyle = ""; $orders->title->CellCssClass = "";
		$orders->title->CellAttrs = array(); $orders->title->ViewAttrs = array(); $orders->title->EditAttrs = array();

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

		// order_date
		$orders->order_date->CellCssStyle = ""; $orders->order_date->CellCssClass = "";
		$orders->order_date->CellAttrs = array(); $orders->order_date->ViewAttrs = array(); $orders->order_date->EditAttrs = array();

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

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

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

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

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

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

			// title
			$orders->title->ViewValue = $orders->title->CurrentValue;
			$orders->title->CssStyle = "";
			$orders->title->CssClass = "";
			$orders->title->ViewCustomAttributes = "";

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

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

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

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

			// teacher
			$orders->teacher->ViewValue = $orders->teacher->CurrentValue;
			$orders->teacher->CssStyle = "";
			$orders->teacher->CssClass = "";
			$orders->teacher->ViewCustomAttributes = "";

			// attachment
			if (!ew_Empty($orders->attachment->Upload->DbValue)) {
				$orders->attachment->ViewValue = $orders->attachment->Upload->DbValue;
			} else {
				$orders->attachment->ViewValue = "";
			}
			$orders->attachment->CssStyle = "";
			$orders->attachment->CssClass = "";
			$orders->attachment->ViewCustomAttributes = "";

			// lesson
			$orders->lesson->HrefValue = "";
			$orders->lesson->TooltipValue = $orders->note->CurrentValue;

			// title
			$orders->title->HrefValue = "";
			$orders->title->TooltipValue = "";

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

			// order_date
			$orders->order_date->HrefValue = "";
			$orders->order_date->TooltipValue = "";

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

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

			// teacher
			$orders->teacher->HrefValue = "";
			$orders->teacher->TooltipValue = "";

			// attachment
			if (!ew_Empty($orders->attachment->Upload->DbValue)) {
				$orders->attachment->HrefValue = ew_UploadPathEx(FALSE, $orders->attachment->UploadPath) . ((!empty($orders->attachment->ViewValue)) ? $orders->attachment->ViewValue : $orders->attachment->CurrentValue);
				if ($orders->Export <> "") $orders->attachment->HrefValue = ew_ConvertFullUrl($orders->attachment->HrefValue);
			} else {
				$orders->attachment->HrefValue = "";
			}
			$orders->attachment->TooltipValue = "";
		}

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