Update
This commit is contained in:
@@ -21,7 +21,7 @@ class ShiftSale < ApplicationRecord
|
|||||||
#find open shift where is open today and is not closed and login by current cashier
|
#find open shift where is open today and is not closed and login by current cashier
|
||||||
today_date = DateTime.now.strftime("%Y-%m-%d")
|
today_date = DateTime.now.strftime("%Y-%m-%d")
|
||||||
|
|
||||||
shift = ShiftSale.where("DATE(shift_started_at)= #{ today_date } and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take
|
shift = ShiftSale.where("DATE(shift_started_at)=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}",today_date).take
|
||||||
|
|
||||||
return shift
|
return shift
|
||||||
#end
|
#end
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<% @float.each do |float| %>
|
<% @float.each do |float| %>
|
||||||
<tr>
|
<tr>
|
||||||
<th><%= float.name %></th>
|
<th><%= float.name %></th>
|
||||||
<th><input class='float-value' type='text' data-value ="<%= float.value %>" value='' /></th>
|
<th><input class='float-value' type='text' data-value ="<%= float.value %>" value='0' id='<%= float.value %>'></input></th>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -25,12 +25,7 @@
|
|||||||
<th><div id='total'></div></th>
|
<th><div id='total'></div></th>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</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>
|
||||||
<div class='col-md-8'>
|
<div class='col-md-8'>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -56,9 +51,9 @@
|
|||||||
<div class=" cashier_number left" data-value="00" data-type="num">00</div>
|
<div class=" cashier_number left" data-value="00" data-type="num">00</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row bottom">
|
<div class="row bottom">
|
||||||
<div class=" cashier_number red" data-type="del" >Del</div>
|
<div class=" cashier_number orange " data-type="clr">Clr</div>
|
||||||
<div class=" cashier_number orange left" data-type="clr">Clr</div>
|
<div class=" cashier_number left" data-type='ent' >Calculate</div>
|
||||||
<div class=" cashier_number purple left" data-type="ent">Ent</div>
|
<div class=" cashier_number purple left" id="open_cashier">Open Cashier</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -67,17 +62,54 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<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)
|
|
||||||
|
|
||||||
|
var float_value = ""
|
||||||
|
var total = 0
|
||||||
|
|
||||||
|
$(document).on('focusout', '.float-value', function(event){
|
||||||
|
float_value = $(this).attr("data-value");
|
||||||
|
$(document).on('click', '.cashier_number', function(event){
|
||||||
|
if(event.handled !== true) {
|
||||||
|
var input_type = $(this).attr("data-type");
|
||||||
|
switch (input_type) {
|
||||||
|
case 'num':
|
||||||
|
var input_value = $(this).attr("data-value");
|
||||||
|
var original = $('#'+float_value).val();
|
||||||
|
if (original == "0"){
|
||||||
|
$('#'+float_value).val(input_value);
|
||||||
|
}else{
|
||||||
|
$('#'+float_value).val(original + input_value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'clr':
|
||||||
|
$('#cash').text("0");
|
||||||
|
break;
|
||||||
|
case 'ent':
|
||||||
|
var sum = 0
|
||||||
|
<%
|
||||||
|
sum = 0
|
||||||
|
@float.each do |float|
|
||||||
|
%>
|
||||||
|
var float = "<%= float.value %>"
|
||||||
|
console.log(float)
|
||||||
|
var cal = $('#'+ float).val() * float
|
||||||
|
sum += cal;
|
||||||
|
<%
|
||||||
|
end
|
||||||
|
%>
|
||||||
|
total = sum
|
||||||
|
$('#total').text(total)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
event.handled = true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
$('#open_cashier').on('click',function(){
|
$('#open_cashier').on('click',function(){
|
||||||
var cashier_terminal = $('#cashier_terminal').val();
|
var cashier_terminal = $('#cashier_terminal').val();
|
||||||
alert(cashier_terminal)
|
|
||||||
var amount = $('#total').text();
|
var amount = $('#total').text();
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_shifts_path %>",
|
url: "<%= origami_shifts_path %>",
|
||||||
|
|||||||
Reference in New Issue
Block a user