PageRenderTime 52ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/diezmolist_1.php

https://github.com/fredd-for/emaus_tesoreria
PHP | 956 lines | 721 code | 108 blank | 127 comment | 195 complexity | 36bf063bbd934daf061a93f35f3a66d6 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. session_start(); // Initialize session data
  3. ob_start(); // Turn on output buffering
  4. ?>
  5. <?php include "ewcfg6.php" ?>
  6. <?php include "ewmysql6.php" ?>
  7. <?php include "phpfn6.php" ?>
  8. <?php include "diezmoinfo.php" ?>
  9. <?php include "usuarioinfo.php" ?>
  10. <?php include "userfn6.php" ?>
  11. <?php
  12. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  13. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
  14. header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
  15. header("Cache-Control: post-check=0, pre-check=0", false);
  16. header("Pragma: no-cache"); // HTTP/1.0
  17. ?>
  18. <?php
  19. // Define page object
  20. $diezmo_list = new cdiezmo_list();
  21. $Page =& $diezmo_list;
  22. // Page init processing
  23. $diezmo_list->Page_Init();
  24. // Page main processing
  25. $diezmo_list->Page_Main();
  26. ?>
  27. <?php include "header.php" ?>
  28. <?php if ($diezmo->Export == "") { ?>
  29. <script type="text/javascript">
  30. <!--
  31. // Create page object
  32. var diezmo_list = new ew_Page("diezmo_list");
  33. // page properties
  34. diezmo_list.PageID = "list"; // page ID
  35. var EW_PAGE_ID = diezmo_list.PageID; // for backward compatibility
  36. // extend page with Form_CustomValidate function
  37. diezmo_list.Form_CustomValidate =
  38. function(fobj) { // DO NOT CHANGE THIS LINE!
  39. // Your custom validation code here, return false if invalid.
  40. return true;
  41. }
  42. <?php if (EW_CLIENT_VALIDATE) { ?>
  43. diezmo_list.ValidateRequired = true; // uses JavaScript validation
  44. <?php } else { ?>
  45. diezmo_list.ValidateRequired = false; // no JavaScript validation
  46. <?php } ?>
  47. //-->
  48. </script>
  49. <script language="JavaScript" type="text/javascript">
  50. <!--
  51. // Write your client script here, no need to add script tags.
  52. // To include another .js script, use:
  53. // ew_ClientScriptInclude("my_javascript.js");
  54. //-->
  55. </script>
  56. <?php } ?>
  57. <?php if ($diezmo->Export == "") { ?>
  58. <?php } ?>
  59. <?php
  60. $bSelectLimit = ($diezmo->Export == "" && $diezmo->SelectLimit);
  61. if (!$bSelectLimit)
  62. $rs = $diezmo_list->LoadRecordset();
  63. $diezmo_list->lTotalRecs = ($bSelectLimit) ? $diezmo->SelectRecordCount() : $rs->RecordCount();
  64. $diezmo_list->lStartRec = 1;
  65. if ($diezmo_list->lDisplayRecs <= 0) // Display all records
  66. $diezmo_list->lDisplayRecs = $diezmo_list->lTotalRecs;
  67. if (!($diezmo->ExportAll && $diezmo->Export <> ""))
  68. $diezmo_list->SetUpStartRec(); // Set up start record position
  69. if ($bSelectLimit)
  70. $rs = $diezmo_list->LoadRecordset($diezmo_list->lStartRec-1, $diezmo_list->lDisplayRecs);
  71. ?>
  72. <p><span class="phpmaker" style="white-space: nowrap;">TABLA: Diezmo
  73. <?php if ($diezmo->Export == "" && $diezmo->CurrentAction == "") { ?>
  74. &nbsp;&nbsp;<a href="<?php echo $diezmo_list->PageUrl() ?>export=excel">Exportar a Excel</a>
  75. <?php } ?>
  76. </span></p>
  77. <?php $diezmo_list->ShowMessage() ?>
  78. <br>
  79. <table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
  80. <div class="ewGridMiddlePanel">
  81. <form name="fdiezmolist" id="fdiezmolist" class="ewForm" action="" method="post">
  82. <?php if ($diezmo_list->lTotalRecs > 0) { ?>
  83. <table cellspacing="0" rowhighlightclass="ewTableHighlightRow" rowselectclass="ewTableSelectRow" roweditclass="ewTableEditRow" class="ewTable ewTableSeparate">
  84. <?php
  85. $diezmo_list->lOptionCnt = 0;
  86. if ($Security->CanView()) {
  87. $diezmo_list->lOptionCnt++; // view
  88. }
  89. if ($Security->CanEdit()) {
  90. $diezmo_list->lOptionCnt++; // edit
  91. }
  92. if ($Security->CanDelete()) {
  93. $diezmo_list->lOptionCnt++; // Delete
  94. }
  95. $diezmo_list->lOptionCnt += count($diezmo_list->ListOptions->Items); // Custom list options
  96. ?>
  97. <?php echo $diezmo->TableCustomInnerHtml ?>
  98. <thead><!-- Table header -->
  99. <tr class="ewTableHeader">
  100. <?php if ($diezmo->idDiezmo->Visible) { // idDiezmo ?>
  101. <?php if ($diezmo->SortUrl($diezmo->idDiezmo) == "") { ?>
  102. <td>Nro</td>
  103. <?php } else { ?>
  104. <td class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $diezmo->SortUrl($diezmo->idDiezmo) ?>',1);">
  105. <table cellspacing="0" class="ewTableHeaderBtn"><tr><td>Nro</td><td style="width: 10px;"><?php if ($diezmo->idDiezmo->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($diezmo->idDiezmo->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></table>
  106. </td>
  107. <?php } ?>
  108. <?php } ?>
  109. <?php if ($diezmo->idMiembro->Visible) { // idMiembro ?>
  110. <?php if ($diezmo->SortUrl($diezmo->idMiembro) == "") { ?>
  111. <td>Id Miembro</td>
  112. <?php } else { ?>
  113. <td class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $diezmo->SortUrl($diezmo->idMiembro) ?>',1);">
  114. <table cellspacing="0" class="ewTableHeaderBtn"><tr><td>Id Miembro</td><td style="width: 10px;"><?php if ($diezmo->idMiembro->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($diezmo->idMiembro->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></table>
  115. </td>
  116. <?php } ?>
  117. <?php } ?>
  118. <?php if ($diezmo->fecha->Visible) { // fecha ?>
  119. <?php if ($diezmo->SortUrl($diezmo->fecha) == "") { ?>
  120. <td>Fecha</td>
  121. <?php } else { ?>
  122. <td class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $diezmo->SortUrl($diezmo->fecha) ?>',1);">
  123. <table cellspacing="0" class="ewTableHeaderBtn"><tr><td>Fecha</td><td style="width: 10px;"><?php if ($diezmo->fecha->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($diezmo->fecha->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></table>
  124. </td>
  125. <?php } ?>
  126. <?php } ?>
  127. <?php if ($diezmo->montoDiezmo->Visible) { // montoDiezmo ?>
  128. <?php if ($diezmo->SortUrl($diezmo->montoDiezmo) == "") { ?>
  129. <td>Monto Diezmo</td>
  130. <?php } else { ?>
  131. <td class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $diezmo->SortUrl($diezmo->montoDiezmo) ?>',1);">
  132. <table cellspacing="0" class="ewTableHeaderBtn"><tr><td>Monto Diezmo</td><td style="width: 10px;"><?php if ($diezmo->montoDiezmo->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($diezmo->montoDiezmo->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></table>
  133. </td>
  134. <?php } ?>
  135. <?php } ?>
  136. <?php if ($diezmo->Export == "") { ?>
  137. <?php if ($Security->CanView()) { ?>
  138. <td style="white-space: nowrap;">&nbsp;</td>
  139. <?php } ?>
  140. <?php if ($Security->CanEdit()) { ?>
  141. <td style="white-space: nowrap;">&nbsp;</td>
  142. <?php } ?>
  143. <?php if ($Security->CanDelete()) { ?>
  144. <td style="white-space: nowrap;">&nbsp;</td>
  145. <?php } ?>
  146. <?php
  147. // Custom list options
  148. foreach ($diezmo_list->ListOptions->Items as $ListOption) {
  149. if ($ListOption->Visible)
  150. echo $ListOption->HeaderCellHtml;
  151. }
  152. ?>
  153. <?php } ?>
  154. </tr>
  155. </thead>
  156. <?php
  157. if ($diezmo->ExportAll && $diezmo->Export <> "") {
  158. $diezmo_list->lStopRec = $diezmo_list->lTotalRecs;
  159. } else {
  160. $diezmo_list->lStopRec = $diezmo_list->lStartRec + $diezmo_list->lDisplayRecs - 1; // Set the last record to display
  161. }
  162. $diezmo_list->lRecCount = $diezmo_list->lStartRec - 1;
  163. if ($rs && !$rs->EOF) {
  164. $rs->MoveFirst();
  165. if (!$diezmo->SelectLimit && $diezmo_list->lStartRec > 1)
  166. $rs->Move($diezmo_list->lStartRec - 1);
  167. }
  168. $diezmo_list->lRowCnt = 0;
  169. while (($diezmo->CurrentAction == "gridadd" || !$rs->EOF) &&
  170. $diezmo_list->lRecCount < $diezmo_list->lStopRec) {
  171. $diezmo_list->lRecCount++;
  172. if (intval($diezmo_list->lRecCount) >= intval($diezmo_list->lStartRec)) {
  173. $diezmo_list->lRowCnt++;
  174. // Init row class and style
  175. $diezmo->CssClass = "";
  176. $diezmo->CssStyle = "";
  177. $diezmo->RowClientEvents = "onmouseover='ew_MouseOver(event, this);' onmouseout='ew_MouseOut(event, this);' onclick='ew_Click(event, this);'";
  178. if ($diezmo->CurrentAction == "gridadd") {
  179. $diezmo_list->LoadDefaultValues(); // Load default values
  180. } else {
  181. $diezmo_list->LoadRowValues($rs); // Load row values
  182. }
  183. $diezmo->RowType = EW_ROWTYPE_VIEW; // Render view
  184. // Render row
  185. $diezmo_list->RenderRow();
  186. ?>
  187. <tr<?php echo $diezmo->RowAttributes() ?>>
  188. <?php if ($diezmo->idDiezmo->Visible) { // idDiezmo ?>
  189. <td<?php echo $diezmo->idDiezmo->CellAttributes() ?>>
  190. <div<?php echo $diezmo->idDiezmo->ViewAttributes() ?>><?php echo $diezmo->idDiezmo->ListViewValue() ?></div>
  191. </td>
  192. <?php } ?>
  193. <?php if ($diezmo->idMiembro->Visible) { // idMiembro ?>
  194. <td<?php echo $diezmo->idMiembro->CellAttributes() ?>>
  195. <div<?php echo $diezmo->idMiembro->ViewAttributes() ?>><?php echo $diezmo->idMiembro->ListViewValue() ?></div>
  196. </td>
  197. <?php } ?>
  198. <?php if ($diezmo->fecha->Visible) { // fecha ?>
  199. <td<?php echo $diezmo->fecha->CellAttributes() ?>>
  200. <div<?php echo $diezmo->fecha->ViewAttributes() ?>><?php echo $diezmo->fecha->ListViewValue() ?></div>
  201. </td>
  202. <?php } ?>
  203. <?php if ($diezmo->montoDiezmo->Visible) { // montoDiezmo ?>
  204. <td<?php echo $diezmo->montoDiezmo->CellAttributes() ?>>
  205. <div<?php echo $diezmo->montoDiezmo->ViewAttributes() ?>><?php echo $diezmo->montoDiezmo->ListViewValue() ?></div>
  206. </td>
  207. <?php } ?>
  208. <?php if ($diezmo->Export == "") { ?>
  209. <?php if ($Security->CanView()) { ?>
  210. <td style="white-space: nowrap;"><span class="phpmaker">
  211. <a href="<?php echo $diezmo->ViewUrl() ?>">Ver</a>
  212. </span></td>
  213. <?php } ?>
  214. <?php if ($Security->CanEdit()) { ?>
  215. <td style="white-space: nowrap;"><span class="phpmaker">
  216. <a href="<?php echo $diezmo->EditUrl() ?>">Editar</a>
  217. </span></td>
  218. <?php } ?>
  219. <?php if ($Security->CanDelete()) { ?>
  220. <td style="white-space: nowrap;"><span class="phpmaker">
  221. <a onclick="ew_ClickDelete(this);return ew_ConfirmDelete('<?php echo $diezmo_list->sDeleteConfirmMsg ?>', this);" href="<?php echo $diezmo->DeleteUrl() ?>">Borrar</a>
  222. </span></td>
  223. <?php } ?>
  224. <?php
  225. // Custom list options
  226. foreach ($diezmo_list->ListOptions->Items as $ListOption) {
  227. if ($ListOption->Visible)
  228. echo $ListOption->BodyCellHtml;
  229. }
  230. ?>
  231. <?php } ?>
  232. </tr>
  233. <?php
  234. }
  235. if ($diezmo->CurrentAction <> "gridadd")
  236. $rs->MoveNext();
  237. }
  238. ?>
  239. </tbody>
  240. </table>
  241. <?php } ?>
  242. </form>
  243. <?php
  244. // Close recordset
  245. if ($rs)
  246. $rs->Close();
  247. ?>
  248. </div>
  249. <?php if ($diezmo->Export == "") { ?>
  250. <div class="ewGridLowerPanel">
  251. <?php if ($diezmo->CurrentAction <> "gridadd" && $diezmo->CurrentAction <> "gridedit") { ?>
  252. <form name="ewpagerform" id="ewpagerform" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
  253. <table border="0" cellspacing="0" cellpadding="0" class="ewPager">
  254. <tr>
  255. <td nowrap>
  256. <?php if (!isset($diezmo_list->Pager)) $diezmo_list->Pager = new cPrevNextPager($diezmo_list->lStartRec, $diezmo_list->lDisplayRecs, $diezmo_list->lTotalRecs) ?>
  257. <?php if ($diezmo_list->Pager->RecordCount > 0) { ?>
  258. <table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpmaker">Página&nbsp;</span></td>
  259. <!--first page button-->
  260. <?php if ($diezmo_list->Pager->FirstButton->Enabled) { ?>
  261. <td><a href="<?php echo $diezmo_list->PageUrl() ?>start=<?php echo $diezmo_list->Pager->FirstButton->Start ?>"><img src="images/first.gif" alt="Primera" width="16" height="16" border="0"></a></td>
  262. <?php } else { ?>
  263. <td><img src="images/firstdisab.gif" alt="Primera" width="16" height="16" border="0"></td>
  264. <?php } ?>
  265. <!--previous page button-->
  266. <?php if ($diezmo_list->Pager->PrevButton->Enabled) { ?>
  267. <td><a href="<?php echo $diezmo_list->PageUrl() ?>start=<?php echo $diezmo_list->Pager->PrevButton->Start ?>"><img src="images/prev.gif" alt="Anterior" width="16" height="16" border="0"></a></td>
  268. <?php } else { ?>
  269. <td><img src="images/prevdisab.gif" alt="Anterior" width="16" height="16" border="0"></td>
  270. <?php } ?>
  271. <!--current page number-->
  272. <td><input type="text" name="<?php echo EW_TABLE_PAGE_NO ?>" id="<?php echo EW_TABLE_PAGE_NO ?>" value="<?php echo $diezmo_list->Pager->CurrentPage ?>" size="4"></td>
  273. <!--next page button-->
  274. <?php if ($diezmo_list->Pager->NextButton->Enabled) { ?>
  275. <td><a href="<?php echo $diezmo_list->PageUrl() ?>start=<?php echo $diezmo_list->Pager->NextButton->Start ?>"><img src="images/next.gif" alt="Siguiente" width="16" height="16" border="0"></a></td>
  276. <?php } else { ?>
  277. <td><img src="images/nextdisab.gif" alt="Siguiente" width="16" height="16" border="0"></td>
  278. <?php } ?>
  279. <!--last page button-->
  280. <?php if ($diezmo_list->Pager->LastButton->Enabled) { ?>
  281. <td><a href="<?php echo $diezmo_list->PageUrl() ?>start=<?php echo $diezmo_list->Pager->LastButton->Start ?>"><img src="images/last.gif" alt="Ultima" width="16" height="16" border="0"></a></td>
  282. <?php } else { ?>
  283. <td><img src="images/lastdisab.gif" alt="Ultima" width="16" height="16" border="0"></td>
  284. <?php } ?>
  285. <td><span class="phpmaker">&nbsp;de <?php echo $diezmo_list->Pager->PageCount ?></span></td>
  286. </tr></table>
  287. </td>
  288. <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
  289. <td>
  290. <span class="phpmaker">Registro <?php echo $diezmo_list->Pager->FromIndex ?> a <?php echo $diezmo_list->Pager->ToIndex ?> de <?php echo $diezmo_list->Pager->RecordCount ?></span>
  291. <?php } else { ?>
  292. <?php if ($Security->CanList()) { ?>
  293. <?php if ($diezmo_list->sSrchWhere == "0=101") { ?>
  294. <span class="phpmaker">Por favor ingrese criterio de busqueda</span>
  295. <?php } else { ?>
  296. <span class="phpmaker">No se encontraron registros</span>
  297. <?php } ?>
  298. <?php } else { ?>
  299. <span class="phpmaker">No tiene permisos para consultar esta página</span>
  300. <?php } ?>
  301. <?php } ?>
  302. </td>
  303. <?php if ($diezmo_list->lTotalRecs > 0) { ?>
  304. <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
  305. <td><table border="0" cellspacing="0" cellpadding="0"><tr><td>Registros por página&nbsp;</td><td>
  306. <input type="hidden" id="t" name="t" value="diezmo">
  307. <select name="<?php echo EW_TABLE_REC_PER_PAGE ?>" id="<?php echo EW_TABLE_REC_PER_PAGE ?>" onchange="this.form.submit();" class="phpmaker">
  308. <option value="20"<?php if ($diezmo_list->lDisplayRecs == 20) { ?> selected="selected"<?php } ?>>20</option>
  309. <option value="50"<?php if ($diezmo_list->lDisplayRecs == 50) { ?> selected="selected"<?php } ?>>50</option>
  310. <option value="ALL"<?php if ($diezmo->getRecordsPerPage() == -1) { ?> selected="selected"<?php } ?>>Todos los registros</option>
  311. </select></td></tr></table>
  312. </td>
  313. <?php } ?>
  314. </tr>
  315. </table>
  316. </form>
  317. <?php } ?>
  318. <?php //if ($diezmo_list->lTotalRecs > 0) { ?>
  319. <span class="phpmaker">
  320. <?php if ($Security->CanAdd()) { ?>
  321. <a href="<?php echo $diezmo->AddUrl() ?>">Agregar</a>&nbsp;&nbsp;
  322. <?php } ?>
  323. </span>
  324. <?php //} ?>
  325. </div>
  326. <?php } ?>
  327. </td></tr></table>
  328. <?php if ($diezmo->Export == "" && $diezmo->CurrentAction == "") { ?>
  329. <script type="text/javascript">
  330. <!--
  331. //ew_ToggleSearchPanel(diezmo_list); // uncomment to init search panel as collapsed
  332. //-->
  333. </script>
  334. <?php } ?>
  335. <?php if ($diezmo->Export == "") { ?>
  336. <script language="JavaScript" type="text/javascript">
  337. <!--
  338. // Write your table-specific startup script here
  339. // document.write("page loaded");
  340. //-->
  341. </script>
  342. <?php } ?>
  343. <?php include "footer.php" ?>
  344. <?php
  345. //
  346. // Page Class
  347. //
  348. class cdiezmo_list {
  349. // Page ID
  350. var $PageID = 'list';
  351. // Table Name
  352. var $TableName = 'diezmo';
  353. // Page Object Name
  354. var $PageObjName = 'diezmo_list';
  355. // Page Name
  356. function PageName() {
  357. return ew_CurrentPage();
  358. }
  359. // Page Url
  360. function PageUrl() {
  361. $PageUrl = ew_CurrentPage() . "?";
  362. global $diezmo;
  363. if ($diezmo->UseTokenInUrl) $PageUrl .= "t=" . $diezmo->TableVar . "&"; // add page token
  364. return $PageUrl;
  365. }
  366. // Message
  367. function getMessage() {
  368. return @$_SESSION[EW_SESSION_MESSAGE];
  369. }
  370. function setMessage($v) {
  371. if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Append
  372. $_SESSION[EW_SESSION_MESSAGE] .= "<br>" . $v;
  373. } else {
  374. $_SESSION[EW_SESSION_MESSAGE] = $v;
  375. }
  376. }
  377. // Show Message
  378. function ShowMessage() {
  379. if ($this->getMessage() <> "") { // Message in Session, display
  380. echo "<p><span class=\"ewMessage\">" . $this->getMessage() . "</span></p>";
  381. $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
  382. }
  383. }
  384. // Validate Page request
  385. function IsPageRequest() {
  386. global $objForm, $diezmo;
  387. if ($diezmo->UseTokenInUrl) {
  388. //IsPageRequest = False
  389. if ($objForm)
  390. return ($diezmo->TableVar == $objForm->GetValue("t"));
  391. if (@$_GET["t"] <> "")
  392. return ($diezmo->TableVar == $_GET["t"]);
  393. } else {
  394. return TRUE;
  395. }
  396. }
  397. //
  398. // Class initialize
  399. // - init objects
  400. // - open connection
  401. //
  402. function cdiezmo_list() {
  403. global $conn;
  404. // Initialize table object
  405. $GLOBALS["diezmo"] = new cdiezmo();
  406. // Initialize other table object
  407. $GLOBALS['usuario'] = new cusuario();
  408. // Intialize page id (for backward compatibility)
  409. if (!defined("EW_PAGE_ID"))
  410. define("EW_PAGE_ID", 'list', TRUE);
  411. // Initialize table name (for backward compatibility)
  412. if (!defined("EW_TABLE_NAME"))
  413. define("EW_TABLE_NAME", 'diezmo', TRUE);
  414. // Open connection to the database
  415. $conn = ew_Connect();
  416. // Initialize list options
  417. $this->ListOptions = new cListOptions();
  418. }
  419. //
  420. // Page_Init
  421. //
  422. function Page_Init() {
  423. global $gsExport, $gsExportFile, $diezmo;
  424. global $Security;
  425. $Security = new cAdvancedSecurity();
  426. if (!$Security->IsLoggedIn()) $Security->AutoLogin();
  427. if (!$Security->IsLoggedIn()) {
  428. $Security->SaveLastUrl();
  429. $this->Page_Terminate("login.php");
  430. }
  431. $Security->TablePermission_Loading();
  432. $Security->LoadCurrentUserLevel($this->TableName);
  433. $Security->TablePermission_Loaded();
  434. if (!$Security->IsLoggedIn()) {
  435. $Security->SaveLastUrl();
  436. $this->Page_Terminate("login.php");
  437. }
  438. if (!$Security->CanList()) {
  439. $Security->SaveLastUrl();
  440. $this->Page_Terminate("login.php");
  441. }
  442. $diezmo->Export = @$_GET["export"]; // Get export parameter
  443. $gsExport = $diezmo->Export; // Get export parameter, used in header
  444. $gsExportFile = $diezmo->TableVar; // Get export file, used in header
  445. if ($diezmo->Export == "excel") {
  446. header('Content-Type: application/vnd.ms-excel');
  447. header('Content-Disposition: attachment; filename=' . $gsExportFile .'.xls');
  448. }
  449. // Global page loading event (in userfn6.php)
  450. Page_Loading();
  451. // Page load event, used in current page
  452. $this->Page_Load();
  453. }
  454. //
  455. // Page_Terminate
  456. // - called when exit page
  457. // - if URL specified, redirect to the URL
  458. //
  459. function Page_Terminate($url = "") {
  460. global $conn;
  461. // Page unload event, used in current page
  462. $this->Page_Unload();
  463. // Global page unloaded event (in userfn*.php)
  464. Page_Unloaded();
  465. // Close Connection
  466. $conn->Close();
  467. // Go to URL if specified
  468. if ($url <> "") {
  469. ob_end_clean();
  470. header("Location: $url");
  471. }
  472. exit();
  473. }
  474. var $lDisplayRecs; // Number of display records
  475. var $lStartRec;
  476. var $lStopRec;
  477. var $lTotalRecs;
  478. var $lRecRange;
  479. var $sSrchWhere;
  480. var $lRecCnt;
  481. var $lEditRowCnt;
  482. var $lRowCnt;
  483. var $lRowIndex;
  484. var $lOptionCnt;
  485. var $lRecPerRow;
  486. var $lColCnt;
  487. var $sDeleteConfirmMsg; // Delete confirm message
  488. var $sDbMasterFilter;
  489. var $sDbDetailFilter;
  490. var $bMasterRecordExists;
  491. var $ListOptions;
  492. var $sMultiSelectKey;
  493. //
  494. // Page main processing
  495. //
  496. function Page_Main() {
  497. global $objForm, $gsSearchError, $Security, $diezmo;
  498. $this->lDisplayRecs = 20;
  499. $this->lRecRange = 10;
  500. $this->lRecCnt = 0; // Record count
  501. // Search filters
  502. $sSrchAdvanced = ""; // Advanced search filter
  503. $sSrchBasic = ""; // Basic search filter
  504. $sFilter = "";
  505. $this->sSrchWhere = ""; // Search WHERE clause
  506. $this->sDeleteConfirmMsg = "żQuiere borrar este registro?"; // Delete confirm message
  507. // Master/Detail
  508. $this->sDbMasterFilter = ""; // Master filter
  509. $this->sDbDetailFilter = ""; // Detail filter
  510. if ($this->IsPageRequest()) { // Validate request
  511. // Set up records per page dynamically
  512. $this->SetUpDisplayRecs();
  513. // Handle reset command
  514. $this->ResetCmd();
  515. // Set Up Sorting Order
  516. $this->SetUpSortOrder();
  517. } // End Validate Request
  518. // Restore display records
  519. if ($diezmo->getRecordsPerPage() <> "") {
  520. $this->lDisplayRecs = $diezmo->getRecordsPerPage(); // Restore from Session
  521. } else {
  522. $this->lDisplayRecs = 20; // Load default
  523. }
  524. // Load Sorting Order
  525. $this->LoadSortOrder();
  526. // Build filter
  527. $sFilter = "";
  528. if (!$Security->CanList()) {
  529. $sFilter = "(0=1)"; // Filter all records
  530. }
  531. if ($this->sDbDetailFilter <> "")
  532. $sFilter = ($sFilter <> "") ? "($sFilter) AND (" . $this->sDbDetailFilter . ")" : $this->sDbDetailFilter;
  533. if ($this->sSrchWhere <> "")
  534. $sFilter = ($sFilter <> "") ? "($sFilter) AND (". $this->sSrchWhere . ")" : $this->sSrchWhere;
  535. // Set up filter in Session
  536. $diezmo->setSessionWhere($sFilter);
  537. $diezmo->CurrentFilter = "";
  538. // Export data only
  539. if (in_array($diezmo->Export, array("html","word","excel","xml","csv"))) {
  540. $this->ExportData();
  541. $this->Page_Terminate(); // Terminate response
  542. exit();
  543. }
  544. }
  545. // Set up number of records displayed per page
  546. function SetUpDisplayRecs() {
  547. global $diezmo;
  548. $sWrk = @$_GET[EW_TABLE_REC_PER_PAGE];
  549. if ($sWrk <> "") {
  550. if (is_numeric($sWrk)) {
  551. $this->lDisplayRecs = intval($sWrk);
  552. } else {
  553. if (strtolower($sWrk) == "all") { // Display all records
  554. $this->lDisplayRecs = -1;
  555. } else {
  556. $this->lDisplayRecs = 20; // Non-numeric, load default
  557. }
  558. }
  559. $diezmo->setRecordsPerPage($this->lDisplayRecs); // Save to Session
  560. // Reset start position
  561. $this->lStartRec = 1;
  562. $diezmo->setStartRecordNumber($this->lStartRec);
  563. }
  564. }
  565. // Set up Sort parameters based on Sort Links clicked
  566. function SetUpSortOrder() {
  567. global $diezmo;
  568. // Check for an Order parameter
  569. if (@$_GET["order"] <> "") {
  570. $diezmo->CurrentOrder = ew_StripSlashes(@$_GET["order"]);
  571. $diezmo->CurrentOrderType = @$_GET["ordertype"];
  572. $diezmo->UpdateSort($diezmo->idDiezmo); // Field
  573. $diezmo->UpdateSort($diezmo->idMiembro); // Field
  574. $diezmo->UpdateSort($diezmo->fecha); // Field
  575. $diezmo->UpdateSort($diezmo->montoDiezmo); // Field
  576. $diezmo->setStartRecordNumber(1); // Reset start position
  577. }
  578. }
  579. // Load Sort Order parameters
  580. function LoadSortOrder() {
  581. global $diezmo;
  582. $sOrderBy = $diezmo->getSessionOrderBy(); // Get order by from Session
  583. if ($sOrderBy == "") {
  584. if ($diezmo->SqlOrderBy() <> "") {
  585. $sOrderBy = $diezmo->SqlOrderBy();
  586. $diezmo->setSessionOrderBy($sOrderBy);
  587. }
  588. }
  589. }
  590. // Reset command based on querystring parameter cmd=
  591. // - RESET: reset search parameters
  592. // - RESETALL: reset search & master/detail parameters
  593. // - RESETSORT: reset sort parameters
  594. function ResetCmd() {
  595. global $diezmo;
  596. // Get reset cmd
  597. if (@$_GET["cmd"] <> "") {
  598. $sCmd = $_GET["cmd"];
  599. // Reset sort criteria
  600. if (strtolower($sCmd) == "resetsort") {
  601. $sOrderBy = "";
  602. $diezmo->setSessionOrderBy($sOrderBy);
  603. $diezmo->idDiezmo->setSort("");
  604. $diezmo->idMiembro->setSort("");
  605. $diezmo->fecha->setSort("");
  606. $diezmo->montoDiezmo->setSort("");
  607. }
  608. // Reset start position
  609. $this->lStartRec = 1;
  610. $diezmo->setStartRecordNumber($this->lStartRec);
  611. }
  612. }
  613. // Set up Starting Record parameters based on Pager Navigation
  614. function SetUpStartRec() {
  615. global $diezmo;
  616. if ($this->lDisplayRecs == 0)
  617. return;
  618. if ($this->IsPageRequest()) { // Validate request
  619. if (@$_GET[EW_TABLE_START_REC] <> "") { // Check for "start" parameter
  620. $this->lStartRec = $_GET[EW_TABLE_START_REC];
  621. $diezmo->setStartRecordNumber($this->lStartRec);
  622. } elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
  623. $this->nPageNo = $_GET[EW_TABLE_PAGE_NO];
  624. if (is_numeric($this->nPageNo)) {
  625. $this->lStartRec = ($this->nPageNo-1)*$this->lDisplayRecs+1;
  626. if ($this->lStartRec <= 0) {
  627. $this->lStartRec = 1;
  628. } elseif ($this->lStartRec >= intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1) {
  629. $this->lStartRec = intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1;
  630. }
  631. $diezmo->setStartRecordNumber($this->lStartRec);
  632. }
  633. }
  634. }
  635. $this->lStartRec = $diezmo->getStartRecordNumber();
  636. // Check if correct start record counter
  637. if (!is_numeric($this->lStartRec) || $this->lStartRec == "") { // Avoid invalid start record counter
  638. $this->lStartRec = 1; // Reset start record counter
  639. $diezmo->setStartRecordNumber($this->lStartRec);
  640. } elseif (intval($this->lStartRec) > intval($this->lTotalRecs)) { // Avoid starting record > total records
  641. $this->lStartRec = intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1; // Point to last page first record
  642. $diezmo->setStartRecordNumber($this->lStartRec);
  643. } elseif (($this->lStartRec-1) % $this->lDisplayRecs <> 0) {
  644. $this->lStartRec = intval(($this->lStartRec-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1; // Point to page boundary
  645. $diezmo->setStartRecordNumber($this->lStartRec);
  646. }
  647. }
  648. // Load recordset
  649. function LoadRecordset($offset = -1, $rowcnt = -1) {
  650. global $conn, $diezmo;
  651. // Call Recordset Selecting event
  652. $diezmo->Recordset_Selecting($diezmo->CurrentFilter);
  653. // Load list page SQL
  654. $sSql = $diezmo->SelectSQL();
  655. if ($offset > -1 && $rowcnt > -1) $sSql .= " LIMIT $offset, $rowcnt";
  656. // Load recordset
  657. $conn->raiseErrorFn = 'ew_ErrorFn';
  658. $rs = $conn->Execute($sSql);
  659. $conn->raiseErrorFn = '';
  660. // Call Recordset Selected event
  661. $diezmo->Recordset_Selected($rs);
  662. return $rs;
  663. }
  664. // Load row based on key values
  665. function LoadRow() {
  666. global $conn, $Security, $diezmo;
  667. $sFilter = $diezmo->KeyFilter();
  668. // Call Row Selecting event
  669. $diezmo->Row_Selecting($sFilter);
  670. // Load sql based on filter
  671. $diezmo->CurrentFilter = $sFilter;
  672. $sSql = $diezmo->SQL();
  673. if ($rs = $conn->Execute($sSql)) {
  674. if ($rs->EOF) {
  675. $LoadRow = FALSE;
  676. } else {
  677. $LoadRow = TRUE;
  678. $rs->MoveFirst();
  679. $this->LoadRowValues($rs); // Load row values
  680. // Call Row Selected event
  681. $diezmo->Row_Selected($rs);
  682. }
  683. $rs->Close();
  684. } else {
  685. $LoadRow = FALSE;
  686. }
  687. return $LoadRow;
  688. }
  689. // Load row values from recordset
  690. function LoadRowValues(&$rs) {
  691. global $diezmo;
  692. $diezmo->idDiezmo->setDbValue($rs->fields('idDiezmo'));
  693. $diezmo->idMiembro->setDbValue($rs->fields('idMiembro'));
  694. $diezmo->fecha->setDbValue($rs->fields('fecha'));
  695. $diezmo->montoDiezmo->setDbValue($rs->fields('montoDiezmo'));
  696. $diezmo->monto2->setDbValue($rs->fields('monto2'));
  697. $diezmo->monto3->setDbValue($rs->fields('monto3'));
  698. }
  699. // Render row values based on field settings
  700. function RenderRow() {
  701. global $conn, $Security, $diezmo;
  702. // Call Row_Rendering event
  703. $diezmo->Row_Rendering();
  704. // Common render codes for all row types
  705. // idDiezmo
  706. $diezmo->idDiezmo->CellCssStyle = "";
  707. $diezmo->idDiezmo->CellCssClass = "";
  708. // idMiembro
  709. $diezmo->idMiembro->CellCssStyle = "";
  710. $diezmo->idMiembro->CellCssClass = "";
  711. // fecha
  712. $diezmo->fecha->CellCssStyle = "";
  713. $diezmo->fecha->CellCssClass = "";
  714. // montoDiezmo
  715. $diezmo->montoDiezmo->CellCssStyle = "";
  716. $diezmo->montoDiezmo->CellCssClass = "";
  717. if ($diezmo->RowType == EW_ROWTYPE_VIEW) { // View row
  718. // idDiezmo
  719. $diezmo->idDiezmo->ViewValue = $diezmo->idDiezmo->CurrentValue;
  720. $diezmo->idDiezmo->CssStyle = "";
  721. $diezmo->idDiezmo->CssClass = "";
  722. $diezmo->idDiezmo->ViewCustomAttributes = "";
  723. // idMiembro
  724. $diezmo->idMiembro->ViewValue = $diezmo->idMiembro->CurrentValue;
  725. $diezmo->idMiembro->CssStyle = "";
  726. $diezmo->idMiembro->CssClass = "";
  727. $diezmo->idMiembro->ViewCustomAttributes = "";
  728. // fecha
  729. $diezmo->fecha->ViewValue = $diezmo->fecha->CurrentValue;
  730. $diezmo->fecha->ViewValue = ew_FormatDateTime($diezmo->fecha->ViewValue, 7);
  731. $diezmo->fecha->CssStyle = "";
  732. $diezmo->fecha->CssClass = "";
  733. $diezmo->fecha->ViewCustomAttributes = "";
  734. // montoDiezmo
  735. $diezmo->montoDiezmo->ViewValue = $diezmo->montoDiezmo->CurrentValue;
  736. $diezmo->montoDiezmo->CssStyle = "";
  737. $diezmo->montoDiezmo->CssClass = "";
  738. $diezmo->montoDiezmo->ViewCustomAttributes = "";
  739. // idDiezmo
  740. $diezmo->idDiezmo->HrefValue = "";
  741. // idMiembro
  742. $diezmo->idMiembro->HrefValue = "";
  743. // fecha
  744. $diezmo->fecha->HrefValue = "";
  745. // montoDiezmo
  746. $diezmo->montoDiezmo->HrefValue = "";
  747. }
  748. // Call Row Rendered event
  749. $diezmo->Row_Rendered();
  750. }
  751. // Export data in XML or CSV format
  752. function ExportData() {
  753. global $diezmo;
  754. $sCsvStr = "";
  755. // Default export style
  756. $sExportStyle = "h";
  757. // Load recordset
  758. $rs = $this->LoadRecordset();
  759. $this->lTotalRecs = $rs->RecordCount();
  760. $this->lStartRec = 1;
  761. // Export all
  762. if ($diezmo->ExportAll) {
  763. $this->lStopRec = $this->lTotalRecs;
  764. } else { // Export 1 page only
  765. $this->SetUpStartRec(); // Set up start record position
  766. // Set the last record to display
  767. if ($this->lDisplayRecs < 0) {
  768. $this->lStopRec = $this->lTotalRecs;
  769. } else {
  770. $this->lStopRec = $this->lStartRec + $this->lDisplayRecs - 1;
  771. }
  772. }
  773. if ($diezmo->Export == "xml") {
  774. $XmlDoc = new cXMLDocument();
  775. } else {
  776. echo ew_ExportHeader($diezmo->Export);
  777. // Horizontal format, write header
  778. if ($sExportStyle <> "v" || $diezmo->Export == "csv") {
  779. $sExportStr = "";
  780. ew_ExportAddValue($sExportStr, 'idDiezmo', $diezmo->Export);
  781. ew_ExportAddValue($sExportStr, 'idMiembro', $diezmo->Export);
  782. ew_ExportAddValue($sExportStr, 'fecha', $diezmo->Export);
  783. ew_ExportAddValue($sExportStr, 'montoDiezmo', $diezmo->Export);
  784. echo ew_ExportLine($sExportStr, $diezmo->Export);
  785. }
  786. }
  787. // Move to first record
  788. $this->lRecCnt = $this->lStartRec - 1;
  789. if (!$rs->EOF) {
  790. $rs->MoveFirst();
  791. $rs->Move($this->lStartRec - 1);
  792. }
  793. while (!$rs->EOF && $this->lRecCnt < $this->lStopRec) {
  794. $this->lRecCnt++;
  795. if (intval($this->lRecCnt) >= intval($this->lStartRec)) {
  796. $this->LoadRowValues($rs);
  797. // Render row for display
  798. $diezmo->RowType = EW_ROWTYPE_VIEW; // Render view
  799. $this->RenderRow();
  800. if ($diezmo->Export == "xml") {
  801. $XmlDoc->BeginRow();
  802. $XmlDoc->AddField('idDiezmo', $diezmo->idDiezmo->CurrentValue);
  803. $XmlDoc->AddField('idMiembro', $diezmo->idMiembro->CurrentValue);
  804. $XmlDoc->AddField('fecha', $diezmo->fecha->CurrentValue);
  805. $XmlDoc->AddField('montoDiezmo', $diezmo->montoDiezmo->CurrentValue);
  806. $XmlDoc->EndRow();
  807. } else {
  808. if ($sExportStyle == "v" && $diezmo->Export <> "csv") { // Vertical format
  809. echo ew_ExportField('idDiezmo', $diezmo->idDiezmo->ExportValue($diezmo->Export, $diezmo->ExportOriginalValue), $diezmo->Export);
  810. echo ew_ExportField('idMiembro', $diezmo->idMiembro->ExportValue($diezmo->Export, $diezmo->ExportOriginalValue), $diezmo->Export);
  811. echo ew_ExportField('fecha', $diezmo->fecha->ExportValue($diezmo->Export, $diezmo->ExportOriginalValue), $diezmo->Export);
  812. echo ew_ExportField('montoDiezmo', $diezmo->montoDiezmo->ExportValue($diezmo->Export, $diezmo->ExportOriginalValue), $diezmo->Export);
  813. } else { // Horizontal format
  814. $sExportStr = "";
  815. ew_ExportAddValue($sExportStr, $diezmo->idDiezmo->ExportValue($diezmo->Export, $diezmo->ExportOriginalValue), $diezmo->Export);
  816. ew_ExportAddValue($sExportStr, $diezmo->idMiembro->ExportValue($diezmo->Export, $diezmo->ExportOriginalValue), $diezmo->Export);
  817. ew_ExportAddValue($sExportStr, $diezmo->fecha->ExportValue($diezmo->Export, $diezmo->ExportOriginalValue), $diezmo->Export);
  818. ew_ExportAddValue($sExportStr, $diezmo->montoDiezmo->ExportValue($diezmo->Export, $diezmo->ExportOriginalValue), $diezmo->Export);
  819. echo ew_ExportLine($sExportStr, $diezmo->Export);
  820. }
  821. }
  822. }
  823. $rs->MoveNext();
  824. }
  825. // Close recordset
  826. $rs->Close();
  827. if ($diezmo->Export == "xml") {
  828. header("Content-Type: text/xml");
  829. echo $XmlDoc->XML();
  830. } else {
  831. echo ew_ExportFooter($diezmo->Export);
  832. }
  833. }
  834. // Page Load event
  835. function Page_Load() {
  836. //echo "Page Load";
  837. }
  838. // Page Unload event
  839. function Page_Unload() {
  840. //echo "Page Unload";
  841. }
  842. // Form Custom Validate event
  843. function Form_CustomValidate(&$CustomError) {
  844. // Return error message in CustomError
  845. return TRUE;
  846. }
  847. }
  848. ?>