diff --git a/app/assets/stylesheets/CRM.scss b/app/assets/stylesheets/CRM.scss
index e2b88eaa..9ab3730c 100644
--- a/app/assets/stylesheets/CRM.scss
+++ b/app/assets/stylesheets/CRM.scss
@@ -23,6 +23,17 @@
.assign .text-muted{
color: #fff !important;
}
+.red{
+ color: #fff !important;
+ background-color: red;
+}
+.green{
+ color: #fff !important;
+ background-color: green;
+}
.required abbr{
color: red !important;
+}
+.jconfirm-box-container{
+ margin-left:-40px !important
}
\ No newline at end of file
diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb
index c1b67509..646f6475 100644
--- a/app/controllers/crm/customers_controller.rb
+++ b/app/controllers/crm/customers_controller.rb
@@ -47,14 +47,7 @@ class Crm::CustomersController < BaseCrmController
#get customer amount
@customer = Customer.find(params[:id])
- response = Customer.get_member_account(@customer)
-
- if(response["status"] == true)
- @membership = response["data"]
- else
- @membership = 0
- end
-
+ @response = Customer.get_membership_transactions(@customer)
#end customer amount
end
@@ -180,7 +173,7 @@ end
else
- flash[:errors] = @crm_customers.errors
+ flash[:errors] = @crm_customer.errors
format.html { redirect_to crm_customers_path}
format.json { render json: @crm_customer.errors, status: :unprocessable_entity }
end
diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb
index 251b0781..734793b3 100644
--- a/app/controllers/crm/dining_queues_controller.rb
+++ b/app/controllers/crm/dining_queues_controller.rb
@@ -84,12 +84,15 @@ class Crm::DiningQueuesController < BaseCrmController
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
+ status = queue.update_attributes(dining_facility_id: table_id,status:"Assign")
+ status = DiningFacility.find(table_id).update_attributes(status: "occupied")
+
+
+ if status == true
+ render json: JSON.generate({:status => true , notice: 'Dining queue was successfully assigned .'})
+ else
+ render json: JSON.generate({:status => false, :error_message => "Record not found"})
+ end
end
diff --git a/app/models/customer.rb b/app/models/customer.rb
index 0924d232..32422185 100644
--- a/app/models/customer.rb
+++ b/app/models/customer.rb
@@ -6,9 +6,10 @@ class Customer < ApplicationRecord
has_many :orders
has_many :sales
- validates_presence_of :name, :contact_no, :email
+ validates_presence_of :name, :contact_no, :email,:company,:card_no
validates :contact_no, uniqueness: true
validates :email, uniqueness: true
+ validates :card_no, uniqueness: true
paginates_per 50
@@ -36,6 +37,30 @@ class Customer < ApplicationRecord
end
+ def self.get_membership_transactions(customer)
+ membership = MembershipSetting.find_by_membership_type("paypar_url")
+ memberaction = MembershipAction.find_by_membership_type("get_member_transactions")
+ 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,
+ :headers => {
+ 'Content-Type' => 'application/json',
+ 'Accept' => 'application/json'
+ },
+ :timeout => 10
+ )
+ rescue Net::OpenTimeout
+ response = { status: false }
+ end
+
+ return response;
+
+ end
+
def self.search(search)
if search
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb
index 2ed4ebba..eacdadb6 100644
--- a/app/models/sale_payment.rb
+++ b/app/models/sale_payment.rb
@@ -202,9 +202,9 @@ class SalePayment < ApplicationRecord
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id)
- puts 'membership_data["status"]'
+ puts 'mmmmmmmmmmmmmmmmmmmmmmmmmmm'
puts membership_data.to_json
- puts "amountttttttttttt"
+ puts "amountttttttttttttttttttttt"
puts self.received_amount
if membership_data["status"]==true
self.payment_method = "paypar"
@@ -264,7 +264,7 @@ class SalePayment < ApplicationRecord
def rebat(sObj)
rebate_prices = SaleItem.calculate_food_beverage(sObj.sale_items)
- puts "rebate_prices"
+ puts "eeeeeeeeeeeeeeeeeeeeeeee"
puts rebate_prices
generic_customer_id = sObj.customer.membership_id
if generic_customer_id != nil || generic_customer_id != "" || generic_customer_id != 0
diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb
index 257692ec..2b1ae2ae 100644
--- a/app/pdf/receipt_bill_pdf.rb
+++ b/app/pdf/receipt_bill_pdf.rb
@@ -250,43 +250,30 @@ class ReceiptBillPdf < Prawn::Document
end
move_down 5
end
+ stroke_horizontal_rule
end
# show member information
def member_info(member_info,customer_name,rebate_amount,sale_data)
if rebate_amount != nil
- stroke_horizontal_rule
- if rebate_amount[1]["status"] == true
- total_redeem = 0.0
- amount = 0.0
- earm_amount = 0.0
- SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
- if payment.payment_method == "paypar"
- total_redeem = total_redeem + payment.payment_amount
- end
- end
- earm_amount = earm_amount + rebate_amount[1]["rebate_earned"].to_f
- amount = amount + total_redeem
- amount = amount + earm_amount
- old = rebate_amount[1]["total_rebate_amount"].to_f - amount
- move_down 5
- y_position = cursor
- bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
- text "Old Balance", :size => self.item_font_size,:align => :left
- end
- bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{old}" , :size => self.item_font_size,:align => :right
- end
- move_down 5
+ if rebate_amount["status"] == true
+ rebate_amount["data"].each do |res|
- y_position = cursor
- bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
- text "Earned Balance", :size => self.item_font_size,:align => :left
- end
- bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{ rebate_amount[1]["rebate_earned"] }" , :size => self.item_font_size,:align => :right
- end
+ if res["receipt_no"]== sale_data.receipt_no
+
+ move_down 5
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
+ text "Rebate Balance", :size => self.item_font_size,:align => :left
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
+ text "#{ res["rebate"] }" , :size => self.item_font_size,:align => :right
+ end
+
+ end
+
+ end
end
end
if member_info["status"] == true
@@ -297,7 +284,7 @@ class ReceiptBillPdf < Prawn::Document
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
- text "Rebate Balance", :size => self.item_font_size,:align => :left
+ text "Current Balance", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{ res["balance"] }" , :size => self.item_font_size,:align => :right
diff --git a/app/views/crm/customers/_card_read_form.html.erb b/app/views/crm/customers/_card_read_form.html.erb
new file mode 100644
index 00000000..4d6a9528
--- /dev/null
+++ b/app/views/crm/customers/_card_read_form.html.erb
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
Some text in the modal.
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/crm/customers/_error_messages.html.erb b/app/views/crm/customers/_error_messages.html.erb
deleted file mode 100644
index bbff284b..00000000
--- a/app/views/crm/customers/_error_messages.html.erb
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
- Select Member Group
- <% @member_group.each do |member| %>
- ">
- <%= member["name"] %>
- <%end %>
-
-
diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb
new file mode 100644
index 00000000..968d2ca9
--- /dev/null
+++ b/app/views/crm/customers/_new_form.html.erb
@@ -0,0 +1,122 @@
+
+
+ <%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
+
+
+ <%= f.hidden_field :id, :class => "form-control col-md-6 " %>
+
+
">
+ <%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
+ <% flash.each do |name, msg| %>
+ <% str="[\"#{msg['name']}\"]"
+ str.gsub!('["', '')
+ str.gsub!('"]', '') %>
+ <%= str %>
+ <% end -%>
+
+
+
+ Salutation :
+
+ Mr
+
+
+ Miss
+
+
+ Mrs
+
+
+ Mdm
+
+
+
+
">
+ <%= f.input :name, :class => "form-control col-md-6 name", :required => true %>
+ <% flash.each do |name, msg| %>
+ <% str="[\"#{msg['name']}\"]"
+ str.gsub!('["', '')
+ str.gsub!('"]', '') %>
+ <%= str %>
+ <% end -%>
+
+
+
+ Gender :
+
+ Male
+
+
+ Female
+
+
+
+
+ <%= f.input :nrc_no, :class => "form-control nrc_no" %>
+
+
+
+ <%= f.input :company, :class => "form-control col-md-6 company",:required => true%>
+
+ <% flash.each do |name, msg| %>
+ <% str="[\"#{msg['company']}\"]"
+ str.gsub!('["', '')
+ str.gsub!('"]', '') %>
+ <%= str %>
+ <% end -%>
+
+
">
+ <%= f.input :contact_no, :class => "form-control col-md-6 contact_no" ,:required => true%>
+
+ <% flash.each do |name, msg| %>
+ <% str="[\"#{msg['contact_no']}\"]"
+ str.gsub!('["', '')
+ str.gsub!('"]', '') %>
+ <%= str %>
+ <% end -%>
+
+
+
">
+ <%= f.input :email, :class => "form-control col-md-6 email" ,:required => true%>
+
+ <% flash.each do |name, msg| %>
+ <% str="[\"#{msg['contact_no']}\"]"
+ str.gsub!('["', '')
+ str.gsub!('"]', '') %>
+ <%= str %>
+ <% end -%>
+
+
+
+ <%= f.input :address, :class => "form-control col-md-6 address" %>
+
+
+
+ Sr.No
+
+
+
+
+ Date Of Birth
+ <%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%>
+
+
+
+ Select Member Group
+
+ <% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
+
+ <%= member.name %>
+ <%end %>
+
+
+
+
+
+
+ <%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %>
+ <%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %>
+ <%= f.button :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %>
+
+ <%end%>
+
\ No newline at end of file
diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb
index 532857f9..a8f02920 100644
--- a/app/views/crm/customers/index.html.erb
+++ b/app/views/crm/customers/index.html.erb
@@ -11,8 +11,6 @@
-
-
-
+ <%= render 'card_read_form' %>
-
- <%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
+ <%= render 'new_form', crm_customer: @crm_customer %>
-
- <%= f.hidden_field :id, :class => "form-control col-md-6 " %>
-
-
- Salutation :
-
- Mr
-
-
- Miss
-
-
- Mrs
-
-
- Mdm
-
-
-
-
">
- <%= f.input :name, :class => "form-control col-md-6 name", :required => true %>
-
- <% flash.each do |name, msg| %>
- <% str="[\"#{msg['name']}\"]"
- str.gsub!('["', '')
- str.gsub!('"]', '') %>
- <%= str %>
- <% end -%>
-
-
-
- Gender :
-
- Male
-
-
- Female
-
-
-
-
- <%= f.input :nrc_no, :class => "form-control nrc_no" %>
-
-
-
- <%= f.input :company, :class => "form-control col-md-6 company",:required => true%>
-
- <% flash.each do |name, msg| %>
- <% str="[\"#{msg['company']}\"]"
- str.gsub!('["', '')
- str.gsub!('"]', '') %>
- <%= str %>
- <% end -%>
-
-
">
- <%= f.input :contact_no, :class => "form-control col-md-6 contact_no" ,:required => true%>
-
- <% flash.each do |name, msg| %>
- <% str="[\"#{msg['contact_no']}\"]"
- str.gsub!('["', '')
- str.gsub!('"]', '') %>
- <%= str %>
- <% end -%>
-
-
-
">
- <%= f.input :email, :class => "form-control col-md-6 email" ,:required => true%>
-
- <% flash.each do |name, msg| %>
- <% str="[\"#{msg['contact_no']}\"]"
- str.gsub!('["', '')
- str.gsub!('"]', '') %>
- <%= str %>
- <% end -%>
-
-
-
- <%= f.input :address, :class => "form-control col-md-6 address" %>
-
-
-
- Sr.No
-
-
-
-
- Date Of Birth
- <%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%>
-
-
-
- Select Member Group
-
- <% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
-
- <%= member.name %>
- <%end %>
-
-
-
-
-
-
- <%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %>
- <%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %>
- <%= f.button :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %>
-
- <%end%>
-
-
@@ -203,9 +91,10 @@ $(function() {
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
+
});
- $(document).on('click',".customer_tr",function(){
+$(document).on('click',".customer_tr",function(){
// if(this.checked){
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
//$( "#checkbox_check" ).prop( "checked", true );
@@ -233,6 +122,7 @@ $(function() {
$('#customer_email').val(data.email);
$('#customer_salution').val(data.salution);
$('#customer_nrc_no').val(data.nrc_no);
+ $('#customer_card_no').val(data.card_no);
$('#customer_address').val(data.address);
$('#customer_date_of_birth').val(data.date_of_birth);
$('#customer_membership_type').val(data.membership_type);
diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb
index 04f3acf9..6f61e3cb 100644
--- a/app/views/crm/customers/show.html.erb
+++ b/app/views/crm/customers/show.html.erb
@@ -1,61 +1,74 @@
+
-
-
-
-
Customer Profile
-
-
-
-
- Name
- <%= @crm_customer.name %>
-
-
- Email
- <%= @crm_customer.email %>
-
-
- Contact no
- <%= @crm_customer.contact_no %>
-
-
- Company
- <%= @crm_customer.company %>
-
-
- Date Of Birth
- <%= @crm_customer.date_of_birth %>
-
-
-
-
-
-
-
-
Membership Detail
-
-
-
- <% if @membership == 0 %>
-
- "There is no membership data"
-
- <% else %>
- <% @membership.each do |member| %>
-
- <%= member["accountable_type"] %>
- <%= member["balance"] %>
-
- <% end %>
-
- <% end %>
-
-
-
-
+
+
+
+
+ Card No
+ Name
+ Company
+ Contact no
+ Email
+ NRC/Passport No
+ Address
+ DOB
+
+
+
+
+
+ <%= @customer.card_no rescue '-'%>
+ <%= @customer.name %>
+ <%= @customer.company rescue '-' %>
+ <%= @customer.contact_no %>
+ <%= @customer.email %>
+ <%= @customer.nrc_no %>
+ <%= @customer.address%>
+ <%= @customer.date_of_birth %>
+
+
+ Membership Transactions
+
+
+ Date
+ Redeem
+ Rebate
+ Balance
+ Account No
+ Status
+ Receipt No
+
+
+ <%
+ if @response["status"] == true %>
+ <% @response["data"].each do |transaction| %>
+
+ <%= transaction["date"]%>
+ <%= transaction["redeem"]%>
+ <%= transaction["rebate"] %>
+ <%= transaction["balance"] %>
+ <%= transaction["account_no"] %>
+ <%= transaction["status"] %>
+ <%= transaction["receipt_no"] %>
+
+
+ <% end %>
+ <% end %>
+
+
diff --git a/app/views/crm/dining_queues/assign.html.erb b/app/views/crm/dining_queues/assign.html.erb
index 5de532cc..94fdc339 100644
--- a/app/views/crm/dining_queues/assign.html.erb
+++ b/app/views/crm/dining_queues/assign.html.erb
@@ -1,44 +1,112 @@
-
-
-
-
-
- <%= form_tag crm_assign_table_path, :method => :post do %>
-
-
- Queue No
-
-
-
-
-
-
- Assign Table
-
- <% end %>
-
+
+
+
+
+
+
+
+
+
+
+
+ <% @i =0 %>
+ <% DiningFacility.all.each do |table| %>
+
" data-id="<%= table.id %>">
+
+
<%= @queue.id %>
+
<%= table.status %>
+
<%= table.name %>
+
+
+
+ <% end %>
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/views/crm/dining_queues/index.html.erb b/app/views/crm/dining_queues/index.html.erb
index 7050885d..502bcd3f 100644
--- a/app/views/crm/dining_queues/index.html.erb
+++ b/app/views/crm/dining_queues/index.html.erb
@@ -9,39 +9,38 @@
-
+
+
-
- <% @i = 0 %> .
- <% @dining_queues.each do |queue| %>
-
-
" style="border:1px solid #ccc;margin-bottom: 10px ">
-
-
<%= queue.id %>
-
<%= queue.status %>
-
<%= @i += 1 %> . Queue No
-
<%= queue.queue_no %>
-
- Name : <%= queue.name %>
- Contact : <%= queue.contact_no %>
-
- Status : <%= queue.status rescue '-' %>
-
-
-
+
-
- <% end %>
-
-
-
-
+
+
+
+
+ <% @i =0 %>
+ <% @dining_queues.each do |queue| %>
+
" data-id="<%= queue.id %>">
+
+
<%= queue.id %>
+
<%= queue.status %>
+
<%= @i += 1 %> . Queue No
+
<%= queue.queue_no %>
+
+
+
+
+ <% end %>
+
+
+
+
+
+
Assign
-
-
\ No newline at end of file
diff --git a/db/migrate/20170620091919_create_customers.rb b/db/migrate/20170621085729_create_customers.rb
similarity index 85%
rename from db/migrate/20170620091919_create_customers.rb
rename to db/migrate/20170621085729_create_customers.rb
index f3f73742..57553010 100644
--- a/db/migrate/20170620091919_create_customers.rb
+++ b/db/migrate/20170621085729_create_customers.rb
@@ -1,5 +1,4 @@
-
- class CreateCustomers < ActiveRecord::Migration[5.1]
+class CreateCustomers < ActiveRecord::Migration[5.1]
def change
create_table :customers, :id => false do |t|
t.string :customer_id, :limit => 16, :primary_key => true #custom foreign_key to prevent conflict during sync
@@ -15,7 +14,7 @@
t.string :gender
t.string :nrc_no
t.string :address
- t.string :card_no
+ t.string :card_no, :unique => true
t.timestamps
end
diff --git a/db/seeds.rb b/db/seeds.rb
index 56591e2c..a646bdad 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -161,7 +161,8 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance",
{membership_type:"update_membership_customer",gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"},
{membership_type:"get_all_member_group",gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"},
{membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"},
- {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}
+ {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"},
+ {membership_type:"get_member_transactions",gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}
])
payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://192.168.1.47:3006"})