From 6ab41766c864f2de8980f0d9bd87805d40bb4e3e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 18 Aug 2014 20:23:06 +0200 Subject: [PATCH 1/5] Fix: define new ref before trigger --- htdocs/commande/class/commande.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ac66f7fb04867..aefdb6205515b 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2005-2013 Regis Houssin + * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2011 Jean Heimburger @@ -9,7 +9,7 @@ * Copyright (C) 2013 Florian Henry * * 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 3 of the License, or * (at your option) any later version. * @@ -301,19 +301,19 @@ function valid($user, $idwarehouse=0) } } + // Set new ref and current status if (! $error) { - // Call trigger - $result=$this->call_trigger('ORDER_VALIDATE',$user); - if ($result < 0) $error++; - // End call triggers + $this->ref = $num; + $this->statut = 1; } - // Set new ref and current status if (! $error) { - $this->ref = $num; - $this->statut = 1; + // Call trigger + $result=$this->call_trigger('ORDER_VALIDATE',$user); + if ($result < 0) $error++; + // End call triggers } if (! $error) From 7437eb8088824078528e835e589a61d19a673481 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Aug 2014 14:40:20 +0200 Subject: [PATCH 2/5] New: On contact list can set filter on both active and not active (no more exclusive select). --- ChangeLog | 1 + htdocs/core/lib/company.lib.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c6846787754c6..9be60e523f506 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.7 compared to 3.6.* ***** For users: +- New: On contact list can set filter on both active and not active (no more exclusive select). - New: Each user can include its own external ics calendar into dolibarr agenda view. - New: Intervention documents are now available in ECM module. - New: Can attach supplier order to a customer order. diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 9b0661e063a8b..a262ea8441dc4 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -634,7 +634,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') // Status print ''; - print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status); + print $form->selectarray('search_status', array('-1'=>'','0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status); print ''; // Copy to clipboard @@ -659,7 +659,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') $sql .= ", p.civilite as civility_id, p.address, p.zip, p.town"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; $sql .= " WHERE p.fk_soc = ".$object->id; - if ($search_status!='') $sql .= " AND p.statut = ".$db->escape($search_status); + if ($search_status!='' && $search_status != '-1') $sql .= " AND p.statut = ".$db->escape($search_status); if ($search_name) $sql .= " AND (p.lastname LIKE '%".$db->escape($search_name)."%' OR p.firstname LIKE '%".$db->escape($search_name)."%')"; $sql.= " ORDER BY $sortfield $sortorder"; From a26a7cedf8d5ed1c0fef5b065090fce96862bbd5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Aug 2014 14:49:12 +0200 Subject: [PATCH 3/5] Qual: Uniformize code. Trigger PROJECT_BUILDDOC is removed because building a doc is not a business event. For technical action after creation of a pdf, hook "afterPDFCreation" must be used instead. --- ChangeLog | 2 ++ htdocs/core/modules/project/modules_project.php | 7 ------- .../core/modules/project/pdf/pdf_baleine.modules.php | 12 ++++++++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9be60e523f506..7d22836f5e6d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -87,6 +87,8 @@ Dolibarr better: - Changed the way parameters are provided to scripts sync_xxx_ldap2dolibarr.php - Some field into database wwere renamed from "libelle" to "label". - Table llx_c_pays were renamed into llx_c_country. +- Trigger PROJECT_BUILDDOC is removed. Building a doc is not a business event. For action after + creation of a pdf, hook "afterPDFCreation" must be used instead. ***** ChangeLog for 3.6 compared to 3.5.* ***** diff --git a/htdocs/core/modules/project/modules_project.php b/htdocs/core/modules/project/modules_project.php index 363bfb67e80f1..ecaf0213bc04b 100644 --- a/htdocs/core/modules/project/modules_project.php +++ b/htdocs/core/modules/project/modules_project.php @@ -225,13 +225,6 @@ function project_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, // Success in building document. We build meta file. dol_meta_create($object); - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers('PROJECT_BUILDDOC',$object,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - return 1; } else diff --git a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php index c8cc0b65fbc25..e6505c0528396 100644 --- a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php @@ -295,6 +295,18 @@ function write_file($object,$outputlangs) $pdf->Close(); $pdf->Output($file,'F'); + + // Add pdfgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('pdfgeneration')); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + global $action; + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); From a220634d30ec87c673054e3a9305874205ba3da0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Aug 2014 14:53:30 +0200 Subject: [PATCH 4/5] Revert "Fix: define new ref before trigger" This reverts commit 6ab41766c864f2de8980f0d9bd87805d40bb4e3e. --- htdocs/commande/class/commande.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index aefdb6205515b..ac66f7fb04867 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2005-2014 Regis Houssin + * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2011 Jean Heimburger @@ -9,7 +9,7 @@ * Copyright (C) 2013 Florian Henry * * 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 3 of the License, or * (at your option) any later version. * @@ -301,13 +301,6 @@ function valid($user, $idwarehouse=0) } } - // Set new ref and current status - if (! $error) - { - $this->ref = $num; - $this->statut = 1; - } - if (! $error) { // Call trigger @@ -316,6 +309,13 @@ function valid($user, $idwarehouse=0) // End call triggers } + // Set new ref and current status + if (! $error) + { + $this->ref = $num; + $this->statut = 1; + } + if (! $error) { $this->db->commit(); From 86d91ff698599b61d63018f5ee0a941fbff83499 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Aug 2014 15:03:55 +0200 Subject: [PATCH 5/5] Fix: Setting new property of object must be done only after all database actions are ok (and if ok). --- htdocs/compta/facture/class/facture.class.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 9b0e236af3590..c46f48ed1c6ce 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1763,16 +1763,6 @@ function validate($user, $force_number='', $idwarehouse=0) } } - // Set new ref and define current statut - if (! $error) - { - $this->ref = $num; - $this->facnumber=$num; - $this->statut=1; - $this->brouillon=0; - $this->date_validation=$now; - } - // Trigger calls if (! $error) { @@ -1782,6 +1772,16 @@ function validate($user, $force_number='', $idwarehouse=0) //TODO: Restoring ref, facnumber, statut, brouillon to previous value if trigger fail // End call triggers } + + // Set new ref and define current statut + if (! $error) + { + $this->ref = $num; + $this->facnumber=$num; + $this->statut=1; + $this->brouillon=0; + $this->date_validation=$now; + } } else {