PageRenderTime 27ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/cierre_gestionlist.php

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