Changeset 570 for trunk/Common/Form/Types
- Timestamp:
- Sep 26, 2013, 11:16:23 PM (11 years ago)
- Location:
- trunk/Common/Form/Types
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Form/Types/Date.php
r548 r570 11 11 global $MonthNames; 12 12 13 if($Item['Value'] == 0) return('');13 if($Item['Value'] == null) return(''); 14 14 if((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time(); 15 15 $Parts = getdate($Item['Value']); 16 16 17 $Output = $Parts['mday'].'. '.$ MonthNames[$Parts['mon']].' '.$Parts['year'];17 $Output = $Parts['mday'].'. '.$Parts['mon'].' '.$Parts['year']; 18 18 return($Output); 19 19 } … … 27 27 28 28 $Output = ''; 29 //if($Item['Value'] == '') $Checked = ' checked="1"'; else $Checked = ''; 30 //$Output .= '<input type="checkbox" name="'.$Item['Name'].'-null"'.$Checked.'/>'; 31 29 $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']]; 30 $Style = ''; 31 if(array_key_exists('Null', $Item) and $Item['Null']) 32 { 33 if($Item['Value'] != null) 34 { 35 $Checked = ' checked="1"'; 36 $Style = 'style="display:inline;"'; 37 } else 38 { 39 $Checked = ''; 40 $Style = 'style="display:none;"'; 41 } 42 $Output .= '<input type="checkbox" name="'.$Item['Name'].'-null"'.$Checked.' onclick="toggle(\''. 43 $Item['Name'].'-day\');toggle(\''.$Item['Name'].'-month\');toggle(\''.$Item['Name'].'-year\');"/>'; 44 } 45 32 46 // Day 33 $Output .= '<select name="'.$Item['Name'].'-day" >';47 $Output .= '<select name="'.$Item['Name'].'-day" id="'.$Item['Name'].'-day" '.$Style.'>'; 34 48 for($I = 1; $I <= 31; $I++) 35 49 { … … 39 53 $Output .= '</select>'; 40 54 // Month 41 $Output .= '<select name="'.$Item['Name'].'-month" >';55 $Output .= '<select name="'.$Item['Name'].'-month" id="'.$Item['Name'].'-month" '.$Style.'>'; 42 56 for($I = 1; $I <= 12; $I++) 43 57 { … … 47 61 $Output .= '</select>'; 48 62 // Year 49 $Output .= '<select name="'.$Item['Name'].'-year" >';63 $Output .= '<select name="'.$Item['Name'].'-year" id="'.$Item['Name'].'-year" '.$Style.'>'; 50 64 for($I = 1900; $I < 2100; $I++) 51 65 { … … 59 73 function OnLoad($Item) 60 74 { 61 return(mktime(0, 0, 0, $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year'])); 75 if(!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return(null); 76 else return(mktime(0, 0, 0, $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year'])); 62 77 } 63 78 … … 67 82 } 68 83 69 function OnSaveDb($Item) 84 function OnSaveDb($Item) 70 85 { 71 return(date('Y-m-d', $Item['Value'])); 86 if($Item['Value'] == null) return(null); 87 else return(date('Y-m-d', $Item['Value'])); 72 88 } 73 89 -
trunk/Common/Form/Types/DateTime.php
r548 r570 25 25 if((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time(); 26 26 $Parts = getdate($Item['Value']); 27 27 28 $Output = ''; 29 $Style = ''; 30 if(array_key_exists('Null', $Item) and $Item['Null']) 31 { 32 if($Item['Value'] != null) 33 { 34 $Checked = ' checked="1"'; 35 $Style = 'style="display:inline;"'; 36 } else 37 { 38 $Checked = ''; 39 $Style = 'style="display:none;"'; 40 } 41 $Output .= '<input type="checkbox" name="'.$Item['Name'].'-null"'.$Checked.' onclick="toggle(\''. 42 $Item['Name'].'-hour\');toggle(\''.$Item['Name'].'-minute\');toggle(\''.$Item['Name'].'-second\');toggle(\''. 43 $Item['Name'].'-day\');toggle(\''.$Item['Name'].'-month\');toggle(\''.$Item['Name'].'-year\');"/>'; 44 } 45 28 46 // Hour 29 $Output = '<select name="'.$Item['Name'].'-hour">';47 $Output .= '<select name="'.$Item['Name'].'-hour" id="'.$Item['Name'].'-hour" '.$Style.'>'; 30 48 for($I = 1; $I <= 24; $I++) 31 49 { … … 35 53 $Output .= '</select>'; 36 54 // Minute 37 $Output .= '<select name="'.$Item['Name'].'-minute" >';55 $Output .= '<select name="'.$Item['Name'].'-minute" id="'.$Item['Name'].'-minute" '.$Style.'>'; 38 56 for($I = 1; $I <= 60; $I++) 39 57 { … … 43 61 $Output .= '</select>'; 44 62 // Second 45 $Output .= '<select name="'.$Item['Name'].'-second" >';63 $Output .= '<select name="'.$Item['Name'].'-second" id="'.$Item['Name'].'-second" '.$Style.'>'; 46 64 for($I = 1; $I <= 60; $I++) 47 65 { … … 51 69 $Output .= '</select>'; 52 70 // Day 53 $Output .= ' <select name="'.$Item['Name'].'-day" >';71 $Output .= ' <select name="'.$Item['Name'].'-day" id="'.$Item['Name'].'-day" '.$Style.'>'; 54 72 for($I = 1; $I <= 31; $I++) 55 73 { … … 59 77 $Output .= '</select>'; 60 78 // Month 61 $Output .= '<select name="'.$Item['Name'].'-month" >';79 $Output .= '<select name="'.$Item['Name'].'-month" id="'.$Item['Name'].'-month" '.$Style.'>'; 62 80 for($I = 1; $I <= 12; $I++) 63 81 { … … 67 85 $Output .= '</select>'; 68 86 // Year 69 $Output .= '<select name="'.$Item['Name'].'-year" >';87 $Output .= '<select name="'.$Item['Name'].'-year" id="'.$Item['Name'].'-year" '.$Style.'>'; 70 88 for($I = 1900; $I < 2100; $I++) 71 89 { … … 79 97 function OnLoad($Item) 80 98 { 81 return(mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second'], 82 $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year'])); 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'])); 83 102 } 84 103 … … 89 108 90 109 function OnSaveDb($Item) 91 { 92 return(date('Y-m-d H:i:s', $Item['Value'])); 110 { 111 if($Item['Value'] == null) return(null); 112 else return(date('Y-m-d H:i:s', $Item['Value'])); 93 113 } 94 114 -
trunk/Common/Form/Types/Time.php
r548 r570 22 22 $TimeParts = getdate($Item['Value']); 23 23 24 $Output = ''; 25 $Style = ''; 26 if(array_key_exists('Null', $Item) and $Item['Null']) 27 { 28 if($Item['Value'] != null) 29 { 30 $Checked = ' checked="1"'; 31 $Style = 'style="display:inline;"'; 32 } else 33 { 34 $Checked = ''; 35 $Style = 'style="display:none;"'; 36 } 37 $Output .= '<input type="checkbox" name="'.$Item['Name'].'-null"'.$Checked.' onclick="toggle(\''. 38 $Item['Name'].'-hour\');toggle(\''.$Item['Name'].'-minute\');toggle(\''.$Item['Name'].'-second\');"/>'; 39 } 40 24 41 // Hour 25 $Output = '<select name="'.$Item['Name'].'-hour">';42 $Output .= '<select name="'.$Item['Name'].'-hour" id="'.$Item['Name'].'-hour" '.$Style.'>'; 26 43 for($I = 1; $I <= 24; $I++) 27 44 { … … 31 48 $Output .= '</select>'; 32 49 // Minute 33 $Output .= '<select name="'.$Item['Name'].'-minute" >';50 $Output .= '<select name="'.$Item['Name'].'-minute" id="'.$Item['Name'].'-minute" '.$Style.'>'; 34 51 for($I = 1; $I <= 60; $I++) 35 52 { … … 39 56 $Output .= '</select>'; 40 57 // Second 41 $Output .= '<select name="'.$Item['Name'].'-second" >';58 $Output .= '<select name="'.$Item['Name'].'-second" id="'.$Item['Name'].'-second" '.$Style.'>'; 42 59 for($I = 1; $I <= 60; $I++) 43 60 { … … 51 68 function OnLoad($Item) 52 69 { 53 return(mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second'])); 70 if(!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return(null); 71 return(mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second'])); 54 72 } 55 73 … … 61 79 function OnSaveDb($Item) 62 80 { 63 return(date('H:i:s', $Item['Value'])); 81 if($Item['Value'] == null) return(null); 82 else return(date('H:i:s', $Item['Value'])); 64 83 } 65 84
Note:
See TracChangeset
for help on using the changeset viewer.