Location: PHPKode > projects > Science Lab Inventory & Order Management > sciencelabinv/orders_date_teacherreport.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

// Global variable for table object
$orders_date_teacher = NULL;

//
// Table class for orders_date_teacher
//
class corders_date_teacher {
	var $TableVar = 'orders_date_teacher';
	var $TableName = 'orders_date_teacher';
	var $TableType = 'REPORT';
	var $id;
	var $room;
	var $order_date;
	var $request_date;
	var $return_date;
	var $lesson;
	var $starts;
	var $ends;
	var $teacher;
	var $note;
	var $fields = array();
	var $UseTokenInUrl = EW_USE_TOKEN_IN_URL;
	var $Export; // Export
	var $ExportOriginalValue = EW_EXPORT_ORIGINAL_VALUE;
	var $ExportAll = TRUE;
	var $SendEmail; // Send email
	var $TableCustomInnerHtml; // Custom inner HTML
	var $BasicSearchKeyword; // Basic search keyword
	var $BasicSearchType; // Basic search type
	var $CurrentFilter; // Current filter
	var $CurrentOrder; // Current order
	var $CurrentOrderType; // Current order type
	var $RowType; // Row type
	var $CssClass; // CSS class
	var $CssStyle; // CSS style
	var $RowAttrs = array(); // Row custom attributes
	var $TableFilter = "";

	//
	// Table class constructor
	//
	function corders_date_teacher() {
		global $Language;

		// id
		$this->id = new cField('orders_date_teacher', 'orders_date_teacher', 'x_id', 'id', '`id`', 19, -1, FALSE, '`id`', FALSE);
		$this->id->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['id'] =& $this->id;

		// room
		$this->room = new cField('orders_date_teacher', 'orders_date_teacher', 'x_room', 'room', '`room`', 200, -1, FALSE, '`room`', FALSE);
		$this->fields['room'] =& $this->room;

		// order_date
		$this->order_date = new cField('orders_date_teacher', 'orders_date_teacher', 'x_order_date', 'order_date', '`order_date`', 135, 5, FALSE, '`order_date`', FALSE);
		$this->order_date->FldDefaultErrMsg = str_replace("%s", "/", $Language->Phrase("IncorrectDateYMD"));
		$this->fields['order_date'] =& $this->order_date;

		// request_date
		$this->request_date = new cField('orders_date_teacher', 'orders_date_teacher', 'x_request_date', 'request_date', '`request_date`', 133, 5, FALSE, '`request_date`', FALSE);
		$this->request_date->FldDefaultErrMsg = str_replace("%s", "/", $Language->Phrase("IncorrectDateYMD"));
		$this->fields['request_date'] =& $this->request_date;

		// return_date
		$this->return_date = new cField('orders_date_teacher', 'orders_date_teacher', 'x_return_date', 'return_date', '`return_date`', 133, 5, FALSE, '`return_date`', FALSE);
		$this->return_date->FldDefaultErrMsg = str_replace("%s", "/", $Language->Phrase("IncorrectDateYMD"));
		$this->fields['return_date'] =& $this->return_date;

		// lesson
		$this->lesson = new cField('orders_date_teacher', 'orders_date_teacher', 'x_lesson', 'lesson', '`lesson`', 200, -1, FALSE, '`lesson`', FALSE);
		$this->fields['lesson'] =& $this->lesson;

		// starts
		$this->starts = new cField('orders_date_teacher', 'orders_date_teacher', 'x_starts', 'starts', '`starts`', 134, -1, FALSE, '`starts`', FALSE);
		$this->starts->FldDefaultErrMsg = $Language->Phrase("IncorrectTime");
		$this->fields['starts'] =& $this->starts;

		// ends
		$this->ends = new cField('orders_date_teacher', 'orders_date_teacher', 'x_ends', 'ends', '`ends`', 134, -1, FALSE, '`ends`', FALSE);
		$this->ends->FldDefaultErrMsg = $Language->Phrase("IncorrectTime");
		$this->fields['ends'] =& $this->ends;

		// teacher
		$this->teacher = new cField('orders_date_teacher', 'orders_date_teacher', 'x_teacher', 'teacher', '`teacher`', 200, -1, FALSE, '`teacher`', FALSE);
		$this->fields['teacher'] =& $this->teacher;

		// note
		$this->note = new cField('orders_date_teacher', 'orders_date_teacher', 'x_note', 'note', '`note`', 201, -1, FALSE, '`note`', FALSE);
		$this->fields['note'] =& $this->note;
	}

	// Table caption
	function TableCaption() {
		global $Language;
		return $Language->TablePhrase($this->TableVar, "TblCaption");
	}

	// Page caption
	function PageCaption($Page) {
		global $Language;
		$Caption = $Language->TablePhrase($this->TableVar, "TblPageCaption" . $Page);
		if ($Caption == "") $Caption = "Page " . $Page;
		return $Caption;
	}

