update table box

This commit is contained in:
Aung Myo
2018-02-06 09:52:27 +06:30
parent 76a094972e
commit 85020d91bf
15 changed files with 173 additions and 79 deletions

View File

@@ -49,6 +49,8 @@ class Origami::CustomersController < BaseOrigamiController
def add_customer
@sale_id = params[:sale_id]
@cashier_type = params[:type]
if(@sale_id[0,3] == "SAL")
@booking = Booking.find_by_sale_id(@sale_id)
@dining_facility = DiningFacility.find(@booking.dining_facility_id)

View File

@@ -4,6 +4,7 @@ class Origami::DiscountsController < BaseOrigamiController
#discount page show from origami index with selected order
def index
sale_id = params[:id]
@cashier_type = params[:type]
if Sale.exists?(sale_id)
@sale_data = Sale.find(sale_id)
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)

View File

@@ -3,6 +3,7 @@ class Origami::OtherChargesController < BaseOrigamiController
def index
sale_id = params[:sale_id]
@cashier_type = params[:type]
if Sale.exists?(sale_id)
@sale_data = Sale.find(sale_id)
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)

View File

@@ -3,8 +3,10 @@ class Origami::QuickServiceController < ApplicationController
def index
@menu = MenuCategory.all.active
@dining = DiningFacility.all.active
@dining = DiningFacility.all.active
@customer = Customer.all
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
# @tables = Table.all.active.order('zone_id asc').group("zone_id")
# @rooms = Room.all.active.order('zone_id asc').group("zone_id")
# @all_table = Table.all.active.order('status desc')

View File

@@ -2,9 +2,10 @@ class Origami::SaleEditController < BaseOrigamiController
authorize_resource class: false
# Index for sale item void OR edit
def edit
sale_id = params[:sale_id]
@table_id = params[:table_id]
@saleobj = Sale.find(sale_id)
sale_id = params[:sale_id]
@table_id = params[:table_id]
@cashier_type = params[:type]
@saleobj = Sale.find(sale_id)
end
# create item void. make duplicate old record and update qty and price

View File

@@ -2,6 +2,7 @@ class Origami::SurveysController < BaseOrigamiController
def new
@survey = Survey.new
@id = params[:id]
@cashier_type = params[:type]
if(@id[0,3] == "SAL")
@sale = Sale.find(@id)
@@ -20,8 +21,14 @@ class Origami::SurveysController < BaseOrigamiController
def create
@dining_facility = DiningFacility.find(params[:table_id])
@url = "/origami/"+@dining_facility.type.downcase+"/"+params[:table_id]
@type = params[:cashier_type]
@sale_id = params[:sale_id]
if @type == "quick_service"
@url = "/origami/sale/"+@sale_id+"/"+@type+"/payment"
else
@url = "/origami/"+@dining_facility.type.downcase+"/"+params[:table_id]
end
@survey = Survey.new(survey_params)
@survey.foreigner = params["survey"]["foreigner"].to_json
# respond_to do |format|

View File

