* Copyright (C) 2018 Frédéric France * * 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 . */ require '../main.inc.php'; require 'class/ProductAttribute.class.php'; require 'class/ProductAttributeValue.class.php'; $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $value = GETPOST('value', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $object = new ProductAttribute($db); $objectval = new ProductAttributeValue($db); if ($object->fetch($id) < 1) { dol_print_error($db, $langs->trans('ErrorRecordNotFound')); exit(); } $permissiontoread = $user->rights->produit->lire || $user->rights->service->lire; // Security check if (empty($conf->variants->enabled)) { accessforbidden('Module not enabled'); } if ($user->socid > 0) { // Protection if external user accessforbidden(); } //$result = restrictedArea($user, 'variant'); if (!$permissiontoread) accessforbidden(); /* * Actions */ if ($cancel) { $action = ''; header('Location: '.DOL_URL_ROOT.'/variants/card.php?id='.$object->id); exit(); } // None /* * View */ if ($action == 'add') { if (empty($ref) || empty($value)) { setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors'); } else { $objectval->fk_product_attribute = $object->id; $objectval->ref = $ref; $objectval->value = $value; if ($objectval->create($user) > 0) { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); header('Location: '.DOL_URL_ROOT.'/variants/card.php?id='.$object->id); exit(); } else { setEventMessages($langs->trans('ErrorCreatingProductAttributeValue'), $objectval->errors, 'errors'); } } } $langs->load('products'); $help_url = 'EN:Module_Products#Variants'; $title = $langs->trans('ProductAttributeName', dol_htmlentities($object->label)); llxHeader('', $title, $help_url); $h = 0; $head[$h][0] = DOL_URL_ROOT.'/variants/card.php?id='.$object->id; $head[$h][1] = $langs->trans("ProductAttributeName"); $head[$h][2] = 'variant'; $h++; print dol_get_fiche_head($head, 'variant', $langs->trans('ProductAttributeName'), -1, 'generic'); print '
'; print '
'; ?>
trans('Ref') ?> ref) ?>
trans('Label') ?> label) ?>
'; print dol_get_fiche_end(); print '
'; print '
'; print ''; print ''; print ''; print ''; print load_fiche_titre($langs->trans('NewProductAttributeValue')); print dol_get_fiche_head(); ?>
'; print ''; print '   '; print ''; print '
'; print ''; // End of page llxFooter(); $db->close();