Debug variant module
This commit is contained in:
parent
8e25155fc9
commit
9b4b096e86
@ -19,13 +19,13 @@ require '../main.inc.php';
|
|||||||
require 'class/ProductAttribute.class.php';
|
require 'class/ProductAttribute.class.php';
|
||||||
require 'class/ProductAttributeValue.class.php';
|
require 'class/ProductAttributeValue.class.php';
|
||||||
|
|
||||||
$id = GETPOST('id');
|
$id = GETPOST('id','int');
|
||||||
$valueid = GETPOST('valueid');
|
$valueid = GETPOST('valueid','alpha');
|
||||||
$action = GETPOST('action');
|
$action = GETPOST('action','alpha');
|
||||||
$label = GETPOST('label');
|
$label = GETPOST('label','alpha');
|
||||||
$ref = GETPOST('ref');
|
$ref = GETPOST('ref','alpha');
|
||||||
$confirm = GETPOST('confirm');
|
$confirm = GETPOST('confirm','alpha');
|
||||||
$cancel = GETPOST('cancel');
|
$cancel = GETPOST('cancel','alpha');
|
||||||
|
|
||||||
$object = new ProductAttribute($db);
|
$object = new ProductAttribute($db);
|
||||||
$objectval = new ProductAttributeValue($db);
|
$objectval = new ProductAttributeValue($db);
|
||||||
@ -92,10 +92,10 @@ if ($confirm == 'yes') {
|
|||||||
setEventMessage($langs->trans('RecordSaved'));
|
setEventMessage($langs->trans('RecordSaved'));
|
||||||
header('Location: '.dol_buildpath('/variants/list.php', 2));
|
header('Location: '.dol_buildpath('/variants/list.php', 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
exit();
|
exit();
|
||||||
} elseif ($action == 'confirm_deletevalue') {
|
}
|
||||||
|
elseif ($action == 'confirm_deletevalue')
|
||||||
|
{
|
||||||
if ($objectval->fetch($valueid) > 0) {
|
if ($objectval->fetch($valueid) > 0) {
|
||||||
|
|
||||||
if ($objectval->delete() < 1) {
|
if ($objectval->delete() < 1) {
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
|
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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/ProductAttribute.class.php';
|
||||||
require 'class/ProductAttributeValue.class.php';
|
require 'class/ProductAttributeValue.class.php';
|
||||||
|
|
||||||
$id = GETPOST('id');
|
$id = GETPOST('id','int');
|
||||||
$ref = GETPOST('ref');
|
$ref = GETPOST('ref','alpha');
|
||||||
$value = GETPOST('value');
|
$value = GETPOST('value','alpha');
|
||||||
|
|
||||||
$prodattr = new ProductAttribute($db);
|
$action=GETPOST('action','alpha');
|
||||||
$prodattrval = new ProductAttributeValue($db);
|
$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'));
|
dol_print_error($db, $langs->trans('ErrorRecordNotFound'));
|
||||||
exit();
|
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)) {
|
if (empty($ref) || empty($value)) {
|
||||||
setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors');
|
setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors');
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$prodattrval->fk_product_attribute = $prodattr->id;
|
$objectval->fk_product_attribute = $object->id;
|
||||||
$prodattrval->ref = $ref;
|
$objectval->ref = $ref;
|
||||||
$prodattrval->value = $value;
|
$objectval->value = $value;
|
||||||
|
|
||||||
if ($prodattrval->create() > 0) {
|
if ($objectval->create() > 0) {
|
||||||
setEventMessage($langs->trans('RecordSaved'));
|
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();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
setEventMessage($langs->trans('ErrorCreatingProductAttributeValue'), 'errors');
|
setEventMessage($langs->trans('ErrorCreatingProductAttributeValue'), 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$langs->load('products');
|
$langs->load('products');
|
||||||
|
|
||||||
$title = $langs->trans('ProductAttributeName', dol_htmlentities($prodattr->label));
|
$title = $langs->trans('ProductAttributeName', dol_htmlentities($object->label));
|
||||||
|
|
||||||
llxHeader('', $title);
|
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 '<div class="fichecenter">';
|
||||||
|
print '<div class="underbanner clearboth"></div>';
|
||||||
?>
|
?>
|
||||||
<table class="border" style="width: 100%">
|
<table class="border" style="width: 100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 15%" class="fieldrequired"><?php echo $langs->trans('Ref') ?></td>
|
<td class="titlefield fieldrequired"><?php echo $langs->trans('Ref') ?></td>
|
||||||
<td><?php echo dol_htmlentities($prodattr->ref) ?>
|
<td><?php echo dol_htmlentities($object->ref) ?>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 15%" class="fieldrequired"><?php echo $langs->trans('Label') ?></td>
|
<td class="fieldrequired"><?php echo $langs->trans('Label') ?></td>
|
||||||
<td><?php echo dol_htmlentities($prodattr->label) ?></td>
|
<td><?php echo dol_htmlentities($object->label) ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
|
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
|
|
||||||
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<input type="hidden" name="action" value="add">';
|
||||||
|
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||||
|
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
||||||
|
|
||||||
print_fiche_titre($langs->trans('NewProductAttributeValue'));
|
print_fiche_titre($langs->trans('NewProductAttributeValue'));
|
||||||
|
|
||||||
dol_fiche_head();
|
dol_fiche_head();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<form method="post">
|
|
||||||
<table class="border" style="width: 100%">
|
<table class="border" style="width: 100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 15%" class="fieldrequired"><label for="ref"><?php echo $langs->trans('Ref') ?></label></td>
|
<td class="titlefield fieldrequired"><label for="ref"><?php echo $langs->trans('Ref') ?></label></td>
|
||||||
<td><input id="ref" type="text" name="ref" value="<?php echo $ref ?>"></td>
|
<td><input id="ref" type="text" name="ref" value="<?php echo $ref ?>"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 15%" class="fieldrequired"><label for="value"><?php echo $langs->trans('Value') ?></label></td>
|
<td class="fieldrequired"><label for="value"><?php echo $langs->trans('Value') ?></label></td>
|
||||||
<td><input id="value" type="text" name="value" value="<?php echo $value ?>"></td>
|
<td><input id="value" type="text" name="value" value="<?php echo $value ?>"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
|
|
||||||
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Create").'"></div></form>';
|
print '<div class="center">';
|
||||||
|
print '<input type="submit" class="button" name="create" value="'.$langs->trans("Create").'">';
|
||||||
|
print ' ';
|
||||||
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
llxFooter();
|
print '</form>';
|
||||||
|
|
||||||
|
llxFooter();
|
||||||
|
$db->close();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user