dolibarr  20.0.0-beta
admin.php
1 <?php
2 /* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
3  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.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
20 require '../../main.inc.php';
21 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
22 require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
23 
24 $langs->loadLangs(array("admin", "products"));
25 
26 $action = GETPOST('action', 'alphanohtml');
27 
28 // Security check
29 if (!$user->admin || !isModEnabled('variants')) {
31 }
32 
33 $error = 0;
34 
35 
36 /*
37  * Actions
38  */
39 
40 if ($action) {
41  $value = GETPOST('PRODUIT_ATTRIBUTES_HIDECHILD');
42 
43  if (!dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_HIDECHILD', $value, 'chaine', 0, '', $conf->entity)) {
44  setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
45  $error++;
46  }
47 
48  if (!dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SEPARATOR', GETPOST('PRODUIT_ATTRIBUTES_SEPARATOR'), 'chaine', 0, '', $conf->entity)) {
49  setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
50  $error++;
51  }
52 
53  if (!dolibarr_set_const($db, 'VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT', GETPOST('VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT'), 'chaine', 0, '', $conf->entity)) {
54  setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
55  $error++;
56  }
57 
58  if (!$error) {
59  setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
60  }
61 }
62 
63 $title = $langs->trans('ModuleSetup').' '.$langs->trans('Module610Name');
64 llxHeader('', $title);
65 
66 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
67 print load_fiche_titre($title, $linkback, 'title_setup');
68 
69 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
70 print '<input type="hidden" name="token" value="'.newToken().'">';
71 print '<input type="hidden" name="action" value="update">';
72 
73 print '<table class="noborder centpercent">';
74 
75 print '<tr class="liste_titre">';
76 print '<th>'.$langs->trans("Parameters").'</th>'."\n";
77 print '<th class="right" width="60">'.$langs->trans("Value").'</th>'."\n";
78 print '</tr>'."\n";
79 
80 print '<tr class="oddeven"><td>'.$langs->trans('HideProductCombinations').'</td><td>';
81 print $form->selectyesno("PRODUIT_ATTRIBUTES_HIDECHILD", getDolGlobalString('PRODUIT_ATTRIBUTES_HIDECHILD'), 1).'</td></tr>';
82 
83 print '<tr class="oddeven"><td>'.$langs->trans('CombinationsSeparator').'</td>';
84 if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) {
85  $separator = getDolGlobalString('PRODUIT_ATTRIBUTES_SEPARATOR');
86 } else {
87  $separator = "_";
88 }
89 print '<td class="right"><input size="3" type="text" class="flat" name="PRODUIT_ATTRIBUTES_SEPARATOR" value="'.$separator.'"></td></tr>';
90 
91 print '<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans('AllowStockMovementVariantParent'), $langs->trans('AllowStockMovementVariantParentHelp')).'</td><td>';
92 print $form->selectyesno("VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT", getDolGlobalString('VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT'), 1).'</td></tr>';
93 
94 print '</table>';
95 
96 print '<br><div class="center"><input type="submit" value="'.$langs->trans("Save").'" class="button button-save"></div>';
97 
98 print '</form>';
99 
100 // End of page
101 llxFooter();
102 $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).
Definition: admin.lib.php:656
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:55
llxFooter()
Empty footer.
Definition: wrapper.php:69
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return 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.