Files
sx-fc/app/views/transactions/order_reservations/show.html.erb
2018-08-30 17:45:51 +06:30

275 lines
13 KiB
Plaintext
Executable File

<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item"><a href="<%= transactions_order_reservations_path %>"><%= t :order_reservation %></a></li>
<li class="breadcrumb-item active"><%= t :details %></li>
<span class="float-right">
<%= link_to 'Back', transactions_order_reservations_path %>
</span>
</ol>
</div>
<div class="row">
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end %>
<div class="col-lg-12 col-md-12 col-sm-12">
<!-- Column One -->
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#order_reservation" role="tab"><%= t :order_reservation_details %> </a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#customer" role="tab"><%= t :customer_details %></a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#delivery" role="tab"><%= t :delivery_details %></a>
</li>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content" style="min-height:670px; max-height:670px;">
<div class="tab-pane active" id="order_reservation" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><%= t :reference_number %></th>
<th><%= t("views.right_panel.detail.type") %></th>
<th><%= t("views.right_panel.detail.requested_time") %></th>
<th><%= t("views.right_panel.detail.cooking_time") %></th>
<th><%= t("views.right_panel.detail.status") %></th>
<th><%= t :payment %> <%= t("views.right_panel.detail.type") %></th>
<th><%= t("views.right_panel.detail.remark") %></th>
</tr>
</thead>
<tbody>
<tr>
<td><%= @order_reservation.transaction_ref %></td>
<td><%= @order_reservation.order_reservation_type %></td>
<td><%= @order_reservation.requested_time.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %></td>
<td><%= @order_reservation.expected_waiting_time rescue '-' %></td>
<td><%= @order_reservation.status %></td>
<td><%= @order_reservation.payment_type %></td>
<td><%= @order_reservation.order_remark ? @order_reservation.order_remark : @order_reservation.reservation_remark %></td>
</tr>
<tr style="border-top:2px solid #000">
<th><%= t :sale %> <%= t("views.right_panel.detail.item_txt") %> <%= t("views.right_panel.detail.name_txt2") %></th>
<th><%= t("views.right_panel.detail.qty") %></th>
<th><%= t("views.right_panel.detail.unit_price") %></th>
<th><%= t("views.right_panel.detail.total_price") %></th>
<th><%= t("views.right_panel.detail.created_at") %></th>
<th></th>
<th></th>
</tr>
<% @order_reservation.order_reservation_items.each do |item| %>
<tr>
<td><%=item.item_name rescue ' '%></td>
<td><%=item.qty rescue ' '%></td>
<td><%= number_with_precision(item.price > 0 ? item.price : item.unit_price, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
<td><%= number_with_precision(item.price > 0 ? item.qty * item.price : item.qty * item.unit_price, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
<td><%=l item.created_at.utc.getlocal , :format => :short rescue ' ' %></td>
<td></td>
<td></td>
</tr>
<% end %>
<%
discount_amount = 0.0
delivery_fee = 0.0
convenience_charge = 0.0
delivery_tax = 0.0
convenience_tax = 0.0
commercial_tax = 0.0
total_discount_amount = 0
total_delivery_fee = 0
total_convenience_charge = 0
total_delivery_tax = 0
total_convenience_tax = 0
total_commercial_tax = 0
total_tax = 0.0
total_amount = 0.0
grand_total = 0.0
total_transaction_fee = 0.0
%>
<%
discount_amount = @order_reservation.discount_amount
delivery_fee = @order_reservation.delivery_fee ? @order_reservation.delivery_fee : 0.0
convenience_charge = @order_reservation.convenience_charge
if !JSON.parse(@order_reservation.taxes).nil? && !JSON.parse(@order_reservation.taxes).empty?
JSON.parse(@order_reservation.taxes).each do |tax_data|
if tax_data[0] == "delivery_tax"
delivery_tax = tax_data[1]
elsif tax_data[0] == "convenience_tax"
convenience_tax = tax_data[1]
elsif tax_data[0] == "commercial_tax"
commercial_tax = tax_data[1]
end
end
end
total_discount_amount += discount_amount.to_f
total_delivery_fee += delivery_fee.to_f
total_convenience_charge += convenience_charge.to_f
total_delivery_tax += delivery_tax.to_f
total_convenience_tax += convenience_tax.to_f
total_commercial_tax += commercial_tax.to_f
total_tax += @order_reservation.total_tax.to_f
total_amount += @order_reservation.total_amount.to_f
grand_total += @order_reservation.grand_total.to_f
total_transaction_fee += @order_reservation.transaction_fee.to_f
%>
<tr style="border-top:2px solid #000">
<td colspan=2 style="text-align:center"></td>
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td colspan="4"><%= number_with_precision(total_amount, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
</tr>
<% if total_discount_amount > 0 %>
<tr style="border-top:2px solid #000">
<td colspan=2 style="text-align:center"></td>
<td><%= t("views.right_panel.detail.discount_amount") %></td>
<td colspan="4"><%= number_with_precision(total_discount_amount, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
</tr>
<% end %>
<% if total_delivery_fee > 0 %>
<tr style="border-top:2px solid #000">
<td colspan=2 style="text-align:center"></td>
<td><%= t("views.right_panel.detail.delivery_fee") %></td>
<td colspan="4"><%= number_with_precision(total_delivery_fee, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
</tr>
<% end %>
<% if total_convenience_charge > 0 %>
<tr style="border-top:2px solid #000">
<td colspan=2 style="text-align:center"></td>
<td><%= t("views.right_panel.detail.convenience_charge") %></td>
<td colspan="4"><%= number_with_precision(total_convenience_charge, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
</tr>
<% end %>
<!-- <% if total_delivery_tax > 0 %>
<tr style="border-top:2px solid #000">
<td colspan=2 style="text-align:center"></td>
<td><%= t("views.right_panel.detail.delivery_tax") %></td>
<td colspan="3"><%= number_with_precision(total_delivery_tax, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
</tr>
<% end %>
<% if total_convenience_tax > 0 %>
<tr style="border-top:2px solid #000">
<td colspan=2 style="text-align:center"></td>
<td><%= t("views.right_panel.detail.convenience_tax") %></td>
<td colspan="3"><%= number_with_precision(total_convenience_tax, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
</tr>
<% end %>
<% if total_commercial_tax > 0 %>
<tr style="border-top:2px solid #000">
<td colspan=2 style="text-align:center"></td>
<td><%= t("views.right_panel.detail.commercial_tax") %></td>
<td colspan="3"><%= number_with_precision(total_commercial_tax, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
</tr>
<% end %> -->
<% if total_tax > 0 %>
<tr style="border-top:2px solid #000">
<td colspan=2 style="text-align:center"></td>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %></td>
<td colspan="4"><%= number_with_precision(total_tax, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
</tr>
<% end %>
<% if grand_total > 0 %>
<tr style="border-top:2px solid #000">
<td colspan="2" style="text-align:center"></td>
<td><%= t("views.right_panel.detail.grand_total") %> </td>
<td colspan="4"><%= number_with_precision(grand_total, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
</tr>
<% end %>
<% if total_transaction_fee > 0 %>
<tr style="border-top:2px solid #000">
<td colspan="2" style="text-align:center"></td>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.transaction_fee") %></td>
<td colspan="4"><%= number_with_precision(total_transaction_fee, precision:precision.to_i, delimiter:delimiter) rescue ' '%></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<!-- panel-2 -->
<div class="tab-pane" id="customer" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><%= t("views.right_panel.detail.name") %></th>
<th><%= t("views.right_panel.detail.company") %></th>
<th><%= t("views.right_panel.detail.contact_no") %></th>
<th><%= t("views.right_panel.detail.email") %></th>
<th><%= t("views.right_panel.detail.nrc_passport_no") %></th>
<th><%= t("views.right_panel.detail.address") %></th>
<th><%= t("views.right_panel.detail.dob") %></th>
</tr>
</thead>
<tbody>
<% if !@customer.nil? %>
<tr>
<td><%= @customer.name %></td>
<td><%= @customer.company rescue '-' %></td>
<td><%= @customer.contact_no %></td>
<td><%= @customer.email %></td>
<td><%= @customer.nrc_no %></td>
<td><%= @customer.address%></td>
<td><%= @customer.date_of_birth %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<!-- panel-3 -->
<div class="tab-pane" id="delivery" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><%= t("views.right_panel.detail.provider") %></th>
<th><%= t("views.right_panel.detail.delivery_type") %></th>
<th><%= t("views.right_panel.detail.address") %></th>
<th><%= t("views.right_panel.detail.township") %></th>
</tr>
</thead>
<tbody>
<% if !@delivery.nil? %>
<%
if @delivery.provider == 'pick_up'
provider = "Pick-Up"
elsif @delivery.provider == 'direct_delivery'
provider = "Direct Delivery"
elsif @delivery.provider == 'turbo'
provider = "TURBO"
else
provider = @delivery.provider
end
%>
<tr>
<td><%= provider%></td>
<td><%= @delivery.delivery_type%></td>
<td><%= @delivery.address%></td>
<td><%= @delivery.township%></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>