diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index f7cc77f5069..f991d590aec 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -443,8 +443,7 @@ class Adherent $sql .= ",statut=" .$this->statut; $sql .= ",fk_adherent_type=".$this->typeid; $sql .= ",morphy=" ."'".$this->morphy."'"; - $birthday = (int) $this->naiss; - $sql .= ",naiss=" .($birthday?"'".$birthday."'":"null"); + $sql .= ",naiss=" .($this->naiss?"'".$this->db->idate($this->naiss)."'":"null"); if ($this->datefin) $sql .= ",datefin='".$this->db->idate($this->datefin)."'"; // Ne doit etre modifié que par effacement cotisation if ($this->datevalid) $sql .= ",datevalid='".$this->db->idate($this->datevalid)."'"; // Ne doit etre modifié que par validation adherent @@ -604,7 +603,7 @@ class Adherent $sql.= " ".$this->db->pdate("d.datec")." as datec,"; $sql.= " ".$this->db->pdate("d.tms")." as datem,"; $sql.= " ".$this->db->pdate("d.datefin")." as datefin,"; - $sql.= " d.naiss as datenaiss,"; + $sql.= " ".$this->db->pdate("d.naiss")." as datenaiss,"; $sql.= " ".$this->db->pdate("d.datevalid")." as datev,"; $sql.= " d.pays,"; $sql.= " p.rowid as pays_id, p.code as pays_code, p.libelle as pays_lib,"; diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 08650bf701e..ac933260b2e 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -73,7 +73,10 @@ if ($_POST["action"] == 'cotisation') $reday=$_POST["reday"]; $remonth=$_POST["remonth"]; $reyear=$_POST["reyear"]; - $datecotisation=@mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + if ($_POST["reyear"] && $_POST["remonth"] && $_POST["reday"]) + { + $datecotisation=dolibarr_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + } $cotisation=$_POST["cotisation"]; $accountid=$_POST["accountid"]; @@ -134,18 +137,12 @@ if ($_POST["action"] == 'cotisation') if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"]) { $datenaiss=''; - if (!empty($_POST["naissyear"])) - { - $birthday = (int) $_POST["naissday"]; - $birthmonth = (int) $_POST["naissmonth"]; - $birthyear = (int) $_POST["naissyear"]; - if($birthmonth>=1 && $birthmonth<=12 - && $birthday>=1 && $birthday<=31 - && $birthyear>=1850 && $birthyear<=date('Y')) - { - $datenaiss = ($birthyear*10000)+($birthmonth*100)+$birthday; - } - } + if (isset($_POST["naissday"]) && $_POST["naissday"] + && isset($_POST["naissmonth"]) && $_POST["naissmonth"] + && isset($_POST["naissyear"]) && $_POST["naissyear"]) + { + $datenaiss=dolibarr_mktime(12, 0, 0, $_POST["naissmonth"], $_POST["naissday"], $_POST["naissyear"]); + } $adh->id = $_POST["rowid"]; $adh->prenom = $_POST["prenom"]; @@ -201,22 +198,16 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"]) if ($_POST["action"] == 'add') { $datenaiss=''; - if ($_POST["naissyear"]) - { - $birthday = (int) $_POST["naissday"]; - $birthmonth = (int) $_POST["naissmonth"]; - $birthyear = (int) $_POST["naissyear"]; - if($birthmonth>=1 && $birthmonth<=12 - && $birthday>=1 && $birthday<=31 - && $birthyear>=1850 && $birthyear<=date('Y')) - { - $datenaiss = ($birthyear*10000)+($birthmonth*100)+$birthday; - } - } + if (isset($_POST["naissday"]) && $_POST["naissday"] + && isset($_POST["naissmonth"]) && $_POST["naissmonth"] + && isset($_POST["naissyear"]) && $_POST["naissyear"]) + { + $datenaiss=dolibarr_mktime(12, 0, 0, $_POST["naissmonth"], $_POST["naissday"], $_POST["naissyear"]); + } $datecotisation=''; if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"])) { - $datecotisation=@mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $datecotisation=dolibarr_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); } $type=$_POST["type"]; diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php index d29e8dd7b8e..6c594b723fd 100644 --- a/htdocs/contact.class.php +++ b/htdocs/contact.class.php @@ -303,12 +303,20 @@ class Contact function update_perso($id, $user=0) { // Mis a jour contact - $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET idp=$id "; + $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET idp=".$id; - if ($this->birthday>0) + if ($this->birthday > 0) { - $birthday = (int) $this->birthday; - $sql .= ", birthday='".$birthday."'"; + if (eregi('\-',$this->birthday)) + { + // Si date = chaine (ne devrait pas arriver) + $sql .= ", birthday='".$this->birthday."'"; + } + else + { + // Si date = timestamp + $sql .= ", birthday=".$this->db->idate($this->birthday); + } } if ($user) $sql .= ", fk_user_modif=".$user->id; $sql .= " WHERE idp=$id"; diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 381a68c44e0..381e087cf98 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -73,17 +73,9 @@ if ($_POST["action"] == 'update') $contact = new Contact($db); $contact->id = $_POST["contactid"]; - if ($_POST["birthdayyear"]) + if ($_POST["birthdayyear"] && $_POST["birthdaymonth"] && $_POST["birthdayday"]) { - $birthday = (int) $_POST["birthdayday"]; - $birthmonth = (int) $_POST["birthdaymonth"]; - $birthyear = (int) $_POST["birthdayyear"]; - if($birthmonth>=1 && $birthmonth<=12 - && $birthday>=1 && $birthday<=31 - && $birthyear>=1850 && $birthyear<=date('Y')) - { - $contact->birthday = ($birthyear*10000)+($birthmonth*100)+$birthday; - } + $contact->birthday = dolibarr_mktime(0,0,0,$_POST["birthdaymonth"],$_POST["birthdayday"],$_POST["birthdayyear"]); } $contact->birthday_alert = $_POST["birthday_alert"]; diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 7d35cbf6697..42cdf50a746 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -536,11 +536,11 @@ function dolibarr_print_date($time,$format='') /** - \brief Retourne une date fabriqué depuis une chaine + \brief Retourne une date fabriquée depuis une chaine \param string Date formatée en chaine (YYYYMMDD ou YYYYMMDDHHMMSS) \return date Date */ -function dolibarr_mktime($string) +function dolibarr_stringtotime($string) { $string=eregi_replace('[^0-9]','',$string); $tmp=$string.'000000'; // Si date YYYYMMDD @@ -549,6 +549,32 @@ function dolibarr_mktime($string) } +/** + \brief Retourne une date fabriquée depuis infos. + Remplace la fonction mktime non implémentée sous Windows si année < 1970 + \param x X + \param y Y + \param z Z + \param month Mois + \param day Jour + \param year Année + \return date Date +*/ +function dolibarr_mktime($x,$y,$z,$month,$day,$year) +{ + if ($year <= 1970 && $_SERVER["WINDIR"]) + { + // Gestion a faire pour windows + + return 0; + } + else + { + return mktime($x,$y,$z,$month,$day,$year); + } +} + + /** \brief Affiche les informations d'un objet \param object objet a afficher