* 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_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php'; $ref = GETPOST('ref', 'alpha'); $label = GETPOST('label', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); /* * Actions */ if ($_POST) { if (empty($ref) || empty($label)) { setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors'); } else { $prodattr = new ProductAttribute($db); $prodattr->label = $label; $prodattr->ref = $ref; $resid = $prodattr->create($user); if ($resid > 0) { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); if ($backtopage) { header('Location: '.$backtopage); } else { header('Location: '.DOL_URL_ROOT.'/variants/card.php?id='.$resid.'&backtopage='.urlencode($backtopage)); } exit; } else { setEventMessages($langs->trans('ErrorRecordAlreadyExists'), $prodattr->errors, 'errors'); } } } $langs->load('products'); /* * View */ $title = $langs->trans('NewProductAttribute'); llxHeader('', $title); print_fiche_titre($title); dol_fiche_head(); print '
'; print ''; print ''; print ''; ?>
trans("VariantRefExample"); ?>
trans("VariantLabelExample"); ?>
'; print '
'; // End of page llxFooter(); $db->close();