From fcfc435df9962343b7bf1689657e5f04fe4cb77f Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Tue, 5 Oct 2004 14:31:45 +0000 Subject: [PATCH] Ajout gestion de notion de contact facturation --- htdocs/contact.class.php | 75 ++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php index 5141b2d057b..9009b27ad8b 100644 --- a/htdocs/contact.class.php +++ b/htdocs/contact.class.php @@ -23,17 +23,18 @@ */ /*! - \file htdocs/contact.class.php - \ingroup societe - \brief Fichier de la classe des contacts - \version $Revision$ + \file htdocs/contact.class.php + \ingroup societe + \brief Fichier de la classe des contacts + \version $Revision$ */ -require (DOL_DOCUMENT_ROOT."/lib/ldap.lib.php"); +require_once (DOL_DOCUMENT_ROOT."/lib/ldap.lib.php"); + /*! \class Contact - \brief Classe permettant la gestion des contacts + \brief Classe permettant la gestion des contacts */ class Contact @@ -270,19 +271,22 @@ class Contact */ function update_perso($id, $user=0) { - # Mis a jour contact + // Mis a jour contact $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET idp=$id "; - 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); - } - } + 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); @@ -291,14 +295,17 @@ class Contact 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; - } + // 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) { @@ -373,6 +380,24 @@ class Contact } $this->db->free(); + + $sql = "SELECT count(*) "; + $sql .= " FROM ".MAIN_DB_PREFIX."contact_facture"; + $sql .= " WHERE fk_contact = ". $_id; + + if ($this->db->query($sql)) + { + if ($this->db->num_rows()) + { + $this->facturation = 1; + } + else + { + $this->facturation = 0; + } + } + $this->db->free(); + if ($user) { $sql = "SELECT fk_user";