diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php index ecf6270e4e4..fdc1c75ed43 100644 --- a/htdocs/contact.class.php +++ b/htdocs/contact.class.php @@ -1,6 +1,7 @@ - * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2004 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,10 +43,10 @@ class Contact return 1; } + /** * Création du contact * - * */ Function create($user) { @@ -91,7 +92,13 @@ class Contact $this->phone_pro = $soc->tel; } - $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET name='$this->name', firstname='$this->firstname'"; + $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET "; + $sql .= " civilite='$this->civilite_id'"; + $sql .= ", name='$this->name'"; + $sql .= ", firstname='$this->firstname'"; + $sql .= ", address='$this->address'"; +// $sql .= ", cp='$this->cp'"; +// $sql .= ", ville='$this->ville'"; $sql .= ", poste='$this->poste'"; $sql .= ", fax='$this->fax'"; $sql .= ", email='$this->email'"; @@ -100,6 +107,9 @@ class Contact $sql .= ", phone_perso = '$this->phone_perso'"; $sql .= ", phone_mobile = '$this->phone_mobile'"; $sql .= ", jabberid = '$this->jabberid'"; + if ($user) { + $sql .= ", fk_user_modif=".$user->id; + } $sql .= " WHERE idp=$id"; $result = $this->db->query($sql); @@ -247,18 +257,41 @@ class Contact */ Function update_perso($id, $user=0) { + # Mis a jour contact + $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET idp=$id "; - $sql = "UPDATE llx_socpeople SET "; - $sql .= " birthday='".$this->birthday."'"; + if ($this->birthday>0) { + if (eregi('\-',$this->birthday)) { + // Si date = chaine + $sql .= ", birthday='".$this->birthday."'"; + } + else { + // Si date = timestamp + $sql .= ", birthday=".$this->db->idate($this->birthday); + } + } $sql .= " WHERE idp=$id"; $result = $this->db->query($sql); - if (!$result) { print $this->db->error() . '
' . $sql; } + # Mis a jour alerte birthday + if ($this->birthday_alert) { + $sql = "INSERT into ".MAIN_DB_PREFIX."user_alert(type,fk_contact,fk_user) "; + $sql.= "values (1,".$id.",".$user->id.")"; + } else { + $sql = "DELETE from ".MAIN_DB_PREFIX."user_alert "; + $sql.= "where type=1 AND fk_contact=".$id." AND fk_user=".$user->id; + } + $result = $this->db->query($sql); + if (!$result) + { + print $this->db->error() . '
' . $sql; + } + return $result; } @@ -269,7 +302,7 @@ class Contact */ Function fetch($id, $user=0) { - $sql = "SELECT c.idp, c.fk_soc, c.name, c.firstname, c.email, phone, phone_perso, phone_mobile, fax, jabberid, c.birthday, c.note, poste"; + $sql = "SELECT c.idp, c.fk_soc, c.civilite civilite_id, c.name, c.firstname, c.address, c.birthday as birthday, poste, phone, phone_perso, phone_mobile, fax, c.email, jabberid, c.note"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $sql .= " WHERE c.idp = $id"; @@ -282,13 +315,18 @@ class Contact $obj = $this->db->fetch_object($result , 0); $this->id = $obj->idp; + $this->civilite_id = $obj->civilite_id; $this->name = $obj->name; $this->firstname = $obj->firstname; $this->nom = $obj->name; $this->prenom = $obj->firstname; + + $this->address = $obj->address; + $this->societeid = $obj->fk_soc; $this->socid = $obj->fk_soc; $this->poste = $obj->poste; + $this->fullname = $this->firstname . ' ' . $this->name; $this->phone_pro = dolibarr_print_phone($obj->phone); @@ -304,13 +342,14 @@ class Contact $this->birthday = $obj->birthday; $this->birthday_alert = $obj->birthday_alert; $this->note = $obj->note; + } $this->db->free(); if ($user) { $sql = "SELECT fk_user"; - $sql .= " FROM ".MAIN_DB_PREFIX."birthday_alert"; + $sql .= " FROM ".MAIN_DB_PREFIX."user_alert"; $sql .= " WHERE fk_user = $user->id AND fk_contact = $id"; if ($this->db->query($sql)) @@ -388,7 +427,7 @@ class Contact Function info($id) { $sql = "SELECT c.idp, ".$this->db->pdate("datec")." as datec, fk_user"; - $sql .= ", ".$this->db->pdate("tms")." as tms"; + $sql .= ", ".$this->db->pdate("tms")." as tms, fk_user_modif"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $sql .= " WHERE c.idp = $id"; @@ -402,9 +441,12 @@ class Contact $cuser = new User($this->db, $obj->fk_user); $cuser->fetch(); - $this->user_creation = $cuser; + $muser = new User($this->db, $obj->fk_user_modif); + $muser->fetch(); + $this->user_modification = $muser; + $this->date_creation = $obj->datec; $this->date_modification = $obj->tms; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 288be474493..edbafdf6892 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Laurent Destailleur - * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2004 Benoit Mortier * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -280,12 +280,19 @@ class Form { print ''; } - + /* + * Affiche zone de selection de date + * Liste deroulante pour les jours, mois, annee et eventuellement heurs et minutes + * Les champs sont présélectionnées avec: + * - La date set_time (timestamps ou date au format YYYY-MM-DD ou YYYY-MM-DD HH:MM) + * - La date du jour si set_time vaut '' + * - Aucune date (champs vides) si set_time vaut -1 + */ Function select_date($set_time='', $prefix='re', $h = 0, $m = 0, $empty=0) { - if (! $set_time && !$empty) + if (! $set_time && ! $empty) { - $set_time = time(); + $set_time = time(); } $strmonth[1] = "Janvier"; @@ -301,30 +308,42 @@ class Form { $strmonth[11] = "Novembre"; $strmonth[12] = "Décembre"; - $smonth = 1; + # Analyse de la date de préselection + if (eregi('^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?',$set_time,$reg)) { + // Date au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS' + $syear = $reg[1]; + $smonth = $reg[2]; + $sday = $reg[3]; + $shour = $reg[4]; + $smin = $reg[5]; + } + else { + // Date est un timestamps + $syear = date("Y", $set_time); + $smonth = date("n", $set_time); + $sday = date("d", $set_time); + $shour = date("H", $set_time); + $smin = date("i", $set_time); + } - $cday = date("d", $set_time); - $cmonth = date("n", $set_time); - $syear = date("Y", $set_time); - $shour = date("H", $set_time); - $smin = date("i", $set_time); - print ''; - if ($empty) + if ($empty || $set_time == -1) { - print '