Files
sx-fc/app/views/origami/shifts/new.html.erb
2017-06-28 15:29:44 +06:30

47 lines
1.2 KiB
Plaintext

<h1>Open Cashier</h1>
<br>
<div class="row">
<div class="col-md-4">
<table class='table table-striped'>
<% @float.each do |float| %>
<tr>
<th><%= float.name %></th>
<th><input class='float-value' type='text' data-value ="<%= float.value %>" value='' /></th>
</tr>
<% end %>
<tr>
<th>Total</th>
<th><div id='total'></div></th>
</tr>
</table>
<div class="row">
<div class='col-md-4'></div>
<div class='col-md-2'>
<button class='btn btn-primary' id='open_cashier'>Open Cashier</button>
</div>
</div>
</div>
</div>
<script>
var total = 0
$(document).on('focusout', '.float-value', function(event){
var input_type = $(this).attr("data-value");
var count = $(this).val();
total += input_type * count
$('#total').text(total)
})
$('#open_cashier').on('click',function(){
var amount = $('#total').text();
$.ajax({type: "POST",
url: "<%= origami_shifts_path %>",
data: "opening_balance=" + amount,
success:function(result){
if(result){
window.location.href = '/origami';
}
}
});
})
</script>