From f518bafda9e83acba2f42d61312ad234ee0afe33 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 19 May 2020 15:17:06 +0200 Subject: [PATCH 1/8] 11.0 - Add Hook "SelectWarehouses" --- htdocs/product/class/html.formproduct.class.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index af78ab5b59d..3f95a5fdaff 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -237,13 +237,23 @@ class FormProduct */ public function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $showstock = 0, $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = '', $showfullpath = 1, $stockMin = false, $orderBy = 'e.ref') { - global $conf,$langs,$user; + global $conf,$langs,$user, $hookmanager; dol_syslog(get_class($this)."::selectWarehouses $selected, $htmlname, $filterstatus, $empty, $disabled, $fk_product, $empty_label, $showstock, $forcecombo, $morecss", LOG_DEBUG); $out=''; if (empty($conf->global->ENTREPOT_EXTRA_STATUS)) $filterstatus = ''; if (!empty($fk_product)) $this->cache_warehouses = array(); + if(empty($exclude)) $exclude = array(); + + $parameters = array( + 'exclude' =>& $exclude, + 'htmlname' =>& $htmlname + ); + + $reshook = $hookmanager->executeHooks('selectWarehouses', $parameters); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + $this->loadWarehouses($fk_product, '', $filterstatus, true, $exclude, $stockMin, $orderBy); $nbofwarehouses=count($this->cache_warehouses); From 987fb806c67b3931bafcc2aefc069428cde104cb Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 19 May 2020 15:24:53 +0200 Subject: [PATCH 2/8] Exclude array param --- htdocs/product/class/html.formproduct.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 3f95a5fdaff..75dbf5d1176 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -235,7 +235,7 @@ class FormProduct * * @throws Exception */ - public function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $showstock = 0, $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = '', $showfullpath = 1, $stockMin = false, $orderBy = 'e.ref') + public function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $showstock = 0, $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = array(), $showfullpath = 1, $stockMin = false, $orderBy = 'e.ref') { global $conf,$langs,$user, $hookmanager; @@ -244,7 +244,6 @@ class FormProduct $out=''; if (empty($conf->global->ENTREPOT_EXTRA_STATUS)) $filterstatus = ''; if (!empty($fk_product)) $this->cache_warehouses = array(); - if(empty($exclude)) $exclude = array(); $parameters = array( 'exclude' =>& $exclude, From 3f28c9a4610dbfb356efd8a72af19511e05f979f Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 19 May 2020 15:31:37 +0200 Subject: [PATCH 3/8] Add parameters to hook --- htdocs/product/class/html.formproduct.class.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 75dbf5d1176..19abade42ae 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -246,8 +246,21 @@ class FormProduct if (!empty($fk_product)) $this->cache_warehouses = array(); $parameters = array( + 'selected' => & $selected, + 'htmlname' =>& $htmlname, + 'filterstatus' =>& $filterstatus, + 'empty' =>& $empty, + 'disabled ' =>& $disabled, + 'fk_product' =>& $fk_product, + 'empty_label' =>& $empty_label, + 'showstock' =>& $showstock, + 'forcecombo' =>& $forcecombo, + 'events' =>& $events, + 'morecss' =>& $morecss, 'exclude' =>& $exclude, - 'htmlname' =>& $htmlname + 'showfullpath' =>& $showfullpath, + 'stockMin' =>& $stockMin, + 'orderBy' =>& $orderBy ); $reshook = $hookmanager->executeHooks('selectWarehouses', $parameters); From e042807b3245c2b1ad3331b1fe7e1122a4fb6fd9 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 19 May 2020 15:58:16 +0200 Subject: [PATCH 4/8] Add $this to parameters --- htdocs/product/class/html.formproduct.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 19abade42ae..8dc86f394a3 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -263,7 +263,7 @@ class FormProduct 'orderBy' =>& $orderBy ); - $reshook = $hookmanager->executeHooks('selectWarehouses', $parameters); + $reshook = $hookmanager->executeHooks('selectWarehouses', $parameters, $this); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $this->loadWarehouses($fk_product, '', $filterstatus, true, $exclude, $stockMin, $orderBy); From 3213148d8717b5e8f6410b2da1225c059532927a Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Mon, 1 Jun 2020 17:12:02 +0200 Subject: [PATCH 5/8] FIX 11.0 - when using pdftk as per hidden conf USE_PDFTK_FOR_PDF_CONCAT, check that the file exists before displaying a success message --- htdocs/core/actions_massactions.inc.php | 16 ++++++++++------ htdocs/langs/en_US/main.lang | 3 ++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index b86e7bd692c..dc5b02286eb 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1030,14 +1030,18 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $input_files .= ' '.escapeshellarg($f); } - $cmd = 'pdftk '.escapeshellarg($input_files).' cat output '.escapeshellarg($file); + $cmd = 'pdftk ' . $input_files . ' cat output '.escapeshellarg($file); exec($cmd); - if (!empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); - - $langs->load("exports"); - setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); + // check if pdftk is installed + if (file_exists($file)) { + if (!empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + $langs->load("exports"); + setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); + } else { + setEventMessages($langs->trans('ErrorPDFTkOutputFileNotFound'), null, 'errors'); + } } else { diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 31e0d5a1c8d..051dde11ff7 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -837,6 +837,7 @@ Sincerely=Sincerely ConfirmDeleteObject=Are you sure you want to delete this object? DeleteLine=Delete line ConfirmDeleteLine=Are you sure you want to delete this line? +ErrorPDFTkOutputFileNotFound=Error: the file was not generated. Please check that the 'pdftk' command is installed in a directory included in the $PATH environment variable (linux/unix only) or contact your system administrator. NoPDFAvailableForDocGenAmongChecked=No PDF were available for the document generation among checked record TooManyRecordForMassAction=Too many records selected for mass action. The action is restricted to a list of %s records. NoRecordSelected=No record selected @@ -1017,4 +1018,4 @@ ContactDefault_ticket=Ticket ContactAddedAutomatically=Contact added from contact thirdparty roles More=More ShowDetails=Show details -CustomReports=Custom reports \ No newline at end of file +CustomReports=Custom reports From 99b4bfc91e1a149285b9439e63f5464399c36fd9 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 2 Jun 2020 09:53:30 +0200 Subject: [PATCH 6/8] Movement of hook "selectwarehouse" --- .../product/class/html.formproduct.class.php | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 8dc86f394a3..f033e91ceff 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -245,27 +245,6 @@ class FormProduct if (empty($conf->global->ENTREPOT_EXTRA_STATUS)) $filterstatus = ''; if (!empty($fk_product)) $this->cache_warehouses = array(); - $parameters = array( - 'selected' => & $selected, - 'htmlname' =>& $htmlname, - 'filterstatus' =>& $filterstatus, - 'empty' =>& $empty, - 'disabled ' =>& $disabled, - 'fk_product' =>& $fk_product, - 'empty_label' =>& $empty_label, - 'showstock' =>& $showstock, - 'forcecombo' =>& $forcecombo, - 'events' =>& $events, - 'morecss' =>& $morecss, - 'exclude' =>& $exclude, - 'showfullpath' =>& $showfullpath, - 'stockMin' =>& $stockMin, - 'orderBy' =>& $orderBy - ); - - $reshook = $hookmanager->executeHooks('selectWarehouses', $parameters, $this); - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - $this->loadWarehouses($fk_product, '', $filterstatus, true, $exclude, $stockMin, $orderBy); $nbofwarehouses=count($this->cache_warehouses); @@ -304,6 +283,27 @@ class FormProduct $out.=''; if ($disabled) $out.=''; + $parameters = array( + 'selected' => $selected, + 'htmlname' => $htmlname, + 'filterstatus' => $filterstatus, + 'empty' => $empty, + 'disabled ' => $disabled, + 'fk_product' => $fk_product, + 'empty_label' => $empty_label, + 'showstock' => $showstock, + 'forcecombo' => $forcecombo, + 'events' => $events, + 'morecss' => $morecss, + 'exclude' => $exclude, + 'showfullpath' => $showfullpath, + 'stockMin' => $stockMin, + 'orderBy' => $orderBy + ); + + $reshook = $hookmanager->executeHooks('selectWarehouses', $parameters, $this); + if ($reshook > 0) $out = $hookmanager->resPrint; + return $out; } From 88a831c05abba711908df2b17e28dade35b9f1b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Jun 2020 12:12:07 +0200 Subject: [PATCH 7/8] Update html.formproduct.class.php --- htdocs/product/class/html.formproduct.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index f033e91ceff..56601accebe 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -235,7 +235,7 @@ class FormProduct * * @throws Exception */ - public function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $showstock = 0, $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = array(), $showfullpath = 1, $stockMin = false, $orderBy = 'e.ref') + public function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $showstock = 0, $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = '', $showfullpath = 1, $stockMin = false, $orderBy = 'e.ref') { global $conf,$langs,$user, $hookmanager; From 009780b895d4dfb8c7b22e76250f86df368763a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Jun 2020 12:13:55 +0200 Subject: [PATCH 8/8] Update html.formproduct.class.php --- htdocs/product/class/html.formproduct.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 56601accebe..5030722bb73 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -303,6 +303,7 @@ class FormProduct $reshook = $hookmanager->executeHooks('selectWarehouses', $parameters, $this); if ($reshook > 0) $out = $hookmanager->resPrint; + elseif ($reshook == 0) $out .= $hookmanager->resPrint; return $out; }