add booking list in transaction

This commit is contained in:
Aung Myo
2017-11-14 13:42:00 +06:30
parent f1a28d64e1
commit 6f06e7a9d7
17 changed files with 351 additions and 42 deletions

View File

@@ -16,7 +16,6 @@
//= require bootstrap/js/popper.min
//= require bootstrap/js/bootstrap-material-design.min
//= require jquery_nested_form
//= require cable
//= require momentjs/moment
//= require bootstrap-material-datetimepicker/js/bootstrap-material-datetimepicker
//= require multi-select/js/jquery.multi-select.js
@@ -24,6 +23,15 @@
//= require bootstrap-notify/bootstrap-notify.js
//= require node-waves/waves.js
//= require sweetalert/sweetalert.min.js
//=require jquery-datatable/jquery.dataTables.js
//=require jquery-datatable/skin/bootstrap/js/dataTables.bootstrap.js
//=require jquery-datatable/extensions/export/dataTables.buttons.min.js
//=require jquery-datatable/extensions/export/buttons.flash.min.js
//=require jquery-datatable/extensions/export/jszip.min.js
//=require jquery-datatable/extensions/export/pdfmake.min.js
//=require jquery-datatable/extensions/export/vfs_fonts.js
//=require jquery-datatable/extensions/export/buttons.html5.min.js
//=require jquery-datatable/extensions/export/buttons.print.min.js
//= require autosize/autosize.js
//= require jquery-countto/jquery.countTo.js
//= require raphael/raphael.min
@@ -343,6 +351,21 @@ $(document).ready(function(){
}
});
});
$(function () {
$('.js-basic-example').DataTable({
responsive: true,
bLengthChange: false
});
//Exportable table
$('.js-exportable').DataTable({
dom: 'Bfrtip',
responsive: true,
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
});
});

View File

@@ -5,6 +5,7 @@
@import "animate-css/animate";
@import "sweetalert/sweetalert.css";
@import "multi-select/css/multi-select.css";
@import "jquery-datatable/skin/bootstrap/css/dataTables.bootstrap.css";
@import "bootstrap-material-datetimepicker/css/bootstrap-material-datetimepicker";
@import "morrisjs/morris";
@import "fileinput.min";

View File

@@ -0,0 +1,44 @@
class Transactions::BookingsController < ApplicationController
load_and_authorize_resource except: [:create]
before_action :set_transactions_booking, only: [:show, :edit, :update, :destroy]
def index
@bookings = Booking.all.order("booking_id desc")
respond_to do |format|
format.html # index.html.erb
format.json { render json: @bookings }
end
end
# GET /transactions/bookings/1
# GET /transactions/bookings/1.json
def show
@booking = Booking.find(params[:id])
@order_items = []
@booking.booking_orders.each do |booking_order|
@order = Order.find(booking_order.order_id)
#if (order.status == "new")
@order_items = @order_items + @order.order_items
#end
end
if @booking.sale_id.present?
@sale = Sale.find(@booking.sale_id)
end
respond_to do |format|
format.html # show.html.erb
format.json { render json: @booking }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_transactions_booking
@transactions_booking = Booking.find(params[:id])
end
end

View File

@@ -41,6 +41,22 @@ class Booking < ApplicationRecord
return new_dining.type
end
def self.search(filter,from,to)
if filter.blank?
keyword = ''
else
keyword = "booking_id LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%"
end
if from.present? && to.present?
sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and NOT sale_status = 'void' ", from,to)
query = sale.where(keyword)
else
where("receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%",)
end
end
private
def generate_custom_id
self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI")

View File

