dolibarr/htdocs/variants/admin/admin.php

117 lines
4.1 KiB
PHP
Raw Permalink Normal View History

2016-07-23 16:37:21 +02:00
<?php
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
2016-07-23 16:37:21 +02:00
*
* 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
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2016-07-23 16:37:21 +02:00
*/
2022-09-07 20:08:59 +02:00
// Load Dolibarr environment
2016-07-23 16:37:21 +02:00
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/variants/lib/variants.lib.php';
2016-07-23 16:37:21 +02:00
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 23:53:20 +01:00
/**
* @var Conf $conf
* @var DoliDB $db
* @var Form $form
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 23:53:20 +01:00
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
*/
2018-05-26 09:40:00 +02:00
$langs->loadLangs(array("admin", "products"));
2016-07-23 16:37:21 +02:00
2020-11-30 13:18:23 +01:00
$action = GETPOST('action', 'alphanohtml');
2016-07-23 16:37:21 +02:00
// Security check
2022-09-25 06:10:17 +02:00
if (!$user->admin || !isModEnabled('variants')) {
2016-07-23 16:37:21 +02:00
accessforbidden();
}
2016-07-23 16:37:21 +02:00
2020-11-30 13:18:23 +01:00
$error = 0;
/*
* Actions
*/
if ($action) {
2016-07-23 16:37:21 +02:00
$value = GETPOST('PRODUIT_ATTRIBUTES_HIDECHILD');
2020-11-30 13:18:23 +01:00
if (!dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_HIDECHILD', $value, 'chaine', 0, '', $conf->entity)) {
2018-07-27 14:49:33 +02:00
setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
2020-11-30 13:18:23 +01:00
$error++;
2016-07-23 16:37:21 +02:00
}
2020-11-30 13:18:23 +01:00
if (!dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SEPARATOR', GETPOST('PRODUIT_ATTRIBUTES_SEPARATOR'), 'chaine', 0, '', $conf->entity)) {
setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
2020-11-30 13:18:23 +01:00
$error++;
}
if (!dolibarr_set_const($db, 'VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT', GETPOST('VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT'), 'chaine', 0, '', $conf->entity)) {
setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
$error++;
}
2020-11-30 13:18:23 +01:00
if (!$error) {
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
}
2016-07-23 16:37:21 +02:00
}
2020-11-30 13:18:23 +01:00
$title = $langs->trans('ModuleSetup').' '.$langs->trans('Module610Name');
2016-07-23 16:37:21 +02:00
llxHeader('', $title);
$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');
2016-07-23 16:37:21 +02:00
$head = adminProductAttributePrepareHead();
print dol_get_fiche_head($head, 'admin', $title, -1, 'product');
2020-09-24 21:54:21 +02:00
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
2020-11-30 13:18:23 +01:00
print '<input type="hidden" name="action" value="update">';
2020-09-24 21:54:21 +02:00
2019-02-16 08:00:16 +01:00
print '<table class="noborder centpercent">';
2020-11-30 13:18:23 +01:00
2016-07-23 16:37:21 +02:00
print '<tr class="liste_titre">';
2020-11-30 13:18:23 +01:00
print '<th>'.$langs->trans("Parameters").'</th>'."\n";
print '<th class="right" width="60">'.$langs->trans("Value").'</th>'."\n";
print '</tr>'."\n";
2018-05-26 09:40:00 +02:00
print '<tr class="oddeven"><td>'.$langs->trans('HideProductCombinations').'</td><td>';
2023-08-26 21:49:24 +02:00
print $form->selectyesno("PRODUIT_ATTRIBUTES_HIDECHILD", getDolGlobalString('PRODUIT_ATTRIBUTES_HIDECHILD'), 1).'</td></tr>';
2020-11-30 13:18:23 +01:00
2018-05-26 09:40:00 +02:00
print '<tr class="oddeven"><td>'.$langs->trans('CombinationsSeparator').'</td>';
2019-02-16 08:00:16 +01:00
if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) {
2024-01-05 04:18:53 +01:00
$separator = getDolGlobalString('PRODUIT_ATTRIBUTES_SEPARATOR');
} else {
$separator = "_";
}
2019-02-16 08:00:16 +01:00
print '<td class="right"><input size="3" type="text" class="flat" name="PRODUIT_ATTRIBUTES_SEPARATOR" value="'.$separator.'"></td></tr>';
2020-11-30 13:18:23 +01:00
2024-02-12 06:08:22 +01:00
print '<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans('AllowStockMovementVariantParent'), $langs->trans('AllowStockMovementVariantParentHelp')).'</td><td>';
print $form->selectyesno("VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT", getDolGlobalString('VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT'), 1).'</td></tr>';
2016-07-23 16:37:21 +02:00
print '</table>';
2020-11-30 13:18:23 +01:00
print '<br><div class="center"><input type="submit" value="'.$langs->trans("Save").'" class="button button-save"></div>';
2020-11-30 13:18:23 +01:00
2016-07-23 16:37:21 +02:00
print '</form>';
2018-08-04 15:58:05 +02:00
// End of page
2016-07-23 16:37:21 +02:00
llxFooter();
$db->close();