Merge branch 'adminbsb_material_ui' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2017-11-07 10:32:48 +06:30
19 changed files with 309 additions and 21 deletions

View File

@@ -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();
})
})

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,82 @@
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">
<%= simple_form_for([:settings,@commission],html: { data_name: "assign_product" }) do |f| %>
<%= f.error_notification %>
<%= f.input :product_code, as: :hidden %>
<div class="card">
<div class="header">
Select Menu Items
</div>
<div class="body">
<div class="row">
<% @menu_categories.each do |category|%>
<div class="col-lg-3 col-md-3 col-sm-6">
<div class="card" style="padding-left:5px">
<div class="card-title">
<div> <h5><%= category.name %></h5></div>
<div> <button type="button" data-id="menu_items_category_<%= category.id %>" class="btn btn-info waves-effect processingitems_all" aria-label="Left Align">
<!-- <i class="fa fa-list" aria-hidden="true"></i> -->
<i class="material-icons">list</i>
</button>
<button type="button" data-id="menu_items_category_<%= category.id %>" class="processingitems_clr btn btn-info waves-effect" aria-label="Left Align">
<!-- <i class="fa fa-minus-circle" aria-hidden="true"></i> -->
<i class="material-icons">remove_circle</i>
</button></div>
</div>
<ul class="opi_ul" id="menu_items_category_<%= category.id %>">
<% category.menu_items.each do |item| %>
<% flag = false %>
<% itemsary = JSON.parse(@commission.product_code) %>
<% itemsary.each do |item_code| %>
<% if item_code == item.item_code %>
<% flag = true %>
<% end %>
<% end %>
<% if flag == true %>
<li><div class="processitems opi_default opi_selected" data-id="<%= item.item_code %>"><%= item.name %></div></li>
<% else %>
<li><div class="processitems opi_default" data-id="<%= item.item_code %>"><%= item.name %></div></li>
<% end %>
<% end %>
</ul>
</div>
</div>
<% end %>
</div>
</div>
</div>
<div class="form-actions">
<%= f.submit "Update",:class => 'btn ccc btn-primary btn-lg waves-effect' %>
</div>
<br>
<% end %>
</div>
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
<div class="card">
<div class="body">
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
<p>
1) <%= t("views.right_panel.detail.select_menu_items") %> - <%= t("views.right_panel.detail.select_txt") %> <%= t("views.right_panel.detail.menu_item_txt") %> <br>
2) <button type="button" class="btn btn-info waves-effect processingitems_all"> <i class="material-icons md-18">list </i> </button> - <%= t("views.right_panel.detail.assign_txt") %> <%= t("views.right_panel.detail.menu_item_txt") %> <br>
3) <button type="button" class="btn btn-info waves-effect processingitems_all"> <i class="material-icons md-18">remove_circle </i></button> - <%= t("views.right_panel.detail.remove_txt") %> <%= t("views.right_panel.detail.menu_item_txt") %> <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
<p>
1) <%= t("views.right_panel.button.update") %> - <%= t("views.right_panel.detail.update_btn_txt") %> <%= t("views.right_panel.detail.processing_items_txt") %> <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
<p>
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.order_queue_stations_txt") %> <br>
</p>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,6 @@
<h1>Editing Settings Order Queue Station</h1>
<%= 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 %>

View File

@@ -0,0 +1,46 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= %>">Home</a></li>
<li>Order Queue Stations</li>
<span style="float: right">
<%= link_to t("views.btn.new"),new_settings_order_queue_station_path,:class => 'btn btn-primary btn-sm' %>
</span>
</ul>
</div>
<br>
<div class="card">
<table class="table">
<thead>
<tr>
<th>Station name</th>
<th>Is active</th>
<th>Print copy</th>
<th>Printer name</th>
<th>Cut per item</th>
<th>Use alternate name</th>
<th>Created by</th>
<th></th>
</tr>
</thead>
<tbody>
<% @settings_order_queue_stations.each do |settings_order_queue_station| %>
<tr>
<td><%= link_to settings_order_queue_station.station_name, settings_order_queue_station_path(settings_order_queue_station) %></td>
<td><%= settings_order_queue_station.is_active %></td>
<td><%= settings_order_queue_station.print_copy %></td>
<td><%= settings_order_queue_station.printer_name %></td>
<td><%= settings_order_queue_station.cut_per_item %></td>
<td><%= settings_order_queue_station.use_alternate_name %></td>
<td><%= settings_order_queue_station.created_by %></td>
<td><%= 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' %></td>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@@ -0,0 +1 @@
json.array! @settings_order_queue_stations, partial: 'settings_order_queue_stations/settings_order_queue_station', as: :settings_order_queue_station

