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 @@
- <%= f.button :submit %> + <%= f.button :submit,"Create Queue" %>
<% end %> diff --git a/app/views/crm/dining_queues/assign.html.erb b/app/views/crm/dining_queues/assign.html.erb new file mode 100644 index 00000000..5de532cc --- /dev/null +++ b/app/views/crm/dining_queues/assign.html.erb @@ -0,0 +1,44 @@ + +
+
+ +
+
+
+ +
+ <%= form_tag crm_assign_table_path, :method => :post do %> + +
+ + + +
+
+ +
+ + + +
+ +
+
+
+ +
+ <% end %> +
+
+ diff --git a/app/views/crm/dining_queues/index.html.erb b/app/views/crm/dining_queues/index.html.erb index e7834b98..7050885d 100644 --- a/app/views/crm/dining_queues/index.html.erb +++ b/app/views/crm/dining_queues/index.html.erb @@ -1,38 +1,69 @@ - - -
-
- - - - - - - - - +
+
+ +
+ <% @i = 0 %> . + <% @dining_queues.each do |queue| %> +
+
" style="border:1px solid #ccc;margin-bottom: 10px "> +
+ + +

<%= @i += 1 %> . Queue No

+

<%= queue.queue_no %>

+

+ Name : <%= queue.name %>
+ Contact : <%= queue.contact_no %> +
+ Status : <%= queue.status rescue '-' %> +

+
+
+ +
+ <% end %> +
+ + +
+
+ + +
-
- <% @dining_queues.each do |dining_queue| %> - - - - - - - <% end %> - -
NameContact NoQueue NoAction
<%= 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?' } %>
+ + \ No newline at end of file diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 995e13e9..9ac19b1a 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -235,7 +235,7 @@
- +
diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb index 9d5c4f88..4dd239e7 100644 --- a/app/views/reports/receipt_no/index.html.erb +++ b/app/views/reports/receipt_no/index.html.erb @@ -44,7 +44,7 @@ <%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %> <%=sale.receipt_no.to_s rescue ''%> - <%=sale.cashier_id rescue ''%> + <%=Employee.find(sale.cashier_id).name rescue ''%> <%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %> diff --git a/config/routes.rb b/config/routes.rb index 3a1e5295..11494743 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 ------------# diff --git a/db/migrate/20170612031153_create_dining_queues.rb b/db/migrate/20170617163811_create_dining_queues.rb similarity index 81% rename from db/migrate/20170612031153_create_dining_queues.rb rename to db/migrate/20170617163811_create_dining_queues.rb index 3cf26418..d4b3eacd 100644 --- a/db/migrate/20170612031153_create_dining_queues.rb +++ b/db/migrate/20170617163811_create_dining_queues.rb @@ -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