<?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 "unitinfo.php" ?>
<?php include "useraccountsinfo.php" ?>
<?php include "userfn7.php" ?>
<?php
// Create page object
$unit_view = new cunit_view();
$Page =& $unit_view;
// Page init
$unit_view->Page_Init();
// Page main
$unit_view->Page_Main();
?>
<?php include "header.php" ?>
<?php if ($unit->Export == "") { ?>
<script type="text/javascript">
<!--
// Create page object
var unit_view = new ew_Page("unit_view");
// page properties
unit_view.PageID = "view"; // page ID
unit_view.FormID = "funitview"; // form ID
var EW_PAGE_ID = unit_view.PageID; // for backward compatibility
// extend page with Form_CustomValidate function
unit_view.Form_CustomValidate =
function(fobj) { // DO NOT CHANGE THIS LINE!
// Your custom validation code here, return false if invalid.
return true;
}
unit_view.SelectAllKey = function(elem) {
ew_SelectAll(elem);
ew_ClickAll(elem);
}
<?php if (EW_CLIENT_VALIDATE) { ?>
unit_view.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
unit_view.ValidateRequired = false; // no JavaScript validation
<?php } ?>
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js");
//-->
</script>
<?php } ?>
<p><span class="phpmaker"><?php echo $Language->Phrase("View") ?> <?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $unit->TableCaption() ?>
<br><br>
<?php if ($unit->Export == "") { ?>
<a href="<?php echo $unit_view->ListUrl ?>"><?php echo $Language->Phrase("BackToList") ?></a>
<?php if ($Security->CanAdd()) { ?>
<a href="<?php echo $unit_view->AddUrl ?>"><?php echo $Language->Phrase("ViewPageAddLink") ?></a>
<?php } ?>
<?php if ($Security->CanEdit()) { ?>
<a href="<?php echo $unit_view->EditUrl ?>"><?php echo $Language->Phrase("ViewPageEditLink") ?></a>
<?php } ?>
<?php if ($Security->CanAdd()) { ?>
<a href="<?php echo $unit_view->CopyUrl ?>"><?php echo $Language->Phrase("ViewPageCopyLink") ?></a>
<?php } ?>
<?php if ($Security->CanDelete()) { ?>
<a href="<?php echo $unit_view->DeleteUrl ?>"><?php echo $Language->Phrase("ViewPageDeleteLink") ?></a>
<?php } ?>
<a href="itemslist.php?<?php echo EW_TABLE_SHOW_MASTER ?>=unit&unit=<?php echo urlencode(strval($unit->unit->CurrentValue)) ?>"><?php echo $Language->Phrase("ViewPageDetailLink") ?><?php echo $Language->TablePhrase("items", "TblCaption") ?>
</a>
<?php if ($Security->AllowList('order_detail')) { ?>
<a href="order_detaillist.php?<?php echo EW_TABLE_SHOW_MASTER ?>=unit&unit=<?php echo urlencode(strval($unit->unit->CurrentValue)) ?>"><?php echo $Language->Phrase("ViewPageDetailLink") ?><?php echo $Language->TablePhrase("order_detail", "TblCaption") ?>
</a>
<?php } ?>
<?php } ?>
</span></p>
<?php
if (EW_DEBUG_ENABLED)
echo ew_DebugMsg();
$unit_view->ShowMessage();
?>
<p>
<?php if ($unit->Export == "") { ?>
<form name="ewpagerform" id="ewpagerform" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
<table border="0" cellspacing="0" cellpadding="0" class="ewPager">
<tr>
<td nowrap>
<?php if (!isset($unit_view->Pager)) $unit_view->Pager = new cPrevNextPager($unit_view->lStartRec, $unit_view->lDisplayRecs, $unit_view->lTotalRecs) ?>
<?php if ($unit_view->Pager->RecordCount > 0) { ?>
<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpmaker"><?php echo $Language->Phrase("Page") ?> </span></td>
<!--first page button-->
<?php if ($unit_view->Pager->FirstButton->Enabled) { ?>
<td><a href="<?php echo $unit_view->PageUrl() ?>start=<?php echo $unit_view->Pager->FirstButton->Start ?>"><img src="images/first.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></a></td>
<?php } else { ?>
<td><img src="images/firstdisab.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
<?php } ?>
<!--previous page button-->
<?php if ($unit_view->Pager->PrevButton->Enabled) { ?>
<td><a href="<?php echo $unit_view->PageUrl() ?>start=<?php echo $unit_view->Pager->PrevButton->Start ?>"><img src="images/prev.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></a></td>
<?php } else { ?>
<td><img src="images/prevdisab.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
<?php } ?>
<!--current page number-->
<td><input type="text" name="<?php echo EW_TABLE_PAGE_NO ?>" id="<?php echo EW_TABLE_PAGE_NO ?>" value="<?php echo $unit_view->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
<?php if ($unit_view->Pager->NextButton->Enabled) { ?>
<td><a href="<?php echo $unit_view->PageUrl() ?>start=<?php echo $unit_view->Pager->NextButton->Start ?>"><img src="images/next.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></a></td>
<?php } else { ?>
<td><img src="images/nextdisab.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
<?php } ?>
<!--last page button-->
<?php if ($unit_view->Pager->LastButton->Enabled) { ?>
<td><a href="<?php echo $unit_view->PageUrl() ?>start=<?php echo $unit_view->Pager->LastButton->Start ?>"><img src="images/last.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></a></td>
<?php } else { ?>
<td><img src="images/lastdisab.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
<?php } ?>
<td><span class="phpmaker"> <?php echo $Language->Phrase("of") ?> <?php echo $unit_view->Pager->PageCount ?></span></td>
</tr></table>
<?php } else { ?>
<?php if ($Security->CanList()) { ?>
<?php if ($unit_view->sSrchWhere == "0=101") { ?>
<span class="phpmaker"><?php echo $Language->Phrase("EnterSearchCriteria") ?></span>
<?php } else { ?>
<span class="phpmaker"><?php echo $Language->Phrase("NoRecord") ?></span>
<?php } ?>
<?php } else { ?>
<span class="phpmaker"><?php echo $Language->Phrase("NoPermission") ?></span>
<?php } ?>
<?php } ?>
</td>
</tr>
</table>
</form>
<br>
<?php } ?>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?php if ($unit->unit->Visible) { // unit ?>
<tr<?php echo $unit->unit->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $unit->unit->FldCaption() ?></td>
<td<?php echo $unit->unit->CellAttributes() ?>>
<div<?php echo $unit->unit->ViewAttributes() ?>><?php echo $unit->unit->ViewValue ?></div></td>
</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<?php if ($unit->Export == "") { ?>
<br>
<form name="ewpagerform" id="ewpagerform" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
<table border="0" cellspacing="0" cellpadding="0" class="ewPager">
<tr>
<td nowrap>
<?php if (!isset($unit_view->Pager)) $unit_view->Pager = new cPrevNextPager($unit_view->lStartRec, $unit_view->lDisplayRecs, $unit_view->lTotalRecs) ?>
<?php if ($unit_view->Pager->RecordCount > 0) { ?>
<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpmaker"><?php echo $Language->Phrase("Page") ?> </span></td>
<!--first page button-->
<?php if ($unit_view->Pager->FirstButton->Enabled) { ?>
<td><a href="<?php echo $unit_view->PageUrl() ?>start=<?php echo $unit_view->Pager->FirstButton->Start ?>"><img src="images/first.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></a></td>
<?php } else { ?>
<td><img src="images/firstdisab.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
<?php } ?>
<!--previous page button-->
<?php if ($unit_view->Pager->PrevButton->Enabled) { ?>
<td><a href="<?php echo $unit_view->PageUrl() ?>start=<?php echo $unit_view->Pager->PrevButton->Start ?>"><img src="images/prev.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></a></td>
<?php } else { ?>
<td><img src="images/prevdisab.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
<?php } ?>
<!--current page number-->
<td><input type="text" name="<?php echo EW_TABLE_PAGE_NO ?>" id="<?php echo EW_TABLE_PAGE_NO ?>" value="<?php echo $unit_view->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
<?php if ($unit_view->Pager->NextButton->Enabled) { ?>
<td><a href="<?php echo $unit_view->PageUrl() ?>start=<?php echo $unit_view->Pager->NextButton->Start ?>"><img src="images/next.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></a></td>
<?php } else { ?>
<td><img src="images/nextdisab.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
<?php } ?>
<!--last page button-->
<?php if ($unit_view->Pager->LastButton->Enabled) { ?>
<td><a href="<?php echo $unit_view->PageUrl() ?>start=<?php echo $unit_view->Pager->LastButton->Start ?>"><img src="images/last.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></a></td>
<?php } else { ?>
<td><img src="images/lastdisab.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
<?php } ?>
<td><span class="phpmaker"> <?php echo $Language->Phrase("of") ?> <?php echo $unit_view->Pager->PageCount ?></span></td>
</tr></table>
<?php } else { ?>
<?php if ($Security->CanList()) { ?>
<?php if ($unit_view->sSrchWhere == "0=101") { ?>
<span class="phpmaker"><?php echo $Language->Phrase("EnterSearchCriteria") ?></span>
<?php } else { ?>
<span class="phpmaker"><?php echo $Language->Phrase("NoRecord") ?></span>
<?php } ?>
<?php } else { ?>
<span class="phpmaker"><?php echo $Language->Phrase("NoPermission") ?></span>
<?php } ?>
<?php } ?>
</td>
</tr>
</table>
</form>
<?php } ?>
<p>
<?php if ($unit->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
$unit_view->Page_Terminate();
?>
<?php
//
// Page class
//
class cunit_view {
// Page ID
var $PageID = 'view';
// Table name
var $TableName = 'unit';
// Page object name
var $PageObjName = 'unit_view';
// Page name
function PageName() {
return ew_CurrentPage();
}
// Page URL
function PageUrl() {
$PageUrl = ew_CurrentPage() . "?";
global $unit;
if ($unit->UseTokenInUrl) $PageUrl .= "t=" . $unit->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, $unit;
if ($unit->UseTokenInUrl) {
if ($objForm)
return ($unit->TableVar == $objForm->GetValue("t"));
if (@$_GET["t"] <> "")
return ($unit->TableVar == $_GET["t"]);
} else {
return TRUE;
}
}
//
// Page class constructor
//
function cunit_view() {
global $conn, $Language;
// Language object
$Language = new cLanguage();
// Table object (unit)
$GLOBALS["unit"] = new cunit();
// Table object (useraccounts)
$GLOBALS['useraccounts'] = new cuseraccounts();
// Page ID
if (!defined("EW_PAGE_ID"))
define("EW_PAGE_ID", 'view', TRUE);
// Table name (for backward compatibility)
if (!defined("EW_TABLE_NAME"))
define("EW_TABLE_NAME", 'unit', 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 $unit;
// Security
$Security = new cAdvancedSecurity();
if (!$Security->IsLoggedIn()) $Security->AutoLogin();
if (!$Security->IsLoggedIn()) {
$Security->SaveLastUrl();
$this->Page_Terminate("login.php");
}
$Security->TablePermission_Loading();
$Security->LoadCurrentUserLevel($this->TableName);
$Security->TablePermission_Loaded();
if (!$Security->IsLoggedIn()) {
$Security->SaveLastUrl();
$this->Page_Terminate("login.php");
}
if (!$Security->CanView()) {
$Security->SaveLastUrl();
$this->Page_Terminate("unitlist.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 $lDisplayRecs = 1;
var $lStartRec;
var $lStopRec;
var $lTotalRecs = 0;
var $lRecRange = 10;
var $lRecCnt;
var $arRecKey = array();
//
// Page main
//
function Page_Main() {
global $Language, $unit;
// Load current record
$bLoadCurrentRecord = FALSE;
$sReturnUrl = "";
$bMatchRecord = FALSE;
if ($this->IsPageRequest()) { // Validate request
if (@$_GET["unit"] <> "") {
$unit->unit->setQueryStringValue($_GET["unit"]);
$this->arRecKey["unit"] = $unit->unit->QueryStringValue;
} else {
$bLoadCurrentRecord = TRUE;
}
// Get action
$unit->CurrentAction = "I"; // Display form
switch ($unit->CurrentAction) {
case "I": // Get a record to display
$this->lStartRec = 1; // Initialize start position
if ($rs = $this->LoadRecordset()) // Load records
$this->lTotalRecs = $rs->RecordCount(); // Get record count
if ($this->lTotalRecs <= 0) { // No record found
$this->setMessage($Language->Phrase("NoRecord")); // Set no record message
$this->Page_Terminate("unitlist.php"); // Return to list page
} elseif ($bLoadCurrentRecord) { // Load current record position
$this->SetUpStartRec(); // Set up start record position
// Point to current record
if (intval($this->lStartRec) <= intval($this->lTotalRecs)) {
$bMatchRecord = TRUE;
$rs->Move($this->lStartRec-1);
}
} else { // Match key values
while (!$rs->EOF) {
if (strval($unit->unit->CurrentValue) == strval($rs->fields('unit'))) {
$unit->setStartRecordNumber($this->lStartRec); // Save record position
$bMatchRecord = TRUE;
break;
} else {
$this->lStartRec++;
$rs->MoveNext();
}
}
}
if (!$bMatchRecord) {
$this->setMessage($Language->Phrase("NoRecord")); // Set no record message
$sReturnUrl = "unitlist.php"; // No matching record, return to list
} else {
$this->LoadRowValues($rs); // Load row values
}
}
} else {
$sReturnUrl = "unitlist.php"; // Not page request, return to list
}
if ($sReturnUrl <> "")
$this->Page_Terminate($sReturnUrl);
// Render row
$unit->RowType = EW_ROWTYPE_VIEW;
$this->RenderRow();
}
// Set up starting record parameters
function SetUpStartRec() {
global $unit;
if ($this->lDisplayRecs == 0)
return;
if ($this->IsPageRequest()) { // Validate request
if (@$_GET[EW_TABLE_START_REC] <> "") { // Check for "start" parameter
$this->lStartRec = $_GET[EW_TABLE_START_REC];
$unit->setStartRecordNumber($this->lStartRec);
} elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
$this->nPageNo = $_GET[EW_TABLE_PAGE_NO];
if (is_numeric($this->nPageNo)) {
$this->lStartRec = ($this->nPageNo-1)*$this->lDisplayRecs+1;
if ($this->lStartRec <= 0) {
$this->lStartRec = 1;
} elseif ($this->lStartRec >= intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1) {
$this->lStartRec = intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1;
}
$unit->setStartRecordNumber($this->lStartRec);
}
}
}
$this->lStartRec = $unit->getStartRecordNumber();
// Check if correct start record counter
if (!is_numeric($this->lStartRec) || $this->lStartRec == "") { // Avoid invalid start record counter
$this->lStartRec = 1; // Reset start record counter
$unit->setStartRecordNumber($this->lStartRec);
} elseif (intval($this->lStartRec) > intval($this->lTotalRecs)) { // Avoid starting record > total records
$this->lStartRec = intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1; // Point to last page first record
$unit->setStartRecordNumber($this->lStartRec);
} elseif (($this->lStartRec-1) % $this->lDisplayRecs <> 0) {
$this->lStartRec = intval(($this->lStartRec-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1; // Point to page boundary
$unit->setStartRecordNumber($this->lStartRec);
}
}
// Load recordset
function LoadRecordset($offset = -1, $rowcnt = -1) {
global $conn, $unit;
// Call Recordset Selecting event
$unit->Recordset_Selecting($unit->CurrentFilter);
// Load List page SQL
$sSql = $unit->SelectSQL();
if ($offset > -1 && $rowcnt > -1)
$sSql .= " LIMIT $offset, $rowcnt";
// Load recordset
$rs = ew_LoadRecordset($sSql);
// Call Recordset Selected event
$unit->Recordset_Selected($rs);
return $rs;
}
// Load row based on key values
function LoadRow() {
global $conn, $Security, $unit;
$sFilter = $unit->KeyFilter();
// Call Row Selecting event
$unit->Row_Selecting($sFilter);
// Load SQL based on filter
$unit->CurrentFilter = $sFilter;
$sSql = $unit->SQL();
$res = FALSE;
$rs = ew_LoadRecordset($sSql);
if ($rs && !$rs->EOF) {
$res = TRUE;
$this->LoadRowValues($rs); // Load row values
// Call Row Selected event
$unit->Row_Selected($rs);
$rs->Close();
}
return $res;
}
// Load row values from recordset
function LoadRowValues(&$rs) {
global $conn, $unit;
$unit->unit->setDbValue($rs->fields('unit'));
}
// Render row values based on field settings
function RenderRow() {
global $conn, $Security, $Language, $unit;
// Initialize URLs
$this->ExportPrintUrl = $this->PageUrl() . "export=print&" . "unit=" . urlencode($unit->unit->CurrentValue);
$this->ExportHtmlUrl = $this->PageUrl() . "export=html&" . "unit=" . urlencode($unit->unit->CurrentValue);
$this->ExportExcelUrl = $this->PageUrl() . "export=excel&" . "unit=" . urlencode($unit->unit->CurrentValue);
$this->ExportWordUrl = $this->PageUrl() . "export=word&" . "unit=" . urlencode($unit->unit->CurrentValue);
$this->ExportXmlUrl = $this->PageUrl() . "export=xml&" . "unit=" . urlencode($unit->unit->CurrentValue);
$this->ExportCsvUrl = $this->PageUrl() . "export=csv&" . "unit=" . urlencode($unit->unit->CurrentValue);
$this->AddUrl = $unit->AddUrl();
$this->EditUrl = $unit->EditUrl();
$this->CopyUrl = $unit->CopyUrl();
$this->DeleteUrl = $unit->DeleteUrl();
$this->ListUrl = $unit->ListUrl();
// Call Row_Rendering event
$unit->Row_Rendering();
// Common render codes for all row types
// unit
$unit->unit->CellCssStyle = ""; $unit->unit->CellCssClass = "";
$unit->unit->CellAttrs = array(); $unit->unit->ViewAttrs = array(); $unit->unit->EditAttrs = array();
if ($unit->RowType == EW_ROWTYPE_VIEW) { // View row
// unit
$unit->unit->ViewValue = $unit->unit->CurrentValue;
$unit->unit->CssStyle = "";
$unit->unit->CssClass = "";
$unit->unit->ViewCustomAttributes = "";
// unit
$unit->unit->HrefValue = "";
$unit->unit->TooltipValue = "";
}
// Call Row Rendered event
if ($unit->RowType <> EW_ROWTYPE_AGGREGATEINIT)
$unit->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";
}
}
?>