@@ -75,12 +75,7 @@
</div>
<!-- <div class="col-md-3">Table -</div> -->
<div class="col-md-6">
<select class="form-control m-t--5" id="table_id" name="table_id" >
<option value="">Select Table</option>
<% @dining.each do |table| %>
<option value="<%= table.id %>" data-type="<%=table.type%>"><%= table.name %></option>
<%end %>
</select>
<a class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#TableModal">Select Table</a>
</div>
</div>
<% else %>
@@ -120,7 +115,7 @@
</table>
<% if type %>
<div class="row clearfix">
<div class="row clearfix hidden">
<div class="col-md-4 ">
<strong id="order-title" class="font-14">Customer</strong>
</div>
@@ -232,7 +227,6 @@
<div class="col-md-7 item-detail">
<h5>Attributes</h5>
<div class="attributes-list">
</div>
<hr>
<h5>Options</h5>
@@ -246,11 +240,7 @@
<div class="mr-auto">
<h4 class=" pull-left">Total : <span id="total_price"></span></h4>
</div>
<div class="row">
<div class="col-md-4">
<button type="button" class="btn btn-default " data-dismiss="modal" id="close">Close</button>
</div>
@@ -333,4 +323,43 @@
</div>
</div>
<div class="modal fade" id="TableModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="TableModalLabel">Select Table</h4>
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#fff;">&times;</button>
</div>
<div class="modal-body">
<h5>Table</h5>
<div class="card-columns">
<% @tables.each do |table| %>
<div class="card tables text-white" data-id="<%= table.name %>">
<div class="card-block">
<%= table.name %>
<span class="float-right font-12"><%= table.name %></span>
</div>
</div>
<% end %>
</div>
<hr>
<h5>Room</h5>
<div class="card-columns">
<% @rooms.each do |room| %>
<div class="card tables text-white" data-id="<%= room.name %>">
<div class="card-block">
<%= room.name %>
<span class="float-right font-12"><%= room.name %></span>
</div>
</div>
<% end %>
</div>
</div>
<div class="modal-footer p-r-30">
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
&nbsp; &nbsp;
<button type="button" class="btn btn-link bg-blue waves-effect choose_payment">SAVE</button>
</div>
</div>
</div>
</div>

View File

@@ -258,6 +258,7 @@
</div>
</div>
<script type="text/javascript">
var cashier_type = "<%= @cashier_type %>";
$(function() {
/*$('.datepicker').datepicker({
setDate: '12-12-1999',
@@ -435,11 +436,16 @@
{
var id = $("#table_id").val();
var type = $("#type").val();
if (type=="Table") {
window.location.href = '/origami/table/'+id
if (cashier_type == "quick_service") {
window.location.href = '/origami/table/'+id
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
window.location.href = '/origami/room/'+id
}
if (type=="Table") {
window.location.href = '/origami/table/'+id
}else{
window.location.href = '/origami/room/'+id
}
}
}else{
swal("Alert!", "Record not found!", "error");
location.reload();

View File

@@ -225,18 +225,22 @@
</div>
<script type="text/javascript">
var cashier_type = "<%= @cashier_type %>";
$(document).ready(function(){
$('#back').on('click',function(){
var id = $("#table_id").text();
var type = $("#table_type").text();
console.log(id);
console.log(type);
if (type=="Table") {
window.location.href = '/origami/table/'+id
var sale_id = $('#sale-id').text();
if (cashier_type=="quick_service") {
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
window.location.href = '/origami/room/'+id
}
if (type=="Table") {
window.location.href = '/origami/table/'+id
}else{
window.location.href = '/origami/room/'+id
}
}
})
$(".cashier_number").on('click', function(event){
@@ -404,11 +408,15 @@
title: "Information!",
text: result.status,
}, function () {
if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id
}
else {
window.location.href = "/origami/room/" + result.table_id
if (cashier_type=="quick_service") {
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id
}
else {
window.location.href = "/origami/room/" + result.table_id
}
}
});
}
@@ -451,12 +459,16 @@
text: result.status,
type: "success",
}, function () {
if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id
}
else {
window.location.href = "/origami/room/" + result.table_id
}
if (cashier_type=="quick_service") {
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id
}
else {
window.location.href = "/origami/room/" + result.table_id
}
}
});
}
});
@@ -474,12 +486,16 @@
text: result.status,
type: "success",
}, function () {
if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id
}
else {
window.location.href = "/origami/room/" + result.table_id
}
if (cashier_type=="quick_service") {
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id
}
else {
window.location.href = "/origami/room/" + result.table_id
}
}
});
}
});
@@ -519,12 +535,16 @@
confirmButtonText: 'OK',
confirmButtonColor: btn_color,
}, function () {
if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id
}
else {
window.location.href = "/origami/room/" + result.table_id
}
if (cashier_type=="quick_service") {
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id
}
else {
window.location.href = "/origami/room/" + result.table_id
}
}
});
}
});

View File

@@ -467,6 +467,7 @@
</div>
</div>
<script>
cashier_type = "cashier"
$(document).ready(function () {
/* start check first bill or not*/
var receipt_no = "";
@@ -547,7 +548,7 @@
}
var table_id = $('.tables').attr("data-id");
window.location.href = '/origami/' + sale_id + "/customers"
window.location.href = '/origami/' + sale_id+"/"+cashier_type + "/customers"
});
@@ -568,7 +569,7 @@
}
if (sale_id != "") {
window.location.href = '/origami/' + sale_id + '/other_charges'
window.location.href = '/origami/' + sale_id + "/"+cashier_type+ '/other_charges'
}
else {
swal ( "Oops" , "Please select an table!" , "warning" );
@@ -589,7 +590,7 @@
}
if (sale_id != "") {
window.location.href = '/origami/' + sale_id + '/discount'
window.location.href = '/origami/' + sale_id+ "/"+cashier_type+'/discount'
}
else {
swal ( "Oops" , "Please select an table!" , "warning" );
@@ -758,7 +759,7 @@
var dining_id = "<%= @dining.id %>"
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
if ($(this).attr('active')=== "true") {
window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/edit";
window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/"+cashier_type +"/edit";
}else{
swal("Opps","You are not authorized for void","warning")
}

View File

@@ -204,6 +204,8 @@
</div>
</div>
<script type="text/javascript">
var cashier_type = "<%= @cashier_type %>";
$(document).ready(function(){
$(".cashier_number").on('click', function(event){
if(event.handled !== true) {
@@ -313,12 +315,16 @@
title: "Information!",
text: "Success",
}, function () {
if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id
}
else {
window.location.href = "/origami/room/" + result.table_id
}
if (cashier_type=="quick_service") {
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id
}
else {
window.location.href = "/origami/room/" + result.table_id
}
}s
});
}
});

