* * 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'); $valueid = GETPOST('valueid'); $action = GETPOST('action'); $label = GETPOST('label'); $ref = GETPOST('ref'); $confirm = GETPOST('confirm'); $cancel = GETPOST('cancel'); $prodattr = new ProductAttribute($db); $prodattrval = new ProductAttributeValue($db); if ($prodattr->fetch($id) < 1) { dol_print_error($db, $langs->trans('ErrorRecordNotFound')); exit(); } /* * Actions */ if ($cancel) $action=''; if ($_POST) { if ($action == 'edit') { $prodattr->label = $label; $prodattr->ref = $ref; if ($prodattr->update() < 1) { setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); } else { setEventMessage($langs->trans('RecordSaved')); header('Location: '.dol_buildpath('/variants/card.php?id='.$id, 2)); exit(); } } elseif ($action == 'edit_value') { if ($prodattrval->fetch($valueid) > 0) { $prodattrval->ref = $ref; $prodattrval->value = GETPOST('value'); if ($prodattrval->update() > 0) { setEventMessage($langs->trans('RecordSaved')); } else { setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); } } header('Location: '.dol_buildpath('/variants/card.php?id='.$prodattr->id, 2)); exit(); } } if ($confirm == 'yes') { if ($action == 'confirm_delete') { $db->begin(); $res = $prodattrval->deleteByFkAttribute($prodattr->id); if ($res < 1 || ($prodattr->delete() < 1)) { $db->rollback(); setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); header('Location: '.dol_buildpath('/variants/card.php?id='.$prodattr->id, 2)); } else { $db->commit(); setEventMessage($langs->trans('RecordSaved')); header('Location: '.dol_buildpath('/variants/list.php', 2)); } exit(); } elseif ($action == 'confirm_deletevalue') { if ($prodattrval->fetch($valueid) > 0) { if ($prodattrval->delete() < 1) { setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); } else { setEventMessage($langs->trans('RecordSaved')); } header('Location: '.dol_buildpath('/variants/card.php?id='.$prodattr->id, 2)); exit(); } } } /* * View */ $langs->load('products'); $title = $langs->trans('ProductAttributeName', dol_htmlentities($prodattr->label)); $var = false; llxHeader('', $title); print_fiche_titre($title); dol_fiche_head(); if ($action == 'edit') { print '
'; } ?>
trans('Ref') ?> ref.'">'; } else { print dol_htmlentities($prodattr->ref); } ?>
trans('Label') ?> label.'">'; } else { print dol_htmlentities($prodattr->label); } ?>
   
formconfirm( "card.php?id=".$prodattr->id, $langs->trans('Delete'), $langs->trans('ProductAttributeDeleteDialog'), "confirm_delete", '', 0, 1 ); } elseif ($action == 'delete_value') { if ($prodattrval->fetch($valueid) > 0) { $form = new Form($db); print $form->formconfirm( "card.php?id=".$prodattr->id."&valueid=".$prodattrval->id, $langs->trans('Delete'), $langs->trans('ProductAttributeValueDeleteDialog', dol_htmlentities($prodattrval->value), dol_htmlentities($prodattrval->ref)), "confirm_deletevalue", '', 0, 1 ); } } ?>
fetchAllByProductAttribute($prodattr->id) as $attrval): ?> > id)): ?>
trans('Ref') ?> trans('Value') ?>
    ref) ?> value) ?>