View File

@@ -0,0 +1,12 @@
<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>">Home</a></li>
<li class="breadcrumb-item"><a href="<%= settings_commissions_path %>">Commissions</a></li>
<li class="breadcrumb-item active"><%= @commission.name %></li>
<span class="float-right">
<%= link_to t('.back', :default => t("views.btn.back")), settings_commissions_path %>
</span>
</ol>
</div>
<br>
<%= render 'form', settings_commission: @commission %>

View File

@@ -0,0 +1,50 @@
<p id="notice"><%= notice %></p>
<p>
<strong>Station name:</strong>
<%= @settings_order_queue_station.station_name %>
</p>
<p>
<strong>Is active:</strong>
<%= @settings_order_queue_station.is_active %>
</p>
<p>
<strong>Processing items:</strong>
<%= @settings_order_queue_station.processing_items %>
</p>
<p>
<strong>Print copy:</strong>
<%= @settings_order_queue_station.print_copy %>
</p>
<p>
<strong>Printer name:</strong>
<%= @settings_order_queue_station.printer_name %>
</p>
<p>
<strong>Font size:</strong>
<%= @settings_order_queue_station.font_size %>
</p>
<p>
<strong>Cut per item:</strong>
<%= @settings_order_queue_station.cut_per_item %>
</p>
<p>
<strong>Use alternate name:</strong>
<%= @settings_order_queue_station.use_alternate_name %>
</p>
<p>
<strong>Created by:</strong>
<%= @settings_order_queue_station.created_by %>
</p>
<%= 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 %>

View File

@@ -0,0 +1 @@
json.partial! "settings_order_queue_stations/settings_order_queue_station", settings_order_queue_station: @settings_order_queue_station

View File

@@ -14,7 +14,7 @@
<br/>
<%= 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'} %>
<br/>
<%= f.label :joined_date %><br/>

View File

@@ -6,8 +6,9 @@
<%= f.error_notification %>
<div class="form-inputs">
<%= f.label :product_code, 'Product' %>
<%= f.collection_select :product_code, MenuItem.all.order('name asc'), :id, :name, {prompt: 'Select a Product'}, {class: 'form-control'} %><br/>
<!--<%= f.label :product_code, 'Product' %>
<%= f.collection_select :product_code, MenuItem.all.order('name asc'), :id, :name, {prompt: 'Select a Product'}, {class: 'form-control'} %><br/>-->
<%= 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 => "" %>

View File

@@ -28,12 +28,14 @@
<tbody>
<% @commissions.each do |commission| %>
<tr>
<td><%= commission.menu_item.name rescue '-' %></td>
<td><%= commission.name rescue '-' %></td>
<td><%= commission.commission_type rescue '-' %></td>
<td><%= commission.amount rescue '-' %></td>
<td><%= commission.is_active rescue '-' %></td>
<td><%= 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" %></td>
<%= 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' %>
</td>
</tr>
<% end %>
</tbody>

View File

@@ -18,7 +18,7 @@
<tbody>
<tr>
<th style="width:20%"><%= t("views.right_panel.detail.product") %> <%= t("views.right_panel.detail.name_txt2") %></th>
<td><%= @commission.menu_item.name rescue '-' %></td>
<td><%= @commission.name rescue '-' %></td>
</tr>
<tr>
<th style="width:20%"><%= t("views.right_panel.detail.amount") %></th>

View File

@@ -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'

View File

@@ -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

View File

@@ -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

View File

@@ -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"})