merge with crm

This commit is contained in:
Yan
2017-06-23 17:51:09 +06:30
22 changed files with 465 additions and 307 deletions

View File

@@ -37,7 +37,7 @@ $(document).ready(function(){
control_button(order_status); control_button(order_status);
var customer_id=$(this).find(".customer-id").text(); var customer_id=$(this).find(".customer-id").text();
//show_customer_details(customer_id); show_customer_details(customer_id);
$("#re-print").val(unique_id); $("#re-print").val(unique_id);

View File

@@ -14,6 +14,7 @@ class ApplicationController < ActionController::Base
# redirect_to root_path # redirect_to root_path
# end # end
def current_user def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end end

View File

@@ -70,7 +70,6 @@ class Crm::CustomersController < BaseCrmController
@crm_customers = Customer.new(customer_params) @crm_customers = Customer.new(customer_params)
respond_to do |format| respond_to do |format|
puts @crm_customers.errors.to_json
if @crm_customers.save if @crm_customers.save
name = customer_params[:name] name = customer_params[:name]
phone = customer_params[:contact_no] phone = customer_params[:contact_no]
@@ -80,6 +79,7 @@ class Crm::CustomersController < BaseCrmController
nrc = customer_params[:nrc_no] nrc = customer_params[:nrc_no]
member_group_id = params[:member_group_id] member_group_id = params[:member_group_id]
if !member_group_id.nil?
membership = MembershipSetting.find_by_membership_type("paypar_url") membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("create_membership_customer") memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
merchant_uid = memberaction.merchant_account_id.to_s merchant_uid = memberaction.merchant_account_id.to_s
@@ -89,7 +89,8 @@ class Crm::CustomersController < BaseCrmController
begin begin
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc, dob: dob,address: address,nrc:nrc,
member_group_id: member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, member_group_id: member_group_id,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
:headers => { :headers => {
'Content-Type' => 'application/json', 'Content-Type' => 'application/json',
'Accept' => 'application/json' 'Accept' => 'application/json'
@@ -103,7 +104,7 @@ class Crm::CustomersController < BaseCrmController
if response["status"] == true if response["status"] == true
customer = Customer.find(@crm_customers.customer_id) customer = Customer.find(@crm_customers.customer_id)
status = customer.update_attributes(membership_id: response["customer_datas"]["id"]) status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
if params[:sale_id] if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' } format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' }
@@ -112,7 +113,6 @@ class Crm::CustomersController < BaseCrmController
end end
# format.json { render :index, status: :created, location: @crm_customers } # format.json { render :index, status: :created, location: @crm_customers }
else else
# @crm_customers.destroy # @crm_customers.destroy
if params[:sale_id] if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'} format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'}
@@ -120,6 +120,7 @@ class Crm::CustomersController < BaseCrmController
format.html { redirect_to crm_customers_path, notice: response["message"] } format.html { redirect_to crm_customers_path, notice: response["message"] }
end end
end end
end
else else
if params[:sale_id] if params[:sale_id]
@@ -135,7 +136,6 @@ class Crm::CustomersController < BaseCrmController
end end
end end
# PATCH/PUT /crm/customers/1 # PATCH/PUT /crm/customers/1
# PATCH/PUT /crm/customers/1.json # PATCH/PUT /crm/customers/1.json
def update def update
@@ -152,6 +152,39 @@ end
id = @crm_customer.membership_id id = @crm_customer.membership_id
member_group_id = params[:member_group_id] member_group_id = params[:member_group_id]
if id.nil? && !member_group_id.nil?
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
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.post(url, :body => { name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc,
member_group_id: member_group_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
if response["status"] == true
customer = Customer.find(@crm_customer.customer_id)
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated'}
else
format.html { redirect_to crm_customers_path, notice: response["message"] }
end
else
membership = MembershipSetting.find_by_membership_type("paypar_url") membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("update_membership_customer") memberaction = MembershipAction.find_by_membership_type("update_membership_customer")
merchant_uid = memberaction.merchant_account_id.to_s merchant_uid = memberaction.merchant_account_id.to_s
@@ -170,8 +203,15 @@ end
rescue Net::OpenTimeout rescue Net::OpenTimeout
response = { status: false } response = { status: false }
end end
if response["status"] == true
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' } format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' }
format.json { render :show, status: :ok, location: @crm_customer } format.json { render :show, status: :ok, location: @crm_customer }
else
format.html { redirect_to crm_customers_path, notice: response["message"] }
end
end
else else

View File

@@ -104,6 +104,6 @@ class Crm::DiningQueuesController < BaseCrmController
# Never trust parameters from the scary internet, only allow the white list through. # Never trust parameters from the scary internet, only allow the white list through.
def dining_queue_params def dining_queue_params
params.require(:dining_queue).permit(:name, :contact_no, :queue_no,:status) params.require(:dining_queue).permit(:name, :contact_no, :queue_no,:status,:seater,:remark)
end end
end end

View File

@@ -1,12 +1,12 @@
class Crm::HomeController < BaseCrmController class Crm::HomeController < BaseCrmController
def index def index
@booking = Booking.all # @booking = Booking.all
@customer = Customer.all # @customer = Customer.all
from = Time.now.beginning_of_day.utc # from = Time.now.beginning_of_day.utc
to = Time.now.end_of_day.utc # to = Time.now.end_of_day.utc
@queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to).order('queue_no ASC') # @queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to).order('queue_no ASC')
redirect_to crm_customers_path
# .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) # .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
end end

View File

@@ -13,6 +13,15 @@ class Origami::CustomersController < BaseOrigamiController
def add_customer def add_customer
@sale_id = params[:sale_id] @sale_id = params[:sale_id]
if(@sale_id[0,3] == "SAL")
@booking = Booking.find_by_sale_id(@sale_id)
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
else
@booking_order = BookingOrder.find_by_order_id(@sale_id)
@booking = Booking.find(@booking_order.booking_id)
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
end
filter = params[:filter] filter = params[:filter]
filter = params[:filter] filter = params[:filter]

View File

@@ -25,12 +25,12 @@ class Origami::HomeController < BaseOrigamiController
order = Order.find(booking_order.order_id) order = Order.find(booking_order.order_id)
if (order.status == "new") if (order.status == "new")
@obj_order = order @obj_order = order
@customer = order.customer
@date = order.created_at @date = order.created_at
order.order_items.each do |item| order.order_items.each do |item|
@order_items.push(item) @order_items.push(item)
end end
end end
end
@status_order = 'order' @status_order = 'order'
else else
sale = Sale.find(booking.sale_id) sale = Sale.find(booking.sale_id)
@@ -43,6 +43,7 @@ class Origami::HomeController < BaseOrigamiController
@date = sale.created_at @date = sale.created_at
@status_sale = 'sale' @status_sale = 'sale'
@obj_sale = sale @obj_sale = sale
@customer = sale.customer
end end
end end
end end

View File

@@ -9,9 +9,11 @@ class Origami::RoomsController < BaseOrigamiController
@room.bookings.each do |booking| @room.bookings.each do |booking|
if booking.sale_id.nil? if booking.sale_id.nil?
@order_items = Array.new @order_items = Array.new
booking.booking_orders.each do |booking_order| booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id) order = Order.find(booking_order.order_id)
@obj = order @obj = order
@customer = order.customer
order.order_items.each do |item| order.order_items.each do |item|
@order_items.push(item) @order_items.push(item)
end end
@@ -23,6 +25,7 @@ class Origami::RoomsController < BaseOrigamiController
if sale.sale_status != "completed" if sale.sale_status != "completed"
@status = 'sale' @status = 'sale'
@obj = sale @obj = sale
@customer = sale.customer
end end
end end
end end

View File

@@ -104,6 +104,7 @@
<div class="form-group"> <div class="form-group">
<label>Select Member Group</label> <label>Select Member Group</label>
<select class="selectpicker form-control col-md-12" name="member_group_id" style="height: 40px" > <select class="selectpicker form-control col-md-12" name="member_group_id" style="height: 40px" >
<option value="">Select Membership Group</option>
<% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %> <% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
<option value="<%= member.value %>"> <option value="<%= member.value %>">
<%= member.name %></option> <%= member.name %></option>

View File

@@ -37,9 +37,10 @@
<th>Select</th> <th>Select</th>
<th>Sr.no</th> <th>Sr.no</th>
<th>Name</th> <th>Name</th>
<th>Company</th> <th>Card No</th>
<th>Contact no</th> <th>Contact no</th>
<th>Email</th> <th>Email</th>
<th>Action</th>
</tr> </tr>
</thead> </thead>
@@ -52,7 +53,7 @@
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td> <input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
<td><%= @i += 1 %></td> <td><%= @i += 1 %></td>
<td><%= crm_customer.name %></td> <td><%= crm_customer.name %></td>
<td><%= crm_customer.company rescue '-' %></td> <td><%= crm_customer.card_no rescue '-' %></td>
<td><%= crm_customer.contact_no %></td> <td><%= crm_customer.contact_no %></td>
<td><%= crm_customer.email %></td> <td><%= crm_customer.email %></td>
<td><%= link_to 'Show', crm_customer_path(crm_customer) %></td> <td><%= link_to 'Show', crm_customer_path(crm_customer) %></td>
@@ -126,7 +127,7 @@ $(document).on('click',".customer_tr",function(){
$('#customer_address').val(data.address); $('#customer_address').val(data.address);
$('#customer_date_of_birth').val(data.date_of_birth); $('#customer_date_of_birth').val(data.date_of_birth);
$('#customer_membership_type').val(data.membership_type); $('#customer_membership_type').val(data.membership_type);
$('.selectpicker > option[value="'+data.membership_type+'"]').attr('selected','selected');
if (data.gender == 'Male') { if (data.gender == 'Male') {
$('.male').prop( "checked", true ) $('.male').prop( "checked", true )
}else{ }else{
@@ -142,7 +143,7 @@ $(document).on('click',".customer_tr",function(){
}else{ }else{
$('.mdm').prop( "checked", true ) $('.mdm').prop( "checked", true )
} }
// $('.selectpicker > option[value="'+data.membership_id+'"]').attr('selected','selected');
$('.membership_authentication_code').val(data.membership_authentication_code); $('.membership_authentication_code').val(data.membership_authentication_code);
$('#update_customer').removeAttr('disabled').val(''); $('#update_customer').removeAttr('disabled').val('');
@@ -150,11 +151,14 @@ $(document).on('click',".customer_tr",function(){
$('#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;
alert(id)
$("#new_customer").attr('id', id); $("#new_customer").attr('id', id);
$(".edit_customer").attr('id', id);
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val()); $(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val()); $(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".patch_method").append('<input type="hidden" name="_method" value="patch">'); $(".patch_method").html('<input type="hidden" name="_method" value="patch">');
//$(".edit_customer").attr('method', 'PATCH'); //$(".edit_customer").attr('method', 'PATCH');
} }
}); });

View File

@@ -1,19 +1,26 @@
<div class="row">
<div class="col-lg-12">
<ol class="breadcrumb">
<li><a href="<%= crm_root_path %>">Home</a></li>
<li class="active">
<a href="<%= crm_customers_path %>">Customer</a>
</li>
<li><%= @customer.customer_id%></li>
</ol>
</div>
</div>
<div class="row"> <div class="row">
<div class="col-lg-11 col-md-11 col-sm-11"> <div class="col-lg-11 col-md-11 col-sm-11">
<!-- Column One --> <!-- Column One -->
<div class="tab-pane active" id="queue" role="tabpanel"">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#customer" role="tab">Customer Details</a>
</li>
<li class="nav-item">
<a class="nav-link " data-toggle="tab" href="#order" role="tab">Order Details</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#sale" role="tab">Sale Details</a>
</li>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content" style="min-height:670px; max-height:670px; ">
<div class="tab-pane active" id="customer" role="tabpanel" style="min-height:670px; max-height:670px; ">
<div class="table-responsive"> <div class="table-responsive">
<br><br>
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
@@ -39,8 +46,20 @@
<td><%= @customer.address%></td> <td><%= @customer.address%></td>
<td><%= @customer.date_of_birth %></td> <td><%= @customer.date_of_birth %></td>
</tr> </tr>
<tr><th colspan="8"></th></tr>
</tbody>
</table>
</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr> <tr>
<th colspan="8">Membership Transactions</th> <th colspan="5">Membership Transactions</th>
<% if @response["status"] == true %>
<th>Current Balance : <%= @response["data"][0]["balance"]%></th>
<% end %>
</tr> </tr>
<tr> <tr>
<th>Date</th> <th>Date</th>
@@ -51,9 +70,9 @@
<th>Status</th> <th>Status</th>
<th>Receipt No</th> <th>Receipt No</th>
</tr> </tr>
</thead>
<% <tbody>
if @response["status"] == true %> <% if @response["status"] == true %>
<% @response["data"].each do |transaction| %> <% @response["data"].each do |transaction| %>
<tr> <tr>
<td><%= transaction["date"]%></td> <td><%= transaction["date"]%></td>
@@ -72,21 +91,9 @@
</div> </div>
</div> </div>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist"> <div class="tab-pane" id="order" role="tabpanel" style="min-height:670px; max-height:670px; ">
<!-- <li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#queue" role="tab">Customer Details </a>
</li> -->
<li class="nav-item">
<a class="nav-link " data-toggle="tab" href="#booking" role="tab">Orders </a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#customer" role="tab">Sales</a>
</li>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content">
<div class="tab-pane" id="booking" role="tabpanel">
<h3>Order Details</h3> <h3>Order Details</h3>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped"> <table class="table table-striped">
@@ -119,6 +126,39 @@
</tbody> </tbody>
</table> </table>
</div> </div>
</div>
<div class="tab-pane" id="sale" role="tabpanel" style="min-height:670px; max-height:670px; ">
<h3>Sale Details</h3>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Sale ID </th>
<th>Menu Item</th>
<th>QTY</th>
<th>Unit Price </th>
<th>Tax Price</th>
<th>Created At</th>
</tr>
</thead>
<tbody>
<% @sale_items.each do |sale_item| %>
<tr>
<td><%= sale_item.sale_id %></td>
<td><%= sale_item.product_name %></td>
<td><%= sale_item.qty %></td>
<td><%= sale_item.unit_price %></td>
<td><%= sale_item.taxable_price %></td>
<td><%= sale_item.created_at %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div> </div>
<div class="tab-pane" id="customer" role="tabpanel"> <div class="tab-pane" id="customer" role="tabpanel">
<h3>Sale Details</h3> <h3>Sale Details</h3>
@@ -151,17 +191,16 @@
</table> </table>
</div> </div>
</div> </div>
</div>
</div> </div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1"> <div class="col-lg-1 col-md-1 col-sm-1">
<br><br> <br><br>
<a href="<%= crm_customers_path%>" class="btn btn-primary pull"> <a href="<%= crm_customers_path%>" class="btn btn-primary btn-lg">
<i class="fa fa-arrow-left fa-xs"></i> Back <i class="fa fa-arrow-left fa-lg"></i> Back
</a> </a>
</div> </div>
</div> </div>

View File

@@ -1,85 +0,0 @@
<div class="row">
<div class="col-lg-12">
<ol class="breadcrumb">
<li><a href="<%= crm_root_path %>">Home</a></li>
<li class="active">
<a href="<%= crm_customers_path %>">Customer</a>
</li>
<li class="active">Details
</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="main-box-body clearfix">
<div class="table-responsive">
<hr>
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Contact no</th>
<th>Company</th>
<th>Date Of Birth</th>
<th>Membership Account</th>
</tr>
</thead>
<tbody>
<tr>
<td><%= @crm_customer.name %></td>
<td><%= @crm_customer.email %></td>
<td><%= @crm_customer.contact_no %></td>
<td><%= @crm_customer.company %></td>
<td><%= @crm_customer.date_of_birth %> </td>
</tr>
</tbody>
</table>
<br>
<h3>Sale Items</h3>
<table class="table table-striped">
<thead>
<tr>
<th>Sale ID </th>
<th>Menu Item</th>
<th>QTY</th>
<th>Unit Price </th>
<th>Tax Price</th>
<th>Created At</th>
</tr>
</thead>
<tbody>
<% @sale_items.each do |sale_item| %>
<tr>
<td><%= sale_item.sale_id %></td>
<td><%= sale_item.product_name %></td>
<td><%= sale_item.qty %></td>
<td><%= sale_item.unit_price %></td>
<td><%= sale_item.taxable_price %></td>
<td><%= sale_item.created_at %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@@ -2,16 +2,21 @@
<%= simple_form_for([:crm,@dining_queue]) do |f| %> <%= simple_form_for([:crm,@dining_queue]) do |f| %>
<%= f.error_notification %> <%= f.error_notification %>
<p class="hidden generate_no"><%= @queue_no %></p> <p class="hidden generate_no"><%= @queue_no %></p>
<div class="col-md-6">
<div class="form-inputs"> <div class="form-inputs">
<%= f.input :queue_no , :class => "dining",:id => "dining", :readonly => true%>
<%= f.input :name %> <%= f.input :name %>
<%= f.input :contact_no %> <%= f.input :contact_no %>
<%= f.input :queue_no , :class => "dining",:id => "dining", :readonly => true%> <%= f.input :seater %>
<%= f.input :remark %>
</div> </div>
<br> <br>
<div class="form-actions"> <div class="form-actions">
<%= f.button :submit,"Create Queue" %> <%= f.button :submit,"Create Queue" %>
</div> </div>
</div>
<% end %> <% end %>

View File

@@ -24,6 +24,7 @@
<p class="hidden queue-id"><%= @queue.id %></p> <p class="hidden queue-id"><%= @queue.id %></p>
<p class="hidden queue-status"><%= table.status %></p> <p class="hidden queue-status"><%= table.status %></p>
<p style="text-align: center"><%= table.name %></p> <p style="text-align: center"><%= table.name %></p>
<p style="text-align: center">Seat : <%= table.seater %></p>
</div> </div>
</div> </div>

View File

@@ -26,6 +26,7 @@
<p class="hidden queue-status"><%= queue.status %></p> <p class="hidden queue-status"><%= queue.status %></p>
<span class="card-title"> <span class="card-title">
<%= @i += 1 %> . Queue No </span> <%= @i += 1 %> . Queue No </span>
<span class="card-title pull-right">Seater : <%= queue.seater %> </span>
<p style="font-size: 30px ;text-align: center;"> <p style="font-size: 30px ;text-align: center;">
<strong><%= queue.queue_no %></strong> <strong><%= queue.queue_no %></strong>
</p> </p>

View File

@@ -73,6 +73,8 @@
<span class="patch_method"></span> <span class="patch_method"></span>
<input type="hidden" id="sale_id" name="sale_id" value="<%= @sale_id %>" /> <input type="hidden" id="sale_id" name="sale_id" value="<%= @sale_id %>" />
<input type="hidden" id="table_id" name="table_id" value="<%= @dining_facility.id %>" />
<input type="hidden" id="type" name="type" value="<%= @dining_facility.type %>" />
<%= f.error_notification %> <%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %> <%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>"> <div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
@@ -171,6 +173,7 @@
<div class="form-group"> <div class="form-group">
<label>Select Member Group</label> <label>Select Member Group</label>
<select class="selectpicker form-control col-md-12" name="member_group_id"> <select class="selectpicker form-control col-md-12" name="member_group_id">
<option value="">Select Membership Group</option>
<% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %> <% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
<option value="<%= member.value %>"> <option value="<%= member.value %>">
<%= member.name %></option> <%= member.name %></option>
@@ -186,9 +189,9 @@
</div> </div>
<div class="col-lg-1 col-md-1 col-sm-1"> <div class="col-lg-1 col-md-1 col-sm-1">
<br> <br>
<a href="<%= origami_root_path%>" class="btn btn-primary"> <button id="back" class="btn btn-primary">
<i class="fa fa-arrow-left fa-lg"></i> Back <i class="fa fa-arrow-left fa-lg"></i> Back
</a> </button>
</div> </div>
</div> </div>
@@ -292,8 +295,14 @@
success: function(data) { success: function(data) {
if(data.status == true) if(data.status == true)
{ {
var id = $("#table_id").val()
var type = $("#type").val()
if (type=="Table") {
window.location.href = '/origami/table/'+id
}else{
window.location.href = '/origami/room/'+id
}
window.location.href = '/origami'
}else{ }else{
alert('Record not found!'); alert('Record not found!');
location.reload(); location.reload();
@@ -307,4 +316,27 @@
}); });
} }
$('#back').on('click',function(){
var id = $("#table_id").val()
var type = $("#type").val()
if (type=="Table") {
window.location.href = '/origami/table/'+id
}else{
window.location.href = '/origami/room/'+id
}
})
</script> </script>
class CreateDiningQueues < ActiveRecord::Migration[5.1]
def change
create_table :dining_queues do |t|
t.string :name
t.string :contact_no
t.string :queue_no
t.string :status
t.references :dining_facility, foreign_key: true
t.timestamps
end
end
end

