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