Skip to content

Commit

Permalink
[ task #710 ] Envoi de mail
Browse files Browse the repository at this point in the history
  • Loading branch information
FHenry committed Mar 23, 2013
1 parent 7ce90c7 commit 8971e6f
Show file tree
Hide file tree
Showing 34 changed files with 400 additions and 231 deletions.
26 changes: 24 additions & 2 deletions htdocs/comm/propal.php
Expand Up @@ -526,7 +526,7 @@

// Envoi de la propal
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1);
if ($mailfile->error)
{
setEventMessage($mailfile->error, 'errors');
Expand Down Expand Up @@ -2238,12 +2238,34 @@
$formmail->substit['__PROPREF__']=$object->ref;
$formmail->substit['__SIGNATURE__']=$user->signature;
$formmail->substit['__PERSONALIZED__']='';
$formmail->substit['__CONTACTCIVNAME__']='';

//Find the good contact adress
$custcontact='';
$contactarr=array();
$contactarr=$object->liste_contact(-1,'external');

if (is_array($contactarr) && count($contactarr)>0) {
foreach($contactarr as $contact) {
if ($contact['libelle']==$langs->trans('TypeContact_propal_external_CUSTOMER')) {
$contactstatic=new Contact($db);
$contactstatic->fetch($contact['id']);
$custcontact=$contactstatic->getFullName($langs,1);
}
}

if (!empty($custcontact)) {
$formmail->substit['__CONTACTCIVNAME__']=$custcontact;
}
}

// Tableau des parametres complementaires
$formmail->param['action']='send';
$formmail->param['models']='propal_send';
$formmail->param['id']=$object->id;
$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;



// Init list of files
if (GETPOST("mode")=='init')
{
Expand Down
22 changes: 21 additions & 1 deletion htdocs/commande/fiche.php
Expand Up @@ -1212,7 +1212,7 @@

// Send mail
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1);
if ($mailfile->error)
{
$mesg='<div class="error">'.$mailfile->error.'</div>';
Expand Down Expand Up @@ -2442,6 +2442,26 @@
$formmail->substit['__ORDERREF__']=$object->ref;
$formmail->substit['__SIGNATURE__']=$user->signature;
$formmail->substit['__PERSONALIZED__']='';
$formmail->substit['__CONTACTCIVNAME__']='';

$custcontact='';
$contactarr=array();
$contactarr=$object->liste_contact(-1,'external');

if (is_array($contactarr) && count($contactarr)>0) {
foreach($contactarr as $contact) {
if ($contact['libelle']==$langs->trans('TypeContact_commande_external_CUSTOMER')) {
$contactstatic=new Contact($db);
$contactstatic->fetch($contact['id']);
$custcontact=$contactstatic->getFullName($langs,1);
}
}

if (!empty($custcontact)) {
$formmail->substit['__CONTACTCIVNAME__']=$custcontact;
}
}

// Tableau des parametres complementaires
$formmail->param['action']='send';
$formmail->param['models']='order_send';
Expand Down
25 changes: 25 additions & 0 deletions htdocs/compta/facture.php
Expand Up @@ -3531,6 +3531,31 @@
$formmail->substit['__FACREF__']=$object->ref;
$formmail->substit['__SIGNATURE__']=$user->signature;
$formmail->substit['__PERSONALIZED__']='';
$formmail->substit['__CONTACTCIVNAME__']='';

//Find the good contact adress
$custcontact='';
$contactarr=array();
$contactarr=$object->liste_contact(-1,'external');

if (is_array($contactarr) && count($contactarr)>0) {
foreach($contactarr as $contact) {
if ($contact['libelle']==$langs->trans('TypeContact_facture_external_BILLING')) {

require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';

$contactstatic=new Contact($db);
$contactstatic->fetch($contact['id']);
$custcontact=$contactstatic->getFullName($langs,1);
}
}

if (!empty($custcontact)) {
$formmail->substit['__CONTACTCIVNAME__']=$custcontact;
}
}


// Tableau des parametres complementaires du post
$formmail->param['action']=$action;
$formmail->param['models']=$modelmail;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/class/html.formmail.class.php
Expand Up @@ -596,7 +596,7 @@ function get_form($addfileaction='addfile',$removefileaction='removefile')
if (!empty($conf->global->FCKEDITOR_ENABLE_MAIL)) {
$this->withfckeditor=1;
}
$doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72);
$doleditor=new DolEditor('message',nl2br($defaultmessage),'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72);
$out.= $doleditor->Create(1);
}
$out.= "</td></tr>\n";
Expand Down
40 changes: 37 additions & 3 deletions htdocs/expedition/fiche.php
Expand Up @@ -412,7 +412,7 @@

$from = GETPOST('fromname','alpha') . ' <' . GETPOST('frommail','alpha') .'>';
$replyto = GETPOST('replytoname','alpha'). ' <' . GETPOST('replytomail','alpha').'>';
$message = GETPOST('message','alpha');
$message = GETPOST('message');
$sendtocc = GETPOST('sendtocc','alpha');
$deliveryreceipt = GETPOST('deliveryreceipt','alpha');

Expand Down Expand Up @@ -442,7 +442,7 @@

// Send mail
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1);
if ($mailfile->error)
{
$mesg='<div class="error">'.$mailfile->error.'</div>';
Expand Down Expand Up @@ -1293,7 +1293,7 @@
* Boutons actions
*/

if ($user->societe_id == 0)
if (($user->societe_id == 0) && ($action!='presend'))
{
print '<div class="tabsAction">';

Expand Down Expand Up @@ -1457,6 +1457,40 @@
$formmail->substit['__SHIPPINGREF__']=$object->ref;
$formmail->substit['__SIGNATURE__']=$user->signature;
$formmail->substit['__PERSONALIZED__']='';
$formmail->substit['__CONTACTCIVNAME__']='';

//Find the good contact adress
//Find the good contact adress
if ($typeobject == 'commande' && $object->$typeobject->id && ! empty($conf->commande->enabled)) {
$objectsrc=new Commande($db);
$objectsrc->fetch($object->$typeobject->id);
}
if ($typeobject == 'propal' && $object->$typeobject->id && ! empty($conf->propal->enabled)) {
$objectsrc=new Propal($db);
$objectsrc->fetch($object->$typeobject->id);
}
$custcontact='';
$contactarr=array();
$contactarr=$objectsrc->liste_contact(-1,'external');

if (is_array($contactarr) && count($contactarr)>0) {
foreach($contactarr as $contact) {

if ($contact['libelle']==$langs->trans('TypeContact_commande_external_CUSTOMER')) {

require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';

$contactstatic=new Contact($db);
$contactstatic->fetch($contact['id']);
$custcontact=$contactstatic->getFullName($langs,1);
}
}

if (!empty($custcontact)) {
$formmail->substit['__CONTACTCIVNAME__']=$custcontact;
}
}

// Tableau des parametres complementaires
$formmail->param['action']='send';
$formmail->param['models']='shipping_send';
Expand Down
34 changes: 28 additions & 6 deletions htdocs/fichinter/fiche.php
Expand Up @@ -662,7 +662,7 @@

$from = GETPOST('fromname','alpha') . ' <' . GETPOST('frommail','alpha') .'>';
$replyto = GETPOST('replytoname','alpha'). ' <' . GETPOST('replytomail','alpha').'>';
$message = GETPOST('message','alpha');
$message = GETPOST('message');
$sendtocc = GETPOST('sendtocc','alpha');
$deliveryreceipt = GETPOST('deliveryreceipt','alpha');

Expand Down Expand Up @@ -692,7 +692,7 @@

// Envoi de la propal
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1);
if ($mailfile->error)
{
$mesg='<div class="error">'.$mailfile->error.'</div>';
Expand All @@ -702,8 +702,8 @@
$result=$mailfile->sendfile();
if ($result)
{
$mesg='<div class="ok">'.$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)).'.</div>';

$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
setEventMessage($mesg);
$error=0;

// Initialisation donnees
Expand All @@ -729,7 +729,7 @@
{
// Redirect here
// This avoid sending mail twice if going out and then back to page
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&msg='.urlencode($mesg));
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
}
Expand Down Expand Up @@ -1365,7 +1365,7 @@

if ($user->societe_id == 0)
{
if ($action != 'editdescription')
if ($action != 'editdescription' && ($action != 'presend'))
{
// Validate
if ($object->statut == 0 && $user->rights->ficheinter->creer && count($object->lines) > 0)
Expand Down Expand Up @@ -1518,6 +1518,28 @@
$formmail->substit['__FICHINTERREF__']=$object->ref;
$formmail->substit['__SIGNATURE__']=$user->signature;
$formmail->substit['__PERSONALIZED__']='';
$formmail->substit['__CONTACTCIVNAME__']='';

//Find the good contact adress
$custcontact='';
$contactarr=array();
$contactarr=$object->liste_contact(-1,'external');

if (is_array($contactarr) && count($contactarr)>0) {
foreach($contactarr as $contact) {
if ($contact['libelle']==$langs->trans('TypeContact_fichinter_external_CUSTOMER')) {
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
$contactstatic=new Contact($db);
$contactstatic->fetch($contact['id']);
$custcontact=$contactstatic->getFullName($langs,1);
}
}

if (!empty($custcontact)) {
$formmail->substit['__CONTACTCIVNAME__']=$custcontact;
}
}

// Tableau des parametres complementaires
$formmail->param['action']='send';
$formmail->param['models']='fichinter_send';
Expand Down
52 changes: 37 additions & 15 deletions htdocs/fourn/commande/fiche.php
Expand Up @@ -746,40 +746,40 @@

// if (is_readable($file))
// {
if ($_POST['sendto'])
if (GETPOST('sendto','alpha'))
{
// Le destinataire a ete fourni via le champ libre
$sendto = $_POST['sendto'];
$sendto = GETPOST('sendto','alpha');
$sendtoid = 0;
}
elseif ($_POST['receiver'] != '-1')
elseif (GETPOST('receiver','alpha') != '-1')
{
// Recipient was provided from combo list
if ($_POST['receiver'] == 'thirdparty') // Id of third party
if (GETPOST('receiver','alpha') == 'thirdparty') // Id of third party
{
$sendto = $object->client->email;
$sendtoid = 0;
}
else // Id du contact
{
$sendto = $object->client->contact_get_property($_POST['receiver'],'email');
$sendtoid = $_POST['receiver'];
$sendto = $object->client->contact_get_property(GETPOST('receiver','alpha'),'email');
$sendtoid = GETPOST('receiver','alpha');
}
}

if (dol_strlen($sendto))
{
$langs->load("commercial");

$from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
$replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>';
$message = $_POST['message'];
$sendtocc = $_POST['sendtocc'];
$deliveryreceipt = $_POST['deliveryreceipt'];
$from = GETPOST('fromname','alpha') . ' <' . GETPOST('frommail','alpha') .'>';
$replyto = GETPOST('replytoname','alpha'). ' <' . GETPOST('replytomail','alpha').'>';
$message = GETPOST('message');
$sendtocc = GETPOST('sendtocc','alpha');
$deliveryreceipt = GETPOST('deliveryreceipt','alpha');

if ($action == 'send')
{
if (dol_strlen($_POST['subject'])) $subject=$_POST['subject'];
if (dol_strlen(GETPOST('subject'))) $subject=GETPOST('subject');
else $subject = $langs->transnoentities('CustomerOrder').' '.$object->ref;
$actiontypecode='AC_SUP_ORD';
$actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
Expand All @@ -803,7 +803,7 @@

// Send mail
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1);
if ($mailfile->error)
{
setEventMessage($mailfile->error, 'errors');
Expand Down Expand Up @@ -840,8 +840,8 @@
else
{
// Redirect here
// This avoid sending mail twice if going out and then back to page
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&mesg='.urlencode($mesg));
// This avoid sending mail twice if going out and then back to page
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
}
Expand Down Expand Up @@ -1908,6 +1908,28 @@
$formmail->substit['__ORDERREF__']=$object->ref;
$formmail->substit['__SIGNATURE__']=$user->signature;
$formmail->substit['__PERSONALIZED__']='';
$formmail->substit['__CONTACTCIVNAME__']='';

//Find the good contact adress
$custcontact='';
$contactarr=array();
$contactarr=$object->liste_contact(-1,'external');

if (is_array($contactarr) && count($contactarr)>0) {
foreach($contactarr as $contact) {
if ($contact['libelle']==$langs->trans('TypeContact_order_supplier_external_BILLING')) {
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
$contactstatic=new Contact($db);
$contactstatic->fetch($contact['id']);
$custcontact=$contactstatic->getFullName($langs,1);
}
}

if (!empty($custcontact)) {
$formmail->substit['__CONTACTCIVNAME__']=$custcontact;
}
}

// Tableau des parametres complementaires
$formmail->param['action']='send';
$formmail->param['models']='order_supplier_send';
Expand Down

0 comments on commit 8971e6f

Please sign in to comment.