diff --git a/Gemfile b/Gemfile index af709905..7dfb53f9 100755 --- a/Gemfile +++ b/Gemfile @@ -18,7 +18,7 @@ gem 'mysql2', '>= 0.3.18', '< 0.5' # redis server for cable -# gem 'redis', '~> 3.0' +gem 'redis', '~> 3.0' # Use Puma as the app server gem 'puma', '~> 3.0' diff --git a/Gemfile.lock b/Gemfile.lock index d7b3ea9d..9583188f 100755 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -170,7 +170,7 @@ GEM rb-fsevent (0.10.2) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) - redis (4.0.1) + redis (3.3.5) rspec-core (3.7.0) rspec-support (~> 3.7.0) rspec-expectations (3.7.0) @@ -284,6 +284,7 @@ DEPENDENCIES puma (~> 3.0) rack-cors rails (~> 5.1.0) + redis (~> 3.0) rspec-rails (~> 3.5) sass-rails (~> 5.0) schema_to_scaffold diff --git a/app/assets/javascripts/settings/processing_items.js b/app/assets/javascripts/settings/processing_items.js index 73d8f66a..1dc5e97f 100755 --- a/app/assets/javascripts/settings/processing_items.js +++ b/app/assets/javascripts/settings/processing_items.js @@ -40,7 +40,12 @@ $(document).ready(function() { items.push($(value).attr("data-id")); }); - $("#order_queue_station_processing_items").val(JSON.stringify(items)); - //$(this).submit(); + + if ($(this).attr('data_name')=="assign_product") { + $("#commission_product_code").val(JSON.stringify(items)); + }else{ + $("#order_queue_station_processing_items").val(JSON.stringify(items)); + } + $(this).submit(); }) }) diff --git a/app/controllers/settings/assign_products_controller.rb b/app/controllers/settings/assign_products_controller.rb new file mode 100644 index 00000000..3b2e0058 --- /dev/null +++ b/app/controllers/settings/assign_products_controller.rb @@ -0,0 +1,62 @@ +class Settings::AssignProductsController < ApplicationController + before_action :set_settings_commission, only: [:show, :edit, :new, :update, :destroy] + + # GET /settings/commissions + # GET /settings/commissions.json + def index + @settings_commissions = Commission.all + end + + # GET /settings/commissions/1 + # GET /settings/commissions/1.json + def show + end + + # GET /settings/commissions/new + def new + #Load list of categories that has product assigned. + @menu_categories = MenuCategory.where("id in (Select distinct menu_category_id from menu_items where menu_category_id is not null)") + + end + + # GET /settings/commissions/1/edit + def edit + end + + # POST /settings/commissions + # POST /settings/commissions.json + def create + + end + + # PATCH/PUT /settings/commissions/1 + # PATCH/PUT /settings/commissions/1.json + def update + respond_to do |format| + if @settings_commission.update(settings_commission_params) + format.html { redirect_to order_queue_station_path(@settings_commission), notice: 'Commission assign was successfully updated.' } + format.json { render :show, status: :ok, location: @settings_commission } + else + format.html { render :edit } + format.json { render json: @settings_commission.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /settings/commissions/1 + # DELETE /settings/commissions/1.json + def destroy + + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_settings_commission + @commission = Commission.find(params[:commission_id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def settings_commission_params + params.require(:commission).permit(:product_type,:name, :product_code, :amount, :commission_type, :is_active) + end +end diff --git a/app/controllers/settings/commissions_controller.rb b/app/controllers/settings/commissions_controller.rb index 3973e623..1138fe96 100755 --- a/app/controllers/settings/commissions_controller.rb +++ b/app/controllers/settings/commissions_controller.rb @@ -29,6 +29,7 @@ class Settings::CommissionsController < ApplicationController def create @commission = Commission.new(commission_params) @commission.product_type = 'menu_item' + @commission.product_code = "[]" respond_to do |format| if @commission.save @@ -45,6 +46,8 @@ class Settings::CommissionsController < ApplicationController # PATCH/PUT /commissions/1.json def update respond_to do |format| + puts commission_params.to_json + puts "updddddddddddddddddddddd" if @commission.update(commission_params) format.html {redirect_to settings_commission_path(@commission), notice: 'Commission was successfully updated.'} format.json {render :show, status: :ok, location: @commission} @@ -73,6 +76,6 @@ class Settings::CommissionsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def commission_params - params.require(:commission).permit(:product_type, :product_code, :amount, :commission_type, :is_active) + params.require(:commission).permit(:product_type,:name, :product_code, :amount, :commission_type, :is_active) end end diff --git a/app/models/commission.rb b/app/models/commission.rb index 84771e9f..e331eb59 100755 --- a/app/models/commission.rb +++ b/app/models/commission.rb @@ -9,7 +9,7 @@ class Commission < ApplicationRecord has_many :product_commissions # validations - validates_presence_of :commission_type, :amount + validates_presence_of :name, :commission_type, :amount private def generate_custom_id diff --git a/app/views/settings/assign_products/_form.html.erb b/app/views/settings/assign_products/_form.html.erb new file mode 100755 index 00000000..98c60104 --- /dev/null +++ b/app/views/settings/assign_products/_form.html.erb @@ -0,0 +1,82 @@ +
+
+ <%= simple_form_for([:settings,@commission],html: { data_name: "assign_product" }) do |f| %> + <%= f.error_notification %> + <%= f.input :product_code, as: :hidden %> + +
+
+ Select Menu Items +
+
+
+ <% @menu_categories.each do |category|%> + +
+
+
+
<%= category.name %>
+ + +
+
+ +
+ +
+
+ <% end %> +
+
+
+ + +
+ <%= f.submit "Update",:class => 'btn ccc btn-primary btn-lg waves-effect' %> +
+
+ <% end %> +
+
+
+
+
view_headline <%= t("views.right_panel.header.page_detail") %>
+

