* * 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 kundenkarte/admin/setup.php * \ingroup kundenkarte * \brief KundenKarte setup page. */ // Load Dolibarr environment $res = 0; if (!$res && file_exists("../../main.inc.php")) { $res = @include "../../main.inc.php"; } if (!$res && file_exists("../../../main.inc.php")) { $res = @include "../../../main.inc.php"; } if (!$res) { die("Include of main fails"); } // Libraries require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once '../lib/kundenkarte.lib.php'; // Translations $langs->loadLangs(array("admin", "kundenkarte@kundenkarte")); // Access control if (!$user->admin && !$user->hasRight('kundenkarte', 'admin')) { accessforbidden(); } // Parameters $action = GETPOST('action', 'aZ09'); // Directory for PDF templates $uploadDir = $conf->kundenkarte->dir_output.'/templates'; /* * Actions */ // Handle PDF template upload if ($action == 'upload_template') { $error = 0; if (!empty($_FILES['pdf_template']['name'])) { // Check file type $fileInfo = pathinfo($_FILES['pdf_template']['name']); if (strtolower($fileInfo['extension']) !== 'pdf') { setEventMessages($langs->trans("ErrorOnlyPDFAllowed"), null, 'errors'); $error++; } if (!$error) { // Create directory if not exists if (!is_dir($uploadDir)) { dol_mkdir($uploadDir); } // Save template as fixed name $targetFile = $uploadDir.'/export_template.pdf'; if (move_uploaded_file($_FILES['pdf_template']['tmp_name'], $targetFile)) { dolibarr_set_const($db, 'KUNDENKARTE_PDF_TEMPLATE', 'export_template.pdf', 'chaine', 0, '', $conf->entity); setEventMessages($langs->trans("TemplateUploadSuccess"), null, 'mesgs'); } else { setEventMessages($langs->trans("ErrorUploadFailed"), null, 'errors'); } } } else { setEventMessages($langs->trans("ErrorNoFileSelected"), null, 'errors'); } } // Handle template deletion if ($action == 'delete_template') { $templateFile = $uploadDir.'/export_template.pdf'; if (file_exists($templateFile)) { unlink($templateFile); dolibarr_set_const($db, 'KUNDENKARTE_PDF_TEMPLATE', '', 'chaine', 0, '', $conf->entity); setEventMessages($langs->trans("TemplateDeleted"), null, 'mesgs'); } } if ($action == 'update') { $error = 0; // Save settings $res = dolibarr_set_const($db, 'KUNDENKARTE_SHOW_FAVORITES_TAB', GETPOSTINT('KUNDENKARTE_SHOW_FAVORITES_TAB'), 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; } $res = dolibarr_set_const($db, 'KUNDENKARTE_SHOW_ANLAGEN_TAB', GETPOSTINT('KUNDENKARTE_SHOW_ANLAGEN_TAB'), 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; } $res = dolibarr_set_const($db, 'KUNDENKARTE_DEFAULT_ORDER_TYPE', GETPOSTINT('KUNDENKARTE_DEFAULT_ORDER_TYPE'), 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; } // PDF font size settings dolibarr_set_const($db, 'KUNDENKARTE_PDF_FONT_HEADER', GETPOSTINT('KUNDENKARTE_PDF_FONT_HEADER'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'KUNDENKARTE_PDF_FONT_CONTENT', GETPOSTINT('KUNDENKARTE_PDF_FONT_CONTENT'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'KUNDENKARTE_PDF_FONT_FIELDS', GETPOSTINT('KUNDENKARTE_PDF_FONT_FIELDS'), 'chaine', 0, '', $conf->entity); if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } } /* * View */ $form = new Form($db); $title = $langs->trans("KundenKarteSetup"); llxHeader('', $title); // Subheader $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($title, $linkback, 'title_setup'); // Configuration header $head = kundenkarteAdminPrepareHead(); print dol_get_fiche_head($head, 'settings', $langs->trans('ModuleKundenKarteName'), -1, "fa-address-card"); print ''.$langs->trans("KundenKarteSetupPage").'

'; print '
'; print ''; print ''; print ''; // Header print ''; print ''; print ''; print ''; // Show Favorites Tab print ''; print ''; print ''; print ''; // Show Anlagen Tab print ''; print ''; print ''; print ''; // Default Order Type for Favorites print ''; print ''; print ''; print ''; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("ShowFavoritesTab").''; print $form->selectyesno('KUNDENKARTE_SHOW_FAVORITES_TAB', getDolGlobalInt('KUNDENKARTE_SHOW_FAVORITES_TAB', 1), 1); print '
'.$langs->trans("ShowAnlagenTab").''; print $form->selectyesno('KUNDENKARTE_SHOW_ANLAGEN_TAB', getDolGlobalInt('KUNDENKARTE_SHOW_ANLAGEN_TAB', 1), 1); print '
'.$langs->trans("DefaultOrderType").''; $orderTypes = array( 0 => $langs->trans("OrderTypeOrder"), 1 => $langs->trans("OrderTypeProposal"), ); print $form->selectarray('KUNDENKARTE_DEFAULT_ORDER_TYPE', $orderTypes, getDolGlobalInt('KUNDENKARTE_DEFAULT_ORDER_TYPE', 0)); print '
'; // PDF Font Size Settings print '

'; print '
'.$langs->trans("PDFFontSettings").'
'; print '

'; print ''; print ''; print ''; print ''; print ''; print ''; // Header font size print ''; print ''; print ''; print ''; print ''; // Content font size print ''; print ''; print ''; print ''; print ''; // Field label font size print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").''.$langs->trans("Description").'
'.$langs->trans("PDFFontHeader").''; print ''; print ''.$langs->trans("PDFFontHeaderHelp").'
'.$langs->trans("PDFFontContent").''; print ''; print ''.$langs->trans("PDFFontContentHelp").'
'.$langs->trans("PDFFontFields").''; print ''; print ''.$langs->trans("PDFFontFieldsHelp").'
'; print '
'; print '
'; print ''; print '
'; print '
'; // PDF Template Section print '

'; print '
'.$langs->trans("PDFExportTemplate").'
'; print '

'; $templateFile = $uploadDir.'/export_template.pdf'; $hasTemplate = file_exists($templateFile); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("PDFTemplate").'
'.$langs->trans("CurrentTemplate").''; if ($hasTemplate) { print ''; print ' export_template.pdf'; print ''; print ' ('.dol_print_size(filesize($templateFile)).')'; print '

'; print ''; print ' '.$langs->trans("DeleteTemplate"); print ''; } else { print ''.$langs->trans("NoTemplateUploaded").''; } print '
'.$langs->trans("UploadNewTemplate").''; print '
'; print ''; print ''; print ''; print ' '; print '
'; print '
'.$langs->trans("PDFTemplateHelp").''; print '
'; // Info section print '
'; print '
'; print ''.$langs->trans("ConfigurationHelp").':
'; print '• '.$langs->trans("ConfigHelpSystems").'
'; print '• '.$langs->trans("ConfigHelpTypes").'
'; print '
'; print dol_get_fiche_end(); llxFooter(); $db->close();