shift
This commit is contained in:
@@ -1,2 +1,46 @@
|
||||
<h1>Origami::Shifts#new</h1>
|
||||
<p>Find me in app/views/origami/shifts/new.html.erb</p>
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user