forked from Dolibarr/dolibarr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEW: Management of extrafields on customer prices, level prices and d…
…efault prices (Dolibarr#31313) * ADD: Management of extrafields on customer prices, level prices and default prices * ADD: sql table for managing extrafields on customer prices, level prices and default prices * FIX: Add actions to update, add, delete extrafields and display extrafield * FIX: colspan for customer price table * ADD: Management of extrafields on customer prices * FIX: Value and search for price label * ADD: name in the files * FIX: * * FIX: PHP-cs fail * FIX: comment in english, please * FIX: variable naming and testing * FIX: GETPOST array * FIX: return is an array of strings, object array will be modified as well * FIX: return array keys for Extrafields::fetch_name_optionals_label are string too * FIX: do not mess with extrafields code and value * Update llx_product_customer_price_extrafields.sql * Update llx_product_price_extrafields.sql * FIX: whooopsie * FIX: PHP warnings --------- Co-authored-by: Mélina JOUM <[email protected]> Co-authored-by: Laurent Destailleur <[email protected]>
- Loading branch information
1 parent
0be87db
commit a181031
Showing
9 changed files
with
899 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
* Copyright (C) 2023 Gauthier VERDOL <[email protected]> | ||
* Copyright (C) 2024 Jean-Rémi TAPONIER <[email protected]> | ||
* Copyright (C) 2024 MDW <[email protected]> | ||
* Copyright (C) 2024 Mélina Joum <[email protected]> | ||
* Copyright (C) 2024 Frédéric France <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
|
@@ -331,6 +332,8 @@ function product_admin_prepare_head() | |
|
||
$extrafields = new ExtraFields($db); | ||
$extrafields->fetch_name_optionals_label('product'); | ||
$extrafields->fetch_name_optionals_label('product_price'); | ||
$extrafields->fetch_name_optionals_label('product_customer_price'); | ||
$extrafields->fetch_name_optionals_label('product_fournisseur_price'); | ||
|
||
$h = 0; | ||
|
@@ -365,6 +368,24 @@ function product_admin_prepare_head() | |
$head[$h][2] = 'attributes'; | ||
$h++; | ||
|
||
$head[$h][0] = DOL_URL_ROOT.'/product/admin/product_price_extrafields.php'; | ||
$head[$h][1] = $langs->trans("ProductLevelExtraFields"); | ||
$nbExtrafields = $extrafields->attributes['product_price']['count']; | ||
if ($nbExtrafields > 0) { | ||
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>'; | ||
} | ||
$head[$h][2] = 'levelAttributes'; | ||
$h++; | ||
|
||
$head[$h][0] = DOL_URL_ROOT.'/product/admin/product_customer_extrafields.php'; | ||
$head[$h][1] = $langs->trans("ProductCustomerExtraFields"); | ||
$nbExtrafields = $extrafields->attributes['product_customer_price']['count']; | ||
if ($nbExtrafields > 0) { | ||
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>'; | ||
} | ||
$head[$h][2] = 'customerAttributes'; | ||
$h++; | ||
|
||
$head[$h][0] = DOL_URL_ROOT.'/product/admin/product_supplier_extrafields.php'; | ||
$head[$h][1] = $langs->trans("ProductSupplierExtraFields"); | ||
$nbExtrafields = $extrafields->attributes['product_fournisseur_price']['count']; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?php | ||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <[email protected]> | ||
* Copyright (C) 2003 Jean-Louis Bergamo <[email protected]> | ||
* Copyright (C) 2004-2011 Laurent Destailleur <[email protected]> | ||
* Copyright (C) 2012 Marcos García <[email protected]> | ||
* Copyright (C) 2012 Regis Houssin <[email protected]> | ||
* Copyright (C) 2019 Tim Otte <[email protected]> | ||
* Copyright (C) 2024 Mélina Joum <[email protected]> | ||
* | ||
* 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/product/admin/product_customer_extrafields.php | ||
* \ingroup product | ||
* \brief Page to setup extra fields of products | ||
*/ | ||
|
||
// Load Dolibarr environment | ||
require '../../main.inc.php'; | ||
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; | ||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; | ||
|
||
// Load translation files required by the page | ||
$langs->loadLangs(array('companies', 'admin', 'products')); | ||
|
||
$extrafields = new ExtraFields($db); | ||
$form = new Form($db); | ||
|
||
// List of supported format | ||
$type2label = ExtraFields::getListOfTypesLabels(); | ||
|
||
$action = GETPOST('action', 'aZ09'); | ||
$attrname = GETPOST('attrname', 'alpha'); | ||
$elementtype = 'product_customer_price'; //Must be the $element of the class that manage extrafield | ||
|
||
if (!$user->admin) { | ||
accessforbidden(); | ||
} | ||
|
||
/* | ||
* Actions | ||
*/ | ||
|
||
require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; | ||
|
||
|
||
|
||
/* | ||
* View | ||
*/ | ||
|
||
$title = $langs->trans('ProductServiceSetup'); | ||
$textobject = $langs->transnoentitiesnoconv("ProductsAndServices"); | ||
if (!isModEnabled("product")) { | ||
$title = $langs->trans('ServiceSetup'); | ||
$textobject = $langs->trans('Services'); | ||
} elseif (!isModEnabled("service")) { | ||
$title = $langs->trans('ProductSetup'); | ||
$textobject = $langs->trans('Products'); | ||
} | ||
|
||
//$help_url='EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'; | ||
$help_url = ''; | ||
llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-product page-admin_product_customer_extrafields'); | ||
|
||
|
||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; | ||
print load_fiche_titre($title, $linkback, 'title_setup'); | ||
|
||
|
||
$head = product_admin_prepare_head(); | ||
|
||
print dol_get_fiche_head($head, 'customerAttributes', $textobject, -1, 'product'); | ||
|
||
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?php | ||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <[email protected]> | ||
* Copyright (C) 2003 Jean-Louis Bergamo <[email protected]> | ||
* Copyright (C) 2004-2011 Laurent Destailleur <[email protected]> | ||
* Copyright (C) 2012 Marcos García <[email protected]> | ||
* Copyright (C) 2012 Regis Houssin <[email protected]> | ||
* Copyright (C) 2019 Tim Otte <[email protected]> | ||
* Copyright (C) 2024 Mélina Joum <[email protected]> | ||
* | ||
* 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/product/admin/product_supplier_extrafields.php | ||
* \ingroup product | ||
* \brief Page to setup extra fields of products | ||
*/ | ||
|
||
// Load Dolibarr environment | ||
require '../../main.inc.php'; | ||
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; | ||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; | ||
|
||
// Load translation files required by the page | ||
$langs->loadLangs(array('companies', 'admin', 'products')); | ||
|
||
$extrafields = new ExtraFields($db); | ||
$form = new Form($db); | ||
|
||
// List of supported format | ||
$type2label = ExtraFields::getListOfTypesLabels(); | ||
|
||
$action = GETPOST('action', 'aZ09'); | ||
$attrname = GETPOST('attrname', 'alpha'); | ||
$elementtype = 'product_price'; //Must be the $element of the class that manage extrafield | ||
|
||
if (!$user->admin) { | ||
accessforbidden(); | ||
} | ||
|
||
|
||
/* | ||
* Actions | ||
*/ | ||
|
||
require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; | ||
|
||
|
||
|
||
/* | ||
* View | ||
*/ | ||
|
||
$title = $langs->trans('ProductServiceSetup'); | ||
$textobject = $langs->transnoentitiesnoconv("ProductsAndServices"); | ||
if (!isModEnabled("product")) { | ||
$title = $langs->trans('ServiceSetup'); | ||
$textobject = $langs->trans('Services'); | ||
} elseif (!isModEnabled("service")) { | ||
$title = $langs->trans('ProductSetup'); | ||
$textobject = $langs->trans('Products'); | ||
} | ||
|
||
//$help_url='EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'; | ||
$help_url = ''; | ||
llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-product page-admin_product_supplier_extrafields'); | ||
|
||
|
||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; | ||
print load_fiche_titre($title, $linkback, 'title_setup'); | ||
|
||
|
||
$head = product_admin_prepare_head(); | ||
|
||
print dol_get_fiche_head($head, 'levelAttributes', $textobject, -1, 'product'); | ||
|
||
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(); |
Oops, something went wrong.