diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index a611767cf2f..f5d35019971 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -19,13 +19,13 @@ 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'); +$id = GETPOST('id','int'); +$valueid = GETPOST('valueid','alpha'); +$action = GETPOST('action','alpha'); +$label = GETPOST('label','alpha'); +$ref = GETPOST('ref','alpha'); +$confirm = GETPOST('confirm','alpha'); +$cancel = GETPOST('cancel','alpha'); $object = new ProductAttribute($db); $objectval = new ProductAttributeValue($db); @@ -92,10 +92,10 @@ if ($confirm == 'yes') { setEventMessage($langs->trans('RecordSaved')); header('Location: '.dol_buildpath('/variants/list.php', 2)); } - exit(); - } elseif ($action == 'confirm_deletevalue') { - + } + elseif ($action == 'confirm_deletevalue') + { if ($objectval->fetch($valueid) > 0) { if ($objectval->delete() < 1) { diff --git a/htdocs/variants/create_val.php b/htdocs/variants/create_val.php index a5ee085cf40..2f463286787 100644 --- a/htdocs/variants/create_val.php +++ b/htdocs/variants/create_val.php @@ -1,5 +1,4 @@ * * This program is free software; you can redistribute it and/or modify @@ -20,83 +19,130 @@ require '../main.inc.php'; require 'class/ProductAttribute.class.php'; require 'class/ProductAttributeValue.class.php'; -$id = GETPOST('id'); -$ref = GETPOST('ref'); -$value = GETPOST('value'); +$id = GETPOST('id','int'); +$ref = GETPOST('ref','alpha'); +$value = GETPOST('value','alpha'); -$prodattr = new ProductAttribute($db); -$prodattrval = new ProductAttributeValue($db); +$action=GETPOST('action','alpha'); +$cancel=GETPOST('cancel','alpha'); +$backtopage=GETPOST('backtopage','alpha'); -if ($prodattr->fetch($id) < 1) { +$object = new ProductAttribute($db); +$objectval = new ProductAttributeValue($db); + +if ($object->fetch($id) < 1) { dol_print_error($db, $langs->trans('ErrorRecordNotFound')); exit(); } -if ($_POST) { +/* + * 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)) { setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors'); } else { - $prodattrval->fk_product_attribute = $prodattr->id; - $prodattrval->ref = $ref; - $prodattrval->value = $value; + $objectval->fk_product_attribute = $object->id; + $objectval->ref = $ref; + $objectval->value = $value; - if ($prodattrval->create() > 0) { + if ($objectval->create() > 0) { setEventMessage($langs->trans('RecordSaved')); - header('Location: '.dol_buildpath('/variants/card.php?id='.$prodattr->id, 2)); + header('Location: '.DOL_URL_ROOT.'/variants/card.php?id='.$object->id); exit(); } else { setEventMessage($langs->trans('ErrorCreatingProductAttributeValue'), 'errors'); } } - } $langs->load('products'); -$title = $langs->trans('ProductAttributeName', dol_htmlentities($prodattr->label)); +$title = $langs->trans('ProductAttributeName', dol_htmlentities($object->label)); llxHeader('', $title); -print_fiche_titre($title); +$h=0; +$head[$h][0] = DOL_URL_ROOT.'/variants/card.php?id='.$object->id; +$head[$h][1] = $langs->trans("Card"); +$head[$h][2] = 'variant'; +$h++; -dol_fiche_head(); +dol_fiche_head($head, 'variant', $langs->trans('ProductAttributeName'), -1, 'generic'); +print '
| trans('Ref') ?> | -ref) ?> + | trans('Ref') ?> | +ref) ?> |
| trans('Label') ?> | -label) ?> | +trans('Label') ?> | +label) ?> |