still dev dis

This commit is contained in:
Yan
2017-06-27 18:32:58 +06:30
parent 950fff469f
commit 58a8cdec6e
5 changed files with 118 additions and 2 deletions

View File

@@ -172,7 +172,7 @@
<div class="col-md-3">
<div class="form-group">
<button id="net" class="btn btn-warning fluid action-btn">Nett</button>
<button id="net" class="btn btn-info fluid action-btn">Nett</button>
<button id="percentage" class="btn btn-primary fluid action-btn">Percentage</button>
<button id="remove-item" class="btn btn-default fluid action-btn">Remove</button>
</div>
@@ -187,6 +187,8 @@
<!-- Action Panel -->
<div>
<button type="button" class="btn btn-primary btn-block" onclick="window.location.href = '/origami';"><i class="fa fa-arrow-left"></i> Back </button>
<button id="remove-item-discount" class="btn btn-warning btn-block action-btn">Remove Discount</button>
<button id="remove-all" class="btn btn-warning btn-block action-btn">Remove All</button>
<button id="pay-discount" class="btn btn-danger btn-block action-btn">Enter</button>
</div>
</div>
@@ -358,6 +360,55 @@ $(document).ready(function(){
}
});
});
// Remove selected given discount item
$("#remove-item-discount").on('click', function(e){
e.preventDefault();
var sale_id = $('#sale-id').text();
var discount_items = [];
// Selected Items
var sale_items = get_selected_sale_items();
for(var i=0;i < sale_items.length;i++){
if(sale_items[i].price < 0){
discount_items.push(sale_items[i]);
}
}
var params = { 'sale_id': sale_id, 'discount_items': JSON.stringify(discount_items) };
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/remove_discount_items",
data: params,
success: function(result){
alert('Removed Discount');
if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id
}
else {
window.location.href = "/origami/room/" + result.table_id
}
}
});
});
$("#remove-all").on('click', function(e){
e.preventDefault();
var sale_id = $('#sale-id').text();
$.ajax({
type: "GET",
url: "/origami/" + sale_id + "/remove_all_discount",
success: function(result){
alert('Removed All Discount');
if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id
}
else {
window.location.href = "/origami/room/" + result.table_id
}
}
});
});
});
/* Remove Selection */