0 date1 > date2 * - < 0 date1 < date2 */ function cmpDate ($p_date,$p_date_oth) { $l_date=isDate($p_date); $l2_date=isDate($p_date_oth); if ($l_date == null || $l2_date == null ) { echo "erreur date"; return null; } $l_adate=explode(".",$l_date); $l2_adate=explode(".",$l2_date); $l_mkdate=mktime(0,0,0,$l_adate[1],$l_adate[0],$l_adate[2]); $l2_mkdate=mktime(0,0,0,$l2_adate[1],$l2_adate[0],$l2_adate[2]); // si $p_date > $p_date_oth return > 0 return $l_mkdate-$l2_mkdate; } /* function isDate * Purpose : Verifie qu'une date est bien formaté * en d.m.y et est valable * parm : * - $p_date * gen : * - rien * return: * - null si la date est invalide ou malformaté * - $p_date si tout est bon * */ function isDate ( $p_date) { if ( strlen (trim($p_date)) == 0 ) return null; if (! ereg ("^[0-9]{1,2}\.[0-9]{1,2}\.20[0-9]{2}",$p_date) ) { return null; } else { $l_date=explode(".",$p_date); if ( $l_date[2] > 2020 ) { return null; } if ( checkdate ($l_date[1],$l_date[0],$l_date[2]) == false) { return null; } }// !ereg return $p_date; } function formatDate($p_date) { if ( isDate($p_date)== null) return "null"; return "'".$p_date."'"; } function html_page_start($p_first=0,$p_script="") { /*global $user,$pass; if ($p_first == 1 ) { echo_debug("Start session explicit"); session_start(); } session_register("user"); session_register("pass"); echo_debug("user = ".$user." pass=".$pass); */ echo ''; echo ""; echo " Gnu Accountancy "; echo ""; } function html_page_stop() { echo ""; echo ""; } function html_button_logout() { echo " Logout "; } function NoAccess() { echo "





"; echo "

You haven't access

"; exit -1; } function FormatString($p_string) { if ( !isset ($p_string) ) { echo_error("ac_common.php FormatString p_string empty"); return null; } $p_string=trim($p_string); if (strlen($p_string) == 0 ) return null; $p_string=str_replace("'","\'",$p_string); return $p_string; } /* GetUserType * purpose : get the type of an user (compta,developper or user) * param $p_user user_login * return : the type of the user */ function GetUserType($p_user) { $cn=DbConnect(); $Res=ExecSql($cn,"select use_usertype from ac_users where use_login='".$p_user."'"); if ( pg_NumRows($Res) == 0 ) return null; $Ret=pg_fetch_row($Res,0); return $Ret[0]; } ?>