	// Current master table name
	function getCurrentMasterTable() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_MASTER_TABLE];
	}

	function setCurrentMasterTable($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_MASTER_TABLE] = $v;
	}

	// Session master WHERE clause
	function getMasterFilter() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_MASTER_FILTER];
	}

	function setMasterFilter($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_MASTER_FILTER] = $v;
	}

	// Session detail WHERE clause
	function getDetailFilter() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_DETAIL_FILTER];
	}

	function setDetailFilter($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_DETAIL_FILTER] = $v;
	}

	// Master filter
	function SqlMasterFilter_useraccounts() {
		return "`username`='@username@'";
	}

	// Detail filter
	function SqlDetailFilter_useraccounts() {
		return "`teacher`='@teacher@'";
	}

	// Report group level SQL
	function SqlGroupSelect() { // Select
		return "SELECT DISTINCT `request_date`,`teacher` FROM `orders_view`";
	}

	function SqlGroupWhere() { // Where
		return "";
	}

	function SqlGroupGroupBy() { // Group By
		return "";
	}

	function SqlGroupHaving() { // Having
		return "";
	}

	function SqlGroupOrderBy() { // Order By
		return "`request_date` DESC,`teacher` ASC";
	}

	// Report detail level SQL
	function SqlDetailSelect() { // Select
		return "SELECT * FROM `orders_view`";
	}

	function SqlDetailWhere() { // Where
		return "";
	}

	function SqlDetailGroupBy() { // Group By
		return "";
	}

	function SqlDetailHaving() { // Having
		return "";
	}

	function SqlDetailOrderBy() { // Order By
		return "`request_date` DESC";
	}

	// Check if Anonymous User is allowed
	function AllowAnonymousUser() {
		switch (EW_PAGE_ID) {
			case "add":
			case "register":
			case "addopt":
				return FALSE;
			case "edit":
			case "update":
				return FALSE;
			case "delete":
				return FALSE;
			case "view":
				return TRUE;
			case "search":
				return TRUE;
			default:
				return TRUE;
		}
	}

	// Apply User ID filters
	function ApplyUserIDFilters($sFilter) {
		global $Security;

		// Add User ID filter
		if (!$this->AllowAnonymousUser() && $Security->CurrentUserID() <> "" && !$Security->IsAdmin()) { // Non system admin
			if ($this->getCurrentMasterTable() == "useraccounts")
				$sFilter = $this->AddDetailUserIDFilter($sFilter, "useraccounts"); // Add detail User ID filter
		}
		return $sFilter;
	}

	// Report group SQL
	function GroupSQL() {
		$sFilter = $this->CurrentFilter;
		$sFilter = $this->ApplyUserIDFilters($sFilter);
		$sSort = "";
		return ew_BuildSelectSql($this->SqlGroupSelect(), $this->SqlGroupWhere(),
			 $this->SqlGroupGroupBy(), $this->SqlGroupHaving(),
			 $this->SqlGroupOrderBy(), $sFilter, $sSort);
	}

	// Report detail SQL
	function DetailSQL() {
		$sFilter = $this->CurrentFilter;
		$sFilter = $this->ApplyUserIDFilters($sFilter);
		$sSort = "";
		return ew_BuildSelectSql($this->SqlDetailSelect(), $this->SqlDetailWhere(),
			$this->SqlDetailGroupBy(), $this->SqlDetailHaving(),
			$this->SqlDetailOrderBy(), $sFilter, $sSort);
	}

	// Return page URL
	function getReturnUrl() {
		$name = EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_RETURN_URL;

		// Get referer URL automatically
		if (ew_ServerVar("HTTP_REFERER") <> "" && ew_ReferPage() <> ew_CurrentPage() && ew_ReferPage() <> "login.php") // Referer not same page or login page
			$_SESSION[$name] = ew_ServerVar("HTTP_REFERER"); // Save to Session
		if (@$_SESSION[$name] <> "") {
			return $_SESSION[$name];
		} else {
			return "orders_date_teacherreport.php";
		}
	}

	function setReturnUrl($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_RETURN_URL] = $v;
	}

	// List URL
	function ListUrl() {
		return "orders_date_teacherreport.php";
	}

	// View URL
	function ViewUrl() {
		return $this->KeyUrl("", $this->UrlParm());
	}

	// Add URL
	function AddUrl() {
		$AddUrl = "";
		$sUrlParm = $this->UrlParm();
		if ($sUrlParm <> "")
			$AddUrl .= "?" . $sUrlParm;
		return $AddUrl;
	}

	// Edit URL
	function EditUrl() {
		return $this->KeyUrl("", $this->UrlParm());
	}

	// Inline edit URL
	function InlineEditUrl() {
		return $this->KeyUrl(ew_CurrentPage(), $this->UrlParm("a=edit"));
	}

	// Copy URL
	function CopyUrl() {
		return $this->KeyUrl("", $this->UrlParm());
	}

	// Inline copy URL
	function InlineCopyUrl() {
		return $this->KeyUrl(ew_CurrentPage(), $this->UrlParm("a=copy"));
	}

	// Delete URL
	function DeleteUrl() {
		return $this->KeyUrl("", $this->UrlParm());
	}

	// Add key value to URL
	function KeyUrl($url, $parm = "") {
		$sUrl = $url . "?";
		if ($parm <> "") $sUrl .= $parm . "&";
		return $sUrl;
	}

	// Sort URL
	function SortUrl(&$fld) {
		if ($this->CurrentAction <> "" || $this->Export <> "" ||
			in_array($fld->FldType, array(128, 204, 205))) { // Unsortable data type
				return "";
		} elseif ($fld->Sortable) {
			$sUrlParm = $this->UrlParm("order=" . urlencode($fld->FldName) . "&ordertype=" . $fld->ReverseSort());
			return ew_CurrentPage() . "?" . $sUrlParm;
		} else {
			return "";
		}
	}

	// Add URL parameter
	function UrlParm($parm = "") {
		$UrlParm = ($this->UseTokenInUrl) ? "t=orders_date_teacher" : "";
		if ($parm <> "") {
			if ($UrlParm <> "")
				$UrlParm .= "&";
			$UrlParm .= $parm;
		}
		return $UrlParm;
	}

	// Load rows based on filter
	function &LoadRs($sFilter) {
		global $conn;

		// Set up filter (SQL WHERE clause) and get return SQL
		$this->CurrentFilter = $sFilter;
		$sSql = $this->SQL();
		return $conn->Execute($sSql);
	}

	// Load row values from recordset
	function LoadListRowValues(&$rs) {
		$this->id->setDbValue($rs->fields('id'));
		$this->room->setDbValue($rs->fields('room'));
		$this->order_date->setDbValue($rs->fields('order_date'));
		$this->request_date->setDbValue($rs->fields('request_date'));
		$this->return_date->setDbValue($rs->fields('return_date'));
		$this->lesson->setDbValue($rs->fields('lesson'));
		$this->starts->setDbValue($rs->fields('starts'));
		$this->ends->setDbValue($rs->fields('ends'));
		$this->teacher->setDbValue($rs->fields('teacher'));
		$this->note->setDbValue($rs->fields('note'));
	}

	// Render list row values
	function RenderListRow() {
		global $conn, $Security;

   // Common render codes
		// id

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

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

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

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

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

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

		// starts
		$orders_date_teacher->starts->CellCssStyle = ""; $orders_date_teacher->starts->CellCssClass = "";
		$orders_date_teacher->starts->CellAttrs = array(); $orders_date_teacher->starts->ViewAttrs = array(); $orders_date_teacher->starts->EditAttrs = array();

		// ends
		$orders_date_teacher->ends->CellCssStyle = ""; $orders_date_teacher->ends->CellCssClass = "";
		$orders_date_teacher->ends->CellAttrs = array(); $orders_date_teacher->ends->ViewAttrs = array(); $orders_date_teacher->ends->EditAttrs = array();

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

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

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

		// room
		$orders_date_teacher->room->ViewValue = $orders_date_teacher->room->CurrentValue;
		$orders_date_teacher->room->CssStyle = "";
		$orders_date_teacher->room->CssClass = "";
		$orders_date_teacher->room->ViewCustomAttributes = "";

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

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

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

		// lesson
		$orders_date_teacher->lesson->ViewValue = $orders_date_teacher->lesson->CurrentValue;
		$orders_date_teacher->lesson->CssStyle = "";
		$orders_date_teacher->lesson->CssClass = "";
		$orders_date_teacher->lesson->ViewCustomAttributes = "";

		// starts
		$orders_date_teacher->starts->ViewValue = $orders_date_teacher->starts->CurrentValue;
		$orders_date_teacher->starts->ViewValue = ew_FormatDateTime($orders_date_teacher->starts->ViewValue, 4);
		$orders_date_teacher->starts->CssStyle = "";
		$orders_date_teacher->starts->CssClass = "";
		$orders_date_teacher->starts->ViewCustomAttributes = "";

		// ends
		$orders_date_teacher->ends->ViewValue = $orders_date_teacher->ends->CurrentValue;
		$orders_date_teacher->ends->ViewValue = ew_FormatDateTime($orders_date_teacher->ends->ViewValue, 4);
		$orders_date_teacher->ends->CssStyle = "";
		$orders_date_teacher->ends->CssClass = "";
		$orders_date_teacher->ends->ViewCustomAttributes = "";

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

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

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

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

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

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

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

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

		// starts
		$orders_date_teacher->starts->HrefValue = "";
		$orders_date_teacher->starts->TooltipValue = "";

		// ends
		$orders_date_teacher->ends->HrefValue = "";
		$orders_date_teacher->ends->TooltipValue = "";

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

		// note
		$orders_date_teacher->note->HrefValue = "";
		$orders_date_teacher->note->TooltipValue = "";
	}

	// Aggregate list row values
	function AggregateListRowValues() {
	}

	// Aggregate list row (for rendering)
	function AggregateListRow() {
	}

	// Add master User ID filter
	function AddMasterUserIDFilter($sFilter, $sCurrentMasterTable) {
		$sFilterWrk = $sFilter;
		if ($sCurrentMasterTable == "useraccounts") {
			$sFilterWrk = $GLOBALS["useraccounts"]->AddUserIDFilter($sFilterWrk);
		}
		return $sFilterWrk;
	}

	// Add detail User ID filter
	function AddDetailUserIDFilter($sFilter, $sCurrentMasterTable) {
		$sFilterWrk = $sFilter;
		if ($sCurrentMasterTable == "useraccounts") {
			$sSubqueryWrk = $GLOBALS["useraccounts"]->GetUserIDSubquery($this->teacher, $GLOBALS["useraccounts"]->username);
			if ($sSubqueryWrk <> "") {
				if ($sFilterWrk <> "") {
					$sFilterWrk = "($sFilterWrk) AND ($sSubqueryWrk)";
				} else {
					$sFilterWrk = $sSubqueryWrk;
				}
			}
		}
		return $sFilterWrk;
	}

	// Row styles
	function RowStyles() {
		$sAtt = "";
		$sStyle = trim($this->CssStyle);
		if (@$this->RowAttrs["style"] <> "")
			$sStyle .= " " . $this->RowAttrs["style"];
		$sClass = trim($this->CssClass);
		if (@$this->RowAttrs["class"] <> "")
			$sClass .= " " . $this->RowAttrs["class"];
		if (trim($sStyle) <> "")
			$sAtt .= " style=\"" . trim($sStyle) . "\"";
		if (trim($sClass) <> "")
			$sAtt .= " class=\"" . trim($sClass) . "\"";
		return $sAtt;
	}

	// Row attributes
	function RowAttributes() {
		$sAtt = $this->RowStyles();
		if ($this->Export == "") {
			foreach ($this->RowAttrs as $k => $v) {
				if ($k <> "class" && $k <> "style" && trim($v) <> "")
					$sAtt .= " " . $k . "=\"" . trim($v) . "\"";
			}
		}
		return $sAtt;
	}

	// Field object by name
	function fields($fldname) {
		return $this->fields[$fldname];
	}
}
?>
<?php include "useraccountsinfo.php" ?>
<?php include "userfn7.php" ?>
<?php

