Ajout de l'email du tiers dans destinataire d'envoi

This commit is contained in:
Laurent Destailleur 2006-11-29 22:03:28 +00:00
parent 887695c8a0
commit 5ed4be7107
10 changed files with 323 additions and 204 deletions

View File

@ -53,7 +53,7 @@ require_once(DOL_DOCUMENT_ROOT.'/actioncomm.class.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php');
$sall=isset($_GET["sall"])?$_GET["sall"]:$_POST["sall"];
if (isset($_GET["msg"])) { $msg=urldecode($_GET["msg"]); }
if (isset($_GET["msg"])) { $mesg=urldecode($_GET["mesg"]); }
$year=isset($_GET["year"])?$_GET["year"]:"";
$month=isset($_GET["month"])?$_GET["month"]:"";
@ -196,7 +196,7 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer)
}
else
{
$msg = '<div class="error">'.$langs->trans("ErrorFailedToCopyProposal",$_POST['copie_propal']).'</div>';
$mesg = '<div class="error">'.$langs->trans("ErrorFailedToCopyProposal",$_POST['copie_propal']).'</div>';
}
}
else
@ -245,7 +245,7 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer)
}
else
{
$msg = '<div class="error">'.$langs->trans("ErrorFailedToAddContact").'</div>';
$mesg = '<div class="error">'.$langs->trans("ErrorFailedToAddContact").'</div>';
$error=1;
}
}
@ -297,26 +297,37 @@ if ($_POST['action'] == 'setstatut' && $user->rights->propale->cloturer)
if ($_POST['action'] == 'send')
{
$langs->load('mails');
$propal= new Propal($db);
if ( $propal->fetch($_POST['propalid']) )
{
$propalref = sanitize_string($propal->ref);
$file = $conf->propal->dir_output . '/' . $propalref . '/' . $propalref . '.pdf';
if (is_readable($file))
{
$soc = new Societe($db, $propal->socid);
if ($_POST['sendto'])
{
// Le destinataire a été fourni via le champ libre
$sendto = $_POST['sendto'];
$sendtoid = 0;
}
elseif ($_POST['receiver'])
{
// Le destinataire a été fourni via la liste déroulante
$sendto = $soc->contact_get_email($_POST['receiver']);
$sendtoid = $_POST['receiver'];
}
$propal->fetch_client();
if ($_POST['sendto'])
{
// Le destinataire a été fourni via le champ libre
$sendto = $_POST['sendto'];
$sendtoid = 0;
}
elseif ($_POST['receiver'])
{
// Le destinataire a été fourni via la liste déroulante
if ($_POST['receiver'] < 0) // Id du tiers
{
$sendto = $propal->client->email;
$sendtoid = 0;
}
else // Id du contact
{
$sendto = $propal->client->contact_get_email($_POST['receiver']);
$sendtoid = $_POST['receiver'];
}
}
if (strlen($sendto))
{
@ -356,54 +367,82 @@ if ($_POST['action'] == 'send')
$filename[1] = $_FILES['addedfile']['name'];
$mimetype[1] = $_FILES['addedfile']['type'];
}
// Envoi de la propal
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
if ($mailfile->sendfile())
{
$msg='<div class="ok">'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.</div>';
// Insertion action
include_once(DOL_DOCUMENT_ROOT."/contact.class.php");
$actioncomm = new ActionComm($db);
$actioncomm->type_id = $actiontypeid;
$actioncomm->label = $actionmsg2;
$actioncomm->note = $actionmsg;
$actioncomm->date = time(); // L'action est faite maintenant
$actioncomm->percent = 100;
$actioncomm->contact = new Contact($db,$sendtoid);
$actioncomm->societe = new Societe($db,$propal->socid);
$actioncomm->user = $user; // User qui a fait l'action
$actioncomm->propalrowid = $propal->id;
$ret=$actioncomm->add($user); // User qui saisi l'action
if ($ret < 0)
{
dolibarr_print_error($db);
}
else
{
// Renvoie sur la fiche
Header('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&msg='.urlencode($msg));
exit;
}
}
else
{
$msg='<div class="error">'.$langs->trans('ErrorFailedToSendMail',$from,$sendto).' - '.$actioncomm->error.'</div>';
}
if ($mailfile->error)
{
$mesg='<div class="error">'.$mailfile->error.'</div>';
}
else
{
$result=$mailfile->sendfile();
if ($result)
{
$mesg='<div class="ok">'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.</div>';
// Insertion action
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
require_once(DOL_DOCUMENT_ROOT.'/actioncomm.class.php');
$actioncomm = new ActionComm($db);
$actioncomm->type_id = $actiontypeid;
$actioncomm->label = $actionmsg2;
$actioncomm->note = $actionmsg;
$actioncomm->date = time(); // L'action est faite maintenant
$actioncomm->percent = 100;
$actioncomm->contact = new Contact($db,$sendtoid);
$actioncomm->societe = new Societe($db,$propal->socid);
$actioncomm->user = $user; // User qui a fait l'action
$actioncomm->propalrowid = $propal->id;
$ret=$actioncomm->add($user); // User qui saisit l'action
if ($ret < 0)
{
dolibarr_print_error($db);
}
else
{
// Renvoie sur la fiche
Header('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&msg='.urlencode($mesg));
exit;
}
}
else
{
$langs->load("other");
$mesg='<div class="error">';
if ($mailfile->error)
{
$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
$mesg.='<br>'.$mailfile->error;
}
else
{
$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
}
$mesg.='</div>';
}
}
}
else
{
$msg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
dolibarr_syslog('Le mail du destinataire est vide');
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
dolibarr_syslog('Recipient email is empty');
}
}
else
{
dolibarr_syslog('Impossible de lire :'.$file);
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
dolibarr_syslog('Failed to read file: '.$file);
}
}
else
{
dolibarr_syslog('Impossible de lire les données de la propale. Le fichier propal n\'a peut-être pas été généré.');
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'</div>';
dolibarr_syslog('Impossible de lire les données de la facture. Le fichier facture n\'a peut-être pas été généré.');
}
}
@ -677,7 +716,7 @@ $html = new Form($db);
*/
if ($_GET['propalid'] > 0)
{
if ($msg) print "$msg<br>";
if ($mesg) print "$mesg<br>";
$propal = new Propal($db);
@ -1648,7 +1687,7 @@ if ($conf->expedition->enabled)
print_titre($langs->trans('SendPropalByMail'));
$liste[0]="&nbsp;";
foreach ($societe->contact_email_array() as $key=>$value)
foreach ($societe->thirdparty_and_contact_email_array() as $key=>$value)
{
$liste[$key]=$value;
}
@ -1674,6 +1713,8 @@ if ($conf->expedition->enabled)
$formmail->param['returnurl']=DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id;
$formmail->show_form();
print '<br>';
}
}

