mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-11 02:12:33 +01:00
Fix: Sending email from thirdparty must add event into agenda if option
is on.
This commit is contained in:
@@ -69,15 +69,18 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
||||
$subject='';$actionmsg='';$actionmsg2='';
|
||||
|
||||
$result=$object->fetch($id);
|
||||
|
||||
|
||||
$sendtosocid=0;
|
||||
if (method_exists($object,"fetch_thirdparty") && $object->element != 'societe')
|
||||
{
|
||||
$result=$object->fetch_thirdparty();
|
||||
$thirdparty=$object->thirdparty;
|
||||
$sendtosocid=$thirdparty->id;
|
||||
}
|
||||
else if ($object->element == 'societe')
|
||||
{
|
||||
$thirdparty=$object;
|
||||
$thirdparty=$object;
|
||||
$sendtosocid=$thirdparty->id;
|
||||
}
|
||||
else dol_print_error('','Use actions_sendmails.in.php for a type that is not supported');
|
||||
|
||||
@@ -114,28 +117,17 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
||||
$sendtocc = $_POST['sendtocc'];
|
||||
$deliveryreceipt = $_POST['deliveryreceipt'];
|
||||
|
||||
if ($action == 'send')
|
||||
if ($action == 'send' || $action == 'relance')
|
||||
{
|
||||
if (dol_strlen($_POST['subject'])) $subject = $_POST['subject'];
|
||||
$actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
|
||||
$actionmsg2=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
|
||||
if ($message)
|
||||
{
|
||||
$actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
|
||||
$actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n";
|
||||
$actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n";
|
||||
$actionmsg.=$message;
|
||||
}
|
||||
//$actionmsg2=$langs->transnoentities('Action'.$actiontypecode);
|
||||
}
|
||||
if ($action == 'relance')
|
||||
{
|
||||
if (dol_strlen($_POST['subject'])) $subject = $_POST['subject'];
|
||||
$actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
|
||||
if ($message) {
|
||||
$actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n";
|
||||
$actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n";
|
||||
$actionmsg.=$message;
|
||||
}
|
||||
//$actionmsg2=$langs->transnoentities('Action'.$actiontypecode);
|
||||
}
|
||||
|
||||
// Create form object
|
||||
@@ -162,7 +154,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
||||
$error=0;
|
||||
|
||||
// Initialisation donnees
|
||||
$object->sendtoid = $sendtoid;
|
||||
$object->socid = $sendtosocid; // To link to a company
|
||||
$object->sendtoid = $sendtoid; // To link to a contact/address
|
||||
$object->actiontypecode = $actiontypecode;
|
||||
$object->actionmsg = $actionmsg; // Long text
|
||||
$object->actionmsg2 = $actionmsg2; // Short text
|
||||
@@ -172,7 +165,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
||||
// Appel des triggers
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
$interface=new Interfaces($db);
|
||||
$result=$interface->run_triggers('THIRDPARTY_EMAILSENT',$object,$user,$langs,$conf);
|
||||
$result=$interface->run_triggers('COMPANY_SENTBYMAIL',$object,$user,$langs,$conf);
|
||||
if ($result < 0) {
|
||||
$error++; $this->errors=$interface->errors;
|
||||
}
|
||||
@@ -188,7 +181,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
||||
// This avoid sending mail twice if going out and then back to page
|
||||
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
|
||||
setEventMessage($mesg);
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id);
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -206,7 +199,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
||||
$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
|
||||
}
|
||||
$mesg.='</div>';
|
||||
|
||||
|
||||
setEventMessage($mesg,'warnings');
|
||||
$action = 'presend';
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class modAgenda extends DolibarrModules
|
||||
function __construct($db)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
$this->db = $db;
|
||||
$this->numero = 2400;
|
||||
|
||||
@@ -74,6 +74,7 @@ class modAgenda extends DolibarrModules
|
||||
// Constantes
|
||||
//-----------
|
||||
$this->const = array();
|
||||
$this->const[15] = array("MAIN_AGENDA_ACTIONAUTO_COMPANY_SENTBYMAIL","chaine","1");
|
||||
$this->const[0] = array("MAIN_AGENDA_ACTIONAUTO_COMPANY_CREATE","chaine","1");
|
||||
$this->const[1] = array("MAIN_AGENDA_ACTIONAUTO_CONTRACT_VALIDATE","chaine","1");
|
||||
$this->const[2] = array("MAIN_AGENDA_ACTIONAUTO_PROPAL_VALIDATE","chaine","1");
|
||||
@@ -166,7 +167,7 @@ class modAgenda extends DolibarrModules
|
||||
$this->rights[$r][2] = 'w';
|
||||
$this->rights[$r][3] = 0;
|
||||
$this->rights[$r][4] = 'export';
|
||||
|
||||
|
||||
// Main menu entries
|
||||
$this->menu = array(); // List of menus to add
|
||||
$r=0;
|
||||
@@ -376,7 +377,7 @@ class modAgenda extends DolibarrModules
|
||||
'a.datea'=>'Date','a.datea2'=>'Date','a.percent'=>'Numeric','a.fk_user_author'=>'List:user:name','a.fk_user_action'=>'List:user:name',
|
||||
'a.fk_user_done'=>"List:user:name","a.priority"=>"Numeric","a.fulldayevent"=>"Boolean","a.location"=>"Text",
|
||||
"a.fk_soc"=>"List:Societe:nom","a.fk_contact"=>"List:socpeople:name","a.fk_action"=>"List:c_actioncomm:libelle:code");
|
||||
|
||||
|
||||
$this->export_entities_array[$r]=array('a.id'=>'action','a.label'=>'action','a.datep'=>'action','a.datep2'=>'action',
|
||||
'a.datea'=>'action','a.datea2'=>'action','a.percent'=>'action','a.fk_user_author'=>'action','a.fk_user_action'=>'action',
|
||||
'a.fk_user_done'=>"action","a.priority"=>"action","a.fulldayevent"=>"action","a.location"=>"action",
|
||||
|
||||
@@ -140,6 +140,20 @@ class InterfaceActionsAuto
|
||||
$object->socid=$object->id;
|
||||
$ok=1;
|
||||
}
|
||||
elseif ($action == 'COMPANY_SENTBYMAIL')
|
||||
{
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("orders");
|
||||
$langs->load("agenda");
|
||||
|
||||
if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO';
|
||||
if (empty($object->actionmsg2)) dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR);
|
||||
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
|
||||
// Parameters $object->sendtoid defined by caller
|
||||
//$object->sendtoid=0;
|
||||
$ok=1;
|
||||
}
|
||||
elseif ($action == 'CONTRACT_VALIDATE')
|
||||
{
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
@@ -625,7 +639,7 @@ class InterfaceActionsAuto
|
||||
$error ="Failed to insert event : ".$actioncomm->error." ".join(',',$actioncomm->errors);
|
||||
$this->error=$error;
|
||||
$this->errors=$actioncomm->errors;
|
||||
|
||||
|
||||
dol_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang)
|
||||
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (4,'ORDER_SUPPLIER_REFUSE','Supplier order request refused','Executed when a supplier order is refused','order_supplier',13);
|
||||
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (5,'ORDER_VALIDATE','Customer order validate','Executed when a customer order is validated','commande',4);
|
||||
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (6,'PROPAL_VALIDATE','Customer proposal validated','Executed when a commercial proposal is validated','propal',2);
|
||||
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (9,'COMPANY_SENTBYMAIL','Mails sent from third party card','Executed when you send email from third party card','societe',1);
|
||||
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (10,'COMPANY_CREATE','Third party created','Executed when a third party is created','societe',1);
|
||||
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (11,'CONTRACT_VALIDATE','Contract validated','Executed when a contract is validated','contrat',18);
|
||||
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (12,'PROPAL_SENTBYMAIL','Commercial proposal sent by mail','Executed when a commercial proposal is sent by mail','propal',3);
|
||||
|
||||
@@ -298,3 +298,6 @@ ALTER TABLE llx_facture_fourn ADD fk_mode_reglement integer NULL AFTER fk_cond_r
|
||||
ALTER TABLE llx_facture_fourn MODIFY COLUMN fk_mode_reglement integer NULL;
|
||||
ALTER TABLE llx_facture_fourn MODIFY COLUMN fk_cond_reglement integer NULL;
|
||||
|
||||
|
||||
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (9,'COMPANY_SENTBYMAIL','Mails sent from third party card','Executed when you send email from third party card','societe',1);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ AutoActions= Alimentation automatique
|
||||
AgendaAutoActionDesc= Définissez dans cet onglet les événements pour lesquels Dolibarr créera automatiquement une action dans l'agenda. Si aucune case n'est cochée (par défaut), seules les actions manuelles seront incluses dans l'agenda.
|
||||
AgendaSetupOtherDesc= Cette page permet de configurer quelques options permettant d'exporter une vue de votre agenda Dolibarr vers un calendrier externe (Thunderbird, Google calendar, …)
|
||||
AgendaExtSitesDesc=Cette page permet d'ajouter des sources de calendriers externes pour les visualiser au sein de l'agenda Dolibarr.
|
||||
ActionsEvents= Événements pour lesquels Dolibarr doit créer une action dans l'agenda en automatique.
|
||||
ActionsEvents= Événements pour lesquels Dolibarr doit insérer un évènement dans l'agenda en automatique.
|
||||
PropalValidatedInDolibarr= Proposition %s validée
|
||||
InvoiceValidatedInDolibarr= Facture %s validée
|
||||
InvoiceBackToDraftInDolibarr=Facture %s repassée en brouillon
|
||||
|
||||
@@ -450,13 +450,14 @@ if (empty($reshook))
|
||||
$result = $object->set_parent(GETPOST('editparentcompany','int'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Actions to send emails
|
||||
$id=$socid;
|
||||
$actiontypecode='AC_OTH_AUTO';
|
||||
$paramname='socid';
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Generate document
|
||||
*/
|
||||
@@ -1778,8 +1779,15 @@ else
|
||||
*/
|
||||
print '<div class="tabsAction">'."\n";
|
||||
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendMail').'</a></div>';
|
||||
|
||||
if (! empty($object->email))
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendMail').'</a></div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEmailDefined")).'">'.$langs->trans('SendMail').'</a></div>';
|
||||
}
|
||||
|
||||
if ($user->rights->societe->creer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a></div>'."\n";
|
||||
@@ -1799,7 +1807,7 @@ else
|
||||
|
||||
print '</div>'."\n";
|
||||
|
||||
|
||||
|
||||
if ($action == 'presend')
|
||||
{
|
||||
/*
|
||||
@@ -1845,9 +1853,9 @@ else
|
||||
$contactarr=array();
|
||||
$contactarr=$object->liste_contact(-1,'external');
|
||||
|
||||
if (is_array($contactarr) && count($contactarr)>0)
|
||||
if (is_array($contactarr) && count($contactarr)>0)
|
||||
{
|
||||
foreach($contactarr as $contact)
|
||||
foreach($contactarr as $contact)
|
||||
{
|
||||
if ($contact['libelle']==$langs->trans('TypeContact_facture_external_BILLING')) {
|
||||
|
||||
@@ -1884,13 +1892,13 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC))
|
||||
{
|
||||
print '<div class="fichecenter"><div class="fichethirdleft">';
|
||||
//print '<table width="100%"><tr><td valign="top" width="50%">';
|
||||
print '<a name="builddoc"></a>'; // ancre
|
||||
|
||||
|
||||
/*
|
||||
* Documents generes
|
||||
*/
|
||||
@@ -1898,36 +1906,36 @@ else
|
||||
$urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id;
|
||||
$genallowed=$user->rights->societe->creer;
|
||||
$delallowed=$user->rights->societe->supprimer;
|
||||
|
||||
|
||||
$var=true;
|
||||
|
||||
|
||||
$somethingshown=$formfile->show_documents('company',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang);
|
||||
|
||||
|
||||
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
||||
|
||||
|
||||
|
||||
|
||||
print '</div></div></div>';
|
||||
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
|
||||
print '<div class="fichecenter"><br></div>';
|
||||
|
||||
|
||||
// Subsidiaries list
|
||||
$result=show_subsidiaries($conf,$langs,$db,$object);
|
||||
|
||||
|
||||
// Contacts list
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
$result=show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
|
||||
}
|
||||
|
||||
|
||||
// Addresses list
|
||||
if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))
|
||||
{
|
||||
$result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
|
||||
}
|
||||
|
||||
|
||||
// Projects list
|
||||
$result=show_projects($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user