New: Possibilité d'jouter des contacts sur une propale

This commit is contained in:
Laurent Destailleur 2006-06-10 19:36:43 +00:00
parent 340abe4786
commit adaf75bb2b
7 changed files with 533 additions and 260 deletions

View File

@ -35,6 +35,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php");
$langs->load('propal'); $langs->load('propal');
$langs->load('compta'); $langs->load('compta');
$langs->load('bills');
$user->getrights('propale'); $user->getrights('propale');
if (!$user->rights->propale->lire) if (!$user->rights->propale->lire)

View File

@ -1628,266 +1628,267 @@ class Commande
} }
/** /**
* \brief Liste les valeurs possibles de type de contacts pour les factures * \brief Liste les valeurs possibles de type de contacts pour les factures
* \param source 'internal' ou 'external' * \param source 'internal' ou 'external'
* \return array Tableau des types de contacts * \return array Tableau des types de contacts
*/ */
function liste_type_contact($source) function liste_type_contact($source)
{ {
global $langs; global $langs;
$element='commande'; $element='commande';
$tab = array(); $tab = array();
$sql = "SELECT distinct tc.rowid, tc.code, tc.libelle"; $sql = "SELECT distinct tc.rowid, tc.code, tc.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
$sql.= " WHERE element='".$element."'"; $sql.= " WHERE element='".$element."'";
$sql.= " AND source='".$source."'"; $sql.= " AND source='".$source."'";
$sql.= " ORDER by tc.code"; $sql.= " ORDER by tc.code";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$num=$this->db->num_rows($resql); $num=$this->db->num_rows($resql);
$i=0; $i=0;
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$transkey="TypeContact_".$element."_".$source."_".$obj->code; $transkey="TypeContact_".$element."_".$source."_".$obj->code;
$libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); $libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle);
$tab[$obj->rowid]=$libelle_type; $tab[$obj->rowid]=$libelle_type;
$i++; $i++;
} }
return $tab; return $tab;
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
return null; return null;
} }
} }
/** /**
* \brief Récupère les lignes de contact de l'objet * \brief Récupère les lignes de contact de l'objet
* \param statut Statut des lignes detail à récupérer * \param statut Statut des lignes detail à récupérer
* \param source Source du contact external (llx_socpeople) ou internal (llx_user) * \param source Source du contact external (llx_socpeople) ou internal (llx_user)
* \return array Tableau des rowid des contacts * \return array Tableau des rowid des contacts
*/ */
function liste_contact($statut=-1,$source='external') function liste_contact($statut=-1,$source='external')
{ {
global $langs; global $langs;
$element='commande'; $element='commande';
$tab=array(); $tab=array();
$sql = "SELECT ec.rowid, ec.statut, ec.fk_socpeople as id,"; $sql = "SELECT ec.rowid, ec.statut, ec.fk_socpeople as id,";
if ($source == 'internal') $sql.=" '-1' as socid,"; if ($source == 'internal') $sql.=" '-1' as socid,";
if ($source == 'external') $sql.=" t.fk_soc as socid,"; if ($source == 'external') $sql.=" t.fk_soc as socid,";
if ($source == 'internal') $sql.=" t.name as nom,"; if ($source == 'internal') $sql.=" t.name as nom,";
if ($source == 'external') $sql.=" t.name as nom,"; if ($source == 'external') $sql.=" t.name as nom,";
$sql.= "tc.source, tc.element, tc.code, tc.libelle"; $sql.= "tc.source, tc.element, tc.code, tc.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."element_contact ec,"; $sql.= " FROM ".MAIN_DB_PREFIX."element_contact ec,";
if ($source == 'internal') $sql.=" ".MAIN_DB_PREFIX."user t,"; if ($source == 'internal') $sql.=" ".MAIN_DB_PREFIX."user t,";
if ($source == 'external') $sql.=" ".MAIN_DB_PREFIX."socpeople t,"; if ($source == 'external') $sql.=" ".MAIN_DB_PREFIX."socpeople t,";
$sql.= " ".MAIN_DB_PREFIX."c_type_contact tc"; $sql.= " ".MAIN_DB_PREFIX."c_type_contact tc";
$sql.= " WHERE element_id =".$this->id; $sql.= " WHERE element_id =".$this->id;
$sql.= " AND ec.fk_c_type_contact=tc.rowid"; $sql.= " AND ec.fk_c_type_contact=tc.rowid";
$sql.= " AND tc.element='".$element."'"; $sql.= " AND tc.element='".$element."'";
if ($source == 'internal') $sql.= " AND tc.source = 'internal'"; if ($source == 'internal') $sql.= " AND tc.source = 'internal'";
if ($source == 'external') $sql.= " AND tc.source = 'external'"; if ($source == 'external') $sql.= " AND tc.source = 'external'";
$sql.= " AND tc.active=1"; $sql.= " AND tc.active=1";
if ($source == 'internal') $sql.= " AND ec.fk_socpeople = t.rowid"; if ($source == 'internal') $sql.= " AND ec.fk_socpeople = t.rowid";
if ($source == 'external') $sql.= " AND ec.fk_socpeople = t.idp"; if ($source == 'external') $sql.= " AND ec.fk_socpeople = t.idp";
if ($statut >= 0) $sql.= " AND statut = '$statut'"; if ($statut >= 0) $sql.= " AND statut = '$statut'";
$sql.=" ORDER BY t.name ASC"; $sql.=" ORDER BY t.name ASC";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$num=$this->db->num_rows($resql); $num=$this->db->num_rows($resql);
$i=0; $i=0;
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code; $transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code;
$libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); $libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle);
$tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id,'nom'=>$obj->nom,'rowid'=>$obj->rowid,'code'=>$obj->code,'libelle'=>$libelle_type,'status'=>$obj->statut); $tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id,'nom'=>$obj->nom,'rowid'=>$obj->rowid,'code'=>$obj->code,'libelle'=>$libelle_type,'status'=>$obj->statut);
$i++; $i++;
} }
return $tab; return $tab;
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dolibarr_print_error($this->db); dolibarr_print_error($this->db);
return -1; return -1;
} }
} }
/** /**
* \brief Ajoute un contact associé une commande * \brief Ajoute un contact associé une commande
* \param fk_socpeople Id du contact a ajouter. * \param fk_socpeople Id du contact a ajouter.
* \param type_contact Type de contact * \param type_contact Type de contact
* \param source extern=Contact externe (llx_socpeople), intern=Contact interne (llx_user) * \param source extern=Contact externe (llx_socpeople), intern=Contact interne (llx_user)
* \return int <0 si erreur, >0 si ok * \return int <0 si erreur, >0 si ok
*/ */
function add_contact($fk_socpeople, $type_contact, $source='extern') function add_contact($fk_socpeople, $type_contact, $source='extern')
{ {
dolibarr_syslog("Commande::add_contact $fk_socpeople, $type_contact, $source"); dolibarr_syslog("Commande::add_contact $fk_socpeople, $type_contact, $source");
if ($fk_socpeople <= 0) return -1; if ($fk_socpeople <= 0) return -1;
// Verifie type_contact // Verifie type_contact
if (! $type_contact || ! is_numeric($type_contact)) if (! $type_contact || ! is_numeric($type_contact))
{ {
$this->error="Valeur pour type_contact incorrect"; $this->error="Valeur pour type_contact incorrect";
return -3; return -3;
} }
$datecreate = time(); $datecreate = time();
// Insertion dans la base // Insertion dans la base
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact";
$sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
$sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ; $sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ;
$sql.= $this->db->idate($datecreate); $sql.= $this->db->idate($datecreate);
$sql.= ", 4, '". $type_contact . "' "; $sql.= ", 4, '". $type_contact . "' ";
$sql.= ")"; $sql.= ")";
// Retour // Retour
if ( $this->db->query($sql) ) if ( $this->db->query($sql) )
{ {
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error()." - $sql"; $this->error=$this->db->error()." - $sql";
return -1; return -1;
} }
} }
/** /**
* \brief Supprime une ligne de contact * \brief Supprime une ligne de contact
* \param rowid La reference du contact * \param rowid La reference du contact
* \return statur >0 si ok, <0 si ko * \return statur >0 si ok, <0 si ko
*/ */
function delete_contact($rowid) function delete_contact($rowid)
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
$sql.= " WHERE rowid =".$rowid; $sql.= " WHERE rowid =".$rowid;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
return 1; return 1;
} }
else else
{ {
return -1; return -1;
} }
} }
/** /**
* \brief Le détail d'un contact * \brief Le détail d'un contact
* \param rowid L'identifiant du contact * \param rowid L'identifiant du contact
* \return object L'objet construit par DoliDb.fetch_object * \return object L'objet construit par DoliDb.fetch_object
*/ */
function detail_contact($rowid) function detail_contact($rowid)
{ {
$element='commande'; $element='commande';
$sql = "SELECT ec.datecreate, ec.statut, ec.fk_socpeople, ec.fk_c_type_contact,"; $sql = "SELECT ec.datecreate, ec.statut, ec.fk_socpeople, ec.fk_c_type_contact,";
$sql.= " tc.code, tc.libelle, s.fk_soc"; $sql.= " tc.code, tc.libelle, s.fk_soc";
$sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc, "; $sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc, ";
$sql.= " ".MAIN_DB_PREFIX."socpeople as s"; $sql.= " ".MAIN_DB_PREFIX."socpeople as s";
$sql.= " WHERE ec.rowid =".$rowid; $sql.= " WHERE ec.rowid =".$rowid;
$sql.= " AND ec.fk_socpeople=s.idp"; $sql.= " AND ec.fk_socpeople=s.idp";
$sql.= " AND ec.fk_c_type_contact=tc.rowid"; $sql.= " AND ec.fk_c_type_contact=tc.rowid";
$sql.= " AND tc.element = '".$element."'"; $sql.= " AND tc.element = '".$element."'";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
return $obj; return $obj;
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dolibarr_print_error($this->db); dolibarr_print_error($this->db);
return null; return null;
} }
} }
/** /**
* \brief Mise a jour du contact associé à une commande * \brief Mise a jour du contact associé à une commande
* \param rowid La reference du lien commande-contact * \param rowid La reference du lien commande-contact
* \param statut Le nouveau statut * \param statut Le nouveau statut
* \param type_contact_id Description du type de contact * \param type_contact_id Description du type de contact
* \return int <0 si erreur, =0 si ok * \return int <0 si erreur, =0 si ok
*/ */
function update_contact($rowid, $statut, $type_contact_id) function update_contact($rowid, $statut, $type_contact_id)
{ {
// Insertion dans la base // Insertion dans la base
$sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set"; $sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set";
$sql.= " statut = $statut,"; $sql.= " statut = $statut,";
$sql.= " fk_c_type_contact = '".$type_contact_id ."'"; $sql.= " fk_c_type_contact = '".$type_contact_id ."'";
$sql.= " where rowid = ".$rowid; $sql.= " where rowid = ".$rowid;
// Retour // Retour
if ( $this->db->query($sql) ) if ( $this->db->query($sql) )
{ {
return 0; return 0;
} }
else else
{ {
dolibarr_print_error($this->db); dolibarr_print_error($this->db);
return -1; return -1;
} }
} }
/** /**
* * \brief Renvoi tableau des id des contacts d'un type donné
* * \param source 'internel' ou 'external'
* * \param code Type de contact
*/ * \param array Tableau des id de réponses
function getIdContact($source,$code) */
{ function getIdContact($source,$code)
$element='commande'; // Contact sur la facture {
$result=array(); $element='commande'; // Contact sur commande
$i=0; $result=array();
$i=0;
$sql = "SELECT ec.fk_socpeople";
$sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc"; $sql = "SELECT ec.fk_socpeople";
$sql.= " WHERE ec.element_id = ".$this->id; $sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc";
$sql.= " AND ec.fk_c_type_contact=tc.rowid"; $sql.= " WHERE ec.element_id = ".$this->id;
$sql.= " AND tc.element = '".$element."'"; $sql.= " AND ec.fk_c_type_contact=tc.rowid";
$sql.= " AND tc.source = '".$source."'"; $sql.= " AND tc.element = '".$element."'";
$sql.= " AND tc.code = '".$code."'"; $sql.= " AND tc.source = '".$source."'";
$sql.= " AND tc.code = '".$code."'";
$resql=$this->db->query($sql);
$resql=$this->db->query($sql);
if ($resql)
{ if ($resql)
while ($obj = $this->db->fetch_object($resql)) {
{ while ($obj = $this->db->fetch_object($resql))
$result[$i]=$obj->fk_socpeople; {
$i++; $result[$i]=$obj->fk_socpeople;
} $i++;
} }
else }
{ else
$this->error=$this->db->error(); {
return null; $this->error=$this->db->error();
} return null;
}
return $result;
} return $result;
}

