diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index d2a22aef..72ff4733 100755 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -404,7 +404,9 @@ $(document).on('turbolinks:load', function() { success: function(result){ // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } location.reload(); @@ -428,7 +430,9 @@ $(document).on('turbolinks:load', function() { success: function(result){ // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } location.reload(); } diff --git a/app/assets/javascripts/custom.js b/app/assets/javascripts/custom.js index f975ad07..3843f297 100644 --- a/app/assets/javascripts/custom.js +++ b/app/assets/javascripts/custom.js @@ -111,6 +111,26 @@ $(document).ready(function() { railBorderRadius: '0', touchScrollStep : 50 }); + + $('#process-reservation-slimscroll').slimScroll({ + height: height-$('#process-reservation-slimscroll').attr('data-height'), + size: '5px', + color: 'rgba(0,0,0,0.5)', + alwaysVisible: false, + borderRadius: '0', + railBorderRadius: '0', + touchScrollStep : 50 + }); + + $('#reservation-info-slimscroll').slimScroll({ + height: height-$('#reservation-info-slimscroll').attr('data-height'), + size: '5px', + color: 'rgba(0,0,0,0.5)', + alwaysVisible: false, + borderRadius: '0', + railBorderRadius: '0', + touchScrollStep : 50 + }); // $('.delete').click(function(){ // var method = $(this).attr('data-method'); // var url = $(this).attr('data-ref'); diff --git a/app/assets/javascripts/reservation.js b/app/assets/javascripts/reservation.js index e41dda14..0dea213e 100644 --- a/app/assets/javascripts/reservation.js +++ b/app/assets/javascripts/reservation.js @@ -1,6 +1,7 @@ //= require custom.js $(function(){ + $(".room_type").hide(); /*new customer UI func:*/ //Initialize tooltips $('.nav-tabs > li a[title]').tooltip(); @@ -21,6 +22,7 @@ $(function(){ nextTab($active); $('.wizard .nav-tabs li.active .connecting-line').css({"border-bottom-left-radius": 0, "border-top-left-radius": 0}); }); + $(".prev-step").click(function (e) { var $active = $('.wizard .nav-tabs li a.active'); @@ -28,6 +30,28 @@ $(function(){ }); /*new customer UI func:*/ + + $(".reservation_type").on("click", function(){ + if($(this).val() == "Dine-in"){ + $(".dining_type").show(); + $(".room_type").hide(); + }else{ + $(".dining_type").hide(); + $(".room_type").show(); + } + }); + + $(".number_limit").on("click", function(){ + if(parseInt($(this).val()) <= 0){ + if($(this).attr("data-type") == "room"){ + $("#room_count").val(1); + }else if($(this).attr("data-type") == "adult"){ + $("#adult_count").val(1); + }else{ + $("#child_count").val(1); + } + } + }); }); /*customer UI tab btn*/ diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 0eee0400..94f4f1ea 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -76,7 +76,6 @@ class Origami::CustomersController < BaseOrigamiController filter = params[:filter] if filter.nil? - puts params[:page] @crm_customers = Customer.order("customer_id") #.page(params[:page]) #@products = Product.order("name").page(params[:page]).per(5) else diff --git a/app/controllers/origami/reservation_controller.rb b/app/controllers/origami/reservation_controller.rb index 6b1e3aa5..91ce359f 100644 --- a/app/controllers/origami/reservation_controller.rb +++ b/app/controllers/origami/reservation_controller.rb @@ -1,6 +1,45 @@ class Origami::ReservationController < BaseOrigamiController def index - + @reservations = Reservation.all end + + def show + end + + def new + end + + def edit + end + + def create + + end + + def update + + end + + # DELETE /crm/customers/1 + # DELETE /crm/customers/1.json + def destroy + @reservation.destroy + respond_to do |format| + format.html { redirect_to origami_reservation_url, notice: 'Reservation was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_origami_reservation + @reservation = Reservation.find(params[:reservation_id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def customer_params + + params.require(:reservation).permit(:reservation_id) + end end diff --git a/app/models/reservation.rb b/app/models/reservation.rb new file mode 100644 index 00000000..4e5ff37a --- /dev/null +++ b/app/models/reservation.rb @@ -0,0 +1,15 @@ +class Reservation < ApplicationRecord + self.primary_key = "reservation_id" + + #primary key - need to be unique generated for multiple shops + before_create :generate_custom_id + + has_many :reservation_items + + scope :active, -> { where("created_at BETWEEN '#{DateTime.now.utc.beginning_of_day}' AND '#{DateTime.now.utc.end_of_day}'") } + + private + def generate_custom_id + self.order_reservation_id = SeedGenerator.generate_id(self.class.name, "RS") + end +end diff --git a/app/models/reservation_item.rb b/app/models/reservation_item.rb new file mode 100644 index 00000000..19e28b82 --- /dev/null +++ b/app/models/reservation_item.rb @@ -0,0 +1,13 @@ +class ReservationItem < ApplicationRecord + self.primary_key = "reservation_items_id" + + #primary key - need to be unique + before_create :generate_custom_id + + belongs_to :reservation, autosave: true + + private + def generate_custom_id + self.reservation_items_id = SeedGenerator.generate_id(self.class.name, "RSI") + end +end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 42ba0d65..eca1a7ef 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -958,7 +958,9 @@ // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } location.reload(); } @@ -1011,9 +1013,11 @@ if((receipt_no!=undefined) && (receipt_no!="")) createReceiptNoInFirstBillData(receipt_no,type); // For Server Print - from jade - if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); - } + if ($("#server_mode").val() == "cloud") { + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } + } location.reload(); } }); @@ -1214,7 +1218,9 @@ success: function (result) { // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } window.location.href = '/origami/'; } @@ -1321,7 +1327,9 @@ console.log(result) // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } window.location.href = '/origami/'; } diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index a6e878c5..4d3f430c 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -1146,7 +1146,9 @@ var trans_flag = <%= @trans_flag %>; success:function(result){ // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } if (pdf_view ==1) { @@ -1439,7 +1441,9 @@ var trans_flag = <%= @trans_flag %>; }, function () { // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } var flag = localStorage.getItem("trans_flag"); if((flag!=null) && (flag != "true")){ @@ -1482,7 +1486,9 @@ var trans_flag = <%= @trans_flag %>; customer_display_view(null,"reload"); // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } var flag = localStorage.getItem("trans_flag"); if((flag!=null) && (flag != "true")){ @@ -1522,7 +1528,9 @@ var trans_flag = <%= @trans_flag %>; // console.log(result) // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } var flag = localStorage.getItem("trans_flag"); if((flag!=null) && (flag != "true")){ diff --git a/app/views/origami/pending_order/completed_sale.html.erb b/app/views/origami/pending_order/completed_sale.html.erb index bc4719f9..f2d66b37 100644 --- a/app/views/origami/pending_order/completed_sale.html.erb +++ b/app/views/origami/pending_order/completed_sale.html.erb @@ -324,7 +324,9 @@ $(document).ready(function(){ url: ajax_url, success: function (result) { if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } location.reload(); } @@ -433,7 +435,9 @@ function check_emp_access_code(access_code,type) { url: ajax_url, success: function (result) { if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } location.reload(); } diff --git a/app/views/origami/reservation/index.html.erb b/app/views/origami/reservation/index.html.erb index 720f9d3e..1374983b 100644 --- a/app/views/origami/reservation/index.html.erb +++ b/app/views/origami/reservation/index.html.erb @@ -5,7 +5,7 @@
-
<%= t :make_reservation %>
+
<%= t :make_reservation %>
-
-
-
- -
-
-
-
-
+
+
+
+
+ +
+
+ +
+
diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 84ea9086..b7df32a0 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -1052,7 +1052,9 @@ $("#first_bill").on('click', function(){ createReceiptNoInFirstBillData(receipt_no,""); // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } location.reload(); } @@ -1090,7 +1092,9 @@ $(".choose_payment").on('click', function () { // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } location.reload(); @@ -1317,7 +1321,9 @@ $('#add_invoice').on('click',function(){ success: function (result) { // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } window.location.href = '/origami/'; } @@ -1406,7 +1412,9 @@ $('#add_invoice').on('click',function(){ console.log(result) // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } window.location.href = '/origami/'; } diff --git a/app/views/origami/sales/show.html.erb b/app/views/origami/sales/show.html.erb index 2d16d3bb..bfe1f0a9 100755 --- a/app/views/origami/sales/show.html.erb +++ b/app/views/origami/sales/show.html.erb @@ -435,7 +435,9 @@ $('#reprint').on('click', function () { url: ajax_url, success: function (result) { if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } location.reload(); } @@ -536,7 +538,9 @@ $(document).on('click', '.access_modal', function(event){ success: function (result) { // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } location.reload(); } diff --git a/app/views/origami/table_invoices/show.html.erb b/app/views/origami/table_invoices/show.html.erb index a95c5398..84efbc66 100644 --- a/app/views/origami/table_invoices/show.html.erb +++ b/app/views/origami/table_invoices/show.html.erb @@ -370,7 +370,9 @@ $(document).ready(function(){ // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } location.reload(); } @@ -403,7 +405,9 @@ $(document).ready(function(){ createReceiptNoInFirstBillData(receipt_no,type); // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } location.reload(); } @@ -475,7 +479,9 @@ $('#void').on('click',function () { success: function (result) { // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } window.location.href = '/origami'; } @@ -512,7 +518,9 @@ $('#foc').click(function() { }, function () { // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } window.location.href = '/origami'; }); diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index 2bb45f4e..04732fb3 100755 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -406,7 +406,9 @@ success: function (result) { // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } window.location.href = '/transactions/sales/'; } diff --git a/config/routes.rb b/config/routes.rb index 936266de..f9a61b63 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -326,7 +326,7 @@ scope "(:locale)", locale: /en|mm/ do # get 'sale/:sale_id/:type/credit_payment/others_payment/GiftVoucher' => "gift_voucher#index" #------------- Start Reservation -------------------# - get '/reservation' => "reservation#index" + resources :reservation #------------- End Reservation -------------------# end diff --git a/db/migrate/20180928052742_create_reservations.rb b/db/migrate/20180928052742_create_reservations.rb new file mode 100644 index 00000000..637c4ba0 --- /dev/null +++ b/db/migrate/20180928052742_create_reservations.rb @@ -0,0 +1,24 @@ +class CreateReservations < ActiveRecord::Migration[5.1] + def change + create_table :reservations, :id => false do |t| + t.string :reservation_id, :limit => 16, :primary_key => true + t.string :source, :null => false, :default => "Cashier" + t.string :reservation_type, :null => false + t.string :customer_id, :null => false + t.datetime :checkin_datetime, :null => false + t.datetime :checkout_datetime + t.json :reservation_info + t.string :remark + t.string :status, :null => false, :default => "new" + t.datetime :action_at, :null => false + t.string :action_by, :null => false + t.datetime :modify_at + t.string :modify_by + t.timestamps + end + end + + def down + drop_table :reservations + end +end diff --git a/db/migrate/20180928074338_create_reservation_items.rb b/db/migrate/20180928074338_create_reservation_items.rb new file mode 100644 index 00000000..54ee6097 --- /dev/null +++ b/db/migrate/20180928074338_create_reservation_items.rb @@ -0,0 +1,26 @@ +class CreateReservationItems < ActiveRecord::Migration[5.1] + def change + create_table :reservation_items, :id => false do |t| + t.string :reservation_items_id, :limit => 16, :primary_key => true + t.string :reservation_id, foreign_key: true, :null => false, :limit => 16 + t.string :item_status, :null => false, :default => "new" + t.string :item_code, :null => false + t.string :item_instance_code + t.string :item_name, :null => false + t.string :alt_name, :null => false + t.json :set_menu_items + t.integer :account_id, :limit => 8, :null => false, :default => 1 + t.decimal :qty, :precision => 10, :scale => 2, :null => false, :default => 0.00 + t.decimal :unit_price, :precision => 10, :scale => 2, :null => false, :default => 0.00 + t.decimal :price, :precision => 10, :scale => 2, :null => false, :default => 0.00 + t.string :remark + t.string :options + t.boolean :taxable, :null => false, :default => true + t.timestamps + end + end + + def down + drop_table :reservation_items + end +end