/roladd.php

https://github.com/fredd-for/emaus_tesoreria · PHP · 658 lines · 462 code · 90 blank · 106 comment · 129 complexity · 69209df8040f1a0b24582ed36270dae4 MD5 · raw file

  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 "rolinfo.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. $rol_add = new crol_add();
  21. $Page =& $rol_add;
  22. // Page init processing
  23. $rol_add->Page_Init();
  24. // Page main processing
  25. $rol_add->Page_Main();
  26. ?>
  27. <?php include "header.php" ?>
  28. <script type="text/javascript">
  29. <!--
  30. // Create page object
  31. var rol_add = new ew_Page("rol_add");
  32. // page properties
  33. rol_add.PageID = "add"; // page ID
  34. var EW_PAGE_ID = rol_add.PageID; // for backward compatibility
  35. // extend page with ValidateForm function
  36. rol_add.ValidateForm = function(fobj) {
  37. if (!this.ValidateRequired)
  38. return true; // ignore validation
  39. if (fobj.a_confirm && fobj.a_confirm.value == "F")
  40. return true;
  41. var i, elm, aelm, infix;
  42. var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
  43. for (i=0; i<rowcnt; i++) {
  44. infix = (fobj.key_count) ? String(i+1) : "";
  45. elm = fobj.elements["x" + infix + "_idRol"];
  46. if (elm && !ew_HasValue(elm))
  47. return ew_OnError(this, elm, "Por favor ingrese los campos requeridos - Id Rol");
  48. elm = fobj.elements["x" + infix + "_idRol"];
  49. if (elm && !ew_CheckInteger(elm.value))
  50. return ew_OnError(this, elm, "Entero Incorrecto - Id Rol");
  51. elm = fobj.elements["x" + infix + "_nombre"];
  52. if (elm && !ew_HasValue(elm))
  53. return ew_OnError(this, elm, "Por favor ingrese los campos requeridos - Nombre");
  54. elmId = fobj.elements["x" + infix + "_idRol"];
  55. elmName = fobj.elements["x" + infix + "_nombre"];
  56. if (elmId && elmName) {
  57. elmId.value = elmId.value.replace(/^\s+|\s+$/, '');
  58. elmName.value = elmName.value.replace(/^\s+|\s+$/, '');
  59. if (elmId && !ew_CheckInteger(elmId.value))
  60. return ew_OnError(this, elmId, "El Nivel de Usuario debe ser un Entero");
  61. var level = parseInt(elmId.value);
  62. if (level == 0) {
  63. if (elmName.value.toLowerCase() != "default")
  64. return ew_OnError(this, elmName, "User level name for user level 0 must be 'Default'");
  65. } else if (level == -1) {
  66. if (elmName.value.toLowerCase() != "administrator")
  67. return ew_OnError(this, elmName, "El nombre de usuario para el usuario nivel -1 debe ser 'Admninistrator'");
  68. } else if (level < -1) {
  69. return ew_OnError(this, elmId, "User defined User Level ID must be larger than 0");
  70. } else if (level > 0) {
  71. if (elmName.value.toLowerCase() == "administrator" || elmName.value.toLowerCase() == "default")
  72. return ew_OnError(this, elmName, "User defined User Level name cannot be 'Administrator' or 'Default'");
  73. }
  74. }
  75. // Call Form Custom Validate event
  76. if (!this.Form_CustomValidate(fobj)) return false;
  77. }
  78. return true;
  79. }
  80. // extend page with Form_CustomValidate function
  81. rol_add.Form_CustomValidate =
  82. function(fobj) { // DO NOT CHANGE THIS LINE!
  83. // Your custom validation code here, return false if invalid.
  84. return true;
  85. }
  86. <?php if (EW_CLIENT_VALIDATE) { ?>
  87. rol_add.ValidateRequired = true; // uses JavaScript validation
  88. <?php } else { ?>
  89. rol_add.ValidateRequired = false; // no JavaScript validation
  90. <?php } ?>
  91. //-->
  92. </script>
  93. <script language="JavaScript" type="text/javascript">
  94. <!--
  95. // Write your client script here, no need to add script tags.
  96. // To include another .js script, use:
  97. // ew_ClientScriptInclude("my_javascript.js");
  98. //-->
  99. </script>
  100. <p><span class="phpmaker">Agregar a TABLA: Rol<br><br>
  101. <a href="<?php echo $rol->getReturnUrl() ?>">Volver atras</a></span></p>
  102. <?php $rol_add->ShowMessage() ?>
  103. <form name="froladd" id="froladd" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return rol_add.ValidateForm(this);">
  104. <p>
  105. <input type="hidden" name="t" id="t" value="rol">
  106. <input type="hidden" name="a_add" id="a_add" value="A">
  107. <table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
  108. <div class="ewGridMiddlePanel">
  109. <table cellspacing="0" class="ewTable">
  110. <?php if ($rol->idRol->Visible) { // idRol ?>
  111. <tr<?php echo $rol->idRol->RowAttributes ?>>
  112. <td class="ewTableHeader">Id Rol<span class="ewRequired">&nbsp;*</span></td>
  113. <td<?php echo $rol->idRol->CellAttributes() ?>><span id="el_idRol">
  114. <input type="text" name="x_idRol" id="x_idRol" size="30" value="<?php echo $rol->idRol->EditValue ?>"<?php echo $rol->idRol->EditAttributes() ?>>
  115. </span><?php echo $rol->idRol->CustomMsg ?></td>
  116. </tr>
  117. <?php } ?>
  118. <?php if ($rol->nombre->Visible) { // nombre ?>
  119. <tr<?php echo $rol->nombre->RowAttributes ?>>
  120. <td class="ewTableHeader">Nombre<span class="ewRequired">&nbsp;*</span></td>
  121. <td<?php echo $rol->nombre->CellAttributes() ?>><span id="el_nombre">
  122. <input type="text" name="x_nombre" id="x_nombre" size="30" maxlength="50" value="<?php echo $rol->nombre->EditValue ?>"<?php echo $rol->nombre->EditAttributes() ?>>
  123. </span><?php echo $rol->nombre->CustomMsg ?></td>
  124. </tr>
  125. <?php } ?>
  126. <!-- row for permission values -->
  127. <tr>
  128. <td class="ewTableHeader">Permisos</td>
  129. <td>
  130. <input type="checkbox" name="x_ewAllowAdd" id="Add" value="<?php echo EW_ALLOW_ADD ?>">Agregar/Copiar
  131. <input type="checkbox" name="x_ewAllowDelete" id="Delete" value="<?php echo EW_ALLOW_DELETE ?>">Borrar
  132. <input type="checkbox" name="x_ewAllowEdit" id="Edit" value="<?php echo EW_ALLOW_EDIT ?>">Editar
  133. <?php if (defined("EW_USER_LEVEL_COMPAT")) { ?>
  134. <input type="checkbox" name="x_ewAllowList" id="List" value="<?php echo EW_ALLOW_LIST ?>">Listar/Buscar/Ver
  135. <?php } else { ?>
  136. <input type="checkbox" name="x_ewAllowList" id="List" value="<?php echo EW_ALLOW_LIST ?>">Listar
  137. <input type="checkbox" name="x_ewAllowView" id="View" value="<?php echo EW_ALLOW_VIEW ?>">Ver
  138. <input type="checkbox" name="x_ewAllowSearch" id="Search" value="<?php echo EW_ALLOW_SEARCH ?>">Buscar
  139. <?php } ?>
  140. </td>
  141. </tr>
  142. </table>
  143. </div>
  144. </td></tr></table>
  145. <p>
  146. <input type="submit" name="btnAction" id="btnAction" value=" AGREGAR ">
  147. </form>
  148. <script language="JavaScript" type="text/javascript">
  149. <!--
  150. // Write your table-specific startup script here
  151. // document.write("page loaded");
  152. //-->
  153. </script>
  154. <?php include "footer.php" ?>
  155. <?php
  156. //
  157. // Page Class
  158. //
  159. class crol_add {
  160. // Page ID
  161. var $PageID = 'add';
  162. // Table Name
  163. var $TableName = 'rol';
  164. // Page Object Name
  165. var $PageObjName = 'rol_add';
  166. // Page Name
  167. function PageName() {
  168. return ew_CurrentPage();
  169. }
  170. // Page Url
  171. function PageUrl() {
  172. $PageUrl = ew_CurrentPage() . "?";
  173. global $rol;
  174. if ($rol->UseTokenInUrl) $PageUrl .= "t=" . $rol->TableVar . "&"; // add page token
  175. return $PageUrl;
  176. }
  177. // Message
  178. function getMessage() {
  179. return @$_SESSION[EW_SESSION_MESSAGE];
  180. }
  181. function setMessage($v) {
  182. if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Append
  183. $_SESSION[EW_SESSION_MESSAGE] .= "<br>" . $v;
  184. } else {
  185. $_SESSION[EW_SESSION_MESSAGE] = $v;
  186. }
  187. }
  188. // Show Message
  189. function ShowMessage() {
  190. if ($this->getMessage() <> "") { // Message in Session, display
  191. echo "<p><span class=\"ewMessage\">" . $this->getMessage() . "</span></p>";
  192. $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
  193. }
  194. }
  195. // Validate Page request
  196. function IsPageRequest() {
  197. global $objForm, $rol;
  198. if ($rol->UseTokenInUrl) {
  199. //IsPageRequest = False
  200. if ($objForm)
  201. return ($rol->TableVar == $objForm->GetValue("t"));
  202. if (@$_GET["t"] <> "")
  203. return ($rol->TableVar == $_GET["t"]);
  204. } else {
  205. return TRUE;
  206. }
  207. }
  208. //
  209. // Class initialize
  210. // - init objects
  211. // - open connection
  212. //
  213. function crol_add() {
  214. global $conn;
  215. // Initialize table object
  216. $GLOBALS["rol"] = new crol();
  217. // Initialize other table object
  218. $GLOBALS['usuario'] = new cusuario();
  219. // Intialize page id (for backward compatibility)
  220. if (!defined("EW_PAGE_ID"))
  221. define("EW_PAGE_ID", 'add', TRUE);
  222. // Initialize table name (for backward compatibility)
  223. if (!defined("EW_TABLE_NAME"))
  224. define("EW_TABLE_NAME", 'rol', TRUE);
  225. // Open connection to the database
  226. $conn = ew_Connect();
  227. }
  228. //
  229. // Page_Init
  230. //
  231. function Page_Init() {
  232. global $gsExport, $gsExportFile, $rol;
  233. global $Security;
  234. $Security = new cAdvancedSecurity();
  235. if (!$Security->IsLoggedIn()) $Security->AutoLogin();
  236. if (!$Security->IsLoggedIn()) {
  237. $Security->SaveLastUrl();
  238. $this->Page_Terminate("login.php");
  239. }
  240. $Security->TablePermission_Loading();
  241. $Security->LoadCurrentUserLevel($this->TableName);
  242. $Security->TablePermission_Loaded();
  243. if (!$Security->CanAdmin()) {
  244. $Security->SaveLastUrl();
  245. $this->Page_Terminate("login.php");
  246. }
  247. // Global page loading event (in userfn6.php)
  248. Page_Loading();
  249. // Page load event, used in current page
  250. $this->Page_Load();
  251. }
  252. //
  253. // Page_Terminate
  254. // - called when exit page
  255. // - if URL specified, redirect to the URL
  256. //
  257. function Page_Terminate($url = "") {
  258. global $conn;
  259. // Page unload event, used in current page
  260. $this->Page_Unload();
  261. // Global page unloaded event (in userfn*.php)
  262. Page_Unloaded();
  263. // Close Connection
  264. $conn->Close();
  265. // Go to URL if specified
  266. if ($url <> "") {
  267. ob_end_clean();
  268. header("Location: $url");
  269. }
  270. exit();
  271. }
  272. var $x_ewPriv = 0;
  273. //
  274. // Page main processing
  275. //
  276. function Page_Main() {
  277. global $objForm, $gsFormError, $rol;
  278. // Load key values from QueryString
  279. $bCopy = TRUE;
  280. if (@$_GET["idRol"] != "") {
  281. $rol->idRol->setQueryStringValue($_GET["idRol"]);
  282. } else {
  283. $bCopy = FALSE;
  284. }
  285. // Create form object
  286. $objForm = new cFormObj();
  287. // Process form if post back
  288. if (@$_POST["a_add"] <> "") {
  289. $rol->CurrentAction = $_POST["a_add"]; // Get form action
  290. $this->LoadFormValues(); // Load form values
  291. // Load values for user privileges
  292. $x_ewAllowAdd = @$_POST["x_ewAllowAdd"];
  293. if ($x_ewAllowAdd == "") $x_ewAllowAdd = 0;
  294. $x_ewAllowEdit = @$_POST["x_ewAllowEdit"];
  295. if ($x_ewAllowEdit == "") $x_ewAllowEdit = 0;
  296. $x_ewAllowDelete = @$_POST["x_ewAllowDelete"];
  297. if ($x_ewAllowDelete == "") $x_ewAllowDelete = 0;
  298. $x_ewAllowList = @$_POST["x_ewAllowList"];
  299. if ($x_ewAllowList == "") $x_ewAllowList = 0;
  300. if (defined("EW_USER_LEVEL_COMPAT")) {
  301. $this->x_ewPriv = intval($x_ewAllowAdd) + intval($x_ewAllowEdit) +
  302. intval($x_ewAllowDelete) + intval($x_ewAllowList);
  303. } else {
  304. $x_ewAllowView = @$_POST["x_ewAllowView"];
  305. if ($x_ewAllowView == "") $x_ewAllowView = 0;
  306. $x_ewAllowSearch = @$_POST["x_ewAllowSearch"];
  307. if ($x_ewAllowSearch == "") $x_ewAllowSearch = 0;
  308. $this->x_ewPriv = intval($x_ewAllowAdd) + intval($x_ewAllowEdit) +
  309. intval($x_ewAllowDelete) + intval($x_ewAllowList) +
  310. intval($x_ewAllowView) + intval($x_ewAllowSearch);
  311. }
  312. // Validate Form
  313. if (!$this->ValidateForm()) {
  314. $rol->CurrentAction = "I"; // Form error, reset action
  315. $this->setMessage($gsFormError);
  316. }
  317. } else { // Not post back
  318. if ($bCopy) {
  319. $rol->CurrentAction = "C"; // Copy Record
  320. } else {
  321. $rol->CurrentAction = "I"; // Display Blank Record
  322. $this->LoadDefaultValues(); // Load default values
  323. }
  324. }
  325. // Perform action based on action code
  326. switch ($rol->CurrentAction) {
  327. case "I": // Blank record, no action required
  328. break;
  329. case "C": // Copy an existing record
  330. if (!$this->LoadRow()) { // Load record based on key
  331. $this->setMessage("No se encontraron registros"); // No record found
  332. $this->Page_Terminate("rollist.php"); // No matching record, return to list
  333. }
  334. break;
  335. case "A": // ' Add new record
  336. $rol->SendEmail = TRUE; // Send email on add success
  337. if ($this->AddRow()) { // Add successful
  338. $this->setMessage("Registro agregado satisfactoriamente"); // Set up success message
  339. $sReturnUrl = $rol->getReturnUrl();
  340. $this->Page_Terminate($sReturnUrl); // Clean up and return
  341. } else {
  342. $this->RestoreFormValues(); // Add failed, restore form values
  343. }
  344. }
  345. // Render row based on row type
  346. $rol->RowType = EW_ROWTYPE_ADD; // Render add type
  347. // Render row
  348. $this->RenderRow();
  349. }
  350. // Get upload files
  351. function GetUploadFiles() {
  352. global $objForm, $rol;
  353. // Get upload data
  354. }
  355. // Load default values
  356. function LoadDefaultValues() {
  357. global $rol;
  358. }
  359. // Load form values
  360. function LoadFormValues() {
  361. // Load from form
  362. global $objForm, $rol;
  363. $rol->idRol->setFormValue($objForm->GetValue("x_idRol"));
  364. $rol->nombre->setFormValue($objForm->GetValue("x_nombre"));
  365. }
  366. // Restore form values
  367. function RestoreFormValues() {
  368. global $rol;
  369. $rol->idRol->CurrentValue = $rol->idRol->FormValue;
  370. $rol->nombre->CurrentValue = $rol->nombre->FormValue;
  371. }
  372. // Load row based on key values
  373. function LoadRow() {
  374. global $conn, $Security, $rol;
  375. $sFilter = $rol->KeyFilter();
  376. // Call Row Selecting event
  377. $rol->Row_Selecting($sFilter);
  378. // Load sql based on filter
  379. $rol->CurrentFilter = $sFilter;
  380. $sSql = $rol->SQL();
  381. if ($rs = $conn->Execute($sSql)) {
  382. if ($rs->EOF) {
  383. $LoadRow = FALSE;
  384. } else {
  385. $LoadRow = TRUE;
  386. $rs->MoveFirst();
  387. $this->LoadRowValues($rs); // Load row values
  388. // Call Row Selected event
  389. $rol->Row_Selected($rs);
  390. }
  391. $rs->Close();
  392. } else {
  393. $LoadRow = FALSE;
  394. }
  395. return $LoadRow;
  396. }
  397. // Load row values from recordset
  398. function LoadRowValues(&$rs) {
  399. global $rol;
  400. $rol->idRol->setDbValue($rs->fields('idRol'));
  401. if (is_null($rol->idRol->CurrentValue)) {
  402. $rol->idRol->CurrentValue = 0;
  403. } else {
  404. $rol->idRol->CurrentValue = intval($rol->idRol->CurrentValue);
  405. }
  406. $rol->nombre->setDbValue($rs->fields('nombre'));
  407. }
  408. // Render row values based on field settings
  409. function RenderRow() {
  410. global $conn, $Security, $rol;
  411. // Call Row_Rendering event
  412. $rol->Row_Rendering();
  413. // Common render codes for all row types
  414. // idRol
  415. $rol->idRol->CellCssStyle = "";
  416. $rol->idRol->CellCssClass = "";
  417. // nombre
  418. $rol->nombre->CellCssStyle = "";
  419. $rol->nombre->CellCssClass = "";
  420. if ($rol->RowType == EW_ROWTYPE_VIEW) { // View row
  421. // idRol
  422. $rol->idRol->ViewValue = $rol->idRol->CurrentValue;
  423. $rol->idRol->CssStyle = "";
  424. $rol->idRol->CssClass = "";
  425. $rol->idRol->ViewCustomAttributes = "";
  426. // nombre
  427. $rol->nombre->ViewValue = $rol->nombre->CurrentValue;
  428. $rol->nombre->CssStyle = "";
  429. $rol->nombre->CssClass = "";
  430. $rol->nombre->ViewCustomAttributes = "";
  431. // idRol
  432. $rol->idRol->HrefValue = "";
  433. // nombre
  434. $rol->nombre->HrefValue = "";
  435. } elseif ($rol->RowType == EW_ROWTYPE_ADD) { // Add row
  436. // idRol
  437. $rol->idRol->EditCustomAttributes = "";
  438. $rol->idRol->EditValue = ew_HtmlEncode($rol->idRol->CurrentValue);
  439. // nombre
  440. $rol->nombre->EditCustomAttributes = "";
  441. $rol->nombre->EditValue = ew_HtmlEncode($rol->nombre->CurrentValue);
  442. }
  443. // Call Row Rendered event
  444. $rol->Row_Rendered();
  445. }
  446. // Validate form
  447. function ValidateForm() {
  448. global $gsFormError, $rol;
  449. // Initialize
  450. $gsFormError = "";
  451. // Check if validation required
  452. if (!EW_SERVER_VALIDATE)
  453. return ($gsFormError == "");
  454. if ($rol->idRol->FormValue == "") {
  455. $gsFormError .= ($gsFormError <> "") ? "<br>" : "";
  456. $gsFormError .= "Por favor ingrese los campos requeridos - Id Rol";
  457. }
  458. if (!ew_CheckInteger($rol->idRol->FormValue)) {
  459. if ($gsFormError <> "") $gsFormError .= "<br>";
  460. $gsFormError .= "Entero Incorrecto - Id Rol";
  461. }
  462. if ($rol->nombre->FormValue == "") {
  463. $gsFormError .= ($gsFormError <> "") ? "<br>" : "";
  464. $gsFormError .= "Por favor ingrese los campos requeridos - Nombre";
  465. }
  466. // Return validate result
  467. $ValidateForm = ($gsFormError == "");
  468. // Call Form_CustomValidate event
  469. $sFormCustomError = "";
  470. $ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
  471. if ($sFormCustomError <> "") {
  472. $gsFormError .= ($gsFormError <> "") ? "<br>" : "";
  473. $gsFormError .= $sFormCustomError;
  474. }
  475. return $ValidateForm;
  476. }
  477. // Add record
  478. function AddRow() {
  479. global $conn, $Security, $rol;
  480. if (trim(strval($rol->idRol->CurrentValue)) == "") {
  481. $this->setMessage("No se encuentra el Identificador de Usuario");
  482. } elseif (trim($rol->nombre->CurrentValue) == "") {
  483. $this->setMessage("Missing User Level name");
  484. } elseif (!is_numeric($rol->idRol->CurrentValue)) {
  485. $this->setMessage("El Nivel de Usuario debe ser un Entero");
  486. } elseif (intval($rol->idRol->CurrentValue) < -1) {
  487. $this->setMessage("User defined User Level ID must be larger than 0");
  488. } elseif (intval($rol->idRol->CurrentValue) == 0 && strtolower(trim($rol->nombre->CurrentValue)) <> "default") {
  489. $this->setMessage("User level name for user level 0 must be 'Default'");
  490. } elseif (intval($rol->idRol->CurrentValue) == -1 && strtolower(trim($rol->nombre->CurrentValue)) <> "administrator") {
  491. $this->setMessage("El nombre de usuario para el usuario nivel -1 debe ser 'Admninistrator'");
  492. } elseif (intval($rol->idRol->CurrentValue) > 0 && (strtolower(trim($rol->nombre->CurrentValue)) == "administrator" || strtolower(trim($rol->nombre->CurrentValue)) == "default")) {
  493. $this->setMessage("User defined User Level name cannot be 'Administrator' or 'Default'");
  494. }
  495. if ($this->getMessage() <> "")
  496. return FALSE;
  497. // Check if key value entered
  498. if ($rol->idRol->CurrentValue == "") {
  499. $this->setMessage("Valor de la llave incorrecto");
  500. return FALSE;
  501. }
  502. // Check for duplicate key
  503. $bCheckKey = TRUE;
  504. $sFilter = $rol->KeyFilter();
  505. if ($bCheckKey) {
  506. $rsChk = $rol->LoadRs($sFilter);
  507. if ($rsChk && !$rsChk->EOF) {
  508. $sKeyErrMsg = str_replace("%f", $sFilter, "Llave primaria duplicado: '%f'");
  509. $this->setMessage($sKeyErrMsg);
  510. $rsChk->Close();
  511. return FALSE;
  512. }
  513. }
  514. $rsnew = array();
  515. // Field idRol
  516. $rol->idRol->SetDbValueDef($rol->idRol->CurrentValue, 0);
  517. $rsnew['idRol'] =& $rol->idRol->DbValue;
  518. // Field nombre
  519. $rol->nombre->SetDbValueDef($rol->nombre->CurrentValue, "");
  520. $rsnew['nombre'] =& $rol->nombre->DbValue;
  521. // Call Row Inserting event
  522. $bInsertRow = $rol->Row_Inserting($rsnew);
  523. if ($bInsertRow) {
  524. $conn->raiseErrorFn = 'ew_ErrorFn';
  525. $AddRow = $conn->Execute($rol->InsertSQL($rsnew));
  526. $conn->raiseErrorFn = '';
  527. } else {
  528. if ($rol->CancelMessage <> "") {
  529. $this->setMessage($rol->CancelMessage);
  530. $rol->CancelMessage = "";
  531. } else {
  532. $this->setMessage("Insertar cancelado");
  533. }
  534. $AddRow = FALSE;
  535. }
  536. if ($AddRow) {
  537. // Call Row Inserted event
  538. $rol->Row_Inserted($rsnew);
  539. }
  540. // Add User Level priv
  541. if ($this->x_ewPriv > 0 && is_array($GLOBALS["EW_USER_LEVEL_TABLE_NAME"])) {
  542. for ($i = 0; $i < count($GLOBALS["EW_USER_LEVEL_TABLE_NAME"]); $i++) {
  543. $sSql = "INSERT INTO " . EW_USER_LEVEL_PRIV_TABLE . " (" .
  544. EW_USER_LEVEL_PRIV_TABLE_NAME_FIELD . ", " .
  545. EW_USER_LEVEL_PRIV_USER_LEVEL_ID_FIELD . ", " .
  546. EW_USER_LEVEL_PRIV_PRIV_FIELD . ") VALUES ('" .
  547. ew_AdjustSql($GLOBALS["EW_USER_LEVEL_TABLE_NAME"][$i]) .
  548. "', " . $rol->idRol->CurrentValue . ", " . $this->x_ewPriv . ")";
  549. $conn->Execute($sSql);
  550. }
  551. }
  552. return $AddRow;
  553. }
  554. // Page Load event
  555. function Page_Load() {
  556. //echo "Page Load";
  557. }
  558. // Page Unload event
  559. function Page_Unload() {
  560. //echo "Page Unload";
  561. }
  562. // Form Custom Validate event
  563. function Form_CustomValidate(&$CustomError) {
  564. // Return error message in CustomError
  565. return TRUE;
  566. }
  567. }
  568. ?>