From cebc46c42a598fbaf9ff3020b89d44e8626da848 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 11 Aug 2025 15:01:31 +0200 Subject: [PATCH] Make setup of pdf concat easier on proposal and order setup --- htdocs/admin/order_pdf.php | 89 +++++++++++++++++------------------ htdocs/admin/pdf_other.php | 3 +- htdocs/admin/propal_pdf.php | 94 +++++++++++++++++++------------------ 3 files changed, 93 insertions(+), 93 deletions(-) diff --git a/htdocs/admin/order_pdf.php b/htdocs/admin/order_pdf.php index d80e547b758..7ee4e70ed12 100644 --- a/htdocs/admin/order_pdf.php +++ b/htdocs/admin/order_pdf.php @@ -63,11 +63,14 @@ $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); $type = 'order'; -$dirforterms = $conf->order->dir_output; +$dirforterms = $conf->order->dir_output.'/'; if (!empty($conf->order->multidir_output[$conf->entity])) { $dirforterms = $conf->order->multidir_output[$conf->entity].'/'; } +$varname = 'MAIN_INFO_ORDER_TERMSOFSALE'; + + /* * Actions */ @@ -84,16 +87,16 @@ if ($action == "update") { dolibarr_del_const($db, "SALES_ORDER_SHOW_SHIPPING_ADDRESS", $conf->entity); } - // Terms of sale - if ($_FILES['termsofsale']["name"]) { - if (!preg_match('/(\.pdf)$/i', $_FILES['termsofsale']["name"])) { // Document can be used on a lot of different places. Only pdf can be supported. + // Add file + if ($_FILES[$varname]["name"]) { + if (!preg_match('/(\.pdf)$/i', $_FILES[$varname]["name"])) { // Document can be used on a lot of different places. Only pdf can be supported. $langs->load("errors"); setEventMessages($langs->trans("ErrorBadFormat"), null, 'errors'); } else { - $original_file = $_FILES['termsofsale']["name"]; - $result = dol_move_uploaded_file($_FILES['termsofsale']["tmp_name"], $dirforterms.$original_file, 1, 0, $_FILES['termsofsale']['error']); + $original_file = $_FILES[$varname]["name"]; + $result = dol_move_uploaded_file($_FILES[$varname]["tmp_name"], $dirforterms.$original_file, 1, 0, $_FILES[$varname]['error']); if ($result) { - dolibarr_set_const($db, 'MAIN_INFO_ORDER_TERMSOFSALE', $original_file, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, $varname, $original_file, 'chaine', 0, '', $conf->entity); } } } @@ -124,6 +127,13 @@ $formfile = new FormFile($db); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); +$maxfilesizearray = getMaxFileSizeArray(); +$tooltipconcatpdf = ($maxfilesizearray['maxmin'] > 0) ? $langs->trans('MaxSize').' : '.$maxfilesizearray['maxmin'].' '.$langs->trans('Kb') : ''; +$documenturl = DOL_URL_ROOT.'/document.php'; +if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) { + $documenturl = getDolGlobalString('DOL_URL_ROOT_DOCUMENT_PHP'); +} + llxHeader('', $langs->trans("OrdersSetup"), '', '', 0, 0, '', '', '', 'mod-admin page-order'); //if ($mesg) print $mesg; @@ -144,17 +154,6 @@ print '
'; print ''; print ''; -print ''; - print ''; -print '
'.$langs->trans("Parameter").'
'; -print $form->textwithpicto($langs->trans("MAIN_PDF_ADD_TERMSOFSALE_ORDER"), $langs->trans("PdfAddTermOfSaleHelp")); -print ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MAIN_PDF_ADD_TERMSOFSALE_ORDER'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("MAIN_PDF_ADD_TERMSOFSALE_ORDER", $arrval, $conf->global->MAIN_PDF_ADD_TERMSOFSALE_ORDER); -} -print '
'; print $form->textwithpicto($langs->trans("SALES_ORDER_SHOW_SHIPPING_ADDRESS"), $langs->trans("SALES_ORDER_SHOW_SHIPPING_ADDRESSMore")); print ''; @@ -166,43 +165,39 @@ if ($conf->use_javascript_ajax) { } print '
'; -print '
'; - -print load_fiche_titre($langs->trans("FileToConcatToGeneratedPDF"), '', 'file'); -print '
'; -print ''; -print ''; - -// Terms of sale -$tooltiptermsofsale = $langs->trans('AvailableFormats').' : pdf'; -$maxfilesizearray = getMaxFileSizeArray(); -$tooltiptermsofsale .= ($maxfilesizearray['maxmin'] > 0) ? '
'.$langs->trans('MaxSize').' : '.$maxfilesizearray['maxmin'].' '.$langs->trans('Kb') : ''; -$documenturl = DOL_URL_ROOT.'/document.php'; -if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) { - $documenturl = $conf->global->DOL_URL_ROOT_DOCUMENT_PHP; +// Concat PDF +print ''; + print '
'.$langs->trans("Parameters").'
'; +print $form->textwithpicto($langs->trans("MAIN_PDF_ADD_TERMSOFSALE_ORDER"), $tooltipconcatpdf); +print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_PDF_ADD_TERMSOFSALE_ORDER', array(), null, 0, 0, 1); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MAIN_PDF_ADD_TERMSOFSALE_ORDER", $arrval, getDolGlobalString('MAIN_PDF_ADD_TERMSOFSALE_ORDER')); } -$modulepart = 'order'; -print '
'; -print '
'; -print ''; - -if (getDolGlobalString("MAIN_INFO_ORDER_TERMSOFSALE")) { - $termofsale = getDolGlobalString("MAIN_INFO_ORDER_TERMSOFSALE"); - if (file_exists($dirforterms.'/'.$termofsale)) { - $file = dol_dir_list($dirforterms, 'files', 0, $termofsale); - print '
'.$termofsale.''.$formfile->showPreview($file[0], $modulepart, $termofsale, 0, ''); - print ''; +if (getDolGlobalString("MAIN_PDF_ADD_TERMSOFSALE_ORDER")) { + $modulepart = 'order'; + print '
'; + print ''; + if (getDolGlobalString("MAIN_INFO_ORDER_TERMSOFSALE")) { + $termofsale = getDolGlobalString("MAIN_INFO_ORDER_TERMSOFSALE"); + if (file_exists($conf->propal->dir_output.'/'.$termofsale)) { + $file = dol_dir_list($conf->propal->dir_output, 'files', 0, $termofsale); + print '
'.$termofsale.''.$formfile->showPreview($file[0], $modulepart, $termofsale, 0, ''); + print ''; + } } + print '
'; } -print '
'; print '
'; print '
'; - -print '
'; +if (getDolGlobalString("MAIN_PDF_ADD_TERMSOFSALE_ORDER")) { + print '
'; +} print ''; diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index adcda47a75b..f0d68cc30bf 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -286,6 +286,7 @@ if (isModEnabled('propal')) { print $form->selectarray("MAIN_GENERATE_PROPOSALS_WITH_PICTURE", $arrval, getDolGlobalString('MAIN_GENERATE_PROPOSALS_WITH_PICTURE')); } print ''; + // Add delivery address option for proposals print ''; print $form->textwithpicto($langs->trans("PROPOSAL_SHOW_SHIPPING_ADDRESS"), $langs->trans("PROPOSAL_SHOW_SHIPPING_ADDRESSMore")); @@ -297,6 +298,7 @@ if (isModEnabled('propal')) { print $form->selectarray("PROPOSAL_SHOW_SHIPPING_ADDRESS", $arrval, getDolGlobalString('PROPOSAL_SHOW_SHIPPING_ADDRESS')); } print ''; + // Concat PDF print ''; print $form->textwithpicto($langs->trans("MAIN_PDF_ADD_TERMSOFSALE_PROPAL"), $tooltipconcatpdf); @@ -322,7 +324,6 @@ if (isModEnabled('propal')) { } print ''; } - print ''; print ''; diff --git a/htdocs/admin/propal_pdf.php b/htdocs/admin/propal_pdf.php index 799612ab79f..30001525bd3 100644 --- a/htdocs/admin/propal_pdf.php +++ b/htdocs/admin/propal_pdf.php @@ -25,7 +25,7 @@ */ /** - * \file htdocs/admin/propal.php + * \file htdocs/admin/propal_pdf.php * \ingroup propale * \brief Setup page for commercial proposal module */ @@ -63,6 +63,13 @@ $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); $type = 'propal'; +$dirforterms = $conf->propal->dir_output.'/'; +if (!empty($conf->propal->multidir_output[$conf->entity])) { + $dirforterms = $conf->propal->multidir_output[$conf->entity].'/'; +} + +$varname = 'MAIN_INFO_PROPAL_TERMSOFSALE'; + /* * Actions @@ -79,17 +86,16 @@ if ($action == "update") { dolibarr_set_const($db, "MAIN_GENERATE_PROPOSALS_WITH_PICTURE", GETPOST("MAIN_GENERATE_PROPOSALS_WITH_PICTURE"), 'chaine', 0, '', $conf->entity); } - // Terms of sale - if ($_FILES['termsofsale']["name"]) { - if (!preg_match('/(\.pdf)$/i', $_FILES['termsofsale']["name"])) { // Document can be used on a lot of different places. Only pdf can be supported. + // Add file + if ($_FILES[$varname]["name"]) { + if (!preg_match('/(\.pdf)$/i', $_FILES[$varname]["name"])) { // Document can be used on a lot of different places. Only pdf can be supported. $langs->load("errors"); setEventMessages($langs->trans("ErrorBadFormat"), null, 'errors'); } else { - $dirforterms = $conf->propal->dir_output.'/'; - $original_file = $_FILES['termsofsale']["name"]; - $result = dol_move_uploaded_file($_FILES['termsofsale']["tmp_name"], $dirforterms.$original_file, 1, 0, $_FILES['termsofsale']['error']); + $original_file = $_FILES[$varname]["name"]; + $result = dol_move_uploaded_file($_FILES[$varname]["tmp_name"], $dirforterms.$original_file, 1, 0, $_FILES[$varname]['error']); if ($result) { - dolibarr_set_const($db, 'MAIN_INFO_PROPAL_TERMSOFSALE', $original_file, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, $varname, $original_file, 'chaine', 0, '', $conf->entity); } } } @@ -103,7 +109,7 @@ if ($action == "update") { // Terms of sale if ($action == 'removetermsofsale') { $filename = getDolGlobalString('MAIN_INFO_PROPAL_TERMSOFSALE'); - $file = $conf->propal->dir_output.'/'.$filename; + $file = $dirforterms.'/'.$filename; if ($filename != '') { dol_delete_file($file); @@ -111,6 +117,7 @@ if ($action == 'removetermsofsale') { dolibarr_del_const($db, 'MAIN_INFO_PROPAL_TERMSOFSALE', $conf->entity); } + /* * View */ @@ -120,6 +127,13 @@ $formfile = new FormFile($db); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); +$maxfilesizearray = getMaxFileSizeArray(); +$tooltipconcatpdf = ($maxfilesizearray['maxmin'] > 0) ? $langs->trans('MaxSize').' : '.$maxfilesizearray['maxmin'].' '.$langs->trans('Kb') : ''; +$documenturl = DOL_URL_ROOT.'/document.php'; +if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) { + $documenturl = getDolGlobalString('DOL_URL_ROOT_DOCUMENT_PHP'); +} + llxHeader('', $langs->trans("PropalSetup"), '', '', 0, 0, '', '', '', 'mod-admin page-propal'); //if ($mesg) print $mesg; @@ -141,13 +155,13 @@ print ''; print ''; print ''; @@ -162,51 +176,41 @@ if ($conf->use_javascript_ajax) { } print ''; -print '
'.$langs->trans("Parameter").'
'; -print $form->textwithpicto($langs->trans("MAIN_PDF_ADD_TERMSOFSALE_PROPAL"), $langs->trans("PdfAddTermOfSaleHelp")); +print $form->textwithpicto($langs->trans("PDF_XXX_SHOW_PRICE_INCL_TAX"), $langs->trans("AvailableWithSomePDFTemplatesOnly")); print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MAIN_PDF_ADD_TERMSOFSALE_PROPAL', array(), null, 0, 0, 1); + print ajax_constantonoff('PDF_PROPAL_SHOW_PRICE_INCL_TAX'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("MAIN_PDF_ADD_TERMSOFSALE_PROPAL", $arrval, $conf->global->MAIN_PDF_ADD_TERMSOFSALE_PROPAL); + print $form->selectarray("PDF_PROPAL_SHOW_PRICE_INCL_TAX", $arrval, getDolGlobalString('PDF_PROPAL_SHOW_PRICE_INCL_TAX')); } print '
'; -print ''; - -if (empty($conf->use_javascript_ajax)) { - print '
'; +// Concat PDF +print ''; +print $form->textwithpicto($langs->trans("MAIN_PDF_ADD_TERMSOFSALE_PROPAL"), $tooltipconcatpdf); +print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_PDF_ADD_TERMSOFSALE_PROPAL', array(), null, 0, 0, 1); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MAIN_PDF_ADD_TERMSOFSALE_PROPAL", $arrval, getDolGlobalString('MAIN_PDF_ADD_TERMSOFSALE_PROPAL')); } - -if (getDolGlobalString('MAIN_PDF_ADD_TERMSOFSALE_PROPAL')) { - print '
'; - print load_fiche_titre($langs->trans("FileToConcatToGeneratedPDF"), '', 'file'); - - print '
'; - print ''; - print ''; - - // Terms of sale - $tooltiptermsofsale = $langs->trans('AvailableFormats').' : pdf'; - $maxfilesizearray = getMaxFileSizeArray(); - $tooltiptermsofsale .= ($maxfilesizearray['maxmin'] > 0) ? '
'.$langs->trans('MaxSize').' : '.$maxfilesizearray['maxmin'].' '.$langs->trans('Kb') : ''; - $documenturl = DOL_URL_ROOT.'/document.php'; - if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) { - $documenturl = $conf->global->DOL_URL_ROOT_DOCUMENT_PHP; - } +if (getDolGlobalString("MAIN_PDF_ADD_TERMSOFSALE_PROPAL")) { $modulepart = 'propal'; - - print ''; - print '
'.$langs->trans("Parameters").'
'; - print '
'; - print ''; + print '
'; + print ''; if (getDolGlobalString("MAIN_INFO_PROPAL_TERMSOFSALE")) { $termofsale = getDolGlobalString("MAIN_INFO_PROPAL_TERMSOFSALE"); if (file_exists($conf->propal->dir_output.'/'.$termofsale)) { $file = dol_dir_list($conf->propal->dir_output, 'files', 0, $termofsale); - print '
'.$termofsale.''.$formfile->showPreview($file[0], $modulepart, $termofsale, 0, ''); - print ''; + print '
'.$termofsale.''.$formfile->showPreview($file[0], $modulepart, $termofsale, 0, ''); + print ''; } } print '
'; - print '
'; - print '
'; - - print '
'; } +print ''; +print ''; +print ''; + +if (getDolGlobalString("MAIN_PDF_ADD_TERMSOFSALE_PROPAL")) { + print '
'; + print ''; + print '
'; +} print '';