Changeset 871 for trunk/Common/Form/Types
- Timestamp:
- Apr 6, 2020, 9:19:50 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Form/Types/DateTime.php
r738 r871 11 11 global $MonthNames; 12 12 13 if ($Item['Value'] == 0) return('');14 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();13 if ($Item['Value'] == 0) return ''; 14 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time(); 15 15 $Parts = getdate($Item['Value']); 16 16 $Output = $Parts['mday'].'.'.$Parts['mon'].'.'.$Parts['year'].' '. 17 17 sprintf('%02d', $Parts['hours']).':'.sprintf('%02d', $Parts['minutes']).':'.sprintf('%02d', $Parts['seconds']); 18 return ($Output);18 return $Output; 19 19 } 20 20 … … 23 23 global $MonthNames; 24 24 25 if(($Item['Value'] !== null) and ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == ''))) $Item['Value'] = time(); 25 if (($Item['Value'] == null) or (($Item['Value'] !== null) and ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')))) 26 { 27 $Item['Value'] = time(); 28 $IsNull = true; 29 } else $IsNull = false; 26 30 $Parts = getdate($Item['Value']); 27 31 28 32 $Output = ''; 29 33 $Style = ''; 30 if (array_key_exists('Null', $Item) and $Item['Null'])34 if (array_key_exists('Null', $Item) and $Item['Null']) 31 35 { 32 if ($Item['Value'] != null)36 if (!$IsNull) 33 37 { 34 38 $Checked = ' checked="1"'; … … 46 50 // Hour 47 51 $Output .= '<select name="'.$Item['Name'].'-hour" id="'.$Item['Name'].'-hour" '.$Style.'>'; 48 for ($I = 1; $I <= 24; $I++)52 for ($I = 1; $I <= 24; $I++) 49 53 { 50 if ($Parts['hours'] == $I) $Selected = ' selected="1"'; else $Selected = '';54 if ($Parts['hours'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 51 55 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 52 56 } … … 54 58 // Minute 55 59 $Output .= '<select name="'.$Item['Name'].'-minute" id="'.$Item['Name'].'-minute" '.$Style.'>'; 56 for ($I = 1; $I <= 60; $I++)60 for ($I = 1; $I <= 60; $I++) 57 61 { 58 if ($Parts['minutes'] == $I) $Selected = ' selected="1"'; else $Selected = '';62 if ($Parts['minutes'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 59 63 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 60 64 } … … 62 66 // Second 63 67 $Output .= '<select name="'.$Item['Name'].'-second" id="'.$Item['Name'].'-second" '.$Style.'>'; 64 for ($I = 1; $I <= 60; $I++)68 for ($I = 1; $I <= 60; $I++) 65 69 { 66 if ($Parts['seconds'] == $I) $Selected = ' selected="1"'; else $Selected = '';70 if ($Parts['seconds'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 67 71 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 68 72 } … … 70 74 // Day 71 75 $Output .= ' <select name="'.$Item['Name'].'-day" id="'.$Item['Name'].'-day" '.$Style.'>'; 72 for ($I = 1; $I <= 31; $I++)76 for ($I = 1; $I <= 31; $I++) 73 77 { 74 if ($Parts['mday'] == $I) $Selected = ' selected="1"'; else $Selected = '';78 if ($Parts['mday'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 75 79 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 76 80 } … … 78 82 // Month 79 83 $Output .= '<select name="'.$Item['Name'].'-month" id="'.$Item['Name'].'-month" '.$Style.'>'; 80 for ($I = 1; $I <= 12; $I++)84 for ($I = 1; $I <= 12; $I++) 81 85 { 82 if ($Parts['mon'] == $I) $Selected = ' selected="1"'; else $Selected = '';86 if ($Parts['mon'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 83 87 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>'; 84 88 } … … 86 90 // Year 87 91 $Output .= '<select name="'.$Item['Name'].'-year" id="'.$Item['Name'].'-year" '.$Style.'>'; 88 for ($I = 1900; $I < 2100; $I++)92 for ($I = 1900; $I < 2100; $I++) 89 93 { 90 if ($Parts['year'] == $I) $Selected = ' selected="1"'; else $Selected = '';94 if ($Parts['year'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 91 95 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 92 96 } 93 97 $Output .= '</select>'; 94 return ($Output);98 return $Output; 95 99 } 96 100 97 101 function OnLoad($Item) 98 102 { 99 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return(null);100 else return (mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second'],101 $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year']) );103 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return null; 104 else return mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second'], 105 $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year']); 102 106 } 103 107 104 108 function OnLoadDb($Item) 105 109 { 106 return (MysqlDateTimeToTime($Item['Value']));110 return MysqlDateTimeToTime($Item['Value']); 107 111 } 108 112 109 113 function OnSaveDb($Item) 110 114 { 111 if ($Item['Value'] == null) return(null);112 else return (date('Y-m-d H:i:s', $Item['Value']));115 if ($Item['Value'] == null) return null; 116 else return date('Y-m-d H:i:s', $Item['Value']); 113 117 } 114 118 115 119 function DatabaseEscape($Value) 116 120 { 117 return ('"'.addslashes($Value).'"');121 return '"'.addslashes($Value).'"'; 118 122 } 119 123 }
Note:
See TracChangeset
for help on using the changeset viewer.