update addorder view
This commit is contained in:
@@ -45,50 +45,46 @@
|
||||
<td class="item-attr"><strong id="sub_total">0.00</strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-success create" id="create_order" disabled="disabled">Create Order</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal fade" id="sx_itemModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<button type="button" id="remove" class="btn btn-default" data-dismiss="modal" style="float:right;margin-right:30px;">Remove Item</button>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title"></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-offset-6 col-md-offset-6 col-sm-offset-6 col-sm-6 col-md-6 col-lg-6">
|
||||
<span id="item_err_msg"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-6" style="width: 14.499999995%">
|
||||
<label for="ex1">Qty</label>
|
||||
<input type="hidden" id="modal_product_name">
|
||||
<input type="hidden" id="modal_product_sku">
|
||||
<input type="hidden" class="current_textbox">
|
||||
<div id="modal_qty" class="form-control" ></div>
|
||||
</div>
|
||||
<table width="100%" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="">Item Name</th>
|
||||
<th style="">Quantity</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="item_name" id="modal-item-name"></td>
|
||||
<td>
|
||||
<input type="number" name="qty" class="form-control col-md-12 input-number" id="modal-qty" value="" min="1" max="100">
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" id="remove" class="btn btn-danger" data-dismiss="modal">Remove</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<label for="ex1" style='width:50%;'>Price</label><span class="minus btn btn-default btn-xs" style='width:50%;'>-</span>
|
||||
<div id="modal_price" class="form-control" ></div>
|
||||
<input type="button" class="btn btn-primary btn-lg btn-block" id="clear" value="Clear">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary">Save changes</button>
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal" id="close">Close</button>
|
||||
<button type="button" class="btn btn-success" data-dismiss="modal" id="save">Update</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -97,7 +93,7 @@
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function(){
|
||||
|
||||
|
||||
//click menu sidebar menu category
|
||||
$(".menu_category").on("click", function(){
|
||||
var menu_id = $(this).find(".menu-id").text();
|
||||
@@ -179,15 +175,15 @@ $(function(){
|
||||
|
||||
// click plus icon for add
|
||||
$(document).on('click', '.add_icon', function(event){
|
||||
var item_data = $(this);
|
||||
show_item_detail(item_data);
|
||||
calculate_sub_total();
|
||||
var item_data = $(this);
|
||||
show_item_detail(item_data);
|
||||
calculate_sub_total();
|
||||
}); //End Add Icon Click
|
||||
|
||||
function show_item_detail(data){
|
||||
qty = 1;
|
||||
append = 0;
|
||||
price = data.attr('data-price');
|
||||
price = parseFloat(data.attr('data-price')).toFixed(2);
|
||||
instance_code = data.attr('data-instance');
|
||||
|
||||
if (instance_code == "undefined"){
|
||||
@@ -203,7 +199,8 @@ $(function(){
|
||||
if ($(item_row[i]).attr('data-code') == data.attr('data-item-code')) {
|
||||
qty = parseInt($(item_row[i]).children('#item_qty').text()) +1;
|
||||
$(item_row[i]).children('#item_qty').text(qty);
|
||||
$(item_row[i]).children('#item_price').text(price*qty);
|
||||
parseFloat($(item_row[i]).children('#item_price').text(price*qty)).toFixed(2);
|
||||
|
||||
append = 1;
|
||||
}else{
|
||||
qty = 1;
|
||||
@@ -211,9 +208,9 @@ $(function(){
|
||||
});
|
||||
|
||||
if (append===0) {
|
||||
row ="<tr data-price ='"+price+ "'data-toggle='modal' data-target='#myModal' 'data-instance ='"+instance+ "'data-code='"+data.attr('data-item-code')+"'>"
|
||||
row ="<tr class='item_box' data-price ='"+price+ "'data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"+instance+ "'data-code='"+data.attr('data-item-code')+"'>"
|
||||
+'<td class="item-cell-no">'+rowCount+'</td>'
|
||||
+'<td class="item-cell-name" >' + data.attr('data-name')+ ' ' + instance + '</td>'
|
||||
+'<td class="item-cell-name" id="item_name" >' + data.attr('data-name')+ ' ' + instance + '</td>'
|
||||
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
|
||||
+'<td class="item-cell-price" id="item_price">'
|
||||
+ parseFloat(price).toFixed(2)
|
||||
@@ -224,29 +221,77 @@ $(function(){
|
||||
|
||||
}
|
||||
|
||||
//click item row for update qty
|
||||
$('.summary-items').on('click', '.item_box', function(){
|
||||
$(this).attr('data-active',true);
|
||||
name = $(this).children('#item_name').text();
|
||||
qty = $(this).children('#item_qty').text();
|
||||
$('#modal-item-name').text(name);
|
||||
$('#modal-qty').val(qty);
|
||||
});
|
||||
|
||||
//click remove buttom in modal box
|
||||
$('#sx_itemModal').on('click','#remove', function(){
|
||||
$('.summary-items tr').filter(function(){
|
||||
if ($(this).attr('data-active') == 'true'){
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
calculate_sub_total();
|
||||
});
|
||||
|
||||
//click close
|
||||
$('#sx_itemModal').on('click','#close', function(){
|
||||
$(".item_box").removeAttr("data-active");
|
||||
});
|
||||
|
||||
//click save buttom after change qty
|
||||
$('#sx_itemModal').on('click','#save', function(){
|
||||
summary_items_filter();
|
||||
calculate_sub_total();
|
||||
});
|
||||
|
||||
//calculate subtotal
|
||||
function calculate_sub_total(){
|
||||
var total_price = 0;
|
||||
var taxable_amount = 0;
|
||||
var item_row = $('.summary-items tbody tr');
|
||||
|
||||
$(item_row).each(function(i){
|
||||
// var taxable = $(item_row[i]).attr('data-taxable');
|
||||
var unit_price = parseFloat($(item_row[i]).attr('data-price'));
|
||||
var qty = parseFloat($(item_row[i]).children('#item_qty').text());
|
||||
// if(taxable == 'true'){
|
||||
// taxable_amount += qty*unit_price;
|
||||
// }
|
||||
total_price += qty*unit_price;
|
||||
});
|
||||
var fixed_total_price = parseFloat(total_price).toFixed(2);
|
||||
var fixed_taxable_amount = parseFloat(taxable_amount).toFixed(2);
|
||||
|
||||
$('#sub_total').empty();
|
||||
$('#sub_total').append(fixed_total_price);
|
||||
// $('#sub_total').attr('taxable_amount',fixed_taxable_amount);
|
||||
// $('#show_sub').text(fixed_total_price);
|
||||
}
|
||||
|
||||
});
|
||||
if (fixed_total_price > 0) {
|
||||
$('.create').removeAttr("disabled", false);
|
||||
}else{
|
||||
$('.create').attr("disabled", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function summary_items_filter(){
|
||||
$('.summary-items tr').filter(function(){
|
||||
|
||||
if ($(this).attr('data-active') == 'true'){
|
||||
qty = $('#modal-qty').val();
|
||||
price = parseFloat($(this).attr('data-price'));
|
||||
total_price = parseFloat(price*qty).toFixed(2);
|
||||
|
||||
$(this).find('#item_qty').text(qty);
|
||||
$(this).find('.item-cell-price').text(total_price);
|
||||
|
||||
$(this).removeAttr('data-active');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user