Skip to content

Commit

Permalink
Default price for margin was not set
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jul 28, 2015
1 parent a753755 commit 5cea60c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions htdocs/core/tpl/objectline_create.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ function price2numjs(num)
jQuery('#trlinefordates').show();
});

/* Sur changemenr de produit, on recharge la liste des prix fournisseur */
/* When changing predefined product, we reload list of supplier prices */
$("#idprod, #idprodfournprice").change(function()
{
setforpredef();
Expand Down Expand Up @@ -521,23 +521,31 @@ function price2numjs(num)
if (this.id != 'pmpprice')
{
i++;

// If margin is calculated on best supplier price, we set it by defaut (but only if value is not 0)
var defaultbuyprice = '<?php echo ((isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1')?'bestsupplierprice':''); ?>';
if (i == 1 && this.price > 0 && 'bestsupplierprice' == defaultbuyprice) { defaultkey = this.id; defaultprice = this.price; }

options += '<option value="'+this.id+'" price="'+this.price+'"';
if (this.price > 0 && i == 1) { defaultkey = this.id; defaultprice = this.price; }
options += '>'+this.label+'</option>';
}
if (this.id == 'pmpprice')
{
// If margin is calculated on PMP, we set it by defaut (but only if value is not 0)
var defaultbuyprice = <?php echo ((isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp')?1:0); ?>;
if (this.price > 0 && 1 == defaultbuyprice) { defaultkey = this.id; defaultprice = this.price; }
var defaultbuyprice = '<?php echo ((isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp')?'pmp':''); ?>';
if (this.price > 0 && 'pmp' == defaultbuyprice) { defaultkey = this.id; defaultprice = this.price; }

options += '<option value="'+this.id+'" price="'+this.price+'">'+this.label+'</option>';
}
});
options += '<option value="inputprice" price="'+defaultprice+'"><?php echo $langs->trans("InputPrice"); ?></option>';

/* alert(defaultkey+' '+defaultprice); */
$("#fournprice_predef").html(options).show();
$("#fournprice_predef").val(defaultkey);
if (defaultkey != '')
{
$("#fournprice_predef").val(defaultkey);
}

/* At loading, no product are yet selected, so we hide field of buying_price */
$("#buying_price").hide();
Expand Down

0 comments on commit 5cea60c

Please sign in to comment.