// Create page object
$orders_date_teacher_report = new corders_date_teacher_report();
$Page =& $orders_date_teacher_report;

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

// Page main
$orders_date_teacher_report->Page_Main();
?>
<?php include "header.php" ?>
<?php if ($orders_date_teacher->Export == "") { ?>
<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 } ?>
<?php if ($orders_date_teacher->Export == "") { ?>
<?php
if ($orders_date_teacher->getMasterFilter() <> "" && $orders_date_teacher->getCurrentMasterTable() == "useraccounts") {
	if ($orders_date_teacher_report->bMasterRecordExists) {
?>
<?php if ($orders_date_teacher->Export == "") { ?>
<p><span class="phpmaker"><a href="useraccountslist.php"><?php echo $Language->Phrase("BackToMasterPage") ?></a></span></p>
<?php } ?>
<?php
	}
}
?>
<?php } ?>
<p><span class="phpmaker"><?php echo $Language->Phrase("TblTypeReport") ?><?php echo $orders_date_teacher->TableCaption() ?>
<?php if ($orders_date_teacher->Export == "") { ?>
&nbsp;&nbsp;<a href="<?php echo $orders_date_teacher_report->ExportPrintUrl ?>"><?php echo $Language->Phrase("PrinterFriendly") ?></a>
&nbsp;&nbsp;<a href="<?php echo $orders_date_teacher_report->ExportExcelUrl ?>"><?php echo $Language->Phrase("ExportToExcel") ?></a>
&nbsp;&nbsp;<a href="<?php echo $orders_date_teacher_report->ExportWordUrl ?>"><?php echo $Language->Phrase("ExportToWord") ?></a>
<?php } ?>
</span></p>
<form method="post">
<table class="ewReportTable" cellspacing="-1">
<?php
$orders_date_teacher_report->sTblDefaultFilter = "";
$orders_date_teacher_report->sFilter = $orders_date_teacher_report->sTblDefaultFilter;
if ($orders_date_teacher_report->sDbDetailFilter <> "") {
	if ($orders_date_teacher_report->sFilter <> "") $orders_date_teacher_report->sFilter .= " AND ";
	$orders_date_teacher_report->sFilter .= "(" . $orders_date_teacher_report->sDbDetailFilter . ")";
}

