Skip to content

Commit

Permalink
Merge pull request #8329 from BadPixxel/7.0
Browse files Browse the repository at this point in the history
BugFix Issue #8261: Variants module. Combinations cannot be edited
  • Loading branch information
eldy committed Mar 10, 2018
2 parents 74dc815 + 6c9e0e1 commit 0b1b740
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
6 changes: 3 additions & 3 deletions htdocs/product/class/product.class.php
Expand Up @@ -1677,7 +1677,7 @@ function updatePrice($newprice, $newpricebase, $user, $newvat='',$newminprice=0,
return -1;
}

if ($newprice != '' || $newprice == 0)
if ($newprice !== '' || $newprice === 0)
{
if ($newpricebase == 'TTC')
{
Expand All @@ -1703,8 +1703,8 @@ function updatePrice($newprice, $newpricebase, $user, $newvat='',$newminprice=0,
$price_ttc = ( $newnpr != 1 ) ? price2num($newprice) * (1 + ($newvat / 100)) : $price;
$price_ttc = price2num($price_ttc,'MU');

if ($newminprice != '' || $newminprice == 0)
{
if ( $newminprice !== '' || $newminprice === 0)
{
$price_min = price2num($newminprice,'MU');
$price_min_ttc = price2num($newminprice) * (1 + ($newvat / 100));
$price_min_ttc = price2num($price_min_ttc,'MU');
Expand Down
36 changes: 19 additions & 17 deletions htdocs/variants/combinations.php
Expand Up @@ -346,12 +346,12 @@
foreach ($prodattr_all as $each) {
$prodattr_alljson[$each->id] = $each;
}

?>

<script type="text/javascript">

variants_available = <?php echo json_encode($prodattr_alljson) ?>;
variants_available = <?php echo json_encode($prodattr_alljson); ?>;
variants_selected = {
index: [],
info: []
Expand Down Expand Up @@ -425,8 +425,11 @@
print '<form method="post" id="combinationform" action="'.$_SERVER["PHP_SELF"].'">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="id" value="'.dol_escape_htmltag($id).'">'."\n";
print '<input type="hidden" name="action" value="create">'."\n";

print '<input type="hidden" name="action" value="' . (($valueid > 0) ? "update" : "create") .'">'."\n";
if($valueid > 0) {
print '<input type="hidden" name="valueid" value="' . $valueid .'">'."\n";
}

print dol_fiche_head();

?>
Expand Down Expand Up @@ -485,7 +488,7 @@
<?php
}

if (is_array($selectedvariant)) {
if (is_array($productCombination2ValuePairs1)) {
?>
<hr>
<table class="border" style="width: 100%">
Expand All @@ -494,18 +497,17 @@
<td class="tdtop">
<div class="inline-block valignmiddle quatrevingtpercent">
<?php
if (is_array($selectedvariant))
if (is_array($productCombination2ValuePairs1))
{
foreach ($selectedvariant as $key => $val) {
$tmp = explode(':',$val);
$result1 = $prodattr->fetch($tmp[0]);
$result2 = $prodattr_val->fetch($tmp[1]);
if ($result1 > 0 && $result2 > 0)
{
print $prodattr->label . ' - '.$prodattr_val->value.'<br>';
// TODO Add delete link
}
}
foreach ($productCombination2ValuePairs1 as $key => $val) {
$result1 = $prodattr->fetch($val->fk_prod_attr);
$result2 = $prodattr_val->fetch($val->fk_prod_attr_val);
if ($result1 > 0 && $result2 > 0)
{
print $prodattr->label . ' - '.$prodattr_val->value.'<br>';
// TODO Add delete link
}
}
}
?>
</div>
Expand Down Expand Up @@ -533,7 +535,7 @@
?>

<div style="text-align: center">
<input type="submit" name="create" <?php if (! is_array($selectedvariant)) print ' disabled="disabled"'; ?> value="<?php echo $action == 'add' ? $langs->trans('Create') : $langs->trans('Save') ?>" class="button">
<input type="submit" name="create" <?php if (! is_array($productCombination2ValuePairs1)) print ' disabled="disabled"'; ?> value="<?php echo $action == 'add' ? $langs->trans('Create') : $langs->trans('Save') ?>" class="button">
&nbsp;
<input type="submit" name="cancel" value="<?php echo $langs->trans('Cancel'); ?>" class="button">
</div>
Expand Down

0 comments on commit 0b1b740

Please sign in to comment.