View File

@@ -126,9 +126,11 @@
<p>Date: <span id="receipt_date"><%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p> <p>Date: <span id="receipt_date"><%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div> </div>
</div> </div>
<div class="card-title row customer_detail hide">
<div class="card-title row">
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-6 col-md-6 col-sm-6">
<p>Customer : <span id="customer_name"></span></p> <p class="hidden customer-id"><%= @customer.customer_id %></p>
<p>Customer : <%= @customer.name %></p>
</div> </div>
</div> </div>
@@ -295,21 +297,37 @@
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
$(".tables").on('click', function(){ $(".tables").on('click', function(){
var customer_id=$(".customer-id").text();
show_customer_details(customer_id);
var dining_id = $(this).attr("data-id"); var dining_id = $(this).attr("data-id");
window.location.href = '/origami/table/' + dining_id; window.location.href = '/origami/table/' + dining_id;
}); });
$(".sales").on('click',function(){ $(".sales").on('click',function(){
var customer_id=$(".customer-id").text();
show_customer_details(customer_id);
var sale_id = $(this).attr("data-id"); var sale_id = $(this).attr("data-id");
window.location.href = '/origami/sale/' + sale_id; window.location.href = '/origami/sale/' + sale_id;
}); });
$(".rooms").on('click', function(){ $(".rooms").on('click', function(){
var customer_id=$(".customer-id").text();
show_customer_details(customer_id);
var dining_id = $(this).attr("data-id"); var dining_id = $(this).attr("data-id");
window.location.href = '/origami/room/' + dining_id; window.location.href = '/origami/room/' + dining_id;
}); });
$(".orders").on('click',function(){ $(".orders").on('click',function(){
var customer_id=$(".customer-id").text();
show_customer_details(customer_id);
var order_id = $(this).attr("data-id"); var order_id = $(this).attr("data-id");
window.location.href = '/origami/order/' + order_id; window.location.href = '/origami/order/' + order_id;
}); });
@@ -322,8 +340,10 @@ $(document).ready(function(){
}else{ }else{
var sale_id = $('#save_order_id').attr('data-order'); var sale_id = $('#save_order_id').attr('data-order');
} }
var table_id = $('.tables').attr("data-id");
window.location.href = '/origami/'+ sale_id + "/customers" window.location.href = '/origami/'+ sale_id + "/customers"
}); });
// Discount for Payment // Discount for Payment
@@ -392,4 +412,39 @@ $('#add_invoice').on('click',function(){
} }
}); });
}) })
//show cusotmer rebate amount
function show_customer_details(customer_id){
var url = '<%= @show_customer_details_path %>'
//Start Ajax
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
success: function(data) {
$("#customer_name").text(data["customer"].name);
if (data["response_data"]["data"].length) {
$.each(data["response_data"]["data"], function (i) {
if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){
var balance = data["response_data"]["data"][i]["balance"];
if (data["response_data"]["status"]==true) {
$('.rebate_amount').removeClass('hide');
row =
'<td class="charges-name">' + "Rebate Balance" +'</td>'
+'<td class="item-attr">' + balance + '</td>';
$(".rebate_amount").html(row);
}
}
});
}else{
$('.rebate_amount').addClass('hide');
}
}
});
//End Ajax
}
</script> </script>

