Update
This commit is contained in:
@@ -43,10 +43,10 @@ class OrderItem < ApplicationRecord
|
||||
def self.get_order_items_details(booking_id)
|
||||
# booking_orders = BookingOrder.where("booking_id=?",booking.booking_id)
|
||||
# if booking_orders
|
||||
# booking_orders.each do |book_order|
|
||||
# booking_orders.each do |book_order|
|
||||
# order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price")
|
||||
# .joins("left join orders on orders.order_id = order_items.order_id")
|
||||
# .where("order_items.order_id=?",book_order.order)
|
||||
# .where("order_items.order_id=?",book_order.order)
|
||||
# return order_details
|
||||
# end
|
||||
# else
|
||||
@@ -57,9 +57,9 @@ class OrderItem < ApplicationRecord
|
||||
.joins("left join orders on orders.order_id = order_items.order_id")
|
||||
.joins("left join booking_orders on booking_orders.order_id = order_items.order_id")
|
||||
.joins("left join bookings on bookings.booking_id = booking_orders.booking_id")
|
||||
.where("bookings.booking_id=?",booking_id)
|
||||
.where("bookings.booking_id=?",booking_id)
|
||||
|
||||
return order_details
|
||||
return order_details
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -21,7 +21,7 @@ class ShiftSale < ApplicationRecord
|
||||
#find open shift where is open today and is not closed and login by current cashier
|
||||
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
|
||||
#end
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<% @float.each do |float| %>
|
||||
<tr>
|
||||
<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>
|
||||
<% end %>
|
||||
<tr>
|
||||
@@ -25,12 +25,7 @@
|
||||
<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 class='col-md-8'>
|
||||
<div class="row">
|
||||
@@ -56,9 +51,9 @@
|
||||
<div class=" cashier_number left" data-value="00" data-type="num">00</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class=" cashier_number red" data-type="del" >Del</div>
|
||||
<div class=" cashier_number orange left" data-type="clr">Clr</div>
|
||||
<div class=" cashier_number purple left" data-type="ent">Ent</div>
|
||||
<div class=" cashier_number orange " data-type="clr">Clr</div>
|
||||
<div class=" cashier_number left" data-type='ent' >Calculate</div>
|
||||
<div class=" cashier_number purple left" id="open_cashier">Open Cashier</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -67,17 +62,54 @@
|
||||
</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)
|
||||
|
||||
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(){
|
||||
var cashier_terminal = $('#cashier_terminal').val();
|
||||
alert(cashier_terminal)
|
||||
var amount = $('#total').text();
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= origami_shifts_path %>",
|
||||
|
||||
Reference in New Issue
Block a user