assign queue and other bug
This commit is contained in:
@@ -17,4 +17,5 @@
|
||||
//= require turbolinks
|
||||
//= require cable
|
||||
//= require jquery-ui
|
||||
//= require bootstrap-datepicker
|
||||
//= require bootstrap-datepicker
|
||||
//= require bootstrap/modal
|
||||
@@ -3,6 +3,7 @@
|
||||
@import "theme";
|
||||
@import "jquery-ui";
|
||||
@import "bootstrap-datepicker3";
|
||||
@import "bootstrap/modal";
|
||||
|
||||
/* Show it is fixed to the top */
|
||||
// body {
|
||||
@@ -10,4 +11,15 @@
|
||||
// padding-top: 4.5rem;
|
||||
// }
|
||||
|
||||
.selected-item {
|
||||
color: #fff !important;
|
||||
background-color: #ccc !important;
|
||||
}
|
||||
|
||||
.assign {
|
||||
color: #fff !important;
|
||||
background-color: red;
|
||||
}
|
||||
.assign .text-muted{
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
# format.json { render :index, status: :created, location: @crm_customers }
|
||||
else
|
||||
|
||||
@crm_customers.destroy
|
||||
# @crm_customers.destroy
|
||||
if params[:sale_id]
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'}
|
||||
else
|
||||
|
||||
@@ -4,7 +4,8 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
# GET /crm/dining_queues
|
||||
# GET /crm/dining_queues.json
|
||||
def index
|
||||
@dining_queues = DiningQueue.all
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
@dining_queues = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? ", today).order("queue_no asc")
|
||||
end
|
||||
|
||||
# GET /crm/dining_queues/1
|
||||
@@ -38,7 +39,7 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_queue_no(print_settings,@dining_queue)
|
||||
|
||||
format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully created.' }
|
||||
format.html { redirect_to crm_dining_queues_path, notice: 'Queue was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @dining_queue }
|
||||
else
|
||||
format.html { render :new }
|
||||
@@ -52,7 +53,7 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @dining_queue.update(dining_queue_params)
|
||||
format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully updated.' }
|
||||
format.html { redirect_to crm_dining_queues_path, notice: 'Queue was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @dining_queue }
|
||||
else
|
||||
format.html { render :edit }
|
||||
@@ -71,6 +72,27 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
end
|
||||
end
|
||||
|
||||
def assign
|
||||
@queue = DiningQueue.find(params[:id])
|
||||
@tables = DiningFacility.where("status = 'available' ")
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
end
|
||||
end
|
||||
|
||||
def assign_table
|
||||
queue = DiningQueue.find(params[:id])
|
||||
table_id = params[:table_id]
|
||||
|
||||
queue.update_attributes(dining_facility_id: table_id,status:"Assign")
|
||||
DiningFacility.find(table_id).update_attributes(status: "occupied")
|
||||
respond_to do |format|
|
||||
format.html { redirect_to crm_dining_queues_path, notice: 'Table was successfully assigned.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_dining_queue
|
||||
@@ -79,6 +101,6 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def dining_queue_params
|
||||
params.require(:dining_queue).permit(:name, :contact_no, :queue_no)
|
||||
params.require(:dining_queue).permit(:name, :contact_no, :queue_no,:status)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,28 +9,8 @@ class Customer < ApplicationRecord
|
||||
validates_presence_of :name, :contact_no, :email
|
||||
validates :contact_no, uniqueness: true
|
||||
validates :email, uniqueness: true
|
||||
|
||||
paginates_per 50
|
||||
|
||||
# def self.get_member_group
|
||||
|
||||
# membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
# memberaction = MembershipAction.find_by_membership_type("get_all_member_group")
|
||||
# app_token = membership.auth_token.to_s
|
||||
|
||||
# url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
# response = HTTParty.get(url,
|
||||
# :body => { app_token: app_token}.to_json,
|
||||
# :headers => {
|
||||
# 'Content-Type' => 'application/json',
|
||||
# 'Accept' => 'application/json'
|
||||
# }
|
||||
# )
|
||||
# puts response.body, response.code, response.message, response.headers.inspect
|
||||
|
||||
# return response;
|
||||
|
||||
# end
|
||||
paginates_per 50
|
||||
|
||||
def self.get_member_account(customer)
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
@@ -38,6 +18,7 @@ class Customer < ApplicationRecord
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
# urltest =self.url_exist?(url)
|
||||
|
||||
response = HTTParty.get(url, :body => { membership_id: customer.membership_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
@@ -59,6 +40,35 @@ class Customer < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
# require "net/http"
|
||||
# def self.url_exist?(url_string)
|
||||
# url = URI.parse(url_string)
|
||||
|
||||
|
||||
# req = Net::HTTP.new(url.host, url.port)
|
||||
# puts "hhhhhhhhhhhh"
|
||||
# puts req.to_json
|
||||
# req.use_ssl = (url.scheme == 'https')
|
||||
# puts "aaaaaaaaaaaa"
|
||||
# puts req.use_ssl?
|
||||
# path = url.path if url.path.present?
|
||||
# puts "bbbbbbbbbbbbb"
|
||||
# puts path
|
||||
# res = req.request_head(path || '/')
|
||||
# puts "cccccccccccccc"
|
||||
# puts res.to_json
|
||||
# puts "ddddddddd"
|
||||
# puts res.kind_of?(Net::HTTPRedirection)
|
||||
# if res.kind_of?(Net::HTTPRedirection)
|
||||
# url_exist?(res['location']) # Go after any redirect and make sure you can access the redirected URL
|
||||
# else
|
||||
# ! %W(4 5).include?(res.code[0]) # Not from 4xx or 5xx families
|
||||
# end
|
||||
# rescue Errno::ENOENT
|
||||
# false #false if can't find the server
|
||||
# end
|
||||
|
||||
|
||||
# def self.search(search)
|
||||
# where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",)
|
||||
# end
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
class DiningQueue < ApplicationRecord
|
||||
|
||||
belongs_to :dining_facility, :optional => true
|
||||
def self.generate_queue_no
|
||||
queue_no = DiningQueue.all.count + 1
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
dining_queues = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? ", today).order("queue_no desc")
|
||||
queue_no = dining_queues.count + 1
|
||||
return queue_no
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -10,7 +10,7 @@
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-actions">
|
||||
<%= f.button :submit %>
|
||||
<%= f.button :submit,"Create Queue" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
44
app/views/crm/dining_queues/assign.html.erb
Normal file
44
app/views/crm/dining_queues/assign.html.erb
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li><a href="<%= crm_dining_queues_path %>">Queue</a></li>
|
||||
<li>New</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-4">
|
||||
<%= form_tag crm_assign_table_path, :method => :post do %>
|
||||
<input type="hidden" name="id" value="<%=@queue.id%>">
|
||||
<div class="form-group">
|
||||
<label>Queue No</label>
|
||||
<input type="text" name="queue" class="form-control" readonly="true" value="<%=@queue.queue_no%>">
|
||||
|
||||
</div>
|
||||
<div class="form-inputs">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Select Table</label>
|
||||
<select class="selectpicker form-control col-md-12" name="table_id" style="height: 40px" >
|
||||
<% @tables.each do |table| %>
|
||||
<option value="<%= table.id %>">
|
||||
<%= table.name %></option>
|
||||
<%end %>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-default">Assign Table</button>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,38 +1,69 @@
|
||||
|
||||
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= %>">Home</a></li>
|
||||
<li>Queue</li>
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")),new_crm_dining_queue_path,:class => 'btn btn-primary btn-sm' %>
|
||||
</span>
|
||||
</ul>
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= %>">Home</a></li>
|
||||
<li>Queue</li>
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")),new_crm_dining_queue_path,:class => 'btn btn-primary btn-sm' %>
|
||||
</span>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<div class="card">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:25%">Name</th>
|
||||
<th style="width:25%">Contact No</th>
|
||||
<th style="width:25%">Queue No</th>
|
||||
<th style="width:25%">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<div class="row">
|
||||
<div class="col-lg-11 col-md-11 col-sm-11" style="min-height:670px; max-height:670px; overflow-y:scroll">
|
||||
|
||||
<div class="row">
|
||||
<% @i = 0 %> .
|
||||
<% @dining_queues.each do |queue| %>
|
||||
<div class="col-md-3 ">
|
||||
<div class="card select-queue <%= !queue.status.nil? ? "assign" : ""%>" style="border:1px solid #ccc;margin-bottom: 10px ">
|
||||
<div class="card-block">
|
||||
<p class="hidden queue-id"><%= queue.id %></p>
|
||||
<p class="hidden queue-status"><%= queue.status %></p>
|
||||
<h4 class="card-title"><%= @i += 1 %> . Queue No </h4>
|
||||
<h1 style="text-align: center"><%= queue.queue_no %></h1>
|
||||
<p class="card-text">
|
||||
<small class="text-muted">Name : <%= queue.name %></small> <br>
|
||||
<small class="text-muted">Contact : <%= queue.contact_no %></small>
|
||||
<br>
|
||||
<small class="text-muted">Status : <%= queue.status rescue '-' %></small>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<button type="button" id="assign" class="btn btn-primary btn-lg btn-block" disabled>Assign</button>
|
||||
|
||||
</div>
|
||||
|
||||
<tbody>
|
||||
<% @dining_queues.each do |dining_queue| %>
|
||||
<tr>
|
||||
<td><%= dining_queue.name %></td>
|
||||
<td><%= dining_queue.contact_no %></td>
|
||||
<td><%= dining_queue.queue_no %></td>
|
||||
<td>
|
||||
<%= link_to 'Edit', edit_crm_dining_queue_path(dining_queue) %> | <%= link_to 'Destroy', crm_dining_queue_path(dining_queue), method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
|
||||
$(".select-queue").on("click", function(){
|
||||
$('.select-queue').removeClass('selected-item');
|
||||
$(this).addClass('selected-item');
|
||||
var status = $(this).find(".queue-status").text();
|
||||
if(status != "Assign"){
|
||||
$("#assign").removeAttr("disabled");
|
||||
}else{
|
||||
$("#assign").addAttr("disabled");
|
||||
}
|
||||
$("#assign").val($(this).find(".queue-id").text());
|
||||
}); //End Click
|
||||
|
||||
|
||||
});
|
||||
$('#assign').click(function() {
|
||||
var id = $(this).val();
|
||||
window.location.href = "dining_queues/"+id + "/assign"
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
@@ -235,7 +235,7 @@
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<!-- Waiter Buttons -->
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block"> Foc </button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block"> FOC </button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block"> Void </button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" onclick="localStorage.removeItem('cash');window.location.href = '/origami';"> Back </button>
|
||||
</div>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<tr>
|
||||
<td style='text-align:center;'><%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %></td>
|
||||
<td style='text-align:center;'><%=sale.receipt_no.to_s rescue ''%></td>
|
||||
<td style='text-align:center;'><%=sale.cashier_id rescue ''%></td>
|
||||
<td style='text-align:center;'><%=Employee.find(sale.cashier_id).name rescue ''%></td>
|
||||
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %></td>
|
||||
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %></td>
|
||||
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %></td>
|
||||
|
||||
@@ -124,6 +124,9 @@ Rails.application.routes.draw do
|
||||
post "update_booking" , to: "bookings#update_booking", as: "update_booking"#assign and cancel
|
||||
get '/print/:id', to: "home#print_order"#print order for crm
|
||||
|
||||
get "/dining_queues/:id/assign" =>"dining_queues#assign", :as => "assign"
|
||||
post "/dining_queues/assign_table" =>"dining_queues#assign_table", :as => "assign_table"
|
||||
|
||||
end
|
||||
|
||||
#--------- Order Queue Station ------------#
|
||||
|
||||
@@ -5,6 +5,7 @@ class CreateDiningQueues < ActiveRecord::Migration[5.1]
|
||||
t.string :contact_no
|
||||
t.string :queue_no
|
||||
t.string :status
|
||||
t.references :dining_facility, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
Reference in New Issue
Block a user