View File

@@ -107,11 +107,12 @@
<div class="col-lg-5 col-md-5 col-sm-5"> <div class="col-lg-5 col-md-5 col-sm-5">
<div class="card" > <div class="card" >
<div class="card-header"> <div class="card-header">
<% if @status == "order" %> <% if @status == 'order' %>
<div id="save_order_id" data-order="<%= @obj.order_id %>"><strong id="order-title">ORDER DETAILS </strong></div> <div id="save_order_id" data-order="<%= @obj.order_id %>"><strong id="order-title">ORDER DETAILS </strong></div>
<% else %> <% elsif @status_sale == 'sale' %>
<div><strong id="order-title">INVOICE DETAILS </strong></div> <div><strong id="order-title">INVOICE DETAILS </strong></div>
<% end %> <% end %>
</div> </div>
<div class="card-block"> <div class="card-block">
<div class="card-title row"> <div class="card-title row">
@@ -128,7 +129,8 @@
</div> </div>
<div class="card-title row customer_detail hide"> <div class="card-title row customer_detail hide">
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-6 col-md-6 col-sm-6">
<p>Customer : <span id="customer_name"></span></p> <p class="hidden customer-id"><%= @customer.customer_id %></p>
<p>Customer : <%= @customer.name %></p>
</div> </div>
</div> </div>
@@ -254,24 +256,36 @@
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
$(".tables").on('click', function(){ $(".tables").on('click', function(){
var customer_id=$(".customer-id").text();
show_customer_details(customer_id);
var dining_id = $(this).attr("data-id"); var dining_id = $(this).attr("data-id");
window.location.href = '/origami/table/' + dining_id; window.location.href = '/origami/table/' + dining_id;
}) })
$(".sales").on('click',function(){ $(".sales").on('click',function(){
var customer_id=$(".customer-id").text();
show_customer_details(customer_id);
var sale_id = $(this).attr("data-id"); var sale_id = $(this).attr("data-id");
window.location.href = '/origami/sale/' + sale_id; window.location.href = '/origami/sale/' + sale_id;
}) })
$(".rooms").on('click', function(){ $(".rooms").on('click', function(){
var customer_id=$(".customer-id").text();
show_customer_details(customer_id);
var dining_id = $(this).attr("data-id"); var dining_id = $(this).attr("data-id");
window.location.href = '/origami/room/' + dining_id; window.location.href = '/origami/room/' + dining_id;
}) })
$(".orders").on('click',function(){ $(".orders").on('click',function(){
var customer_id=$(".customer-id").text();
show_customer_details(customer_id);
var order_id = $(this).attr("data-id"); var order_id = $(this).attr("data-id");
window.location.href = '/origami/order/' + order_id; window.location.href = '/origami/order/' + order_id;
}) })
// 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
@@ -331,4 +345,40 @@ $('#move').on('click',function(){
$('#back').on('click',function(){ $('#back').on('click',function(){
window.location.href = '/origami/'; window.location.href = '/origami/';
}) })
//show cusotmer rebate amount
function show_customer_details(customer_id){
var url = '<%= @show_customer_details_path %>'
//Start Ajax
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
success: function(data) {
$("#customer_name").text(data["customer"].name);
if (data["response_data"]["data"].length) {
$.each(data["response_data"]["data"], function (i) {
if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){
var balance = data["response_data"]["data"][i]["balance"];
if (data["response_data"]["status"]==true) {
$('.rebate_amount').removeClass('hide');
row =
'<td class="charges-name">' + "Rebate Balance" +'</td>'
+'<td class="item-attr">' + balance + '</td>';
$(".rebate_amount").html(row);
}
}
});
}else{
$('.rebate_amount').addClass('hide');
}
}
});
//End Ajax
}
</script> </script>

