NEW: Migrate order and supplier order extrafields admin pages to the unified page

This commit is contained in:
Frédéric FRANCE 2026-08-11 19:10:05 +02:00
parent 22abf35052
commit d889a84b47
No known key found for this signature in database
GPG key ID: C06E4A9656127239
8 changed files with 59 additions and 462 deletions

View file

@ -1,108 +0,0 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2012 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/admin/order_extrafields.php
* \ingroup order
* \brief Page to setup extra fields of order
*/
// 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/order.lib.php';
if (!$user->admin) {
accessforbidden();
}
// Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'orders'));
$form = new Form($db);
// List of supported format
$type2label = ExtraFields::getListOfTypesLabels();
$action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'commande'; //Must be the $table_element of the class that manage extrafield
/*
* Actions
*/
require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
/*
* View
*/
$textobject = $langs->transnoentitiesnoconv("Orders");
llxHeader('', $langs->trans("OrdersSetup"), '', '', 0, 0, '', '', '', 'mod-admin page-order_extrafields');
$linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup');
$head = order_admin_prepare_head();
print dol_get_fiche_head($head, 'attributes', $langs->trans("Orders"), -1, 'order');
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 '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
// Edition of an optional field
if ($action == 'edit' && !empty($attrname)) {
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
// End of page
llxFooter();
$db->close();

View file

@ -1,108 +0,0 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2012 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/admin/orderdet_extrafields.php
* \ingroup order
* \brief Page to setup extra fields of order
*/
// 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/order.lib.php';
if (!$user->admin) {
accessforbidden();
}
// Load translation files required by the page
$langs->loadlangs(array('admin', 'other', 'orders'));
$form = new Form($db);
// List of supported format
$type2label = ExtraFields::getListOfTypesLabels();
$action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'commandedet'; //Must be the $table_element of the class that manage extrafield
/*
* Actions
*/
require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
/*
* View
*/
$textobject = $langs->transnoentitiesnoconv("Orders");
llxHeader('', $langs->trans("OrdersSetup"), '', '', 0, 0, '', '', '', 'mod-admin page-orderdet_extrafields');
$linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup');
$head = order_admin_prepare_head();
print dol_get_fiche_head($head, 'attributeslines', $langs->trans("Orders"), -1, 'order');
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 '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
// Edition of an optional field
if ($action == 'edit' && !empty($attrname)) {
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
// End of page
llxFooter();
$db->close();

View file

@ -473,5 +473,58 @@ function getExtrafieldsAdminMap()
'helpurl' => '',
'langs' => array('mrp', 'admin'),
),
'commande' => array(
'headfunction' => 'order_admin_prepare_head',
'headfile' => 'core/lib/order.lib.php',
'tabid' => 'attributes',
'headlabel' => 'Orders',
'textobject' => 'Orders',
'headpicto' => 'order',
'title' => 'OrdersSetup',
'helpurl' => '',
'langs' => array('admin', 'other', 'orders'),
),
'commandedet' => array(
'headfunction' => 'order_admin_prepare_head',
'headfile' => 'core/lib/order.lib.php',
'tabid' => 'attributeslines',
'headlabel' => 'Orders',
'textobject' => 'Orders',
'headpicto' => 'order',
'title' => 'OrdersSetup',
'helpurl' => '',
'langs' => array('admin', 'other', 'orders'),
),
// The supplier order module is mid-transition between the legacy 'fournisseur'
// module (core/lib/fourn.lib.php, function supplierorder_admin_prepare_head())
// and the new split 'supplier_order' module (core/lib/supplier_order.lib.php,
// function supplier_order_admin_prepare_head()), selected at runtime by the
// MAIN_USE_NEW_SUPPLIERMOD conf option — this mirrors the exact conditional
// the original (now-deleted) per-object supplier order extrafields admin wrapper
// files used to pick which lib file to require and which head function
// to call. Both functions build a $head array containing the same 'supplierorder'
// / 'supplierorderdet' tab id, so only headfunction/headfile need to vary.
'commande_fournisseur' => array(
'headfunction' => getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') ? 'supplier_order_admin_prepare_head' : 'supplierorder_admin_prepare_head',
'headfile' => getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') ? 'core/lib/supplier_order.lib.php' : 'core/lib/fourn.lib.php',
'tabid' => 'supplierorder',
'headlabel' => 'Suppliers',
'textobject' => 'SuppliersOrders',
'headpicto' => 'company',
'title' => 'SuppliersSetup',
'helpurl' => '',
'langs' => array('admin', 'other', 'orders'),
),
'commande_fournisseurdet' => array(
'headfunction' => getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') ? 'supplier_order_admin_prepare_head' : 'supplierorder_admin_prepare_head',
'headfile' => getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') ? 'core/lib/supplier_order.lib.php' : 'core/lib/fourn.lib.php',
'tabid' => 'supplierorderdet',
'headlabel' => 'Suppliers',
'textobject' => 'SuppliersOrders',
'headpicto' => 'company',
'title' => 'SuppliersSetup',
'helpurl' => '',
'langs' => array('admin', 'other', 'orders'),
),
);
}

View file

