diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index c067ee2bc56..e19530ec209 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1028,14 +1028,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 8c992bf91ca..532edcb6a67 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -840,6 +840,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 @@ -1032,4 +1033,4 @@ DeleteFileHeader=Confirm file delete DeleteFileText=Do you really want delete this file? ShowOtherLanguages=Show other languages SwitchInEditModeToAddTranslation=Switch in edit mode to add translations for this language -NotUsedForThisCustomer=Not used for this customer \ No newline at end of file +NotUsedForThisCustomer=Not used for this customer diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 89a1d20628e..7e6355b2a30 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1060,7 +1060,7 @@ if ($dirins && ($action == 'droptable' || $action == 'droptableextrafields') && $objectname = $tabobj; $arrayoftables = array(); - if ($action == 'droptable') $arrayoftables[] = MAIN_DB_PREFIX.strtoslower($module).'_'.strtolower($tabobj); + if ($action == 'droptable') $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).'_'.strtolower($tabobj); if ($action == 'droptableextrafields') $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).'_'.strtolower($tabobj).'_extrafields'; foreach ($arrayoftables as $tabletodrop) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 0eeddd15c07..903eedd3e8a 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -237,13 +237,14 @@ 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(); + $this->loadWarehouses($fk_product, '', $filterstatus, true, $exclude, $stockMin, $orderBy); $nbofwarehouses = count($this->cache_warehouses); @@ -287,6 +288,28 @@ 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; + elseif ($reshook == 0) $out .= $hookmanager->resPrint; + return $out; }