<?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_list = new cunit_list();
$Page =& $unit_list;
// Page init
$unit_list->Page_Init();
// Page main
$unit_list->Page_Main();
?>
<?php include "header.php" ?>
<?php if ($unit->Export == "") { ?>
<script type="text/javascript">
<!--
// Create page object
var unit_list = new ew_Page("unit_list");
// page properties
unit_list.PageID = "list"; // page ID
unit_list.FormID = "funitlist"; // form ID
var EW_PAGE_ID = unit_list.PageID; // for backward compatibility
// extend page with ValidateForm function
unit_list.ValidateForm = function(fobj) {
ew_PostAutoSuggest(fobj);
if (!this.ValidateRequired)
return true; // ignore validation
if (fobj.a_confirm && fobj.a_confirm.value == "F")
return true;
var i, elm, aelm, infix;
var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
var addcnt = 0;
for (i=0; i<rowcnt; i++) {
infix = (fobj.key_count) ? String(i+1) : "";
var chkthisrow = true;
if (fobj.a_list && fobj.a_list.value == "gridinsert")
chkthisrow = !(this.EmptyRow(fobj, infix));
else
chkthisrow = true;
if (chkthisrow) {
addcnt += 1;
elm = fobj.elements["x" + infix + "_unit"];
if (elm && !ew_HasValue(elm))
return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($unit->unit->FldCaption()) ?>");
// Call Form Custom Validate event
if (!this.Form_CustomValidate(fobj)) return false;
} // End Grid Add checking
}
if (fobj.a_list && fobj.a_list.value == "gridinsert" && addcnt == 0) { // No row added
alert(ewLanguage.Phrase("NoAddRecord"));
return false;
}
return true;
}
// Extend page with empty row check
unit_list.EmptyRow = function(fobj, infix) {
if (ew_ValueChanged(fobj, infix, "unit", false)) return false;
return true;
}
// extend page with Form_CustomValidate function
unit_list.Form_CustomValidate =
function(fobj) { // DO NOT CHANGE THIS LINE!
// Your custom validation code here, return false if invalid.
return true;
}
unit_list.SelectAllKey = function(elem) {
ew_SelectAll(elem);
ew_ClickAll(elem);
}
<?php if (EW_CLIENT_VALIDATE) { ?>
unit_list.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
unit_list.ValidateRequired = false; // no JavaScript validation
<?php } ?>
//-->
</script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];
//-->
</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 } ?>
<?php if ($unit->Export == "") { ?>
<?php } ?>
<?php
if ($unit->CurrentAction == "gridadd") {
$unit->CurrentFilter = "0=1";
$unit_list->lStartRec = 1;
if ($unit_list->lDisplayRecs <= 0)
$unit_list->lDisplayRecs = 10;
$unit_list->lTotalRecs = $unit_list->lDisplayRecs;
$unit_list->lStopRec = $unit_list->lDisplayRecs;
} else {
$bSelectLimit = EW_SELECT_LIMIT;
if ($bSelectLimit) {
$unit_list->lTotalRecs = $unit->SelectRecordCount();
} else {
if ($rs = $unit_list->LoadRecordset())
$unit_list->lTotalRecs = $rs->RecordCount();
}
$unit_list->lStartRec = 1;
if ($unit_list->lDisplayRecs <= 0 || ($unit->Export <> "" && $unit->ExportAll)) // Display all records
$unit_list->lDisplayRecs = $unit_list->lTotalRecs;
if (!($unit->Export <> "" && $unit->ExportAll))
$unit_list->SetUpStartRec(); // Set up start record position
if ($bSelectLimit)
$rs = $unit_list->LoadRecordset($unit_list->lStartRec-1, $unit_list->lDisplayRecs);
}
?>
<p><span class="phpmaker" style="white-space: nowrap;"><?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $unit->TableCaption() ?>
<?php if ($unit->Export == "" && $unit->CurrentAction == "") { ?>
<a href="<?php echo $unit_list->ExportPrintUrl ?>"><?php echo $Language->Phrase("PrinterFriendly") ?></a>
<a href="<?php echo $unit_list->ExportHtmlUrl ?>"><?php echo $Language->Phrase("ExportToHtml") ?></a>
<a href="<?php echo $unit_list->ExportExcelUrl ?>"><?php echo $Language->Phrase("ExportToExcel") ?></a>
<a href="<?php echo $unit_list->ExportWordUrl ?>"><?php echo $Language->Phrase("ExportToWord") ?></a>
<a href="<?php echo $unit_list->ExportCsvUrl ?>"><?php echo $Language->Phrase("ExportToCsv") ?></a>
<a name="emf_unit" id="emf_unit" href="javascript:void(0);" onclick="ew_EmailDialogShow({lnk:'emf_unit',hdr:ewLanguage.Phrase('ExportToEmail'),f:document.funitlist,sel:false});"><?php echo $Language->Phrase("ExportToEmail") ?></a>
<?php } ?>
</span></p>
<?php if ($Security->CanSearch()) { ?>
<?php if ($unit->Export == "" && $unit->CurrentAction == "") { ?>
<a href="javascript:ew_ToggleSearchPanel(unit_list);" style="text-decoration: none;"><img id="unit_list_SearchImage" src="images/collapse.gif" alt="" width="9" height="9" border="0"></a><span class="phpmaker"> <?php echo $Language->Phrase("Search") ?></span><br>
<div id="unit_list_SearchPanel">
<form name="funitlistsrch" id="funitlistsrch" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
<input type="hidden" id="t" name="t" value="unit">
<table class="ewBasicSearch">
<tr>
<td><span class="phpmaker">
<input type="text" name="<?php echo EW_TABLE_BASIC_SEARCH ?>" id="<?php echo EW_TABLE_BASIC_SEARCH ?>" size="20" value="<?php echo ew_HtmlEncode($unit->getSessionBasicSearchKeyword()) ?>">
<input type="Submit" name="Submit" id="Submit" value="<?php echo ew_BtnCaption($Language->Phrase("QuickSearchBtn")) ?>">
<a href="<?php echo $unit_list->PageUrl() ?>cmd=reset"><?php echo $Language->Phrase("ShowAll") ?></a>
</span></td>
</tr>
<tr>
<td><span class="phpmaker"><label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value=""<?php if ($unit->getSessionBasicSearchType() == "") { ?> checked="checked"<?php } ?>><?php echo $Language->Phrase("ExactPhrase") ?></label> <label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="AND"<?php if ($unit->getSessionBasicSearchType() == "AND") { ?> checked="checked"<?php } ?>><?php echo $Language->Phrase("AllWord") ?></label> <label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="OR"<?php if ($unit->getSessionBasicSearchType() == "OR") { ?> checked="checked"<?php } ?>><?php echo $Language->Phrase("AnyWord") ?></label></span></td>
</tr>
</table>
</form>
</div>
<?php } ?>
<?php } ?>
<?php
if (EW_DEBUG_ENABLED)
echo ew_DebugMsg();
$unit_list->ShowMessage();
?>
<br>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<?php if ($unit->Export == "") { ?>
<div class="ewGridUpperPanel">
<?php if ($unit->CurrentAction <> "gridadd" && $unit->CurrentAction <> "gridedit") { ?>
<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_list->Pager)) $unit_list->Pager = new cPrevNextPager($unit_list->lStartRec, $unit_list->lDisplayRecs, $unit_list->lTotalRecs) ?>
<?php if ($unit_list->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_list->Pager->FirstButton->Enabled) { ?>
<td><a href="<?php echo $unit_list->PageUrl() ?>start=<?php echo $unit_list->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_list->Pager->PrevButton->Enabled) { ?>
<td><a href="<?php echo $unit_list->PageUrl() ?>start=<?php echo $unit_list->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_list->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
<?php if ($unit_list->Pager->NextButton->Enabled) { ?>
<td><a href="<?php echo $unit_list->PageUrl() ?>start=<?php echo $unit_list->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_list->Pager->LastButton->Enabled) { ?>
<td><a href="<?php echo $unit_list->PageUrl() ?>start=<?php echo $unit_list->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_list->Pager->PageCount ?></span></td>
</tr></table>
</td>
<td> </td>
<td>
<span class="phpmaker"><?php echo $Language->Phrase("Record") ?> <?php echo $unit_list->Pager->FromIndex ?> <?php echo $Language->Phrase("To") ?> <?php echo $unit_list->Pager->ToIndex ?> <?php echo $Language->Phrase("Of") ?> <?php echo $unit_list->Pager->RecordCount ?></span>
<?php } else { ?>
<?php if ($Security->CanList()) { ?>
<?php if ($unit_list->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>
<?php if ($unit_list->lTotalRecs > 0) { ?>
<td> </td>
<td><table border="0" cellspacing="0" cellpadding="0"><tr><td><?php echo $Language->Phrase("RecordsPerPage") ?> </td><td>
<input type="hidden" id="t" name="t" value="unit">
<select name="<?php echo EW_TABLE_REC_PER_PAGE ?>" id="<?php echo EW_TABLE_REC_PER_PAGE ?>" onchange="this.form.submit();" class="phpmaker">
<option value="10"<?php if ($unit_list->lDisplayRecs == 10) { ?> selected="selected"<?php } ?>>10</option>
<option value="25"<?php if ($unit_list->lDisplayRecs == 25) { ?> selected="selected"<?php } ?>>25</option>
<option value="50"<?php if ($unit_list->lDisplayRecs == 50) { ?> selected="selected"<?php } ?>>50</option>
<option value="ALL"<?php if ($unit->getRecordsPerPage() == -1) { ?> selected="selected"<?php } ?>><?php echo $Language->Phrase("AllRecords") ?></option>
</select></td></tr></table>
</td>
<?php } ?>
</tr>
</table>
</form>
<?php } ?>
<span class="phpmaker">
<?php if ($unit->CurrentAction <> "gridadd" && $unit->CurrentAction <> "gridedit") { // Not grid add/edit mode ?>
<?php if ($Security->CanAdd()) { ?>
<a href="<?php echo $unit_list->AddUrl ?>"><?php echo $Language->Phrase("AddLink") ?></a>
<a href="<?php echo $unit_list->GridAddUrl ?>"><?php echo $Language->Phrase("GridAddLink") ?></a>
<?php } ?>
<?php if ($Security->CanEdit()) { ?>
<?php if ($unit_list->lTotalRecs > 0) { ?>
<a href="<?php echo $unit_list->GridEditUrl ?>"><?php echo $Language->Phrase("GridEditLink") ?></a>
<?php } ?>
<?php } ?>
<?php if ($unit_list->lTotalRecs > 0) { ?>
<?php if ($Security->CanDelete()) { ?>
<a href="" onclick="ew_SubmitSelected(document.funitlist, '<?php echo $unit_list->MultiDeleteUrl ?>');return false;"><?php echo $Language->Phrase("DeleteSelectedLink") ?></a>
<?php } ?>
<?php } ?>
<?php } else { // Grid add/edit mode ?>
<?php if ($unit->CurrentAction == "gridadd") { ?>
<a href="" onclick="f=document.funitlist;if(unit_list.ValidateForm(f))f.submit();return false;"><?php echo $Language->Phrase("GridInsertLink") ?></a>
<a href="<?php echo $unit_list->PageUrl() ?>a=cancel"><?php echo $Language->Phrase("GridCancelLink") ?></a>
<?php } ?>
<?php if ($unit->CurrentAction == "gridedit") { ?>
<a href="" onclick="f=document.funitlist;if(unit_list.ValidateForm(f))f.submit();return false;"><?php echo $Language->Phrase("GridSaveLink") ?></a>
<a href="<?php echo $unit_list->PageUrl() ?>a=cancel"><?php echo $Language->Phrase("GridCancelLink") ?></a>
<?php } ?>
<?php } ?>
</span>
</div>
<?php } ?>
<form name="funitlist" id="funitlist" class="ewForm" action="<?php echo ew_CurrentPage() ?>" method="post">
<input type="hidden" name="t" id="t" value="unit">
<div id="gmp_unit" class="ewGridMiddlePanel">
<?php if ($unit_list->lTotalRecs > 0) { ?>
<table cellspacing="0" rowhighlightclass="ewTableHighlightRow" rowselectclass="ewTableSelectRow" roweditclass="ewTableEditRow" class="ewTable ewTableSeparate">
<?php echo $unit->TableCustomInnerHtml ?>
<thead><!-- Table header -->
<tr class="ewTableHeader">
<?php
// Render list options
$unit_list->RenderListOptions();
// Render list options (header, left)
$unit_list->ListOptions->Render("header", "left");
?>
<?php if ($unit->unit->Visible) { // unit ?>
<?php if ($unit->SortUrl($unit->unit) == "") { ?>
<td><?php echo $unit->unit->FldCaption() ?></td>
<?php } else { ?>
<td><div class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $unit->SortUrl($unit->unit) ?>',1);">
<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $unit->unit->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($unit->unit->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($unit->unit->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
</div></td>
<?php } ?>
<?php } ?>
<?php
// Render list options (header, right)
$unit_list->ListOptions->Render("header", "right");
?>
</tr>
</thead>
<?php
if ($unit->ExportAll && $unit->Export <> "") {
$unit_list->lStopRec = $unit_list->lTotalRecs;
} else {
$unit_list->lStopRec = $unit_list->lStartRec + $unit_list->lDisplayRecs - 1; // Set the last record to display
}
$unit_list->lRecCount = $unit_list->lStartRec - 1;
if ($rs && !$rs->EOF) {
$rs->MoveFirst();
if (!$bSelectLimit && $unit_list->lStartRec > 1)
$rs->Move($unit_list->lStartRec - 1);
}
// Initialize aggregate
$unit->RowType = EW_ROWTYPE_AGGREGATEINIT;
$unit_list->RenderRow();
$unit_list->lRowCnt = 0;
if ($unit->CurrentAction == "gridadd")
$unit_list->lRowIndex = 0;
if ($unit->CurrentAction == "gridedit")
$unit_list->lRowIndex = 0;
while (($unit->CurrentAction == "gridadd" || !$rs->EOF) &&
$unit_list->lRecCount < $unit_list->lStopRec) {
$unit_list->lRecCount++;
if (intval($unit_list->lRecCount) >= intval($unit_list->lStartRec)) {
$unit_list->lRowCnt++;
if ($unit->CurrentAction == "gridadd" || $unit->CurrentAction == "gridedit")
$unit_list->lRowIndex++;
// Init row class and style
$unit->CssClass = "";
$unit->CssStyle = "";
$unit->RowAttrs = array('onmouseover'=>'ew_MouseOver(event, this);', 'onmouseout'=>'ew_MouseOut(event, this);', 'onclick'=>'ew_Click(event, this);');
if ($unit->CurrentAction == "gridadd") {
$unit_list->LoadDefaultValues(); // Load default values
} else {
$unit_list->LoadRowValues($rs); // Load row values
}
$unit->RowType = EW_ROWTYPE_VIEW; // Render view
if ($unit->CurrentAction == "gridadd") // Grid add
$unit->RowType = EW_ROWTYPE_ADD; // Render add
if ($unit->CurrentAction == "gridadd" && $unit->EventCancelled) // Insert failed
$unit_list->RestoreCurrentRowFormValues($unit_list->lRowIndex); // Restore form values
if ($unit->CurrentAction == "gridedit") { // Grid edit
$unit->RowType = EW_ROWTYPE_EDIT; // Render edit
}
if ($unit->RowType == EW_ROWTYPE_EDIT && $unit->EventCancelled) { // Update failed
if ($unit->CurrentAction == "gridedit")
$unit_list->RestoreCurrentRowFormValues($unit_list->lRowIndex); // Restore form values
}
if ($unit->RowType == EW_ROWTYPE_EDIT) // Edit row
$unit_list->lEditRowCnt++;
if ($unit->RowType == EW_ROWTYPE_ADD || $unit->RowType == EW_ROWTYPE_EDIT) { // Add / Edit row
$unit->RowAttrs = array_merge($unit->RowAttrs, array('onmouseover'=>'this.edit=true;ew_MouseOver(event, this);', 'onmouseout'=>'ew_MouseOut(event, this);', 'onclick'=>'ew_Click(event, this);'));
$unit->CssClass = "ewTableEditRow";
}
// Render row
$unit_list->RenderRow();
// Render list options
$unit_list->RenderListOptions();
?>
<tr<?php echo $unit->RowAttributes() ?>>
<?php
// Render list options (body, left)
$unit_list->ListOptions->Render("body", "left");
?>
<?php if ($unit->unit->Visible) { // unit ?>
<td<?php echo $unit->unit->CellAttributes() ?>>
<?php if ($unit->RowType == EW_ROWTYPE_ADD) { // Add record ?>
<input type="text" name="x<?php echo $unit_list->lRowIndex ?>_unit" id="x<?php echo $unit_list->lRowIndex ?>_unit" title="<?php echo $unit->unit->FldTitle() ?>" size="30" maxlength="5" value="<?php echo $unit->unit->EditValue ?>"<?php echo $unit->unit->EditAttributes() ?>>
<input type="hidden" name="o<?php echo $unit_list->lRowIndex ?>_unit" id="o<?php echo $unit_list->lRowIndex ?>_unit" value="<?php echo ew_HtmlEncode($unit->unit->OldValue) ?>">
<?php } ?>
<?php if ($unit->RowType == EW_ROWTYPE_EDIT) { // Edit record ?>
<div<?php echo $unit->unit->ViewAttributes() ?>><?php echo $unit->unit->EditValue ?></div><input type="hidden" name="x<?php echo $unit_list->lRowIndex ?>_unit" id="x<?php echo $unit_list->lRowIndex ?>_unit" value="<?php echo ew_HtmlEncode($unit->unit->CurrentValue) ?>">
<?php } ?>
<?php if ($unit->RowType == EW_ROWTYPE_VIEW) { // View record ?>
<div<?php echo $unit->unit->ViewAttributes() ?>><?php echo $unit->unit->ListViewValue() ?></div>
<?php } ?>
</td>
<?php } ?>
<?php
// Render list options (body, right)
$unit_list->ListOptions->Render("body", "right");
?>
</tr>
<?php if ($unit->RowType == EW_ROWTYPE_ADD) { ?>
<?php } ?>
<?php if ($unit->RowType == EW_ROWTYPE_EDIT) { ?>
<?php } ?>
<?php
}
if ($unit->CurrentAction <> "gridadd")
$rs->MoveNext();
}
?>
</tbody>
</table>
<?php } ?>
<?php if ($unit->CurrentAction == "gridadd") { ?>
<input type="hidden" name="a_list" id="a_list" value="gridinsert">
<input type="hidden" name="key_count" id="key_count" value="<?php echo $unit_list->lRowIndex ?>">
<?php } ?>
<?php if ($unit->CurrentAction == "gridedit") { ?>
<input type="hidden" name="a_list" id="a_list" value="gridupdate">
<input type="hidden" name="key_count" id="key_count" value="<?php echo $unit_list->lRowIndex ?>">
<?php echo $unit_list->sMultiSelectKey ?>
<?php } ?>
</div>
</form>
<?php
// Close recordset
if ($rs)
$rs->Close();
?>
<?php if ($unit_list->lTotalRecs > 0) { ?>
<?php if ($unit->Export == "") { ?>
<div class="ewGridLowerPanel">
<?php if ($unit->CurrentAction <> "gridadd" && $unit->CurrentAction <> "gridedit") { ?>
<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_list->Pager)) $unit_list->Pager = new cPrevNextPager($unit_list->lStartRec, $unit_list->lDisplayRecs, $unit_list->lTotalRecs) ?>
<?php if ($unit_list->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_list->Pager->FirstButton->Enabled) { ?>
<td><a href="<?php echo $unit_list->PageUrl() ?>start=<?php echo $unit_list->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_list->Pager->PrevButton->Enabled) { ?>
<td><a href="<?php echo $unit_list->PageUrl() ?>start=<?php echo $unit_list->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_list->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
<?php if ($unit_list->Pager->NextButton->Enabled) { ?>
<td><a href="<?php echo $unit_list->PageUrl() ?>start=<?php echo $unit_list->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_list->Pager->LastButton->Enabled) { ?>
<td><a href="<?php echo $unit_list->PageUrl() ?>start=<?php echo $unit_list->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_list->Pager->PageCount ?></span></td>
</tr></table>
</td>
<td> </td>
<td>
<span class="phpmaker"><?php echo $Language->Phrase("Record") ?> <?php echo $unit_list->Pager->FromIndex ?> <?php echo $Language->Phrase("To") ?> <?php echo $unit_list->Pager->ToIndex ?> <?php echo $Language->Phrase("Of") ?> <?php echo $unit_list->Pager->RecordCount ?></span>
<?php } else { ?>
<?php if ($Security->CanList()) { ?>
<?php if ($unit_list->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>
<?php if ($unit_list->lTotalRecs > 0) { ?>
<td> </td>
<td><table border="0" cellspacing="0" cellpadding="0"><tr><td><?php echo $Language->Phrase("RecordsPerPage") ?> </td><td>
<input type="hidden" id="t" name="t" value="unit">
<select name="<?php echo EW_TABLE_REC_PER_PAGE ?>" id="<?php echo EW_TABLE_REC_PER_PAGE ?>" onchange="this.form.submit();" class="phpmaker">
<option value="10"<?php if ($unit_list->lDisplayRecs == 10) { ?> selected="selected"<?php } ?>>10</option>
<option value="25"<?php if ($unit_list->lDisplayRecs == 25) { ?> selected="selected"<?php } ?>>25</option>
<option value="50"<?php if ($unit_list->lDisplayRecs == 50) { ?> selected="selected"<?php } ?>>50</option>
<option value="ALL"<?php if ($unit->getRecordsPerPage() == -1) { ?> selected="selected"<?php } ?>><?php echo $Language->Phrase("AllRecords") ?></option>
</select></td></tr></table>
</td>
<?php } ?>
</tr>
</table>
</form>
<?php } ?>
<?php //if ($unit_list->lTotalRecs > 0) { ?>
<span class="phpmaker">
<?php if ($unit->CurrentAction <> "gridadd" && $unit->CurrentAction <> "gridedit") { // Not grid add/edit mode ?>
<?php if ($Security->CanAdd()) { ?>
<a href="<?php echo $unit_list->AddUrl ?>"><?php echo $Language->Phrase("AddLink") ?></a>
<a href="<?php echo $unit_list->GridAddUrl ?>"><?php echo $Language->Phrase("GridAddLink") ?></a>
<?php } ?>
<?php if ($Security->CanEdit()) { ?>
<?php if ($unit_list->lTotalRecs > 0) { ?>
<a href="<?php echo $unit_list->GridEditUrl ?>"><?php echo $Language->Phrase("GridEditLink") ?></a>
<?php } ?>
<?php } ?>
<?php if ($unit_list->lTotalRecs > 0) { ?>
<?php if ($Security->CanDelete()) { ?>
<a href="" onclick="ew_SubmitSelected(document.funitlist, '<?php echo $unit_list->MultiDeleteUrl ?>');return false;"><?php echo $Language->Phrase("DeleteSelectedLink") ?></a>
<?php } ?>
<?php } ?>
<?php } else { // Grid add/edit mode ?>
<?php if ($unit->CurrentAction == "gridadd") { ?>
<a href="" onclick="f=document.funitlist;if(unit_list.ValidateForm(f))f.submit();return false;"><?php echo $Language->Phrase("GridInsertLink") ?></a>
<a href="<?php echo $unit_list->PageUrl() ?>a=cancel"><?php echo $Language->Phrase("GridCancelLink") ?></a>
<?php } ?>
<?php if ($unit->CurrentAction == "gridedit") { ?>
<a href="" onclick="f=document.funitlist;if(unit_list.ValidateForm(f))f.submit();return false;"><?php echo $Language->Phrase("GridSaveLink") ?></a>
<a href="<?php echo $unit_list->PageUrl() ?>a=cancel"><?php echo $Language->Phrase("GridCancelLink") ?></a>
<?php } ?>
<?php } ?>
</span>
<?php //} ?>
</div>
<?php } ?>
<?php } ?>
</td></tr></table>
<?php if ($unit->Export == "" && $unit->CurrentAction == "") { ?>
<script type="text/javascript">
<!--
ew_ToggleSearchPanel(unit_list); // Init search panel as collapsed
//-->
</script>
<?php } ?>
<?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_list->Page_Terminate();
?>
<?php
//
// Page class
//
class cunit_list {
// Page ID
var $PageID = 'list';
// Table name
var $TableName = 'unit';
// Page object name
var $PageObjName = 'unit_list';
// 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_list() {
global $conn, $Language;
// Language object
$Language = new cLanguage();
// Table object (unit)
$GLOBALS["unit"] = new cunit();
// Initialize URLs
$this->ExportPrintUrl = $this->PageUrl() . "export=print";
$this->ExportExcelUrl = $this->PageUrl() . "export=excel";
$this->ExportWordUrl = $this->PageUrl() . "export=word";
$this->ExportHtmlUrl = $this->PageUrl() . "export=html";
$this->ExportXmlUrl = $this->PageUrl() . "export=xml";
$this->ExportCsvUrl = $this->PageUrl() . "export=csv";
$this->AddUrl = $GLOBALS["unit"]->AddUrl();
$this->InlineAddUrl = $this->PageUrl() . "a=add";
$this->GridAddUrl = $this->PageUrl() . "a=gridadd";
$this->GridEditUrl = $this->PageUrl() . "a=gridedit";
$this->MultiDeleteUrl = "unitdelete.php";
$this->MultiUpdateUrl = "unitupdate.php";
// Table object (useraccounts)
$GLOBALS['useraccounts'] = new cuseraccounts();
// Page ID
if (!defined("EW_PAGE_ID"))
define("EW_PAGE_ID", 'list', 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();
// List options
$this->ListOptions = new cListOptions();
}
//
// 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->CanList()) {
$Security->SaveLastUrl();
$this->Page_Terminate("login.php");
}
$Security->UserID_Loading();
if ($Security->IsLoggedIn()) $Security->LoadUserID();
$Security->UserID_Loaded();
// Create form object
$objForm = new cFormObj();
// Get export parameters
if (@$_GET["export"] <> "") {
$unit->Export = $_GET["export"];
} elseif (ew_IsHttpPost()) {
if (@$_POST["exporttype"] <> "")
$unit->Export = $_POST["exporttype"];
} else {
$unit->setExportReturnUrl(ew_CurrentUrl());
}
$gsExport = $unit->Export; // Get export parameter, used in header
$gsExportFile = $unit->TableVar; // Get export file, used in header
if (in_array($unit->Export, array("html", "email", "excel", "word")))
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";
if ($unit->Export == "excel") {
header('Content-Type: application/vnd.ms-excel;charset=utf-8');
header('Content-Disposition: attachment; filename=' . $gsExportFile .'.xls');
}
if ($unit->Export == "word") {
header('Content-Type: application/vnd.ms-word;charset=utf-8');
header('Content-Disposition: attachment; filename=' . $gsExportFile .'.doc');
}
if ($unit->Export == "csv") {
header('Content-Type: application/csv;charset=utf-8');
header('Content-Disposition: attachment; filename=' . $gsExportFile .'.csv');
}
// 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();
}
// Class variables
var $ListOptions; // List options
var $lDisplayRecs = 10;
var $lStartRec;
var $lStopRec;
var $lTotalRecs = 0;
var $lRecRange = 10;
var $sSrchWhere = ""; // Search WHERE clause
var $lRecCnt = 0; // Record count
var $lEditRowCnt;
var $lRowCnt;
var $lRowIndex; // Row index
var $lRecPerRow = 0;
var $lColCnt = 0;
var $sDbMasterFilter = ""; // Master filter
var $sDbDetailFilter = ""; // Detail filter
var $bMasterRecordExists;
var $sMultiSelectKey;
var $RestoreSearch;
//
// Page main
//
function Page_Main() {
global $objForm, $Language, $gsSearchError, $Security, $unit;
// Search filters
$sSrchAdvanced = ""; // Advanced search filter
$sSrchBasic = ""; // Basic search filter
$sFilter = "";
if ($this->IsPageRequest()) { // Validate request
// Set up records per page
$this->SetUpDisplayRecs();
// Handle reset command
$this->ResetCmd();
// Check QueryString parameters
if (@$_GET["a"] <> "") {
$unit->CurrentAction = $_GET["a"];
// Clear inline mode
if ($unit->CurrentAction == "cancel")
$this->ClearInlineMode();
// Switch to grid edit mode
if ($unit->CurrentAction == "gridedit")
$this->GridEditMode();
// Switch to grid add mode
if ($unit->CurrentAction == "gridadd")
$this->GridAddMode();
} else {
if (@$_POST["a_list"] <> "") {
$unit->CurrentAction = $_POST["a_list"]; // Get action
// Grid Update
if (($unit->CurrentAction == "gridupdate" || $unit->CurrentAction == "gridoverwrite") && @$_SESSION[EW_SESSION_INLINE_MODE] == "gridedit")
$this->GridUpdate();
// Grid Insert
if ($unit->CurrentAction == "gridinsert" && @$_SESSION[EW_SESSION_INLINE_MODE] == "gridadd")
$this->GridInsert();
}
}
// Set up list options
$this->SetupListOptions();
// Get basic search values
$this->LoadBasicSearchValues();
// Restore search parms from Session
$this->RestoreSearchParms();
// Call Recordset SearchValidated event
$unit->Recordset_SearchValidated();
// Set up sorting order
$this->SetUpSortOrder();
// Get basic search criteria
if ($gsSearchError == "")
$sSrchBasic = $this->BasicSearchWhere();
}
// Restore display records
if ($unit->getRecordsPerPage() <> "") {
$this->lDisplayRecs = $unit->getRecordsPerPage(); // Restore from Session
} else {
$this->lDisplayRecs = 10; // Load default
}
// Load Sorting Order
$this->LoadSortOrder();
// Build search criteria
if ($sSrchAdvanced <> "")
$this->sSrchWhere = ($this->sSrchWhere <> "") ? "(" . $this->sSrchWhere . ") AND (" . $sSrchAdvanced . ")" : $sSrchAdvanced;
if ($sSrchBasic <> "")
$this->sSrchWhere = ($this->sSrchWhere <> "") ? "(" . $this->sSrchWhere . ") AND (" . $sSrchBasic. ")" : $sSrchBasic;
// Call Recordset_Searching event
$unit->Recordset_Searching($this->sSrchWhere);
// Save search criteria
if ($this->sSrchWhere <> "") {
if ($sSrchBasic == "")
$this->ResetBasicSearchParms();
$unit->setSearchWhere($this->sSrchWhere); // Save to Session
if (!$this->RestoreSearch) {
$this->lStartRec = 1; // Reset start record counter
$unit->setStartRecordNumber($this->lStartRec);
}
} else {
$this->sSrchWhere = $unit->getSearchWhere();
}
// Build filter
$sFilter = "";
if (!$Security->CanList())
$sFilter = "(0=1)"; // Filter all records
if ($this->sDbDetailFilter <> "")
$sFilter = ($sFilter <> "") ? "(" . $sFilter . ") AND (" . $this->sDbDetailFilter . ")" : $this->sDbDetailFilter;
if ($this->sSrchWhere <> "")
$sFilter = ($sFilter <> "") ? "(" . $sFilter . ") AND (". $this->sSrchWhere . ")" : $this->sSrchWhere;
// Set up filter in session
$unit->setSessionWhere($sFilter);
$unit->CurrentFilter = "";
// Export data only
if (in_array($unit->Export, array("html","word","excel","xml","csv","email"))) {
$this->ExportData();
if ($unit->Export <> "email")
$this->Page_Terminate(); // Terminate response
exit();
}
}
// Set up number of records displayed per page
function SetUpDisplayRecs() {
global $unit;
$sWrk = @$_GET[EW_TABLE_REC_PER_PAGE];
if ($sWrk <> "") {
if (is_numeric($sWrk)) {
$this->lDisplayRecs = intval($sWrk);
} else {
if (strtolower($sWrk) == "all") { // Display all records
$this->lDisplayRecs = -1;
} else {
$this->lDisplayRecs = 10; // Non-numeric, load default
}
}
$unit->setRecordsPerPage($this->lDisplayRecs); // Save to Session
// Reset start position
$this->lStartRec = 1;
$unit->setStartRecordNumber($this->lStartRec);
}
}
// Exit inline mode
function ClearInlineMode() {
global $unit;
$unit->CurrentAction = ""; // Clear action
$_SESSION[EW_SESSION_INLINE_MODE] = ""; // Clear inline mode
}
// Switch to Grid Add mode
function GridAddMode() {
$_SESSION[EW_SESSION_INLINE_MODE] = "gridadd"; // Enabled grid add
}
// Switch to Grid Edit mode
function GridEditMode() {
$_SESSION[EW_SESSION_INLINE_MODE] = "gridedit"; // Enable grid edit
}
// Perform update to grid
function GridUpdate() {
global $conn, $Language, $objForm, $gsFormError, $unit;
$rowindex = 1;
$bGridUpdate = TRUE;
// Begin transaction
$conn->BeginTrans();
// Get old recordset
$unit->CurrentFilter = $this->BuildKeyFilter();
$sSql = $unit->SQL();
if ($rs = $conn->Execute($sSql)) {
$rsold = $rs->GetRows();
$rs->Close();
}
$sKey = "";
// Update row index and get row key
$objForm->Index = $rowindex;
$sThisKey = strval($objForm->GetValue("k_key"));
// Update all rows based on key
while ($sThisKey <> "") {
// Load all values and keys
$this->LoadFormValues(); // Get form values
// Validate form
if (!$this->ValidateForm()) {
$bGridUpdate = FALSE; // Form error, reset action
$this->setMessage($gsFormError);
} else {
if ($this->SetupKeyValues($sThisKey)) { // Set up key values
$unit->SendEmail = FALSE; // Do not send email on update success
$bGridUpdate = $this->EditRow(); // Update this row
} else {
$bGridUpdate = FALSE; // update failed
}
}
if ($bGridUpdate) {
if ($sKey <> "") $sKey .= ", ";
$sKey .= $sThisKey;
} else {
break;
}
// Update row index and get row key
$rowindex++; // next row
$objForm->Index = $rowindex;
$sThisKey = strval($objForm->GetValue("k_key"));
}
if ($bGridUpdate) {
$conn->CommitTrans(); // Commit transaction
// Get new recordset
if ($rs = $conn->Execute($sSql)) {
$rsnew = $rs->GetRows();
$rs->Close();
}
$this->setMessage($Language->Phrase("UpdateSuccess")); // Set update success message
$this->ClearInlineMode(); // Clear inline edit mode
} else {
$conn->RollbackTrans(); // Rollback transaction
if ($this->getMessage() == "")
$this->setMessage($Language->Phrase("UpdateFailed")); // Set update failed message
$unit->EventCancelled = TRUE; // Set event cancelled
$unit->CurrentAction = "gridedit"; // Stay in Grid Edit mode
}
}
// Build filter for all keys
function BuildKeyFilter() {
global $objForm, $unit;
$sWrkFilter = "";
// Update row index and get row key
$rowindex = 1;
$objForm->Index = $rowindex;
$sThisKey = strval($objForm->GetValue("k_key"));
while ($sThisKey <> "") {
if ($this->SetupKeyValues($sThisKey)) {
$sFilter = $unit->KeyFilter();
if ($sWrkFilter <> "") $sWrkFilter .= " OR ";
$sWrkFilter .= $sFilter;
} else {
$sWrkFilter = "0=1";
break;
}
// Update row index and get row key
$rowindex++; // next row
$objForm->Index = $rowindex;
$sThisKey = strval($objForm->GetValue("k_key"));
}
return $sWrkFilter;
}
// Set up key values
function SetupKeyValues($key) {
global $unit;
$arrKeyFlds = explode(EW_COMPOSITE_KEY_SEPARATOR, $key);
if (count($arrKeyFlds) >= 1) {
$unit->unit->setFormValue($arrKeyFlds[0]);
}
return TRUE;
}
// Perform Grid Add
function GridInsert() {
global $conn, $Language, $objForm, $gsFormError, $unit;
$rowindex = 1;
$bGridInsert = FALSE;
// Begin transaction
$conn->BeginTrans();
// Init key filter
$sWrkFilter = "";
$addcnt = 0;
$sKey = "";
// Get row count
$objForm->Index = 0;
$rowcnt = strval($objForm->GetValue("key_count"));
if ($rowcnt == "" || !is_numeric($rowcnt))
$rowcnt = 0;
// Insert all rows
for ($rowindex = 1; $rowindex <= $rowcnt; $rowindex++) {
// Load current row values
$objForm->Index = $rowindex;
$this->LoadFormValues(); // Get form values
if (!$this->EmptyRow()) {
$addcnt++;
$unit->SendEmail = FALSE; // Do not send email on insert success
// Validate form
if (!$this->ValidateForm()) {
$bGridInsert = FALSE; // Form error, reset action
$this->setMessage($gsFormError);
} else {
$bGridInsert = $this->AddRow(); // Insert this row
}
if ($bGridInsert) {
if ($sKey <> "") $sKey .= EW_COMPOSITE_KEY_SEPARATOR;
$sKey .= $unit->unit->CurrentValue;
// Add filter for this record
$sFilter = $unit->KeyFilter();
if ($sWrkFilter <> "") $sWrkFilter .= " OR ";
$sWrkFilter .= $sFilter;
} else {
break;
}
}
}
if ($bGridInsert) {
$conn->CommitTrans(); // Commit transaction
// Get new recordset
$unit->CurrentFilter = $sWrkFilter;
$sSql = $unit->SQL();
if ($rs = $conn->Execute($sSql)) {
$rsnew = $rs->GetRows();
$rs->Close();
}
$this->setMessage($Language->Phrase("InsertSuccess")); // Set insert success message
$this->ClearInlineMode(); // Clear grid add mode
} else {
$conn->RollbackTrans(); // Rollback transaction
if ($addcnt == 0) { // No record inserted
$this->setMessage($Language->Phrase("NoAddRecord"));
} elseif ($this->getMessage() == "") {
$this->setMessage($Language->Phrase("InsertFailed")); // Set insert failed message
}
$unit->EventCancelled = TRUE; // Set event cancelled
$unit->CurrentAction = "gridadd"; // Stay in gridadd mode
}
}
// Check if empty row
function EmptyRow() {
global $unit;
if ($unit->unit->CurrentValue <> $unit->unit->OldValue)
return FALSE;
return TRUE;
}
// Restore form values for current row
function RestoreCurrentRowFormValues($idx) {
global $objForm, $unit;
// Get row based on current index
$objForm->Index = $idx;
if ($unit->CurrentAction == "gridadd")
$this->LoadFormValues(); // Load form values
if ($unit->CurrentAction == "gridedit") {
$sKey = strval($objForm->GetValue("k_key"));
$arrKeyFlds = explode(EW_COMPOSITE_KEY_SEPARATOR, $sKey);
if (count($arrKeyFlds) >= 1) {
if (strval($arrKeyFlds[0]) == strval($unit->unit->CurrentValue)) {
$this->LoadFormValues(); // Load form values
}
}
}
}
// Return basic search SQL
function BasicSearchSQL($Keyword) {
global $unit;
$sKeyword = ew_AdjustSql($Keyword);
$sWhere = "";
$this->BuildBasicSearchSQL($sWhere, $unit->unit, $Keyword);
return $sWhere;
}
// Build basic search SQL
function BuildBasicSearchSql(&$Where, &$Fld, $Keyword) {
$sFldExpression = ($Fld->FldVirtualExpression <> "") ? $Fld->FldVirtualExpression : $Fld->FldExpression;
$lFldDataType = ($Fld->FldIsVirtual) ? EW_DATATYPE_STRING : $Fld->FldDataType;
if ($lFldDataType == EW_DATATYPE_NUMBER) {
$sWrk = $sFldExpression . " = " . ew_QuotedValue($Keyword, $lFldDataType);
} else {
$sWrk = $sFldExpression . " LIKE " . ew_QuotedValue("%" . $Keyword . "%", $lFldDataType);
}
if ($Where <> "") $Where .= " OR ";
$Where .= $sWrk;
}
// Return basic search WHERE clause based on search keyword and type
function BasicSearchWhere() {
global $Security, $unit;
$sSearchStr = "";
if (!$Security->CanSearch()) return "";
$sSearchKeyword = $unit->BasicSearchKeyword;
$sSearchType = $unit->BasicSearchType;
if ($sSearchKeyword <> "") {
$sSearch = trim($sSearchKeyword);
if ($sSearchType <> "") {
while (strpos($sSearch, " ") !== FALSE)
$sSearch = str_replace(" ", " ", $sSearch);
$arKeyword = explode(" ", trim($sSearch));
foreach ($arKeyword as $sKeyword) {
if ($sSearchStr <> "") $sSearchStr .= " " . $sSearchType . " ";
$sSearchStr .= "(" . $this->BasicSearchSQL($sKeyword) . ")";
}
} else {
$sSearchStr = $this->BasicSearchSQL($sSearch);
}
}
if ($sSearchKeyword <> "") {
$unit->setSessionBasicSearchKeyword($sSearchKeyword);
$unit->setSessionBasicSearchType($sSearchType);
}
return $sSearchStr;
}
// Clear all search parameters
function ResetSearchParms() {
global $unit;
// Clear search WHERE clause
$this->sSrchWhere = "";
$unit->setSearchWhere($this->sSrchWhere);
// Clear basic search parameters
$this->ResetBasicSearchParms();
}
// Clear all basic search parameters
function ResetBasicSearchParms() {
global $unit;
$unit->setSessionBasicSearchKeyword("");
$unit->setSessionBasicSearchType("");
}
// Restore all search parameters
function RestoreSearchParms() {
global $unit;
$bRestore = TRUE;
if (@$_GET[EW_TABLE_BASIC_SEARCH] <> "") $bRestore = FALSE;
$this->RestoreSearch = $bRestore;
if ($bRestore) {
// Restore basic search values
$unit->BasicSearchKeyword = $unit->getSessionBasicSearchKeyword();
$unit->BasicSearchType = $unit->getSessionBasicSearchType();
}
}
// Set up sort parameters
function SetUpSortOrder() {
global $unit;
// Check for "order" parameter
if (@$_GET["order"] <> "") {
$unit->CurrentOrder = ew_StripSlashes(@$_GET["order"]);
$unit->CurrentOrderType = @$_GET["ordertype"];
$unit->UpdateSort($unit->unit); // unit
$unit->setStartRecordNumber(1); // Reset start position
}
}
// Load sort order parameters
function LoadSortOrder() {
global $unit;
$sOrderBy = $unit->getSessionOrderBy(); // Get ORDER BY from Session
if ($sOrderBy == "") {
if ($unit->SqlOrderBy() <> "") {
$sOrderBy = $unit->SqlOrderBy();
$unit->setSessionOrderBy($sOrderBy);
$unit->unit->setSort("ASC");
}
}
}
// Reset command
// cmd=reset (Reset search parameters)
// cmd=resetall (Reset search and master/detail parameters)
// cmd=resetsort (Reset sort parameters)
function ResetCmd() {
global $unit;
// Get reset command
if (@$_GET["cmd"] <> "") {
$sCmd = $_GET["cmd"];
// Reset search criteria
if (strtolower($sCmd) == "reset" || strtolower($sCmd) == "resetall")
$this->ResetSearchParms();
// Reset sorting order
if (strtolower($sCmd) == "resetsort") {
$sOrderBy = "";
$unit->setSessionOrderBy($sOrderBy);
$unit->unit->setSort("");
}
// Reset start position
$this->lStartRec = 1;
$unit->setStartRecordNumber($this->lStartRec);
}
}
// Set up list options
function SetupListOptions() {
global $Security, $unit;
// "view"
$this->ListOptions->Add("view");
$item =& $this->ListOptions->Items["view"];
$item->CssStyle = "white-space: nowrap;";
$item->Visible = $Security->CanView();
$item->OnLeft = FALSE;
// "edit"
$this->ListOptions->Add("edit");
$item =& $this->ListOptions->Items["edit"];
$item->CssStyle = "white-space: nowrap;";
$item->Visible = $Security->CanEdit();
$item->OnLeft = FALSE;
// "copy"
$this->ListOptions->Add("copy");
$item =& $this->ListOptions->Items["copy"];
$item->CssStyle = "white-space: nowrap;";
$item->Visible = $Security->CanAdd();
$item->OnLeft = FALSE;
// "detail_items"
$this->ListOptions->Add("detail_items");
$item =& $this->ListOptions->Items["detail_items"];
$item->CssStyle = "white-space: nowrap;";
$item->Visible = True;
$item->OnLeft = FALSE;
// "detail_order_detail"
$this->ListOptions->Add("detail_order_detail");
$item =& $this->ListOptions->Items["detail_order_detail"];
$item->CssStyle = "white-space: nowrap;";
$item->Visible = $Security->AllowList('order_detail');
$item->OnLeft = FALSE;
// "checkbox"
$this->ListOptions->Add("checkbox");
$item =& $this->ListOptions->Items["checkbox"];
$item->CssStyle = "white-space: nowrap;";
$item->Visible = $Security->CanDelete();
$item->OnLeft = FALSE;
$item->Header = "<input type=\"checkbox\" name=\"key\" id=\"key\" class=\"phpmaker\" onclick=\"unit_list.SelectAllKey(this);\">";
// Call ListOptions_Load event
$this->ListOptions_Load();
if ($unit->Export <> "" ||
$unit->CurrentAction == "gridadd" ||
$unit->CurrentAction == "gridedit")
$this->ListOptions->HideAllOptions();
}
// Render list options
function RenderListOptions() {
global $Security, $Language, $unit;
$this->ListOptions->LoadDefault();
// "view"
$oListOpt =& $this->ListOptions->Items["view"];
if ($Security->CanView() && $oListOpt->Visible)
$oListOpt->Body = "<a href=\"" . $this->ViewUrl . "\">" . $Language->Phrase("ViewLink") . "</a>";
// "edit"
$oListOpt =& $this->ListOptions->Items["edit"];
if ($Security->CanEdit() && $oListOpt->Visible) {
$oListOpt->Body = "<a href=\"" . $this->EditUrl . "\">" . $Language->Phrase("EditLink") . "</a>";
}
// "copy"
$oListOpt =& $this->ListOptions->Items["copy"];
if ($Security->CanAdd() && $oListOpt->Visible) {
$oListOpt->Body = "<a href=\"" . $this->CopyUrl . "\">" . $Language->Phrase("CopyLink") . "</a>";
}
// "detail_items"
$oListOpt =& $this->ListOptions->Items["detail_items"];
if (True) {
$oListOpt->Body = $Language->Phrase("DetailLink") . $Language->TablePhrase("items", "TblCaption");
$oListOpt->Body = "<a href=\"itemslist.php?" . EW_TABLE_SHOW_MASTER . "=unit&unit=" . urlencode(strval($unit->unit->CurrentValue)) . "\">" . $oListOpt->Body . "</a>";
}
// "detail_order_detail"
$oListOpt =& $this->ListOptions->Items["detail_order_detail"];
if ($Security->AllowList('order_detail')) {
$oListOpt->Body = $Language->Phrase("DetailLink") . $Language->TablePhrase("order_detail", "TblCaption");
$oListOpt->Body = "<a href=\"order_detaillist.php?" . EW_TABLE_SHOW_MASTER . "=unit&unit=" . urlencode(strval($unit->unit->CurrentValue)) . "\">" . $oListOpt->Body . "</a>";
}
// "checkbox"
$oListOpt =& $this->ListOptions->Items["checkbox"];
if ($Security->CanDelete() && $oListOpt->Visible)
$oListOpt->Body = "<input type=\"checkbox\" name=\"key_m[]\" id=\"key_m[]\" value=\"" . ew_HtmlEncode($unit->unit->CurrentValue) . "\" class=\"phpmaker\" onclick='ew_ClickMultiCheckbox(this);'>";
if ($unit->CurrentAction == "gridedit")
$this->sMultiSelectKey .= "<input type=\"hidden\" name=\"k" . $this->lRowIndex . "_key\" id=\"k" . $this->lRowIndex . "_key\" value=\"" . $unit->unit->CurrentValue . "\">";
$this->RenderListOptionsExt();
// Call ListOptions_Rendered event
$this->ListOptions_Rendered();
}
function RenderListOptionsExt() {
global $Security, $Language, $unit;
}
// 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 default values
function LoadDefaultValues() {
global $unit;
}
// Load basic search values
function LoadBasicSearchValues() {
global $unit;
$unit->BasicSearchKeyword = @$_GET[EW_TABLE_BASIC_SEARCH];
$unit->BasicSearchType = @$_GET[EW_TABLE_BASIC_SEARCH_TYPE];
}
// Load form values
function LoadFormValues() {
// Load from form
global $objForm, $unit;
$unit->unit->setFormValue($objForm->GetValue("x_unit"));
$unit->unit->setOldValue($objForm->GetValue("o_unit"));
}
// Restore form values
function RestoreFormValues() {
global $objForm, $unit;
$unit->unit->CurrentValue = $unit->unit->FormValue;
}
// 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->ViewUrl = $unit->ViewUrl();
$this->EditUrl = $unit->EditUrl();
$this->InlineEditUrl = $unit->InlineEditUrl();
$this->CopyUrl = $unit->CopyUrl();
$this->InlineCopyUrl = $unit->InlineCopyUrl();
$this->DeleteUrl = $unit->DeleteUrl();
// 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 = "";
} elseif ($unit->RowType == EW_ROWTYPE_ADD) { // Add row
// unit
$unit->unit->EditCustomAttributes = "";
$unit->unit->EditValue = ew_HtmlEncode($unit->unit->CurrentValue);
} elseif ($unit->RowType == EW_ROWTYPE_EDIT) { // Edit row
// unit
$unit->unit->EditCustomAttributes = "";
$unit->unit->EditValue = $unit->unit->CurrentValue;
$unit->unit->CssStyle = "";
$unit->unit->CssClass = "";
$unit->unit->ViewCustomAttributes = "";
// Edit refer script
// unit
$unit->unit->HrefValue = "";
}
// Call Row Rendered event
if ($unit->RowType <> EW_ROWTYPE_AGGREGATEINIT)
$unit->Row_Rendered();
}
// Validate form
function ValidateForm() {
global $Language, $gsFormError, $unit;
// Initialize form error message
$gsFormError = "";
// Check if validation required
if (!EW_SERVER_VALIDATE)
return ($gsFormError == "");
if (!is_null($unit->unit->FormValue) && $unit->unit->FormValue == "") {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $unit->unit->FldCaption();
}
// Return validate result
$ValidateForm = ($gsFormError == "");
// Call Form_CustomValidate event
$sFormCustomError = "";
$ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
if ($sFormCustomError <> "") {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $sFormCustomError;
}
return $ValidateForm;
}
// Update record based on key values
function EditRow() {
global $conn, $Security, $Language, $unit;
$sFilter = $unit->KeyFilter();
$unit->CurrentFilter = $sFilter;
$sSql = $unit->SQL();
$conn->raiseErrorFn = 'ew_ErrorFn';
$rs = $conn->Execute($sSql);
$conn->raiseErrorFn = '';
if ($rs === FALSE)
return FALSE;
if ($rs->EOF) {
$EditRow = FALSE; // Update Failed
} else {
// Save old values
$rsold =& $rs->fields;
$rsnew = array();
// unit
// Call Row Updating event
$bUpdateRow = $unit->Row_Updating($rsold, $rsnew);
if ($bUpdateRow) {
$conn->raiseErrorFn = 'ew_ErrorFn';
$EditRow = $conn->Execute($unit->UpdateSQL($rsnew));
$conn->raiseErrorFn = '';
} else {
if ($unit->CancelMessage <> "") {
$this->setMessage($unit->CancelMessage);
$unit->CancelMessage = "";
} else {
$this->setMessage($Language->Phrase("UpdateCancelled"));
}
$EditRow = FALSE;
}
}
// Call Row_Updated event
if ($EditRow)
$unit->Row_Updated($rsold, $rsnew);
$rs->Close();
return $EditRow;
}
// Add record
function AddRow() {
global $conn, $Language, $Security, $unit;
// Check if key value entered
if ($unit->unit->CurrentValue == "") {
$this->setMessage($Language->Phrase("InvalidKeyValue"));
return FALSE;
}
// Check for duplicate key
$bCheckKey = TRUE;
$sFilter = $unit->KeyFilter();
if ($bCheckKey) {
$rsChk = $unit->LoadRs($sFilter);
if ($rsChk && !$rsChk->EOF) {
$sKeyErrMsg = str_replace("%f", $sFilter, $Language->Phrase("DupKey"));
$this->setMessage($sKeyErrMsg);
$rsChk->Close();
return FALSE;
}
}
$rsnew = array();
// unit
$unit->unit->SetDbValueDef($rsnew, $unit->unit->CurrentValue, "", FALSE);
// Call Row Inserting event
$bInsertRow = $unit->Row_Inserting($rsnew);
if ($bInsertRow) {
$conn->raiseErrorFn = 'ew_ErrorFn';
$AddRow = $conn->Execute($unit->InsertSQL($rsnew));
$conn->raiseErrorFn = '';
} else {
if ($unit->CancelMessage <> "") {
$this->setMessage($unit->CancelMessage);
$unit->CancelMessage = "";
} else {
$this->setMessage($Language->Phrase("InsertCancelled"));
}
$AddRow = FALSE;
}
if ($AddRow) {
// Call Row Inserted event
$unit->Row_Inserted($rsnew);
}
return $AddRow;
}
// Export data in HTML/CSV/Word/Excel/XML/Email format
function ExportData() {
global $unit;
$utf8 = TRUE;
$bSelectLimit = EW_SELECT_LIMIT;
// Load recordset
if ($bSelectLimit) {
$this->lTotalRecs = $unit->SelectRecordCount();
} else {
if ($rs = $this->LoadRecordset())
$this->lTotalRecs = $rs->RecordCount();
}
$this->lStartRec = 1;
// Export all
if ($unit->ExportAll) {
$this->lDisplayRecs = $this->lTotalRecs;
$this->lStopRec = $this->lTotalRecs;
} else { // Export one page only
$this->SetUpStartRec(); // Set up start record position
// Set the last record to display
if ($this->lDisplayRecs < 0) {
$this->lStopRec = $this->lTotalRecs;
} else {
$this->lStopRec = $this->lStartRec + $this->lDisplayRecs - 1;
}
}
if ($bSelectLimit)
$rs = $this->LoadRecordset($this->lStartRec-1, $this->lDisplayRecs);
if (!$rs) {
header("Content-Type:"); // Remove header
header("Content-Disposition:");
$this->ShowMessage();
return;
}
if ($unit->Export == "xml") {
$XmlDoc = new cXMLDocument(EW_XML_ENCODING);
$XmlDoc->AddRoot();
} else {
$ExportDoc = new cExportDocument($unit, "h");
$ExportDoc->ExportHeader();
if ($ExportDoc->Horizontal) { // Horizontal format, write header
$ExportDoc->BeginExportRow();
$ExportDoc->ExportCaption($unit->unit);
$ExportDoc->EndExportRow();
}
}
// Move to first record
$this->lRecCnt = $this->lStartRec - 1;
if (!$rs->EOF) {
$rs->MoveFirst();
if (!$bSelectLimit && $this->lStartRec > 1)
$rs->Move($this->lStartRec - 1);
}
while (!$rs->EOF && $this->lRecCnt < $this->lStopRec) {
$this->lRecCnt++;
if (intval($this->lRecCnt) >= intval($this->lStartRec)) {
$this->LoadRowValues($rs);
// Render row
$unit->CssClass = "";
$unit->CssStyle = "";
$unit->RowType = EW_ROWTYPE_VIEW; // Render view
$this->RenderRow();
if ($unit->Export == "xml") {
$XmlDoc->AddRow();
$XmlDoc->AddField('unit', $unit->unit->ExportValue($unit->Export, $unit->ExportOriginalValue));
} else {
$ExportDoc->BeginExportRow(TRUE); // Allow CSS styles if enabled
$ExportDoc->ExportField($unit->unit);
$ExportDoc->EndExportRow();
}
}
$rs->MoveNext();
}
if ($unit->Export <> "xml")
$ExportDoc->ExportFooter();
// Close recordset
$rs->Close();
// Clean output buffer
if (!EW_DEBUG_ENABLED && ob_get_length())
ob_end_clean();
// Write BOM if utf-8
if ($utf8 && !in_array($unit->Export, array("email", "xml")))
echo "\xEF\xBB\xBF";
// Write debug message if enabled
if (EW_DEBUG_ENABLED)
echo ew_DebugMsg();
// Output data
if ($unit->Export == "xml") {
header("Content-Type: text/xml");
echo $XmlDoc->XML();
} elseif ($unit->Export == "email") {
$this->ExportEmail($ExportDoc->Text);
$this->Page_Terminate($unit->ExportReturnUrl());
} else {
echo $ExportDoc->Text;
}
}
// Export email
function ExportEmail($EmailContent) {
global $Language, $unit;
$sSender = @$_GET["sender"];
$sRecipient = @$_GET["recipient"];
$sCc = @$_GET["cc"];
$sBcc = @$_GET["bcc"];
$sContentType = @$_GET["contenttype"];
// Subject
$sSubject = ew_StripSlashes(@$_GET["subject"]);
$sEmailSubject = $sSubject;
// Message
$sContent = ew_StripSlashes(@$_GET["message"]);
$sEmailMessage = $sContent;
// Check sender
if ($sSender == "") {
$this->setMessage($Language->Phrase("EnterSenderEmail"));
return;
}
if (!ew_CheckEmail($sSender)) {
$this->setMessage($Language->Phrase("EnterProperSenderEmail"));
return;
}
// Check recipient
if (!ew_CheckEmailList($sRecipient, EW_MAX_EMAIL_RECIPIENT)) {
$this->setMessage($Language->Phrase("EnterProperRecipientEmail"));
return;
}
// Check cc
if (!ew_CheckEmailList($sCc, EW_MAX_EMAIL_RECIPIENT)) {
$this->setMessage($Language->Phrase("EnterProperCcEmail"));
return;
}
// Check bcc
if (!ew_CheckEmailList($sBcc, EW_MAX_EMAIL_RECIPIENT)) {
$this->setMessage($Language->Phrase("EnterProperBccEmail"));
return;
}
// Check email sent count
if (!isset($_SESSION[EW_EXPORT_EMAIL_COUNTER]))
$_SESSION[EW_EXPORT_EMAIL_COUNTER] = 0;
if (intval($_SESSION[EW_EXPORT_EMAIL_COUNTER]) > EW_MAX_EMAIL_SENT_COUNT) {
$this->setMessage($Language->Phrase("ExceedMaxEmailExport"));
return;
}
if ($sEmailMessage <> "") {
$sEmailMessage = ew_RemoveXSS($sEmailMessage);
$sEmailMessage .= ($sContentType == "url") ? "\r\n\r\n" : "<br><br>";
}
if ($sContentType == "url") {
$sUrl = ew_ConvertFullUrl(ew_CurrentPage() . "?" . $this->ExportQueryString());
$sEmailMessage .= $sUrl; // send URL only
} else {
$sEmailMessage .= $EmailContent; // send HTML
}
// Send email
$Email = new cEmail();
$Email->Sender = $sSender; // Sender
$Email->Recipient = $sRecipient; // Recipient
$Email->Cc = $sCc; // Cc
$Email->Bcc = $sBcc; // Bcc
$Email->Subject = $sEmailSubject; // Subject
$Email->Content = $sEmailMessage; // Content
$Email->Format = ($sContentType == "url") ? "text" : "html";
$Email->Charset = EW_EMAIL_CHARSET;
$EventArgs = array();
$bEmailSent = FALSE;
if ($unit->Email_Sending($Email, $EventArgs))
$bEmailSent = $Email->Send();
// Check email sent status
if ($bEmailSent) {
// Update email sent count
$_SESSION[EW_EXPORT_EMAIL_COUNTER]++;
// Sent email success
$this->setMessage($Language->Phrase("SendEmailSuccess"));
} else {
// Sent email failure
$this->setMessage($Email->SendErrDescription);
}
}
// Export QueryString
function ExportQueryString() {
global $unit;
// Initialize
$sQry = "export=html";
// Build QueryString for search
if ($unit->getSessionBasicSearchKeyword() <> "") {
$sQry .= "&" . EW_TABLE_BASIC_SEARCH . "=" . $unit->getSessionBasicSearchKeyword() . "&" . EW_TABLE_BASIC_SEARCH_TYPE . "=" . $unit->getSessionBasicSearchType();
}
// Build QueryString for pager
$sQry .= "&" . EW_TABLE_REC_PER_PAGE . "=" . $unit->getRecordsPerPage() . "&" . EW_TABLE_START_REC . "=" . $unit->getStartRecordNumber();
return $sQry;
}
// Add search QueryString
function AddSearchQueryString(&$Qry, &$Fld) {
global $unit;
$FldParm = substr($Fld->FldVar, 2);
$FldSearchValue = $unit->GetAdvancedSearch("x_" . $FldParm);
if (strval($FldSearchValue) <> "") {
$Qry .= "&x_" . $FldParm . "=" . FldSearchValue .
"&z_" . $FldParm . "=" . $unit->GetAdvancedSearch("z_" . $FldParm);
}
$FldSearchValue2 = $unit->GetAdvancedSearch("y_" . $FldParm);
if (strval($FldSearchValue2) <> "") {
$Qry .= "&v_" . $FldParm . "=" . $unit->GetAdvancedSearch("v_" . $FldParm) .
"&y_" . $FldParm . "=" . $FldSearchValue2 .
"&w_" . $FldParm . "=" . $unit->GetAdvancedSearch("w_" . $FldParm);
}
}
// 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";
}
// Form Custom Validate event
function Form_CustomValidate(&$CustomError) {
// Return error message in CustomError
return TRUE;
}
// ListOptions Load event
function ListOptions_Load() {
// Example:
//$this->ListOptions->Add("new");
//$this->ListOptions->Items["new"]->OnLeft = TRUE; // Link on left
//$this->ListOptions->MoveItem("new", 0); // Move to first column
}
// ListOptions Rendered event
function ListOptions_Rendered() {
// Example:
//$this->ListOptions->Items["new"]->Body = "xxx";
}
}
?>