+ 1) <%= t("views.right_panel.detail.select_menu_items") %> - <%= t("views.right_panel.detail.select_txt") %> <%= t("views.right_panel.detail.menu_item_txt") %>
+ 2) - <%= t("views.right_panel.detail.assign_txt") %> <%= t("views.right_panel.detail.menu_item_txt") %>
+ 3) - <%= t("views.right_panel.detail.remove_txt") %> <%= t("views.right_panel.detail.menu_item_txt") %>
+

+
list <%= t("views.right_panel.header.button_lists") %>
+

+ 1) <%= t("views.right_panel.button.update") %> - <%= t("views.right_panel.detail.update_btn_txt") %> <%= t("views.right_panel.detail.processing_items_txt") %>
+

+
list <%= t("views.right_panel.header.link_lists") %>
+

+ 1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %>
+ 2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.order_queue_stations_txt") %>
+

+
+
+
+
\ No newline at end of file diff --git a/app/views/settings/assign_products/edit.html.erb b/app/views/settings/assign_products/edit.html.erb new file mode 100755 index 00000000..d1039cb8 --- /dev/null +++ b/app/views/settings/assign_products/edit.html.erb @@ -0,0 +1,6 @@ +

Editing Settings Order Queue Station

+ +<%= render 'form', settings_order_queue_station: @settings_order_queue_station %> + +<%= link_to t("views.btn.show"), @settings_order_queue_station %> | +<%= link_to t('.new', :default => t("views.btn.new")), settings_order_queue_stations_path %> diff --git a/app/views/settings/assign_products/index.html.erb b/app/views/settings/assign_products/index.html.erb new file mode 100755 index 00000000..8ae85b2c --- /dev/null +++ b/app/views/settings/assign_products/index.html.erb @@ -0,0 +1,46 @@ + + + + +
+
+ + + + + + + + + + + + + + + + <% @settings_order_queue_stations.each do |settings_order_queue_station| %> + + + + + + + + + + + <% end %> + +
Station nameIs activePrint copyPrinter nameCut per itemUse alternate nameCreated by
<%= link_to settings_order_queue_station.station_name, settings_order_queue_station_path(settings_order_queue_station) %><%= settings_order_queue_station.is_active %><%= settings_order_queue_station.print_copy %><%= settings_order_queue_station.printer_name %><%= settings_order_queue_station.cut_per_item %><%= settings_order_queue_station.use_alternate_name %><%= settings_order_queue_station.created_by %><%= link_to 'Assign Processing Items', settings_order_queue_station_path(settings_order_queue_station),:class => 'btn btn-success btn-lg waves-effect' %> + <%= link_to t("views.btn.edit"), edit_settings_order_queue_station_path(settings_order_queue_station),:class => 'btn btn-info btn-lg waves-effect' %>
+ +
diff --git a/app/views/settings/assign_products/index.json.jbuilder b/app/views/settings/assign_products/index.json.jbuilder new file mode 100755 index 00000000..4f27abb6 --- /dev/null +++ b/app/views/settings/assign_products/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @settings_order_queue_stations, partial: 'settings_order_queue_stations/settings_order_queue_station', as: :settings_order_queue_station diff --git a/app/views/settings/assign_products/new.html.erb b/app/views/settings/assign_products/new.html.erb new file mode 100755 index 00000000..2598af76 --- /dev/null +++ b/app/views/settings/assign_products/new.html.erb @@ -0,0 +1,12 @@ + +
+ <%= render 'form', settings_commission: @commission %> \ No newline at end of file diff --git a/app/views/settings/assign_products/show.html.erb b/app/views/settings/assign_products/show.html.erb new file mode 100755 index 00000000..871a0e8d --- /dev/null +++ b/app/views/settings/assign_products/show.html.erb @@ -0,0 +1,50 @@ +

