<?
define("DATETIME_FORMAT", "%H:%i %d-%m-%Y");
define("DATE_FORMAT", "%d-%m-%Y");
define("SQL_SELECT_MEMBER", "
select
a.*,
date_format(a.birthdate, '" . DATE_FORMAT . "') birthdate_f,
date_format(a.print_application_date, '" . DATE_FORMAT . "') print_application_date_f,
date_format(a.acceptance_date, '" . DATE_FORMAT . "') acceptance_date_f,
date_format(a.registration_date, '" . DATETIME_FORMAT . "') registration_date_f,
b.description member_type_description
from
tmember a,
tmember_type b
where
a.member_type_id = b.member_type_id
");
function lov($p_name, $p_query, $p_selected, $noblank = false, $attributes = "") {
$lov_result = mysql_query($p_query)
or die("lov $p_name $p_query failed!");
print("<select name=\"$p_name\" $attributes>\n");
if (!$noblank) print("<option value=\"\">\n");
while ($lov_line = mysql_fetch_row($lov_result)) {
$selected = (($lov_line[0] == $p_selected) ? ("selected") : (""));
print("<option $selected value=\"$lov_line[0]\">$lov_line[1]\n");
}
print("</select>\n");
}
function retry($action_retry, $p_message) {
unset($pars);
global $HTTP_POST_VARS;
$post_vars = $HTTP_POST_VARS;
unset($post_vars["p_action"]);
foreach ($post_vars as $key => $value) {
// print("$key -> $value<br>");
$pars .= "&" . urlencode($key) . "=" . urlencode($value);
}
header("Location: index.php?p_action=$action_retry&p_action_error=" . urlencode($p_message) . $pars);
}
function add_where(&$where, $where_cond) {
$where .= (($where != "") ? (" and ") : (" where ")) . $where_cond;
}
function to_mysql_date($string_date) {
// il formato in ingresso deve essere DD-MM-YYYY
// restituisce la data in formato YYYY-MM-DD
list($day, $month, $year) = split("-", $string_date);
$mysql_date = "$year-$month-$day";
if (!checkdate($month, $day, $year)) {
return false;
} else {
return $mysql_date;
}
}
?>