1 | <?php
|
---|
2 |
|
---|
3 | class TypeDateTime extends TypeBase
|
---|
4 | {
|
---|
5 | var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
|
---|
6 |
|
---|
7 | function OnView($Item)
|
---|
8 | {
|
---|
9 | global $MonthNames;
|
---|
10 |
|
---|
11 | $ValueParts = explode(' ', $Item['Value']);
|
---|
12 | $DateParts = explode('-', $ValueParts[0]);
|
---|
13 | $TimeParts = explode(':', $ValueParts[1]);
|
---|
14 |
|
---|
15 | $Output = $TimeParts[0].':'.$TimeParts[1].':'.$TimeParts[2].' '.($DateParts[2] * 1).'. '.$MonthNames[$DateParts[1] * 1].' '.$DateParts[0];
|
---|
16 | return($Output);
|
---|
17 | }
|
---|
18 |
|
---|
19 | function OnEdit($Item)
|
---|
20 | {
|
---|
21 | global $MonthNames;
|
---|
22 |
|
---|
23 | $ValueParts = explode(' ', $Item['Value']);
|
---|
24 | $DateParts = explode('-', $ValueParts[0]);
|
---|
25 | $TimeParts = explode(':', $ValueParts[1]);
|
---|
26 |
|
---|
27 | // Hour
|
---|
28 | $Output = '<select name="'.$Item['Name'].'-hour">';
|
---|
29 | for($I = 1; $I <= 24; $I++)
|
---|
30 | {
|
---|
31 | if($TimeParts[2] == $I) $Selected = ' selected="1"'; else $Selected = '';
|
---|
32 | $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
|
---|
33 | }
|
---|
34 | $Output .= '</select>';
|
---|
35 | // Minute
|
---|
36 | $Output .= '<select name="'.$Item['Name'].'-minute">';
|
---|
37 | for($I = 1; $I <= 60; $I++)
|
---|
38 | {
|
---|
39 | if($TimeParts[1] == $I) $Selected = ' selected="1"'; else $Selected = '';
|
---|
40 | $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
|
---|
41 | }
|
---|
42 | $Output .= '</select>';
|
---|
43 | // Second
|
---|
44 | $Output .= '<select name="'.$Item['Name'].'-second">';
|
---|
45 | for($I = 1; $I <= 60; $I++)
|
---|
46 | {
|
---|
47 | if($TimeParts[0] == $I) $Selected = ' selected="1"'; else $Selected = '';
|
---|
48 | $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
|
---|
49 | }
|
---|
50 | $Output .= '</select>';
|
---|
51 | // Day
|
---|
52 | $Output .= ' <select name="'.$Item['Name'].'-day">';
|
---|
53 | for($I = 1; $I <= 31; $I++)
|
---|
54 | {
|
---|
55 | if($DateParts[2] == $I) $Selected = ' selected="1"'; else $Selected = '';
|
---|
56 | $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
|
---|
57 | }
|
---|
58 | $Output .= '</select>';
|
---|
59 | // Month
|
---|
60 | $Output .= '<select name="'.$Item['Name'].'-month">';
|
---|
61 | for($I = 1; $I <= 12; $I++)
|
---|
62 | {
|
---|
63 | if($DateParts[1] == $I) $Selected = ' selected="1"'; else $Selected = '';
|
---|
64 | $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>';
|
---|
65 | }
|
---|
66 | $Output .= '</select>';
|
---|
67 | // Year
|
---|
68 | $Output .= '<select name="'.$Item['Name'].'-year">';
|
---|
69 | for($I = 1900; $I < 2100; $I++)
|
---|
70 | {
|
---|
71 | if($DateParts[0] == $I) $Selected = ' selected="1"'; else $Selected = '';
|
---|
72 | $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
|
---|
73 | }
|
---|
74 | $Output .= '</select>';
|
---|
75 | return($Output);
|
---|
76 | }
|
---|
77 |
|
---|
78 | function OnLoad($Item)
|
---|
79 | {
|
---|
80 | return($_POST[$Item['Name'].'-year'].'-'.$_POST[$Item['Name'].'-month'].'-'.$_POST[$Item['Name'].'-day'].' '.
|
---|
81 | $_POST[$Item['Name'].'-hour'].':'.$_POST[$Item['Name'].'-minute'].':'.$_POST[$Item['Name'].'-second']);
|
---|
82 | }
|
---|
83 |
|
---|
84 | function DatabaseEscape($Value)
|
---|
85 | {
|
---|
86 | return('"'.addslashes($Value).'"');
|
---|
87 | }
|
---|
88 | }
|
---|
89 |
|
---|
90 | ?>
|
---|