PageRenderTime 52ms CodeModel.GetById 34ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/jf/web/reports/PRTY_Reportssmry.php

http://tinkerportal.googlecode.com/
PHP | 1720 lines | 1250 code | 225 blank | 245 comment | 333 complexity | 5066ee8197c1c32592e22d7692cef0a9 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1<?php
   2if (session_id() == "") session_start(); // Initialize Session data
   3ob_start();
   4?>
   5<?php include_once "phprptinc/ewrcfg5.php"; ?>
   6<?php include_once "phprptinc/ewmysql.php"; ?>
   7<?php include_once "phprptinc/ewrfn5.php"; ?>
   8<?php include_once "phprptinc/ewrusrfn.php"; ?>
   9<?php
  10
  11// Global variable for table object
  12$PRTY_Reports = NULL;
  13
  14//
  15// Table class for PRTY Reports
  16//
  17class crPRTY_Reports {
  18	var $TableVar = 'PRTY_Reports';
  19	var $TableName = 'PRTY Reports';
  20	var $TableType = 'REPORT';
  21	var $ShowCurrentFilter = EWRPT_SHOW_CURRENT_FILTER;
  22	var $FilterPanelOption = EWRPT_FILTER_PANEL_OPTION;
  23	var $CurrentOrder; // Current order
  24	var $CurrentOrderType; // Current order type
  25
  26	// Table caption
  27	function TableCaption() {
  28		global $ReportLanguage;
  29		return $ReportLanguage->TablePhrase($this->TableVar, "TblCaption");
  30	}
  31
  32	// Session Group Per Page
  33	function getGroupPerPage() {
  34		return @$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_grpperpage"];
  35	}
  36
  37	function setGroupPerPage($v) {
  38		@$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_grpperpage"] = $v;
  39	}
  40
  41	// Session Start Group
  42	function getStartGroup() {
  43		return @$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_start"];
  44	}
  45
  46	function setStartGroup($v) {
  47		@$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_start"] = $v;
  48	}
  49
  50	// Session Order By
  51	function getOrderBy() {
  52		return @$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_orderby"];
  53	}
  54
  55	function setOrderBy($v) {
  56		@$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_orderby"] = $v;
  57	}
  58
  59//	var $SelectLimit = TRUE;
  60	var $id;
  61	var $full_name;
  62	var $dob;
  63	var $priority;
  64	var $department_name;
  65	var $fields = array();
  66	var $Export; // Export
  67	var $ExportAll = TRUE;
  68	var $UseTokenInUrl = EWRPT_USE_TOKEN_IN_URL;
  69	var $RowType; // Row type
  70	var $RowTotalType; // Row total type
  71	var $RowTotalSubType; // Row total subtype
  72	var $RowGroupLevel; // Row group level
  73	var $RowAttrs = array(); // Row attributes
  74
  75	// Reset CSS styles for table object
  76	function ResetCSS() {
  77    	$this->RowAttrs["style"] = "";
  78		$this->RowAttrs["class"] = "";
  79		foreach ($this->fields as $fld) {
  80			$fld->ResetCSS();
  81		}
  82	}
  83
  84	//
  85	// Table class constructor
  86	//
  87	function crPRTY_Reports() {
  88		global $ReportLanguage;
  89
  90		// id
  91		$this->id = new crField('PRTY_Reports', 'PRTY Reports', 'x_id', 'id', '`id`', 19, EWRPT_DATATYPE_NUMBER, -1);
  92		$this->id->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
  93		$this->fields['id'] =& $this->id;
  94		$this->id->DateFilter = "";
  95		$this->id->SqlSelect = "";
  96		$this->id->SqlOrderBy = "";
  97
  98		// full_name
  99		$this->full_name = new crField('PRTY_Reports', 'PRTY Reports', 'x_full_name', 'full_name', '`full_name`', 200, EWRPT_DATATYPE_STRING, -1);
 100		$this->fields['full_name'] =& $this->full_name;
 101		$this->full_name->DateFilter = "";
 102		$this->full_name->SqlSelect = "";
 103		$this->full_name->SqlOrderBy = "";
 104
 105		// dob
 106		$this->dob = new crField('PRTY_Reports', 'PRTY Reports', 'x_dob', 'dob', '`dob`', 133, EWRPT_DATATYPE_DATE, 7);
 107		$this->dob->FldDefaultErrMsg = str_replace("%s", "/", $ReportLanguage->Phrase("IncorrectDateDMY"));
 108		$this->fields['dob'] =& $this->dob;
 109		$this->dob->DateFilter = "";
 110		$this->dob->SqlSelect = "";
 111		$this->dob->SqlOrderBy = "";
 112
 113		// priority
 114		$this->priority = new crField('PRTY_Reports', 'PRTY Reports', 'x_priority', 'priority', '`priority`', 202, EWRPT_DATATYPE_STRING, -1);
 115		$this->priority->GroupingFieldId = 1;
 116		$this->fields['priority'] =& $this->priority;
 117		$this->priority->DateFilter = "";
 118		$this->priority->SqlSelect = "SELECT DISTINCT `priority` FROM " . $this->SqlFrom();
 119		$this->priority->SqlOrderBy = "`priority`";
 120		$this->priority->FldGroupByType = "";
 121		$this->priority->FldGroupInt = "0";
 122		$this->priority->FldGroupSql = "";
 123
 124		// department_name
 125		$this->department_name = new crField('PRTY_Reports', 'PRTY Reports', 'x_department_name', 'department_name', '`department_name`', 200, EWRPT_DATATYPE_STRING, -1);
 126		$this->department_name->GroupingFieldId = 2;
 127		$this->fields['department_name'] =& $this->department_name;
 128		$this->department_name->DateFilter = "";
 129		$this->department_name->SqlSelect = "SELECT DISTINCT `department_name` FROM " . $this->SqlFrom();
 130		$this->department_name->SqlOrderBy = "`department_name`";
 131		$this->department_name->FldGroupByType = "";
 132		$this->department_name->FldGroupInt = "0";
 133		$this->department_name->FldGroupSql = "";
 134	}
 135
 136	// Multiple column sort
 137	function UpdateSort(&$ofld, $ctrl) {
 138		if ($this->CurrentOrder == $ofld->FldName) {
 139			$sLastSort = $ofld->getSort();
 140			if ($this->CurrentOrderType == "ASC" || $this->CurrentOrderType == "DESC") {
 141				$sThisSort = $this->CurrentOrderType;
 142			} else {
 143				$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
 144			}
 145			$ofld->setSort($sThisSort);
 146		} else {
 147			if ($ofld->GroupingFieldId == 0 && !$ctrl) $ofld->setSort("");
 148		}
 149	}
 150
 151	// Get Sort SQL
 152	function SortSql() {
 153		$sDtlSortSql = "";
 154		$argrps = array();
 155		foreach ($this->fields as $fld) {
 156			if ($fld->getSort() <> "") {
 157				if ($fld->GroupingFieldId > 0) {
 158					if ($fld->FldGroupSql <> "")
 159						$argrps[$fld->GroupingFieldId] = str_replace("%s", $fld->FldExpression, $fld->FldGroupSql) . " " . $fld->getSort();
 160					else
 161						$argrps[$fld->GroupingFieldId] = $fld->FldExpression . " " . $fld->getSort();
 162				} else {
 163					if ($sDtlSortSql <> "") $sDtlSortSql .= ", ";
 164					$sDtlSortSql .= $fld->FldExpression . " " . $fld->getSort();
 165				}
 166			}
 167		}
 168		$sSortSql = "";
 169		foreach ($argrps as $grp) {
 170			if ($sSortSql <> "") $sSortSql .= ", ";
 171			$sSortSql .= $grp;
 172		}
 173		if ($sDtlSortSql <> "") {
 174			if ($sSortSql <> "") $sSortSql .= ",";
 175			$sSortSql .= $sDtlSortSql;
 176		}
 177		return $sSortSql;
 178	}
 179
 180	// Table level SQL
 181	function SqlFrom() { // From
 182		return "`vw__priority_reports`";
 183	}
 184
 185	function SqlSelect() { // Select
 186		return "SELECT * FROM " . $this->SqlFrom();
 187	}
 188
 189	function SqlWhere() { // Where
 190		return "";
 191	}
 192
 193	function SqlGroupBy() { // Group By
 194		return "";
 195	}
 196
 197	function SqlHaving() { // Having
 198		return "";
 199	}
 200
 201	function SqlOrderBy() { // Order By
 202		return "`priority` ASC, `department_name` ASC";
 203	}
 204
 205	// Table Level Group SQL
 206	function SqlFirstGroupField() {
 207		return "`priority`";
 208	}
 209
 210	function SqlSelectGroup() {
 211		return "SELECT DISTINCT " . $this->SqlFirstGroupField() . " FROM " . $this->SqlFrom();
 212	}
 213
 214	function SqlOrderByGroup() {
 215		return "`priority` ASC";
 216	}
 217
 218	function SqlSelectAgg() {
 219		return "SELECT * FROM " . $this->SqlFrom();
 220	}
 221
 222	function SqlAggPfx() {
 223		return "";
 224	}
 225
 226	function SqlAggSfx() {
 227		return "";
 228	}
 229
 230	function SqlSelectCount() {
 231		return "SELECT COUNT(*) FROM " . $this->SqlFrom();
 232	}
 233
 234	// Sort URL
 235	function SortUrl(&$fld) {
 236		if ($this->Export <> "" ||
 237			in_array($fld->FldType, array(128, 204, 205))) { // Unsortable data type
 238				return "";
 239		} elseif ($fld->Sortable) {
 240			$sUrlParm = "order=" . urlencode($fld->FldName) . "&ordertype=" . $fld->ReverseSort();
 241			return ewrpt_CurrentPage() . "?" . $sUrlParm;
 242		} else {
 243			return "";
 244		}
 245	}
 246
 247	// Row attributes
 248	function RowAttributes() {
 249		$sAtt = "";
 250		foreach ($this->RowAttrs as $k => $v) {
 251			if (trim($v) <> "")
 252				$sAtt .= " " . $k . "=\"" . trim($v) . "\"";
 253		}
 254		return $sAtt;
 255	}
 256
 257	// Field object by fldvar
 258	function &fields($fldvar) {
 259		return $this->fields[$fldvar];
 260	}
 261
 262	// Table level events
 263	// Row Rendering event
 264	function Row_Rendering() {
 265
 266		// Enter your code here	
 267	}
 268
 269	// Cell Rendered event
 270	function Cell_Rendered(&$Field, $CurrentValue, &$ViewValue, &$ViewAttrs, &$CellAttrs, &$HrefValue) {
 271
 272		//$ViewValue = "xxx";
 273		//$ViewAttrs["style"] = "xxx";
 274
 275	}
 276
 277	// Row Rendered event
 278	function Row_Rendered() {
 279
 280		// To view properties of field class, use:
 281		//var_dump($this-><FieldName>); 
 282
 283	}
 284
 285	// Load Filters event
 286	function Filters_Load() {
 287
 288		// Enter your code here	
 289		// Example: Register/Unregister Custom Extended Filter
 290		//ewrpt_RegisterFilter($this-><Field>, 'StartsWithA', 'Starts With A', 'GetStartsWithAFilter');
 291		//ewrpt_UnregisterFilter($this-><Field>, 'StartsWithA');
 292
 293	}
 294
 295	// Page Filter Validated event
 296	function Page_FilterValidated() {
 297
 298		// Example:
 299		//global $MyTable;
 300		//$MyTable->MyField1->SearchValue = "your search criteria"; // Search value
 301
 302	}
 303
 304	// Chart Rendering event
 305	function Chart_Rendering(&$chart) {
 306
 307		// var_dump($chart);
 308	}
 309
 310	// Chart Rendered event
 311	function Chart_Rendered($chart, &$chartxml) {
 312
 313		// Example:	
 314		//$doc = $chart->XmlDoc; // Get the DOMDocument object
 315		// Enter your code to manipulate the DOMDocument object here
 316		//$chartxml = $doc->saveXML(); // Output the XML
 317
 318	}
 319
 320	// Email Sending event
 321	function Email_Sending(&$Email, &$Args) {
 322
 323		//var_dump($Email); var_dump($Args); exit();
 324		return TRUE;
 325	}
 326}
 327?>
 328<?php ewrpt_Header(FALSE) ?>
 329<?php
 330
 331// Create page object
 332$PRTY_Reports_summary = new crPRTY_Reports_summary();
 333$Page =& $PRTY_Reports_summary;
 334
 335// Page init
 336$PRTY_Reports_summary->Page_Init();
 337
 338// Page main
 339$PRTY_Reports_summary->Page_Main();
 340?>
 341<?php include_once "phprptinc/header.php"; ?>
 342<?php if ($PRTY_Reports->Export == "" || $PRTY_Reports->Export == "print" || $PRTY_Reports->Export == "email") { ?>
 343<script type="text/javascript">
 344
 345// Create page object
 346var PRTY_Reports_summary = new ewrpt_Page("PRTY_Reports_summary");
 347
 348// page properties
 349PRTY_Reports_summary.PageID = "summary"; // page ID
 350PRTY_Reports_summary.FormID = "fPRTY_Reportssummaryfilter"; // form ID
 351var EWRPT_PAGE_ID = PRTY_Reports_summary.PageID;
 352
 353// extend page with Chart_Rendering function
 354PRTY_Reports_summary.Chart_Rendering =  
 355 function(chart, chartid) { // DO NOT CHANGE THIS LINE!
 356
 357 	//alert(chartid);
 358 }
 359
 360// extend page with Chart_Rendered function
 361PRTY_Reports_summary.Chart_Rendered =  
 362 function(chart, chartid) { // DO NOT CHANGE THIS LINE!
 363
 364 	//alert(chartid);
 365 }
 366</script>
 367<?php } ?>
 368<?php if ($PRTY_Reports->Export == "") { ?>
 369<script language="JavaScript" type="text/javascript">
 370<!--
 371
 372// Write your client script here, no need to add script tags.
 373//-->
 374
 375</script>
 376<?php } ?>
 377<?php if ($PRTY_Reports->Export == "" || $PRTY_Reports->Export == "print" || $PRTY_Reports->Export == "email") { ?>
 378<script src="<?php echo EWRPT_FUSIONCHARTS_FREE_JSCLASS_FILE; ?>" type="text/javascript"></script>
 379<?php } ?>
 380<?php if ($PRTY_Reports->Export == "") { ?>
 381<div id="ewrpt_PopupFilter"><div class="bd"></div></div>
 382<script src="phprptjs/ewrptpop.js" type="text/javascript"></script>
 383<script type="text/javascript">
 384
 385// popup fields
 386<?php $jsdata = ewrpt_GetJsData($PRTY_Reports->priority, $PRTY_Reports->priority->FldType); ?>
 387ewrpt_CreatePopup("PRTY_Reports_priority", [<?php echo $jsdata ?>]);
 388<?php $jsdata = ewrpt_GetJsData($PRTY_Reports->department_name, $PRTY_Reports->department_name->FldType); ?>
 389ewrpt_CreatePopup("PRTY_Reports_department_name", [<?php echo $jsdata ?>]);
 390</script>
 391<?php } ?>
 392<?php if ($PRTY_Reports->Export == "" || $PRTY_Reports->Export == "print" || $PRTY_Reports->Export == "email") { ?>
 393<!-- Table Container (Begin) -->
 394<table id="ewContainer" cellspacing="0" cellpadding="0" border="0">
 395<!-- Top Container (Begin) -->
 396<tr><td colspan="3"><div id="ewTop" class="phpreportmaker">
 397<!-- top slot -->
 398<a name="top"></a>
 399<?php } ?>
 400<p class="phpreportmaker ewTitle"><?php echo $PRTY_Reports->TableCaption() ?>
 401&nbsp;&nbsp;<?php $PRTY_Reports_summary->ExportOptions->Render("body"); ?></p>
 402<?php $PRTY_Reports_summary->ShowPageHeader(); ?>
 403<?php $PRTY_Reports_summary->ShowMessage(); ?>
 404<br><br>
 405<?php if ($PRTY_Reports->Export == "" || $PRTY_Reports->Export == "print" || $PRTY_Reports->Export == "email") { ?>
 406</div></td></tr>
 407<!-- Top Container (End) -->
 408<tr>
 409	<!-- Left Container (Begin) -->
 410	<td style="vertical-align: top;"><div id="ewLeft" class="phpreportmaker">
 411	<!-- Left slot -->
 412	</div></td>
 413	<!-- Left Container (End) -->
 414	<!-- Center Container - Report (Begin) -->
 415	<td style="vertical-align: top;" class="ewPadding"><div id="ewCenter" class="phpreportmaker">
 416	<!-- center slot -->
 417<?php } ?>
 418<!-- summary report starts -->
 419<div id="report_summary">
 420<?php if ($PRTY_Reports->ShowCurrentFilter) { ?>
 421<div id="ewrptFilterList">
 422<?php $PRTY_Reports_summary->ShowFilterList() ?>
 423</div>
 424<br>
 425<?php } ?>
 426<table class="ewGrid" cellspacing="0"><tr>
 427	<td class="ewGridContent">
 428<?php if ($PRTY_Reports->Export == "") { ?>
 429<div class="ewGridUpperPanel">
 430<form action="<?php echo ewrpt_CurrentPage() ?>" name="ewpagerform" id="ewpagerform" class="ewForm">
 431<table border="0" cellspacing="0" cellpadding="0">
 432	<tr>
 433		<td style="white-space: nowrap;">
 434<?php if (!isset($Pager)) $Pager = new crPrevNextPager($PRTY_Reports_summary->StartGrp, $PRTY_Reports_summary->DisplayGrps, $PRTY_Reports_summary->TotalGrps) ?>
 435<?php if ($Pager->RecordCount > 0) { ?>
 436	<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("Page") ?>&nbsp;</span></td>
 437<!--first page button-->
 438	<?php if ($Pager->FirstButton->Enabled) { ?>
 439	<td><a href="<?php echo ewrpt_CurrentPage() ?>?start=<?php echo $Pager->FirstButton->Start ?>"><img src="phprptimages/first.gif" alt="<?php echo $ReportLanguage->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></a></td>
 440	<?php } else { ?>
 441	<td><img src="phprptimages/firstdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
 442	<?php } ?>
 443<!--previous page button-->
 444	<?php if ($Pager->PrevButton->Enabled) { ?>
 445	<td><a href="<?php echo ewrpt_CurrentPage() ?>?start=<?php echo $Pager->PrevButton->Start ?>"><img src="phprptimages/prev.gif" alt="<?php echo $ReportLanguage->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></a></td>
 446	<?php } else { ?>
 447	<td><img src="phprptimages/prevdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
 448	<?php } ?>
 449<!--current page number-->
 450	<td><input type="text" name="pageno" id="pageno" value="<?php echo $Pager->CurrentPage ?>" size="4"></td>
 451<!--next page button-->
 452	<?php if ($Pager->NextButton->Enabled) { ?>
 453	<td><a href="<?php echo ewrpt_CurrentPage() ?>?start=<?php echo $Pager->NextButton->Start ?>"><img src="phprptimages/next.gif" alt="<?php echo $ReportLanguage->Phrase("PagerNext") ?>" width="16" height="16" border="0"></a></td>	
 454	<?php } else { ?>
 455	<td><img src="phprptimages/nextdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
 456	<?php } ?>
 457<!--last page button-->
 458	<?php if ($Pager->LastButton->Enabled) { ?>
 459	<td><a href="<?php echo ewrpt_CurrentPage() ?>?start=<?php echo $Pager->LastButton->Start ?>"><img src="phprptimages/last.gif" alt="<?php echo $ReportLanguage->Phrase("PagerLast") ?>" width="16" height="16" border="0"></a></td>	
 460	<?php } else { ?>
 461	<td><img src="phprptimages/lastdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
 462	<?php } ?>
 463	<td><span class="phpreportmaker">&nbsp;<?php echo $ReportLanguage->Phrase("of") ?> <?php echo $Pager->PageCount ?></span></td>
 464	</tr></table>
 465	</td>	
 466	<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
 467	<td>
 468	<span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("Record") ?> <?php echo $Pager->FromIndex ?> <?php echo $ReportLanguage->Phrase("To") ?> <?php echo $Pager->ToIndex ?> <?php echo $ReportLanguage->Phrase("Of") ?> <?php echo $Pager->RecordCount ?></span>
 469<?php } else { ?>
 470	<?php if ($PRTY_Reports_summary->Filter == "0=101") { ?>
 471	<span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("EnterSearchCriteria") ?></span>
 472	<?php } else { ?>
 473	<span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("NoRecord") ?></span>
 474	<?php } ?>
 475<?php } ?>
 476		</td>
 477<?php if ($PRTY_Reports_summary->TotalGrps > 0) { ?>
 478		<td style="white-space: nowrap;">&nbsp;&nbsp;&nbsp;&nbsp;</td>
 479		<td align="right" style="vertical-align: top; white-space: nowrap;"><span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("GroupsPerPage"); ?>&nbsp;
 480<select name="<?php echo EWRPT_TABLE_GROUP_PER_PAGE; ?>" onchange="this.form.submit();">
 481<option value="1"<?php if ($PRTY_Reports_summary->DisplayGrps == 1) echo " selected=\"selected\"" ?>>1</option>
 482<option value="2"<?php if ($PRTY_Reports_summary->DisplayGrps == 2) echo " selected=\"selected\"" ?>>2</option>
 483<option value="3"<?php if ($PRTY_Reports_summary->DisplayGrps == 3) echo " selected=\"selected\"" ?>>3</option>
 484<option value="4"<?php if ($PRTY_Reports_summary->DisplayGrps == 4) echo " selected=\"selected\"" ?>>4</option>
 485<option value="5"<?php if ($PRTY_Reports_summary->DisplayGrps == 5) echo " selected=\"selected\"" ?>>5</option>
 486<option value="10"<?php if ($PRTY_Reports_summary->DisplayGrps == 10) echo " selected=\"selected\"" ?>>10</option>
 487<option value="20"<?php if ($PRTY_Reports_summary->DisplayGrps == 20) echo " selected=\"selected\"" ?>>20</option>
 488<option value="50"<?php if ($PRTY_Reports_summary->DisplayGrps == 50) echo " selected=\"selected\"" ?>>50</option>
 489<option value="ALL"<?php if ($PRTY_Reports->getGroupPerPage() == -1) echo " selected=\"selected\"" ?>><?php echo $ReportLanguage->Phrase("AllRecords") ?></option>
 490</select>
 491		</span></td>
 492<?php } ?>
 493	</tr>
 494</table>
 495</form>
 496</div>
 497<?php } ?>
 498<!-- Report Grid (Begin) -->
 499<div class="ewGridMiddlePanel">
 500<table class="<?php echo $PRTY_Reports_summary->ReportTableClass ?>" cellspacing="0">
 501<?php
 502
 503// Set the last group to display if not export all
 504if ($PRTY_Reports->ExportAll && $PRTY_Reports->Export <> "") {
 505	$PRTY_Reports_summary->StopGrp = $PRTY_Reports_summary->TotalGrps;
 506} else {
 507	$PRTY_Reports_summary->StopGrp = $PRTY_Reports_summary->StartGrp + $PRTY_Reports_summary->DisplayGrps - 1;
 508}
 509
 510// Stop group <= total number of groups
 511if (intval($PRTY_Reports_summary->StopGrp) > intval($PRTY_Reports_summary->TotalGrps))
 512	$PRTY_Reports_summary->StopGrp = $PRTY_Reports_summary->TotalGrps;
 513$PRTY_Reports_summary->RecCount = 0;
 514
 515// Get first row
 516if ($PRTY_Reports_summary->TotalGrps > 0) {
 517	$PRTY_Reports_summary->GetGrpRow(1);
 518	$PRTY_Reports_summary->GrpCount = 1;
 519}
 520while (($rsgrp && !$rsgrp->EOF && $PRTY_Reports_summary->GrpCount <= $PRTY_Reports_summary->DisplayGrps) || $PRTY_Reports_summary->ShowFirstHeader) {
 521
 522	// Show header
 523	if ($PRTY_Reports_summary->ShowFirstHeader) {
 524?>
 525	<thead>
 526	<tr>
 527<td class="ewTableHeader">
 528<?php if ($PRTY_Reports->Export <> "") { ?>
 529<?php echo $PRTY_Reports->priority->FldCaption() ?>
 530<?php } else { ?>
 531	<table cellspacing="0" class="ewTableHeaderBtn"><tr>
 532<?php if ($PRTY_Reports->SortUrl($PRTY_Reports->priority) == "") { ?>
 533		<td style="vertical-align: bottom;"><?php echo $PRTY_Reports->priority->FldCaption() ?></td>
 534<?php } else { ?>
 535		<td class="ewPointer" onmousedown="ewrpt_Sort(event,'<?php echo $PRTY_Reports->SortUrl($PRTY_Reports->priority) ?>',2);"><?php echo $PRTY_Reports->priority->FldCaption() ?></td><td style="width: 10px;">
 536		<?php if ($PRTY_Reports->priority->getSort() == "ASC") { ?><img src="phprptimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($PRTY_Reports->priority->getSort() == "DESC") { ?><img src="phprptimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td>
 537<?php } ?>
 538		<td style="width: 20px;" align="right"><a href="#" onclick="ewrpt_ShowPopup(this.name, 'PRTY_Reports_priority', false, '<?php echo $PRTY_Reports->priority->RangeFrom; ?>', '<?php echo $PRTY_Reports->priority->RangeTo; ?>');return false;" name="x_priority<?php echo $PRTY_Reports_summary->Cnt[0][0]; ?>" id="x_priority<?php echo $PRTY_Reports_summary->Cnt[0][0]; ?>"><img src="phprptimages/popup.gif" width="15" height="14" border="0" alt="<?php echo $ReportLanguage->Phrase("Filter") ?>"></a></td>
 539	</tr></table>
 540<?php } ?>
 541</td>
 542<td class="ewTableHeader">
 543<?php if ($PRTY_Reports->Export <> "") { ?>
 544<?php echo $PRTY_Reports->department_name->FldCaption() ?>
 545<?php } else { ?>
 546	<table cellspacing="0" class="ewTableHeaderBtn"><tr>
 547<?php if ($PRTY_Reports->SortUrl($PRTY_Reports->department_name) == "") { ?>
 548		<td style="vertical-align: bottom;"><?php echo $PRTY_Reports->department_name->FldCaption() ?></td>
 549<?php } else { ?>
 550		<td class="ewPointer" onmousedown="ewrpt_Sort(event,'<?php echo $PRTY_Reports->SortUrl($PRTY_Reports->department_name) ?>',2);"><?php echo $PRTY_Reports->department_name->FldCaption() ?></td><td style="width: 10px;">
 551		<?php if ($PRTY_Reports->department_name->getSort() == "ASC") { ?><img src="phprptimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($PRTY_Reports->department_name->getSort() == "DESC") { ?><img src="phprptimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td>
 552<?php } ?>
 553		<td style="width: 20px;" align="right"><a href="#" onclick="ewrpt_ShowPopup(this.name, 'PRTY_Reports_department_name', false, '<?php echo $PRTY_Reports->department_name->RangeFrom; ?>', '<?php echo $PRTY_Reports->department_name->RangeTo; ?>');return false;" name="x_department_name<?php echo $PRTY_Reports_summary->Cnt[0][0]; ?>" id="x_department_name<?php echo $PRTY_Reports_summary->Cnt[0][0]; ?>"><img src="phprptimages/popup.gif" width="15" height="14" border="0" alt="<?php echo $ReportLanguage->Phrase("Filter") ?>"></a></td>
 554	</tr></table>
 555<?php } ?>
 556</td>
 557<td class="ewTableHeader">
 558<?php if ($PRTY_Reports->Export <> "") { ?>
 559<?php echo $PRTY_Reports->full_name->FldCaption() ?>
 560<?php } else { ?>
 561	<table cellspacing="0" class="ewTableHeaderBtn"><tr>
 562<?php if ($PRTY_Reports->SortUrl($PRTY_Reports->full_name) == "") { ?>
 563		<td style="vertical-align: bottom;"><?php echo $PRTY_Reports->full_name->FldCaption() ?></td>
 564<?php } else { ?>
 565		<td class="ewPointer" onmousedown="ewrpt_Sort(event,'<?php echo $PRTY_Reports->SortUrl($PRTY_Reports->full_name) ?>',2);"><?php echo $PRTY_Reports->full_name->FldCaption() ?></td><td style="width: 10px;">
 566		<?php if ($PRTY_Reports->full_name->getSort() == "ASC") { ?><img src="phprptimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($PRTY_Reports->full_name->getSort() == "DESC") { ?><img src="phprptimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td>
 567<?php } ?>
 568	</tr></table>
 569<?php } ?>
 570</td>
 571<td class="ewTableHeader">
 572<?php if ($PRTY_Reports->Export <> "") { ?>
 573<?php echo $PRTY_Reports->dob->FldCaption() ?>
 574<?php } else { ?>
 575	<table cellspacing="0" class="ewTableHeaderBtn"><tr>
 576<?php if ($PRTY_Reports->SortUrl($PRTY_Reports->dob) == "") { ?>
 577		<td style="vertical-align: bottom;"><?php echo $PRTY_Reports->dob->FldCaption() ?></td>
 578<?php } else { ?>
 579		<td class="ewPointer" onmousedown="ewrpt_Sort(event,'<?php echo $PRTY_Reports->SortUrl($PRTY_Reports->dob) ?>',2);"><?php echo $PRTY_Reports->dob->FldCaption() ?></td><td style="width: 10px;">
 580		<?php if ($PRTY_Reports->dob->getSort() == "ASC") { ?><img src="phprptimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($PRTY_Reports->dob->getSort() == "DESC") { ?><img src="phprptimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td>
 581<?php } ?>
 582	</tr></table>
 583<?php } ?>
 584</td>
 585	</tr>
 586	</thead>
 587	<tbody>
 588<?php
 589		$PRTY_Reports_summary->ShowFirstHeader = FALSE;
 590	}
 591
 592	// Build detail SQL
 593	$sWhere = ewrpt_DetailFilterSQL($PRTY_Reports->priority, $PRTY_Reports->SqlFirstGroupField(), $PRTY_Reports->priority->GroupValue());
 594	if ($PRTY_Reports_summary->Filter != "")
 595		$sWhere = "($PRTY_Reports_summary->Filter) AND ($sWhere)";
 596	$sSql = ewrpt_BuildReportSql($PRTY_Reports->SqlSelect(), $PRTY_Reports->SqlWhere(), $PRTY_Reports->SqlGroupBy(), $PRTY_Reports->SqlHaving(), $PRTY_Reports->SqlOrderBy(), $sWhere, $PRTY_Reports_summary->Sort);
 597	$rs = $conn->Execute($sSql);
 598	$rsdtlcnt = ($rs) ? $rs->RecordCount() : 0;
 599	if ($rsdtlcnt > 0)
 600		$PRTY_Reports_summary->GetRow(1);
 601	while ($rs && !$rs->EOF) { // Loop detail records
 602		$PRTY_Reports_summary->RecCount++;
 603
 604		// Render detail row
 605		$PRTY_Reports->ResetCSS();
 606		$PRTY_Reports->RowType = EWRPT_ROWTYPE_DETAIL;
 607		$PRTY_Reports_summary->RenderRow();
 608?>
 609	<tr<?php echo $PRTY_Reports->RowAttributes(); ?>>
 610		<td<?php echo $PRTY_Reports->priority->CellAttributes(); ?>>
 611<span<?php echo $PRTY_Reports->priority->ViewAttributes(); ?>><?php echo $PRTY_Reports->priority->GroupViewValue; ?></span></td>
 612		<td<?php echo $PRTY_Reports->department_name->CellAttributes(); ?>>
 613<span<?php echo $PRTY_Reports->department_name->ViewAttributes(); ?>><?php echo $PRTY_Reports->department_name->GroupViewValue; ?></span></td>
 614		<td<?php echo $PRTY_Reports->full_name->CellAttributes() ?>>
 615<span<?php echo $PRTY_Reports->full_name->ViewAttributes(); ?>><?php echo $PRTY_Reports->full_name->ListViewValue(); ?></span></td>
 616		<td<?php echo $PRTY_Reports->dob->CellAttributes() ?>>
 617<span<?php echo $PRTY_Reports->dob->ViewAttributes(); ?>><?php echo $PRTY_Reports->dob->ListViewValue(); ?></span></td>
 618	</tr>
 619<?php
 620
 621		// Accumulate page summary
 622		$PRTY_Reports_summary->AccumulateSummary();
 623
 624		// Get next record
 625		$PRTY_Reports_summary->GetRow(2);
 626
 627		// Show Footers
 628?>
 629<?php
 630	} // End detail records loop
 631?>
 632<?php
 633?>
 634<?php
 635			$PRTY_Reports->ResetCSS();
 636			$PRTY_Reports->RowType = EWRPT_ROWTYPE_TOTAL;
 637			$PRTY_Reports->RowTotalType = EWRPT_ROWTOTAL_GROUP;
 638			$PRTY_Reports->RowTotalSubType = EWRPT_ROWTOTAL_FOOTER;
 639			$PRTY_Reports->RowGroupLevel = 1;
 640			$PRTY_Reports_summary->RenderRow();
 641?>
 642	<tr<?php echo $PRTY_Reports->RowAttributes(); ?>>
 643		<td colspan="4"<?php echo $PRTY_Reports->priority->CellAttributes() ?>><?php echo $ReportLanguage->Phrase("RptSumHead") ?> <?php echo $PRTY_Reports->priority->FldCaption() ?>: <?php echo $PRTY_Reports->priority->GroupViewValue; ?> (<?php echo ewrpt_FormatNumber($PRTY_Reports_summary->Cnt[1][0],0,-2,-2,-2); ?><?php echo $ReportLanguage->Phrase("RptDtlRec") ?>)</td></tr>
 644<?php
 645
 646			// Reset level 1 summary
 647			$PRTY_Reports_summary->ResetLevelSummary(1);
 648?>
 649<?php
 650
 651	// Next group
 652	$PRTY_Reports_summary->GetGrpRow(2);
 653	$PRTY_Reports_summary->GrpCount++;
 654} // End while
 655?>
 656	</tbody>
 657	<tfoot>
 658<?php
 659if ($PRTY_Reports_summary->TotalGrps > 0) {
 660	$PRTY_Reports->ResetCSS();
 661	$PRTY_Reports->RowType = EWRPT_ROWTYPE_TOTAL;
 662	$PRTY_Reports->RowTotalType = EWRPT_ROWTOTAL_GRAND;
 663	$PRTY_Reports->RowTotalSubType = EWRPT_ROWTOTAL_FOOTER;
 664	$PRTY_Reports->RowAttrs["class"] = "ewRptGrandSummary";
 665	$PRTY_Reports_summary->RenderRow();
 666?>
 667	<!-- tr><td colspan="4"><span class="phpreportmaker">&nbsp;<br></span></td></tr -->
 668	<tr<?php echo $PRTY_Reports->RowAttributes(); ?>><td colspan="4"><?php echo $ReportLanguage->Phrase("RptGrandTotal") ?> (<?php echo ewrpt_FormatNumber($PRTY_Reports_summary->TotCount,0,-2,-2,-2); ?><?php echo $ReportLanguage->Phrase("RptDtlRec") ?>)</td></tr>
 669<?php } ?>
 670	</tfoot>
 671</table>
 672</div>
 673<?php if ($PRTY_Reports_summary->TotalGrps > 0) { ?>
 674<?php if ($PRTY_Reports->Export == "") { ?>
 675<div class="ewGridLowerPanel">
 676<form action="<?php echo ewrpt_CurrentPage() ?>" name="ewpagerform" id="ewpagerform" class="ewForm">
 677<table border="0" cellspacing="0" cellpadding="0">
 678	<tr>
 679		<td style="white-space: nowrap;">
 680<?php if (!isset($Pager)) $Pager = new crPrevNextPager($PRTY_Reports_summary->StartGrp, $PRTY_Reports_summary->DisplayGrps, $PRTY_Reports_summary->TotalGrps) ?>
 681<?php if ($Pager->RecordCount > 0) { ?>
 682	<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("Page") ?>&nbsp;</span></td>
 683<!--first page button-->
 684	<?php if ($Pager->FirstButton->Enabled) { ?>
 685	<td><a href="<?php echo ewrpt_CurrentPage() ?>?start=<?php echo $Pager->FirstButton->Start ?>"><img src="phprptimages/first.gif" alt="<?php echo $ReportLanguage->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></a></td>
 686	<?php } else { ?>
 687	<td><img src="phprptimages/firstdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
 688	<?php } ?>
 689<!--previous page button-->
 690	<?php if ($Pager->PrevButton->Enabled) { ?>
 691	<td><a href="<?php echo ewrpt_CurrentPage() ?>?start=<?php echo $Pager->PrevButton->Start ?>"><img src="phprptimages/prev.gif" alt="<?php echo $ReportLanguage->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></a></td>
 692	<?php } else { ?>
 693	<td><img src="phprptimages/prevdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
 694	<?php } ?>
 695<!--current page number-->
 696	<td><input type="text" name="pageno" id="pageno" value="<?php echo $Pager->CurrentPage ?>" size="4"></td>
 697<!--next page button-->
 698	<?php if ($Pager->NextButton->Enabled) { ?>
 699	<td><a href="<?php echo ewrpt_CurrentPage() ?>?start=<?php echo $Pager->NextButton->Start ?>"><img src="phprptimages/next.gif" alt="<?php echo $ReportLanguage->Phrase("PagerNext") ?>" width="16" height="16" border="0"></a></td>	
 700	<?php } else { ?>
 701	<td><img src="phprptimages/nextdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
 702	<?php } ?>
 703<!--last page button-->
 704	<?php if ($Pager->LastButton->Enabled) { ?>
 705	<td><a href="<?php echo ewrpt_CurrentPage() ?>?start=<?php echo $Pager->LastButton->Start ?>"><img src="phprptimages/last.gif" alt="<?php echo $ReportLanguage->Phrase("PagerLast") ?>" width="16" height="16" border="0"></a></td>	
 706	<?php } else { ?>
 707	<td><img src="phprptimages/lastdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
 708	<?php } ?>
 709	<td><span class="phpreportmaker">&nbsp;<?php echo $ReportLanguage->Phrase("of") ?> <?php echo $Pager->PageCount ?></span></td>
 710	</tr></table>
 711	</td>	
 712	<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
 713	<td>
 714	<span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("Record") ?> <?php echo $Pager->FromIndex ?> <?php echo $ReportLanguage->Phrase("To") ?> <?php echo $Pager->ToIndex ?> <?php echo $ReportLanguage->Phrase("Of") ?> <?php echo $Pager->RecordCount ?></span>
 715<?php } else { ?>
 716	<?php if ($PRTY_Reports_summary->Filter == "0=101") { ?>
 717	<span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("EnterSearchCriteria") ?></span>
 718	<?php } else { ?>
 719	<span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("NoRecord") ?></span>
 720	<?php } ?>
 721<?php } ?>
 722		</td>
 723<?php if ($PRTY_Reports_summary->TotalGrps > 0) { ?>
 724		<td style="white-space: nowrap;">&nbsp;&nbsp;&nbsp;&nbsp;</td>
 725		<td align="right" style="vertical-align: top; white-space: nowrap;"><span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("GroupsPerPage"); ?>&nbsp;
 726<select name="<?php echo EWRPT_TABLE_GROUP_PER_PAGE; ?>" onchange="this.form.submit();">
 727<option value="1"<?php if ($PRTY_Reports_summary->DisplayGrps == 1) echo " selected=\"selected\"" ?>>1</option>
 728<option value="2"<?php if ($PRTY_Reports_summary->DisplayGrps == 2) echo " selected=\"selected\"" ?>>2</option>
 729<option value="3"<?php if ($PRTY_Reports_summary->DisplayGrps == 3) echo " selected=\"selected\"" ?>>3</option>
 730<option value="4"<?php if ($PRTY_Reports_summary->DisplayGrps == 4) echo " selected=\"selected\"" ?>>4</option>
 731<option value="5"<?php if ($PRTY_Reports_summary->DisplayGrps == 5) echo " selected=\"selected\"" ?>>5</option>
 732<option value="10"<?php if ($PRTY_Reports_summary->DisplayGrps == 10) echo " selected=\"selected\"" ?>>10</option>
 733<option value="20"<?php if ($PRTY_Reports_summary->DisplayGrps == 20) echo " selected=\"selected\"" ?>>20</option>
 734<option value="50"<?php if ($PRTY_Reports_summary->DisplayGrps == 50) echo " selected=\"selected\"" ?>>50</option>
 735<option value="ALL"<?php if ($PRTY_Reports->getGroupPerPage() == -1) echo " selected=\"selected\"" ?>><?php echo $ReportLanguage->Phrase("AllRecords") ?></option>
 736</select>
 737		</span></td>
 738<?php } ?>
 739	</tr>
 740</table>
 741</form>
 742</div>
 743<?php } ?>
 744<?php } ?>
 745</td></tr></table>
 746</div>
 747<!-- Summary Report Ends -->
 748<?php if ($PRTY_Reports->Export == "" || $PRTY_Reports->Export == "print" || $PRTY_Reports->Export == "email") { ?>
 749	</div><br></td>
 750	<!-- Center Container - Report (End) -->
 751	<!-- Right Container (Begin) -->
 752	<td style="vertical-align: top;"><div id="ewRight" class="phpreportmaker">
 753	<!-- Right slot -->
 754	</div></td>
 755	<!-- Right Container (End) -->
 756</tr>
 757<!-- Bottom Container (Begin) -->
 758<tr><td colspan="3"><div id="ewBottom" class="phpreportmaker">
 759	<!-- Bottom slot -->
 760	</div><br></td></tr>
 761<!-- Bottom Container (End) -->
 762</table>
 763<!-- Table Container (End) -->
 764<?php } ?>
 765<?php $PRTY_Reports_summary->ShowPageFooter(); ?>
 766<?php if (EWRPT_DEBUG_ENABLED) echo ewrpt_DebugMsg(); ?>
 767<?php
 768
 769// Close recordsets
 770if ($rsgrp) $rsgrp->Close();
 771if ($rs) $rs->Close();
 772?>
 773<?php if ($PRTY_Reports->Export == "") { ?>
 774<script language="JavaScript" type="text/javascript">
 775<!--
 776
 777// Write your table-specific startup script here
 778// document.write("page loaded");
 779//-->
 780
 781</script>
 782<?php } ?>
 783<?php include_once "phprptinc/footer.php"; ?>
 784<?php
 785$PRTY_Reports_summary->Page_Terminate();
 786?>
 787<?php
 788
 789//
 790// Page class
 791//
 792class crPRTY_Reports_summary {
 793
 794	// Page ID
 795	var $PageID = 'summary';
 796
 797	// Table name
 798	var $TableName = 'PRTY Reports';
 799
 800	// Page object name
 801	var $PageObjName = 'PRTY_Reports_summary';
 802
 803	// Page name
 804	function PageName() {
 805		return ewrpt_CurrentPage();
 806	}
 807
 808	// Page URL
 809	function PageUrl() {
 810		$PageUrl = ewrpt_CurrentPage() . "?";
 811		global $PRTY_Reports;
 812		if ($PRTY_Reports->UseTokenInUrl) $PageUrl .= "t=" . $PRTY_Reports->TableVar . "&"; // Add page token
 813		return $PageUrl;
 814	}
 815
 816	// Export URLs
 817	var $ExportPrintUrl;
 818	var $ExportExcelUrl;
 819	var $ExportWordUrl;
 820	var $ExportPdfUrl;
 821	var $ReportTableClass;
 822
 823	// Message
 824	function getMessage() {
 825		return @$_SESSION[EWRPT_SESSION_MESSAGE];
 826	}
 827
 828	function setMessage($v) {
 829		if (@$_SESSION[EWRPT_SESSION_MESSAGE] <> "") { // Append
 830			$_SESSION[EWRPT_SESSION_MESSAGE] .= "<br>" . $v;
 831		} else {
 832			$_SESSION[EWRPT_SESSION_MESSAGE] = $v;
 833		}
 834	}
 835
 836	// Show message
 837	function ShowMessage() {
 838		$sMessage = $this->getMessage();
 839		$this->Message_Showing($sMessage);
 840		if ($sMessage <> "") { // Message in Session, display
 841			echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
 842			$_SESSION[EWRPT_SESSION_MESSAGE] = ""; // Clear message in Session
 843		}
 844	}
 845	var $PageHeader;
 846	var $PageFooter;
 847
 848	// Show Page Header
 849	function ShowPageHeader() {
 850		$sHeader = $this->PageHeader;
 851		$this->Page_DataRendering($sHeader);
 852		if ($sHeader <> "") { // Header exists, display
 853			echo "<p><span class=\"phpreportmaker\">" . $sHeader . "</span></p>";
 854		}
 855	}
 856
 857	// Show Page Footer
 858	function ShowPageFooter() {
 859		$sFooter = $this->PageFooter;
 860		$this->Page_DataRendered($sFooter);
 861		if ($sFooter <> "") { // Fotoer exists, display
 862			echo "<p><span class=\"phpreportmaker\">" . $sFooter . "</span></p>";
 863		}
 864	}
 865
 866	// Validate page request
 867	function IsPageRequest() {
 868		global $PRTY_Reports;
 869		if ($PRTY_Reports->UseTokenInUrl) {
 870			if (ewrpt_IsHttpPost())
 871				return ($PRTY_Reports->TableVar == @$_POST("t"));
 872			if (@$_GET["t"] <> "")
 873				return ($PRTY_Reports->TableVar == @$_GET["t"]);
 874		} else {
 875			return TRUE;
 876		}
 877	}
 878
 879	//
 880	// Page class constructor
 881	//
 882	function crPRTY_Reports_summary() {
 883		global $conn, $ReportLanguage;
 884
 885		// Language object
 886		$ReportLanguage = new crLanguage();
 887
 888		// Table object (PRTY_Reports)
 889		$GLOBALS["PRTY_Reports"] = new crPRTY_Reports();
 890		$GLOBALS["Table"] =& $GLOBALS["PRTY_Reports"];
 891
 892		// Initialize URLs
 893		$this->ExportPrintUrl = $this->PageUrl() . "export=print";
 894		$this->ExportExcelUrl = $this->PageUrl() . "export=excel";
 895		$this->ExportWordUrl = $this->PageUrl() . "export=word";
 896		$this->ExportPdfUrl = $this->PageUrl() . "export=pdf";
 897
 898		// Page ID
 899		if (!defined("EWRPT_PAGE_ID"))
 900			define("EWRPT_PAGE_ID", 'summary', TRUE);
 901
 902		// Table name (for backward compatibility)
 903		if (!defined("EWRPT_TABLE_NAME"))
 904			define("EWRPT_TABLE_NAME", 'PRTY Reports', TRUE);
 905
 906		// Start timer
 907		$GLOBALS["gsTimer"] = new crTimer();
 908
 909		// Open connection
 910		$conn = ewrpt_Connect();
 911
 912		// Export options
 913		$this->ExportOptions = new crListOptions();
 914		$this->ExportOptions->Tag = "span";
 915		$this->ExportOptions->Separator = "&nbsp;&nbsp;";
 916	}
 917
 918	// 
 919	//  Page_Init
 920	//
 921	function Page_Init() {
 922		global $gsExport, $gsExportFile, $ReportLanguage, $Security;
 923		global $PRTY_Reports;
 924
 925		// Get export parameters
 926		if (@$_GET["export"] <> "") {
 927			$PRTY_Reports->Export = $_GET["export"];
 928		}
 929		$gsExport = $PRTY_Reports->Export; // Get export parameter, used in header
 930		$gsExportFile = $PRTY_Reports->TableVar; // Get export file, used in header
 931		if ($PRTY_Reports->Export == "excel") {
 932			header('Content-Type: application/vnd.ms-excel;charset=utf-8');
 933			header('Content-Disposition: attachment; filename=' . $gsExportFile .'.xls');
 934		}
 935		if ($PRTY_Reports->Export == "word") {
 936			header('Content-Type: application/vnd.ms-word;charset=utf-8');
 937			header('Content-Disposition: attachment; filename=' . $gsExportFile .'.doc');
 938		}
 939
 940		// Setup export options
 941		$this->SetupExportOptions();
 942
 943		// Global Page Loading event (in userfn*.php)
 944		Page_Loading();
 945
 946		// Page Load event
 947		$this->Page_Load();
 948	}
 949
 950	// Set up export options
 951	function SetupExportOptions() {
 952		global $ReportLanguage, $PRTY_Reports;
 953
 954		// Printer friendly
 955		$item =& $this->ExportOptions->Add("print");
 956		$item->Body = "<a href=\"" . $this->ExportPrintUrl . "\">" . $ReportLanguage->Phrase("PrinterFriendly") . "</a>";
 957		$item->Visible = TRUE;
 958
 959		// Export to Excel
 960		$item =& $this->ExportOptions->Add("excel");
 961		$item->Body = "<a href=\"" . $this->ExportExcelUrl . "\">" . $ReportLanguage->Phrase("ExportToExcel") . "</a>";
 962		$item->Visible = TRUE;
 963
 964		// Export to Word
 965		$item =& $this->ExportOptions->Add("word");
 966		$item->Body = "<a href=\"" . $this->ExportWordUrl . "\">" . $ReportLanguage->Phrase("ExportToWord") . "</a>";
 967		$item->Visible = TRUE;
 968
 969		// Export to Pdf
 970		$item =& $this->ExportOptions->Add("pdf");
 971		$item->Body = "<a href=\"" . $this->ExportPdfUrl . "\">" . $ReportLanguage->Phrase("ExportToPDF") . "</a>";
 972		$item->Visible = FALSE;
 973
 974		// Uncomment codes below to show export to Pdf link
 975//		$item->Visible = FALSE;
 976		// Export to Email
 977
 978		$item =& $this->ExportOptions->Add("email");
 979		$item->Body = "<a name=\"emf_PRTY_Reports\" id=\"emf_PRTY_Reports\" href=\"javascript:void(0);\" onclick=\"ewrpt_EmailDialogShow({lnk:'emf_PRTY_Reports',hdr:ewLanguage.Phrase('ExportToEmail')});\">" . $ReportLanguage->Phrase("ExportToEmail") . "</a>";
 980		$item->Visible = FALSE;
 981
 982		// Reset filter
 983		$item =& $this->ExportOptions->Add("resetfilter");
 984		$item->Body = "<a href=\"" . ewrpt_CurrentPage() . "?cmd=reset\">" . $ReportLanguage->Phrase("ResetAllFilter") . "</a>";
 985		$item->Visible = TRUE;
 986		$this->SetupExportOptionsExt();
 987
 988		// Hide options for export
 989		if ($PRTY_Reports->Export <> "")
 990			$this->ExportOptions->HideAllOptions();
 991
 992		// Set up table class
 993		if ($PRTY_Reports->Export == "word" || $PRTY_Reports->Export == "excel" || $PRTY_Reports->Export == "pdf")
 994			$this->ReportTableClass = "ewTable";
 995		else
 996			$this->ReportTableClass = "ewTable ewTableSeparate";
 997	}
 998
 999	//
1000	// Page_Terminate
1001	//
1002	function Page_Terminate($url = "") {
1003		global $conn;
1004		global $ReportLanguage;
1005		global $PRTY_Reports;
1006
1007		// Page Unload event
1008		$this->Page_Unload();
1009
1010		// Global Page Unloaded event (in userfn*.php)
1011		Page_Unloaded();
1012
1013		// Export to Email (use ob_file_contents for PHP)
1014		if ($PRTY_Reports->Export == "email") {
1015			$sContent = ob_get_contents();
1016			$this->ExportEmail($sContent);
1017			ob_end_clean();
1018
1019			 // Close connection
1020			$conn->Close();
1021			header("Location: " . ewrpt_CurrentPage());
1022			exit();
1023		}
1024
1025		// Export to PDF (use ob_file_contents for PHP)
1026		if ($PRTY_Reports->Export == "pdf") {
1027			$sContent = ob_get_contents();
1028			$this->ExportPDF($sContent);
1029			ob_end_clean();
1030
1031			 // Close connection
1032			$conn->Close();
1033		}
1034
1035		 // Close connection
1036		$conn->Close();
1037
1038		// Go to URL if specified
1039		if ($url <> "") {
1040			if (!EWRPT_DEBUG_ENABLED && ob_get_length())
1041				ob_end_clean();
1042			header("Location: " . $url);
1043		}
1044		exit();
1045	}
1046
1047	// Initialize common variables
1048	var $ExportOptions; // Export options
1049
1050	// Paging variables
1051	var $RecCount = 0; // Record count
1052	var $StartGrp = 0; // Start group
1053	var $StopGrp = 0; // Stop group
1054	var $TotalGrps = 0; // Total groups
1055	var $GrpCount = 0; // Group count
1056	var $DisplayGrps = 10; // Groups per page
1057	var $GrpRange = 10;
1058	var $Sort = "";
1059	var $Filter = "";
1060	var $UserIDFilter = "";
1061
1062	// Clear field for ext filter
1063	var $ClearExtFilter = "";
1064	var $FilterApplied;
1065	var $ShowFirstHeader;
1066	var $Cnt, $Col, $Val, $Smry, $Mn, $Mx, $GrandSmry, $GrandMn, $GrandMx;
1067	var $TotCount;
1068
1069	//
1070	// Page main
1071	//
1072	function Page_Main() {
1073		global $PRTY_Reports;
1074		global $rs;
1075		global $rsgrp;
1076		global $gsFormError;
1077
1078		// Aggregate variables
1079		// 1st dimension = no of groups (level 0 used for grand total)
1080		// 2nd dimension = no of fields
1081
1082		$nDtls = 3;
1083		$nGrps = 3;
1084		$this->Val =& ewrpt_InitArray($nDtls, 0);
1085		$this->Cnt =& ewrpt_Init2DArray($nGrps, $nDtls, 0);
1086		$this->Smry =& ewrpt_Init2DArray($nGrps, $nDtls, 0);
1087		$this->Mn =& ewrpt_Init2DArray($nGrps, $nDtls, NULL);
1088		$this->Mx =& ewrpt_Init2DArray($nGrps, $nDtls, NULL);
1089		$this->GrandSmry =& ewrpt_InitArray($nDtls, 0);
1090		$this->GrandMn =& ewrpt_InitArray($nDtls, NULL);
1091		$this->GrandMx =& ewrpt_InitArray($nDtls, NULL);
1092
1093		// Set up if accumulation required
1094		$this->Col = array(FALSE, FALSE, FALSE);
1095
1096		// Set up groups per page dynamically
1097		$this->SetUpDisplayGrps();
1098		$PRTY_Reports->priority->SelectionList = "";
1099		$PRTY_Reports->priority->DefaultSelectionList = "";
1100		$PRTY_Reports->priority->ValueList = "";
1101		$PRTY_Reports->department_name->SelectionList = "";
1102		$PRTY_Reports->department_name->DefaultSelectionList = "";
1103		$PRTY_Reports->department_name->ValueList = "";
1104
1105		// Load default filter values
1106		$this->LoadDefaultFilters();
1107
1108		// Load custom filters
1109		$PRTY_Reports->Filters_Load();
1110
1111		// Set up popup filter
1112		$this->SetupPopup();
1113
1114		// Extended filter
1115		$sExtendedFilter = "";
1116
1117		// Build popup filter
1118		$sPopupFilter = $this->GetPopupFilter();
1119
1120		//ewrpt_SetDebugMsg("popup filter: " . $sPopupFilter);
1121		if ($sPopupFilter <> "") {
1122			if ($this->Filter <> "")
1123				$this->Filter = "($this->Filter) AND ($sPopupFilter)";
1124			else
1125				$this->Filter = $sPopupFilter;
1126		}
1127
1128		// Check if filter applied
1129		$this->FilterApplied = $this->CheckFilter();
1130		$this->ExportOptions->GetItem("resetfilter")->Visible = $this->FilterApplied;
1131
1132		// Get sort
1133		$this->Sort = $this->GetSort();
1134
1135		// Get total group count
1136		$sGrpSort = ewrpt_UpdateSortFields($PRTY_Reports->SqlOrderByGroup(), $this->Sort, 2); // Get grouping field only
1137		$sSql = ewrpt_BuildReportSql($PRTY_Reports->SqlSelectGroup(), $PRTY_Reports->SqlWhere(), $PRTY_Reports->SqlGroupBy(), $PRTY_Reports->SqlHaving(), $PRTY_Reports->SqlOrderByGroup(), $this->Filter, $sGrpSort);
1138		$this->TotalGrps = $this->GetGrpCnt($sSql);
1139		if ($this->DisplayGrps <= 0) // Display all groups
1140			$this->DisplayGrps = $this->TotalGrps;
1141		$this->StartGrp = 1;
1142
1143		// Show header
1144		$this->ShowFirstHeader = ($this->TotalGrps > 0);
1145
1146		//$this->ShowFirstHeader = TRUE; // Uncomment to always show header
1147		// Set up start position if not export all
1148
1149		if ($PRTY_Reports->ExportAll && $PRTY_Reports->Export <> "")
1150		    $this->DisplayGrps = $this->TotalGrps;
1151		else
1152			$this->SetUpStartGroup(); 
1153
1154		// Hide all options if export
1155		if ($PRTY_Reports->Export <> "") {
1156			$this->ExportOptions->HideAllOptions();
1157		}
1158
1159		// Get current page groups
1160		$rsgrp = $this->GetGrpRs($sSql, $this->StartGrp, $this->DisplayGrps);
1161
1162		// Init detail recordset
1163		$rs = NULL;
1164	}
1165
1166	// Check level break
1167	function ChkLvlBreak($lvl) {
1168		global $PRTY_Reports;
1169		switch ($lvl) {
1170			case 1:
1171				return (is_null($PRTY_Reports->priority->CurrentValue) && !is_null($PRTY_Reports->priority->OldValue)) ||
1172					(!is_null($PRTY_Reports->priority->CurrentValue) && is_null($PRTY_Reports->priority->OldValue)) ||
1173					($PRTY_Reports->priority->GroupValue() <> $PRTY_Reports->priority->GroupOldValue());
1174			case 2:
1175				return (is_null($PRTY_Reports->department_name->CurrentValue) && !is_null($PRTY_Reports->department_name->OldValue)) ||
1176					(!is_null($PRTY_Reports->department_name->CurrentValue) && is_null($PRTY_Reports->department_name->OldValue)) ||
1177					($PRTY_Reports->department_name->GroupValue() <> $PRTY_Reports->department_name->GroupOldValue()) || $this->ChkLvlBreak(1); // Recurse upper level
1178		}
1179	}
1180
1181	// Accummulate summary
1182	function AccumulateSummary() {
1183		$cntx = count($this->Smry);
1184		for ($ix = 0; $ix < $cntx; $ix++) {
1185			$cnty = count($this->Smry[$ix]);
1186			for ($iy = 1; $iy < $cnty; $iy++) {
1187				$this->Cnt[$ix][$iy]++;
1188				if ($this->Col[$iy]) {
1189					$valwrk = $this->Val[$iy];
1190					if (is_null($valwrk) || !is_numeric($valwrk)) {
1191
1192						// skip
1193					} else {
1194						$this->Smry[$ix][$iy] += $valwrk;
1195						if (is_null($this->Mn[$ix][$iy])) {
1196							$this->Mn[$ix][$iy] = $valwrk;
1197							$this->Mx[$ix][$iy] = $valwrk;
1198						} else {
1199							if ($this->Mn[$ix][$iy] > $valwrk) $this->Mn[$ix][$iy] = $valwrk;
1200							if ($this->Mx[$ix][$iy] < $valwrk) $this->Mx[$ix][$iy] = $valwrk;
1201						}
1202					}
1203				}
1204			}
1205		}
1206		$cntx = count($this->Smry);
1207		for ($ix = 1; $ix < $cntx; $ix++) {
1208			$this->Cnt[$ix][0]++;
1209		}
1210	}
1211
1212	// Reset level summary
1213	function ResetLevelSummary($lvl) {
1214
1215		// Clear summary values
1216		$cntx = count($this->Smry);
1217		for ($ix = $lvl; $ix < $cntx; $ix++) {
1218			$cnty = count($this->Smry[$ix]);
1219			for ($iy = 1; $iy < $cnty; $iy++) {
1220				$this->Cnt[$ix][$iy] = 0;
1221				if ($this->Col[$iy]) {
1222					$this->Smry[$ix][$iy] = 0;
1223					$this->Mn[$ix][$iy] = NULL;
1224					$this->Mx[$ix][$iy] = NULL;
1225				}
1226			}
1227		}
1228		$cntx = count($this->Smry);
1229		for ($ix = $lvl; $ix < $cntx; $ix++) {
1230			$this->Cnt[$ix][0] = 0;
1231		}
1232
1233		// Reset record count
1234		$this->RecCount = 0;
1235	}
1236
1237	// Accummulate grand summary
1238	function AccumulateGrandSummary() {
1239		$this->Cnt[0][0]++;
1240		$cntgs = count($this->GrandSmry);
1241		for ($iy = 1; $iy < $cntgs; $iy++) {
1242			if ($this->Col[$iy]) {
1243				$valwrk = $this->Val[$iy];
1244				if (is_null($valwrk) || !is_numeric($valwrk)) {
1245
1246					// skip
1247				} else {
1248					$this->GrandSmry[$iy] += $valwrk;
1249					if (is_null($this->GrandMn[$iy])) {
1250						$this->GrandMn[$iy] = $valwrk;
1251						$this->GrandMx[$iy] = $valwrk;
1252					} else {
1253						if ($this->GrandMn[$iy] > $valwrk) $this->GrandMn[$iy] = $valwrk;
1254						if ($this->GrandMx[$iy] < $valwrk) $this->GrandMx[$iy] = $valwrk;
1255					}
1256				}
1257			}
1258		}
1259	}
1260
1261	// Get group count
1262	function GetGrpCnt($sql) {
1263		global $conn;
1264		global $PRTY_Reports;
1265		$rsgrpcnt = $conn->Execute($sql);
1266		$grpcnt = ($rsgrpcnt) ? $rsgrpcnt->RecordCount() : 0;
1267		if ($rsgrpcnt) $rsgrpcnt->Close();
1268		return $grpcnt;
1269	}
1270
1271	// Get group rs
1272	function GetGrpRs($sql, $start, $grps) {
1273		global $conn;
1274		global $PRTY_Reports;
1275		$wrksql = $sql;
1276		if ($start > 0 && $grps > -1)
1277			$wrksql .= " LIMIT " . ($start-1) . ", " . ($grps);
1278		$rswrk = $conn->Execute($wrksql);
1279		return $rswrk;
1280	}
1281
1282	// Get group row values
1283	function GetGrpRow($opt) {
1284		global $rsgrp;
1285		global $PRTY_Reports;
1286		if (!$rsgrp)
1287			return;
1288		if ($opt == 1) { // Get first group
1289
1290			//$rsgrp->MoveFirst(); // NOTE: no need to move position
1291			$PRTY_Reports->priority->setDbValue(""); // Init first value
1292		} else { // Get next group
1293			$rsgrp->MoveNext();
1294		}
1295		if (!$rsgrp->EOF)
1296			$PRTY_Reports->priority->setDbValue($rsgrp->fields[0]);
1297		if ($rsgrp->EOF) {
1298			$PRTY_Reports->priority->setDbValue("");
1299		}
1300	}
1301
1302	// Get row values
1303	function GetRow($opt) {
1304		global $rs;
1305		global $PRTY_Reports;
1306		if (!$rs)
1307			return;
1308		if ($opt == 1) { // Get first row
1309
1310	//		$rs->MoveFirst(); // NOTE: no need to move position
1311		} else { // Get next row
1312			$rs->MoveNext();
1313		}
1314		if (!$rs->EOF) {
1315			$PRTY_Reports->id->setDbValue($rs->fields('id'));
1316			$PRTY_Reports->full_name->setDbValue($rs->fields('full_name'));
1317			$PRTY_Reports->dob->setDbValue($rs->fields('dob'));
1318			if ($opt <> 1) {
1319				if (is_array($PRTY_Reports->priority->GroupDbValues))
1320					$PRTY_Reports->priority->setDbValue(@$PRTY_Reports->priority->GroupDbValues[$rs->fields('priority')]);
1321				else
1322					$PRTY_Reports->priority->setDbValue(ewrpt_GroupValue($PRTY_Reports->priority, $rs->fields('priority')));
1323			}
1324			$PRTY_Reports->department_name->setDbValue($rs->fields('department_name'));
1325			$this->Val[1] = $PRTY_Reports->full_name->CurrentValue;
1326			$this->Val[2] = $PRTY_Reports->dob->CurrentValue;
1327		} else {
1328			$PRTY_Reports->id->setDbValue("");
1329			$PRTY_Reports->full_name->setDbValue("");
1330			$PRTY_Reports->dob->setDbValue("");
1331			$PRTY_Reports->priority->setDbValue("");
1332			$PRTY_Reports->department_name->setDbValue("");
1333		}
1334	}
1335
1336	//  Set up starting group
1337	function SetUpStartGroup() {
1338		global $PRTY_Reports;
1339
1340		// Exit if no groups
1341		if ($this->DisplayGrps == 0)
1342			return;
1343
1344		// Check for a 'start' parameter
1345		if (@$_GET[EWRPT_TABLE_START_GROUP] != "") {
1346			$this->StartGrp = $_GET[EWRPT_TABLE_START_GROUP];
1347			$PRTY_Reports->setStartGroup($this->StartGrp);
1348		} elseif (@$_GET["pageno"] != "") {
1349			$nPageNo = $_GET["pageno"];
1350			if (is_numeric($nPageNo)) {
1351				$thiā€¦

Large files files are truncated, but you can click here to view the full file