* Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2011-2013 Juanjo Menent * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * 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 * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/admin/order_pdf.php * \ingroup order * \brief Setup page for order module */ // Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; /** * @var Conf $conf * @var DoliDB $db * @var HookManager $hookmanager * @var Societe $mysoc * @var Translate $langs * @var User $user */ // Load translation files required by the page $langs->loadLangs(array("admin", "other", "errors", "orders")); if (!$user->admin) { accessforbidden(); } $action = GETPOST('action', 'aZ09'); $value = GETPOST('value', 'alpha'); $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); $type = 'order'; $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'; $error = 0; /* * Actions */ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == "update") { if (GETPOSTISSET('MAIN_PDF_ADD_TERMSOFSALE_ORDER')) { dolibarr_set_const($db, "MAIN_PDF_ADD_TERMSOFSALE_ORDER", GETPOST("MAIN_PDF_ADD_TERMSOFSALE_ORDER", 'int'), 'chaine', 0, '', $conf->entity); } if (GETPOSTISSET('SALES_ORDER_SHOW_SHIPPING_ADDRESS')) { dolibarr_set_const($db, "SALES_ORDER_SHOW_SHIPPING_ADDRESS", GETPOSTINT("SALES_ORDER_SHOW_SHIPPING_ADDRESS"), 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, "SALES_ORDER_SHOW_SHIPPING_ADDRESS", $conf->entity); } // 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[$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, $varname, $original_file, 'chaine', 0, '', $conf->entity); } } } setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); exit; } // Terms of sale if ($action == 'removetermsofsale') { $filename = getDolGlobalString('MAIN_INFO_ORDER_TERMSOFSALE'); $file = $dirforterms.'/'.$filename; if ($filename != '') { dol_delete_file($file); } dolibarr_del_const($db, 'MAIN_INFO_ORDER_TERMSOFSALE', $conf->entity); } /* * View */ $form = new Form($db); $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; $linkback = ''.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup'); $head = order_admin_prepare_head(); print dol_get_fiche_head($head, 'pdf', $langs->trans("Orders"), -1, 'order'); print '
'; print ''; print ''; print '
'; print ''; print ''; print ''; // Concat PDF print ''; print '
'.$langs->trans("Parameter").'
'; print $form->textwithpicto($langs->trans("SALES_ORDER_SHOW_SHIPPING_ADDRESS"), $langs->trans("SALES_ORDER_SHOW_SHIPPING_ADDRESSMore")); print ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('SALES_ORDER_SHOW_SHIPPING_ADDRESS'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("SALES_ORDER_SHOW_SHIPPING_ADDRESS", $arrval, $conf->global->SALES_ORDER_SHOW_SHIPPING_ADDRESS); } print '
'; 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')); } 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 '
'; if (getDolGlobalString("MAIN_PDF_ADD_TERMSOFSALE_ORDER")) { print '
'; } print '
'; print '

'; // End of page llxFooter(); $db->close();