// Set up filter and load Group level sql
$orders_date_teacher->CurrentFilter = $orders_date_teacher_report->sFilter;
$orders_date_teacher_report->sSql = $orders_date_teacher->GroupSQL();

// Load recordset
$rs = $conn->Execute($orders_date_teacher_report->sSql);

// Get First Row
if (!$rs->EOF) {
	$orders_date_teacher->request_date->setDbValue($rs->fields('request_date'));
	$orders_date_teacher_report->vGrps[0] = $orders_date_teacher->request_date->DbValue;
	$orders_date_teacher->teacher->setDbValue($rs->fields('teacher'));
	$orders_date_teacher_report->vGrps[1] = $orders_date_teacher->teacher->DbValue;
}
$orders_date_teacher_report->lRecCnt = 0;
$orders_date_teacher_report->nCntRecs[0] = 0;
$orders_date_teacher_report->ChkLvlBreak();
while (!$rs->EOF) {

	// Render for view
	$orders_date_teacher->RowType = EW_ROWTYPE_VIEW;
	$orders_date_teacher_report->RenderRow();

	// Show group headers
	if ($orders_date_teacher_report->bLvlBreak[1]) { // Reset counter and aggregation
?>
	<tr><td class="ewGroupField"><span class="phpmaker"><?php echo $orders_date_teacher->request_date->FldCaption() ?></span></td>
	<td colspan=7 class="ewGroupName"><span class="phpmaker">
<div<?php echo $orders_date_teacher->request_date->ViewAttributes() ?>><?php echo $orders_date_teacher->request_date->ViewValue ?></div></span></td></tr>
<?php
	}
	if ($orders_date_teacher_report->bLvlBreak[2]) { // Reset counter and aggregation
?>
	<tr><td class="ewGroupField"><span class="phpmaker"><?php echo $orders_date_teacher->teacher->FldCaption() ?></span></td>
	<td colspan=7 class="ewGroupName"><span class="phpmaker">
<div<?php echo $orders_date_teacher->teacher->ViewAttributes() ?>><?php echo $orders_date_teacher->teacher->ViewValue ?></div></span></td></tr>
<?php
	}

	// Get detail records
	$orders_date_teacher_report->sFilter = $orders_date_teacher_report->sTblDefaultFilter;
	if ($orders_date_teacher_report->sFilter <> "") $orders_date_teacher_report->sFilter .= " AND ";
	if (is_null(ew_UnFormatDateTime(ew_FormatDateTime($orders_date_teacher->request_date->CurrentValue,5),5))) {
		$orders_date_teacher_report->sFilter .= "(`request_date` IS NULL)";
	} else {
		$orders_date_teacher_report->sFilter .= "(`request_date` = '" . ew_AdjustSql(ew_UnFormatDateTime(ew_FormatDateTime($orders_date_teacher->request_date->CurrentValue,5),5)) . "')";
	}
	if ($orders_date_teacher_report->sFilter <> "") $orders_date_teacher_report->sFilter .= " AND ";
	if (is_null($orders_date_teacher->teacher->CurrentValue)) {
		$orders_date_teacher_report->sFilter .= "(`teacher` IS NULL)";
	} else {
		$orders_date_teacher_report->sFilter .= "(`teacher` = '" . ew_AdjustSql($orders_date_teacher->teacher->CurrentValue) . "')";
	}
	if ($orders_date_teacher_report->sDbDetailFilter <> "") {
		if ($orders_date_teacher_report->sFilter <> "")
			$orders_date_teacher_report->sFilter .= " AND ";
		$orders_date_teacher_report->sFilter .= "(" . $orders_date_teacher_report->sDbDetailFilter . ")";
	}

	// Set up detail SQL
	$orders_date_teacher->CurrentFilter = $orders_date_teacher_report->sFilter;
	$orders_date_teacher_report->sSql = $orders_date_teacher->DetailSQL();

	// Load detail records
	$rsdtl = $conn->Execute($orders_date_teacher_report->sSql);
	$orders_date_teacher_report->nDtlRecs = $rsdtl->RecordCount();

	// Initialize aggregates
	if (!$rsdtl->EOF) {
		$orders_date_teacher_report->lRecCnt++;
	}
	if ($orders_date_teacher_report->lRecCnt == 1) {
		$orders_date_teacher_report->nCntRecs[0] = 0;
	}
	for ($i = 1; $i <= 2; $i++) {
		if ($orders_date_teacher_report->bLvlBreak[$i]) { // Reset counter and aggregation
			$orders_date_teacher_report->nCntRecs[$i] = 0;
		}
	}
	$orders_date_teacher_report->nCntRecs[0] += $orders_date_teacher_report->nDtlRecs;
	$orders_date_teacher_report->nCntRecs[1] += $orders_date_teacher_report->nDtlRecs;
	$orders_date_teacher_report->nCntRecs[2] += $orders_date_teacher_report->nDtlRecs;
?>
	<tr>
		<td valign="top" class="ewGroupHeader"><span class="phpmaker"><?php echo $orders_date_teacher->id->FldCaption() ?></span></td>
		<td valign="top" class="ewGroupHeader"><span class="phpmaker"><?php echo $orders_date_teacher->room->FldCaption() ?></span></td>
		<td valign="top" class="ewGroupHeader"><span class="phpmaker"><?php echo $orders_date_teacher->order_date->FldCaption() ?></span></td>
		<td valign="top" class="ewGroupHeader"><span class="phpmaker"><?php echo $orders_date_teacher->return_date->FldCaption() ?></span></td>
		<td valign="top" class="ewGroupHeader"><span class="phpmaker"><?php echo $orders_date_teacher->lesson->FldCaption() ?></span></td>
		<td valign="top" class="ewGroupHeader"><span class="phpmaker"><?php echo $orders_date_teacher->starts->FldCaption() ?></span></td>
		<td valign="top" class="ewGroupHeader"><span class="phpmaker"><?php echo $orders_date_teacher->ends->FldCaption() ?></span></td>
		<td valign="top" class="ewGroupHeader"><span class="phpmaker"><?php echo $orders_date_teacher->note->FldCaption() ?></span></td>
	</tr>
<?php
	while (!$rsdtl->EOF) {
		$orders_date_teacher->id->setDbValue($rsdtl->fields('id'));
		$orders_date_teacher->room->setDbValue($rsdtl->fields('room'));
		$orders_date_teacher->order_date->setDbValue($rsdtl->fields('order_date'));
		$orders_date_teacher->return_date->setDbValue($rsdtl->fields('return_date'));
		$orders_date_teacher->lesson->setDbValue($rsdtl->fields('lesson'));
		$orders_date_teacher->starts->setDbValue($rsdtl->fields('starts'));
		$orders_date_teacher->ends->setDbValue($rsdtl->fields('ends'));
		$orders_date_teacher->note->setDbValue($rsdtl->fields('note'));

		// Render for view
		$orders_date_teacher->RowType = EW_ROWTYPE_VIEW;
		$orders_date_teacher_report->RenderRow();
?>
	<tr>
		<td><span class="phpmaker">
<div<?php echo $orders_date_teacher->id->ViewAttributes() ?>><?php echo $orders_date_teacher->id->ViewValue ?></div></span></td>
		<td><span class="phpmaker">
<div<?php echo $orders_date_teacher->room->ViewAttributes() ?>><?php echo $orders_date_teacher->room->ViewValue ?></div></span></td>
		<td><span class="phpmaker">
<div<?php echo $orders_date_teacher->order_date->ViewAttributes() ?>><?php echo $orders_date_teacher->order_date->ViewValue ?></div></span></td>
		<td><span class="phpmaker">
<div<?php echo $orders_date_teacher->return_date->ViewAttributes() ?>><?php echo $orders_date_teacher->return_date->ViewValue ?></div></span></td>
		<td><span class="phpmaker">
<div<?php echo $orders_date_teacher->lesson->ViewAttributes() ?>>
<?php if ($orders_date_teacher->lesson->HrefValue <> "" || $orders_date_teacher->lesson->TooltipValue <> "" || $orders_date_teacher->note->ViewValue <> "") { ?>
<a href="javascript:void(0);" onmouseover="ew_ShowTooltip(this, 'tt_orders_date_teacher_x_lesson');" onmouseout="ew_HideTooltip();"><?php echo $orders_date_teacher->lesson->ViewValue ?></a>
<?php } else { ?>
<?php echo $orders_date_teacher->lesson->ViewValue ?>
<?php } ?>
</div><div id="tt_orders_date_teacher_x_lesson" style="display: none">
<?php if ($orders_date_teacher->lesson->TooltipValue <> "") { ?>
<?php echo $orders_date_teacher->lesson->TooltipValue ?>
<?php } else { ?>
<div<?php echo $orders_date_teacher->note->ViewAttributes() ?>><?php echo $orders_date_teacher->note->ViewValue ?></div>
<?php } ?>
</div></span></td>
		<td><span class="phpmaker">
<div<?php echo $orders_date_teacher->starts->ViewAttributes() ?>><?php echo $orders_date_teacher->starts->ViewValue ?></div></span></td>
		<td><span class="phpmaker">
<div<?php echo $orders_date_teacher->ends->ViewAttributes() ?>><?php echo $orders_date_teacher->ends->ViewValue ?></div></span></td>
		<td><span class="phpmaker">
<div<?php echo $orders_date_teacher->note->ViewAttributes() ?>><?php echo $orders_date_teacher->note->ViewValue ?></div></span></td>
	</tr>
<?php
		$rsdtl->MoveNext();
	}
	$rsdtl->Close();

	// Save old group data
	$orders_date_teacher_report->vGrps[0] = $orders_date_teacher->request_date->CurrentValue;
	$orders_date_teacher_report->vGrps[1] = $orders_date_teacher->teacher->CurrentValue;

	// Get next record
	$rs->MoveNext();
	if ($rs->EOF) {
		$orders_date_teacher_report->lRecCnt = 0; // EOF, force all level breaks
	} else {
		$orders_date_teacher->request_date->setDbValue($rs->fields('request_date'));
		$orders_date_teacher->teacher->setDbValue($rs->fields('teacher'));
	}
	$orders_date_teacher_report->ChkLvlBreak();

	// Show footers
	if ($orders_date_teacher_report->bLvlBreak[2]) {
		$orders_date_teacher->teacher->CurrentValue = $orders_date_teacher_report->vGrps[1];

		// Render row for view
		$orders_date_teacher->RowType = EW_ROWTYPE_VIEW;
		$orders_date_teacher_report->RenderRow();
		$orders_date_teacher->teacher->CurrentValue = $orders_date_teacher->teacher->DbValue;
?>
<?php
}
	if ($orders_date_teacher_report->bLvlBreak[1]) {
		$orders_date_teacher->request_date->CurrentValue = $orders_date_teacher_report->vGrps[0];

		// Render row for view
		$orders_date_teacher->RowType = EW_ROWTYPE_VIEW;
		$orders_date_teacher_report->RenderRow();
		$orders_date_teacher->request_date->CurrentValue = $orders_date_teacher->request_date->DbValue;
?>
<?php
}
}

