-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculoedit.php
762 lines (648 loc) · 22.9 KB
/
calculoedit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
<?php
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
define("EW_DEFAULT_LOCALE", "es_ES", TRUE);
@setlocale(LC_ALL, EW_DEFAULT_LOCALE);
?>
<?php include "ewcfg7.php" ?>
<?php include "ewmysql7.php" ?>
<?php include "phpfn7.php" ?>
<?php include "calculoinfo.php" ?>
<?php include "userfn7.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php
// Create page object
$calculo_edit = new ccalculo_edit();
$Page =& $calculo_edit;
// Page init
$calculo_edit->Page_Init();
// Page main
$calculo_edit->Page_Main();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--
// Create page object
var calculo_edit = new ew_Page("calculo_edit");
// page properties
calculo_edit.PageID = "edit"; // page ID
calculo_edit.FormID = "fcalculoedit"; // form ID
var EW_PAGE_ID = calculo_edit.PageID; // for backward compatibility
// extend page with ValidateForm function
calculo_edit.ValidateForm = function(fobj) {
ew_PostAutoSuggest(fobj);
if (!this.ValidateRequired)
return true; // ignore validation
if (fobj.a_confirm && fobj.a_confirm.value == "F")
return true;
var i, elm, aelm, infix;
var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
for (i=0; i<rowcnt; i++) {
infix = (fobj.key_count) ? String(i+1) : "";
elm = fobj.elements["x" + infix + "_diasresta"];
if (elm && !ew_CheckInteger(elm.value))
return ew_OnError(this, elm, "<?php echo ew_JsEncode2($calculo->diasresta->FldErrMsg()) ?>");
elm = fobj.elements["x" + infix + "_diaslleva"];
if (elm && !ew_CheckInteger(elm.value))
return ew_OnError(this, elm, "<?php echo ew_JsEncode2($calculo->diaslleva->FldErrMsg()) ?>");
elm = fobj.elements["x" + infix + "_diasllevalab"];
if (elm && !ew_CheckInteger(elm.value))
return ew_OnError(this, elm, "<?php echo ew_JsEncode2($calculo->diasllevalab->FldErrMsg()) ?>");
// Call Form Custom Validate event
if (!this.Form_CustomValidate(fobj)) return false;
}
return true;
}
// extend page with Form_CustomValidate function
calculo_edit.Form_CustomValidate =
function(fobj) { // DO NOT CHANGE THIS LINE!
// Your custom validation code here, return false if invalid.
return true;
}
<?php if (EW_CLIENT_VALIDATE) { ?>
calculo_edit.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
calculo_edit.ValidateRequired = false; // no JavaScript validation
<?php } ?>
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js");
//-->
</script>
<p><span class="phpmaker"><?php echo $Language->Phrase("Edit") ?> <?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $calculo->TableCaption() ?><br><br>
<a href="<?php echo $calculo->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
echo ew_DebugMsg();
$calculo_edit->ShowMessage();
?>
<form name="fcalculoedit" id="fcalculoedit" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return calculo_edit.ValidateForm(this);">
<p>
<input type="hidden" name="a_table" id="a_table" value="calculo">
<input type="hidden" name="a_edit" id="a_edit" value="U">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?php if ($calculo->fechahoy->Visible) { // fechahoy ?>
<tr<?php echo $calculo->RowAttributes() ?>>
<td class="ewTableHeader"><?php echo $calculo->fechahoy->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
<td<?php echo $calculo->fechahoy->CellAttributes() ?>><span id="el_fechahoy">
<div<?php echo $calculo->fechahoy->ViewAttributes() ?>><?php echo $calculo->fechahoy->EditValue ?></div><input type="hidden" name="x_fechahoy" id="x_fechahoy" value="<?php echo ew_HtmlEncode($calculo->fechahoy->CurrentValue) ?>">
</span><?php echo $calculo->fechahoy->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($calculo->fechahasta->Visible) { // fechahasta ?>
<tr<?php echo $calculo->RowAttributes() ?>>
<td class="ewTableHeader"><?php echo $calculo->fechahasta->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
<td<?php echo $calculo->fechahasta->CellAttributes() ?>><span id="el_fechahasta">
<div<?php echo $calculo->fechahasta->ViewAttributes() ?>><?php echo $calculo->fechahasta->EditValue ?></div><input type="hidden" name="x_fechahasta" id="x_fechahasta" value="<?php echo ew_HtmlEncode($calculo->fechahasta->CurrentValue) ?>">
</span><?php echo $calculo->fechahasta->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($calculo->diasresta->Visible) { // diasresta ?>
<tr<?php echo $calculo->RowAttributes() ?>>
<td class="ewTableHeader"><?php echo $calculo->diasresta->FldCaption() ?></td>
<td<?php echo $calculo->diasresta->CellAttributes() ?>><span id="el_diasresta">
<input type="text" name="x_diasresta" id="x_diasresta" title="<?php echo $calculo->diasresta->FldTitle() ?>" size="30" value="<?php echo $calculo->diasresta->EditValue ?>"<?php echo $calculo->diasresta->EditAttributes() ?>>
</span><?php echo $calculo->diasresta->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($calculo->diaslleva->Visible) { // diaslleva ?>
<tr<?php echo $calculo->RowAttributes() ?>>
<td class="ewTableHeader"><?php echo $calculo->diaslleva->FldCaption() ?></td>
<td<?php echo $calculo->diaslleva->CellAttributes() ?>><span id="el_diaslleva">
<input type="text" name="x_diaslleva" id="x_diaslleva" title="<?php echo $calculo->diaslleva->FldTitle() ?>" size="30" value="<?php echo $calculo->diaslleva->EditValue ?>"<?php echo $calculo->diaslleva->EditAttributes() ?>>
</span><?php echo $calculo->diaslleva->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($calculo->diasllevalab->Visible) { // diasllevalab ?>
<tr<?php echo $calculo->RowAttributes() ?>>
<td class="ewTableHeader"><?php echo $calculo->diasllevalab->FldCaption() ?></td>
<td<?php echo $calculo->diasllevalab->CellAttributes() ?>><span id="el_diasllevalab">
<input type="text" name="x_diasllevalab" id="x_diasllevalab" title="<?php echo $calculo->diasllevalab->FldTitle() ?>" size="30" value="<?php echo $calculo->diasllevalab->EditValue ?>"<?php echo $calculo->diasllevalab->EditAttributes() ?>>
</span><?php echo $calculo->diasllevalab->CustomMsg ?></td>
</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="<?php echo ew_BtnCaption($Language->Phrase("EditBtn")) ?>">
</form>
<script language="JavaScript" type="text/javascript">
<!--
// Write your table-specific startup script here
// document.write("page loaded");
//-->
</script>
<?php include "footer.php" ?>
<?php
$calculo_edit->Page_Terminate();
?>
<?php
//
// Page class
//
class ccalculo_edit {
// Page ID
var $PageID = 'edit';
// Table name
var $TableName = 'calculo';
// Page object name
var $PageObjName = 'calculo_edit';
// Page name
function PageName() {
return ew_CurrentPage();
}
// Page URL
function PageUrl() {
$PageUrl = ew_CurrentPage() . "?";
global $calculo;
if ($calculo->UseTokenInUrl) $PageUrl .= "t=" . $calculo->TableVar . "&"; // Add page token
return $PageUrl;
}
// Page URLs
var $AddUrl;
var $EditUrl;
var $CopyUrl;
var $DeleteUrl;
var $ViewUrl;
var $ListUrl;
// Export URLs
var $ExportPrintUrl;
var $ExportHtmlUrl;
var $ExportExcelUrl;
var $ExportWordUrl;
var $ExportXmlUrl;
var $ExportCsvUrl;
// Update URLs
var $InlineAddUrl;
var $InlineCopyUrl;
var $InlineEditUrl;
var $GridAddUrl;
var $GridEditUrl;
var $MultiDeleteUrl;
var $MultiUpdateUrl;
// Message
function getMessage() {
return @$_SESSION[EW_SESSION_MESSAGE];
}
function setMessage($v) {
if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Append
$_SESSION[EW_SESSION_MESSAGE] .= "<br>" . $v;
} else {
$_SESSION[EW_SESSION_MESSAGE] = $v;
}
}
// Show message
function ShowMessage() {
$sMessage = $this->getMessage();
$this->Message_Showing($sMessage);
if ($sMessage <> "") { // Message in Session, display
echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
}
}
// Validate page request
function IsPageRequest() {
global $objForm, $calculo;
if ($calculo->UseTokenInUrl) {
if ($objForm)
return ($calculo->TableVar == $objForm->GetValue("t"));
if (@$_GET["t"] <> "")
return ($calculo->TableVar == $_GET["t"]);
} else {
return TRUE;
}
}
//
// Page class constructor
//
function ccalculo_edit() {
global $conn, $Language;
// Language object
$Language = new cLanguage();
// Table object (calculo)
$GLOBALS["calculo"] = new ccalculo();
// Page ID
if (!defined("EW_PAGE_ID"))
define("EW_PAGE_ID", 'edit', TRUE);
// Table name (for backward compatibility)
if (!defined("EW_TABLE_NAME"))
define("EW_TABLE_NAME", 'calculo', TRUE);
// Start timer
$GLOBALS["gsTimer"] = new cTimer();
// Open connection
$conn = ew_Connect();
}
//
// Page_Init
//
function Page_Init() {
global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
global $calculo;
// Create form object
$objForm = new cFormObj();
// Global Page Loading event (in userfn*.php)
Page_Loading();
// Page Load event
$this->Page_Load();
}
//
// Page_Terminate
//
function Page_Terminate($url = "") {
global $conn;
// Page Unload event
$this->Page_Unload();
// Global Page Unloaded event (in userfn*.php)
Page_Unloaded();
// Close connection
$conn->Close();
// Go to URL if specified
$this->Page_Redirecting($url);
if ($url <> "") {
if (!EW_DEBUG_ENABLED && ob_get_length())
ob_end_clean();
header("Location: " . $url);
}
exit();
}
var $sDbMasterFilter;
var $sDbDetailFilter;
//
// Page main
//
function Page_Main() {
global $objForm, $Language, $gsFormError, $calculo;
// Load key from QueryString
if (@$_GET["fechahoy"] <> "")
$calculo->fechahoy->setQueryStringValue($_GET["fechahoy"]);
if (@$_GET["fechahasta"] <> "")
$calculo->fechahasta->setQueryStringValue($_GET["fechahasta"]);
if (@$_POST["a_edit"] <> "") {
$calculo->CurrentAction = $_POST["a_edit"]; // Get action code
$this->LoadFormValues(); // Get form values
// Validate form
if (!$this->ValidateForm()) {
$calculo->CurrentAction = ""; // Form error, reset action
$this->setMessage($gsFormError);
$calculo->EventCancelled = TRUE; // Event cancelled
$this->RestoreFormValues();
}
} else {
$calculo->CurrentAction = "I"; // Default action is display
}
// Check if valid key
if ($calculo->fechahoy->CurrentValue == "")
$this->Page_Terminate("calculolist.php"); // Invalid key, return to list
if ($calculo->fechahasta->CurrentValue == "")
$this->Page_Terminate("calculolist.php"); // Invalid key, return to list
switch ($calculo->CurrentAction) {
case "I": // Get a record to display
if (!$this->LoadRow()) { // Load record based on key
$this->setMessage($Language->Phrase("NoRecord")); // No record found
$this->Page_Terminate("calculolist.php"); // No matching record, return to list
}
break;
Case "U": // Update
$calculo->SendEmail = TRUE; // Send email on update success
if ($this->EditRow()) { // Update record based on key
$this->setMessage($Language->Phrase("UpdateSuccess")); // Update success
$sReturnUrl = $calculo->getReturnUrl();
if (ew_GetPageName($sReturnUrl) == "calculoview.php")
$sReturnUrl = $calculo->ViewUrl(); // View paging, return to View page directly
$this->Page_Terminate($sReturnUrl); // Return to caller
} else {
$calculo->EventCancelled = TRUE; // Event cancelled
$this->RestoreFormValues(); // Restore form values if update failed
}
}
// Render the record
$calculo->RowType = EW_ROWTYPE_EDIT; // Render as Edit
$this->RenderRow();
}
// Get upload files
function GetUploadFiles() {
global $objForm, $calculo;
// Get upload data
}
// Load form values
function LoadFormValues() {
// Load from form
global $objForm, $calculo;
$calculo->fechahoy->setFormValue($objForm->GetValue("x_fechahoy"));
$calculo->fechahasta->setFormValue($objForm->GetValue("x_fechahasta"));
$calculo->diasresta->setFormValue($objForm->GetValue("x_diasresta"));
$calculo->diaslleva->setFormValue($objForm->GetValue("x_diaslleva"));
$calculo->diasllevalab->setFormValue($objForm->GetValue("x_diasllevalab"));
}
// Restore form values
function RestoreFormValues() {
global $objForm, $calculo;
$this->LoadRow();
$calculo->fechahoy->CurrentValue = $calculo->fechahoy->FormValue;
$calculo->fechahasta->CurrentValue = $calculo->fechahasta->FormValue;
$calculo->diasresta->CurrentValue = $calculo->diasresta->FormValue;
$calculo->diaslleva->CurrentValue = $calculo->diaslleva->FormValue;
$calculo->diasllevalab->CurrentValue = $calculo->diasllevalab->FormValue;
}
// Load row based on key values
function LoadRow() {
global $conn, $Security, $calculo;
$sFilter = $calculo->KeyFilter();
// Call Row Selecting event
$calculo->Row_Selecting($sFilter);
// Load SQL based on filter
$calculo->CurrentFilter = $sFilter;
$sSql = $calculo->SQL();
$res = FALSE;
$rs = ew_LoadRecordset($sSql);
if ($rs && !$rs->EOF) {
$res = TRUE;
$this->LoadRowValues($rs); // Load row values
// Call Row Selected event
$calculo->Row_Selected($rs);
$rs->Close();
}
return $res;
}
// Load row values from recordset
function LoadRowValues(&$rs) {
global $conn, $calculo;
$calculo->fechahoy->setDbValue($rs->fields('fechahoy'));
$calculo->fechahasta->setDbValue($rs->fields('fechahasta'));
$calculo->diasresta->setDbValue($rs->fields('diasresta'));
$calculo->diaslleva->setDbValue($rs->fields('diaslleva'));
$calculo->diasllevalab->setDbValue($rs->fields('diasllevalab'));
}
// Render row values based on field settings
function RenderRow() {
global $conn, $Security, $Language, $calculo;
// Initialize URLs
// Call Row_Rendering event
$calculo->Row_Rendering();
// Common render codes for all row types
// fechahoy
$calculo->fechahoy->CellCssStyle = ""; $calculo->fechahoy->CellCssClass = "";
$calculo->fechahoy->CellAttrs = array(); $calculo->fechahoy->ViewAttrs = array(); $calculo->fechahoy->EditAttrs = array();
// fechahasta
$calculo->fechahasta->CellCssStyle = ""; $calculo->fechahasta->CellCssClass = "";
$calculo->fechahasta->CellAttrs = array(); $calculo->fechahasta->ViewAttrs = array(); $calculo->fechahasta->EditAttrs = array();
// diasresta
$calculo->diasresta->CellCssStyle = ""; $calculo->diasresta->CellCssClass = "";
$calculo->diasresta->CellAttrs = array(); $calculo->diasresta->ViewAttrs = array(); $calculo->diasresta->EditAttrs = array();
// diaslleva
$calculo->diaslleva->CellCssStyle = ""; $calculo->diaslleva->CellCssClass = "";
$calculo->diaslleva->CellAttrs = array(); $calculo->diaslleva->ViewAttrs = array(); $calculo->diaslleva->EditAttrs = array();
// diasllevalab
$calculo->diasllevalab->CellCssStyle = ""; $calculo->diasllevalab->CellCssClass = "";
$calculo->diasllevalab->CellAttrs = array(); $calculo->diasllevalab->ViewAttrs = array(); $calculo->diasllevalab->EditAttrs = array();
if ($calculo->RowType == EW_ROWTYPE_VIEW) { // View row
// fechahoy
if (strval($calculo->fechahoy->CurrentValue) <> "") {
switch ($calculo->fechahoy->CurrentValue) {
case "Lunes":
$calculo->fechahoy->ViewValue = "Lunes";
break;
case "Martes":
$calculo->fechahoy->ViewValue = "Martes";
break;
case "Miercoles":
$calculo->fechahoy->ViewValue = "Miercoles";
break;
case "Jueves":
$calculo->fechahoy->ViewValue = "Jueves";
break;
case "Viernes":
$calculo->fechahoy->ViewValue = "Viernes";
break;
case "Sabado":
$calculo->fechahoy->ViewValue = "Sabado";
break;
case "Domingo":
$calculo->fechahoy->ViewValue = "Domingo";
break;
default:
$calculo->fechahoy->ViewValue = $calculo->fechahoy->CurrentValue;
}
} else {
$calculo->fechahoy->ViewValue = NULL;
}
$calculo->fechahoy->CssStyle = "";
$calculo->fechahoy->CssClass = "";
$calculo->fechahoy->ViewCustomAttributes = "";
// fechahasta
$calculo->fechahasta->ViewValue = $calculo->fechahasta->CurrentValue;
$calculo->fechahasta->CssStyle = "";
$calculo->fechahasta->CssClass = "";
$calculo->fechahasta->ViewCustomAttributes = "";
// diasresta
$calculo->diasresta->ViewValue = $calculo->diasresta->CurrentValue;
$calculo->diasresta->CssStyle = "";
$calculo->diasresta->CssClass = "";
$calculo->diasresta->ViewCustomAttributes = "";
// diaslleva
$calculo->diaslleva->ViewValue = $calculo->diaslleva->CurrentValue;
$calculo->diaslleva->CssStyle = "";
$calculo->diaslleva->CssClass = "";
$calculo->diaslleva->ViewCustomAttributes = "";
// diasllevalab
$calculo->diasllevalab->ViewValue = $calculo->diasllevalab->CurrentValue;
$calculo->diasllevalab->CssStyle = "";
$calculo->diasllevalab->CssClass = "";
$calculo->diasllevalab->ViewCustomAttributes = "";
// fechahoy
$calculo->fechahoy->HrefValue = "";
$calculo->fechahoy->TooltipValue = "";
// fechahasta
$calculo->fechahasta->HrefValue = "";
$calculo->fechahasta->TooltipValue = "";
// diasresta
$calculo->diasresta->HrefValue = "";
$calculo->diasresta->TooltipValue = "";
// diaslleva
$calculo->diaslleva->HrefValue = "";
$calculo->diaslleva->TooltipValue = "";
// diasllevalab
$calculo->diasllevalab->HrefValue = "";
$calculo->diasllevalab->TooltipValue = "";
} elseif ($calculo->RowType == EW_ROWTYPE_EDIT) { // Edit row
// fechahoy
$calculo->fechahoy->EditCustomAttributes = "";
if (strval($calculo->fechahoy->CurrentValue) <> "") {
switch ($calculo->fechahoy->CurrentValue) {
case "Lunes":
$calculo->fechahoy->EditValue = "Lunes";
break;
case "Martes":
$calculo->fechahoy->EditValue = "Martes";
break;
case "Miercoles":
$calculo->fechahoy->EditValue = "Miercoles";
break;
case "Jueves":
$calculo->fechahoy->EditValue = "Jueves";
break;
case "Viernes":
$calculo->fechahoy->EditValue = "Viernes";
break;
case "Sabado":
$calculo->fechahoy->EditValue = "Sabado";
break;
case "Domingo":
$calculo->fechahoy->EditValue = "Domingo";
break;
default:
$calculo->fechahoy->EditValue = $calculo->fechahoy->CurrentValue;
}
} else {
$calculo->fechahoy->EditValue = NULL;
}
$calculo->fechahoy->CssStyle = "";
$calculo->fechahoy->CssClass = "";
$calculo->fechahoy->ViewCustomAttributes = "";
// fechahasta
$calculo->fechahasta->EditCustomAttributes = "";
$calculo->fechahasta->EditValue = $calculo->fechahasta->CurrentValue;
$calculo->fechahasta->CssStyle = "";
$calculo->fechahasta->CssClass = "";
$calculo->fechahasta->ViewCustomAttributes = "";
// diasresta
$calculo->diasresta->EditCustomAttributes = "";
$calculo->diasresta->EditValue = ew_HtmlEncode($calculo->diasresta->CurrentValue);
// diaslleva
$calculo->diaslleva->EditCustomAttributes = "";
$calculo->diaslleva->EditValue = ew_HtmlEncode($calculo->diaslleva->CurrentValue);
// diasllevalab
$calculo->diasllevalab->EditCustomAttributes = "";
$calculo->diasllevalab->EditValue = ew_HtmlEncode($calculo->diasllevalab->CurrentValue);
// Edit refer script
// fechahoy
$calculo->fechahoy->HrefValue = "";
// fechahasta
$calculo->fechahasta->HrefValue = "";
// diasresta
$calculo->diasresta->HrefValue = "";
// diaslleva
$calculo->diaslleva->HrefValue = "";
// diasllevalab
$calculo->diasllevalab->HrefValue = "";
}
// Call Row Rendered event
if ($calculo->RowType <> EW_ROWTYPE_AGGREGATEINIT)
$calculo->Row_Rendered();
}
// Validate form
function ValidateForm() {
global $Language, $gsFormError, $calculo;
// Initialize form error message
$gsFormError = "";
// Check if validation required
if (!EW_SERVER_VALIDATE)
return ($gsFormError == "");
if (!ew_CheckInteger($calculo->diasresta->FormValue)) {
if ($gsFormError <> "") $gsFormError .= "<br>";
$gsFormError .= $calculo->diasresta->FldErrMsg();
}
if (!ew_CheckInteger($calculo->diaslleva->FormValue)) {
if ($gsFormError <> "") $gsFormError .= "<br>";
$gsFormError .= $calculo->diaslleva->FldErrMsg();
}
if (!ew_CheckInteger($calculo->diasllevalab->FormValue)) {
if ($gsFormError <> "") $gsFormError .= "<br>";
$gsFormError .= $calculo->diasllevalab->FldErrMsg();
}
// Return validate result
$ValidateForm = ($gsFormError == "");
// Call Form_CustomValidate event
$sFormCustomError = "";
$ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
if ($sFormCustomError <> "") {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $sFormCustomError;
}
return $ValidateForm;
}
// Update record based on key values
function EditRow() {
global $conn, $Security, $Language, $calculo;
$sFilter = $calculo->KeyFilter();
$calculo->CurrentFilter = $sFilter;
$sSql = $calculo->SQL();
$conn->raiseErrorFn = 'ew_ErrorFn';
$rs = $conn->Execute($sSql);
$conn->raiseErrorFn = '';
if ($rs === FALSE)
return FALSE;
if ($rs->EOF) {
$EditRow = FALSE; // Update Failed
} else {
// Save old values
$rsold =& $rs->fields;
$rsnew = array();
// fechahoy
// fechahasta
// diasresta
$calculo->diasresta->SetDbValueDef($rsnew, $calculo->diasresta->CurrentValue, NULL, FALSE);
// diaslleva
$calculo->diaslleva->SetDbValueDef($rsnew, $calculo->diaslleva->CurrentValue, NULL, FALSE);
// diasllevalab
$calculo->diasllevalab->SetDbValueDef($rsnew, $calculo->diasllevalab->CurrentValue, NULL, FALSE);
// Call Row Updating event
$bUpdateRow = $calculo->Row_Updating($rsold, $rsnew);
if ($bUpdateRow) {
$conn->raiseErrorFn = 'ew_ErrorFn';
$EditRow = $conn->Execute($calculo->UpdateSQL($rsnew));
$conn->raiseErrorFn = '';
} else {
if ($calculo->CancelMessage <> "") {
$this->setMessage($calculo->CancelMessage);
$calculo->CancelMessage = "";
} else {
$this->setMessage($Language->Phrase("UpdateCancelled"));
}
$EditRow = FALSE;
}
}
// Call Row_Updated event
if ($EditRow)
$calculo->Row_Updated($rsold, $rsnew);
$rs->Close();
return $EditRow;
}
// Page Load event
function Page_Load() {
//echo "Page Load";
}
// Page Unload event
function Page_Unload() {
//echo "Page Unload";
}
// Page Redirecting event
function Page_Redirecting(&$url) {
// Example:
//$url = "your URL";
}
// Message Showing event
function Message_Showing(&$msg) {
// Example:
//$msg = "your new message";
}
// Form Custom Validate event
function Form_CustomValidate(&$CustomError) {
// Return error message in CustomError
return TRUE;
}
}
?>