From 1af178fecba344792d0851898607a570a93a3202 Mon Sep 17 00:00:00 2001 From: Zin Lin Phyo Date: Tue, 22 Aug 2017 09:51:08 +0630 Subject: [PATCH 1/2] update ui commission & commissioner --- .idea/.generators | 2 +- .idea/sxrestaurant.iml | 1 + .idea/workspace.xml | 363 ++++++++++-------- .../origami/commissions_controller.rb | 2 +- .../origami/commissioners/_form.html.erb | 28 +- app/views/origami/commissioners/edit.html.erb | 4 +- .../origami/commissioners/index.html.erb | 2 +- app/views/origami/commissioners/new.html.erb | 4 +- app/views/origami/commissioners/show.html.erb | 54 ++- app/views/origami/commissions/_form.html.erb | 12 +- app/views/origami/commissions/edit.html.erb | 6 +- app/views/origami/commissions/index.html.erb | 2 +- app/views/origami/commissions/new.html.erb | 18 +- app/views/origami/commissions/show.html.erb | 56 +-- 14 files changed, 315 insertions(+), 239 deletions(-) diff --git a/.idea/.generators b/.idea/.generators index 8893e668..98526fe7 100644 --- a/.idea/.generators +++ b/.idea/.generators @@ -5,4 +5,4 @@ You are allowed to: 2. Remove generators 3. Add installed generators To add new installed generators automatically delete this file and reload the project. ---> +--> diff --git a/.idea/sxrestaurant.iml b/.idea/sxrestaurant.iml index f88608e6..e1c0cfaa 100644 --- a/.idea/sxrestaurant.iml +++ b/.idea/sxrestaurant.iml @@ -181,6 +181,7 @@ + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b41a365d..fdfb3e9b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,26 +2,20 @@ - - - - - - - - - - - - - - - - - - + + - + + + + + + + + + + + @@ -38,21 +32,11 @@ - - + + - - - - - - - - - - - - + + @@ -61,28 +45,38 @@ - - + + - - - - - - - - - - - + - - + + + + + + + + + + + + + + + + + + + + + + @@ -91,48 +85,48 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -179,9 +173,16 @@ @@ -192,10 +193,10 @@ DEFINITION_ORDER - @@ -215,22 +216,8 @@ - - - - - - - - - - - + @@ -347,6 +334,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -784,22 +811,23 @@ - + + - - + - + - + @@ -826,10 +854,6 @@ - - - - @@ -867,14 +891,6 @@ - - - - - - - - @@ -925,6 +941,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -945,90 +984,106 @@ - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - + - - + + - + + + + + + + + + - + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/controllers/origami/commissions_controller.rb b/app/controllers/origami/commissions_controller.rb index f0f07d2a..fdd1bf73 100644 --- a/app/controllers/origami/commissions_controller.rb +++ b/app/controllers/origami/commissions_controller.rb @@ -1,5 +1,5 @@ class Origami::CommissionsController < BaseOrigamiController - # before_action :set_commission, only: [:show, :edit, :update, :destroy] + before_action :set_commission, only: [:show, :edit, :update, :destroy] # GET /commissions # GET /commissions.json diff --git a/app/views/origami/commissioners/_form.html.erb b/app/views/origami/commissioners/_form.html.erb index 6386b0f7..4c2a17f8 100644 --- a/app/views/origami/commissioners/_form.html.erb +++ b/app/views/origami/commissioners/_form.html.erb @@ -1,14 +1,18 @@ -<%= simple_form_for([:origami,@commissioner]) do |f| %> - <%= f.error_notification %> +
+ <%= simple_form_for([:origami, @commissioner]) do |f| %> + <%= f.error_notification %> -
- <%= f.input :name %> - <%= f.collection_select :emp_id, Employee.all.order('name asc'), :emp_id, :name, {prompt: "Select an Employee"}, {class: "form-control"} %> - <%= f.input :commission_type %> - -
+
+ <%= f.input :name %> + <%= f.label :emp_id %> + <%= f.collection_select :emp_id, Employee.all.order('name asc'), :emp_id, :name, {prompt: "Select an Employee"}, {class: "form-control"} %>
+ <%= f.input :commission_type %> + +
-
- <%= f.button :submit %> -
-<% end %> +
+ <%= link_to 'Back', origami_commissioners_path, class: 'btn btn-success' %> + <%= f.button :submit, class: 'btn btn-info' %> +
+ <% end %> +
diff --git a/app/views/origami/commissioners/edit.html.erb b/app/views/origami/commissioners/edit.html.erb index 0a2edab4..ea5c44cd 100644 --- a/app/views/origami/commissioners/edit.html.erb +++ b/app/views/origami/commissioners/edit.html.erb @@ -1,10 +1,10 @@
<%= render 'form', commissioner: @commissioner %> -
\ No newline at end of file + diff --git a/app/views/origami/commissioners/index.html.erb b/app/views/origami/commissioners/index.html.erb index e7230fd9..baadb225 100644 --- a/app/views/origami/commissioners/index.html.erb +++ b/app/views/origami/commissioners/index.html.erb @@ -1,6 +1,6 @@ diff --git a/app/views/origami/commissioners/show.html.erb b/app/views/origami/commissioners/show.html.erb index 579c9c0d..83d5442b 100644 --- a/app/views/origami/commissioners/show.html.erb +++ b/app/views/origami/commissioners/show.html.erb @@ -1,11 +1,11 @@
@@ -14,25 +14,37 @@ - Name<%= @commissioner.name %> - Employee Name - - <% if Employee.exists? %> - <% employee = Employee.where('emp_id=?',@commissioner.emp_id) %> - <%= employee[0].name %> - <% end %> - - - Commission Type<%= @commissioner.commission_type %> - Active<%= @commissioner.is_active %> - Created By<%= Employee.find(@commissioner.created_by).name %> - - - <%= link_to 'Edit', edit_origami_commissioner_path(@commissioner) %><%= link_to 'Destroy', origami_commissioner_path(@commissioner), method: :delete, data: { confirm: 'Are you sure?' } %> - + + Name + <%= @commissioner.name %> + + + Employee Name + + <% if Employee.exists? %> + <% employee = Employee.where('emp_id=?', @commissioner.emp_id) %> + <%= employee[0].name %> + <% end %> + + + + Commission Type + <%= @commissioner.commission_type %> + + + Active + <%= @commissioner.is_active %> + + + Created By + <%= Employee.find(@commissioner.created_by).name %> + + <%= link_to 'Back', origami_commissioners_path, class: 'btn btn-success' %> + <%= link_to 'Edit', edit_origami_commissioner_path(@commissioner), class: 'btn btn-info' %> + <%= link_to 'Destroy', origami_commissioner_path(@commissioner), method: :delete, data: {confirm: 'Are you sure?'}, class: 'btn btn-danger' %>
diff --git a/app/views/origami/commissions/_form.html.erb b/app/views/origami/commissions/_form.html.erb index 826dbf78..a5c0d2c0 100644 --- a/app/views/origami/commissions/_form.html.erb +++ b/app/views/origami/commissions/_form.html.erb @@ -1,15 +1,17 @@ +
<%= simple_form_for([:origami,@commission]) do |f| %> <%= f.error_notification %>
- <%= f.collection_select :product_id, Product.all.order('name asc'), :id, :name, {prompt: "Select a Product"}, {class: "form-control"} %> + <%= f.label :product_id %> + <%= f.collection_select :product_id, Product.all.order('name asc'), :id, :name, {prompt: "Select a Product"}, {class: "form-control"} %>
<%= f.input :amount %> - <%= f.input :commission_type, :collection => [:percentage,:net_amount] %> + <%= f.input :commission_type, :collection => [:percentage, :net_amount] %>
-
- <%= f.button :submit %> + <%= link_to 'Back', origami_commissions_path, class: 'btn btn-success' %> + <%= f.button :submit, class: 'btn btn-info' %>
<% end %> - \ No newline at end of file +
diff --git a/app/views/origami/commissions/edit.html.erb b/app/views/origami/commissions/edit.html.erb index da73332f..f3b72f3d 100644 --- a/app/views/origami/commissions/edit.html.erb +++ b/app/views/origami/commissions/edit.html.erb @@ -1,10 +1,10 @@
<%= render 'form', commission: @commission %> -
\ No newline at end of file + diff --git a/app/views/origami/commissions/index.html.erb b/app/views/origami/commissions/index.html.erb index 420920b9..e5a83639 100644 --- a/app/views/origami/commissions/index.html.erb +++ b/app/views/origami/commissions/index.html.erb @@ -1,6 +1,6 @@ diff --git a/app/views/origami/commissions/show.html.erb b/app/views/origami/commissions/show.html.erb index 6eb399af..da04710e 100644 --- a/app/views/origami/commissions/show.html.erb +++ b/app/views/origami/commissions/show.html.erb @@ -1,43 +1,45 @@

