-
Notifications
You must be signed in to change notification settings - Fork 0
/
userlevelsinfo.php
888 lines (738 loc) · 24.3 KB
/
userlevelsinfo.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
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
<?php
// Global variable for table object
$userlevels = NULL;
//
// Table class for userlevels
//
class cuserlevels extends cTable {
var $userlevelid;
var $userlevelname;
//
// Table class constructor
//
function __construct() {
global $Language;
// Language object
if (!isset($Language)) $Language = new cLanguage();
$this->TableVar = 'userlevels';
$this->TableName = 'userlevels';
$this->TableType = 'TABLE';
// Update Table
$this->UpdateTable = "`userlevels`";
$this->DBID = 'DB';
$this->ExportAll = TRUE;
$this->ExportPageBreakCount = 0; // Page break per every n record (PDF only)
$this->ExportPageOrientation = "portrait"; // Page orientation (PDF only)
$this->ExportPageSize = "a4"; // Page size (PDF only)
$this->ExportExcelPageOrientation = ""; // Page orientation (PHPExcel only)
$this->ExportExcelPageSize = ""; // Page size (PHPExcel only)
$this->DetailAdd = FALSE; // Allow detail add
$this->DetailEdit = FALSE; // Allow detail edit
$this->DetailView = FALSE; // Allow detail view
$this->ShowMultipleDetails = FALSE; // Show multiple details
$this->GridAddRowCount = 5;
$this->AllowAddDeleteRow = ew_AllowAddDeleteRow(); // Allow add/delete row
$this->UserIDAllowSecurity = 0; // User ID Allow
$this->BasicSearch = new cBasicSearch($this->TableVar);
// userlevelid
$this->userlevelid = new cField('userlevels', 'userlevels', 'x_userlevelid', 'userlevelid', '`userlevelid`', '`userlevelid`', 3, -1, FALSE, '`userlevelid`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
$this->userlevelid->Sortable = TRUE; // Allow sort
$this->userlevelid->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
$this->fields['userlevelid'] = &$this->userlevelid;
// userlevelname
$this->userlevelname = new cField('userlevels', 'userlevels', 'x_userlevelname', 'userlevelname', '`userlevelname`', '`userlevelname`', 200, -1, FALSE, '`userlevelname`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
$this->userlevelname->Sortable = TRUE; // Allow sort
$this->fields['userlevelname'] = &$this->userlevelname;
}
// Set Field Visibility
function SetFieldVisibility($fldparm) {
global $Security;
return $this->$fldparm->Visible; // Returns original value
}
// Single column sort
function UpdateSort(&$ofld) {
if ($this->CurrentOrder == $ofld->FldName) {
$sSortField = $ofld->FldExpression;
$sLastSort = $ofld->getSort();
if ($this->CurrentOrderType == "ASC" || $this->CurrentOrderType == "DESC") {
$sThisSort = $this->CurrentOrderType;
} else {
$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
}
$ofld->setSort($sThisSort);
$this->setSessionOrderBy($sSortField . " " . $sThisSort); // Save to Session
} else {
$ofld->setSort("");
}
}
// Current detail table name
function getCurrentDetailTable() {
return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_DETAIL_TABLE];
}
function setCurrentDetailTable($v) {
$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_DETAIL_TABLE] = $v;
}
// Get detail url
function GetDetailUrl() {
// Detail url
$sDetailUrl = "";
if ($this->getCurrentDetailTable() == "userlevelpermissions") {
$sDetailUrl = $GLOBALS["userlevelpermissions"]->GetListUrl() . "?" . EW_TABLE_SHOW_MASTER . "=" . $this->TableVar;
$sDetailUrl .= "&fk_userlevelid=" . urlencode($this->userlevelid->CurrentValue);
}
if ($sDetailUrl == "") {
$sDetailUrl = "userlevelslist.php";
}
return $sDetailUrl;
}
// Table level SQL
var $_SqlFrom = "";
function getSqlFrom() { // From
return ($this->_SqlFrom <> "") ? $this->_SqlFrom : "`userlevels`";
}
function SqlFrom() { // For backward compatibility
return $this->getSqlFrom();
}
function setSqlFrom($v) {
$this->_SqlFrom = $v;
}
var $_SqlSelect = "";
function getSqlSelect() { // Select
return ($this->_SqlSelect <> "") ? $this->_SqlSelect : "SELECT * FROM " . $this->getSqlFrom();
}
function SqlSelect() { // For backward compatibility
return $this->getSqlSelect();
}
function setSqlSelect($v) {
$this->_SqlSelect = $v;
}
var $_SqlWhere = "";
function getSqlWhere() { // Where
$sWhere = ($this->_SqlWhere <> "") ? $this->_SqlWhere : "";
$this->TableFilter = "";
ew_AddFilter($sWhere, $this->TableFilter);
return $sWhere;
}
function SqlWhere() { // For backward compatibility
return $this->getSqlWhere();
}
function setSqlWhere($v) {
$this->_SqlWhere = $v;
}
var $_SqlGroupBy = "";
function getSqlGroupBy() { // Group By
return ($this->_SqlGroupBy <> "") ? $this->_SqlGroupBy : "";
}
function SqlGroupBy() { // For backward compatibility
return $this->getSqlGroupBy();
}
function setSqlGroupBy($v) {
$this->_SqlGroupBy = $v;
}
var $_SqlHaving = "";
function getSqlHaving() { // Having
return ($this->_SqlHaving <> "") ? $this->_SqlHaving : "";
}
function SqlHaving() { // For backward compatibility
return $this->getSqlHaving();
}
function setSqlHaving($v) {
$this->_SqlHaving = $v;
}
var $_SqlOrderBy = "";
function getSqlOrderBy() { // Order By
return ($this->_SqlOrderBy <> "") ? $this->_SqlOrderBy : "";
}
function SqlOrderBy() { // For backward compatibility
return $this->getSqlOrderBy();
}
function setSqlOrderBy($v) {
$this->_SqlOrderBy = $v;
}
// Apply User ID filters
function ApplyUserIDFilters($sFilter) {
return $sFilter;
}
// Check if User ID security allows view all
function UserIDAllow($id = "") {
$allow = EW_USER_ID_ALLOW;
switch ($id) {
case "add":
case "copy":
case "gridadd":
case "register":
case "addopt":
return (($allow & 1) == 1);
case "edit":
case "gridedit":
case "update":
case "changepwd":
case "forgotpwd":
return (($allow & 4) == 4);
case "delete":
return (($allow & 2) == 2);
case "view":
return (($allow & 32) == 32);
case "search":
return (($allow & 64) == 64);
default:
return (($allow & 8) == 8);
}
}
// Get SQL
function GetSQL($where, $orderby) {
return ew_BuildSelectSql($this->getSqlSelect(), $this->getSqlWhere(),
$this->getSqlGroupBy(), $this->getSqlHaving(), $this->getSqlOrderBy(),
$where, $orderby);
}
// Table SQL
function SQL() {
$sFilter = $this->CurrentFilter;
$sFilter = $this->ApplyUserIDFilters($sFilter);
$sSort = $this->getSessionOrderBy();
return ew_BuildSelectSql($this->getSqlSelect(), $this->getSqlWhere(),
$this->getSqlGroupBy(), $this->getSqlHaving(), $this->getSqlOrderBy(),
$sFilter, $sSort);
}
// Table SQL with List page filter
function SelectSQL() {
$sFilter = $this->getSessionWhere();
ew_AddFilter($sFilter, $this->CurrentFilter);
$sFilter = $this->ApplyUserIDFilters($sFilter);
$this->Recordset_Selecting($sFilter);
$sSort = $this->getSessionOrderBy();
return ew_BuildSelectSql($this->getSqlSelect(), $this->getSqlWhere(), $this->getSqlGroupBy(),
$this->getSqlHaving(), $this->getSqlOrderBy(), $sFilter, $sSort);
}
// Get ORDER BY clause
function GetOrderBy() {
$sSort = $this->getSessionOrderBy();
return ew_BuildSelectSql("", "", "", "", $this->getSqlOrderBy(), "", $sSort);
}
// Try to get record count
function TryGetRecordCount($sSql) {
$cnt = -1;
if (($this->TableType == 'TABLE' || $this->TableType == 'VIEW' || $this->TableType == 'LINKTABLE') && preg_match("/^SELECT \* FROM/i", $sSql)) {
$sSql = "SELECT COUNT(*) FROM" . preg_replace('/^SELECT\s([\s\S]+)?\*\sFROM/i', "", $sSql);
$sOrderBy = $this->GetOrderBy();
if (substr($sSql, strlen($sOrderBy) * -1) == $sOrderBy)
$sSql = substr($sSql, 0, strlen($sSql) - strlen($sOrderBy)); // Remove ORDER BY clause
} else {
$sSql = "SELECT COUNT(*) FROM (" . $sSql . ") EW_COUNT_TABLE";
}
$conn = &$this->Connection();
if ($rs = $conn->Execute($sSql)) {
if (!$rs->EOF && $rs->FieldCount() > 0) {
$cnt = $rs->fields[0];
$rs->Close();
}
}
return intval($cnt);
}
// Get record count based on filter (for detail record count in master table pages)
function LoadRecordCount($sFilter) {
$origFilter = $this->CurrentFilter;
$this->CurrentFilter = $sFilter;
$this->Recordset_Selecting($this->CurrentFilter);
//$sSql = $this->SQL();
$sSql = $this->GetSQL($this->CurrentFilter, "");
$cnt = $this->TryGetRecordCount($sSql);
if ($cnt == -1) {
if ($rs = $this->LoadRs($this->CurrentFilter)) {
$cnt = $rs->RecordCount();
$rs->Close();
}
}
$this->CurrentFilter = $origFilter;
return intval($cnt);
}
// Get record count (for current List page)
function SelectRecordCount() {
$sSql = $this->SelectSQL();
$cnt = $this->TryGetRecordCount($sSql);
if ($cnt == -1) {
$conn = &$this->Connection();
if ($rs = $conn->Execute($sSql)) {
$cnt = $rs->RecordCount();
$rs->Close();
}
}
return intval($cnt);
}
// INSERT statement
function InsertSQL(&$rs) {
$names = "";
$values = "";
foreach ($rs as $name => $value) {
if (!isset($this->fields[$name]) || $this->fields[$name]->FldIsCustom)
continue;
$names .= $this->fields[$name]->FldExpression . ",";
$values .= ew_QuotedValue($value, $this->fields[$name]->FldDataType, $this->DBID) . ",";
}
while (substr($names, -1) == ",")
$names = substr($names, 0, -1);
while (substr($values, -1) == ",")
$values = substr($values, 0, -1);
return "INSERT INTO " . $this->UpdateTable . " ($names) VALUES ($values)";
}
// Insert
function Insert(&$rs) {
$conn = &$this->Connection();
return $conn->Execute($this->InsertSQL($rs));
}
// UPDATE statement
function UpdateSQL(&$rs, $where = "", $curfilter = TRUE) {
$sql = "UPDATE " . $this->UpdateTable . " SET ";
foreach ($rs as $name => $value) {
if (!isset($this->fields[$name]) || $this->fields[$name]->FldIsCustom)
continue;
$sql .= $this->fields[$name]->FldExpression . "=";
$sql .= ew_QuotedValue($value, $this->fields[$name]->FldDataType, $this->DBID) . ",";
}
while (substr($sql, -1) == ",")
$sql = substr($sql, 0, -1);
$filter = ($curfilter) ? $this->CurrentFilter : "";
if (is_array($where))
$where = $this->ArrayToFilter($where);
ew_AddFilter($filter, $where);
if ($filter <> "") $sql .= " WHERE " . $filter;
return $sql;
}
// Update
function Update(&$rs, $where = "", $rsold = NULL, $curfilter = TRUE) {
$conn = &$this->Connection();
return $conn->Execute($this->UpdateSQL($rs, $where, $curfilter));
}
// DELETE statement
function DeleteSQL(&$rs, $where = "", $curfilter = TRUE) {
$sql = "DELETE FROM " . $this->UpdateTable . " WHERE ";
if (is_array($where))
$where = $this->ArrayToFilter($where);
if ($rs) {
if (array_key_exists('userlevelid', $rs))
ew_AddFilter($where, ew_QuotedName('userlevelid', $this->DBID) . '=' . ew_QuotedValue($rs['userlevelid'], $this->userlevelid->FldDataType, $this->DBID));
}
$filter = ($curfilter) ? $this->CurrentFilter : "";
ew_AddFilter($filter, $where);
if ($filter <> "")
$sql .= $filter;
else
$sql .= "0=1"; // Avoid delete
return $sql;
}
// Delete
function Delete(&$rs, $where = "", $curfilter = TRUE) {
$conn = &$this->Connection();
return $conn->Execute($this->DeleteSQL($rs, $where, $curfilter));
}
// Key filter WHERE clause
function SqlKeyFilter() {
return "`userlevelid` = @userlevelid@";
}
// Key filter
function KeyFilter() {
$sKeyFilter = $this->SqlKeyFilter();
if (!is_numeric($this->userlevelid->CurrentValue))
$sKeyFilter = "0=1"; // Invalid key
$sKeyFilter = str_replace("@userlevelid@", ew_AdjustSql($this->userlevelid->CurrentValue, $this->DBID), $sKeyFilter); // Replace key value
return $sKeyFilter;
}
// Return page URL
function getReturnUrl() {
$name = EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_RETURN_URL;
// Get referer URL automatically
if (ew_ServerVar("HTTP_REFERER") <> "" && ew_ReferPage() <> ew_CurrentPage() && ew_ReferPage() <> "login.php") // Referer not same page or login page
$_SESSION[$name] = ew_ServerVar("HTTP_REFERER"); // Save to Session
if (@$_SESSION[$name] <> "") {
return $_SESSION[$name];
} else {
return "userlevelslist.php";
}
}
function setReturnUrl($v) {
$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_RETURN_URL] = $v;
}
// List URL
function GetListUrl() {
return "userlevelslist.php";
}
// View URL
function GetViewUrl($parm = "") {
if ($parm <> "")
$url = $this->KeyUrl("userlevelsview.php", $this->UrlParm($parm));
else
$url = $this->KeyUrl("userlevelsview.php", $this->UrlParm(EW_TABLE_SHOW_DETAIL . "="));
return $this->AddMasterUrl($url);
}
// Add URL
function GetAddUrl($parm = "") {
if ($parm <> "")
$url = "userlevelsadd.php?" . $this->UrlParm($parm);
else
$url = "userlevelsadd.php";
return $this->AddMasterUrl($url);
}
// Edit URL
function GetEditUrl($parm = "") {
if ($parm <> "")
$url = $this->KeyUrl("userlevelsedit.php", $this->UrlParm($parm));
else
$url = $this->KeyUrl("userlevelsedit.php", $this->UrlParm(EW_TABLE_SHOW_DETAIL . "="));
return $this->AddMasterUrl($url);
}
// Inline edit URL
function GetInlineEditUrl() {
$url = $this->KeyUrl(ew_CurrentPage(), $this->UrlParm("a=edit"));
return $this->AddMasterUrl($url);
}
// Copy URL
function GetCopyUrl($parm = "") {
if ($parm <> "")
$url = $this->KeyUrl("userlevelsadd.php", $this->UrlParm($parm));
else
$url = $this->KeyUrl("userlevelsadd.php", $this->UrlParm(EW_TABLE_SHOW_DETAIL . "="));
return $this->AddMasterUrl($url);
}
// Inline copy URL
function GetInlineCopyUrl() {
$url = $this->KeyUrl(ew_CurrentPage(), $this->UrlParm("a=copy"));
return $this->AddMasterUrl($url);
}
// Delete URL
function GetDeleteUrl() {
return $this->KeyUrl("userlevelsdelete.php", $this->UrlParm());
}
// Add master url
function AddMasterUrl($url) {
return $url;
}
function KeyToJson() {
$json = "";
$json .= "userlevelid:" . ew_VarToJson($this->userlevelid->CurrentValue, "number", "'");
return "{" . $json . "}";
}
// Add key value to URL
function KeyUrl($url, $parm = "") {
$sUrl = $url . "?";
if ($parm <> "") $sUrl .= $parm . "&";
if (!is_null($this->userlevelid->CurrentValue)) {
$sUrl .= "userlevelid=" . urlencode($this->userlevelid->CurrentValue);
} else {
return "javascript:ew_Alert(ewLanguage.Phrase('InvalidRecord'));";
}
return $sUrl;
}
// Sort URL
function SortUrl(&$fld) {
if ($this->CurrentAction <> "" || $this->Export <> "" ||
in_array($fld->FldType, array(128, 204, 205))) { // Unsortable data type
return "";
} elseif ($fld->Sortable) {
$sUrlParm = $this->UrlParm("order=" . urlencode($fld->FldName) . "&ordertype=" . $fld->ReverseSort());
return $this->AddMasterUrl(ew_CurrentPage() . "?" . $sUrlParm);
} else {
return "";
}
}
// Get record keys from $_POST/$_GET/$_SESSION
function GetRecordKeys() {
global $EW_COMPOSITE_KEY_SEPARATOR;
$arKeys = array();
$arKey = array();
if (isset($_POST["key_m"])) {
$arKeys = ew_StripSlashes($_POST["key_m"]);
$cnt = count($arKeys);
} elseif (isset($_GET["key_m"])) {
$arKeys = ew_StripSlashes($_GET["key_m"]);
$cnt = count($arKeys);
} elseif (!empty($_GET) || !empty($_POST)) {
$isPost = ew_IsHttpPost();
if ($isPost && isset($_POST["userlevelid"]))
$arKeys[] = ew_StripSlashes($_POST["userlevelid"]);
elseif (isset($_GET["userlevelid"]))
$arKeys[] = ew_StripSlashes($_GET["userlevelid"]);
else
$arKeys = NULL; // Do not setup
//return $arKeys; // Do not return yet, so the values will also be checked by the following code
}
// Check keys
$ar = array();
if (is_array($arKeys)) {
foreach ($arKeys as $key) {
if (!is_numeric($key))
continue;
$ar[] = $key;
}
}
return $ar;
}
// Get key filter
function GetKeyFilter() {
$arKeys = $this->GetRecordKeys();
$sKeyFilter = "";
foreach ($arKeys as $key) {
if ($sKeyFilter <> "") $sKeyFilter .= " OR ";
$this->userlevelid->CurrentValue = $key;
$sKeyFilter .= "(" . $this->KeyFilter() . ")";
}
return $sKeyFilter;
}
// Load rows based on filter
function &LoadRs($sFilter) {
// Set up filter (SQL WHERE clause) and get return SQL
//$this->CurrentFilter = $sFilter;
//$sSql = $this->SQL();
$sSql = $this->GetSQL($sFilter, "");
$conn = &$this->Connection();
$rs = $conn->Execute($sSql);
return $rs;
}
// Load row values from recordset
function LoadListRowValues(&$rs) {
$this->userlevelid->setDbValue($rs->fields('userlevelid'));
$this->userlevelname->setDbValue($rs->fields('userlevelname'));
}
// Render list row values
function RenderListRow() {
global $Security, $gsLanguage, $Language;
// Call Row Rendering event
$this->Row_Rendering();
// Common render codes
// userlevelid
// userlevelname
// userlevelid
$this->userlevelid->ViewValue = $this->userlevelid->CurrentValue;
$this->userlevelid->ViewCustomAttributes = "";
// userlevelname
$this->userlevelname->ViewValue = $this->userlevelname->CurrentValue;
$this->userlevelname->ViewCustomAttributes = "";
// userlevelid
$this->userlevelid->LinkCustomAttributes = "";
$this->userlevelid->HrefValue = "";
$this->userlevelid->TooltipValue = "";
// userlevelname
$this->userlevelname->LinkCustomAttributes = "";
$this->userlevelname->HrefValue = "";
$this->userlevelname->TooltipValue = "";
// Call Row Rendered event
$this->Row_Rendered();
}
// Render edit row values
function RenderEditRow() {
global $Security, $gsLanguage, $Language;
// Call Row Rendering event
$this->Row_Rendering();
// userlevelid
$this->userlevelid->EditAttrs["class"] = "form-control";
$this->userlevelid->EditCustomAttributes = "";
$this->userlevelid->EditValue = $this->userlevelid->CurrentValue;
$this->userlevelid->ViewCustomAttributes = "";
// userlevelname
$this->userlevelname->EditAttrs["class"] = "form-control";
$this->userlevelname->EditCustomAttributes = "";
$this->userlevelname->EditValue = $this->userlevelname->CurrentValue;
$this->userlevelname->PlaceHolder = ew_RemoveHtml($this->userlevelname->FldCaption());
// Call Row Rendered event
$this->Row_Rendered();
}
// Aggregate list row values
function AggregateListRowValues() {
}
// Aggregate list row (for rendering)
function AggregateListRow() {
// Call Row Rendered event
$this->Row_Rendered();
}
var $ExportDoc;
// Export data in HTML/CSV/Word/Excel/Email/PDF format
function ExportDocument(&$Doc, &$Recordset, $StartRec, $StopRec, $ExportPageType = "") {
if (!$Recordset || !$Doc)
return;
if (!$Doc->ExportCustom) {
// Write header
$Doc->ExportTableHeader();
if ($Doc->Horizontal) { // Horizontal format, write header
$Doc->BeginExportRow();
if ($ExportPageType == "view") {
if ($this->userlevelid->Exportable) $Doc->ExportCaption($this->userlevelid);
if ($this->userlevelname->Exportable) $Doc->ExportCaption($this->userlevelname);
} else {
if ($this->userlevelid->Exportable) $Doc->ExportCaption($this->userlevelid);
if ($this->userlevelname->Exportable) $Doc->ExportCaption($this->userlevelname);
}
$Doc->EndExportRow();
}
}
// Move to first record
$RecCnt = $StartRec - 1;
if (!$Recordset->EOF) {
$Recordset->MoveFirst();
if ($StartRec > 1)
$Recordset->Move($StartRec - 1);
}
while (!$Recordset->EOF && $RecCnt < $StopRec) {
$RecCnt++;
if (intval($RecCnt) >= intval($StartRec)) {
$RowCnt = intval($RecCnt) - intval($StartRec) + 1;
// Page break
if ($this->ExportPageBreakCount > 0) {
if ($RowCnt > 1 && ($RowCnt - 1) % $this->ExportPageBreakCount == 0)
$Doc->ExportPageBreak();
}
$this->LoadListRowValues($Recordset);
// Render row
$this->RowType = EW_ROWTYPE_VIEW; // Render view
$this->ResetAttrs();
$this->RenderListRow();
if (!$Doc->ExportCustom) {
$Doc->BeginExportRow($RowCnt); // Allow CSS styles if enabled
if ($ExportPageType == "view") {
if ($this->userlevelid->Exportable) $Doc->ExportField($this->userlevelid);
if ($this->userlevelname->Exportable) $Doc->ExportField($this->userlevelname);
} else {
if ($this->userlevelid->Exportable) $Doc->ExportField($this->userlevelid);
if ($this->userlevelname->Exportable) $Doc->ExportField($this->userlevelname);
}
$Doc->EndExportRow();
}
}
// Call Row Export server event
if ($Doc->ExportCustom)
$this->Row_Export($Recordset->fields);
$Recordset->MoveNext();
}
if (!$Doc->ExportCustom) {
$Doc->ExportTableFooter();
}
}
// Get auto fill value
function GetAutoFill($id, $val) {
$rsarr = array();
$rowcnt = 0;
// Output
if (is_array($rsarr) && $rowcnt > 0) {
$fldcnt = count($rsarr[0]);
for ($i = 0; $i < $rowcnt; $i++) {
for ($j = 0; $j < $fldcnt; $j++) {
$str = strval($rsarr[$i][$j]);
$str = ew_ConvertToUtf8($str);
if (isset($post["keepCRLF"])) {
$str = str_replace(array("\r", "\n"), array("\\r", "\\n"), $str);
} else {
$str = str_replace(array("\r", "\n"), array(" ", " "), $str);
}
$rsarr[$i][$j] = $str;
}
}
return ew_ArrayToJson($rsarr);
} else {
return FALSE;
}
}
// Table level events
// Recordset Selecting event
function Recordset_Selecting(&$filter) {
// Enter your code here
}
// Recordset Selected event
function Recordset_Selected(&$rs) {
//echo "Recordset Selected";
}
// Recordset Search Validated event
function Recordset_SearchValidated() {
// Example:
//$this->MyField1->AdvancedSearch->SearchValue = "your search criteria"; // Search value
}
// Recordset Searching event
function Recordset_Searching(&$filter) {
// Enter your code here
}
// Row_Selecting event
function Row_Selecting(&$filter) {
// Enter your code here
}
// Row Selected event
function Row_Selected(&$rs) {
//echo "Row Selected";
}
// Row Inserting event
function Row_Inserting($rsold, &$rsnew) {
// Enter your code here
// To cancel, set return value to FALSE
return TRUE;
}
// Row Inserted event
function Row_Inserted($rsold, &$rsnew) {
//echo "Row Inserted"
}
// Row Updating event
function Row_Updating($rsold, &$rsnew) {
// Enter your code here
// To cancel, set return value to FALSE
return TRUE;
}
// Row Updated event
function Row_Updated($rsold, &$rsnew) {
//echo "Row Updated";
}
// Row Update Conflict event
function Row_UpdateConflict($rsold, &$rsnew) {
// Enter your code here
// To ignore conflict, set return value to FALSE
return TRUE;
}
// Grid Inserting event
function Grid_Inserting() {
// Enter your code here
// To reject grid insert, set return value to FALSE
return TRUE;
}
// Grid Inserted event
function Grid_Inserted($rsnew) {
//echo "Grid Inserted";
}
// Grid Updating event
function Grid_Updating($rsold) {
// Enter your code here
// To reject grid update, set return value to FALSE
return TRUE;
}
// Grid Updated event
function Grid_Updated($rsold, $rsnew) {
//echo "Grid Updated";
}
// Row Deleting event
function Row_Deleting(&$rs) {
// Enter your code here
// To cancel, set return value to False
return TRUE;
}
// Row Deleted event
function Row_Deleted(&$rs) {
//echo "Row Deleted";
}
// Email Sending event
function Email_Sending(&$Email, &$Args) {
//var_dump($Email); var_dump($Args); exit();
return TRUE;
}
// Lookup Selecting event
function Lookup_Selecting($fld, &$filter) {
//var_dump($fld->FldName, $fld->LookupFilters, $filter); // Uncomment to view the filter
// Enter your code here
}
// Row Rendering event
function Row_Rendering() {
// Enter your code here
}
// Row Rendered event
function Row_Rendered() {
// To view properties of field class, use:
//var_dump($this-><FieldName>);
}
// User ID Filtering event
function UserID_Filtering(&$filter) {
// Enter your code here
}
}
?>