@ -342,7 +342,7 @@ function supplierorder_admin_prepare_head()
complete_head_from_modules($conf, $langs, null, $head, $h, 'supplierorder_admin');
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/supplier_order/admin/supplierorder_extrafields.php');
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/extrafields.php', array('elementtype' => 'commande_fournisseur'));
$head[$h][1] = $langs->trans("ExtraFieldsSupplierOrders");
$nbExtrafields = $extrafields->attributes['commande_fournisseur']['count'];
if ($nbExtrafields > 0) {
@ -351,7 +351,7 @@ function supplierorder_admin_prepare_head()
$head[$h][2] = 'supplierorder';
$h++;
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/supplier_order/admin/supplierorderdet_extrafields.php');
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/extrafields.php', array('elementtype' => 'commande_fournisseurdet'));
$head[$h][1] = $langs->trans("ExtraFieldsSupplierOrdersLines");
$nbExtrafields = $extrafields->attributes['commande_fournisseurdet']['count'];
if ($nbExtrafields > 0) {

View file

@ -195,7 +195,7 @@ function order_admin_prepare_head()
complete_head_from_modules($conf, $langs, null, $head, $h, 'order_admin');
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/admin/order_extrafields.php');
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/extrafields.php', array('elementtype' => 'commande'));
$head[$h][1] = $langs->trans("ExtraFields");
$nbExtrafields = $extrafields->attributes['commande']['count'];
if ($nbExtrafields > 0) {
@ -204,7 +204,7 @@ function order_admin_prepare_head()
$head[$h][2] = 'attributes';
$h++;
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/admin/orderdet_extrafields.php');
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/extrafields.php', array('elementtype' => 'commandedet'));
$head[$h][1] = $langs->trans("ExtraFieldsLines");
$nbExtrafields = $extrafields->attributes['commandedet']['count'];
if ($nbExtrafields > 0) {

View file

@ -192,7 +192,7 @@ function supplier_order_admin_prepare_head()
complete_head_from_modules($conf, $langs, null, $head, $h, 'supplierorder_admin');
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/supplier_order/admin/supplierorder_extrafields.php');
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/extrafields.php', array('elementtype' => 'commande_fournisseur'));
$head[$h][1] = $langs->trans("ExtraFieldsSupplierOrders");
$nbExtrafields = $extrafields->attributes['commande_fournisseur']['count'];
if ($nbExtrafields > 0) {
@ -201,7 +201,7 @@ function supplier_order_admin_prepare_head()
$head[$h][2] = 'supplierorder';
$h++;
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/supplier_order/admin/supplierorderdet_extrafields.php');
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/extrafields.php', array('elementtype' => 'commande_fournisseurdet'));
$head[$h][1] = $langs->trans("ExtraFieldsSupplierOrdersLines");
$nbExtrafields = $extrafields->attributes['commande_fournisseurdet']['count'];
if ($nbExtrafields > 0) {

View file

@ -1,120 +0,0 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2012 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/supplier_order/admin/supplierorder_extrafields.php
* \ingroup fourn
* \brief Page to setup extra fields of supplierorder
*/
// Load Dolibarr environment
require '../../main.inc.php';
/**
* @var Conf $conf
* @var DoliDB $db
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
*/
if (getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/supplier_order.lib.php';
} else {
require_once DOL_DOCUMENT_ROOT . '/core/lib/fourn.lib.php';
}
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) {
accessforbidden();
}
// Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'orders'));
$extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$type2label = ExtraFields::getListOfTypesLabels();
$action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'commande_fournisseur'; //Must be the $table_element of the class that manage extrafield
/*
* Actions
*/
require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
/*
* View
*/
$textobject = $langs->transnoentitiesnoconv("SuppliersOrders");
llxHeader('', $langs->trans("SuppliersSetup"), '', '', 0, 0, '', '', '', 'mod-admin page-supplierorder_extrafields');
$linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
print load_fiche_titre($langs->trans("SuppliersSetup"), $linkback, 'title_setup');
print "<br>\n";
if (getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) {
$head = supplier_order_admin_prepare_head();
} else {
$head = supplierorder_admin_prepare_head();
}
print dol_get_fiche_head($head, 'supplierorder', $langs->trans("Suppliers"), -1, 'company');
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 '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
// Edition of an optional field
if ($action == 'edit' && !empty($attrname)) {
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
// End of page
llxFooter();
$db->close();

View file

@ -1,120 +0,0 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2012 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/supplier_order/admin/supplierorder_extrafields.php
* \ingroup fourn
* \brief Page to setup extra fields of supplierorder line
*/
// Load Dolibarr environment
require '../../main.inc.php';
/**
* @var Conf $conf
* @var DoliDB $db
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
*/
if (getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/supplier_order.lib.php';
} else {
require_once DOL_DOCUMENT_ROOT . '/core/lib/fourn.lib.php';
}
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) {
accessforbidden();
}
// Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'orders'));
$extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$type2label = ExtraFields::getListOfTypesLabels();
$action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'commande_fournisseurdet'; //Must be the $table_element of the class that manage extrafield
/*
* Actions
*/
require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
/*
* View
*/
$textobject = $langs->transnoentitiesnoconv("SuppliersOrders");
llxHeader('', $langs->trans("SuppliersSetup"), '', '', 0, 0, '', '', '', 'mod-admin page-supplierorderdet_extrafields');
$linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
print load_fiche_titre($langs->trans("SuppliersSetup"), $linkback, 'title_setup');
print "<br>\n";
if (getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) {
$head = supplier_order_admin_prepare_head();
} else {
$head = supplierorder_admin_prepare_head();
}
print dol_get_fiche_head($head, 'supplierorderdet', $langs->trans("Suppliers"), -1, 'company');
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 '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
// Edition of an optional field
if ($action == 'edit' && !empty($attrname)) {
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
// End of page
llxFooter();
$db->close();