update booking controller in crm
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
class Api::BookingsController < Api::ApiController
|
class Api::BookingsController < Api::ApiController
|
||||||
skip_before_action :authenticate
|
skip_before_action :authenticate
|
||||||
|
|
||||||
#Show customer by ID
|
#Show customer by ID
|
||||||
def index
|
def index
|
||||||
@customer = Customer.find_by(params[:id])
|
@customer = Customer.find_by(params[:id])
|
||||||
@@ -10,19 +9,6 @@ class Api::BookingsController < Api::ApiController
|
|||||||
@booking = Booking.find(params[:id])
|
@booking = Booking.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_booking
|
|
||||||
booking = Booking.find(params[:booking_id])
|
|
||||||
status = booking.update_attributes(booking_status: params[:type])
|
|
||||||
|
|
||||||
if status
|
|
||||||
render json: JSON.generate({:status => true ,:type => params[:type]})
|
|
||||||
|
|
||||||
else
|
|
||||||
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# private
|
# private
|
||||||
# def Bookings_params
|
# def Bookings_params
|
||||||
# params.permit(:id, :order_id)
|
# params.permit(:id, :order_id)
|
||||||
|
|||||||
@@ -20,10 +20,10 @@
|
|||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<button id="assign" data-ref="<%= booking.id%>" data-type="complete" class="btn assign btn-primary btn-sm btn-block">ASSIGN</button>
|
<button id="assign" data-booking-ref="<%= booking.id%>" data-type="complete" class="btn assign btn-primary btn-sm btn-block">ASSIGN</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<button id="cancel" data-ref="<%= booking.id%>" data-type="cancel" class="btn btn-danger cancel btn-sm btn-block">CANCLE</button>
|
<button id="cancel" data-booking-ref="<%= booking.id%>" data-type="cancel" class="btn btn-danger cancel btn-sm btn-block">CANCLE</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -42,13 +42,15 @@ $(function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('.assign').click(function(e){
|
$('.assign').click(function(e){
|
||||||
var booking_id = $('#assign').attr('data-ref');
|
var booking_id = $('#assign').attr('data-booking-ref');
|
||||||
|
alert(booking_id);
|
||||||
var type = $('#assign').attr('data-type');
|
var type = $('#assign').attr('data-type');
|
||||||
update_booking(booking_id,type)
|
update_booking(booking_id,type)
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.cancel').click(function(e){
|
$('.cancel').click(function(e){
|
||||||
var booking_id = $('#cancel').attr('data-ref');
|
var booking_id = $('#cancel').attr('data-booking-ref');
|
||||||
|
alert(booking_id);
|
||||||
var type = $('#cancel').attr('data-type');
|
var type = $('#cancel').attr('data-type');
|
||||||
update_booking(booking_id,type)
|
update_booking(booking_id,type)
|
||||||
});
|
});
|
||||||
@@ -91,17 +93,11 @@ function show_details(url_item){
|
|||||||
function update_booking(booking_id,type) {
|
function update_booking(booking_id,type) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "api/update_booking/" ,
|
url: "crm/update_booking/" ,
|
||||||
data: {booking_id:booking_id,type:type},
|
data: {booking_id:booking_id,type:type},
|
||||||
dataType: "json",
|
// dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
if(data.status == true && data.type == "cancel")
|
|
||||||
{
|
|
||||||
alert('Booking has canceled!');
|
|
||||||
}else{
|
|
||||||
alert('Booking has completed!');
|
|
||||||
}
|
|
||||||
location.reload();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ Rails.application.routes.draw do
|
|||||||
resources :bookings, only: [:index, :show, :create, :update]
|
resources :bookings, only: [:index, :show, :create, :update]
|
||||||
resources :customers, only: [:index, :show, :create, :update]
|
resources :customers, only: [:index, :show, :create, :update]
|
||||||
|
|
||||||
post "update_booking" , to: "bookings#update_booking", as: "update_booking"
|
|
||||||
|
|
||||||
#Generating Invoice and making payments - output render @sale
|
#Generating Invoice and making payments - output render @sale
|
||||||
resources :invoices, only: [:index, :show, :create, :update, :destroy ] do
|
resources :invoices, only: [:index, :show, :create, :update, :destroy ] do
|
||||||
resources :sale_items, only:[:create, :update, :destroy]
|
resources :sale_items, only:[:create, :update, :destroy]
|
||||||
@@ -89,6 +87,7 @@ Rails.application.routes.draw do
|
|||||||
resources :customers
|
resources :customers
|
||||||
#membership
|
#membership
|
||||||
#bookings
|
#bookings
|
||||||
|
post "update_booking" , to: "bookings#update_booking", as: "update_booking"
|
||||||
#queue
|
#queue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user