New: unified action and event with trigger name

This commit is contained in:
Regis Houssin 2011-06-04 23:31:29 +00:00
parent 994d41aad1
commit 63b7f070fc

View File

@ -103,7 +103,6 @@ class InterfaceNotification
{ {
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);
$action_notify = 'NOTIFY_VAL_FAC';
$ref = dol_sanitizeFileName($object->ref); $ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf'; $filepdf = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
if (! file_exists($filepdf)) $filepdf=''; if (! file_exists($filepdf)) $filepdf='';
@ -112,14 +111,13 @@ class InterfaceNotification
$mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated",$object->ref); $mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated",$object->ref);
$notify = new Notify($this->db); $notify = new Notify($this->db);
$notify->send($action_notify, $object->socid, $mesg, 'facture', $object->id, $filepdf); $notify->send($action, $object->socid, $mesg, 'facture', $object->id, $filepdf);
} }
elseif ($action == 'ORDER_VALIDATE') elseif ($action == 'ORDER_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);
$action_notify = 'NOTIFY_VAL_ORDER';
$ref = dol_sanitizeFileName($object->ref); $ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf'; $filepdf = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
if (! file_exists($filepdf)) $filepdf=''; if (! file_exists($filepdf)) $filepdf='';
@ -128,14 +126,13 @@ class InterfaceNotification
$mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated",$object->ref); $mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated",$object->ref);
$notify = new Notify($this->db); $notify = new Notify($this->db);
$notify->send($action_notify, $object->socid, $mesg, 'order', $object->id, $filepdf); $notify->send($action, $object->socid, $mesg, 'order', $object->id, $filepdf);
} }
elseif ($action == 'PROPAL_VALIDATE') elseif ($action == 'PROPAL_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);
$action_notify = 'NOTIFY_VAL_PROPAL';
$ref = dol_sanitizeFileName($object->ref); $ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->propale->dir_output . '/' . $ref . '/' . $ref . '.pdf'; $filepdf = $conf->propale->dir_output . '/' . $ref . '/' . $ref . '.pdf';
if (! file_exists($filepdf)) $filepdf=''; if (! file_exists($filepdf)) $filepdf='';
@ -144,14 +141,13 @@ class InterfaceNotification
$mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$object->ref); $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$object->ref);
$notify = new Notify($this->db); $notify = new Notify($this->db);
$notify->send($action_notify, $object->socid, $mesg, 'propal', $object->id, $filepdf); $notify->send($action, $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);
$action_notify = 'NOTIFY_VAL_FICHINTER';
$ref = dol_sanitizeFileName($object->ref); $ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf'; $filepdf = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
if (! file_exists($filepdf)) $filepdf=''; if (! file_exists($filepdf)) $filepdf='';
@ -160,14 +156,13 @@ class InterfaceNotification
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated",$object->ref); $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated",$object->ref);
$notify = new Notify($this->db); $notify = new Notify($this->db);
$notify->send($action_notify, $object->socid, $mesg, 'ficheinter', $object->id, $filepdf); $notify->send($action, $object->socid, $mesg, 'ficheinter', $object->id, $filepdf);
} }
elseif ($action == 'ORDER_SUPPLIER_APPROVE') elseif ($action == 'ORDER_SUPPLIER_APPROVE')
{ {
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);
$action_notify = 'NOTIFY_APP_ORDER_SUPPLIER';
$ref = dol_sanitizeFileName($object->ref); $ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->fournisseur->dir_output . '/commande/' . $ref . '/' . $ref . '.pdf'; $filepdf = $conf->fournisseur->dir_output . '/commande/' . $ref . '/' . $ref . '.pdf';
if (! file_exists($filepdf)) $filepdf=''; if (! file_exists($filepdf)) $filepdf='';
@ -176,14 +171,13 @@ class InterfaceNotification
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; $mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
$notify = new Notify($this->db); $notify = new Notify($this->db);
$notify->send($action_notify, $object->socid, $mesg, 'order_supplier', $object->id, $filepdf); $notify->send($action, $object->socid, $mesg, 'order_supplier', $object->id, $filepdf);
} }
elseif ($action == 'ORDER_SUPPLIER_REFUSE') elseif ($action == 'ORDER_SUPPLIER_REFUSE')
{ {
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);
$action_notify = 'NOTIFY_REF_ORDER_SUPPLIER';
$ref = dol_sanitizeFileName($object->ref); $ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->fournisseur->dir_output . '/commande/' . $ref . '/' . $ref . '.pdf'; $filepdf = $conf->fournisseur->dir_output . '/commande/' . $ref . '/' . $ref . '.pdf';
if (! file_exists($filepdf)) $filepdf=''; if (! file_exists($filepdf)) $filepdf='';
@ -192,7 +186,7 @@ class InterfaceNotification
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; $mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
$notify = new Notify($this->db); $notify = new Notify($this->db);
$notify->send($action_notify, $object->socid, $mesg, 'order_supplier', $object->id, $filepdf); $notify->send($action, $object->socid, $mesg, 'order_supplier', $object->id, $filepdf);
} }
// If not found // If not found