forked from Wavyzz/dolibarr
Fix: Debug module notification.
New: Can use email notification when validating proposal or orders.
This commit is contained in:
@@ -973,7 +973,27 @@ if ($id > 0 || ! empty($ref))
|
|||||||
*/
|
*/
|
||||||
if ($_GET['action'] == 'validate')
|
if ($_GET['action'] == 'validate')
|
||||||
{
|
{
|
||||||
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?propalid='.$propal->id, $langs->trans('ValidateProp'), $langs->trans('ConfirmValidateProp'), 'confirm_validate','',0,1);
|
// on verifie si l'objet est en numerotation provisoire
|
||||||
|
$ref = substr($propal->ref, 1, 4);
|
||||||
|
if ($ref == 'PROV')
|
||||||
|
{
|
||||||
|
$numref = $propal->getNextNumRef($soc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$numref = $propal->ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
$text=$langs->trans('ConfirmValidateProp',$numref);
|
||||||
|
if ($conf->notification->enabled)
|
||||||
|
{
|
||||||
|
require_once(DOL_DOCUMENT_ROOT ."/notify.class.php");
|
||||||
|
$notify=new Notify($db);
|
||||||
|
$text.='<br>';
|
||||||
|
$text.=$notify->confirmMessage('NOTIFY_VAL_PROPAL',$propal->socid);
|
||||||
|
}
|
||||||
|
|
||||||
|
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?propalid='.$propal->id, $langs->trans('ValidateProp'), $text, 'confirm_validate','',0,1);
|
||||||
if ($ret == 'html') print '<br>';
|
if ($ret == 'html') print '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1242,18 +1242,25 @@ else
|
|||||||
*/
|
*/
|
||||||
if ($_GET['action'] == 'validate')
|
if ($_GET['action'] == 'validate')
|
||||||
{
|
{
|
||||||
// on verifie si la facture est en numerotation provisoire
|
// on verifie si l'objet est en numerotation provisoire
|
||||||
$ref = substr($commande->ref, 1, 4);
|
$ref = substr($commande->ref, 1, 4);
|
||||||
if ($ref == 'PROV')
|
if ($ref == 'PROV')
|
||||||
{
|
{
|
||||||
$num = $commande->getNextNumRef($soc);
|
$numref = $commande->getNextNumRef($soc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$num = $commande->ref;
|
$numref = $commande->ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
$text=$langs->trans('ConfirmValidateOrder',$num);
|
$text=$langs->trans('ConfirmValidateOrder',$numref);
|
||||||
|
if ($conf->notification->enabled)
|
||||||
|
{
|
||||||
|
require_once(DOL_DOCUMENT_ROOT ."/notify.class.php");
|
||||||
|
$notify=new Notify($db);
|
||||||
|
$text.='<br>';
|
||||||
|
$text.=$notify->confirmMessage('NOTIFY_VAL_ORDER',$commande->socid);
|
||||||
|
}
|
||||||
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', '', 0, 1);
|
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', '', 0, 1);
|
||||||
if ($ret == 'html') print '<br>';
|
if ($ret == 'html') print '<br>';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2060,7 +2060,7 @@ else
|
|||||||
// Confirmation de la validation
|
// Confirmation de la validation
|
||||||
if ($_GET['action'] == 'valid')
|
if ($_GET['action'] == 'valid')
|
||||||
{
|
{
|
||||||
// on verifie si la facture est en numerotation provisoire
|
// on verifie si l'objet est en numerotation provisoire
|
||||||
$facref = substr($fac->ref, 1, 4);
|
$facref = substr($fac->ref, 1, 4);
|
||||||
if ($facref == 'PROV')
|
if ($facref == 'PROV')
|
||||||
{
|
{
|
||||||
@@ -2070,21 +2070,21 @@ else
|
|||||||
$fac->date=gmmktime();
|
$fac->date=gmmktime();
|
||||||
$fac->date_lim_reglement=$fac->calculate_date_lim_reglement();
|
$fac->date_lim_reglement=$fac->calculate_date_lim_reglement();
|
||||||
}
|
}
|
||||||
$numfa = $fac->getNextNumRef($soc);
|
$numref = $fac->getNextNumRef($soc);
|
||||||
//$fac->date=$savdate;
|
//$fac->date=$savdate;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$numfa = $fac->ref;
|
$numref = $fac->ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
$text=$langs->trans('ConfirmValidateBill',$numfa);
|
$text=$langs->trans('ConfirmValidateBill',$numref);
|
||||||
if ($conf->notification->enabled)
|
if ($conf->notification->enabled)
|
||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/notify.class.php");
|
require_once(DOL_DOCUMENT_ROOT ."/notify.class.php");
|
||||||
$notify=new Notify($db);
|
$notify=new Notify($db);
|
||||||
$text.='<br>';
|
$text.='<br>';
|
||||||
$text.=$notify->confirmMessage(2,$fac->socid);
|
$text.=$notify->confirmMessage('NOTIFY_VAL_FAC',$fac->socid);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id,$langs->trans('ValidateBill'),$text,'confirm_valid','',0,($conf->notification->enabled?0:2));
|
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id,$langs->trans('ValidateBill'),$text,'confirm_valid','',0,($conf->notification->enabled?0:2));
|
||||||
|
|||||||
@@ -1,206 +1,206 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/includes/triggers/interface_modNotification_notification.class.php
|
* \file htdocs/includes/triggers/interface_modNotification_notification.class.php
|
||||||
* \ingroup notification
|
* \ingroup notification
|
||||||
* \brief Fichier de gestion des notifications sur evenement Dolibarr
|
* \brief Fichier de gestion des notifications sur evenement Dolibarr
|
||||||
* \version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class InterfaceNotification
|
* \class InterfaceNotification
|
||||||
* \brief Classe des fonctions triggers des actions personalisees du workflow
|
* \brief Classe des fonctions triggers des actions personalisees du workflow
|
||||||
*/
|
*/
|
||||||
class InterfaceNotification
|
class InterfaceNotification
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Constructeur.
|
* \brief Constructeur.
|
||||||
* \param DB Handler d'acces base
|
* \param DB Handler d'acces base
|
||||||
*/
|
*/
|
||||||
function InterfaceNotification($DB)
|
function InterfaceNotification($DB)
|
||||||
{
|
{
|
||||||
$this->db = $DB ;
|
$this->db = $DB ;
|
||||||
|
|
||||||
$this->name = preg_replace('/^Interface/i','',get_class($this));
|
$this->name = preg_replace('/^Interface/i','',get_class($this));
|
||||||
$this->family = "notification";
|
$this->family = "notification";
|
||||||
$this->description = "Triggers of this module send email notifications according to Notification module setup.";
|
$this->description = "Triggers of this module send email notifications according to Notification module setup.";
|
||||||
$this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version
|
$this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoi nom du lot de triggers
|
* \brief Renvoi nom du lot de triggers
|
||||||
* \return string Nom du lot de triggers
|
* \return string Nom du lot de triggers
|
||||||
*/
|
*/
|
||||||
function getName()
|
function getName()
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoi descriptif du lot de triggers
|
* \brief Renvoi descriptif du lot de triggers
|
||||||
* \return string Descriptif du lot de triggers
|
* \return string Descriptif du lot de triggers
|
||||||
*/
|
*/
|
||||||
function getDesc()
|
function getDesc()
|
||||||
{
|
{
|
||||||
return $this->description;
|
return $this->description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoi version du lot de triggers
|
* \brief Renvoi version du lot de triggers
|
||||||
* \return string Version du lot de triggers
|
* \return string Version du lot de triggers
|
||||||
*/
|
*/
|
||||||
function getVersion()
|
function getVersion()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
if ($this->version == 'experimental') return $langs->trans("Experimental");
|
if ($this->version == 'experimental') return $langs->trans("Experimental");
|
||||||
elseif ($this->version == 'dolibarr') return DOL_VERSION;
|
elseif ($this->version == 'dolibarr') return DOL_VERSION;
|
||||||
elseif ($this->version) return $this->version;
|
elseif ($this->version) return $this->version;
|
||||||
else return $langs->trans("Unknown");
|
else return $langs->trans("Unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Fonction appelee lors du declenchement d'un evenement Dolibarr.
|
* \brief Fonction appelee lors du declenchement d'un evenement Dolibarr.
|
||||||
* D'autres fonctions run_trigger peuvent etre presentes dans includes/triggers
|
* D'autres fonctions run_trigger peuvent etre presentes dans includes/triggers
|
||||||
* \param action Code de l'evenement
|
* \param action Code de l'evenement
|
||||||
* \param object Objet concerne
|
* \param object Objet concerne
|
||||||
* \param user Objet user
|
* \param user Objet user
|
||||||
* \param lang Objet lang
|
* \param lang Objet lang
|
||||||
* \param conf Objet conf
|
* \param conf Objet conf
|
||||||
* \return int <0 si ko, 0 si aucune action faite, >0 si ok
|
* \return int <0 si ko, 0 si aucune action faite, >0 si ok
|
||||||
*/
|
*/
|
||||||
function run_trigger($action,$object,$user,$langs,$conf)
|
function run_trigger($action,$object,$user,$langs,$conf)
|
||||||
{
|
{
|
||||||
// Mettre ici le code a executer en reaction de l'action
|
// Mettre ici le code a executer en reaction de l'action
|
||||||
// Les donnees de l'action sont stockees dans $object
|
// Les donnees de l'action sont stockees dans $object
|
||||||
|
|
||||||
// Si module notification non actif, on ne fait rien
|
// Si module notification non actif, on ne fait rien
|
||||||
if (! $conf->notification->enabled) return 0;
|
if (! $conf->notification->enabled) return 0;
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT .'/notify.class.php');
|
require_once(DOL_DOCUMENT_ROOT .'/notify.class.php');
|
||||||
|
|
||||||
if ($action == 'BILL_VALIDATE')
|
if ($action == 'BILL_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_FAC';
|
$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='';
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
$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_notify, $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';
|
$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='';
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
$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_notify, $object->socid, $mesg, 'order', $object->id, $filepdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif ($action == 'PROPOSAL_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_PROPOSAL';
|
$action_notify = 'NOTIFY_VAL_PROPAL';
|
||||||
$ref = dol_sanitizeFileName($object->ref);
|
$ref = dol_sanitizeFileName($object->ref);
|
||||||
$filepdf = $conf->propal->dir_output . '/' . $ref . '/' . $ref . '.pdf';
|
$filepdf = $conf->propal->dir_output . '/' . $ref . '/' . $ref . '.pdf';
|
||||||
if (! file_exists($filepdf)) $filepdf='';
|
if (! file_exists($filepdf)) $filepdf='';
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
$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_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);
|
||||||
|
|
||||||
$action_notify = 'NOTIFY_VAL_FICHINTER';
|
$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='';
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
$mesg = $langs->transnoentitiesnoconv("EMailTextIntervnetionValidated",$object->ref);
|
$mesg = $langs->transnoentitiesnoconv("EMailTextIntervnetionValidated",$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_notify, $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';
|
$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='';
|
||||||
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
|
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
|
||||||
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy",$object->ref,$user->fullname);
|
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy",$object->ref,$user->fullname);
|
||||||
$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_notify, $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';
|
$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='';
|
||||||
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
|
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
|
||||||
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy",$object->ref,$user->fullname);
|
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy",$object->ref,$user->fullname);
|
||||||
$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_notify, $object->socid, $mesg, 'order_supplier', $object->id, $filepdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not found
|
// If not found
|
||||||
/*
|
/*
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' was ran by ".__FILE__." but no handler found for this action.");
|
dol_syslog("Trigger '".$this->name."' for action '$action' was ran by ".__FILE__." but no handler found for this action.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ 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;
|
||||||
|
|
||||||
|
ALTER TABLE llx_notify ADD COLUMN email VARCHAR(255);
|
||||||
|
|
||||||
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 (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');
|
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');
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
-- ===================================================================
|
-- ===================================================================
|
||||||
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
-- Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
--
|
--
|
||||||
-- This program is free software; you can redistribute it and/or modify
|
-- This program is free software; you can redistribute it and/or modify
|
||||||
-- it under the terms of the GNU General Public License as published by
|
-- it under the terms of the GNU General Public License as published by
|
||||||
@@ -26,5 +27,6 @@ create table llx_notify
|
|||||||
fk_action integer NOT NULL,
|
fk_action integer NOT NULL,
|
||||||
fk_contact integer NOT NULL,
|
fk_contact integer NOT NULL,
|
||||||
objet_type varchar(24) NOT NULL,
|
objet_type varchar(24) NOT NULL,
|
||||||
objet_id integer NOT NULL
|
objet_id integer NOT NULL,
|
||||||
|
email varchar(255)
|
||||||
)type=innodb;
|
)type=innodb;
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ class Notify
|
|||||||
/**
|
/**
|
||||||
* \brief Renvoie le message signalant les notifications qui auront lieu sur
|
* \brief Renvoie le message signalant les notifications qui auront lieu sur
|
||||||
* un evenement pour affichage dans texte de confirmation evenement.
|
* un evenement pour affichage dans texte de confirmation evenement.
|
||||||
|
* \param action Id of action in llx_action_def
|
||||||
|
* \param socid Id of third party
|
||||||
* \return string Message
|
* \return string Message
|
||||||
*/
|
*/
|
||||||
function confirmMessage($action,$socid)
|
function confirmMessage($action,$socid)
|
||||||
@@ -76,8 +78,10 @@ class Notify
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoie le nombre de notifications configures pour l'action et la societe donnee
|
* \brief Return number of notifications activated for action code and third party
|
||||||
* \return int <0 si ko, sinon nombre de notifications definies
|
* \param action Code of action in llx_action_def (new usage) or Id of action in llx_action_def (old usage)
|
||||||
|
* \param socid Id of third party
|
||||||
|
* \return int <0 si ko, sinon nombre de notifications definies
|
||||||
*/
|
*/
|
||||||
function countDefinedNotifications($action,$socid)
|
function countDefinedNotifications($action,$socid)
|
||||||
{
|
{
|
||||||
@@ -87,7 +91,8 @@ class Notify
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c, ".MAIN_DB_PREFIX."action_def as a, ".MAIN_DB_PREFIX."notify_def as n, ".MAIN_DB_PREFIX."societe as s";
|
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c, ".MAIN_DB_PREFIX."action_def as a, ".MAIN_DB_PREFIX."notify_def as n, ".MAIN_DB_PREFIX."societe as s";
|
||||||
$sql.= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
|
$sql.= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
|
||||||
$sql.= " AND n.fk_soc = s.rowid";
|
$sql.= " AND n.fk_soc = s.rowid";
|
||||||
$sql.= " AND n.fk_action = ".$action;
|
if (is_numeric($action)) $sql.= " AND n.fk_action = ".$action; // Old usage
|
||||||
|
else $sql.= " AND a.code = '".$action."'"; // New usage
|
||||||
$sql.= " AND s.rowid = ".$socid;
|
$sql.= " AND s.rowid = ".$socid;
|
||||||
|
|
||||||
dol_syslog("Notify.class::countDefinedNotifications $action, $socid");
|
dol_syslog("Notify.class::countDefinedNotifications $action, $socid");
|
||||||
@@ -109,7 +114,7 @@ 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 into llx_notify.
|
* 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 in llx_action_def (new usage) or Id of action in llx_action_def (old usage)
|
||||||
* \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 the notification deals on (facture, order, propal, order_supplier...). Just for log in llx_notify.
|
* \param objet_type Type of object the notification deals on (facture, order, propal, order_supplier...). Just for log in llx_notify.
|
||||||
@@ -123,25 +128,29 @@ class Notify
|
|||||||
|
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
|
|
||||||
$sql = "SELECT s.nom, c.email, c.rowid, c.name, c.firstname, a.titre,n.rowid";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c, ".MAIN_DB_PREFIX."action_def as a, ".MAIN_DB_PREFIX."notify_def as n, ".MAIN_DB_PREFIX."societe as s";
|
|
||||||
$sql .= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
|
|
||||||
$sql .= " AND n.fk_soc = s.rowid";
|
|
||||||
$sql .= " AND a.code = '".$action."'";
|
|
||||||
$sql .= " AND s.rowid = ".$socid;
|
|
||||||
|
|
||||||
dol_syslog("Notify::send $action, $socid, $texte, $objet_type, $objet_id, $file");
|
dol_syslog("Notify::send $action, $socid, $texte, $objet_type, $objet_id, $file");
|
||||||
|
|
||||||
|
$sql = "SELECT s.nom, c.email, c.rowid, c.name, c.firstname,";
|
||||||
|
$sql.= " a.rowid as adid, a.titre, a.code, n.rowid";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c, ".MAIN_DB_PREFIX."action_def as a, ".MAIN_DB_PREFIX."notify_def as n, ".MAIN_DB_PREFIX."societe as s";
|
||||||
|
$sql.= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
|
||||||
|
$sql.= " AND n.fk_soc = s.rowid";
|
||||||
|
if (is_numeric($action)) $sql.= " AND n.fk_action = ".$action; // Old usage
|
||||||
|
else $sql.= " AND a.code = '".$action."'"; // New usage
|
||||||
|
$sql .= " AND s.rowid = ".$socid;
|
||||||
|
|
||||||
|
dol_syslog("Notify::send sql=".$sql);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows($result);
|
$num = $this->db->num_rows($result);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num) // For each notification couple defined (third party/actioncode)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
|
|
||||||
$sendto = $obj->firstname . " " . $obj->name . " <".$obj->email.">";
|
$sendto = $obj->firstname . " " . $obj->name . " <".$obj->email.">";
|
||||||
|
$actiondefid = $obj->adid;
|
||||||
|
|
||||||
if (strlen($sendto))
|
if (strlen($sendto))
|
||||||
{
|
{
|
||||||
@@ -166,8 +175,9 @@ class Notify
|
|||||||
{
|
{
|
||||||
$sendto = htmlentities($sendto);
|
$sendto = htmlentities($sendto);
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_contact, objet_type, objet_id)";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_contact, objet_type, objet_id, email)";
|
||||||
$sql.= " VALUES (".$this->db->idate(mktime()).", ".$action." ,".$obj->rowid." , '".$objet_type."', ".$objet_id.");";
|
$sql.= " VALUES (".$this->db->idate(mktime()).", ".$actiondefid." ,".$obj->rowid." , '".$objet_type."', ".$objet_id.", '".addslashes($obj->email)."')";
|
||||||
|
dol_syslog("Notify::send sql=".$sql);
|
||||||
if (! $this->db->query($sql) )
|
if (! $this->db->query($sql) )
|
||||||
{
|
{
|
||||||
dol_print_error($this->db);
|
dol_print_error($this->db);
|
||||||
|
|||||||
Reference in New Issue
Block a user