From 187caa5253c63b5a2f02e6a422eee111d46a58df Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 22 Jun 2017 11:58:16 +0630 Subject: [PATCH] update customre --- app/assets/stylesheets/origami.scss | 6 ++++++ app/controllers/origami/customers_controller.rb | 13 +++++++++---- app/models/customer.rb | 2 +- app/views/origami/customers/index.html.erb | 2 +- app/views/origami/home/show.html.erb | 2 +- ...ers.rb => 20170622050926_create_customers.rb} | 16 +++++++--------- db/seeds.rb | 2 +- 7 files changed, 26 insertions(+), 17 deletions(-) rename db/migrate/{20170621085729_create_customers.rb => 20170622050926_create_customers.rb} (81%) diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 6b350bf1..30e3781d 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -179,3 +179,9 @@ select.form-control { tr.discount-item-row:hover { background-color: #e3e3e3 !important; } + +/* Jquery Confirm */ + +.jconfirm-box-container{ + margin-left:-40px !important +} \ No newline at end of file diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 878571f1..373dc2f5 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -44,17 +44,22 @@ class Origami::CustomersController < BaseOrigamiController id = params[:sale_id][0,3] if(id == "SAL") sale = Sale.find(params[:sale_id]) + status = sale.update_attributes(customer_id: params[:customer_id]) else - sale = Order.find(params[:sale_id]) - end + @booking = BookingOrder.find_by_order_id(params[:sale_id]) + @orders = BookingOrder.where("booking_id = ? ", @booking.booking_id) - status = sale.update_attributes(customer_id: params[:customer_id]) + @orders.each do |bo| + order = Order.find(bo.order_id) + status = order.update_attributes(customer_id: params[:customer_id]) + end + + end if status == true render json: JSON.generate({:status => true}) 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 4e25c9bc..5debec38 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -6,7 +6,7 @@ class Customer < ApplicationRecord has_many :orders has_many :sales - validates_presence_of :name, :contact_no, :email,:company,:card_no + validates_presence_of :name, :contact_no, :email,:card_no validates :contact_no, uniqueness: true validates :email, uniqueness: true validates :card_no, uniqueness: true diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index 3b192319..5539b42b 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -246,7 +246,7 @@ $('#update_customer').removeAttr('disabled').val(''); $('#update_customer').attr('value', 'Update'); - $('#submit_customer').attr('disabled','disabled'); + // $('#submit_customer').attr('disabled','disabled'); $("#new_customer").attr('class', 'simple_form edit_customer'); var id = "edit_customer_"+$('#customer_id').val(); diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 22e35765..2719a758 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -298,7 +298,7 @@ $(document).ready(function(){ // bind customer to order or sale $("#customer").on('click', function(){ var sale = $('#sale_id').val(); - if (sale!="") { + if (sale) { var sale_id = sale }else{ var sale_id = $('#save_order_id').attr('data-order'); diff --git a/db/migrate/20170621085729_create_customers.rb b/db/migrate/20170622050926_create_customers.rb similarity index 81% rename from db/migrate/20170621085729_create_customers.rb rename to db/migrate/20170622050926_create_customers.rb index 57553010..07ec136f 100644 --- a/db/migrate/20170621085729_create_customers.rb +++ b/db/migrate/20170622050926_create_customers.rb @@ -1,22 +1,20 @@ class CreateCustomers < ActiveRecord::Migration[5.1] def change - create_table :customers, :id => false do |t| + create_table :customers, :id => false do |t| t.string :customer_id, :limit => 16, :primary_key => true #custom foreign_key to prevent conflict during sync t.string :name, :null => false t.string :company - t.string :contact_no, :unique => true t.string :email - t.date :date_of_birth - t.string :membership_id - t.string :membership_type - t.string :membership_authentication_code - t.string :salution + t.string :contact_no, :unique => true + t.date :date_of_birth + t.string :salutation t.string :gender t.string :nrc_no t.string :address t.string :card_no, :unique => true - - t.timestamps + t.string :membership_id + t.string :membership_type + t.string :membership_authentication_code end end end diff --git a/db/seeds.rb b/db/seeds.rb index 0e88e336..21268860 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -84,7 +84,7 @@ void_reason = Lookup.create([{lookup_type:'void_reason', name: 'Approve By Manag #WALK CUSTOMER - Default CUSTOMER (take key 1) customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000",card_no:"000"}) -customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111",card_no:"000"}) +customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111",card_no:"111"}) #Default ZOne # zone = Zone.create({id:1, name: "Normal Zone", is_active:true, created_by: "SYSTEM DEFAULT"})