<%= notice %>

+ +

+ Station name: + <%= @settings_order_queue_station.station_name %> +

+ +

+ Is active: + <%= @settings_order_queue_station.is_active %> +

+ +

+ Processing items: + <%= @settings_order_queue_station.processing_items %> +

+ +

+ Print copy: + <%= @settings_order_queue_station.print_copy %> +

+ +

+ Printer name: + <%= @settings_order_queue_station.printer_name %> +

+ +

+ Font size: + <%= @settings_order_queue_station.font_size %> +

+ +

+ Cut per item: + <%= @settings_order_queue_station.cut_per_item %> +

+ +

+ Use alternate name: + <%= @settings_order_queue_station.use_alternate_name %> +

+ +

+ Created by: + <%= @settings_order_queue_station.created_by %> +

+ +<%= link_to t("views.btn.edit"), edit_settings_order_queue_station_path(@settings_order_queue_station) %> | <%= link_to t("views.btn.delete"), settings_order_queue_station_path(@settings_order_queue_station), method: :delete, data: { confirm: 'Are you sure?' } %> | + +<%= link_to t('.new', :default => t("views.btn.new")), settings_order_queue_stations_path %> diff --git a/app/views/settings/assign_products/show.json.jbuilder b/app/views/settings/assign_products/show.json.jbuilder new file mode 100755 index 00000000..ac16b11a --- /dev/null +++ b/app/views/settings/assign_products/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "settings_order_queue_stations/settings_order_queue_station", settings_order_queue_station: @settings_order_queue_station diff --git a/app/views/settings/commissioners/_form.html.erb b/app/views/settings/commissioners/_form.html.erb index 30be6ae5..6c007320 100755 --- a/app/views/settings/commissioners/_form.html.erb +++ b/app/views/settings/commissioners/_form.html.erb @@ -14,7 +14,7 @@
<%= f.label :commission_id, 'Commission'%> - <%= f.select :commission_id, Commission.all.map {|l| [l.menu_item.name, l.id]}, { :include_blank => 'Choose Commission Product', :selected => ''}, {class: 'form-control'} %> + <%= f.select :commission_id, Commission.all.map {|l| [l.name, l.id]}, { :include_blank => 'Choose Commission Product', :selected => ''}, {class: 'form-control'} %>
<%= f.label :joined_date %>
diff --git a/app/views/settings/commissions/_form.html.erb b/app/views/settings/commissions/_form.html.erb index d48d0e8d..75bd3e70 100755 --- a/app/views/settings/commissions/_form.html.erb +++ b/app/views/settings/commissions/_form.html.erb @@ -6,8 +6,9 @@ <%= f.error_notification %>
- <%= f.label :product_code, 'Product' %> - <%= f.collection_select :product_code, MenuItem.all.order('name asc'), :id, :name, {prompt: 'Select a Product'}, {class: 'form-control'} %>
+ + <%= f.input :name %> <%= f.input :commission_type, :collection => ['Percentage','Net Amount'], prompt: 'Select Commission Type', class: 'form-control' %> <%= f.input :amount %> <%= f.input :is_active,:class => "filled-in" ,:id => "" %> diff --git a/app/views/settings/commissions/index.html.erb b/app/views/settings/commissions/index.html.erb index 4c1a4b44..12450e87 100755 --- a/app/views/settings/commissions/index.html.erb +++ b/app/views/settings/commissions/index.html.erb @@ -28,12 +28,14 @@ <% @commissions.each do |commission| %> - <%= commission.menu_item.name rescue '-' %> + <%= commission.name rescue '-' %> <%= commission.commission_type rescue '-' %> <%= commission.amount rescue '-' %> <%= commission.is_active rescue '-' %> <%= link_to t("views.btn.show"), settings_commission_path(commission), :class => "btn btn-info btn-sm waves-effect" %> - <%= link_to t("views.btn.edit"), edit_settings_commission_path(commission), :class => "btn btn-info btn-sm waves-effect" %> + <%= link_to t("views.btn.edit"), edit_settings_commission_path(commission), :class => "btn btn-info btn-sm waves-effect" %> + <%= link_to 'Assign Product', new_settings_commission_assign_product_path(commission),:class => 'btn btn-success btn-sm waves-effect' %> + <% end %> diff --git a/app/views/settings/commissions/show.html.erb b/app/views/settings/commissions/show.html.erb index 00157854..627b61f5 100755 --- a/app/views/settings/commissions/show.html.erb +++ b/app/views/settings/commissions/show.html.erb @@ -18,7 +18,7 @@ <%= t("views.right_panel.detail.product") %> <%= t("views.right_panel.detail.name_txt2") %> - <%= @commission.menu_item.name rescue '-' %> + <%= @commission.name rescue '-' %> <%= t("views.right_panel.detail.amount") %> diff --git a/config/routes.rb b/config/routes.rb index b7ab10bf..e02a0436 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -312,7 +312,10 @@ scope "(:locale)", locale: /en|mm/ do get '/find_parent_item' => 'promotions#find_parent_item', as:'find_parent_item' # commission - resources :commissions + #commissions + resources :commissions do + resources :assign_products, :only => [:new, :create] + end resources :commissioners get '/get_transactions_by_commissioner' => 'commissioners#get_transaction_by_commissioner', as:'get_transaction_by_commissioner' diff --git a/db/migrate/20170825093252_createss_commissions.rb b/db/migrate/20170825093252_createss_commissions.rb new file mode 100755 index 00000000..bfa1c6ed --- /dev/null +++ b/db/migrate/20170825093252_createss_commissions.rb @@ -0,0 +1,15 @@ +class CreateCommissions < ActiveRecord::Migration[5.1] + # rake db:migrate:down VERSION=20170825093252 + def change + create_table :commissions, id: false do |t| + t.string :commission_id, limit: 16, primary_key: true # custom primary key + t.string :name + t.string :product_type + t.json :product_code + t.string :commission_type + t.integer :amount + t.boolean :is_active, default: true + t.timestamps + end + end +end diff --git a/db/migrate/20170825093252_create_commissions.rb b/db/migrate/20171106102000_create_commissions.rb old mode 100755 new mode 100644 similarity index 89% rename from db/migrate/20170825093252_create_commissions.rb rename to db/migrate/20171106102000_create_commissions.rb index 8c344fbc..8f92d526 --- a/db/migrate/20170825093252_create_commissions.rb +++ b/db/migrate/20171106102000_create_commissions.rb @@ -3,9 +3,9 @@ class CreateCommissions < ActiveRecord::Migration[5.1] def change create_table :commissions, id: false do |t| t.string :commission_id, limit: 16, primary_key: true # custom primary key - + t.string :name t.string :product_type - t.string :product_code + t.json :product_code t.string :commission_type t.integer :amount t.boolean :is_active, default: true @@ -13,3 +13,4 @@ class CreateCommissions < ActiveRecord::Migration[5.1] end end end + diff --git a/db/seeds.rb b/db/seeds.rb index 0da65820..a831d511 100755 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -167,16 +167,14 @@ admin_employee = Employee.create({name: "Waiter", role: "waiter", password: "111 admin_employee = Employee.create({name: "Waiter 2", role: "waiter", password: "22222", emp_id:"222", created_by: "SYSTEM DEFAULT"}) admin_employee = Employee.create({name: "Cashier", role: "cashier", password: "33333", emp_id:"333", created_by: "SYSTEM DEFAULT"}) -order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) -order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) -request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) -close_cashier_printer=PrintSetting.create({name: "Close Cashier", unique_code: "CloseCashierPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) -crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) -queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) +order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5",font:""}) +order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5",font:""}) +request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5",font:""}) +close_cashier_printer=PrintSetting.create({name: "Close Cashier", unique_code: "CloseCashierPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5",font:""}) +crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5",font:""}) +queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5",font:""}) cashier_terminal = CashierTerminal.create({name:"Terminal 1"}) -cashier_terminal2 = CashierTerminal.create({name:"Terminal 2"}) -cashier_terminal3 = CashierTerminal.create({name:"Terminal 3"}) zone = Zone.create({id:1, name: "H1", is_active:true, created_by: "SYSTEM DEFAULT"}) table = Table.create({name:"61", zone: zone, status:"available", seater: 2 , order_by:1, created_by:"SYSTEM DEFAULT"})