ajout fix date cotisation + fix date naissance ajout zeros là où il le faut

This commit is contained in:
ywarnier 2007-01-16 11:24:38 +00:00
parent 9c645dc0b0
commit 78e5c3ffac

View File

@ -134,20 +134,18 @@ if ($_POST["action"] == 'cotisation')
if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"]) if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"])
{ {
$datenaiss=''; $datenaiss='';
if (isset($_POST["naissday"]) && $_POST["naissday"] if (!empty($_POST["naissyear"]))
&& isset($_POST["naissmonth"]) && $_POST["naissmonth"] {
&& isset($_POST["naissyear"]) && $_POST["naissyear"]) $birthday = (int) $_POST["naissday"];
{ $birthmonth = (int) $_POST["naissmonth"];
#$datenaiss=@mktime(12, 0 , 0, $_POST["naissmonth"], $_POST["naissday"], $_POST["naissyear"]); $birthyear = (int) $_POST["naissyear"];
$naissday = (int) $_POST["naissday"]; if($birthmonth>=1 && $birthmonth<=12
$naissmonth = (int) $_POST["naissmonth"]; && $birthday>=1 && $birthday<=31
$naissyear = (int) $_POST["naissyear"]; && $birthyear>=1850 && $birthyear<=date('Y'))
if($naissmonth>=1 && $naissmonth<=12 {
&& $naissday>=1 && $naissday<=31 $datenaiss = ($birthyear*10000)+($birthmonth*100)+$birthday;
&& $naissyear>=1850 && $naissyear<=date('Y')) {
$datenaiss=$naissyear.$naissmonth.$naissday;
} }
} }
$adh->id = $_POST["rowid"]; $adh->id = $_POST["rowid"];
$adh->prenom = $_POST["prenom"]; $adh->prenom = $_POST["prenom"];
@ -167,7 +165,6 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"])
$adh->phone_mobile= $_POST["phone_mobile"]; $adh->phone_mobile= $_POST["phone_mobile"];
$adh->email = $_POST["email"]; $adh->email = $_POST["email"];
$adh->naiss = $datenaiss; $adh->naiss = $datenaiss;
$adh->date = $datenaiss; // A virer
$adh->photo = $_POST["photo"]; $adh->photo = $_POST["photo"];
$adh->typeid = $_POST["type"]; $adh->typeid = $_POST["type"];
@ -184,7 +181,9 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"])
{ {
if (ereg("^options_",$key)) if (ereg("^options_",$key))
{ {
$adh->array_options[$key]=$_POST[$key]; //escape values from POST, at least with addslashes, to avoid obvious SQL injections
//(array_options is directly input in the DB in adherent.class.php::update())
$adh->array_options[$key]=addslashes($_POST[$key]);
} }
} }
if ($adh->update($user,0) >= 0) if ($adh->update($user,0) >= 0)
@ -202,23 +201,21 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"])
if ($_POST["action"] == 'add') if ($_POST["action"] == 'add')
{ {
$datenaiss=''; $datenaiss='';
if (isset($_POST["naissday"]) && $_POST["naissday"] if ($_POST["naissyear"])
&& isset($_POST["naissmonth"]) {
&& isset($_POST["naissyear"]) && $_POST["naissyear"]) $birthday = (int) $_POST["naissday"];
{ $birthmonth = (int) $_POST["naissmonth"];
$datenaiss=@mktime(12, 0 , 0, $_POST["naissmonth"], $_POST["naissday"], $_POST["naissyear"]); $birthyear = (int) $_POST["naissyear"];
$naissday = (int) $_POST["naissday"]; if($birthmonth>=1 && $birthmonth<=12
$naissmonth = (int) $_POST["naissmonth"]; && $birthday>=1 && $birthday<=31
$naissyear = (int) $_POST["naissyear"]; && $birthyear>=1850 && $birthyear<=date('Y'))
if($naissmonth>=1 && $naissmonth<=12 {
&& $naissday>=1 && $naissday<=31 $datenaiss = ($birthyear*10000)+($birthmonth*100)+$birthday;
&& $naissyear>=1850 && $naissyear<=date('Y')) {
$datenaiss=$naissyear.$naissmonth.$naissday;
} }
} }
$datecotisation=''; $datecotisation='';
if (isset($_POST["naissday"]) && isset($_POST["naissmonth"]) && isset($_POST["naissyear"])) if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"]))
{ {
$datecotisation=@mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $datecotisation=@mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
} }
@ -262,7 +259,9 @@ if ($_POST["action"] == 'add')
$adh->morphy = $morphy; $adh->morphy = $morphy;
foreach($_POST as $key => $value){ foreach($_POST as $key => $value){
if (ereg("^options_",$key)){ if (ereg("^options_",$key)){
$adh->array_options[$key]=$_POST[$key]; //escape values from POST, at least with addslashes, to avoid obvious SQL injections
//(array_options is directly input in the DB in adherent.class.php::update())
$adh->array_options[$key]=addslashes($_POST[$key]);
} }
} }