// Close recordset
$rs->Close();
?>
	<tr><td colspan=8><span class="phpmaker">&nbsp;<br></span></td></tr>
	<tr><td colspan=8 class="ewGrandSummary"><span class="phpmaker"><?php echo $Language->Phrase("RptGrandTotal") ?>&nbsp;(<?php echo ew_FormatNumber($orders_date_teacher_report->nCntRecs[0], 0) ?>&nbsp;<?php echo $Language->Phrase("RptDtlRec") ?>)</span></td></tr>
	<tr><td colspan=8><span class="phpmaker">&nbsp;<br></span></td></tr>
</table>
</form>
<?php if ($orders_date_teacher->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
$orders_date_teacher_report->Page_Terminate();
?>
<?php

//
// Page class
//
class corders_date_teacher_report {

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

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

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

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

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		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() {
		return TRUE;
	}

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

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

		// Table object (orders_date_teacher)
		$GLOBALS["orders_date_teacher"] = new corders_date_teacher();

		// Initialize URLs
		$this->ExportPrintUrl = $this->PageUrl() . "export=print";
		$this->ExportExcelUrl = $this->PageUrl() . "export=excel";
		$this->ExportWordUrl = $this->PageUrl() . "export=word";

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

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

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'orders_date_teacher', 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_date_teacher;

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

		// Get export parameters
		if (@$_GET["export"] <> "") {
			$orders_date_teacher->Export = $_GET["export"];
		}
		$gsExport = $orders_date_teacher->Export; // Get export parameter, used in header
		$gsExportFile = $orders_date_teacher->TableVar; // Get export file, used in header
		if ($orders_date_teacher->Export == "excel") {
			header('Content-Type: application/vnd.ms-excel;charset=utf-8');
			header('Content-Disposition: attachment; filename=' . $gsExportFile .'.xls');
		}
		if ($orders_date_teacher->Export == "word") {
			header('Content-Type: application/vnd.ms-word;charset=utf-8');
			header('Content-Disposition: attachment; filename=' . $gsExportFile .'.doc');
		}

		// 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 $lRecCnt = 0;
	var $sSql = "";
	var $sFilter = "";
	var $sTblDefaultFilter = "";
	var $sDbMasterFilter = "";
	var $sDbDetailFilter = "";
	var $bMasterRecordExists;
	var $sCmd = "";
	var $lDtlRecs;
	var $vGrps;
	var $nCntRecs;
	var $bLvlBreak;
	var $nTotals;
	var $nMaxs;
	var $nMins;

	//
	// Page main
	//
	function Page_Main() {
		global $Language, $orders_date_teacher;
		$this->vGrps =& ew_InitArray(3, NULL);
		$this->nCntRecs =& ew_InitArray(3, 0);
		$this->bLvlBreak =& ew_InitArray(3, FALSE);
		$this->nTotals =& ew_Init2DArray(3, 9, 0);
		$this->nMaxs =& ew_Init2DArray(3, 9, 0);
		$this->nMins =& ew_Init2DArray(3, 9, 0);

		// Get reset command
		if (@$_GET["cmd"] <> "") {
			$sCmd = $_GET["cmd"];

			// Reset master/detail
			if (strtolower($sCmd) == "resetall") {
				$orders_date_teacher->setMasterFilter(""); // Clear master filter
				$this->sDbMasterFilter = "";
				$orders_date_teacher->setDetailFilter(""); // Clear detail filter
				$this->sDbDetailFilter = "";
			}
		}

		// Set up master/detail parameters
		$this->SetUpMasterDetail();

		// Restore master/detail filter
		$this->sDbMasterFilter = $orders_date_teacher->getMasterFilter(); // Restore master filter
		$this->sDbDetailFilter = $orders_date_teacher->getDetailFilter(); // Restore detail filter

		// Build master record SQL
		global $useraccounts;
		if ($orders_date_teacher->getMasterFilter() <> "" && $orders_date_teacher->getCurrentMasterTable() == "useraccounts") {
			$rsmaster = $useraccounts->LoadRs($orders_date_teacher->getMasterFilter());
			$this->bMasterRecordExists = ($rsmaster && !$rsmaster->EOF);
			if (!$this->bMasterRecordExists) {
				$orders_date_teacher->setMasterFilter(""); // Clear master filter
				$orders_date_teacher->setDetailFilter(""); // Clear detail filter
				$this->setMessage($Language->Phrase("NoRecord")); // Set no record message
				$this->Page_Terminate("useraccountslist.php"); // Return to master page
			} else {
				$useraccounts->LoadListRowValues($rsmaster);
				$useraccounts->RowType = EW_ROWTYPE_MASTER; // Master row
				$useraccounts->RenderListRow();
				$rsmaster->Close();
			}
		}
	}

	// Check level break
	function ChkLvlBreak() {
		global $orders_date_teacher;
		$this->bLvlBreak[1] = FALSE;
		$this->bLvlBreak[2] = FALSE;
		if ($this->lRecCnt == 0) { // Start Or End of Recordset
			$this->bLvlBreak[1] = TRUE;
			$this->bLvlBreak[2] = TRUE;
		} else {
			if (!ew_CompareValue($orders_date_teacher->request_date->CurrentValue, $this->vGrps[0])) {
				$this->bLvlBreak[1] = TRUE;
				$this->bLvlBreak[2] = TRUE;
			}
			if (!ew_CompareValue($orders_date_teacher->teacher->CurrentValue, $this->vGrps[1])) {
				$this->bLvlBreak[2] = TRUE;
			}
		}
	}

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

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

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

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

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

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

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

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

		// starts
		$orders_date_teacher->starts->CellCssStyle = ""; $orders_date_teacher->starts->CellCssClass = "";
		$orders_date_teacher->starts->CellAttrs = array(); $orders_date_teacher->starts->ViewAttrs = array(); $orders_date_teacher->starts->EditAttrs = array();

		// ends
		$orders_date_teacher->ends->CellCssStyle = ""; $orders_date_teacher->ends->CellCssClass = "";
		$orders_date_teacher->ends->CellAttrs = array(); $orders_date_teacher->ends->ViewAttrs = array(); $orders_date_teacher->ends->EditAttrs = array();

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

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

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

			// room
			$orders_date_teacher->room->ViewValue = $orders_date_teacher->room->CurrentValue;
			$orders_date_teacher->room->CssStyle = "";
			$orders_date_teacher->room->CssClass = "";
			$orders_date_teacher->room->ViewCustomAttributes = "";

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

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

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

			// lesson
			$orders_date_teacher->lesson->ViewValue = $orders_date_teacher->lesson->CurrentValue;
			$orders_date_teacher->lesson->CssStyle = "";
			$orders_date_teacher->lesson->CssClass = "";
			$orders_date_teacher->lesson->ViewCustomAttributes = "";

			// starts
			$orders_date_teacher->starts->ViewValue = $orders_date_teacher->starts->CurrentValue;
			$orders_date_teacher->starts->ViewValue = ew_FormatDateTime($orders_date_teacher->starts->ViewValue, 4);
			$orders_date_teacher->starts->CssStyle = "";
			$orders_date_teacher->starts->CssClass = "";
			$orders_date_teacher->starts->ViewCustomAttributes = "";

			// ends
			$orders_date_teacher->ends->ViewValue = $orders_date_teacher->ends->CurrentValue;
			$orders_date_teacher->ends->ViewValue = ew_FormatDateTime($orders_date_teacher->ends->ViewValue, 4);
			$orders_date_teacher->ends->CssStyle = "";
			$orders_date_teacher->ends->CssClass = "";
			$orders_date_teacher->ends->ViewCustomAttributes = "";

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

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

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

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

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

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

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

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

			// starts
			$orders_date_teacher->starts->HrefValue = "";
			$orders_date_teacher->starts->TooltipValue = "";

			// ends
			$orders_date_teacher->ends->HrefValue = "";
			$orders_date_teacher->ends->TooltipValue = "";

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

			// note
			$orders_date_teacher->note->HrefValue = "";
			$orders_date_teacher->note->TooltipValue = "";
		}
	}

	// Set up master/detail based on QueryString
	function SetUpMasterDetail() {
		global $orders_date_teacher;
		$bValidMaster = FALSE;

		// Get the keys for master table
		if (@$_GET[EW_TABLE_SHOW_MASTER] <> "") {
			$sMasterTblVar = $_GET[EW_TABLE_SHOW_MASTER];
			if ($sMasterTblVar == "") {
				$bValidMaster = TRUE;
				$this->sDbMasterFilter = "";
				$this->sDbDetailFilter = "";
			}
			if ($sMasterTblVar == "useraccounts") {
				$bValidMaster = TRUE;
				$this->sDbMasterFilter = $orders_date_teacher->SqlMasterFilter_useraccounts();
				$this->sDbDetailFilter = $orders_date_teacher->SqlDetailFilter_useraccounts();
				if (@$_GET["username"] <> "") {
					$GLOBALS["useraccounts"]->username->setQueryStringValue($_GET["username"]);
					$orders_date_teacher->teacher->setQueryStringValue($GLOBALS["useraccounts"]->username->QueryStringValue);
					$orders_date_teacher->teacher->setSessionValue($orders_date_teacher->teacher->QueryStringValue);
					$this->sDbMasterFilter = str_replace("@username@", ew_AdjustSql($GLOBALS["useraccounts"]->username->QueryStringValue), $this->sDbMasterFilter);
					$this->sDbDetailFilter = str_replace("@teacher@", ew_AdjustSql($GLOBALS["useraccounts"]->username->QueryStringValue), $this->sDbDetailFilter);
				} else {
					$bValidMaster = FALSE;
				}
			}
		}
		if ($bValidMaster) {

			// Save current master table
			$orders_date_teacher->setCurrentMasterTable($sMasterTblVar);
			$orders_date_teacher->setMasterFilter($this->sDbMasterFilter); // Set up master filter
			$orders_date_teacher->setDetailFilter($this->sDbDetailFilter); // Set up detail filter

			// Clear previous master key from Session
			if ($sMasterTblVar <> "useraccounts") {
				if ($orders_date_teacher->teacher->QueryStringValue == "") $orders_date_teacher->teacher->setSessionValue("");
			}
		} else {
			$this->sDbMasterFilter = $orders_date_teacher->getMasterFilter(); //  Restore master filter
			$this->sDbDetailFilter = $orders_date_teacher->getDetailFilter(); // Restore detail filter
		}
	}

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