-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathphpfn9.php
5435 lines (4848 loc) · 151 KB
/
phpfn9.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
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* PHPMaker Common classes and functions
* (C) 2002-2012 e.World Technology Limited. All rights reserved.
*/
// Auto load class
function ew_AutoLoad($class) {
if (substr($class, 0, 1) == "c") {
$fn = "%cls%info.php";
$file = str_replace("%cls%", substr($class, 1), $fn);
if (file_exists($file))
include $file;
}
}
spl_autoload_register("ew_AutoLoad");
if (!function_exists("G")) {
function &G($name) {
return $GLOBALS[$name];
}
}
// Get current project ID
function CurrentProjectID() {
if (isset($GLOBALS["Page"]))
return $GLOBALS["Page"]->ProjectID;
return "{94C0E450-F9A8-47EE-A905-551040DB9277}";
}
// Get current page object
function &CurrentPage() {
return $GLOBALS["Page"];
}
// Get current main table object
function &CurrentTable() {
return $GLOBALS["Table"];
}
// Get current master table object
function &CurrentMasterTable() {
$res = NULL;
$tbl = &CurrentTable();
if ($tbl && method_exists($tbl, "getCurrentMasterTable") && $tbl->getCurrentMasterTable() <> "")
$res = $GLOBALS[$tbl->getCurrentMasterTable()];
return $res;
}
// Get PHP errors
function ew_ErrorHandler($errno, $errstr, $errfile, $errline) {
switch ($errno) {
case E_USER_ERROR:
case E_RECOVERABLE_ERROR:
ew_AddMessage($_SESSION[EW_SESSION_FAILURE_MESSAGE], $errstr . ", file: " . $errfile . ", line: " . $errline);
break;
case E_WARNING:
case E_USER_WARNING:
ew_AddMessage($_SESSION[EW_SESSION_WARNING_MESSAGE], $errstr . ", file: " . $errfile . ", line: " . $errline);
break;
//case E_NOTICE: // Skip
case E_USER_NOTICE:
case E_STRICT:
case E_DEPRECATED:
case E_USER_DEPRECATED:
ew_AddMessage($_SESSION[EW_SESSION_MESSAGE], $errstr . ", file: " . $errfile . ", line: " . $errline);
break;
default:
break;
}
return FALSE; // Restore standard PHP error handler
}
/**
* Export document classes
*/
// Get export document object
function &ew_ExportDocument(&$tbl, $style) {
global $EW_EXPORT;
$inst = NULL;
$type = strtolower($tbl->Export);
$class = $EW_EXPORT[$type];
if (class_exists($class))
$inst = new $class($tbl, $style);
return $inst;
}
//
// Base class for export
//
class cExportBase {
var $Table;
var $Text;
var $Line = "";
var $Header = "";
var $Style = "h"; // "v"(Vertical) or "h"(Horizontal)
var $Horizontal = TRUE; // Horizontal
var $RowCnt = 0;
var $FldCnt = 0;
// Constructor
function __construct(&$tbl = NULL, $style = "") {
$this->Table = $tbl;
$this->SetStyle($style);
}
// Style
function SetStyle($style) {
if (strtolower($style) == "v" || strtolower($style) == "h")
$this->Style = strtolower($style);
$this->Horizontal = ($this->Style <> "v");
}
// Field caption
function ExportCaption(&$fld) {
$this->FldCnt++;
$this->ExportValueEx($fld, $fld->ExportCaption());
}
// Field value
function ExportValue(&$fld) {
$this->ExportValueEx($fld, $fld->ExportValue());
}
// Field aggregate
function ExportAggregate(&$fld, $type) {
$this->FldCnt++;
if ($this->Horizontal) {
global $Language;
$val = "";
if (in_array($type, array("TOTAL", "COUNT", "AVERAGE")))
$val = $Language->Phrase($type) . ": " . $fld->ExportValue();
$this->ExportValueEx($fld, $val);
}
}
// Get meta tag for charset
function CharsetMetaTag() {
return "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . EW_CHARSET . "\"/>\r\n";
}
// Table header
function ExportTableHeader() {
$this->Text .= "<table cellspacing=\"0\" class=\"ewExportTable\">";
}
// Export a value (caption, field value, or aggregate)
function ExportValueEx(&$fld, $val, $usestyle = TRUE) {
$this->Text .= "<td" . (($usestyle && EW_EXPORT_CSS_STYLES) ? $fld->CellStyles() : "") . ">";
$this->Text .= strval($val);
$this->Text .= "</td>";
}
// Begin a row
function BeginExportRow($rowcnt = 0, $usestyle = TRUE) {
$this->RowCnt++;
$this->FldCnt = 0;
if ($this->Horizontal) {
if ($rowcnt == -1) {
$this->Table->CssClass = "ewExportTableFooter";
} elseif ($rowcnt == 0) {
$this->Table->CssClass = "ewExportTableHeader";
} else {
$this->Table->CssClass = (($rowcnt % 2) == 1) ? "ewExportTableRow" : "ewExportTableAltRow";
}
$this->Text .= "<tr" . (($usestyle && EW_EXPORT_CSS_STYLES) ? $this->Table->RowStyles() : "") . ">";
}
}
// End a row
function EndExportRow() {
if ($this->Horizontal)
$this->Text .= "</tr>";
}
// Empty row
function ExportEmptyRow() {
$this->RowCnt++;
$this->Text .= "<br>";
}
// Page break
function ExportPageBreak() {
}
// Export a field
function ExportField(&$fld) {
$this->FldCnt++;
$wrkExportValue = "";
if ($fld->HrefValue2 <> "") { // Upload field
if (!empty($fld->Upload->DbValue))
$wrkExportValue = ew_ConvertFullUrl($fld->HrefValue2);
if ($wrkExportValue <> "") {
$attrs = array("href" => $wrkExportValue);
$wrkExportValue = ew_HtmlElement("a", $attrs, $fld->FldCaption());
}
} else {
$wrkExportValue = $fld->ExportValue($this->Table->Export, $fld->ExportOriginalValue);
}
if ($this->Horizontal) {
$this->ExportValueEx($fld, $wrkExportValue);
} else { // Vertical, export as a row
$this->RowCnt++;
$this->Text .= "<tr class=\"" . (($this->FldCnt % 2 == 1) ? "ewExportTableRow" : "ewExportTableAltRow") . "\">" .
"<td class=\"ewTableHeader\">" . $fld->ExportCaption() . "</td>";
$this->Text .= "<td" . ((EW_EXPORT_CSS_STYLES) ? $fld->CellStyles() : "") . ">" . $wrkExportValue . "</td></tr>";
}
}
// Table Footer
function ExportTableFooter() {
$this->Text .= "</table>";
}
// Add HTML tags
function ExportHeaderAndFooter() {
$header = "<html><head>\r\n";
$header .= $this->CharsetMetaTag();
if (EW_EXPORT_CSS_STYLES && EW_PROJECT_STYLESHEET_FILENAME <> "")
$header .= "<style type=\"text/css\">" . file_get_contents(EW_PROJECT_STYLESHEET_FILENAME) . "</style>\r\n";
$header .= "</" . "head>\r\n<body>\r\n";
$this->Text = $header . $this->Text . "</body></html>";
}
// Export
function Export() {
if (strtolower(EW_CHARSET) == "utf-8")
echo "\xEF\xBB\xBF";
echo $this->Text;
}
}
//
// Class for export to email
//
class cExportEmail extends cExportBase {
// Export a field
function ExportField(&$fld) {
$this->FldCnt++;
$ExportValue = $fld->ExportValue();
if ($fld->FldViewTag == "IMAGE") {
if ($fld->ImageResize && function_exists("ew_GdVersion") && ew_GdVersion() > 0) {
$imagefn = $fld->GetTempImage();
if ($imagefn <> "")
$ExportValue = "<img src=\"" . $imagefn . "\" alt=\"\" style=\"border: 0;\">";
} elseif ($ExportValue <> "") {
$ExportValue = ew_ConvertFullUrl($ExportValue);
$attrs = array("href" => $ExportValue);
$ExportValue = ew_HtmlElement("a", $attrs, $fld->FldCaption());
}
}
if ($this->Horizontal) {
$this->ExportValueEx($fld, $ExportValue);
} else { // Vertical, export as a row
$this->RowCnt++;
$this->Text .= "<tr class=\"" . (($this->FldCnt % 2 == 1) ? "ewExportTableRow" : "ewExportTableAltRow") . "\">" .
"<td class=\"ewTableHeader\">" . $fld->ExportCaption() . "</td>";
$this->Text .= "<td" . ((EW_EXPORT_CSS_STYLES) ? $fld->CellStyles() : "") . ">" . $ExportValue . "</td></tr>";
}
}
// Export
function Export() {
echo $this->Text;
}
// Destructor
function __destruct() {
ew_DeleteTmpImages();
}
}
//
// Class for export to HTML
//
class cExportHtml extends cExportBase {
// Same as base class
}
//
// Class for export to Word
//
class cExportWord extends cExportBase {
// Export
function Export() {
global $gsExportFile;
header('Content-Type: application/vnd.ms-word' . ((EW_CHARSET <> "") ? ";charset=" . EW_CHARSET : ""));
header('Content-Disposition: attachment; filename=' . $gsExportFile . '.doc');
if (strtolower(EW_CHARSET) == "utf-8")
echo "\xEF\xBB\xBF";
echo $this->Text;
}
}
//
// Class for export to Excel
//
class cExportExcel extends cExportBase {
// Export a value (caption, field value, or aggregate)
function ExportValueEx(&$fld, $val, $usestyle = TRUE) {
if ($fld->FldDataType == EW_DATATYPE_STRING && is_numeric($val))
$val = "=\"" . strval($val) . "\"";
$this->Text .= parent::ExportValueEx($fld, $val, $usestyle);
}
// Export
function Export() {
global $gsExportFile;
header('Content-Type: application/vnd.ms-excel' . ((EW_CHARSET <> "") ? ";charset=" . EW_CHARSET : ""));
header('Content-Disposition: attachment; filename=' . $gsExportFile . '.xls');
if (strtolower(EW_CHARSET) == "utf-8")
echo "\xEF\xBB\xBF";
echo $this->Text;
}
}
//
// Class for export to CSV
//
class cExportCsv extends cExportBase {
var $QuoteChar = "\"";
// Style
function ChangeStyle($style) {
$this->Horizontal = TRUE;
}
// Table header
function ExportTableHeader() {
// Skip
}
// Export a value (caption, field value, or aggregate)
function ExportValueEx(&$fld, $val, $usestyle = TRUE) {
if ($this->Line <> "")
$this->Line .= ",";
$this->Line .= $this->QuoteChar . str_replace($this->QuoteChar, $this->QuoteChar . $this->QuoteChar, strval($val)) . $this->QuoteChar;
}
// Begin a row
function BeginExportRow($rowcnt = 0, $usestyle = TRUE) {
$this->Line = "";
}
// End a row
function EndExportRow() {
$this->Line .= "\r\n";
$this->Text .= $this->Line;
}
// Empty line
function ExportEmptyLine() {
// Skip
}
// Export a field
function ExportField(&$fld) {
$this->ExportValue($fld);
}
// Table Footer
function ExportTableFooter() {
// Skip
}
// Add HTML tags
function ExportHeaderAndFooter() {
// Skip
}
// Export
function Export() {
global $gsExportFile;
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename=' . $gsExportFile . '.csv');
if (strtolower(EW_CHARSET) == "utf-8")
echo "\xEF\xBB\xBF";
echo $this->Text;
}
}
//
// Class for export to XML
//
class cExportXml extends cExportBase {
var $XmlDoc;
var $HasParent;
// Constructor
function __construct(&$tbl = NULL, $style = "") {
parent::__construct($tbl, $style);
$this->XmlDoc = new cXMLDocument(EW_XML_ENCODING);
}
// Style
function SetStyle($style) {}
// Field caption
function ExportCaption(&$fld) {}
// Field value
function ExportValue(&$fld) {}
// Field aggregate
function ExportAggregate(&$fld, $type) {}
// Get meta tag for charset
function CharsetMetaTag() {}
// Table header
function ExportTableHeader() {
$this->HasParent = is_object($this->XmlDoc->DocumentElement());
if (!$this->HasParent)
$this->XmlDoc->AddRoot($this->Table->TableVar);
}
// Export a value (caption, field value, or aggregate)
function ExportValueEx(&$fld, $val, $usestyle = TRUE) {}
// Begin a row
function BeginExportRow($rowcnt = 0, $usestyle = TRUE) {
if ($rowcnt <= 0)
return;
if ($this->HasParent)
$this->XmlDoc->AddRow($this->Table->TableVar);
else
$this->XmlDoc->AddRow();
}
// End a row
function EndExportRow() {}
// Empty row
function ExportEmptyRow() {}
// Page break
function ExportPageBreak() {}
// Export a field
function ExportField(&$fld) {
if ($fld->FldDataType <> EW_DATATYPE_BLOB) {
$ExportValue = $fld->ExportValue();
if (is_null($ExportValue))
$ExportValue = "<Null>";
$this->XmlDoc->AddField(substr($fld->FldVar, 2), $ExportValue);
}
}
// Table Footer
function ExportTableFooter() {}
// Add HTML tags
function ExportHeaderAndFooter() {}
// Export
function Export() {
global $gsExportFile;
ob_end_clean();
header('Content-Type: text/xml');
//header('Content-Disposition: attachment; filename=' . $gsExportFile . '.xml');
echo $this->XmlDoc->XML();
}
}
//
// Class for export to PDF
//
class cExportPdf extends cExportBase {
// Table header
function ExportTableHeader() {
$this->Text .= "<table cellspacing=\"0\" class=\"ewTablePdf ewTablePdfBorder\">\r\n";
}
// Export a value (caption, field value, or aggregate)
function ExportValueEx(&$fld, $val, $usestyle = TRUE) {
$wrkval = strval($val);
$wrkval = "<td" . (($usestyle && EW_EXPORT_CSS_STYLES) ? $fld->CellStyles() : "") . ">" . $wrkval . "</td>\r\n";
$this->Line .= $wrkval;
$this->Text .= $wrkval;
}
// Begin a row
function BeginExportRow($rowcnt = 0, $usestyle = TRUE) {
$this->FldCnt = 0;
if ($this->Horizontal) {
if ($rowcnt == -1)
$this->Table->CssClass = "ewTablePdfFooter";
elseif ($rowcnt == 0)
$this->Table->CssClass = "ewTablePdfHeader";
else
$this->Table->CssClass = (($rowcnt % 2) == 1) ? "ewTableRow" : "ewTableAltRow";
$this->Line = "<tr" . (($usestyle && EW_EXPORT_CSS_STYLES) ? $this->Table->RowStyles() : "") . ">";
$this->Text .= $this->Line;
}
}
// End a row
function EndExportRow() {
if ($this->Horizontal) {
$this->Line .= "</tr>";
$this->Text .= "</tr>";
$this->Header = $this->Line;
}
}
// Page break
function ExportPageBreak() {
if ($this->Horizontal) {
$this->Text .= "</table>\r\n"; // end current table
$this->Text .= "<p style=\"page-break-after:always;\">\r\n"; // page break
$this->Text .= "<table class=\"ewTablePdf ewTablePdfBorder\">\r\n"; // new page header
$this->Text .= $this->Header;
}
}
// Export a field
function ExportField(&$fld) {
$ExportValue = $fld->ExportValue();
if ($fld->FldViewTag == "IMAGE") {
$imagefn = $fld->GetTempImage();
if ($imagefn <> "")
$ExportValue = "<img src=\"" . $imagefn . "\" alt=\"\" style=\"border: 0;\">";
} else {
$ExportValue = str_replace("<br>", "\r\n", $ExportValue);
$ExportValue = strip_tags($ExportValue);
$ExportValue = str_replace("\r\n", "<br>", $ExportValue);
}
if ($this->Horizontal) {
$this->ExportValueEx($fld, $ExportValue);
} else { // Vertical, export as a row
$this->FldCnt++;
$fld->CellCssClass = ($this->FldCnt % 2 == 1) ? "ewTableRow" : "ewTableAltRow";
$this->Text .= "<tr><td class=\"ewTablePdfHeader\">" . $fld->ExportCaption() . "</td>";
$this->Text .= "<td" . ((EW_EXPORT_CSS_STYLES) ? $fld->CellStyles() : "") . ">" .
$ExportValue . "</td></tr>";
}
}
// Add HTML tags
function ExportHeaderAndFooter() {
$header = "<html><head>\r\n";
$header .= $this->CharsetMetaTag();
if (EW_EXPORT_CSS_STYLES && EW_PDF_STYLESHEET_FILENAME <> "")
$header .= "<style type=\"text/css\">" . file_get_contents(EW_PDF_STYLESHEET_FILENAME) . "</style>\r\n";
$header .= "</" . "head>\r\n<body>\r\n";
$this->Text = $header . $this->Text . "</body></html>";
}
// Export
function Export() {
global $gsExportFile;
include_once "includes/dompdf060b3/dompdf_config.inc.php";
@ini_set("memory_limit", EW_PDF_MEMORY_LIMIT);
set_time_limit(EW_PDF_TIME_LIMIT);
$dompdf = new DOMPDF();
$dompdf->load_html($this->Text);
$dompdf->set_paper($this->Table->ExportPageSize, $this->Table->ExportPageOrientation);
$dompdf->render();
ob_end_clean();
$dompdf->stream($gsExportFile . ".pdf", array("Attachment" => 1)); // 0 to open in browser, 1 to download
}
// Destructor
function __destruct() {
ew_DeleteTmpImages();
}
}
/**
* Email class
*/
class cEmail {
// Class properties
var $Sender = ""; // Sender
var $Recipient = ""; // Recipient
var $Cc = ""; // Cc
var $Bcc = ""; // Bcc
var $Subject = ""; // Subject
var $Format = ""; // Format
var $Content = ""; // Content
var $AttachmentContent = ""; // Attachement content
var $AttachmentFileName = ""; // Attachment file name
var $EmbeddedImages = array(); // Embedded image
var $Charset = ""; // Charset
var $SendErrDescription; // Send error description
var $SmtpSecure = EW_SMTP_SECURE_OPTION; // Send secure option
// Method to load email from template
function Load($fn) {
$fn = ew_ScriptFolder() . EW_PATH_DELIMITER . $fn;
$sWrk = file_get_contents($fn); // Load text file content
if (substr($sWrk, 0, 3) == "\xEF\xBB\xBF") // utf-8 BOM
$sWrk = substr($sWrk, 3);
if ($sWrk <> "") {
// Locate Header & Mail Content
if (EW_IS_WINDOWS) {
$i = strpos($sWrk, "\r\n\r\n");
} else {
$i = strpos($sWrk, "\n\n");
if ($i === FALSE) $i = strpos($sWrk, "\r\n\r\n");
}
if ($i > 0) {
$sHeader = substr($sWrk, 0, $i);
$this->Content = trim(substr($sWrk, $i, strlen($sWrk)));
if (EW_IS_WINDOWS) {
$arrHeader = explode("\r\n", $sHeader);
} else {
$arrHeader = explode("\n", $sHeader);
}
$cnt = count($arrHeader);
for ($j = 0; $j < $cnt; $j++) {
$i = strpos($arrHeader[$j], ":");
if ($i > 0) {
$sName = trim(substr($arrHeader[$j], 0, $i));
$sValue = trim(substr($arrHeader[$j], $i+1, strlen($arrHeader[$j])));
switch (strtolower($sName))
{
case "subject":
$this->Subject = $sValue;
break;
case "from":
$this->Sender = $sValue;
break;
case "to":
$this->Recipient = $sValue;
break;
case "cc":
$this->Cc = $sValue;
break;
case "bcc":
$this->Bcc = $sValue;
break;
case "format":
$this->Format = $sValue;
break;
}
}
}
}
}
}
// Method to replace sender
function ReplaceSender($ASender) {
$this->Sender = str_replace('<!--$From-->', $ASender, $this->Sender);
}
// Method to replace recipient
function ReplaceRecipient($ARecipient) {
$this->Recipient = str_replace('<!--$To-->', $ARecipient, $this->Recipient);
}
// Method to add Cc email
function AddCc($ACc) {
if ($ACc <> "") {
if ($this->Cc <> "") $this->Cc .= ";";
$this->Cc .= $ACc;
}
}
// Method to add Bcc email
function AddBcc($ABcc) {
if ($ABcc <> "") {
if ($this->Bcc <> "") $this->Bcc .= ";";
$this->Bcc .= $ABcc;
}
}
// Method to replace subject
function ReplaceSubject($ASubject) {
$this->Subject = str_replace('<!--$Subject-->', $ASubject, $this->Subject);
}
// Method to replace content
function ReplaceContent($Find, $ReplaceWith) {
$this->Content = str_replace($Find, $ReplaceWith, $this->Content);
}
// Method to add embedded image
function AddEmbeddedImage($image) {
if ($image <> "")
$this->EmbeddedImages[] = $image;
}
// Method to send email
function Send() {
global $gsEmailErrDesc;
$result = ew_SendEmail($this->Sender, $this->Recipient, $this->Cc, $this->Bcc,
$this->Subject, $this->Content, $this->Format, $this->Charset, $this->SmtpSecure,
$this->AttachmentFileName, $this->AttachmentContent, $this->EmbeddedImages);
$this->SendErrDescription = $gsEmailErrDesc;
return $result;
}
}
/**
* Pager item class
*/
class cPagerItem {
var $Start;
var $Text;
var $Enabled;
}
/**
* Numeric pager class
*/
class cNumericPager {
var $Items = array();
var $Count, $FromIndex, $ToIndex, $RecordCount, $PageSize, $Range;
var $FirstButton, $PrevButton, $NextButton, $LastButton;
var $ButtonCount = 0;
var $Visible = TRUE;
function __construct($StartRec, $DisplayRecs, $TotalRecs, $RecRange)
{
$this->FirstButton = new cPagerItem;
$this->PrevButton = new cPagerItem;
$this->NextButton = new cPagerItem;
$this->LastButton = new cPagerItem;
$this->FromIndex = intval($StartRec);
$this->PageSize = intval($DisplayRecs);
$this->RecordCount = intval($TotalRecs);
$this->Range = intval($RecRange);
if ($this->PageSize == 0) return;
if ($this->FromIndex > $this->RecordCount)
$this->FromIndex = $this->RecordCount;
$this->ToIndex = $this->FromIndex + $this->PageSize - 1;
if ($this->ToIndex > $this->RecordCount)
$this->ToIndex = $this->RecordCount;
// setup
$this->SetupNumericPager();
// update button count
if ($this->FirstButton->Enabled) $this->ButtonCount++;
if ($this->PrevButton->Enabled) $this->ButtonCount++;
if ($this->NextButton->Enabled) $this->ButtonCount++;
if ($this->LastButton->Enabled) $this->ButtonCount++;
$this->ButtonCount += count($this->Items);
}
// Add pager item
function AddPagerItem($StartIndex, $Text, $Enabled)
{
$Item = new cPagerItem;
$Item->Start = $StartIndex;
$Item->Text = $Text;
$Item->Enabled = $Enabled;
$this->Items[] = $Item;
}
// Setup pager items
function SetupNumericPager()
{
if ($this->RecordCount > $this->PageSize) {
$Eof = ($this->RecordCount < ($this->FromIndex + $this->PageSize));
$HasPrev = ($this->FromIndex > 1);
// First Button
$TempIndex = 1;
$this->FirstButton->Start = $TempIndex;
$this->FirstButton->Enabled = ($this->FromIndex > $TempIndex);
// Prev Button
$TempIndex = $this->FromIndex - $this->PageSize;
if ($TempIndex < 1) $TempIndex = 1;
$this->PrevButton->Start = $TempIndex;
$this->PrevButton->Enabled = $HasPrev;
// Page links
if ($HasPrev || !$Eof) {
$x = 1;
$y = 1;
$dx1 = intval(($this->FromIndex-1)/($this->PageSize*$this->Range))*$this->PageSize*$this->Range + 1;
$dy1 = intval(($this->FromIndex-1)/($this->PageSize*$this->Range))*$this->Range + 1;
if (($dx1+$this->PageSize*$this->Range-1) > $this->RecordCount) {
$dx2 = intval($this->RecordCount/$this->PageSize)*$this->PageSize + 1;
$dy2 = intval($this->RecordCount/$this->PageSize) + 1;
} else {
$dx2 = $dx1 + $this->PageSize*$this->Range - 1;
$dy2 = $dy1 + $this->Range - 1;
}
while ($x <= $this->RecordCount) {
if ($x >= $dx1 && $x <= $dx2) {
$this->AddPagerItem($x, $y, $this->FromIndex<>$x);
$x += $this->PageSize;
$y++;
} elseif ($x >= ($dx1-$this->PageSize*$this->Range) && $x <= ($dx2+$this->PageSize*$this->Range)) {
if ($x+$this->Range*$this->PageSize < $this->RecordCount) {
$this->AddPagerItem($x, $y . "-" . ($y+$this->Range-1), TRUE);
} else {
$ny = intval(($this->RecordCount-1)/$this->PageSize) + 1;
if ($ny == $y) {
$this->AddPagerItem($x, $y, TRUE);
} else {
$this->AddPagerItem($x, $y . "-" . $ny, TRUE);
}
}
$x += $this->Range*$this->PageSize;
$y += $this->Range;
} else {
$x += $this->Range*$this->PageSize;
$y += $this->Range;
}
}
}
// Next Button
$TempIndex = $this->FromIndex + $this->PageSize;
$this->NextButton->Start = $TempIndex;
$this->NextButton->Enabled = !$Eof;
// Last Button
$TempIndex = intval(($this->RecordCount-1)/$this->PageSize)*$this->PageSize + 1;
$this->LastButton->Start = $TempIndex;
$this->LastButton->Enabled = ($this->FromIndex < $TempIndex);
}
}
}
/**
* PrevNext pager class
*/
class cPrevNextPager {
var $FirstButton, $PrevButton, $NextButton, $LastButton;
var $CurrentPage, $PageCount, $FromIndex, $ToIndex, $RecordCount;
var $Visible = TRUE;
function __construct($StartRec, $DisplayRecs, $TotalRecs)
{
$this->FirstButton = new cPagerItem;
$this->PrevButton = new cPagerItem;
$this->NextButton = new cPagerItem;
$this->LastButton = new cPagerItem;
$this->FromIndex = intval($StartRec);
$this->PageSize = intval($DisplayRecs);
$this->RecordCount = intval($TotalRecs);
if ($this->PageSize == 0) return;
$this->CurrentPage = intval(($this->FromIndex-1)/$this->PageSize) + 1;
$this->PageCount = intval(($this->RecordCount-1)/$this->PageSize) + 1;
if ($this->FromIndex > $this->RecordCount)
$this->FromIndex = $this->RecordCount;
$this->ToIndex = $this->FromIndex + $this->PageSize - 1;
if ($this->ToIndex > $this->RecordCount)
$this->ToIndex = $this->RecordCount;
// First Button
$TempIndex = 1;
$this->FirstButton->Start = $TempIndex;
$this->FirstButton->Enabled = ($TempIndex <> $this->FromIndex);
// Prev Button
$TempIndex = $this->FromIndex - $this->PageSize;
if ($TempIndex < 1) $TempIndex = 1;
$this->PrevButton->Start = $TempIndex;
$this->PrevButton->Enabled = ($TempIndex <> $this->FromIndex);
// Next Button
$TempIndex = $this->FromIndex + $this->PageSize;
if ($TempIndex > $this->RecordCount)
$TempIndex = $this->FromIndex;
$this->NextButton->Start = $TempIndex;
$this->NextButton->Enabled = ($TempIndex <> $this->FromIndex);
// Last Button
$TempIndex = intval(($this->RecordCount-1)/$this->PageSize)*$this->PageSize + 1;
$this->LastButton->Start = $TempIndex;
$this->LastButton->Enabled = ($TempIndex <> $this->FromIndex);
}
}
/**
* Table classes
*/
// Common class for table and report
class cTableBase {
var $TableVar;
var $TableName;
var $TableType;
var $Visible = TRUE;
var $fields = array();
var $UseTokenInUrl = EW_USE_TOKEN_IN_URL;
var $Export; // Export
var $ExportAll;
var $ExportPageBreakCount; // Page break per every n record (PDF only)
var $ExportPageOrientation; // Page orientation (PDF only)
var $ExportPageSize; // Page size (PDF only)
var $SendEmail; // Send email
var $TableCustomInnerHtml; // Custom inner HTML
var $BasicSearch; // Basic search
var $CurrentFilter; // Current filter
var $CurrentOrder; // Current order
var $CurrentOrderType; // Current order type
var $RowType; // Row type
var $CssClass; // CSS class
var $CssStyle; // CSS style
var $RowAttrs = array(); // Row custom attributes
var $CurrentAction; // Current action
var $LastAction; // Last action
var $UserIDAllowSecurity = 0; // User ID Allow
// Reset attributes for table object
function ResetAttrs() {
$this->CssClass = "";
$this->CssStyle = "";
$this->RowAttrs = array();
foreach ($this->fields as $fld) {
$fld->ResetAttrs();
}
}
// Setup field titles
function SetupFieldTitles() {
foreach ($this->fields as &$fld) {
if (strval($fld->FldTitle()) <> "") {
$fld->EditAttrs["onmouseover"] = "ew_ShowTitle(this, '" . ew_JsEncode3($fld->FldTitle()) . "');";
$fld->EditAttrs["onmouseout"] = "ew_HideTooltip();";
}
}
}
var $TableFilter = "";
// Get field values
function GetFieldValues($propertyname) {
$values = array();
foreach ($this->fields as $fldname => $fld)
$values[$fldname] = &$fld->$propertyname;
return $values;
}
var $TableCaption = "";
// Set table caption
function setTableCaption($v) {
$this->TableCaption = $v;
}
// Table caption
function TableCaption() {
global $Language;
if ($this->TableCaption <> "")
return $this->TableCaption;
else
return $Language->TablePhrase($this->TableVar, "TblCaption");
}
var $PgCaption = array();
// Set page caption
function setPageCaption($Page, $v) {
$this->PgCaption[$Page] = $v;
}
// Page caption
function PageCaption($Page) {
global $Language;
$Caption = @$this->PgCaption[$Page];
if ($Caption <> "") {
return $Caption;
} else {
$Caption = $Language->TablePhrase($this->TableVar, "TblPageCaption" . $Page);
if ($Caption == "") $Caption = "Page " . $Page;
return $Caption;
}
}
// Add URL parameter
function UrlParm($parm = "") {
$UrlParm = ($this->UseTokenInUrl) ? "t=" . $this->TablVar : "";
if ($parm <> "") {
if ($UrlParm <> "")
$UrlParm .= "&";
$UrlParm .= $parm;
}
return $UrlParm;
}
// Row styles
function RowStyles() {
$sAtt = "";
$sStyle = trim($this->CssStyle);