update jade integration
This commit is contained in:
@@ -6,12 +6,34 @@ class Crm::CustomersController < BaseCrmController
|
||||
# GET /crm/customers.json
|
||||
def index
|
||||
filter = params[:filter]
|
||||
type = params[:type]
|
||||
if filter.nil?
|
||||
@crm_customers = Customer.all
|
||||
else
|
||||
@crm_customers = Customer.search(filter)
|
||||
|
||||
# search account no from paypar
|
||||
if !@crm_customers.present? && type == "card"
|
||||
response = Customer.search_paypar_account_no(filter)
|
||||
if response["status"] == true
|
||||
@crm_customers = Customer.new
|
||||
@crm_customers.name = response["customer_data"]["name"]
|
||||
@crm_customers.contact_no = response["customer_data"]["phone"]
|
||||
@crm_customers.email = response["customer_data"]["email"]
|
||||
@crm_customers.date_of_birth = response["customer_data"]["DOB"]
|
||||
@crm_customers.nrc_no = response["customer_data"]["NRC"]
|
||||
@crm_customers.address = response["customer_data"]["address"]
|
||||
@crm_customers.card_no = response["customer_data"]["customer_card_no"]
|
||||
@crm_customers.paypar_account_no = filter
|
||||
@crm_customers.membership_id = response["customer_data"]["id"]
|
||||
@crm_customers.membership_type = response["customer_data"]["member_group_id"]
|
||||
@crm_customers.customer_type = "Dinein"
|
||||
@crm_customers.tax_profiles = ["1", "2"]
|
||||
@crm_customers.save
|
||||
@crm_customers = Customer.search(filter)
|
||||
end
|
||||
end
|
||||
end
|
||||
puts @crm_customers
|
||||
#@crm_customers = Customer.all
|
||||
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
|
||||
@crm_customer = Customer.new
|
||||
|
||||
@@ -9,13 +9,39 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def get_customer
|
||||
|
||||
filter = params[:filter]
|
||||
type = params[:type]
|
||||
|
||||
if filter.nil?
|
||||
@crm_customers = Customer.order("customer_id").page(params[:page])
|
||||
#@products = Product.order("name").page(params[:page]).per(5)
|
||||
else
|
||||
@crm_customers = Customer.search(filter)
|
||||
@crm_customers = Customer.search(filter)
|
||||
# search account no from paypar
|
||||
if !@crm_customers.present? && type == "card"
|
||||
response = Customer.search_paypar_account_no(filter)
|
||||
if response["status"] == true
|
||||
@crm_customers = Customer.new
|
||||
@crm_customers.name = response["customer_data"]["name"]
|
||||
@crm_customers.contact_no = response["customer_data"]["phone"]
|
||||
@crm_customers.email = response["customer_data"]["email"]
|
||||
@crm_customers.date_of_birth = response["customer_data"]["DOB"]
|
||||
@crm_customers.nrc_no = response["customer_data"]["NRC"]
|
||||
@crm_customers.address = response["customer_data"]["address"]
|
||||
@crm_customers.card_no = 121212
|
||||
@crm_customers.paypar_account_no = filter
|
||||
@crm_customers.membership_id = response["customer_data"]["id"]
|
||||
@crm_customers.membership_type = response["customer_data"]["member_group_id"]
|
||||
@crm_customers.customer_type = "Dinein"
|
||||
@crm_customers.tax_profiles = ["1", "2"]
|
||||
@crm_customers.save
|
||||
else
|
||||
@crm_customers = {:status=> response["status"],:message=>response["message"] }
|
||||
end
|
||||
end
|
||||
end
|
||||
puts @crm_customers
|
||||
render :json => @crm_customers.to_json
|
||||
end
|
||||
|
||||
|
||||
@@ -194,6 +194,41 @@ class Customer < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def self.search_paypar_account_no(account_no)
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("search_paypar_account_no")
|
||||
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
|
||||
begin
|
||||
response = HTTParty.get(url,
|
||||
:body => { paypar_account_no:account_no,
|
||||
merchant_uid:merchant_uid,
|
||||
auth_token:auth_token
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
rescue HTTParty::Error
|
||||
response = {status: false, message: "Server Error"}
|
||||
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false , message: "Server Time out"}
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false, message: "Can't connect server"}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false, message: "Can't connect server"}
|
||||
end
|
||||
puts "sssssssssssss"
|
||||
puts response.to_json
|
||||
return response
|
||||
end
|
||||
|
||||
def self.search(search)
|
||||
if search
|
||||
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
|
||||
|
||||
@@ -169,6 +169,7 @@
|
||||
if(cardNo.length == 16){
|
||||
$("#paypar_account_no").val(cardNo);
|
||||
$("#search").val(cardNo);
|
||||
$("#type").val("card");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -25,6 +25,7 @@
|
||||
<%= form_tag crm_customers_path, :id => "filter_form", :method => :get do %>
|
||||
<div class="input-append col-md-7 form-group pull-left">
|
||||
<input type="text" name="filter" style="margin-right:10px" placeholder="Search" id="search" class="form-control input-xs col-md-9">
|
||||
<input type="hidden" name="type" id="type" value="">
|
||||
<button type="submit" class="btn btn-primary btn-md">Search</button>
|
||||
<!-- <a href="modal-window" data-toggle= "modal" data-target="#modal-window" class="btn btn-primary btn-md" id="card_read" >Read Card</a> -->
|
||||
|
||||
|
||||
@@ -114,8 +114,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<div class="attributes-list">
|
||||
</div>
|
||||
<div class="option-list">
|
||||
<h4 id="attributes-type"></h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -164,7 +165,7 @@ $(function(){
|
||||
menu_items_list.empty();
|
||||
|
||||
menu_items = data.menu_items;
|
||||
|
||||
|
||||
for(var field in menu_items) {
|
||||
|
||||
instances = menu_items[field].instances ;
|
||||
@@ -191,7 +192,7 @@ $(function(){
|
||||
+'</i></div>'
|
||||
+'</div>'
|
||||
|
||||
+"<div class='menu_item_box' data-id = '"+JSON.stringify(menu_items[field].attributes)+"' data-item = '"+JSON.stringify(item_attributes)+"' data-toggle='modal' data-target='.sx_item_detailModal'>'"
|
||||
+"<div class='menu_item_box' data-instance = '"+JSON.stringify(menu_items[field].instances)+"' data-id = '"+JSON.stringify(menu_items[field].attributes)+"' data-item = '"+JSON.stringify(item_attributes)+"' data-toggle='modal' data-target='.sx_item_detailModal'>'"
|
||||
|
||||
+'<div class="card-block">'
|
||||
+'<%= image_tag "logo.png" ,width: '75', height: '75', :style => '' %>'
|
||||
@@ -212,11 +213,14 @@ $(function(){
|
||||
|
||||
//click item row for add order
|
||||
$(document).on('click', '.menu_item_box', function(event){
|
||||
$('.option-list').empty();
|
||||
$('.attributes-list').empty();
|
||||
$('.attributes-list').empty();
|
||||
|
||||
data = $(this).parent().children().children('.add_icon');
|
||||
attributes = $(this).data('id');
|
||||
selected_item = $(this).data('item');
|
||||
console.log(attributes);
|
||||
instances = $(this).data('instance');
|
||||
|
||||
for(var field in attributes) {
|
||||
value = attributes[field]["value"];
|
||||
type = attributes[field]["type"]
|
||||
@@ -228,13 +232,12 @@ $(function(){
|
||||
status = "selected-option";
|
||||
}
|
||||
|
||||
row +='<button id="selected-option" data-type="'+type+'" class="btn btn-default custom-btn '+ status +' '+ type +'">'+value[i]+'</button>';
|
||||
row +="<button id='selected-option' data-instances='"+JSON.stringify(instances)+"' data-type='"+type+"' data-value='"+value[i]+"' class='btn btn-default attribute_btn "+ status +" "+ type +" '>"+value[i]+"</button>";
|
||||
|
||||
});
|
||||
$(".option-list").append(row);
|
||||
|
||||
|
||||
$(".attributes-list").append(row);
|
||||
}
|
||||
|
||||
$('#change_qty').val(1);
|
||||
$('#title_name').text(data.attr('data-name'));
|
||||
$('#total_price').text(data.attr('data-price'));
|
||||
@@ -242,11 +245,29 @@ $(function(){
|
||||
});
|
||||
|
||||
// click select option icon for add
|
||||
$(document).on('click', '.custom-btn', function(event){
|
||||
type = $(this).data('type');
|
||||
$('+ type +').removeClass('selected-option');
|
||||
$(document).on('click', '.attribute_btn', function(event){
|
||||
value = $(this).data('value');
|
||||
type = $(this).data('type');
|
||||
instances = $(this).data('instances');
|
||||
if ($(".attribute_btn").attr("data-type")==type){
|
||||
$('.'+type).removeClass("selected-option");
|
||||
}
|
||||
|
||||
$(this).addClass('selected-option');
|
||||
|
||||
selected_item = $('.selected-option').text();
|
||||
|
||||
qty = $('#change_qty').val();
|
||||
|
||||
// for(var field in instances) {
|
||||
// item_attr = instances[field].item_attributes;
|
||||
|
||||
// status ="";
|
||||
// if(parseInt(jQuery.inArray(selected_item, item_attr))!== -1){
|
||||
// status = "selected-option";
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
}); //End selecct Click
|
||||
|
||||
@@ -445,7 +466,7 @@ $(function(){
|
||||
color: #fff !important;
|
||||
background-color: green !important;
|
||||
}
|
||||
.custom-btn {
|
||||
.attribute_btn {
|
||||
white-space: normal !important;
|
||||
height: 60px;
|
||||
width: 90px;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<%= form_tag path, :id => "filter_form", :method => :get do %>
|
||||
<div class="input-append col-md-7 form-group pull-left">
|
||||
<input type="text" name="filter" style="margin-right:10px" id="search" placeholder="Search" class="form-control input-sm col-md-9">
|
||||
<input type="hidden" name="type" id="type" value="">
|
||||
<button type="submit" class="btn btn-primary btn-sm">Search</button>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -258,9 +259,14 @@
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "get_customer" ,
|
||||
data: { filter : customer_mamber_card_no },
|
||||
data: { filter : customer_mamber_card_no ,type :"card"},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
success: function(data) {
|
||||
if (data.status == false) {
|
||||
alert(data.message)
|
||||
}
|
||||
|
||||
|
||||
customer_id = data[0].customer_id;
|
||||
customer_name = data[0].name;
|
||||
update_sale(customer_id, customer_name,sale_id);
|
||||
@@ -282,6 +288,7 @@
|
||||
if(cardNo.length == 16){
|
||||
$("#paypar_account_no").val(cardNo);
|
||||
$("#search").val(cardNo);
|
||||
$("#type").val("card")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user