update customre

This commit is contained in:
Aung Myo
2017-06-22 11:58:16 +06:30
parent 54526230aa
commit 187caa5253
7 changed files with 26 additions and 17 deletions

View File

@@ -179,3 +179,9 @@ select.form-control {
tr.discount-item-row:hover { tr.discount-item-row:hover {
background-color: #e3e3e3 !important; background-color: #e3e3e3 !important;
} }
/* Jquery Confirm */
.jconfirm-box-container{
margin-left:-40px !important
}

View File

@@ -44,17 +44,22 @@ class Origami::CustomersController < BaseOrigamiController
id = params[:sale_id][0,3] id = params[:sale_id][0,3]
if(id == "SAL") if(id == "SAL")
sale = Sale.find(params[:sale_id]) sale = Sale.find(params[:sale_id])
status = sale.update_attributes(customer_id: params[:customer_id])
else else
sale = Order.find(params[:sale_id]) @booking = BookingOrder.find_by_order_id(params[:sale_id])
@orders = BookingOrder.where("booking_id = ? ", @booking.booking_id)
@orders.each do |bo|
order = Order.find(bo.order_id)
status = order.update_attributes(customer_id: params[:customer_id])
end end
status = sale.update_attributes(customer_id: params[:customer_id]) end
if status == true if status == true
render json: JSON.generate({:status => true}) render json: JSON.generate({:status => true})
else else
render json: JSON.generate({:status => false, :error_message => "Record not found"}) render json: JSON.generate({:status => false, :error_message => "Record not found"})
end end
end end

View File

@@ -6,7 +6,7 @@ class Customer < ApplicationRecord
has_many :orders has_many :orders
has_many :sales 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 :contact_no, uniqueness: true
validates :email, uniqueness: true validates :email, uniqueness: true
validates :card_no, uniqueness: true validates :card_no, uniqueness: true

View File

@@ -246,7 +246,7 @@
$('#update_customer').removeAttr('disabled').val(''); $('#update_customer').removeAttr('disabled').val('');
$('#update_customer').attr('value', 'Update'); $('#update_customer').attr('value', 'Update');
$('#submit_customer').attr('disabled','disabled'); // $('#submit_customer').attr('disabled','disabled');
$("#new_customer").attr('class', 'simple_form edit_customer'); $("#new_customer").attr('class', 'simple_form edit_customer');
var id = "edit_customer_"+$('#customer_id').val(); var id = "edit_customer_"+$('#customer_id').val();

View File

@@ -298,7 +298,7 @@ $(document).ready(function(){
// bind customer to order or sale // bind customer to order or sale
$("#customer").on('click', function(){ $("#customer").on('click', function(){
var sale = $('#sale_id').val(); var sale = $('#sale_id').val();
if (sale!="") { if (sale) {
var sale_id = sale var sale_id = sale
}else{ }else{
var sale_id = $('#save_order_id').attr('data-order'); var sale_id = $('#save_order_id').attr('data-order');

View File

@@ -4,19 +4,17 @@ class CreateCustomers < ActiveRecord::Migration[5.1]
t.string :customer_id, :limit => 16, :primary_key => true #custom foreign_key to prevent conflict during sync t.string :customer_id, :limit => 16, :primary_key => true #custom foreign_key to prevent conflict during sync
t.string :name, :null => false t.string :name, :null => false
t.string :company t.string :company
t.string :contact_no, :unique => true
t.string :email t.string :email
t.string :contact_no, :unique => true
t.date :date_of_birth t.date :date_of_birth
t.string :membership_id t.string :salutation
t.string :membership_type
t.string :membership_authentication_code
t.string :salution
t.string :gender t.string :gender
t.string :nrc_no t.string :nrc_no
t.string :address t.string :address
t.string :card_no, :unique => true t.string :card_no, :unique => true
t.string :membership_id
t.timestamps t.string :membership_type
t.string :membership_authentication_code
end end
end end
end end

View File

@@ -84,7 +84,7 @@ void_reason = Lookup.create([{lookup_type:'void_reason', name: 'Approve By Manag
#WALK CUSTOMER - Default CUSTOMER (take key 1) #WALK CUSTOMER - Default CUSTOMER (take key 1)
customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000",card_no:"000"}) 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 #Default ZOne
# zone = Zone.create({id:1, name: "Normal Zone", is_active:true, created_by: "SYSTEM DEFAULT"}) # zone = Zone.create({id:1, name: "Normal Zone", is_active:true, created_by: "SYSTEM DEFAULT"})