View File

@ -21,9 +21,9 @@
*/ */
/** /**
\file htdocs/compta/contact.php \file htdocs/commande/contact.php
\ingroup facture \ingroup commande
\brief Onglet de gestion des contacts des factures \brief Onglet de gestion des contacts de commande
\version $Revision$ \version $Revision$
*/ */

View File

@ -5,6 +5,7 @@ ProposalsDraft=Draft commercial proposals
ProposalDraft=Draft commercial proposal ProposalDraft=Draft commercial proposal
ProposalsOpened=Opened commercial proposals ProposalsOpened=Opened commercial proposals
Prop=Commercial proposals Prop=Commercial proposals
ProposalContact=Proposal contact
NewProp=New commercial proposal NewProp=New commercial proposal
NewProposal=New commercial proposal NewProposal=New commercial proposal
NewPropal=New proposal NewPropal=New proposal

View File

@ -5,6 +5,7 @@ ProposalsDraft=Propositions commerciales brouillons
ProposalDraft=Proposition commerciale brouillon ProposalDraft=Proposition commerciale brouillon
Prop=Propositions commerc. Prop=Propositions commerc.
ProposalsOpened=Propositions commerciales ouvertes ProposalsOpened=Propositions commerciales ouvertes
ProposalContact=Contact proposition
NewProp=Nouvelle proposition commerciale NewProp=Nouvelle proposition commerciale
NewProposal=Nouvelle proposition commerciale NewProposal=Nouvelle proposition commerciale
NewPropal=Nouvelle proposition NewPropal=Nouvelle proposition

