Changeset 17760 for extensions/EStat/lib/statDB.class.inc.php
- Timestamp:
- Sep 5, 2012, 5:15:35 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/EStat/lib/statDB.class.inc.php
r17758 r17760 865 865 866 866 867 868 /** 869 * to be used with Date filter: replace the given operator with 'between' or 'not between' 870 * 871 * @param Array $value 872 * @return Array 873 */ 874 protected function checkDateFilter($value) 875 { 876 if(is_array($value)) 877 { 878 if(isset($value['operator'])) 879 { 880 if($value['operator']=='=' or 881 $value['operator']=='like') 882 { 883 $value['operator']='between'; 884 $value['minValue']=$value['value']; 885 $value['maxValue']=$value['value']; 886 $value['value']=null; 887 } 888 elseif($value['operator']=='!=' or 889 $value['operator']=='not like') 890 { 891 $value['operator']='not between'; 892 $value['minValue']=$value['value']; 893 $value['maxValue']=$value['value']; 894 $value['value']=null; 895 } 896 } 897 } 898 return($value); 899 } // checkDateFilter 900 901 902 903 867 904 /** 868 905 * check if value is a valid operator array … … 902 939 { 903 940 case 'date': 904 $value['value']=$this->checkValueDate($value['value']); 941 switch($value['operator']) 942 { 943 case '>': 944 case '<=': 945 $value['value']=$this->checkValueDate($value['value'], 'E'); 946 break; 947 case '<': 948 case '>=': 949 default: 950 $value['value']=$this->checkValueDate($value['value'], 'B'); 951 break; 952 } 905 953 if($value['value']==null) return(null); 906 954 $value['value']=$value['value']; … … 958 1006 { 959 1007 case 'date': 960 $value['minValue']=$this->checkValueDate($value['minValue'] );1008 $value['minValue']=$this->checkValueDate($value['minValue'], 'B'); 961 1009 if($value['minValue']==null) return(null); 962 $value['maxValue']=$this->checkValueDate($value['maxValue'] );1010 $value['maxValue']=$this->checkValueDate($value['maxValue'], 'E'); 963 1011 if($value['maxValue']==null) return(null); 964 1012 break; … … 993 1041 /** 994 1042 * check if date is Ok 995 * return the date completed (YYYY-MM-DD => YYYY-MM-DD 00:00:00) or null if not valid 1043 * return the date completed 1044 * (YYYY-MM-DD => YYYY-MM-DD 00:00:00) if $mode='B' 1045 * or (YYYY-MM-DD => YYYY-MM-DD 23:59:59) if $mode='E' 1046 * or null if not valid 996 1047 * 997 1048 * @param String $value 1049 * @param String $mode: 'B' for begin or 'E' for end 998 1050 * @return String 999 1051 */ 1000 protected function checkValueDate($value )1052 protected function checkValueDate($value, $mode='B') 1001 1053 { 1002 1054 $returned=null; 1003 1055 $result=array(); 1004 if(preg_match('/^(\d{4}-\d{2}-\d{2})(?:(\s{1}\d{2}:\d{2})(:\d{2})?)?$/', $value, $result)>0)1056 if(preg_match('/^(\d{4}-\d{2}-\d{2})(?:(\s{1}\d{2}:\d{2})(:\d{2})?)?$/', trim($value), $result)>0) 1005 1057 { 1006 1058 $returned=$result[1]; … … 1012 1064 $returned.=$result[3]; 1013 1065 } 1014 else $returned.=':00'; 1015 } 1016 else $returned.=' 00:00:00'; 1066 else 1067 { 1068 $returned.=($mode=='B')?':00':':59'; 1069 } 1070 } 1071 else 1072 { 1073 $returned.=($mode=='B')?' 00:00:00':' 23:59:59'; 1074 } 1017 1075 } 1018 1076 return(strtotime($returned));
Note: See TracChangeset
for help on using the changeset viewer.