From c10f895d77f7d2ad22826a0c553dc5652995d48a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 4 Jul 2011 10:35:48 +0000 Subject: [PATCH] Fix: add more triggers --- htdocs/comm/propal/index.php | 6 +++--- htdocs/commande/class/commande.class.php | 6 +++++- htdocs/compta/facture/class/facture.class.php | 8 ++++++-- .../includes/modules/commande/modules_commande.php | 12 ++++++++++-- .../includes/modules/facture/modules_facture.php | 13 +++++++++++-- .../includes/modules/propale/modules_propale.php | 12 ++++++++++-- .../triggers/interface_all_Demo.class.php-NORUN | 14 +++++++++++++- 7 files changed, 58 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index 02df09c1d53..4943178e9c5 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -22,7 +22,7 @@ * \file htdocs/comm/propal/index.php * \ingroup propal * \brief Home page of proposal area - * \version $Id$ + * \version $Id: index.php,v 1.6 2011/07/04 10:35:49 hregis Exp $ */ require("../../main.inc.php"); @@ -249,7 +249,7 @@ if ($resql) print ''; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; @@ -416,6 +416,6 @@ print ''; $db->close(); -llxFooter('$Date$ - $Revision$'); +llxFooter('$Date: 2011/07/04 10:35:49 $ - $Revision: 1.6 $'); ?> diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 6e6ac3d4d82..0bad431057f 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -25,7 +25,7 @@ * \file htdocs/commande/class/commande.class.php * \ingroup commande * \brief Fichier des classes de commandes - * \version $Id: commande.class.php,v 1.117 2011/07/04 09:36:29 eldy Exp $ + * \version $Id: commande.class.php,v 1.118 2011/07/04 10:35:49 hregis Exp $ */ require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); @@ -258,6 +258,8 @@ class Commande extends CommonObject if (! $error) { + $this->oldref=''; + // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { @@ -273,6 +275,8 @@ class Commande extends CommonObject if (@rename($dirsource, $dirdest)) { + $this->oldref = $comref; + dol_syslog("Rename ok"); // Suppression ancien fichier PDF dans nouveau rep dol_delete_file($conf->commande->dir_output.'/'.$snum.'/'.$comref.'.*'); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f8f946d3065..8060ef58a4c 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -28,7 +28,7 @@ * \file htdocs/compta/facture/class/facture.class.php * \ingroup facture * \brief Fichier de la classe des factures clients - * \version $Id: facture.class.php,v 1.122 2011/06/30 13:27:20 hregis Exp $ + * \version $Id: facture.class.php,v 1.123 2011/07/04 10:35:48 hregis Exp $ */ require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php"); @@ -1664,6 +1664,8 @@ class Facture extends CommonObject if (! $error) { + $this->oldref = ''; + // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { @@ -1679,6 +1681,8 @@ class Facture extends CommonObject if (@rename($dirsource, $dirdest)) { + $this->oldref = $facref; + dol_syslog("Rename ok"); // Suppression ancien fichier PDF dans nouveau rep dol_delete_file($conf->facture->dir_output.'/'.$snumfa.'/'.$facref.'.*'); @@ -1690,7 +1694,7 @@ class Facture extends CommonObject // Set new ref and define current statut if (! $error) { - $this->ref = $num; + $this->ref = $num; $this->facnumber=$num; $this->statut=1; } diff --git a/htdocs/includes/modules/commande/modules_commande.php b/htdocs/includes/modules/commande/modules_commande.php index 6bf604fb508..0a10adcd852 100644 --- a/htdocs/includes/modules/commande/modules_commande.php +++ b/htdocs/includes/modules/commande/modules_commande.php @@ -26,7 +26,7 @@ * \ingroup commande * \brief Fichier contenant la classe mere de generation des commandes en PDF * et la classe mere de numerotation des commandes - * \version $Id$ + * \version $Id: modules_commande.php,v 1.47 2011/07/04 10:35:49 hregis Exp $ */ require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); @@ -146,7 +146,7 @@ class ModeleNumRefCommandes */ function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { - global $conf,$langs; + global $conf,$user,$langs; $langs->load("orders"); $dir = "/includes/modules/commande/"; @@ -198,6 +198,14 @@ function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0 $outputlangs->charset_output=$sav_charset_output; // on supprime l'image correspondant au preview commande_delete_preview($db, $object->id); + + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($db); + $result=$interface->run_triggers('ORDER_BUILDDOC',$object,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + return 1; } else diff --git a/htdocs/includes/modules/facture/modules_facture.php b/htdocs/includes/modules/facture/modules_facture.php index 42e9248f8c9..9e1640010f4 100644 --- a/htdocs/includes/modules/facture/modules_facture.php +++ b/htdocs/includes/modules/facture/modules_facture.php @@ -25,7 +25,7 @@ * \ingroup facture * \brief Fichier contenant la classe mere de generation des factures en PDF * et la classe mere de numerotation des factures - * \version $Id$ + * \version $Id: modules_facture.php,v 1.92 2011/07/04 10:35:48 hregis Exp $ */ require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); @@ -147,7 +147,8 @@ class ModeleNumRefFactures */ function facture_pdf_create($db, $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { - global $conf,$langs; + global $conf,$user,$langs; + $langs->load("bills"); // Increase limit for PDF build @@ -218,6 +219,14 @@ function facture_pdf_create($db, $object, $message, $modele, $outputlangs, $hide facture_delete_preview($db, $object->id); $outputlangs->charset_output=$sav_charset_output; + + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($db); + $result=$interface->run_triggers('BILL_BUILDDOC',$object,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + return 1; } else diff --git a/htdocs/includes/modules/propale/modules_propale.php b/htdocs/includes/modules/propale/modules_propale.php index 5828075a41e..b4572034c3a 100644 --- a/htdocs/includes/modules/propale/modules_propale.php +++ b/htdocs/includes/modules/propale/modules_propale.php @@ -24,7 +24,7 @@ * \ingroup propale * \brief Fichier contenant la classe mere de generation des propales en PDF * et la classe mere de numerotation des propales - * \version $Id: modules_propale.php,v 1.61 2011/07/04 08:53:01 eldy Exp $ + * \version $Id: modules_propale.php,v 1.62 2011/07/04 10:35:49 hregis Exp $ */ require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); @@ -143,7 +143,7 @@ class ModeleNumRefPropales */ function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { - global $conf,$langs; + global $conf,$user,$langs; $langs->load("propale"); $dir = "/includes/modules/propale/"; @@ -197,6 +197,14 @@ function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $outputlangs->charset_output=$sav_charset_output; // on supprime l'image correspondant au preview propale_delete_preview($db, $object->id); + + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($db); + $result=$interface->run_triggers('PROPAL_BUILDDOC',$object,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + return 1; } else diff --git a/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN b/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN index 21e9219ab8e..d4deae9b132 100644 --- a/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN +++ b/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN @@ -28,7 +28,7 @@ * - Le nom de la classe doit etre InterfaceMytrigger * - Le nom de la methode constructeur doit etre InterfaceMytrigger * - Le nom de la propriete name doit etre Mytrigger - * \version $Id$ + * \version $Id: interface_all_Demo.class.php-NORUN,v 1.26 2011/07/04 10:35:49 hregis Exp $ */ @@ -225,6 +225,10 @@ class InterfaceDemo { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } + elseif ($action == 'ORDER_BUILDDOC') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } elseif ($action == 'ORDER_SENTBYMAIL') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); @@ -269,6 +273,10 @@ class InterfaceDemo { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } + elseif ($action == 'PROPAL_BUILDDOC') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } elseif ($action == 'PROPAL_SENTBYMAIL') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); @@ -341,6 +349,10 @@ class InterfaceDemo { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } + elseif ($action == 'BILL_BUILDDOC') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } elseif ($action == 'BILL_SENTBYMAIL') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);