From 4c10efb7d3773151e1993cb3651752a9e0f788f4 Mon Sep 17 00:00:00 2001 From: All3kcis Date: Wed, 27 Jun 2018 15:32:22 +0200 Subject: [PATCH 1/7] Enable auto update PDF on update note Generate order/invoice PDF on update public note --- htdocs/core/class/commonobject.class.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a165704c058..0b1d2749842 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2511,6 +2511,27 @@ abstract class CommonObject $this->note = $note; // deprecated $this->note_private = $note; } + if($suffix != '_private' && in_array($this->table_element, array('commande_fournisseur', 'commande', 'propal', 'facture_fourn', 'facture' ))){ + global $conf; + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $this->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$this->modelpdf; + $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); + $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); + $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); + $result=$this->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) dol_print_error($db,$result); + } + } return 1; } else From 8d23aa305fb40c5732df9e249857f636edf0e556 Mon Sep 17 00:00:00 2001 From: All-3kcis Date: Fri, 27 Jul 2018 14:47:22 +0200 Subject: [PATCH 2/7] Move code into "htdocs/core/actions_setnotes.inc.php" --- htdocs/core/actions_setnotes.inc.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php index 50b35392644..cee1c3dacb5 100644 --- a/htdocs/core/actions_setnotes.inc.php +++ b/htdocs/core/actions_setnotes.inc.php @@ -32,8 +32,28 @@ if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel { if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); if (empty($object->id)) $object->fetch($id); // Fetch may not be already done - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public'); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + $result_update=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public'); + if(in_array($object->table_element, array('commande_fournisseur', 'commande', 'propal', 'facture_fourn', 'facture' ))){ + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); + $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); + $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); + $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) dol_print_error($db,$result); + } + } + if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors'); } // Set public note else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('cancel','alpha')) From a00150a3fbead55b59cf8cbe5bdbd8582d1313a9 Mon Sep 17 00:00:00 2001 From: All-3kcis Date: Fri, 27 Jul 2018 14:48:31 +0200 Subject: [PATCH 3/7] Revert "Enable auto update PDF on update note" This reverts commit 4c10efb7d3773151e1993cb3651752a9e0f788f4. --- htdocs/core/class/commonobject.class.php | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0b1d2749842..a165704c058 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2511,27 +2511,6 @@ abstract class CommonObject $this->note = $note; // deprecated $this->note_private = $note; } - if($suffix != '_private' && in_array($this->table_element, array('commande_fournisseur', 'commande', 'propal', 'facture_fourn', 'facture' ))){ - global $conf; - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $this->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$this->modelpdf; - $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); - $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); - $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); - $result=$this->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) dol_print_error($db,$result); - } - } return 1; } else From e9267c54ce73d9a3e088ab4ceb0421307b3f7ddc Mon Sep 17 00:00:00 2001 From: All-3kcis Date: Fri, 27 Jul 2018 15:04:16 +0200 Subject: [PATCH 4/7] add include productfournisseur --- htdocs/core/actions_setnotes.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php index cee1c3dacb5..5d6e80f7b3d 100644 --- a/htdocs/core/actions_setnotes.inc.php +++ b/htdocs/core/actions_setnotes.inc.php @@ -49,6 +49,7 @@ if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db,$result); } From f382d8f0bbc909446f5648d052877720b99eda39 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Aug 2018 23:52:33 +0200 Subject: [PATCH 5/7] Update actions_setnotes.inc.php --- htdocs/core/actions_setnotes.inc.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php index 5d6e80f7b3d..169b511b61b 100644 --- a/htdocs/core/actions_setnotes.inc.php +++ b/htdocs/core/actions_setnotes.inc.php @@ -32,8 +32,11 @@ if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel { if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); if (empty($object->id)) $object->fetch($id); // Fetch may not be already done + $result_update=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public'); - if(in_array($object->table_element, array('commande_fournisseur', 'commande', 'propal', 'facture_fourn', 'facture' ))){ + + if (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) + { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { From 848fcc4b176d4b0a8e5887175871cf0c44192e90 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Aug 2018 23:53:48 +0200 Subject: [PATCH 6/7] Update actions_setnotes.inc.php --- htdocs/core/actions_setnotes.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php index 169b511b61b..899a9a260fb 100644 --- a/htdocs/core/actions_setnotes.inc.php +++ b/htdocs/core/actions_setnotes.inc.php @@ -35,7 +35,8 @@ if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel $result_update=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public'); - if (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) + if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors'); + elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) @@ -57,7 +58,6 @@ if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel if ($result < 0) dol_print_error($db,$result); } } - if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors'); } // Set public note else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('cancel','alpha')) From dda0c5699e12114e4641caba097ab725b1349745 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Sep 2018 15:59:09 +0200 Subject: [PATCH 7/7] Update actions_setnotes.inc.php --- htdocs/core/actions_setnotes.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php index 899a9a260fb..ec253d5ef4a 100644 --- a/htdocs/core/actions_setnotes.inc.php +++ b/htdocs/core/actions_setnotes.inc.php @@ -53,8 +53,9 @@ if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) dol_print_error($db,$result); } }