@@ -0,0 +1,61 @@
<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 active"><%= t :booking %></li>
<span class="float-right">
<%= link_to 'Back', dashboard_path %>
</span>
</ol>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="main-box-body clearfix p-l-5 p-r-5">
<div class="card">
<div class="table-responsive">
<table class="table table-bordered table-striped table-hover js-basic-example dataTable">
<thead>
<tr>
<th><%= t("views.right_panel.detail.booking_id") %></th>
<th><%= t("views.right_panel.detail.sale_id") %></th>
<th><%= t("views.right_panel.detail.table") %></th>
<th><%= t("views.right_panel.detail.checkin_time") %></th>
<th><%= t("views.right_panel.detail.checkout_time") %></th>
<th><%= t("views.right_panel.detail.checkin_by") %></th>
<th> <%= t("views.right_panel.detail.checkout_by") %></th>
<th><%= t("views.right_panel.detail.booking_status") %></th>
<th><%= t("views.right_panel.detail.booking_date") %></th>
</tr>
</thead>
<tbody>
<% if @bookings != 0 %>
<% @bookings.each do |booking| %>
<tr>
<td><%= link_to booking.booking_id, transactions_booking_path(booking) %></td>
<td><%= link_to booking.sale_id, transactions_sale_path(booking.sale_id) rescue '-' %></td>
<td><%= booking.dining_facility.name %></td>
<td><%= booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %></td>
<td><%= booking.checkout_at.utc.getlocal.strftime("%I:%M %p") rescue '-' %></td>
<td><%= booking.checkin_by rescue '-' %></td>
<td><%= booking.checkout_by rescue '-' %></td>
<td> <%= booking.booking_status %> </td>
<td> <%= booking.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> </td>
</tr>
<% end %>
<% else %>
<tr><td colspan="8"><strong><p style="text-align: center">There is no data for search....</p></strong></td></tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1 @@
json.array! @transactions_sales, partial: 'transactions_sales/transactions_sale', as: :transactions_sale

View File

@@ -0,0 +1,59 @@
<p id="notice"><%= notice %></p>
<h1><%= t("views.right_panel.header.transactions_sales") %></h1>
<table>
<thead>
<tr>
<th><%= t :cashier %></th>
<th><%= t :cashier %> <%= t("views.right_panel.detail.name_txt2") %></th>
<th><%= t("views.right_panel.detail.requested_by") %></th>
<th><%= t("views.right_panel.detail.requested_at") %></th>
<th><%= t("views.right_panel.detail.receipt_no") %></th>
<th><%= t("views.right_panel.detail.receipt_date") %></th>
<th><%= t :customer %></th>
<th><%= t("views.right_panel.detail.payment_status") %></th>
<th><%= t("views.right_panel.detail.sale_status") %></th>
<th><%= t("views.right_panel.detail.total_amount") %></th>
<th><%= t("views.right_panel.detail.total_discount") %></th>
<th><%= t("views.right_panel.detail.total_tax") %></th>
<th><%= t("views.right_panel.detail.tax_type") %></th>
<th><%= t("views.right_panel.detail.grand_total") %></th>
<th><%= t("views.right_panel.detail.rnd_adj") %></th>
<th><%= t("views.right_panel.detail.amt_received") %></th>
<th><%= t("views.right_panel.detail.amt_changed") %></th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @transactions_sales.each do |transactions_sale| %>
<tr>
<td><%= transactions_sale.cashier %></td>
<td><%= transactions_sale.cashier_name %></td>
<td><%= transactions_sale.requested_by %></td>
<td><%= transactions_sale.requested_at %></td>
<td><%= transactions_sale.receipt_no %></td>
<td><%= transactions_sale.receipt_date %></td>
<td><%= transactions_sale.customer %></td>
<td><%= transactions_sale.payment_status %></td>
<td><%= transactions_sale.sale_status %></td>
<td><%= transactions_sale.total_amount %></td>
<td><%= transactions_sale.total_discount %></td>
<td><%= transactions_sale.total_tax %></td>
<td><%= transactions_sale.tax_type %></td>
<td><%= transactions_sale.grand_total %></td>
<td><%= transactions_sale.rounding_adjustment %></td>
<td><%= transactions_sale.amount_received %></td>
<td><%= transactions_sale.amount_changed %></td>
<td><%= link_to t("views.btn.show"), transactions_sale %></td>
<td><%= link_to t("views.btn.edit"), edit_transactions_sale_path(transactions_sale) %></td>
<td><%= link_to t("views.btn.delete"), transactions_sale, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New Transactions Sale', new_transactions_sale_path %>

