update edit with remark

This commit is contained in:
Aung Myo
2018-02-26 16:56:57 +06:30
parent 07e208a457
commit b38e98a22a
10 changed files with 123 additions and 61 deletions

View File

@@ -38,7 +38,7 @@
<% @sale_data.sale_items.each do |sale_item| %>
<%
sub_total += sale_item.qty*sale_item.unit_price
if sale_item.price != 0 && sale_item.remark != "void" && sale_item.remark != "foc"
if sale_item.price != 0 && sale_item.status != "void" && sale_item.status != "foc"
%>
<tr class="item-row" id=<%= sale_item.sale_item_id %> >
<td style="width:60%; text-align:left">

View File

@@ -57,7 +57,7 @@
<td class="p-2" width="20%">
<%= sale_item.product_name %>
</td>
<% if sale_item.remark != 'void' && sale_item.remark != 'edit' && sale_item.remark != 'foc' %>
<% if sale_item.status != 'void' && sale_item.status != 'edit' && sale_item.status != 'foc' %>
<td class="p-1" width="5%">
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control "/>
</td>
@@ -69,11 +69,12 @@
</td> -->
<td class="p-1" width="25%">
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-blue waves-effect update'>Update</button>
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-danger waves-effect void'>Void</button>
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-red waves-effect foc'>FOC</button>
<button data-id="<%= sale_item.id %>" data-type="void" class='editModal btn btn-lg bg-danger waves-effect' data-toggle="modal" data-target="#editModal">Void</button>
<button data-id="<%= sale_item.id %>" data-type="foc" class='editModal btn btn-lg bg-danger waves-effect' data-toggle="modal" data-target="#editModal">FOC</button>
</td>
<% elsif sale_item.qty.to_i < 0 || sale_item.remark == 'edit' %>
<% elsif sale_item.qty.to_i < 0 || sale_item.status == 'edit' %>
<td class="p-1" width="5%">
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
</td>
@@ -148,18 +149,48 @@
</div>
</div>
</div> -->
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- Waiter Buttons -->
<button type="button" class="btn btn-block btn-lg bg-default waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
<button type="button" class="btn btn-danger btn- action-btn" id='cancel_all_void'>Cancel All Void</button>
<button type="button" class="btn btn-block btn-lg bg-blue waves-effect" id='apply'>Apply</button>
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- Waiter Buttons -->
<button type="button" class="btn btn-block btn-lg bg-default waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
<button type="button" class="btn btn-danger btn- action-btn" id='cancel_all_void'>Cancel All Void</button>
<button type="button" class="btn btn-block btn-lg bg-blue waves-effect" id='apply'>Apply</button>
</div>
</div>
</div>
<div class="modal fade" id="editModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="editModalLabel">Please Enter Remark</h4>
</div>
<div class="modal-body">
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="remark">
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<div class="col-md-5">
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-red waves-effect" id="action">VOID</button>
</div>
<div class="col-md-5">
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
// Bill Request
$(document).ready(function () {
$('.editModal').on('click', function () {
$("#action").attr('data-type', $(this).attr('data-type'));
$("#action").attr('data-id', $(this).attr('data-id'));
$("#action").text($(this).attr('data-type'))
})
$(".update").on('click', function () {
var sale_item_id = $(this).attr('data-id');
@@ -182,13 +213,14 @@
});
});
$('.void').on('click', function () {
/*$('.void').on('click', function () {
var sale_item_id = $(this).attr('data-id');
var remark = $("#remark").val();
var ajax_url = "/origami/item_void";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id,
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark,
success: function (result) {
location.reload();
}
@@ -201,7 +233,27 @@
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id,
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark,
success: function (result) {
location.reload();
}
});
})*/
$('#action').on('click', function () {
var sale_item_id = $(this).attr('data-id');
var type = $(this).attr('data-type');
var remark = $("#remark").val();
if (type=='foc') {
var ajax_url = "/origami/item_foc";
}else{
var ajax_url = "/origami/item_void";
}
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark,
success: function (result) {
location.reload();
}
@@ -224,6 +276,7 @@
})
$('#back').on('click', function () {
var table_id = '<%= @table_id %>'
window.location.href = '/origami/table/' + table_id;