Skip to content

Commit

Permalink
Merge pull request #405 from cbattarel/develop
Browse files Browse the repository at this point in the history
correct some ajax bugs caused by tpl recent updates
  • Loading branch information
eldy committed Sep 19, 2012
2 parents a68483d + de93c81 commit 9bc0011
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
6 changes: 3 additions & 3 deletions htdocs/core/tpl/objectline_edit.tpl.php
Expand Up @@ -329,9 +329,9 @@ function(data) {

<?php } ?>

<?php if (! empty($conf->margin->enabled)) { ?>
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': <?php echo $line->fk_product; ?>}, function(data) {
if (data.length > 0) {
<?php if (! empty($conf->margin->enabled)) { ?>
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': <?php echo $line->fk_product?$line->fk_product:0; ?>}, function(data) {
if (data && data.length > 0) {
var options = '';
var trouve=false;
$(data).each(function() {
Expand Down
22 changes: 12 additions & 10 deletions htdocs/core/tpl/predefinedproductline_create.tpl.php
Expand Up @@ -140,31 +140,33 @@
?>
<script type="text/javascript">
$("#idprod").change(function() {
$("#np_fournprice options").remove();
$("#np_buying_price").show();
$("#fournprice options").remove();
$("#fournprice").hide();
$("#buying_price").val("");
$("#buying_price").show();
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': $(this).val()}, function(data) {
if (data.length > 0) {
if (data && data.length > 0) {
var options = '';
var i = 0;
$(data).each(function() {
i++;
options += '<option value="'+this.id+'" price="'+this.price+'"';
if (i == 1) {
options += ' selected';
$("#np_buying_price").val(this.price);
$("#buying_price").val(this.price);
}
options += '>'+this.label+'</option>';
});
options += '<option value=null><?php echo $langs->trans("InputPrice"); ?></option>';
$("#np_fournprice").html(options);
$("#np_buying_price").hide();
$("#np_fournprice").show();
$("#np_fournprice").change(function() {
$("#fournprice").html(options);
$("#buying_price").hide();
$("#fournprice").show();
$("#fournprice").change(function() {
var selval = $(this).find('option:selected').attr("price");
if (selval)
$("#np_buying_price").val(selval).hide();
$("#buying_price").val(selval).hide();
else
$('#np_buying_price').show();
$('#buying_price').show();
});
}
},
Expand Down

0 comments on commit 9bc0011

Please sign in to comment.