View File

@ -131,7 +131,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
}
else
{
$msg = '<div class="error">'.$langs->trans("ErrorFailedToAddContact").'</div>';
$mesg = '<div class="error">'.$langs->trans("ErrorFailedToAddContact").'</div>';
$error=1;
}
}
@ -516,26 +516,37 @@ if ($action=='remove_file')
if ($_POST['action'] == 'send')
{
$langs->load('mails');
$commande= new Commande($db);
if ( $commande->fetch($_POST['orderid']) )
{
$orderref = sanitize_string($commande->ref);
$file = $conf->commande->dir_output . '/' . $orderref . '/' . $orderref . '.pdf';
if (is_readable($file))
{
$soc = new Societe($db, $commande->socid);
if ($_POST['sendto'])
{
// Le destinataire a été fourni via le champ libre
$sendto = $_POST['sendto'];
$sendtoid = 0;
}
elseif ($_POST['receiver'])
{
// Le destinataire a été fourni via la liste déroulante
$sendto = $soc->contact_get_email($_POST['receiver']);
$sendtoid = $_POST['receiver'];
}
$commande->fetch_client();
if ($_POST['sendto'])
{
// Le destinataire a été fourni via le champ libre
$sendto = $_POST['sendto'];
$sendtoid = 0;
}
elseif ($_POST['receiver'])
{
// Le destinataire a été fourni via la liste déroulante
if ($_POST['receiver'] < 0) // Id du tiers
{
$sendto = $commande->client->email;
$sendtoid = 0;
}
else // Id du contact
{
$sendto = $commande->client->contact_get_email($_POST['receiver']);
$sendtoid = $_POST['receiver'];
}
}
if (strlen($sendto))
{
@ -575,54 +586,82 @@ if ($_POST['action'] == 'send')
$filename[1] = $_FILES['addedfile']['name'];
$mimetype[1] = $_FILES['addedfile']['type'];
}
// Envoi de la commande
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
if ($mailfile->sendfile())
{
$msg='<div class="ok">'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.</div>';
// Insertion action
include_once(DOL_DOCUMENT_ROOT."/contact.class.php");
$actioncomm = new ActionComm($db);
$actioncomm->type_id = $actiontypeid;
$actioncomm->label = $actionmsg2;
$actioncomm->note = $actionmsg;
$actioncomm->date = time(); // L'action est faite maintenant
$actioncomm->percent = 100;
$actioncomm->contact = new Contact($db,$sendtoid);
$actioncomm->societe = new Societe($db,$commande->socid);
$actioncomm->user = $user; // User qui a fait l'action
$actioncomm->orderrowid = $commande->id;
$ret=$actioncomm->add($user); // User qui saisi l'action
if ($ret < 0)
{
dolibarr_print_error($db);
}
else
{
// Renvoie sur la fiche
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&msg='.urlencode($msg));
exit;
}
}
else
{
$msg='<div class="error">'.$langs->trans('ErrorFailedToSendMail',$from,$sendto).' - '.$actioncomm->error.'</div>';
}
if ($mailfile->error)
{
$mesg='<div class="error">'.$mailfile->error.'</div>';
}
else
{
$result=$mailfile->sendfile();
if ($result)
{
$mesg='<div class="ok">'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.</div>';
// Insertion action
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
require_once(DOL_DOCUMENT_ROOT.'/actioncomm.class.php');
$actioncomm = new ActionComm($db);
$actioncomm->type_id = $actiontypeid;
$actioncomm->label = $actionmsg2;
$actioncomm->note = $actionmsg;
$actioncomm->date = time(); // L'action est faite maintenant
$actioncomm->percent = 100;
$actioncomm->contact = new Contact($db,$sendtoid);
$actioncomm->societe = new Societe($db,$commande->socid);
$actioncomm->user = $user; // User qui a fait l'action
$actioncomm->orderrowid = $commande->id;
$ret=$actioncomm->add($user); // User qui saisit l'action
if ($ret < 0)
{
dolibarr_print_error($db);
}
else
{
// Renvoie sur la fiche
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&msg='.urlencode($mesg));
exit;
}
}
else
{
$langs->load("other");
$mesg='<div class="error">';
if ($mailfile->error)
{
$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
$mesg.='<br>'.$mailfile->error;
}
else
{
$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
}
$mesg.='</div>';
}
}
}
else
{
$msg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
dolibarr_syslog('Le mail du destinataire est vide');
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
dolibarr_syslog('Recipient email is empty');
}
}
else
{
dolibarr_syslog('Impossible de lire :'.$file);
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
dolibarr_syslog('Failed to read file: '.$file);
}
}
else
{
dolibarr_syslog('Impossible de lire les données de la commande. Le fichier commande n\'a peut-être pas été généré.');
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'</div>';
dolibarr_syslog('Impossible de lire les données de la facture. Le fichier facture n\'a peut-être pas été généré.');
}
}
@ -941,15 +980,17 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
}
}
else
/* *************************************************************************** */
/* */
/* Mode vue et edition */
/* */
/* *************************************************************************** */
{
/* *************************************************************************** */
/* */
/* Mode vue et edition */
/* */
/* *************************************************************************** */
$id = $_GET['id'];
if ($id > 0)
{
if ($mesg) print $mesg.'<br>';
$commande = new Commande($db);
if ( $commande->fetch($_GET['id']) > 0)
{
@ -1840,7 +1881,7 @@ else
$soc->fetch($commande->socid);
$liste[0]="&nbsp;";
foreach ($soc->contact_email_array() as $key=>$value)
foreach ($soc->thirdparty_and_contact_email_array() as $key=>$value)
{
$liste[$key]=$value;
}
@ -1866,8 +1907,9 @@ else
$formmail->param['returnurl']=DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id;
$formmail->show_form();
}
print '<br>';
}
}
else
{

View File

@ -819,17 +819,27 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c
if (is_readable($file))
{
$soc = new Societe($db, $fac->socid);
if ($_POST['sendto']) {
$fac->fetch_client();
if ($_POST['sendto'])
{
// Le destinataire a été fourni via le champ libre
$sendto = $_POST['sendto'];
$sendtoid = 0;
}
elseif ($_POST['receiver']) {
elseif ($_POST['receiver'])
{
// Le destinataire a été fourni via la liste déroulante
$sendto = $soc->contact_get_email($_POST['receiver']);
$sendtoid = $_POST['receiver'];
if ($_POST['receiver'] < 0) // Id du tiers
{
$sendto = $fac->client->email;
$sendtoid = 0;
}
else // Id du contact
{
$sendto = $fac->client->contact_get_email($_POST['receiver']);
$sendtoid = $_POST['receiver'];
}
}
if (strlen($sendto))
@ -877,10 +887,13 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c
$filepath[0] = $file;
$filename[0] = $fac->ref.'.pdf';
$mimetype[0] = 'application/pdf';
$filepath[1] = $_FILES['addedfile']['tmp_name'];
$filename[1] = $_FILES['addedfile']['name'];
$mimetype[1] = $_FILES['addedfile']['type'];
if ($_FILES['addedfile']['tmp_name'])
{
$filepath[1] = $_FILES['addedfile']['tmp_name'];
$filename[1] = $_FILES['addedfile']['name'];
$mimetype[1] = $_FILES['addedfile']['type'];
}
// Envoi de la facture
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
if ($mailfile->error)
@ -889,7 +902,8 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c
}
else
{
if ($mailfile->sendfile())
$result=$mailfile->sendfile();
if ($result)
{
$mesg='<div class="ok">'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.</div>';
@ -900,7 +914,7 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c
$actioncomm->type_id = $actiontypeid;
$actioncomm->label = $actionmsg2;
$actioncomm->note = $actionmsg;
$actioncomm->date = time();
$actioncomm->date = time(); // L'action est faite maintenant
$actioncomm->percent = 100;
$actioncomm->contact = new Contact($db,$sendtoid);
$actioncomm->societe = new Societe($db,$fac->socid);
@ -908,7 +922,6 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c
$actioncomm->facid = $fac->id;
$ret=$actioncomm->add($user); // User qui saisit l'action
if ($ret < 0)
{
dolibarr_print_error($db);
@ -924,8 +937,15 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c
{
$langs->load("other");
$mesg='<div class="error">';
$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
if ($mailfile->error) $mesg.='<br>'.$mailfile->error;
if ($mailfile->error)
{
$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
$mesg.='<br>'.$mailfile->error;
}
else
{
$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
}
$mesg.='</div>';
}
}
@ -936,7 +956,6 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').'</div>';
dolibarr_syslog('Recipient email is empty');
}
}
else
{
@ -1571,15 +1590,14 @@ if ($_GET['action'] == 'create')
}
else
{
/* *************************************************************************** */
/* */
/* Fiche en mode visu */
/* */
/* *************************************************************************** */
$id = $_GET['facid'];
if ($id > 0)
{
/* *************************************************************************** */
/* */
/* Fiche en mode visu */
/* */
/* *************************************************************************** */
if ($mesg) print $mesg.'<br>';
$fac = New Facture($db);
@ -2772,7 +2790,7 @@ else
print_titre($langs->trans('SendBillByMail'));
$liste[0]='&nbsp;';
foreach ($soc->contact_email_array() as $key=>$value)
foreach ($soc->thirdparty_and_contact_email_array() as $key=>$value)
{
$liste[$key]=$value;
}
@ -2828,7 +2846,7 @@ else
print_titre($langs->trans('SendReminderBillByMail'));
$liste[0]='&nbsp;';
foreach ($soc->contact_email_array() as $key=>$value)
foreach ($soc->thirdparty_and_contact_email_array() as $key=>$value)
{
$liste[$key]=$value;
}
@ -2857,7 +2875,6 @@ else
print '<br>';
}
}
else
{

View File

@ -28,10 +28,11 @@
\brief Page des societes
\version $Revision$
*/
require("./pre.inc.php");
require("../../tva.class.php");
$langs->load("other");
$year=$_GET["year"];
if ($year == 0 )
{

View File

@ -1034,7 +1034,7 @@ class Form
$obj = $this->db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
$libelle=($langs->trans("PaymentTypeShort".$obj->code)!=("PaymentTypeShort".$obj->code)?$langs->trans("PaymentTypeShort".$obj->code):($obj->libelle!='-'?$obj->libelle:''));
$libelle=($langs->trans("PaymentModeShort".$obj->code)!=("PaymentModeShort".$obj->code)?$langs->trans("PaymentModeShort".$obj->code):($obj->libelle!='-'?$obj->libelle:''));
$this->cache_types_paiements_code[$obj->id]=$obj->code;
$this->cache_types_paiements_libelle[$obj->id]=$libelle;
$this->cache_types_paiements_type[$obj->id]=$obj->type;

View File

@ -78,7 +78,7 @@ class pdf_paiement
$pdf->Text(11,$this->tab_top + 6,'Date');
$pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10);
$pdf->Text(42, $this->tab_top + 6, $langs->trans("PaymentType"));
$pdf->Text(42, $this->tab_top + 6, $langs->trans("PaymentMode"));
$pdf->line(80, $this->tab_top, 80, $this->tab_top + $this->tab_height + 10);
$pdf->Text(82, $this->tab_top + 6, $langs->trans("Invoice"));

View File

@ -490,6 +490,7 @@ print '</td></tr></table>';
*/
$boxarray=$infobox->listboxes("0",$user); // 0=valeur pour la page accueil
$boxjavascriptids=array();
//print_r($boxarray);
// Gestion deplacement des boxes
if (eregi('boxobject_([0-9]+)',$_GET["switchfrom"],$regfrom)

View File

@ -47,6 +47,7 @@ Town=Town
Web=Web
Birthday=Birthday
VATIsUsed=Using VAT
ThirdPartyEMail=%s
##### Professionnal ID #####
ProfId1=Professional ID 1
ProfId2=Professional ID 2

View File

@ -47,6 +47,7 @@ Town=Ville
Web=Web
Birthday=Date de naissance
VATIsUsed=Assujéti à TVA
ThirdPartyEMail=%s
##### Professionnal ID #####
ProfId1=ID professionnel 1
ProfId2=ID professionnel 2

View File

@ -1148,76 +1148,91 @@ class Societe
}
/**
* \brief Renvoie la liste des contacts emails existant pour la société
* \return array tableau des contacts emails
*/
function contact_email_array()
{
$contact_email = array();
$sql = "SELECT idp, email, name, firstname FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = '$this->id'";
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object();
$contact_email[$obj->idp] = "$obj->firstname $obj->name &lt;$obj->email&gt;";
$i++;
}
}
return $contact_email;
}
else
{
dolibarr_print_error($this->db);
}
}
/**
* \brief Renvoie la liste des contacts de cette société
* \return array tableau des contacts
*/
function contact_array()
{
$contacts = array();
$sql = "SELECT idp, name, firstname FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = '$this->id'";
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object();
$contacts[$obj->idp] = "$obj->firstname $obj->name";
$i++;
}
}
return $contacts;
}
else
{
dolibarr_print_error($this->db);
}
}
/**
* \brief Renvoie la liste des contacts emails existant pour la sociét
* \return array tableau des contacts emails
*/
function thirdparty_and_contact_email_array()
{
global $langs;
$contact_email = $this->contact_email_array();
if ($this->email)
{
// TODO: Tester si email non deja présent dans tableau contact
$contact_email[-1]=$langs->trans("ThirdParty").': '.dolibarr_trunc($this->nom,16)." &lt;".$this->email."&gt;";;
}
return $contact_email;
}
/**
* \brief Renvoie la liste des contacts emails existant pour la société
* \return array tableau des contacts emails
*/
function contact_email_array()
{
$contact_email = array();
$sql = "SELECT idp, email, name, firstname";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople";
$sql.= " WHERE fk_soc = '".$this->id."'";
$resql=$this->db->query($sql);
if ($resql)
{
$nump = $this->db->num_rows($resql);
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object($resql);
$contact_email[$obj->idp] = trim($obj->firstname." ".$obj->name)." &lt;".$obj->email."&gt;";
$i++;
}
}
}
else
{
dolibarr_print_error($this->db);
}
return $contact_email;
}
/**
* \brief Renvoie la liste des contacts de cette sociét
* \return array tableau des contacts
*/
function contact_array()
{
$contacts = array();
$sql = "SELECT idp, name, firstname FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = '$this->id'";
$resql=$this->db->query($sql);
if ($resql)
{
$nump = $this->db->num_rows($resql);
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object($resql);
$contacts[$obj->idp] = "$obj->firstname $obj->name";
$i++;
}
}
}
else
{
dolibarr_print_error($this->db);
}
return $contacts;
}
/**
* \brief Renvoie l'email d'un contact par son id
* \brief Renvoie l'email d'un contact depuis son id
* \param rowid id du contact
* \return string email du contact
*/