diff --git a/app/controllers/transactions/bookings_controller.rb b/app/controllers/transactions/bookings_controller.rb
index 16d264af..f8a74a53 100644
--- a/app/controllers/transactions/bookings_controller.rb
+++ b/app/controllers/transactions/bookings_controller.rb
@@ -53,6 +53,19 @@ class Transactions::BookingsController < ApplicationController
end
end
+ def update_status
+ data = Booking.where("sale_id IS NULL AND booking_status='assign' AND booking_id = ?", params[:booking_id])
+ if !data.nil?
+ booking = Booking.find(params[:booking_id])
+ booking.booking_status = 'moved'
+ booking.save!
+
+ render :json => {:status => true, :message => "Update status successfully."}
+ else
+ render :json => {:status => false, :error_message => "Can't update status!"}
+ end
+ end
+
private
# Use callbacks to share common setup or constraints between actions.
def set_transactions_booking
diff --git a/app/views/transactions/bookings/show.html.erb b/app/views/transactions/bookings/show.html.erb
index a8276c60..4aae7c79 100755
--- a/app/views/transactions/bookings/show.html.erb
+++ b/app/views/transactions/bookings/show.html.erb
@@ -40,9 +40,14 @@
<%= t("views.right_panel.detail.checkout_by") %> |
<%= t("views.right_panel.detail.booking_status") %> |
<%= t("views.right_panel.detail.booking_date") %> |
- <%if (@booking.sale_id.nil?) && (current_login_employee.role == "administrator") && (!@order.nil?) %>
+ <%if current_login_employee.role == "administrator" %>
+ <%if (!@order.nil?) && (@booking.sale_id.nil?) %>
+ <% end %>
+ <%if @order.nil? && @booking.booking_status == 'assign' && (@booking.sale_id.nil?) %>
+
+ <% end %>
|
<% end %>
@@ -59,8 +64,14 @@
<%= @booking.checkout_by rescue '-' %> |
<%= @booking.booking_status %> |
<%= @booking.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> |
- <%if (@booking.sale_id.nil?) && (current_login_employee.role == "administrator") && (!@order.nil?) %>
- |
+ <%if current_login_employee.role == "administrator" %>
+ <%if (!@order.nil?) && (@booking.sale_id.nil?) %>
+ |
+ <% end %>
+ <%if @order.nil? %>
+ |
+ <% end %>
+
<% end %>
@@ -175,6 +186,35 @@
}
});
});
+
+ $("#change_booking_status").on("click", function(){
+ $('#change_booking_status').prop("disabled",true);
+ var booking_id = '<%= @booking.booking_id %>';
+ $.ajax({
+ type: "GET",
+ url: "/transactions/bookings/update_status/"+booking_id,
+ success: function (result) {
+ if (!result.status) {
+ $('#change_booking_status').prop("disabled",false);
+ swal("Opps",result.error_message,"warning");
+ }
+ else {
+ swal({
+ title: "Information",
+ text: result.message,
+ type: "success",
+ html: true,
+ closeOnConfirm: false,
+ closeOnCancel: false,
+ allowOutsideClick: false
+ }, function() {
+ // Redirect the user
+ window.location.reload();
+ });
+ }
+ }
+ });
+ });
diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb
index 04732fb3..3e4dfca0 100755
--- a/app/views/transactions/sales/show.html.erb
+++ b/app/views/transactions/sales/show.html.erb
@@ -41,21 +41,22 @@
<%= t :cashier %> |
<%= t("views.right_panel.detail.sales_status") %> |
<%= t("views.right_panel.detail.receipt_generated_at") %> |
- <% if @sale.sale_status == "completed" %>
+ <% if @sale.sale_status == "new" || @sale.sale_status == "completed" %>
<% if current_login_employee.role == "administrator" || current_login_employee.role == "manager" %>
-
- |
+
+
<% end %>
- <% elsif @sale.sale_status == "new" %>
+ <% end %>
+ <% if @sale.sale_status == "new" %>
<% if current_login_employee.role == "administrator" %>
<%if @membership.discount && @sale.customer.membership_id %>
-
-
+
+
|
<%else%>
-
-
+
+
|
<%end%>
<%end%>
diff --git a/config/routes.rb b/config/routes.rb
index 59742571..3dabf4d8 100755
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -479,6 +479,7 @@ scope "(:locale)", locale: /en|mm/ do
get "/sales/:sale_id/void" => "manual_sales#void", :as => "void"
post "sales/:sale_id/manual_void_sale", to: "manual_sales#manual_void_sale", :as => "manual_void_sale"
post "sales/:sale_id/:type/void" => "sales#overall_void"
+ get "/bookings/update_status/:booking_id" => "bookings#update_status", :default => { :format => 'json' }
end
#--------- Reports Controller Sections ------------#