tables origami
This commit is contained in:
@@ -8,18 +8,16 @@ class Origami::HomeController < BaseOrigamiController
|
||||
left join order_items on order_items.order_id = orders.id")
|
||||
.where("orders.order_type=? and dining_facilities.is_active=?","dine_in",true)
|
||||
.group("orders.id")
|
||||
|
||||
end
|
||||
def show
|
||||
@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.id = order_items.order_id")
|
||||
.where("order_items.order_id=?",params[:order_id])
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json{
|
||||
render :json => @order_details.to_json
|
||||
}
|
||||
end
|
||||
|
||||
.where("order_items.order_id=?",params[:order_id])
|
||||
# render :json => @order_details.to_json
|
||||
str = []
|
||||
@order_details.each do |ord_detail|
|
||||
str.push(ord_detail)
|
||||
end
|
||||
render :json => str.to_json
|
||||
end
|
||||
end
|
||||
|
||||
@@ -196,23 +196,18 @@
|
||||
<div id="table-details" class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll">
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<% sub_total = 0%>
|
||||
<% if @order_details%>
|
||||
<% @order_details.each do |order_detail| %>
|
||||
<tr>
|
||||
<td style="width:60%; text-align:left">
|
||||
<%=order_detail.item_name%> @ <%=order_detail.price%>
|
||||
<span id="item-name-price"></span>
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
<%=order_detail.qty%>
|
||||
<span id="item-qty"></span>
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
<%=order_detail.total_price%>
|
||||
<%sub_total+=order_detail.total_price%>
|
||||
<span id="item-total-price"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -220,13 +215,13 @@
|
||||
<table class="table" style="margin-bottom:0px">
|
||||
<tfooter>
|
||||
<tr>
|
||||
<td style="width:80%; text-align:left; border-top:none"><strong>Total Amount</strong></td>
|
||||
<td style="width:20%; text-align:right; border-top:none"><strong><%=sub_total%></strong></td>
|
||||
<td style="width:80%; text-align:left; border-top:none"><strong>Sub Total</strong></td>
|
||||
<td style="width:20%; text-align:right; border-top:none"><strong><span id="sub-total"></span></strong></td>
|
||||
</tr>
|
||||
<!--
|
||||
<tr>
|
||||
<td style="width:80%; text-align:left; border-top:none"><strong>Sub Total</strong></td>
|
||||
<td style="width:20%; text-align:right; border-top:none"><strong><%=sub_total%></strong></td>
|
||||
<td style="width:20%; text-align:right; border-top:none"><strong>0</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:80%; text-align:left">Discounts</td>
|
||||
@@ -268,17 +263,32 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function callOrderDetails(order_id){
|
||||
function callOrderDetails(order_id){
|
||||
$("#item-name-price").html("")
|
||||
$("#item-qty").html("")
|
||||
$("#item-total-price").html("")
|
||||
$("#sub-total").html("")
|
||||
url = "origami/"+order_id
|
||||
$.ajax({type: "GET",
|
||||
url: url,
|
||||
data: { order_id: order_id},
|
||||
success:function(result){
|
||||
alert('ok'+result);
|
||||
success:function(result){
|
||||
var sub_total = 0
|
||||
for (i = 0; i < result.length; i++) {
|
||||
var data = JSON.stringify(result[i]);
|
||||
// console.log(parse_data)
|
||||
var parse_data = JSON.parse(data)
|
||||
sub_total += (parse_data.qty*parse_data.price)
|
||||
$("#item-name-price").append(parse_data.item_name+"@"+parse_data.price+"<br/>")
|
||||
$("#item-qty").append(parse_data.qty+"<br/>")
|
||||
$("#item-total-price").append((parse_data.qty*parse_data.price)+"<br/>")
|
||||
|
||||
}
|
||||
$("#sub-total").append((sub_total)+"<br/>")
|
||||
},
|
||||
error:function(result){
|
||||
alert('error');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user