dolibarr 24.0.0-beta
admin.php
1<?php
2/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
3 * Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19// Load Dolibarr environment
20require '../../main.inc.php';
21require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
22require_once DOL_DOCUMENT_ROOT.'/variants/lib/variants.lib.php';
23require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
24
34$langs->loadLangs(array("admin", "products"));
35
36$action = GETPOST('action', 'alphanohtml');
37
38// Security check
39if (!$user->admin || !isModEnabled('variants')) {
41}
42
43$error = 0;
44
45
46/*
47 * Actions
48 */
49
50if ($action) {
51 $value = GETPOST('PRODUIT_ATTRIBUTES_HIDECHILD');
52
53 if (!dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_HIDECHILD', $value, 'chaine', 0, '', $conf->entity)) {
54 setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
55 $error++;
56 }
57
58 if (!dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SEPARATOR', GETPOST('PRODUIT_ATTRIBUTES_SEPARATOR'), 'chaine', 0, '', $conf->entity)) {
59 setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
60 $error++;
61 }
62
63 if (!dolibarr_set_const($db, 'VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT', GETPOST('VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT'), 'chaine', 0, '', $conf->entity)) {
64 setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
65 $error++;
66 }
67
68 if (!$error) {
69 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
70 }
71}
72
73$title = $langs->trans('ModuleSetup').' '.$langs->trans('Module610Name');
74llxHeader('', $title);
75
76$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>';
77print load_fiche_titre($title, $linkback, 'title_setup');
78
80
81print dol_get_fiche_head($head, 'admin', $title, -1, 'product');
82
83print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
84print '<input type="hidden" name="token" value="'.newToken().'">';
85print '<input type="hidden" name="action" value="update">';
86
87print '<table class="noborder centpercent">';
88
89print '<tr class="liste_titre">';
90print '<th>'.$langs->trans("Parameters").'</th>'."\n";
91print '<th class="right" width="60">'.$langs->trans("Value").'</th>'."\n";
92print '</tr>'."\n";
93
94print '<tr class="oddeven"><td>'.$langs->trans('HideProductCombinations').'</td><td>';
95print $form->selectyesno("PRODUIT_ATTRIBUTES_HIDECHILD", getDolGlobalString('PRODUIT_ATTRIBUTES_HIDECHILD'), 1).'</td></tr>';
96
97print '<tr class="oddeven"><td>'.$langs->trans('CombinationsSeparator').'</td>';
98
99$separator = getDolGlobalString('PRODUIT_ATTRIBUTES_SEPARATOR', '_');
100
101print '<td class="right"><input size="3" type="text" class="flat" name="PRODUIT_ATTRIBUTES_SEPARATOR" value="'.$separator.'"></td></tr>';
102
103print '<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans('AllowStockMovementVariantParent'), $langs->trans('AllowStockMovementVariantParentHelp')).'</td><td>';
104print $form->selectyesno("VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT", getDolGlobalString('VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT'), 1).'</td></tr>';
105
106print '</table>';
107
108print '<br><div class="center"><input type="submit" value="'.$langs->trans("Save").'" class="button button-save"></div>';
109
110print '</form>';
111
112// End of page
113llxFooter();
114$db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
adminProductAttributePrepareHead()
Prepare array with list of tabs.