New: Module notification has been enhanced:
EMail use now language of target contact. Can also define a fixed email for notifications. Better error management
This commit is contained in:
parent
0fc1c85b34
commit
a1a03a8061
@ -292,8 +292,8 @@ class Notify
|
||||
|
||||
if ($mailfile->sendfile())
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_contact, objet_type, objet_id, email)";
|
||||
$sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$actiondefid.", ".$obj->cid.", '".$object_type."', ".$object->id.", '".$this->db->escape($obj->email)."')";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, objet_type, objet_id, email)";
|
||||
$sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$actiondefid.", ".$object->socid.", ".$obj->cid.", '".$object_type."', ".$object->id.", '".$this->db->escape($obj->email)."')";
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
@ -330,6 +330,10 @@ class Notify
|
||||
$param='NOTIFICATION_FIXEDEMAIL_'.$action;
|
||||
if (! empty($conf->global->$param))
|
||||
{
|
||||
$sendto = $conf->global->$param;
|
||||
$actiondefid = dol_getIdFromCode($this->db, $action, 'c_action_trigger', 'code', 'rowid');
|
||||
if ($actiondefid <= 0) dol_print_error($this->db, 'Failed to get id from code');
|
||||
|
||||
$object_type = '';
|
||||
$link = '';
|
||||
$num++;
|
||||
@ -417,8 +421,8 @@ class Notify
|
||||
|
||||
if ($mailfile->sendfile())
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_contact, objet_type, objet_id, email)";
|
||||
$sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$actiondefid.", ".$obj->cid.", '".$object_type."', ".$object->id.", '".$this->db->escape($obj->email)."')";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, objet_type, objet_id, email)";
|
||||
$sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$actiondefid.", ".$object->socid.", null, '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')";
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_CLASSIFYBILLED','Intervention set billed','Executed when a intervention is set to billed (when option FICHINTER_DISABLE_DETAILS is set)','ficheinter',19);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_SENTBYMAIL','Intervention sent by mail','Executed when a intervention is sent by mail','ficheinter',19);
|
||||
|
||||
ALTER TABLE llx_notify ADD COLUMN fk_soc integer NULL after fk_action;
|
||||
|
||||
ALTER TABLE llx_bank_account ADD COLUMN fk_user_author integer;
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ create table llx_notify
|
||||
tms timestamp,
|
||||
daten datetime, -- date de la notification
|
||||
fk_action integer NOT NULL,
|
||||
fk_soc integer NULL,
|
||||
fk_contact integer NULL,
|
||||
fk_user integer NULL,
|
||||
objet_type varchar(24) NOT NULL,
|
||||
|
||||
@ -1074,7 +1074,7 @@ ModuleCompanyCodeAquarium=Return an accountancy code built by:<br>%s followed by
|
||||
ModuleCompanyCodePanicum=Return an empty accountancy code.
|
||||
ModuleCompanyCodeDigitaria=Accountancy code depends on third party code. The code is composed of the character "C" in the first position followed by the first 5 characters of the third party code.
|
||||
UseNotifications=Use notifications
|
||||
NotificationsDesc=EMails notifications feature allows you to silently send automatic mail, for some Dolibarr events. Targets of notifications can be defined:<br>* per third parties contacts (customers or suppliers), one third party at time.<br>* or by setting a global target email address on this page.
|
||||
NotificationsDesc=EMails notifications feature allows you to silently send automatic mail, for some Dolibarr events. Targets of notifications can be defined:<br>* per third parties contacts (customers or suppliers), one third party at time.<br>* or by setting a global target email address on module setup page.
|
||||
ModelModules=Documents templates
|
||||
DocumentModelOdt=Generate documents from OpenDocuments templates (.ODT or .ODS files for OpenOffice, KOffice, TextEdit,...)
|
||||
WatermarkOnDraft=Watermark on draft document
|
||||
|
||||
@ -133,6 +133,6 @@ Notifications=Notifications
|
||||
NoNotificationsWillBeSent=No email notifications are planned for this event and company
|
||||
ANotificationsWillBeSent=1 notification will be sent by email
|
||||
SomeNotificationsWillBeSent=%s notifications will be sent by email
|
||||
AddNewNotification=Activate a new email notification request
|
||||
ListOfActiveNotifications=List all active email notification requests
|
||||
AddNewNotification=Activate a new email notification target
|
||||
ListOfActiveNotifications=List all active email notification targets
|
||||
ListOfNotificationsDone=List all email notifications sent
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -191,12 +191,10 @@ if ($result > 0)
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
// Help
|
||||
print '<br>'.$langs->trans("NotificationsDesc").'<br>';
|
||||
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
// Help
|
||||
print $langs->trans("NotificationsDesc").'<br><br>';
|
||||
|
||||
print "\n";
|
||||
|
||||
@ -372,19 +370,20 @@ if ($result > 0)
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("Target"),$_SERVER["PHP_SELF"],"c.lastname",'',$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.titre",'',$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"",'',$param,'',$sortfield,$sortorder);
|
||||
//print_liste_field_titre($langs->trans("Object"),$_SERVER["PHP_SELF"],"",'',$param,'"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"a.daten",'',$param,'align="right"',$sortfield,$sortorder);
|
||||
print '</tr>';
|
||||
|
||||
// List
|
||||
$sql = "SELECT n.rowid, n.daten, n.email, n.objet_type, n.objet_id,";
|
||||
$sql.= " c.rowid as id, c.lastname, c.firstname, c.email,";
|
||||
$sql = "SELECT n.rowid, n.daten, n.email, n.objet_type, n.objet_id as object_id, n.type,";
|
||||
$sql.= " c.rowid as id, c.lastname, c.firstname, c.email as contactemail,";
|
||||
$sql.= " a.code, a.label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."notify as n, ";
|
||||
$sql.= " ".MAIN_DB_PREFIX."socpeople as c";
|
||||
$sql.= " ".MAIN_DB_PREFIX."notify as n ";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as c ON n.fk_contact = c.rowid";
|
||||
$sql.= " WHERE a.rowid = n.fk_action";
|
||||
$sql.= " AND c.rowid = n.fk_contact";
|
||||
$sql.= " AND c.fk_soc = ".$object->id;
|
||||
$sql.= " AND n.fk_soc = ".$object->id;
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
@ -400,17 +399,37 @@ if ($result > 0)
|
||||
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$contactstatic->id=$obj->id;
|
||||
$contactstatic->lastname=$obj->lastname;
|
||||
$contactstatic->firstname=$obj->firstname;
|
||||
print '<tr '.$bc[$var].'><td>'.$contactstatic->getNomUrl(1);
|
||||
print $obj->email?' <'.$obj->email.'>':$langs->trans("NoMail");
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
if ($obj->id > 0)
|
||||
{
|
||||
$contactstatic->id=$obj->id;
|
||||
$contactstatic->lastname=$obj->lastname;
|
||||
$contactstatic->firstname=$obj->firstname;
|
||||
print $contactstatic->getNomUrl(1);
|
||||
print $obj->email?' <'.$obj->email.'>':$langs->trans("NoMail");
|
||||
}
|
||||
else
|
||||
{
|
||||
print $obj->email;
|
||||
}
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
$label=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label);
|
||||
print $label;
|
||||
print '</td>';
|
||||
// TODO Add link to object here
|
||||
print '<td>';
|
||||
if ($obj->type == 'email') print $langs->trans("Email");
|
||||
if ($obj->type == 'sms') print $langs->trans("Sms");
|
||||
print '</td>';
|
||||
// TODO Add link to object here for other types
|
||||
/*print '<td>';
|
||||
if ($obj->object_type == 'order')
|
||||
{
|
||||
$orderstatic->id=$obj->object_id;
|
||||
$orderstatic->ref=...
|
||||
print $orderstatic->getNomUrl(1);
|
||||
}
|
||||
print '</td>';*/
|
||||
// print
|
||||
print'<td align="right">'.dol_print_date($db->jdate($obj->daten), 'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
@ -427,7 +446,7 @@ if ($result > 0)
|
||||
}
|
||||
else dol_print_error('','RecordNotFound');
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user