merge with crm
This commit is contained in:
@@ -43,6 +43,10 @@ $(document).ready(function(){
|
||||
$("#customer").attr('disabled','disabled');
|
||||
}
|
||||
|
||||
var customer_id=$(this).find(".customer-id").text();
|
||||
show_customer_details(customer_id);
|
||||
|
||||
|
||||
var cashier="";
|
||||
var receipt_date="";
|
||||
var sub_total=0;
|
||||
@@ -165,6 +169,7 @@ $(document).ready(function(){
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Payment for Bill
|
||||
$('#pay-bill').click(function() {
|
||||
var sale_id=$(".selected-item").find(".orders-id").text();
|
||||
@@ -180,10 +185,27 @@ $(document).ready(function(){
|
||||
|
||||
$('#customer').click(function() {
|
||||
var sale_id=$(".selected-item").find(".orders-id").text();
|
||||
window.location.href = '/crm/customers/'+ sale_id + "/assign_sale_id"
|
||||
window.location.href = '/origami/'+ sale_id + "/add_customer"
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
function show_customer_details(customer_id){
|
||||
$('.customer_detail').removeClass('hide');
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "origami/"+customer_id+"/get_customer/",
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
$("#customer_name").text(data.name);
|
||||
$("#customer_name").text(data.name);
|
||||
}
|
||||
});
|
||||
//End Ajax
|
||||
}
|
||||
|
||||
/* For Receipt - Calculate discount or tax */
|
||||
$('.cashier_number').on('click', function(event){
|
||||
if(event.handled !== true) {
|
||||
|
||||
@@ -4,21 +4,23 @@ class Crm::CustomersController < BaseCrmController
|
||||
# GET /crm/customers
|
||||
# GET /crm/customers.json
|
||||
def index
|
||||
@sale_id = 0
|
||||
filter = params[:filter]
|
||||
|
||||
if filter.nil?
|
||||
@crm_customers = Customer.order("name").page(params[:page])
|
||||
@crm_customers = Customer.order("customer_id").page(params[:page])
|
||||
#@products = Product.order("name").page(params[:page]).per(5)
|
||||
else
|
||||
@crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page])
|
||||
end
|
||||
#@crm_customers = Customer.all
|
||||
@crm_customer = Customer.new
|
||||
@membership = Customer.get_member_group
|
||||
if @membership["status"] == true
|
||||
@member_group = @membership["data"]
|
||||
end
|
||||
@crm_customer = Customer.new
|
||||
@crm_customer.valid?
|
||||
|
||||
|
||||
# @membership = Customer.get_member_group
|
||||
# if @membership["status"] == true
|
||||
# @member_group = @membership["data"]
|
||||
# end
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @crm_customers }
|
||||
@@ -49,8 +51,6 @@ class Crm::CustomersController < BaseCrmController
|
||||
|
||||
respond_to do |format|
|
||||
if @crm_customers.save
|
||||
|
||||
|
||||
name = customer_params[:name]
|
||||
phone = customer_params[:contact_no]
|
||||
email = customer_params[:email]
|
||||
@@ -71,40 +71,37 @@ class Crm::CustomersController < BaseCrmController
|
||||
}
|
||||
)
|
||||
|
||||
if response["status"] == true
|
||||
if response["status"] == true
|
||||
customer = Customer.find(@crm_customers.customer_id)
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"])
|
||||
if params[:sale_id] != 0
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' }
|
||||
|
||||
if params[:sale_id].nil?
|
||||
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer', notice: 'Customer was successfully created.' }
|
||||
else
|
||||
format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: 'Customer was successfully created.' }
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' }
|
||||
end
|
||||
# format.json { render :index, status: :created, location: @crm_customers }
|
||||
else
|
||||
|
||||
|
||||
@crm_customers.destroy
|
||||
|
||||
if params[:sale_id] != 0
|
||||
format.html { redirect_to crm_customers_path, notice: response["message"] }
|
||||
|
||||
if params[:sale_id].nil?
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
|
||||
else
|
||||
format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: response["message"] }
|
||||
format.html { redirect_to crm_customers_path, notice: response["message"] }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
# format.json { render :index, status: :created, location: @crm_customers }
|
||||
|
||||
else
|
||||
if params[:sale_id] != 0
|
||||
format.html { redirect_to crm_customers_path}
|
||||
format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
|
||||
|
||||
else
|
||||
format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: response["message"] }
|
||||
end
|
||||
|
||||
|
||||
if params[:sale_id].nil?
|
||||
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
|
||||
else
|
||||
|
||||
format.html { redirect_to crm_customers_path}
|
||||
format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -161,7 +158,6 @@ class Crm::CustomersController < BaseCrmController
|
||||
# DELETE /crm/customers/1
|
||||
# DELETE /crm/customers/1.json
|
||||
def get_sale_id
|
||||
|
||||
@sale_id = params[:sale_id]
|
||||
@crm_customers = Customer.all
|
||||
@crm_customer = Customer.new
|
||||
@@ -184,6 +180,6 @@ class Crm::CustomersController < BaseCrmController
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def customer_params
|
||||
|
||||
params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth, :membership_type, :membership_authentication_code)
|
||||
params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,38 @@
|
||||
class Origami::CustomersController < BaseOrigamiController
|
||||
#Form to add customer -
|
||||
def index
|
||||
|
||||
|
||||
end
|
||||
def create
|
||||
|
||||
# GET /crm/customers/1
|
||||
# GET /crm/customers/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
|
||||
|
||||
def add_customer
|
||||
|
||||
@sale_id = params[:sale_id]
|
||||
filter = params[:filter]
|
||||
|
||||
if filter.nil?
|
||||
@crm_customers = Customer.order("name").page(params[:page])
|
||||
else
|
||||
@crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page])
|
||||
end
|
||||
@crm_customer = Customer.new
|
||||
@membership = Customer.get_member_group
|
||||
if @membership["status"] == true
|
||||
@member_group = @membership["data"]
|
||||
end
|
||||
respond_to do |format|
|
||||
# format.html { render :template => "crm/customers/index" }
|
||||
format.html { render action: "index"}
|
||||
format.json { render json: @crm_customers }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -17,7 +17,12 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@booking_orders = Order.get_booking_order_table()
|
||||
@booking_rooms = Order.get_booking_order_rooms()
|
||||
@orders = Order.get_orders()
|
||||
<<<<<<< HEAD
|
||||
end
|
||||
=======
|
||||
|
||||
end
|
||||
>>>>>>> d65882ac5bcdce934116e65b66a8a3cb34965ba3
|
||||
|
||||
def item_show
|
||||
selection(params[:booking_id],1)
|
||||
@@ -45,4 +50,23 @@ class Origami::HomeController < BaseOrigamiController
|
||||
str
|
||||
end
|
||||
end
|
||||
|
||||
def update_sale_by_customer
|
||||
|
||||
sale = Sale.find(params[:sale_id])
|
||||
status = sale.update_attributes(customer_id: params[:customer_id])
|
||||
|
||||
if status == true
|
||||
render json: JSON.generate({:status => true})
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def get_customer
|
||||
@customer = Customer.find(params[:customer_id])
|
||||
|
||||
render :json => @customer.to_json
|
||||
end
|
||||
end
|
||||
|
||||
@@ -221,8 +221,8 @@ class Order < ApplicationRecord
|
||||
end
|
||||
|
||||
#Origami: Cashier : to view booking order Table
|
||||
def self.get_selected_order(id)
|
||||
booking_orders = Booking.select("sales.receipt_no,orders.status as order_status,
|
||||
def self.get_booking_order_table
|
||||
booking_orders = Booking.select("sales.receipt_no,orders.status as order_status,orders.customer_id as customer_id,
|
||||
bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
|
||||
.joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id")
|
||||
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
|
||||
@@ -261,7 +261,7 @@ class Order < ApplicationRecord
|
||||
|
||||
#Origami: Cashier : to view order type Room
|
||||
def self.get_booking_order_rooms
|
||||
booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status,bookings.booking_id,
|
||||
booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status,bookings.booking_id,orders.customer_id as customer_id,
|
||||
sales.sale_id as sale_id,dining_facilities.name as room_name")
|
||||
.joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id")
|
||||
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
|
||||
@@ -290,7 +290,7 @@ class Order < ApplicationRecord
|
||||
from = Time.now.beginning_of_day.utc
|
||||
to = Time.now.end_of_day.utc
|
||||
orders = Order.select("orders.order_id as order_id,sales.receipt_no,orders.status as order_status,
|
||||
bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
|
||||
orders.customer_id as customer_id,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
|
||||
.joins("left join booking_orders on booking_orders.order_id = orders.order_id
|
||||
left join bookings on bookings.booking_id = booking_orders.order_id
|
||||
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
|
||||
|
||||
@@ -69,8 +69,10 @@
|
||||
|
||||
<div class="col-lg-4">
|
||||
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
|
||||
|
||||
<span class="patch_method"></span>
|
||||
<input type="hidden" id="sale_id" name="sale_id" value="<%= @sale_id %>" />
|
||||
<%= f.error_notification %>
|
||||
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
|
||||
|
||||
<div class="form-group">
|
||||
@@ -95,24 +97,14 @@
|
||||
<%= f.text_field :date_of_birth,:class=>"form-control date_of_birth datepicker"%>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<select class="selectpicker form-control col-md-12" name="membership_id">
|
||||
<option>Select Member Group</option>
|
||||
<% @member_group.each do |member| %>
|
||||
<option value="<%= member["id"] %>">
|
||||
<%= member["name"] %></option>
|
||||
<%end %>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<!-- <div class="form-group">
|
||||
<%= f.input :membership_type, :class => "form-control col-md-6 membership_type" %>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.input :membership_authentication_code, :class => "form-control col-md-6 membership_authentication_code" %>
|
||||
</div>
|
||||
|
||||
-->
|
||||
<div class="form-group">
|
||||
<%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %>
|
||||
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %>
|
||||
@@ -140,11 +132,11 @@
|
||||
$(document).on('click',".checkbox_check",function(){
|
||||
if(this.checked){
|
||||
|
||||
var sale_id = $("#sale_id").val() || 0;
|
||||
var sale_id = $("#sale_id").val() || 0;
|
||||
var customer_id = $(this).val();
|
||||
|
||||
if(sale_id != 0){
|
||||
var url = "../"+customer_id;
|
||||
// var url = "/"+customer_id;
|
||||
update_sale(customer_id,sale_id);
|
||||
}else{
|
||||
|
||||
@@ -201,7 +193,7 @@
|
||||
action: function(){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "../../update_sale/" ,
|
||||
url: "update_sale/" ,
|
||||
data: {customer_id:customer_id,sale_id:sale_id},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
|
||||
@@ -76,8 +76,9 @@ $(function(){
|
||||
//End Print Click
|
||||
|
||||
$('.assign').click(function(e){
|
||||
var booking_id = $(this).val()
|
||||
var type = $(this).attr("data-type")
|
||||
var booking_id = $(this).val();
|
||||
var type = $(this).attr("data-type");
|
||||
alert(booking_id);
|
||||
|
||||
update_booking(booking_id,type)
|
||||
});
|
||||
@@ -190,7 +191,7 @@ function update_booking(booking_id,type) {
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "update_booking/" ,
|
||||
url: "crm/update_booking/" ,
|
||||
data: {booking_id:booking_id,type:type},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<!-- Column One -->
|
||||
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<!-- <ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#queue" role="tab">Queue <span class="badge badge-pill badge-default"><%= @queue.count %></span></a>
|
||||
</li>
|
||||
@@ -13,7 +13,7 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#customer" role="tab">Customers</a>
|
||||
</li>
|
||||
</ul>
|
||||
</ul> -->
|
||||
<!-- Nav tabs - End -->
|
||||
|
||||
<div class="tab-content" style="min-height:670px; max-height:670px; overflow-y:scroll">
|
||||
|
||||
@@ -51,7 +51,12 @@
|
||||
<div class="card orders <%= sale_status %>">
|
||||
<div class="card-block">
|
||||
<p class="hidden orders-id"><%= unique_id %></p>
|
||||
<<<<<<< HEAD
|
||||
<h4 class="card-title orders-table"><%= cpo.table_name %></h4>
|
||||
=======
|
||||
<p class="hidden customer-id"><%= bko.customer_id %></p>
|
||||
<h4 class="card-title orders-table"><%= bko.table_name %></h4>
|
||||
>>>>>>> d65882ac5bcdce934116e65b66a8a3cb34965ba3
|
||||
<p class="card-text">
|
||||
Receipt No :
|
||||
<span class="orders-receipt-no">
|
||||
@@ -157,8 +162,14 @@
|
||||
%>
|
||||
<div class="card orders <%= sale_status %>">
|
||||
<div class="card-block">
|
||||
<<<<<<< HEAD
|
||||
<p class="hidden orders-id"><%= unique_id %></p>
|
||||
<h4 class="card-title orders-table"><%= rmo.room_name %></h4>
|
||||
=======
|
||||
<p class="hidden orders-id"><%= unique_id %></p>
|
||||
<p class="hidden customer-id"><%= rmo.customer_id %></p>
|
||||
<h4 class="card-title orders-table"><%= rmo.room_name %></h4>
|
||||
>>>>>>> d65882ac5bcdce934116e65b66a8a3cb34965ba3
|
||||
<p class="card-text">
|
||||
Receipt No :
|
||||
<span class="orders-receipt-no">
|
||||
@@ -211,8 +222,14 @@
|
||||
%>
|
||||
<div class="card orders <%= sale_status %>">
|
||||
<div class="card-block">
|
||||
<<<<<<< HEAD
|
||||
<p class="hidden orders-id"><%= unique_id %></p>
|
||||
<h4 class="card-title orders-table"><%= odr.table_name %></h4>
|
||||
=======
|
||||
<p class="hidden orders-id"><%= unique_id %></p>
|
||||
<p class="hidden customer-id"><%= odr.customer_id %></p>
|
||||
<h4 class="card-title orders-table"><%= odr.table_name %></h4>
|
||||
>>>>>>> d65882ac5bcdce934116e65b66a8a3cb34965ba3
|
||||
<p class="card-text">
|
||||
Receipt No :
|
||||
<span class="orders-receipt-no">
|
||||
@@ -255,6 +272,15 @@
|
||||
<p>Date: <span id="receipt_date"><%=@selected_item.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-title row customer_detail hide">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<p>Customer : <span id="customer_name"></span></p>
|
||||
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
|
||||
<p>Amount : <span id="customer_amount"></span></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-text">
|
||||
<table class="table table-striped" id="order-items-table">
|
||||
<thead>
|
||||
@@ -339,13 +365,11 @@
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Add Order</button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Edit</button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Move</button>
|
||||
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled id="customer" disabled>Customer</button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" id="customer" disabled>Customer</button>
|
||||
<button type="button" id="request_bills" class="btn btn-primary btn-lg btn-block" disabled>Req.Bill</button>
|
||||
<!-- Cashier Buttons -->
|
||||
<button type="button" id="discount" class="btn btn-primary btn-lg btn-block" disabled>Discount</button>
|
||||
<!-- <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Tax</button> -->
|
||||
|
||||
<button type="button" id="pay-bill" class="btn btn-primary btn-lg btn-block" disabled>Pay</button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Re.Print</button>
|
||||
</div>
|
||||
|
||||
@@ -72,9 +72,15 @@ Rails.application.routes.draw do
|
||||
#--------- Cashier ------------#
|
||||
namespace :origami do
|
||||
root "home#index"
|
||||
<<<<<<< HEAD
|
||||
get "/:booking_id" => "home#index" do #origami/:booking_id will show
|
||||
# resources :discounts, only: [:index,:new, :create ] #add discount type
|
||||
resources :customers, only: [:index,:new, :create ] #add customer type
|
||||
=======
|
||||
get "/:booking_id" => "home#show" do #origami/:booking_id will show
|
||||
resources :discounts, only: [:index,:new, :create ] #add discount type
|
||||
resources :customers #add customer type
|
||||
>>>>>>> d65882ac5bcdce934116e65b66a8a3cb34965ba3
|
||||
end
|
||||
|
||||
post '/:booking_id' => 'home#item_show'
|
||||
@@ -90,10 +96,20 @@ Rails.application.routes.draw do
|
||||
post 'paypar_payment_process' => 'paypar_payments#create'
|
||||
get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index"
|
||||
get 'sale/:sale_id/payment/others_payment' => "others_payments#index"
|
||||
<<<<<<< HEAD
|
||||
# get 'sale/:sale_id/payment/others_payment/:payment_method' => "redeem_payments#index"
|
||||
get 'sale/:sale_id/payment/others_payment/MPU' => "mpu#index"
|
||||
post 'create_mpu_payment' => "mpu#create"
|
||||
get 'sale/:sale_id/payment/others_payment/REDEEMREBATE' => "redeem_payments#index"
|
||||
=======
|
||||
|
||||
#---------Add Customer --------------#
|
||||
#resources :customers
|
||||
get '/:sale_id/add_customer', to: "customers#add_customer"
|
||||
get '/:customer_id/get_customer' => 'home#get_customer'
|
||||
post '/:sale_id/update_sale' , to: "home#update_sale_by_customer"#update customer id in sale table
|
||||
|
||||
>>>>>>> d65882ac5bcdce934116e65b66a8a3cb34965ba3
|
||||
end
|
||||
|
||||
#--------- Waiter/Ordering Station ------------#
|
||||
@@ -108,9 +124,7 @@ Rails.application.routes.draw do
|
||||
root "home#index"
|
||||
resources :customers
|
||||
resources :dining_queues
|
||||
get 'customers/:sale_id/assign_sale_id', to: "customers#get_sale_id", :as => "assign_sale"#get sale id with customer for crm
|
||||
post "update_booking" , to: "bookings#update_booking", as: "update_booking"#assign and cancel
|
||||
post "update_sale" , to: "home#update_sale_by_customer"#update customer id in sale table
|
||||
get '/print/:id', to: "home#print_order"#print order for crm
|
||||
|
||||
end
|
||||
@@ -162,6 +176,8 @@ Rails.application.routes.draw do
|
||||
resources :tax_profiles
|
||||
#lookups
|
||||
resources :lookups
|
||||
#orders
|
||||
resources :orders
|
||||
#cashier_terminals
|
||||
resources :cashier_terminals
|
||||
#order_job_stations
|
||||
|
||||
Reference in New Issue
Block a user