PageRenderTime 50ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 1ms

/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
Possible License(s): LGPL-2.1

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

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

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