View File

@@ -0,0 +1,140 @@
<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_bookings_path %>"><%= t :booking %></a></li>
<li class="breadcrumb-item active"><%= t :details %></li>
<span class="float-right">
<%= link_to 'Back', transactions_bookings_path %>
</span>
</ol>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#booking" role="tab"><%= t :booking_details %></a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#order" role="tab"><%= t :order_details %></a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#sale" role="tab"><%= t :sale_details %></a>
</li>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content" style="min-height:670px; max-height:670px;">
<div class="tab-pane active" id="booking" role="tabpanel">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><%= t("views.right_panel.detail.booking_id") %></th>
<th><%= t("views.right_panel.detail.sale_id") %></th>
<th><%= t("views.right_panel.detail.table") %></th>
<th><%= t("views.right_panel.detail.checkin_time") %></th>
<th><%= t("views.right_panel.detail.checkout_time") %></th>
<th><%= t("views.right_panel.detail.checkin_by") %></th>
<th> <%= t("views.right_panel.detail.checkout_by") %></th>
<th><%= t("views.right_panel.detail.booking_status") %></th>
<th><%= t("views.right_panel.detail.booking_date") %></th>
</tr>
</thead>
<tbody>
<tr>
<td><%= @booking.booking_id%></td>
<td><%= link_to @booking.sale_id, transactions_sale_path(booking.sale_id) rescue '-' %></td>
<td><%= @booking.dining_facility.name %></td>
<td><%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %></td>
<td><%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") rescue '-' %></td>
<td><%= @booking.checkin_by rescue '-' %></td>
<td><%= @booking.checkout_by rescue '-' %></td>
<td><%= @booking.booking_status %> </td>
<td><%= @booking.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> </td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="tab-pane" id="order" role="tabpanel">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><%= t("views.right_panel.detail.order_id") %></th>
<th><%= t("views.right_panel.header.menu_item") %></th>
<th><%= t("views.right_panel.detail.qty") %></th>
<th><%= t("views.right_panel.detail.unit_price") %></th>
<th><%= t("views.right_panel.detail.option") %></th>
<th><%= t("views.right_panel.detail.status") %></th>
<th><%= t("views.right_panel.detail.waiter") %></th>
<th><%= t("views.right_panel.detail.created_at") %></th>
</tr>
</thead>
<tbody>
<% @order_items.each do |order_item| %>
<tr>
<td><%= link_to order_item.order_id, transactions_order_path(order_item.order_id) %><%= %></td>
<td><%= order_item.item_name %></td>
<td><%= order_item.qty %></td>
<td><%= order_item.price %></td>
<td><%= order_item.options %></td>
<td><%= order_item.order_item_status %></td>
<td><%= order_item.item_order_by %> </td>
<td><%= order_item.created_at.strftime("%d-%m-%y %I:%M %p") %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<div class="tab-pane" id="sale" role="tabpanel">
<div class="table-responsive">
<table class="table table- table-striped table-hover js-basic- ">
<thead>
<tr>
<th><%= t("views.right_panel.detail.sale_id") %></th>
<th><%= t("views.right_panel.detail.receipt_no") %></th>
<th><%= t("views.right_panel.detail.total_discount") %></th>
<th><%= t("views.right_panel.detail.tax_amount") %></th>
<th><%= t("views.right_panel.detail.sub_total") %></th>
<th><%= t("views.right_panel.detail.grand_total") %></th>
<th><%= t :cashier %></th>
<th><%= t("views.right_panel.detail.sales_status") %></th>
<th><%= t("views.right_panel.detail.receipt_date") %></th>
</tr>
</thead>
<tbody>
<% if @sale %>
<tr>
<td><%= link_to @sale.sale_id, transactions_sale_path(@sale) %></td>
<td><%= @sale.receipt_no %></td>
<td><%= @sale.total_discount %></td>
<td><%= @sale.total_tax %></td>
<td><%= @sale.total_amount %></td>
<td><%= @sale.grand_total rescue '-' %></td>
<td><%= @sale.cashier_name rescue '-' %></td>
<td> <%= @sale.sale_status %> </td>
<td> <%= @sale.receipt_date.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> </td>
</tr>
<% else %>
<tr><td colspan="9"><strong><p style="text-align: center">There is no data ....</p></strong></td></tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1 @@
json.partial! "transactions_sales/transactions_sale", transactions_sale: @transactions_sale

