diff --git a/app/assets/javascripts/CRM.js b/app/assets/javascripts/CRM.js
index fc535ff7..c7457bed 100644
--- a/app/assets/javascripts/CRM.js
+++ b/app/assets/javascripts/CRM.js
@@ -17,4 +17,5 @@
//= require turbolinks
//= require cable
//= require jquery-ui
-//= require bootstrap-datepicker
\ No newline at end of file
+//= require bootstrap-datepicker
+//= require bootstrap/modal
\ No newline at end of file
diff --git a/app/assets/stylesheets/CRM.scss b/app/assets/stylesheets/CRM.scss
index a88efe96..8ddc1605 100644
--- a/app/assets/stylesheets/CRM.scss
+++ b/app/assets/stylesheets/CRM.scss
@@ -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;
+}
diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb
index 4cacae00..290f6ca1 100644
--- a/app/controllers/crm/customers_controller.rb
+++ b/app/controllers/crm/customers_controller.rb
@@ -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
diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb
index 41655d98..251b0781 100644
--- a/app/controllers/crm/dining_queues_controller.rb
+++ b/app/controllers/crm/dining_queues_controller.rb
@@ -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
diff --git a/app/models/customer.rb b/app/models/customer.rb
index 0fda2bb9..de9846f2 100644
--- a/app/models/customer.rb
+++ b/app/models/customer.rb
@@ -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)
begin
response = HTTParty.get(url, :body => { membership_id: customer.membership_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
@@ -64,6 +45,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
diff --git a/app/models/dining_queue.rb b/app/models/dining_queue.rb
index 09f8b6b5..d710d67f 100644
--- a/app/models/dining_queue.rb
+++ b/app/models/dining_queue.rb
@@ -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
\ No newline at end of file
diff --git a/app/views/crm/dining_queues/_form.html.erb b/app/views/crm/dining_queues/_form.html.erb
index 7f02ac15..320bac40 100644
--- a/app/views/crm/dining_queues/_form.html.erb
+++ b/app/views/crm/dining_queues/_form.html.erb
@@ -10,7 +10,7 @@
| Name | -Contact No | -Queue No | -Action | -
|---|---|---|---|
| <%= dining_queue.name %> | -<%= dining_queue.contact_no %> | -<%= dining_queue.queue_no %> | -- <%= 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?' } %> | -