View File

@@ -297,7 +297,7 @@
<button type="button" class="btn bg-red btn-block" id="void" active="<%= can? :overall_void, :void %>"> Void </button>
<% if @cashier_type=="quick_service" %>
<hr>
<button type="button" id="add_order" class="btn btn-block bg-blue waves-effect"><%= t("views.btn.add") %> <%= t("views.right_panel.detail.order") %></button>
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button>
<button type="button" id="customer" class="btn btn-block bg-blue waves-effect" >Customer</button>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
@@ -383,7 +383,7 @@ var cashier_type = "<%= @cashier_type %>";
var sale_id = $('#save_order_id').attr('data-order');
}
var table_id = $('.tables').attr("data-id");
window.location.href = '/origami/' + sale_id + "/customers"
window.location.href = '/origami/' + sale_id + "/"+cashier_type+"/customers"
});
// Add Other Charges
@@ -395,7 +395,7 @@ var cashier_type = "<%= @cashier_type %>";
var sale_id = $('#save_order_id').attr('data-order');
}
if (sale_id != "") {
window.location.href = '/origami/' + sale_id + '/other_charges'
window.location.href = '/origami/' + sale_id +"/"+cashier_type+ '/other_charges'
}
else {
swal ( "Oops" , "Please select an table!" , "warning" );
@@ -413,7 +413,7 @@ var cashier_type = "<%= @cashier_type %>";
}
if (sale_id != "") {
window.location.href = '/origami/' + sale_id + '/discount'
window.location.href = '/origami/' + sale_id + "/"+cashier_type+'/discount'
}
else {
swal ( "Oops" , "Please select an table!" , "warning" );
@@ -426,9 +426,9 @@ var cashier_type = "<%= @cashier_type %>";
$('#edit').on('click', function () {
var dining_id = "<%= @dining.id %>"
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
var sale_id = $('#sale_id').text();
if ($(this).attr('active')=== "true") {
window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/edit";
window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/"+cashier_type+"/edit";
}else{
swal("Opps","You are not authorized for void","warning")
}

View File

@@ -128,15 +128,16 @@
</div>
</div>
<script>
var cashier_type = "<%= @cashier_type %>";
// Bill Request
$(document).ready(function () {
$(".update").on('click', function () {
var sale_item_id = $(this).attr('data-id');
var qty = $('#' + sale_item_id + "_qty").val();
var price = $('#' + sale_item_id + "_price").val();
var qty = $('#' + sale_item_id + "_qty").val();
var price = $('#' + sale_item_id + "_price").val();
console.log(qty + "|" + price)
var ajax_url = "/origami/item_edit";
var ajax_url = "/origami/item_edit";
$.ajax({
type: "POST",
url: ajax_url,
@@ -196,7 +197,12 @@
$('#back').on('click', function () {
var table_id = '<%= @table_id %>'
window.location.href = '/origami/table/' + table_id;
var sale_id = "<%= @saleobj.sale_id %>"
if (cashier_type=="quick_service") {
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
window.location.href = '/origami/table/' + table_id;
}
})
$('#cancel_all_void').on('click', function () {
@@ -221,7 +227,12 @@
url: ajax_url,
data: 'sale_id=' + sale_id,
success: function (result) {
window.location.href = '/origami/table/' + table_id;
if (cashier_type=="quick_service") {
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
window.location.href = '/origami/table/' + table_id;
}
}
});
})

View File

@@ -42,6 +42,8 @@
</div>
<input type="hidden" name="table_id" value="<%=@dining_facility.id%>">
<input type="hidden" name="sale_id" value="<%=@id%>">
<input type="hidden" name="cashier_type" value="<%=@cashier_type%>">
<%= f.input :dining_name, :as => :hidden, :input_html => { :value => @dining_facility.name } %>
<%= f.input :created_by, :as => :hidden, :input_html => { :value => current_login_employee.name } %>
<%= f.input :receipt_no, :as => :hidden, :input_html => { :value => @receipt_no} %>
@@ -145,6 +147,7 @@
</div>
<script type="text/javascript">
var cashier_type = "<%= @cashier_type %>";
$(document).ready(function(){
//click add button for new row
$('#addForeigner').on('click',function(){
@@ -223,17 +226,21 @@
return false;
}
});
// click back button for redirect
$('#back').on('click',function(){
table_type = '<%=@table_type%>';
table_id = '<%=@dining_facility.id%>';
if (cashier_type == "quick_service") {
window.location.href = '/origami/sale/<%= @id %>/<%= @cashier_type %>/payment/';
}else{
if(table_type == "Table"){
window.location.href = "/origami/table/" + table_id
}
else {
window.location.href = "/origami/room/" + table_id
}
}
});
});

View File

@@ -98,7 +98,7 @@ scope "(:locale)", locale: /en|mm/ do
resources :customers #add customer type
end
post 'moving' => "movetable#moving"
get "/table/:table_id/sale/:sale_id/edit" => "sale_edit#edit"
get "/table/:table_id/sale/:sale_id/:type/edit" => "sale_edit#edit"
post 'item_void' => "sale_edit#item_void"
post 'item_foc' => "sale_edit#item_foc"
post 'item_edit' => "sale_edit#item_edit"
@@ -124,11 +124,11 @@ scope "(:locale)", locale: /en|mm/ do
# post '/:booking_id' => 'home#item_show'
# Other Charges
get "/:sale_id/other_charges" => "other_charges#index"
get "/:sale_id/:type/other_charges" => "other_charges#index"
post "/:sale_id/other_charges" => "other_charges#create"
# Discount
get "/:id/discount" => "discounts#index"
get "/:id/:type/discount" => "discounts#index"
post "/:id/discount" => "discounts#create"
get "/:id/remove_all_discount" => "discounts#remove_all_discount"
post "/:id/remove_discount_items" => "discounts#remove_discount_items"
@@ -191,9 +191,9 @@ scope "(:locale)", locale: /en|mm/ do
#---------Add Customer --------------#
#resources :customers
get '/:sale_id/customers', to: "customers#add_customer"
get '/:sale_id/:type/customers', to: "customers#add_customer"
get '/:customer_id/get_customer' => 'home#get_customer', :as => "show_customer_details"
post '/:sale_id/update_sale', to: "customers#update_sale_by_customer" # update customer id in sale table
post '/:sale_id/:type/update_sale', to: "customers#update_sale_by_customer" # update customer id in sale table
post '/:sale_id/get_customer' => "customers#get_customer"