View File

@@ -1,27 +0,0 @@
<%= simple_form_for(@transactions_sale) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.association :cashier %>
<%= f.input :cashier_name %>
<%= f.input :requested_by %>
<%= f.input :requested_at %>
<%= f.input :receipt_no %>
<%= f.input :receipt_date %>
<%= f.association :customer %>
<%= f.input :payment_status %>
<%= f.input :sale_status %>
<%= f.input :total_amount %>
<%= f.input :total_discount %>
<%= f.input :total_tax %>
<%= f.input :tax_type %>
<%= f.input :grand_total %>
<%= f.input :rounding_adjustment %>
<%= f.input :amount_received %>
<%= f.input :amount_changed %>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>

View File

@@ -1,2 +0,0 @@
json.extract! transactions_sale, :id, :cashier_id, :cashier_name, :requested_by, :requested_at, :receipt_no, :receipt_date, :customer_id, :payment_status, :sale_status, :total_amount, :total_discount, :total_tax, :tax_type, :grand_total, :rounding_adjustment, :amount_received, :amount_changed, :created_at, :updated_at
json.url transactions_sale_url(transactions_sale, format: :json)

View File

@@ -1,6 +0,0 @@
<h1>Editing Transactions Sale</h1>
<%= render 'form', transactions_sale: @transactions_sale %>
<%= link_to t("views.btn.show"), @transactions_sale %> |
<%= link_to 'Back', transactions_sales_path %>

View File

@@ -1,5 +0,0 @@
<h1>New Transactions Sale</h1>
<%= render 'form', transactions_sale: @transactions_sale %>
<%= link_to 'Back', transactions_sales_path %>

View File

@@ -142,7 +142,7 @@
<tbody>
<% @order_items.each do |order_item| %>
<tr>
<td><%= order_item.order_id %></td>
<td><%= link_to order_item.order_id, transactions_order_path(order_item.order_id) %><%= %></td>
<td><%= order_item.item_name %></td>
<td><%= order_item.qty %></td>
<td><%= order_item.price %></td>

View File

@@ -63,6 +63,7 @@ en:
customer_details: "Customer Details"
order_details: "Order Details"
sale_details: "Sale Details"
booking_details: "Booking Details"
inventory_definitions: "Inventory Definitions"
sale_audits: "Sale Audits"

View File

@@ -63,6 +63,7 @@ mm:
customer_details: "စားသုံးသူကိုယ်ရေးအသေးစိတ်"
order_details: "မှာကြားမှုအသေးစိတ်"
sale_details: "ရောင်းရငွေအသေးစိတ်"
booking_details: "ရောင်းရငွေအသေးစိတ်"
inventory_definitions: "ကုန်လှောင်ရုံပစ္စည်းဖွင့်ဆိုချက်များ"
sale_audits: "အရောင်းပြင်ဆင်ခြင်းများ"

View File

@@ -335,6 +335,7 @@ scope "(:locale)", locale: /en|mm/ do
resources :sales
resources :orders
resources :credit_notes
resources :bookings
get "/sales/:sale_id/manual_complete_sale" => "manual_sales#manual_complete_sale", :as => "manual_complete_sale"
get "/sales/:sale_id/void" => "manual_sales#void", :as => "void"