View File

@ -55,6 +55,11 @@ function propal_prepare_head($propal)
$h++; $h++;
} }
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('ProposalContact');
$head[$h][2] = 'contact';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Note'); $head[$h][1] = $langs->trans('Note');
$head[$h][2] = 'note'; $head[$h][2] = 'note';

View File

@ -349,6 +349,270 @@ class Propal
} }
/**
* \brief Liste les valeurs possibles de type de contacts pour les factures
* \param source 'internal' ou 'external'
* \return array Tableau des types de contacts
*/
function liste_type_contact($source)
{
global $langs;
$element='propal';
$tab = array();
$sql = "SELECT distinct tc.rowid, tc.code, tc.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
$sql.= " WHERE element='".$element."'";
$sql.= " AND source='".$source."'";
$sql.= " ORDER by tc.code";
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->num_rows($resql);
$i=0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$transkey="TypeContact_".$element."_".$source."_".$obj->code;
$libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle);
$tab[$obj->rowid]=$libelle_type;
$i++;
}
return $tab;
}
else
{
$this->error=$this->db->error();
return null;
}
}
/**
* \brief Récupère les lignes de contact de l'objet
* \param statut Statut des lignes detail à récupérer
* \param source Source du contact external (llx_socpeople) ou internal (llx_user)
* \return array Tableau des rowid des contacts
*/
function liste_contact($statut=-1,$source='external')
{
global $langs;
$element='propal';
$tab=array();
$sql = "SELECT ec.rowid, ec.statut, ec.fk_socpeople as id,";
if ($source == 'internal') $sql.=" '-1' as socid,";
if ($source == 'external') $sql.=" t.fk_soc as socid,";
if ($source == 'internal') $sql.=" t.name as nom,";
if ($source == 'external') $sql.=" t.name as nom,";
$sql.= "tc.source, tc.element, tc.code, tc.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."element_contact ec,";
if ($source == 'internal') $sql.=" ".MAIN_DB_PREFIX."user t,";
if ($source == 'external') $sql.=" ".MAIN_DB_PREFIX."socpeople t,";
$sql.= " ".MAIN_DB_PREFIX."c_type_contact tc";
$sql.= " WHERE element_id =".$this->id;
$sql.= " AND ec.fk_c_type_contact=tc.rowid";
$sql.= " AND tc.element='".$element."'";
if ($source == 'internal') $sql.= " AND tc.source = 'internal'";
if ($source == 'external') $sql.= " AND tc.source = 'external'";
$sql.= " AND tc.active=1";
if ($source == 'internal') $sql.= " AND ec.fk_socpeople = t.rowid";
if ($source == 'external') $sql.= " AND ec.fk_socpeople = t.idp";
if ($statut >= 0) $sql.= " AND statut = '$statut'";
$sql.=" ORDER BY t.name ASC";
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->num_rows($resql);
$i=0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code;
$libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle);
$tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id,'nom'=>$obj->nom,'rowid'=>$obj->rowid,'code'=>$obj->code,'libelle'=>$libelle_type,'status'=>$obj->statut);
$i++;
}
return $tab;
}
else
{
$this->error=$this->db->error();
dolibarr_print_error($this->db);
return -1;
}
}
/**
* \brief Ajoute un contact associé une commande
* \param fk_socpeople Id du contact a ajouter.
* \param type_contact Type de contact
* \param source extern=Contact externe (llx_socpeople), intern=Contact interne (llx_user)
* \return int <0 si erreur, >0 si ok
*/
function add_contact($fk_socpeople, $type_contact, $source='extern')
{
dolibarr_syslog("Commande::add_contact $fk_socpeople, $type_contact, $source");
if ($fk_socpeople <= 0) return -1;
// Verifie type_contact
if (! $type_contact || ! is_numeric($type_contact))
{
$this->error="Valeur pour type_contact incorrect";
return -3;
}
$datecreate = time();
// Insertion dans la base
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact";
$sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
$sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ;
$sql.= $this->db->idate($datecreate);
$sql.= ", 4, '". $type_contact . "' ";
$sql.= ")";
// Retour
if ( $this->db->query($sql) )
{
return 1;
}
else
{
$this->error=$this->db->error()." - $sql";
return -1;
}
}
/**
* \brief Supprime une ligne de contact
* \param rowid La reference du contact
* \return statur >0 si ok, <0 si ko
*/
function delete_contact($rowid)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
$sql.= " WHERE rowid =".$rowid;
if ($this->db->query($sql))
{
return 1;
}
else
{
return -1;
}
}
/**
* \brief Le détail d'un contact
* \param rowid L'identifiant du contact
* \return object L'objet construit par DoliDb.fetch_object
*/
function detail_contact($rowid)
{
$element='propal';
$sql = "SELECT ec.datecreate, ec.statut, ec.fk_socpeople, ec.fk_c_type_contact,";
$sql.= " tc.code, tc.libelle, s.fk_soc";
$sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc, ";
$sql.= " ".MAIN_DB_PREFIX."socpeople as s";
$sql.= " WHERE ec.rowid =".$rowid;
$sql.= " AND ec.fk_socpeople=s.idp";
$sql.= " AND ec.fk_c_type_contact=tc.rowid";
$sql.= " AND tc.element = '".$element."'";
$resql=$this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
return $obj;
}
else
{
$this->error=$this->db->error();
dolibarr_print_error($this->db);
return null;
}
}
/**
* \brief Mise a jour du contact associé à une commande
* \param rowid La reference du lien commande-contact
* \param statut Le nouveau statut
* \param type_contact_id Description du type de contact
* \return int <0 si erreur, =0 si ok
*/
function update_contact($rowid, $statut, $type_contact_id)
{
// Insertion dans la base
$sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set";
$sql.= " statut = $statut,";
$sql.= " fk_c_type_contact = '".$type_contact_id ."'";
$sql.= " where rowid = ".$rowid;
// Retour
if ( $this->db->query($sql) )
{
return 0;
}
else
{
dolibarr_print_error($this->db);
return -1;
}
}
/**
* \brief Renvoi tableau des id des contacts d'un type donné
* \param source 'internel' ou 'external'
* \param code Type de contact
* \param array Tableau des id de réponses
*/
function getIdContact($source,$code)
{
$element='propal'; // Contact sur propal
$result=array();
$i=0;
$sql = "SELECT ec.fk_socpeople";
$sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc";
$sql.= " WHERE ec.element_id = ".$this->id;
$sql.= " AND ec.fk_c_type_contact=tc.rowid";
$sql.= " AND tc.element = '".$element."'";
$sql.= " AND tc.source = '".$source."'";
$sql.= " AND tc.code = '".$code."'";
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj = $this->db->fetch_object($resql))
{
$result[$i]=$obj->fk_socpeople;
$i++;
}
}
else
{
$this->error=$this->db->error();
return null;
}
return $result;
}
/** /**
* *
* *