<%= notice %>

-<%= link_to 'Edit', edit_commission_path(@commission) %> | -<%= link_to 'Back', commissions_path %> - -

Commission

- - - - - - - - - - - - + + + + + + + + + + + + + + + +
Product Name - <% if Product.exists? %> - <% product = Product.find(@commission.product_id) %> - <%= product.name %> - <% end %> - -
Amount<%= @commission.amount %>
Commission Type<%= @commission.commission_type %>
Active<%= @commission.is_active %>
<%= link_to 'Edit', edit_origami_commission_path(@commission) %><%= link_to 'Destroy', origami_commission_path(@commission), method: :delete, data: { confirm: 'Are you sure?' } %>
Product Name + <% if Product.exists? %> + <% product = Product.find(@commission.product_id) %> + <%= product.name %> + <% end %> +
Amount<%= @commission.amount %>
Commission Type<%= @commission.commission_type %>
Active<%= @commission.is_active %>
+ <%= link_to 'Back', origami_commissions_path, class: 'btn btn-success' %> + <%= link_to 'Edit', edit_origami_commission_path(@commission), class: 'btn btn-info' %> + <%= link_to 'Destroy', origami_commission_path(@commission), method: :delete, class: 'btn btn-danger', data: {confirm: 'Are you sure?'} %>
From 74c2955ef0faaa3eac09df4667ee88a0ae4149c9 Mon Sep 17 00:00:00 2001 From: Zin Lin Phyo Date: Tue, 22 Aug 2017 11:08:49 +0630 Subject: [PATCH 2/2] create productCommission --- .idea/workspace.xml | 300 +++-- .../origami/product_commissions_controller.rb | 74 ++ .../origami/product_commissions_helper.rb | 2 + app/models/product_commission.rb | 2 + app/views/home/dashboard.html.erb | 27 +- app/views/home/index.html.erb | 197 ++-- app/views/layouts/_header.html.erb | 2 +- app/views/origami/home/show.html.erb | 1049 +++++++++-------- .../product_commissions/_form.html.erb | 10 + .../_product_commission.json.jbuilder | 2 + .../origami/product_commissions/edit.html.erb | 6 + .../product_commissions/index.html.erb | 25 + .../product_commissions/index.json.jbuilder | 1 + .../origami/product_commissions/new.html.erb | 5 + .../origami/product_commissions/show.html.erb | 4 + .../product_commissions/show.json.jbuilder | 1 + ...170822034139_create_product_commissions.rb | 12 + .../product_commissions_controller_spec.rb | 141 +++ .../product_commissions_helper_spec.rb | 15 + spec/models/product_commission_spec.rb | 5 + .../origami_product_commissions_spec.rb | 10 + .../product_commissions_routing_spec.rb | 39 + .../product_commissions/edit.html.erb_spec.rb | 14 + .../index.html.erb_spec.rb | 14 + .../product_commissions/new.html.erb_spec.rb | 14 + .../product_commissions/show.html.erb_spec.rb | 11 + 26 files changed, 1187 insertions(+), 795 deletions(-) create mode 100644 app/controllers/origami/product_commissions_controller.rb create mode 100644 app/helpers/origami/product_commissions_helper.rb create mode 100644 app/models/product_commission.rb create mode 100644 app/views/origami/product_commissions/_form.html.erb create mode 100644 app/views/origami/product_commissions/_product_commission.json.jbuilder create mode 100644 app/views/origami/product_commissions/edit.html.erb create mode 100644 app/views/origami/product_commissions/index.html.erb create mode 100644 app/views/origami/product_commissions/index.json.jbuilder create mode 100644 app/views/origami/product_commissions/new.html.erb create mode 100644 app/views/origami/product_commissions/show.html.erb create mode 100644 app/views/origami/product_commissions/show.json.jbuilder create mode 100644 db/migrate/20170822034139_create_product_commissions.rb create mode 100644 spec/controllers/origami/product_commissions_controller_spec.rb create mode 100644 spec/helpers/origami/product_commissions_helper_spec.rb create mode 100644 spec/models/product_commission_spec.rb create mode 100644 spec/requests/origami/origami_product_commissions_spec.rb create mode 100644 spec/routing/origami/product_commissions_routing_spec.rb create mode 100644 spec/views/origami/product_commissions/edit.html.erb_spec.rb create mode 100644 spec/views/origami/product_commissions/index.html.erb_spec.rb create mode 100644 spec/views/origami/product_commissions/new.html.erb_spec.rb create mode 100644 spec/views/origami/product_commissions/show.html.erb_spec.rb diff --git a/.idea/workspace.xml b/.idea/workspace.xml index fdfb3e9b..de9b54ce 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,20 +2,11 @@ - - - - - - - - - - - - - + + + + @@ -32,101 +23,74 @@ - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -136,11 +100,12 @@ - origami table_invoice sale_id oqs void + red + origami @@ -154,7 +119,6 @@ @@ -330,59 +298,7 @@ @@ -800,6 +717,9 @@ + + + @@ -812,12 +732,12 @@ - + - @@ -828,19 +748,19 @@ + + - - @@ -854,8 +774,6 @@ - - @@ -863,9 +781,7 @@ - - @@ -887,9 +803,6 @@ - - - @@ -992,14 +905,6 @@ - - - - - - - - @@ -1059,7 +964,7 @@ - + @@ -1082,8 +987,75 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/controllers/origami/product_commissions_controller.rb b/app/controllers/origami/product_commissions_controller.rb new file mode 100644 index 00000000..f3f05ab9 --- /dev/null +++ b/app/controllers/origami/product_commissions_controller.rb @@ -0,0 +1,74 @@ +class Origami::ProductCommissionsController < ApplicationController + before_action :set_product_commission, only: [:show, :edit, :update, :destroy] + + # GET /product_commissions + # GET /product_commissions.json + def index + @product_commissions = ProductCommission.all + end + + # GET /product_commissions/1 + # GET /product_commissions/1.json + def show + end + + # GET /product_commissions/new + def new + @product_commission = ProductCommission.new + end + + # GET /product_commissions/1/edit + def edit + end + + # POST /product_commissions + # POST /product_commissions.json + def create + @product_commission = ProductCommission.new(product_commission_params) + + respond_to do |format| + if @product_commission.save + format.html { redirect_to @product_commission, notice: 'Product commission was successfully created.' } + format.json { render :show, status: :created, location: @product_commission } + else + format.html { render :new } + format.json { render json: @product_commission.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /product_commissions/1 + # PATCH/PUT /product_commissions/1.json + def update + respond_to do |format| + if @product_commission.update(product_commission_params) + format.html { redirect_to @product_commission, notice: 'Product commission was successfully updated.' } + format.json { render :show, status: :ok, location: @product_commission } + else + format.html { render :edit } + format.json { render json: @product_commission.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /product_commissions/1 + # DELETE /product_commissions/1.json + def destroy + @product_commission.destroy + respond_to do |format| + format.html { redirect_to product_commissions_url, notice: 'Product commission was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_product_commission + @product_commission = ProductCommission.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def product_commission_params + params.fetch(:product_commission, {}) + end +end diff --git a/app/helpers/origami/product_commissions_helper.rb b/app/helpers/origami/product_commissions_helper.rb new file mode 100644 index 00000000..1d191b16 --- /dev/null +++ b/app/helpers/origami/product_commissions_helper.rb @@ -0,0 +1,2 @@ +module Origami::ProductCommissionsHelper +end diff --git a/app/models/product_commission.rb b/app/models/product_commission.rb new file mode 100644 index 00000000..70de81f8 --- /dev/null +++ b/app/models/product_commission.rb @@ -0,0 +1,2 @@ +class ProductCommission < ApplicationRecord +end diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 511cd500..025cfae9 100644 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -30,7 +30,7 @@
- Origami + Cashier
@@ -66,8 +66,7 @@

- Administrator - + Administrator

@@ -105,7 +104,7 @@
  • OQS

  • -
  • Origami

  • +
  • Cashier

  • CRM
@@ -115,8 +114,7 @@

- Manager - + Manager

@@ -152,7 +150,7 @@
  • OQS

  • -
  • Origami

  • +
  • Cashier

  • CRM
@@ -162,8 +160,7 @@

- Supervisor - + Supervisor

@@ -185,14 +182,13 @@

- Cashier - + Cashier

    -
  • Orgami Panel except Edit and Void
  • +
  • Cashier Panel except Edit and Void
  • Sale and Order
  • and Queue in CRM
@@ -203,8 +199,7 @@

- Accountant - + Accountant

@@ -223,11 +218,11 @@
-