View File

@@ -110,14 +110,14 @@
<tr><td colspan="5">&nbsp;<td></tr> <tr><td colspan="5">&nbsp;<td></tr>
<tr> <tr>
<td colspan=2 style="text-align:center"></td> <td colspan=2 style="text-align:center"></td>
<td>Pay Amount</td> <td>Total Pay Amount</td>
<td colspan="2"><%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%></td> <td colspan="2"><%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr> </tr>
<% @sale_receivables.each do |r|%> <% @sale_receivables.each do |r|%>
<tr> <tr>
<td colspan=2 style="text-align:center"></td> <td colspan=2 style="text-align:center"></td>
<td>Payment <%= r.payment_method rescue ' '%></td> <td> <%= r.payment_method.capitalize rescue ' '%> Payment</td>
<td colspan="2"><%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%> <td colspan="2"><%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%>
</td> </td>
</tr> </tr>

View File

@@ -112,7 +112,7 @@ Rails.application.routes.draw do
#---------Add Customer --------------# #---------Add Customer --------------#
#resources :customers #resources :customers
get '/:sale_id/customers', to: "customers#add_customer" get '/:sale_id/customers', to: "customers#add_customer"
get '/:customer_id/get_customer' => 'home#get_customer' get '/:customer_id/get_customer' => 'home#get_customer',:as => "show_customer_details"
post '/:sale_id/update_sale' , to: "customers#update_sale_by_customer"#update customer id in sale table post '/:sale_id/update_sale' , to: "customers#update_sale_by_customer"#update customer id in sale table
end end

View File

@@ -6,7 +6,8 @@ class CreateDiningQueues < ActiveRecord::Migration[5.1]
t.string :queue_no t.string :queue_no
t.string :status t.string :status
t.references :dining_facility, foreign_key: true t.references :dining_facility, foreign_key: true
t.integer :seater
t.string :remark
t.timestamps t.timestamps
end end
end end