New: Module notification can send mail on order or proposal validation.

This commit is contained in:
Laurent Destailleur 2010-01-09 01:56:33 +00:00
parent 6404866bff
commit 5558b0d081
6 changed files with 220 additions and 181 deletions

View File

@ -114,6 +114,36 @@ class InterfaceNotification
$notify->send($action_notify, $object->socid, $mesg, 'facture', $object->id, $filepdf); $notify->send($action_notify, $object->socid, $mesg, 'facture', $object->id, $filepdf);
} }
elseif ($action == 'ORDER_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$action_notify = 'NOTIFY_VAL_ORDER';
$ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
if (! file_exists($filepdf)) $filepdf='';
$langs->load("other");
$mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated",$object->ref);
$notify = new Notify($this->db);
$notify->send($action_notify, $object->socid, $mesg, 'order', $object->id, $filepdf);
}
elseif ($action == 'PROPOSAL_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$action_notify = 'NOTIFY_VAL_PROPOSAL';
$ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->propal->dir_output . '/' . $ref . '/' . $ref . '.pdf';
if (! file_exists($filepdf)) $filepdf='';
$langs->load("other");
$mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$object->ref);
$notify = new Notify($this->db);
$notify->send($action_notify, $object->socid, $mesg, 'propal', $object->id, $filepdf);
}
elseif ($action == 'FICHEINTER_VALIDATE') elseif ($action == 'FICHEINTER_VALIDATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);

View File

@ -36,3 +36,5 @@ insert into llx_action_def (rowid,code,titre,description,objet_type) values (1,'
insert into llx_action_def (rowid,code,titre,description,objet_type) values (2,'NOTIFY_VAL_FAC','Validation facture client','Executed when a customer invoice is approved','facture'); insert into llx_action_def (rowid,code,titre,description,objet_type) values (2,'NOTIFY_VAL_FAC','Validation facture client','Executed when a customer invoice is approved','facture');
insert into llx_action_def (rowid,code,titre,description,objet_type) values (3,'NOTIFY_APP_ORDER_SUPPLIER','Approbation commande fournisseur','Executed when a supplier order is approved','order_supplier'); insert into llx_action_def (rowid,code,titre,description,objet_type) values (3,'NOTIFY_APP_ORDER_SUPPLIER','Approbation commande fournisseur','Executed when a supplier order is approved','order_supplier');
insert into llx_action_def (rowid,code,titre,description,objet_type) values (4,'NOTIFY_REF_ORDER_SUPPLIER','Refus commande fournisseur','Executed when a supplier order is refused','order_supplier'); insert into llx_action_def (rowid,code,titre,description,objet_type) values (4,'NOTIFY_REF_ORDER_SUPPLIER','Refus commande fournisseur','Executed when a supplier order is refused','order_supplier');
insert into llx_action_def (rowid,code,titre,description,objet_type) values (5,'NOTIFY_VAL_ORDER','Validation commande client','Executed when a customer order is validated','order');
insert into llx_action_def (rowid,code,titre,description,objet_type) values (6,'NOTIFY_VAL_PROPAL','Validation proposition client','Executed when a commercial proposal is validated','propal');

View File

@ -33,3 +33,6 @@ ALTER TABLE llx_facture_fourn_det MODIFY COLUMN qty real;
ALTER TABLE llx_projet ADD COLUMN datee DATE AFTER dateo; ALTER TABLE llx_projet ADD COLUMN datee DATE AFTER dateo;
insert into llx_action_def (rowid,code,titre,description,objet_type) values (5,'NOTIFY_VAL_ORDER','Validation commande client','Executed when a customer order is validated','order');
insert into llx_action_def (rowid,code,titre,description,objet_type) values (6,'NOTIFY_VAL_PROPAL','Validation proposition client','Executed when a commercial proposal is validated','propal');

View File

@ -26,9 +26,11 @@ DateToBirth=Date to birth
BirthdayAlertOn = birthday alert active BirthdayAlertOn = birthday alert active
BirthdayAlertOff = birthday alert inactive BirthdayAlertOff = birthday alert inactive
Notify_NOTIFY_VAL_FICHINTER=Intervention validated Notify_NOTIFY_VAL_FICHINTER=Intervention validated
Notify_NOTIFY_VAL_FAC=Invoice validated Notify_NOTIFY_VAL_FAC=Customer invoice validated
Notify_NOTIFY_APP_ORDER_SUPPLIER=Supplier order approved Notify_NOTIFY_APP_ORDER_SUPPLIER=Supplier order approved
Notify_NOTIFY_REF_ORDER_SUPPLIER=Supplier order refused Notify_NOTIFY_REF_ORDER_SUPPLIER=Supplier order refused
Notify_NOTIFY_VAL_ORDER=Customer order validated
Notify_NOTIFY_VAL_PROPAL=Customer proposal validated
NbOfAttachedFiles=Number of attached files/documents NbOfAttachedFiles=Number of attached files/documents
TotalSizeOfAttachedFiles=Total size of attached files/documents TotalSizeOfAttachedFiles=Total size of attached files/documents
MaxSize=Maximum size MaxSize=Maximum size

View File

@ -26,9 +26,11 @@ DateToBirth=Date de naissance
BirthdayAlertOn = alerte anniversaire active BirthdayAlertOn = alerte anniversaire active
BirthdayAlertOff = alerte anniversaire inactive BirthdayAlertOff = alerte anniversaire inactive
Notify_NOTIFY_VAL_FICHINTER=Validation fiche intervention Notify_NOTIFY_VAL_FICHINTER=Validation fiche intervention
Notify_NOTIFY_VAL_FAC=Validation facture Notify_NOTIFY_VAL_FAC=Validation facture client
Notify_NOTIFY_APP_ORDER_SUPPLIER=Approbation commande fournisseur Notify_NOTIFY_APP_ORDER_SUPPLIER=Approbation commande fournisseur
Notify_NOTIFY_REF_ORDER_SUPPLIER=Refus commande fournisseur Notify_NOTIFY_REF_ORDER_SUPPLIER=Refus commande fournisseur
Notify_NOTIFY_VAL_ORDER=Validation commande client
Notify_NOTIFY_VAL_PROPAL=Validation proposition commerciale client
NbOfAttachedFiles=Nombre de fichiers/documents liés NbOfAttachedFiles=Nombre de fichiers/documents liés
TotalSizeOfAttachedFiles=Taille total fichiers/documents liés TotalSizeOfAttachedFiles=Taille total fichiers/documents liés
MaxSize=Taille maximum MaxSize=Taille maximum

View File

@ -108,12 +108,12 @@ class Notify
/** /**
* \brief Check if notification are active for couple action/company. * \brief Check if notification are active for couple action/company.
* If yes, send mail and save trace. * If yes, send mail and save trace into llx_notify.
* \param action Code of action to check and send (list in llx_action_def) * \param action Code of action to check and send (list in llx_action_def)
* \param socid Id of third party * \param socid Id of third party
* \param texte Message to send * \param texte Message to send
* \param objet_type Type of object notification deals on * \param objet_type Type of object the notification deals on (facture, order, propal, order_supplier...). Just for log in llx_notify.
* \param objet_id Id of object notification deals on * \param objet_id Id of object the notification deals on
* \param file Attach a file * \param file Attach a file
* \return int <0 if KO or number of changes if OK * \return int <0 if KO or number of changes if OK
*/ */