From 661d1de2fd7a4912c2a463fdcf8bee7db1f7e594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 11 Aug 2026 19:20:01 +0200 Subject: [PATCH] NEW: Migrate ticket extrafields admin page to the unified page --- htdocs/admin/ticket_extrafields.php | 105 ---------------------- htdocs/core/lib/admin_extrafields.lib.php | 11 +++ htdocs/core/lib/ticket.lib.php | 2 +- 3 files changed, 12 insertions(+), 106 deletions(-) delete mode 100644 htdocs/admin/ticket_extrafields.php diff --git a/htdocs/admin/ticket_extrafields.php b/htdocs/admin/ticket_extrafields.php deleted file mode 100644 index 9c989c8e543..00000000000 --- a/htdocs/admin/ticket_extrafields.php +++ /dev/null @@ -1,105 +0,0 @@ - - * Copyright (C) 2024-2026 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 admin/ticket_extrafields.php - * \ingroup ticket - * \brief Page to setup extra fields of ticket - */ - -// Load Dolibarr environment -require '../main.inc.php'; -/** - * @var Conf $conf - * @var DoliDB $db - * @var ExtraFields $extrafields - * @var HookManager $hookmanager - * @var Translate $langs - * @var User $user - */ - -require_once DOL_DOCUMENT_ROOT."/core/lib/ticket.lib.php"; -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; - -// Load translation files required by the page -$langs->loadLangs(array('ticket', 'admin')); - -$form = new Form($db); - -// List of supported format -$type2label = ExtraFields::getListOfTypesLabels(); - -$action = GETPOST('action', 'aZ09'); -$attrname = GETPOST('attrname', 'alpha'); -$elementtype = 'ticket'; //Must be the $table_element of the class that manage extrafield - -if (!$user->admin) { - accessforbidden(); -} - - -/* - * Actions - */ - -include DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; - - - -/* - * View - */ - -$textobject = $langs->transnoentitiesnoconv("Ticket"); - -$help_url = "FR:Module_Ticket"; -$page_name = "TicketSetup"; -llxHeader('', $langs->trans($page_name), $help_url, '', 0, 0, '', '', '', 'mod-admin page-ticket_extrafields'); - -$linkback = ''.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').''.$langs->trans("BackToModuleList").''; - -print load_fiche_titre($langs->trans("TicketSetup"), $linkback, 'title_setup'); - -$head = ticketAdminPrepareHead(); - -print dol_get_fiche_head($head, 'attributes', $langs->trans("Module56000Name"), -1, "ticket"); - -require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; - -print dol_get_fiche_end(); - - -// Creation of an optional field -if ($action == 'create') { - print "
"; - print load_fiche_titre($langs->trans('NewAttribute')); - - include DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; -} - -// Edition of an optional field -if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - - include DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/core/lib/admin_extrafields.lib.php b/htdocs/core/lib/admin_extrafields.lib.php index c6b0ae6c2bb..94cbc229473 100644 --- a/htdocs/core/lib/admin_extrafields.lib.php +++ b/htdocs/core/lib/admin_extrafields.lib.php @@ -537,5 +537,16 @@ function getExtrafieldsAdminMap() 'helpurl' => '', 'langs' => array('admin', 'other', 'resource'), ), + 'ticket' => array( + 'headfunction' => 'ticketAdminPrepareHead', + 'headfile' => 'core/lib/ticket.lib.php', + 'tabid' => 'attributes', + 'headlabel' => 'Module56000Name', + 'textobject' => 'Ticket', + 'headpicto' => 'ticket', + 'title' => 'TicketSetup', + 'helpurl' => 'FR:Module_Ticket', + 'langs' => array('ticket', 'admin'), + ), ); } diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 0cbc6e9c326..35f35c75674 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -46,7 +46,7 @@ function ticketAdminPrepareHead() $head[$h][2] = 'settings'; $h++; - $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/ticket_extrafields.php'); + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/extrafields.php', array('elementtype' => 'ticket')); $head[$h][1] = $langs->trans("ExtraFieldsTicket"); $nbExtrafields = $extrafields->attributes['ticket']['count']; if ($nbExtrafields > 0) {