From 5ed4be7107f8b92d967f3bd0da12ed10d0e23c3f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Nov 2006 22:03:28 +0000 Subject: [PATCH] Ajout de l'email du tiers dans destinataire d'envoi --- htdocs/comm/propal.php | 147 +++++++++++------ htdocs/commande/fiche.php | 154 +++++++++++------- htdocs/compta/facture.php | 67 +++++--- htdocs/compta/tva/index.php | 3 +- htdocs/html.form.class.php | 2 +- .../modules/rapport/pdf_paiement.class.php | 2 +- htdocs/index.php | 1 + htdocs/langs/en_US/companies.lang | 1 + htdocs/langs/fr_FR/companies.lang | 1 + htdocs/societe.class.php | 149 +++++++++-------- 10 files changed, 323 insertions(+), 204 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 30d258077e0..c28781010ee 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -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 = '
'.$langs->trans("ErrorFailedToCopyProposal",$_POST['copie_propal']).'
'; + $mesg = '
'.$langs->trans("ErrorFailedToCopyProposal",$_POST['copie_propal']).'
'; } } else @@ -245,7 +245,7 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer) } else { - $msg = '
'.$langs->trans("ErrorFailedToAddContact").'
'; + $mesg = '
'.$langs->trans("ErrorFailedToAddContact").'
'; $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='
'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.
'; - // 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='
'.$langs->trans('ErrorFailedToSendMail',$from,$sendto).' - '.$actioncomm->error.'
'; - } + if ($mailfile->error) + { + $mesg='
'.$mailfile->error.'
'; + } + else + { + $result=$mailfile->sendfile(); + if ($result) + { + $mesg='
'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.
'; + + // 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='
'; + if ($mailfile->error) + { + $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); + $mesg.='
'.$mailfile->error; + } + else + { + $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } + $mesg.='
'; + } + } } else { - $msg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; - dolibarr_syslog('Le mail du destinataire est vide'); + $langs->load("other"); + $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; + dolibarr_syslog('Recipient email is empty'); } } else { - dolibarr_syslog('Impossible de lire :'.$file); + $langs->load("other"); + $mesg='
'.$langs->trans('ErrorCantReadFile',$file).'
'; + 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='
'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'
'; + 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
"; + if ($mesg) print "$mesg
"; $propal = new Propal($db); @@ -1648,7 +1687,7 @@ if ($conf->expedition->enabled) print_titre($langs->trans('SendPropalByMail')); $liste[0]=" "; - 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 '
'; } } diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 45c2b20bd63..2fce2ed26cb 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -131,7 +131,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer) } else { - $msg = '
'.$langs->trans("ErrorFailedToAddContact").'
'; + $mesg = '
'.$langs->trans("ErrorFailedToAddContact").'
'; $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='
'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.
'; - // 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='
'.$langs->trans('ErrorFailedToSendMail',$from,$sendto).' - '.$actioncomm->error.'
'; - } + if ($mailfile->error) + { + $mesg='
'.$mailfile->error.'
'; + } + else + { + $result=$mailfile->sendfile(); + if ($result) + { + $mesg='
'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.
'; + + // 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='
'; + if ($mailfile->error) + { + $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); + $mesg.='
'.$mailfile->error; + } + else + { + $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } + $mesg.='
'; + } + } } else { - $msg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; - dolibarr_syslog('Le mail du destinataire est vide'); + $langs->load("other"); + $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; + dolibarr_syslog('Recipient email is empty'); } } else { - dolibarr_syslog('Impossible de lire :'.$file); + $langs->load("other"); + $mesg='
'.$langs->trans('ErrorCantReadFile',$file).'
'; + 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='
'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'
'; + 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.'
'; + $commande = new Commande($db); if ( $commande->fetch($_GET['id']) > 0) { @@ -1840,7 +1881,7 @@ else $soc->fetch($commande->socid); $liste[0]=" "; - 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 '
'; + } } else { diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index b730fe8bbb7..a77947eb345 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -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='
'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.
'; @@ -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='
'; - $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); - if ($mailfile->error) $mesg.='
'.$mailfile->error; + if ($mailfile->error) + { + $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); + $mesg.='
'.$mailfile->error; + } + else + { + $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } $mesg.='
'; } } @@ -936,7 +956,6 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').'
'; 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.'
'; $fac = New Facture($db); @@ -2772,7 +2790,7 @@ else print_titre($langs->trans('SendBillByMail')); $liste[0]=' '; - 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]=' '; - 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 '
'; } - } else { diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index a17b4b76a18..896839914c0 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -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 ) { diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index f55254df286..26655467484 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -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; diff --git a/htdocs/includes/modules/rapport/pdf_paiement.class.php b/htdocs/includes/modules/rapport/pdf_paiement.class.php index f4e9a1b0bf9..cebf05a3c9f 100644 --- a/htdocs/includes/modules/rapport/pdf_paiement.class.php +++ b/htdocs/includes/modules/rapport/pdf_paiement.class.php @@ -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")); diff --git a/htdocs/index.php b/htdocs/index.php index 309fcb3a7fb..bca69c96750 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -490,6 +490,7 @@ print ''; */ $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) diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 03c942e1957..83cf3c5972f 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -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 diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 7487d8de3a8..347d443c01a 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -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 diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index 6126ffe54a4..382741e6551 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -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 <$obj->email>"; - $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)." <".$this->email.">";; + } + 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)." <".$obj->email.">"; + $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 */