From d7d29e4d167cea5f998d632cd2781491a9555d70 Mon Sep 17 00:00:00 2001 From: Min Zeya Phyo Date: Mon, 29 May 2017 18:55:34 +0630 Subject: [PATCH 01/39] sales listing under transacitons --- .../javascripts/transactions/sales.coffee | 3 + .../stylesheets/transactions/sales.scss | 3 + .../transactions/sales_controller.rb | 74 +++++++++ app/helpers/transactions/sales_helper.rb | 2 + app/models/transactions.rb | 5 + app/views/transactions/sales/_form.html.erb | 27 ++++ .../sales/_transactions_sale.json.jbuilder | 2 + app/views/transactions/sales/edit.html.erb | 6 + app/views/transactions/sales/index.html.erb | 59 ++++++++ .../transactions/sales/index.json.jbuilder | 1 + app/views/transactions/sales/new.html.erb | 5 + app/views/transactions/sales/show.html.erb | 89 +++++++++++ .../transactions/sales/show.json.jbuilder | 1 + config/routes.rb | 5 + db/scaffold_structure | 2 + .../transactions/sales_controller_spec.rb | 141 ++++++++++++++++++ .../helpers/transactions/sales_helper_spec.rb | 15 ++ spec/models/transactions/sale_spec.rb | 5 + .../transactions/transactions_sales_spec.rb | 10 ++ .../transactions/sales_routing_spec.rb | 39 +++++ .../transactions/sales/edit.html.erb_spec.rb | 60 ++++++++ .../transactions/sales/index.html.erb_spec.rb | 61 ++++++++ .../transactions/sales/new.html.erb_spec.rb | 60 ++++++++ .../transactions/sales/show.html.erb_spec.rb | 42 ++++++ test/application_system_test_case.rb | 5 + test/system/sales_test.rb | 9 ++ 26 files changed, 731 insertions(+) create mode 100644 app/assets/javascripts/transactions/sales.coffee create mode 100644 app/assets/stylesheets/transactions/sales.scss create mode 100644 app/controllers/transactions/sales_controller.rb create mode 100644 app/helpers/transactions/sales_helper.rb create mode 100644 app/models/transactions.rb create mode 100644 app/views/transactions/sales/_form.html.erb create mode 100644 app/views/transactions/sales/_transactions_sale.json.jbuilder create mode 100644 app/views/transactions/sales/edit.html.erb create mode 100644 app/views/transactions/sales/index.html.erb create mode 100644 app/views/transactions/sales/index.json.jbuilder create mode 100644 app/views/transactions/sales/new.html.erb create mode 100644 app/views/transactions/sales/show.html.erb create mode 100644 app/views/transactions/sales/show.json.jbuilder create mode 100644 spec/controllers/transactions/sales_controller_spec.rb create mode 100644 spec/helpers/transactions/sales_helper_spec.rb create mode 100644 spec/models/transactions/sale_spec.rb create mode 100644 spec/requests/transactions/transactions_sales_spec.rb create mode 100644 spec/routing/transactions/sales_routing_spec.rb create mode 100644 spec/views/transactions/sales/edit.html.erb_spec.rb create mode 100644 spec/views/transactions/sales/index.html.erb_spec.rb create mode 100644 spec/views/transactions/sales/new.html.erb_spec.rb create mode 100644 spec/views/transactions/sales/show.html.erb_spec.rb create mode 100644 test/application_system_test_case.rb create mode 100644 test/system/sales_test.rb diff --git a/app/assets/javascripts/transactions/sales.coffee b/app/assets/javascripts/transactions/sales.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/transactions/sales.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/transactions/sales.scss b/app/assets/stylesheets/transactions/sales.scss new file mode 100644 index 00000000..2ab00c12 --- /dev/null +++ b/app/assets/stylesheets/transactions/sales.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the transactions/Sales controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb new file mode 100644 index 00000000..ea9e8ccd --- /dev/null +++ b/app/controllers/transactions/sales_controller.rb @@ -0,0 +1,74 @@ +class Transactions::SalesController < ApplicationController + before_action :set_transactions_sale, only: [:show, :edit, :update, :destroy] + + # GET /transactions/sales + # GET /transactions/sales.json + def index + @transactions_sales = Sale.all + end + + # GET /transactions/sales/1 + # GET /transactions/sales/1.json + def show + end + + # GET /transactions/sales/new + def new + @transactions_sale = Sale.new + end + + # GET /transactions/sales/1/edit + def edit + end + + # POST /transactions/sales + # POST /transactions/sales.json + def create + @transactions_sale = Sale.new(transactions_sale_params) + + respond_to do |format| + if @transactions_sale.save + format.html { redirect_to @transactions_sale, notice: 'Sale was successfully created.' } + format.json { render :show, status: :created, location: @transactions_sale } + else + format.html { render :new } + format.json { render json: @transactions_sale.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /transactions/sales/1 + # PATCH/PUT /transactions/sales/1.json + def update + respond_to do |format| + if @transactions_sale.update(transactions_sale_params) + format.html { redirect_to @transactions_sale, notice: 'Sale was successfully updated.' } + format.json { render :show, status: :ok, location: @transactions_sale } + else + format.html { render :edit } + format.json { render json: @transactions_sale.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /transactions/sales/1 + # DELETE /transactions/sales/1.json + def destroy + @transactions_sale.destroy + respond_to do |format| + format.html { redirect_to transactions_sales_url, notice: 'Sale was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_transactions_sale + @transactions_sale = Sale.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def transactions_sale_params + params.require(:transactions_sale).permit(:cashier_id, :cashier_name, :requested_by, :requested_at, :receipt_no, :receipt_date, :customer_id, :payment_status, :sale_status, :total_amount, :total_discount, :total_tax, :tax_type, :grand_total, :rounding_adjustment, :amount_received, :amount_changed) + end +end diff --git a/app/helpers/transactions/sales_helper.rb b/app/helpers/transactions/sales_helper.rb new file mode 100644 index 00000000..95aa5c87 --- /dev/null +++ b/app/helpers/transactions/sales_helper.rb @@ -0,0 +1,2 @@ +module Transactions::SalesHelper +end diff --git a/app/models/transactions.rb b/app/models/transactions.rb new file mode 100644 index 00000000..9cffb0d1 --- /dev/null +++ b/app/models/transactions.rb @@ -0,0 +1,5 @@ +module Transactions + def self.table_name_prefix + 'transactions_' + end +end diff --git a/app/views/transactions/sales/_form.html.erb b/app/views/transactions/sales/_form.html.erb new file mode 100644 index 00000000..e83e3202 --- /dev/null +++ b/app/views/transactions/sales/_form.html.erb @@ -0,0 +1,27 @@ +<%= simple_form_for(@transactions_sale) do |f| %> + <%= f.error_notification %> + +
+ <%= f.association :cashier %> + <%= f.input :cashier_name %> + <%= f.input :requested_by %> + <%= f.input :requested_at %> + <%= f.input :receipt_no %> + <%= f.input :receipt_date %> + <%= f.association :customer %> + <%= f.input :payment_status %> + <%= f.input :sale_status %> + <%= f.input :total_amount %> + <%= f.input :total_discount %> + <%= f.input :total_tax %> + <%= f.input :tax_type %> + <%= f.input :grand_total %> + <%= f.input :rounding_adjustment %> + <%= f.input :amount_received %> + <%= f.input :amount_changed %> +
+ +
+ <%= f.button :submit %> +
+<% end %> diff --git a/app/views/transactions/sales/_transactions_sale.json.jbuilder b/app/views/transactions/sales/_transactions_sale.json.jbuilder new file mode 100644 index 00000000..869b3cf7 --- /dev/null +++ b/app/views/transactions/sales/_transactions_sale.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! transactions_sale, :id, :cashier_id, :cashier_name, :requested_by, :requested_at, :receipt_no, :receipt_date, :customer_id, :payment_status, :sale_status, :total_amount, :total_discount, :total_tax, :tax_type, :grand_total, :rounding_adjustment, :amount_received, :amount_changed, :created_at, :updated_at +json.url transactions_sale_url(transactions_sale, format: :json) diff --git a/app/views/transactions/sales/edit.html.erb b/app/views/transactions/sales/edit.html.erb new file mode 100644 index 00000000..cf11644b --- /dev/null +++ b/app/views/transactions/sales/edit.html.erb @@ -0,0 +1,6 @@ +

Editing Transactions Sale

+ +<%= render 'form', transactions_sale: @transactions_sale %> + +<%= link_to 'Show', @transactions_sale %> | +<%= link_to 'Back', transactions_sales_path %> diff --git a/app/views/transactions/sales/index.html.erb b/app/views/transactions/sales/index.html.erb new file mode 100644 index 00000000..c39b0ac3 --- /dev/null +++ b/app/views/transactions/sales/index.html.erb @@ -0,0 +1,59 @@ +

<%= notice %>

+ +

Transactions Sales

+ + + + + + + + + + + + + + + + + + + + + + + + + + + <% @transactions_sales.each do |transactions_sale| %> + + + + + + + + + + + + + + + + + + + + + + + <% end %> + +
CashierCashier nameRequested byRequested atReceipt noReceipt dateCustomerPayment statusSale statusTotal amountTotal discountTotal taxTax typeGrand totalRounding adjustmentAmount receivedAmount changed
<%= transactions_sale.cashier %><%= transactions_sale.cashier_name %><%= transactions_sale.requested_by %><%= transactions_sale.requested_at %><%= transactions_sale.receipt_no %><%= transactions_sale.receipt_date %><%= transactions_sale.customer %><%= transactions_sale.payment_status %><%= transactions_sale.sale_status %><%= transactions_sale.total_amount %><%= transactions_sale.total_discount %><%= transactions_sale.total_tax %><%= transactions_sale.tax_type %><%= transactions_sale.grand_total %><%= transactions_sale.rounding_adjustment %><%= transactions_sale.amount_received %><%= transactions_sale.amount_changed %><%= link_to 'Show', transactions_sale %><%= link_to 'Edit', edit_transactions_sale_path(transactions_sale) %><%= link_to 'Destroy', transactions_sale, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Transactions Sale', new_transactions_sale_path %> diff --git a/app/views/transactions/sales/index.json.jbuilder b/app/views/transactions/sales/index.json.jbuilder new file mode 100644 index 00000000..a67adc38 --- /dev/null +++ b/app/views/transactions/sales/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @transactions_sales, partial: 'transactions_sales/transactions_sale', as: :transactions_sale diff --git a/app/views/transactions/sales/new.html.erb b/app/views/transactions/sales/new.html.erb new file mode 100644 index 00000000..1f479747 --- /dev/null +++ b/app/views/transactions/sales/new.html.erb @@ -0,0 +1,5 @@ +

New Transactions Sale

+ +<%= render 'form', transactions_sale: @transactions_sale %> + +<%= link_to 'Back', transactions_sales_path %> diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb new file mode 100644 index 00000000..c82c2c5e --- /dev/null +++ b/app/views/transactions/sales/show.html.erb @@ -0,0 +1,89 @@ +

<%= notice %>

+ +

+ Cashier: + <%= @transactions_sale.cashier %> +

+ +

+ Cashier name: + <%= @transactions_sale.cashier_name %> +

+ +

+ Requested by: + <%= @transactions_sale.requested_by %> +

+ +

+ Requested at: + <%= @transactions_sale.requested_at %> +

+ +

+ Receipt no: + <%= @transactions_sale.receipt_no %> +

+ +

+ Receipt date: + <%= @transactions_sale.receipt_date %> +

+ +

+ Customer: + <%= @transactions_sale.customer %> +

+ +

+ Payment status: + <%= @transactions_sale.payment_status %> +

+ +

+ Sale status: + <%= @transactions_sale.sale_status %> +

+ +

+ Total amount: + <%= @transactions_sale.total_amount %> +

+ +

+ Total discount: + <%= @transactions_sale.total_discount %> +

+ +

+ Total tax: + <%= @transactions_sale.total_tax %> +

+ +

+ Tax type: + <%= @transactions_sale.tax_type %> +

+ +

+ Grand total: + <%= @transactions_sale.grand_total %> +

+ +

+ Rounding adjustment: + <%= @transactions_sale.rounding_adjustment %> +

+ +

+ Amount received: + <%= @transactions_sale.amount_received %> +

+ +

+ Amount changed: + <%= @transactions_sale.amount_changed %> +

+ +<%= link_to 'Edit', edit_transactions_sale_path(@transactions_sale) %> | +<%= link_to 'Back', transactions_sales_path %> diff --git a/app/views/transactions/sales/show.json.jbuilder b/app/views/transactions/sales/show.json.jbuilder new file mode 100644 index 00000000..48c70528 --- /dev/null +++ b/app/views/transactions/sales/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "transactions_sales/transactions_sale", transactions_sale: @transactions_sale diff --git a/config/routes.rb b/config/routes.rb index ed2cdab0..da5d8baf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -142,7 +142,12 @@ Rails.application.routes.draw do end end + #--------- Transactions Sections ------------# + namespace :transactions do + resources :sales + end + #--------- Reports Controller Sections ------------# namespace :reports do resources :sales, :only => [:index, :show] resources :orders, :only => [:index, :show] diff --git a/db/scaffold_structure b/db/scaffold_structure index 7446c21b..064f62d4 100644 --- a/db/scaffold_structure +++ b/db/scaffold_structure @@ -20,3 +20,5 @@ rails generate scaffold Setup/TaxProfile name:string rate:decimal inclusive:bool rails generate scaffold_controller Setup/CashierTerminal name:string is_active:boolean is_currently_login:boolean auto_print_receipt:string printer_name:string header:json footer:json font:string font_size:string show_tax:boolean show_cashier:boolean show_guest_info:boolean --no-migration rails generate scaffold_controller Settings/OrderQueueStation station_name:string is_active:boolean processing_items:json print_copy:boolean printer_name:string font_size:integer cut_per_item:boolean use_alternate_name:boolean created_by:string --no-migration + +rails generate scaffold_controller transactions/Sale cashier:references cashier_name:string requested_by:string requested_at:datetime receipt_no:string receipt_date:datetime customer:references payment_status:string sale_status:string total_amount:decimal total_discount:decimal total_tax:decimal tax_type:string grand_total:decimal rounding_adjustment:decimal amount_received:decimal amount_changed:decimal --no-migration diff --git a/spec/controllers/transactions/sales_controller_spec.rb b/spec/controllers/transactions/sales_controller_spec.rb new file mode 100644 index 00000000..054e2430 --- /dev/null +++ b/spec/controllers/transactions/sales_controller_spec.rb @@ -0,0 +1,141 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to specify the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. +# +# Compared to earlier versions of this generator, there is very limited use of +# stubs and message expectations in this spec. Stubs are only used when there +# is no simpler way to get a handle on the object needed for the example. +# Message expectations are only used when there is no simpler way to specify +# that an instance is receiving a specific message. +# +# Also compared to earlier versions of this generator, there are no longer any +# expectations of assigns and templates rendered. These features have been +# removed from Rails core in Rails 5, but can be added back in via the +# `rails-controller-testing` gem. + +RSpec.describe Transactions::SalesController, type: :controller do + + # This should return the minimal set of attributes required to create a valid + # Transactions::Sale. As you add validations to Transactions::Sale, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + # This should return the minimal set of values that should be in the session + # in order to pass any filters (e.g. authentication) defined in + # Transactions::SalesController. Be sure to keep this updated too. + let(:valid_session) { {} } + + describe "GET #index" do + it "returns a success response" do + sale = Transactions::Sale.create! valid_attributes + get :index, params: {}, session: valid_session + expect(response).to be_success + end + end + + describe "GET #show" do + it "returns a success response" do + sale = Transactions::Sale.create! valid_attributes + get :show, params: {id: sale.to_param}, session: valid_session + expect(response).to be_success + end + end + + describe "GET #new" do + it "returns a success response" do + get :new, params: {}, session: valid_session + expect(response).to be_success + end + end + + describe "GET #edit" do + it "returns a success response" do + sale = Transactions::Sale.create! valid_attributes + get :edit, params: {id: sale.to_param}, session: valid_session + expect(response).to be_success + end + end + + describe "POST #create" do + context "with valid params" do + it "creates a new Transactions::Sale" do + expect { + post :create, params: {transactions_sale: valid_attributes}, session: valid_session + }.to change(Transactions::Sale, :count).by(1) + end + + it "redirects to the created transactions_sale" do + post :create, params: {transactions_sale: valid_attributes}, session: valid_session + expect(response).to redirect_to(Transactions::Sale.last) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'new' template)" do + post :create, params: {transactions_sale: invalid_attributes}, session: valid_session + expect(response).to be_success + end + end + end + + describe "PUT #update" do + context "with valid params" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested transactions_sale" do + sale = Transactions::Sale.create! valid_attributes + put :update, params: {id: sale.to_param, transactions_sale: new_attributes}, session: valid_session + sale.reload + skip("Add assertions for updated state") + end + + it "redirects to the transactions_sale" do + sale = Transactions::Sale.create! valid_attributes + put :update, params: {id: sale.to_param, transactions_sale: valid_attributes}, session: valid_session + expect(response).to redirect_to(sale) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'edit' template)" do + sale = Transactions::Sale.create! valid_attributes + put :update, params: {id: sale.to_param, transactions_sale: invalid_attributes}, session: valid_session + expect(response).to be_success + end + end + end + + describe "DELETE #destroy" do + it "destroys the requested transactions_sale" do + sale = Transactions::Sale.create! valid_attributes + expect { + delete :destroy, params: {id: sale.to_param}, session: valid_session + }.to change(Transactions::Sale, :count).by(-1) + end + + it "redirects to the transactions_sales list" do + sale = Transactions::Sale.create! valid_attributes + delete :destroy, params: {id: sale.to_param}, session: valid_session + expect(response).to redirect_to(transactions_sales_url) + end + end + +end diff --git a/spec/helpers/transactions/sales_helper_spec.rb b/spec/helpers/transactions/sales_helper_spec.rb new file mode 100644 index 00000000..fd45fe62 --- /dev/null +++ b/spec/helpers/transactions/sales_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the Transactions::SalesHelper. For example: +# +# describe Transactions::SalesHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe Transactions::SalesHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/transactions/sale_spec.rb b/spec/models/transactions/sale_spec.rb new file mode 100644 index 00000000..8a24dfc4 --- /dev/null +++ b/spec/models/transactions/sale_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Transactions::Sale, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/requests/transactions/transactions_sales_spec.rb b/spec/requests/transactions/transactions_sales_spec.rb new file mode 100644 index 00000000..23ed6d80 --- /dev/null +++ b/spec/requests/transactions/transactions_sales_spec.rb @@ -0,0 +1,10 @@ +require 'rails_helper' + +RSpec.describe "Transactions::Sales", type: :request do + describe "GET /transactions_sales" do + it "works! (now write some real specs)" do + get transactions_sales_path + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/routing/transactions/sales_routing_spec.rb b/spec/routing/transactions/sales_routing_spec.rb new file mode 100644 index 00000000..e81109a2 --- /dev/null +++ b/spec/routing/transactions/sales_routing_spec.rb @@ -0,0 +1,39 @@ +require "rails_helper" + +RSpec.describe Transactions::SalesController, type: :routing do + describe "routing" do + + it "routes to #index" do + expect(:get => "/transactions/sales").to route_to("transactions/sales#index") + end + + it "routes to #new" do + expect(:get => "/transactions/sales/new").to route_to("transactions/sales#new") + end + + it "routes to #show" do + expect(:get => "/transactions/sales/1").to route_to("transactions/sales#show", :id => "1") + end + + it "routes to #edit" do + expect(:get => "/transactions/sales/1/edit").to route_to("transactions/sales#edit", :id => "1") + end + + it "routes to #create" do + expect(:post => "/transactions/sales").to route_to("transactions/sales#create") + end + + it "routes to #update via PUT" do + expect(:put => "/transactions/sales/1").to route_to("transactions/sales#update", :id => "1") + end + + it "routes to #update via PATCH" do + expect(:patch => "/transactions/sales/1").to route_to("transactions/sales#update", :id => "1") + end + + it "routes to #destroy" do + expect(:delete => "/transactions/sales/1").to route_to("transactions/sales#destroy", :id => "1") + end + + end +end diff --git a/spec/views/transactions/sales/edit.html.erb_spec.rb b/spec/views/transactions/sales/edit.html.erb_spec.rb new file mode 100644 index 00000000..8ab20cd0 --- /dev/null +++ b/spec/views/transactions/sales/edit.html.erb_spec.rb @@ -0,0 +1,60 @@ +require 'rails_helper' + +RSpec.describe "transactions/sales/edit", type: :view do + before(:each) do + @transactions_sale = assign(:transactions_sale, Transactions::Sale.create!( + :cashier => nil, + :cashier_name => "MyString", + :requested_by => "MyString", + :receipt_no => "MyString", + :customer => nil, + :payment_status => "MyString", + :sale_status => "MyString", + :total_amount => "9.99", + :total_discount => "9.99", + :total_tax => "9.99", + :tax_type => "MyString", + :grand_total => "9.99", + :rounding_adjustment => "9.99", + :amount_received => "9.99", + :amount_changed => "9.99" + )) + end + + it "renders the edit transactions_sale form" do + render + + assert_select "form[action=?][method=?]", transactions_sale_path(@transactions_sale), "post" do + + assert_select "input[name=?]", "transactions_sale[cashier_id]" + + assert_select "input[name=?]", "transactions_sale[cashier_name]" + + assert_select "input[name=?]", "transactions_sale[requested_by]" + + assert_select "input[name=?]", "transactions_sale[receipt_no]" + + assert_select "input[name=?]", "transactions_sale[customer_id]" + + assert_select "input[name=?]", "transactions_sale[payment_status]" + + assert_select "input[name=?]", "transactions_sale[sale_status]" + + assert_select "input[name=?]", "transactions_sale[total_amount]" + + assert_select "input[name=?]", "transactions_sale[total_discount]" + + assert_select "input[name=?]", "transactions_sale[total_tax]" + + assert_select "input[name=?]", "transactions_sale[tax_type]" + + assert_select "input[name=?]", "transactions_sale[grand_total]" + + assert_select "input[name=?]", "transactions_sale[rounding_adjustment]" + + assert_select "input[name=?]", "transactions_sale[amount_received]" + + assert_select "input[name=?]", "transactions_sale[amount_changed]" + end + end +end diff --git a/spec/views/transactions/sales/index.html.erb_spec.rb b/spec/views/transactions/sales/index.html.erb_spec.rb new file mode 100644 index 00000000..9071ef3a --- /dev/null +++ b/spec/views/transactions/sales/index.html.erb_spec.rb @@ -0,0 +1,61 @@ +require 'rails_helper' + +RSpec.describe "transactions/sales/index", type: :view do + before(:each) do + assign(:transactions_sales, [ + Transactions::Sale.create!( + :cashier => nil, + :cashier_name => "Cashier Name", + :requested_by => "Requested By", + :receipt_no => "Receipt No", + :customer => nil, + :payment_status => "Payment Status", + :sale_status => "Sale Status", + :total_amount => "9.99", + :total_discount => "9.99", + :total_tax => "9.99", + :tax_type => "Tax Type", + :grand_total => "9.99", + :rounding_adjustment => "9.99", + :amount_received => "9.99", + :amount_changed => "9.99" + ), + Transactions::Sale.create!( + :cashier => nil, + :cashier_name => "Cashier Name", + :requested_by => "Requested By", + :receipt_no => "Receipt No", + :customer => nil, + :payment_status => "Payment Status", + :sale_status => "Sale Status", + :total_amount => "9.99", + :total_discount => "9.99", + :total_tax => "9.99", + :tax_type => "Tax Type", + :grand_total => "9.99", + :rounding_adjustment => "9.99", + :amount_received => "9.99", + :amount_changed => "9.99" + ) + ]) + end + + it "renders a list of transactions/sales" do + render + assert_select "tr>td", :text => nil.to_s, :count => 2 + assert_select "tr>td", :text => "Cashier Name".to_s, :count => 2 + assert_select "tr>td", :text => "Requested By".to_s, :count => 2 + assert_select "tr>td", :text => "Receipt No".to_s, :count => 2 + assert_select "tr>td", :text => nil.to_s, :count => 2 + assert_select "tr>td", :text => "Payment Status".to_s, :count => 2 + assert_select "tr>td", :text => "Sale Status".to_s, :count => 2 + assert_select "tr>td", :text => "9.99".to_s, :count => 2 + assert_select "tr>td", :text => "9.99".to_s, :count => 2 + assert_select "tr>td", :text => "9.99".to_s, :count => 2 + assert_select "tr>td", :text => "Tax Type".to_s, :count => 2 + assert_select "tr>td", :text => "9.99".to_s, :count => 2 + assert_select "tr>td", :text => "9.99".to_s, :count => 2 + assert_select "tr>td", :text => "9.99".to_s, :count => 2 + assert_select "tr>td", :text => "9.99".to_s, :count => 2 + end +end diff --git a/spec/views/transactions/sales/new.html.erb_spec.rb b/spec/views/transactions/sales/new.html.erb_spec.rb new file mode 100644 index 00000000..5e499ef5 --- /dev/null +++ b/spec/views/transactions/sales/new.html.erb_spec.rb @@ -0,0 +1,60 @@ +require 'rails_helper' + +RSpec.describe "transactions/sales/new", type: :view do + before(:each) do + assign(:transactions_sale, Transactions::Sale.new( + :cashier => nil, + :cashier_name => "MyString", + :requested_by => "MyString", + :receipt_no => "MyString", + :customer => nil, + :payment_status => "MyString", + :sale_status => "MyString", + :total_amount => "9.99", + :total_discount => "9.99", + :total_tax => "9.99", + :tax_type => "MyString", + :grand_total => "9.99", + :rounding_adjustment => "9.99", + :amount_received => "9.99", + :amount_changed => "9.99" + )) + end + + it "renders new transactions_sale form" do + render + + assert_select "form[action=?][method=?]", transactions_sales_path, "post" do + + assert_select "input[name=?]", "transactions_sale[cashier_id]" + + assert_select "input[name=?]", "transactions_sale[cashier_name]" + + assert_select "input[name=?]", "transactions_sale[requested_by]" + + assert_select "input[name=?]", "transactions_sale[receipt_no]" + + assert_select "input[name=?]", "transactions_sale[customer_id]" + + assert_select "input[name=?]", "transactions_sale[payment_status]" + + assert_select "input[name=?]", "transactions_sale[sale_status]" + + assert_select "input[name=?]", "transactions_sale[total_amount]" + + assert_select "input[name=?]", "transactions_sale[total_discount]" + + assert_select "input[name=?]", "transactions_sale[total_tax]" + + assert_select "input[name=?]", "transactions_sale[tax_type]" + + assert_select "input[name=?]", "transactions_sale[grand_total]" + + assert_select "input[name=?]", "transactions_sale[rounding_adjustment]" + + assert_select "input[name=?]", "transactions_sale[amount_received]" + + assert_select "input[name=?]", "transactions_sale[amount_changed]" + end + end +end diff --git a/spec/views/transactions/sales/show.html.erb_spec.rb b/spec/views/transactions/sales/show.html.erb_spec.rb new file mode 100644 index 00000000..6d2ec4cc --- /dev/null +++ b/spec/views/transactions/sales/show.html.erb_spec.rb @@ -0,0 +1,42 @@ +require 'rails_helper' + +RSpec.describe "transactions/sales/show", type: :view do + before(:each) do + @transactions_sale = assign(:transactions_sale, Transactions::Sale.create!( + :cashier => nil, + :cashier_name => "Cashier Name", + :requested_by => "Requested By", + :receipt_no => "Receipt No", + :customer => nil, + :payment_status => "Payment Status", + :sale_status => "Sale Status", + :total_amount => "9.99", + :total_discount => "9.99", + :total_tax => "9.99", + :tax_type => "Tax Type", + :grand_total => "9.99", + :rounding_adjustment => "9.99", + :amount_received => "9.99", + :amount_changed => "9.99" + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(//) + expect(rendered).to match(/Cashier Name/) + expect(rendered).to match(/Requested By/) + expect(rendered).to match(/Receipt No/) + expect(rendered).to match(//) + expect(rendered).to match(/Payment Status/) + expect(rendered).to match(/Sale Status/) + expect(rendered).to match(/9.99/) + expect(rendered).to match(/9.99/) + expect(rendered).to match(/9.99/) + expect(rendered).to match(/Tax Type/) + expect(rendered).to match(/9.99/) + expect(rendered).to match(/9.99/) + expect(rendered).to match(/9.99/) + expect(rendered).to match(/9.99/) + end +end diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb new file mode 100644 index 00000000..d19212ab --- /dev/null +++ b/test/application_system_test_case.rb @@ -0,0 +1,5 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/test/system/sales_test.rb b/test/system/sales_test.rb new file mode 100644 index 00000000..7df56114 --- /dev/null +++ b/test/system/sales_test.rb @@ -0,0 +1,9 @@ +require "application_system_test_case" + +class Transactions::SalesTest < ApplicationSystemTestCase + # test "visiting the index" do + # visit transactions_sales_url + # + # assert_selector "h1", text: "Transactions::Sale" + # end +end From 9361e24a8af68644e33f6819a4873980682df34b Mon Sep 17 00:00:00 2001 From: Min Zeya Phyo Date: Tue, 30 May 2017 12:42:50 +0630 Subject: [PATCH 02/39] remove sale_discount from model list --- app/models/sale_discount.rb | 3 --- db/migrate/20170403162221_create_sale_discounts.rb | 13 ------------- spec/models/sale_discount_spec.rb | 5 ----- 3 files changed, 21 deletions(-) delete mode 100644 app/models/sale_discount.rb delete mode 100644 db/migrate/20170403162221_create_sale_discounts.rb delete mode 100644 spec/models/sale_discount_spec.rb diff --git a/app/models/sale_discount.rb b/app/models/sale_discount.rb deleted file mode 100644 index 1d18c856..00000000 --- a/app/models/sale_discount.rb +++ /dev/null @@ -1,3 +0,0 @@ -class SaleDiscount < ApplicationRecord - belongs_to :sale -end diff --git a/db/migrate/20170403162221_create_sale_discounts.rb b/db/migrate/20170403162221_create_sale_discounts.rb deleted file mode 100644 index e10b2f98..00000000 --- a/db/migrate/20170403162221_create_sale_discounts.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateSaleDiscounts < ActiveRecord::Migration[5.0] - def change - create_table :sale_discounts do |t| - t.references :sale, foreign_key: true - t.string :discount_type, :null => false - t.decimal :discount_value, :precision => 10, :scale => 2, :null => false, :default => 0.00 - t.decimal :discount_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00 - t.string :discount_code - - t.timestamps - end - end -end diff --git a/spec/models/sale_discount_spec.rb b/spec/models/sale_discount_spec.rb deleted file mode 100644 index 1365ceff..00000000 --- a/spec/models/sale_discount_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe SaleDiscount, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end From e46fe1ec7c1407c0ed43b0078b8d00689c26efaf Mon Sep 17 00:00:00 2001 From: Yan Date: Tue, 30 May 2017 19:02:40 +0630 Subject: [PATCH 03/39] add cable but not complete --- Gemfile | 4 ++++ Gemfile.lock | 9 +++---- app/assets/javascripts/cable.js | 2 +- .../channels/order_queue_station.js | 24 +++++++++++++++++++ app/channels/application_cable/channel.rb | 14 +++++++++-- app/channels/order_queue_station_channel.rb | 13 ++++++++++ app/jobs/order_broadcast_job.rb | 8 +++++++ app/jobs/order_queue_processor_job.rb | 3 ++- app/models/order.rb | 12 ++++++++-- config/environments/development.rb | 3 +++ config/routes.rb | 3 +++ spec/jobs/order_broadcast_job_spec.rb | 5 ++++ 12 files changed, 90 insertions(+), 10 deletions(-) create mode 100644 app/assets/javascripts/channels/order_queue_station.js create mode 100644 app/channels/order_queue_station_channel.rb create mode 100644 app/jobs/order_broadcast_job.rb create mode 100644 spec/jobs/order_broadcast_job_spec.rb diff --git a/Gemfile b/Gemfile index d42da647..23f3c908 100644 --- a/Gemfile +++ b/Gemfile @@ -11,6 +11,10 @@ gem 'rails', '~> 5.1.0' # Use mysql as the database for Active Record gem 'mysql2', '>= 0.3.18', '< 0.5' #gem 'pg' + +# redis server for cable +gem 'redis', '~> 3.0' + # Use Puma as the app server gem 'puma', '~> 3.0' # Use SCSS for stylesheets diff --git a/Gemfile.lock b/Gemfile.lock index 6916f408..46cdc6ea 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -48,9 +48,9 @@ GEM sass (>= 3.4.19) builder (3.2.3) byebug (9.0.6) - coffee-rails (4.2.1) + coffee-rails (4.2.2) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.2.x) + railties (>= 4.0.0) coffee-script (2.4.1) coffee-script-source execjs @@ -97,7 +97,7 @@ GEM minitest (5.10.2) multi_json (1.12.1) mysql2 (0.4.6) - nio4r (2.0.0) + nio4r (2.1.0) nokogiri (1.7.2) mini_portile2 (~> 2.1.0) pdf-core (0.7.0) @@ -238,6 +238,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 @@ -255,4 +256,4 @@ DEPENDENCIES web-console (>= 3.3.0) BUNDLED WITH - 1.14.6 + 1.15.0 diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js index 71ee1e66..739aa5f0 100644 --- a/app/assets/javascripts/cable.js +++ b/app/assets/javascripts/cable.js @@ -1,5 +1,5 @@ // Action Cable provides the framework to deal with WebSockets in Rails. -// You can generate new channels where WebSocket features live using the rails generate channel command. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. // //= require action_cable //= require_self diff --git a/app/assets/javascripts/channels/order_queue_station.js b/app/assets/javascripts/channels/order_queue_station.js new file mode 100644 index 00000000..00151e5e --- /dev/null +++ b/app/assets/javascripts/channels/order_queue_station.js @@ -0,0 +1,24 @@ +App.order_queue_station = App.cable.subscriptions.create("OrderQueueStationChannel", { + connected: function() {}, + + disconnected: function() {}, + + received: function(message) { + alert(message); + }, + + order: function(message) { + return this.perform('order', { + message: message + }); + } +}); + +// $(function(){ +// $("#submit_order").on('click', function(event) { +// var orderData=$("#new_order").serializeObject(); +// App.order_station.order(orderData); +// //orderData=''; +// return event.preventDefault(); +// }); +// }); diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb index d6726972..a66bc071 100644 --- a/app/channels/application_cable/channel.rb +++ b/app/channels/application_cable/channel.rb @@ -1,4 +1,14 @@ module ApplicationCable - class Channel < ActionCable::Channel::Base - end + class Channel < ActionCable::Channel::Base + end + # Order Queue Station Channel + class OrderChannel < ActionCable::Channel::Base + + end + + # Order Queue Station Channel + class OQSChannel < ActionCable::Channel::Base + + end + end diff --git a/app/channels/order_queue_station_channel.rb b/app/channels/order_queue_station_channel.rb new file mode 100644 index 00000000..8206c64b --- /dev/null +++ b/app/channels/order_queue_station_channel.rb @@ -0,0 +1,13 @@ +class OrderQueueStationChannel < ApplicationCable::Channel + def subscribed + stream_from "order_queue_station_channel" + end + + def unsubscribed + # Any cleanup needed when channel is unsubscribed + end + + def order(message) + # ToDo + end +end diff --git a/app/jobs/order_broadcast_job.rb b/app/jobs/order_broadcast_job.rb new file mode 100644 index 00000000..b29f4cd8 --- /dev/null +++ b/app/jobs/order_broadcast_job.rb @@ -0,0 +1,8 @@ +class OrderBroadcastJob < ApplicationJob + queue_as :default + + def perform(message) + order = Order.find(message) # message come as order_id + ApplicationCable.server.broadcast "order_queue_station_channel", order: order + end +end diff --git a/app/jobs/order_queue_processor_job.rb b/app/jobs/order_queue_processor_job.rb index 33380674..e9a8c13f 100644 --- a/app/jobs/order_queue_processor_job.rb +++ b/app/jobs/order_queue_processor_job.rb @@ -3,8 +3,9 @@ class OrderQueueProcessorJob < ApplicationJob def perform(order_id) # Do something later - #Order ID + #Order ID order = Order.find(order_id) + #Loop through the order stations and process the items #Execute orders and send to order stations if order diff --git a/app/models/order.rb b/app/models/order.rb index 0bec3a1e..7061fdb7 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -8,7 +8,6 @@ class Order < ApplicationRecord #internal references attributes for business logic control attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name, :booking_id - #Main Controller method to create new order - validate all inputs and generate new order # order_item : { # order_item_code : "", @@ -43,6 +42,9 @@ class Order < ApplicationRecord #Send order to queue one it done! process_order_queue + #send order to broadcast job + send_order_broadcast + return true, booking end @@ -198,7 +200,13 @@ class Order < ApplicationRecord #Process order items and send to order queue def process_order_queue - #Send to background job for processing + #Send to background job for processing OrderQueueProcessorJob.perform_later(self.id) end + + #send order items and send to order queue + def send_order_broadcast + #Send to background job for processing + OrderBroadcastJob.perform_later(self.id) + end end diff --git a/config/environments/development.rb b/config/environments/development.rb index 6f719704..f5ab7304 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -51,4 +51,7 @@ Rails.application.configure do # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker + + # Set Cable URL + config.action_cable.url = "ws://192.168.1.140:3002/cable" end diff --git a/config/routes.rb b/config/routes.rb index ed2cdab0..138137dd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,6 +5,9 @@ Rails.application.routes.draw do root 'home#index' mount Sidekiq::Web => '/kiq' + # Action Cable Creation + mount ActionCable.server => "/cable" + #--------- SmartSales Installation ------------# get 'install' => 'install#index' post 'install' => 'install#create' diff --git a/spec/jobs/order_broadcast_job_spec.rb b/spec/jobs/order_broadcast_job_spec.rb new file mode 100644 index 00000000..74f8f77c --- /dev/null +++ b/spec/jobs/order_broadcast_job_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe OrderBroadcastJob, type: :job do + pending "add some examples to (or delete) #{__FILE__}" +end From 516b854fba7f571e02a33dfd80ab7c49f632a228 Mon Sep 17 00:00:00 2001 From: Min Zeya Phyo Date: Tue, 30 May 2017 23:46:22 +0800 Subject: [PATCH 04/39] shop_setup branch --- app/forms/shop_form.rb | 7 ++++++ app/models/booking.rb | 3 ++- app/models/booking_order.rb | 2 ++ app/models/order.rb | 2 ++ app/models/order_item.rb | 2 ++ app/models/sale.rb | 2 ++ app/models/sale_audit.rb | 2 ++ app/models/sale_item.rb | 2 ++ app/models/sale_order.rb | 2 ++ app/models/sale_payment.rb | 2 ++ app/models/sale_tax.rb | 2 ++ app/models/seed_generator.rb | 19 ++++++++++++++ app/models/shop.rb | 2 ++ .../20170403163734_create_sale_payments.rb | 2 +- .../20170408105938_create_seed_generators.rb | 1 - db/migrate/20170530072247_create_shops.rb | 25 +++++++++++++++++++ spec/models/shop_spec.rb | 5 ++++ 17 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 app/forms/shop_form.rb create mode 100644 app/models/shop.rb create mode 100644 db/migrate/20170530072247_create_shops.rb create mode 100644 spec/models/shop_spec.rb diff --git a/app/forms/shop_form.rb b/app/forms/shop_form.rb new file mode 100644 index 00000000..19af84a5 --- /dev/null +++ b/app/forms/shop_form.rb @@ -0,0 +1,7 @@ +#Form object to use during the installation process - will handle creation of shop model into db after verification from the cloud +#provising service through license verification + +class ShopForm < ActiveModel + :attr_accessor :logo, :name, :address, :township, :city, :state, :country, :license, :base_currency, :password, :password_confirmation + +end diff --git a/app/models/booking.rb b/app/models/booking.rb index c6a6452e..c34ecf42 100644 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -1,5 +1,6 @@ class Booking < ApplicationRecord - + #primary key - need to be unique + belongs_to :dining_facility, :optional => true belongs_to :sale, :optional => true has_many :booking_orders diff --git a/app/models/booking_order.rb b/app/models/booking_order.rb index c0883967..c9f748f0 100644 --- a/app/models/booking_order.rb +++ b/app/models/booking_order.rb @@ -1,4 +1,6 @@ class BookingOrder < ApplicationRecord + #primary key - need to be unique + belongs_to :booking belongs_to :order end diff --git a/app/models/order.rb b/app/models/order.rb index 0bec3a1e..b6367f42 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,4 +1,6 @@ class Order < ApplicationRecord + #primary key - need to be unique + before_create :set_order_date belongs_to :customer diff --git a/app/models/order_item.rb b/app/models/order_item.rb index afba7d7e..596d5ccf 100644 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -1,4 +1,6 @@ class OrderItem < ApplicationRecord + #primary key - need to be unique + #Associations belongs_to :order, autosave: true diff --git a/app/models/sale.rb b/app/models/sale.rb index 37819c9b..744baafa 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1,3 +1,5 @@ +#primary key - need to be unique generated for multiple shops + class Sale < ApplicationRecord #before_create :generate_receipt_no belongs_to :cashier, :optional => true diff --git a/app/models/sale_audit.rb b/app/models/sale_audit.rb index 15fee460..cce6982d 100644 --- a/app/models/sale_audit.rb +++ b/app/models/sale_audit.rb @@ -1,4 +1,6 @@ class SaleAudit < ApplicationRecord +#primary key - need to be unique generated for multiple shops + belongs_to :sale def record_audit_void(sale_id, void_by, approved_by, reason) diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index 82b20237..c92ed48f 100644 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -1,4 +1,6 @@ class SaleItem < ApplicationRecord +#primary key - need to be unique generated for multiple shops + belongs_to :sale #compute items - discount, tax, price_change diff --git a/app/models/sale_order.rb b/app/models/sale_order.rb index 7a27f5a3..23fd39bd 100644 --- a/app/models/sale_order.rb +++ b/app/models/sale_order.rb @@ -1,4 +1,6 @@ class SaleOrder < ApplicationRecord +#primary key - need to be unique generated for multiple shops + belongs_to :sale belongs_to :order end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 71793f4c..2f7b72ea 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -1,4 +1,6 @@ class SalePayment < ApplicationRecord +#primary key - need to be unique generated for multiple shops + belongs_to :sale :attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status diff --git a/app/models/sale_tax.rb b/app/models/sale_tax.rb index cb3fae0b..6e0a2d47 100644 --- a/app/models/sale_tax.rb +++ b/app/models/sale_tax.rb @@ -1,3 +1,5 @@ class SaleTax < ApplicationRecord +#primary key - need to be unique generated for multiple shops + belongs_to :sale end diff --git a/app/models/seed_generator.rb b/app/models/seed_generator.rb index 573e0ff6..4351e74b 100644 --- a/app/models/seed_generator.rb +++ b/app/models/seed_generator.rb @@ -1,4 +1,23 @@ class SeedGenerator < ApplicationRecord + def self.generate_id(model, prefix) + seed = SeedGenerator.find_by_model(model) + new_receipt_no = 0 + if (seed.nil?) + seed = SeedGenerator.new() + seed.model = model + new_receipt_no = seed.next + seed.save + + else + current_no = seed.next + seed.next = seed.next + seed.increase_by + seed.current = current_no + seed.save + end + + return prefix + "-" + seed.current.to_s + end + def self.new_receipt_no seed = SeedGenerator.find_by_model("sale") new_receipt_no = 0 diff --git a/app/models/shop.rb b/app/models/shop.rb new file mode 100644 index 00000000..1cf1119c --- /dev/null +++ b/app/models/shop.rb @@ -0,0 +1,2 @@ +class Shop < ApplicationRecord +end diff --git a/db/migrate/20170403163734_create_sale_payments.rb b/db/migrate/20170403163734_create_sale_payments.rb index dd440036..3da5cb17 100644 --- a/db/migrate/20170403163734_create_sale_payments.rb +++ b/db/migrate/20170403163734_create_sale_payments.rb @@ -7,7 +7,7 @@ class CreateSalePayments < ActiveRecord::Migration[5.0] t.decimal :outstanding_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.string :payment_reference t.string :payment_status, :null => false, :default => "new" - + t.timestamps end end diff --git a/db/migrate/20170408105938_create_seed_generators.rb b/db/migrate/20170408105938_create_seed_generators.rb index 6ccf669f..eb58749a 100644 --- a/db/migrate/20170408105938_create_seed_generators.rb +++ b/db/migrate/20170408105938_create_seed_generators.rb @@ -5,7 +5,6 @@ class CreateSeedGenerators < ActiveRecord::Migration[5.0] t.integer :increase_by, :null => false, :default => 1 t.bigint :current, :null => false ,:default => 1 t.bigint :next, :null => false, :default => 2 - t.timestamps end end diff --git a/db/migrate/20170530072247_create_shops.rb b/db/migrate/20170530072247_create_shops.rb new file mode 100644 index 00000000..25de6c6a --- /dev/null +++ b/db/migrate/20170530072247_create_shops.rb @@ -0,0 +1,25 @@ +class CreateShops < ActiveRecord::Migration[5.1] + def change + create_table :shops do |t| + t.string :logo + t.string :name, :null => false + t.string :address, :null => false + t.string :township, :null => false + t.string :city, :null => false + t.string :state, :null => false + t.string :country, :null => false + t.string :phone_no, :null => false + t.string :reserviation_no, :null => false + t.string :license, :null => false + t.datetime :activated_at, :null => false + t.text :license_data, :null => false + t.string :base_currency, :null => false, :limit => 3 + t.string :cloud_url + t.string :cloud_token + t.string :owner_token + t.string :id_prefix, :null => false, :limit => 3 + + t.timestamps + end + end +end diff --git a/spec/models/shop_spec.rb b/spec/models/shop_spec.rb new file mode 100644 index 00000000..9fd43ff8 --- /dev/null +++ b/spec/models/shop_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Shop, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 0b8ec2297682c3cf8583708766d0758ace5ad810 Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 31 May 2017 13:42:44 +0630 Subject: [PATCH 05/39] deleted queue_items --- app/controllers/oqs/home_controller.rb | 7 +++++++ app/views/oqs/home/index.html.erb | 19 ++++++++++++++----- dump.rdb | Bin 485 -> 1669 bytes 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index acf99e41..07f12b93 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -1,5 +1,12 @@ class Oqs::HomeController < BaseOqsController def index + @queue_stations=OrderQueueStation.all + + # @queue_stations.each do |que| + # Contact.find(:all, :joins => ['left join sales s on s.customer_id = contacts.id'], :conditions => ["contact_type = 'Customer' AND name IS NOT NULL"],:group => ["contacts.id"]) + # AssignedOrderItem.find(:all, :conditions=>["order_queue_station_id=#{que.id}"], :group => ["order_queue_station_id"]) + # # AssignedOrderItem.where("order_queue_station_id = :que_id", {:que_id => que_id}).get + # end end def show end diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 35815331..1f449cbc 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -4,18 +4,27 @@

@@ -67,7 +76,7 @@ -
+
diff --git a/dump.rdb b/dump.rdb index 96c96478436694a7da4fdb143daf16a6e2e802f7..b931754d4d0d6c1b83a8ccc4d623c8f56f2121e8 100644 GIT binary patch literal 1669 zcmY*a-*4Mj6~DIQ{7%-isMCtJd}C)>qvU$`_YV&=yWJG6h;7h^g4opDpTWb4Q`;Fu zm7$X=-uNLJZ-bCH)3zdQ(j;CGkI{HQyZ}}IfqZd^Kvd!dAylLcx7!1Iy7%1k<8wYo z=bZcX=bwAwB0@;sA8Q6*Yr)q;GfzvTr0hY-QZH&$QEUEVP3hxx|TX0z64*4p1IlsC5O_0=B? zZLNomcICzt(XTES!qwom+O@_;GBbjf3-yLG^~$+i*eG<8CvwfuZYE#KwVPWZxw-n& zN39_?A{;OaPGU`s&`~00k{ge^W-#sGFPnCujF}dgNv3p3Ga{H`NgZsg-a4F2hLt9r zdb81Z!$OeISneSsK|{?fhb(G}FxEMv ziJLpK`k(Zb-dIr9+rYgt$y?)!BI%u^!SUoqdZIUk6qPtV)f+)tQrLCICPB`fNSC@m6;JmU`DwzDMidjz5H=1=9E3N4 zJojWe(H%po#5l!L$fVw%;MbEpVYqYLt!{(2)0OSNO#I7~?mqFS0mVLGvzRbqtrt)^ zm2v0 zdq+F9Ngfe(l5?mCB}IBt8)zc65KC`GaFO76_vt?X*S2|-mc#K`};fNDj;ElVbJ2meZZ3Z5L6uTx!qA6aa597 z_K&BZN#SnRMLB=xgtRg^jJ!oLsK})L+jRbo&RLaV^zPK{{Un3MSDvZu9PO-)Y374= zL_u2o=h9OE&2@7DQMmZX2o6j$6UDiY`b!k>LHc>mWU#vM*Syy*M7K0K#Id6K-t_Gp z!J;((5s<~p>2&vc0(9|*x7Paa5Bemc7hlOos69pVcYs*Dl`*o&$C0JjMJpoq^Dm~R zx8O!(j2s7pi(ek4%o^tjx0M@5<7?*oS)s_%v+2p+;KG((eV5h$v>7}9)dnH zy8QcLiJ(S`6w9N*C>EqgwEA#5Sbv#kr4}fcH`r2YlN|bYo@418E1XHky7TXhijrVL zV5QQ@?jcBkc}Hrcdok1b1e|WQO}iXTtsZ=tAS~ekgP;QdCjL(| r5FdLeZhpFhK5v_V>CY<(SP)Js)Ck*2#YdH^HCADemS%W;6xt<9Aq%5e#d1 zDgoD~t3QjYrerZH`78RUB z7WJ`DS{i=IkNrJ7z5q&s)uk>w>>l(u%Q=&MyszPehA=9qHHF2H$>8H)?lL&5zX^uV nl&}!}5-A~2IX^b%I=15(UfXIC2i0CZp+t{Ycb_kkUxURbn6RK= From 1ed15e2e0d7d753d2356dd399c909a1b0953a42e Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 31 May 2017 13:54:01 +0630 Subject: [PATCH 06/39] pull master --- Gemfile | 3 --- Gemfile.lock | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index bcdb0ab0..23f3c908 100644 --- a/Gemfile +++ b/Gemfile @@ -15,9 +15,6 @@ gem 'mysql2', '>= 0.3.18', '< 0.5' # redis server for cable gem 'redis', '~> 3.0' -#gem pg for -gem 'pg' - # Use Puma as the app server gem 'puma', '~> 3.0' # Use SCSS for stylesheets diff --git a/Gemfile.lock b/Gemfile.lock index 1942950c..829845e5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -233,6 +233,7 @@ DEPENDENCIES jbuilder (~> 2.5) jquery-rails listen (~> 3.0.5) + mysql2 (>= 0.3.18, < 0.5) pg prawn prawn-table From a67c76d945afc76b11932fb021e5930a6832ef39 Mon Sep 17 00:00:00 2001 From: PhyoTheingi Date: Wed, 31 May 2017 18:27:31 +0630 Subject: [PATCH 07/39] Menu 2nd Phrase --- .../settings/menu_categories_controller.rb | 4 +- app/controllers/settings/menus_controller.rb | 7 ++-- .../settings/set_menu_items_controller.rb | 4 +- .../settings/simple_menu_items_controller.rb | 17 ++++---- app/models/menu.rb | 4 +- .../settings/menu_categories/index.html.erb | 1 + .../settings/menu_categories/show.html.erb | 40 ++++++++++++++----- app/views/settings/menus/index.html.erb | 9 +++-- app/views/settings/menus/show.html.erb | 11 ++--- .../settings/simple_menu_items/_form.html.erb | 2 +- .../settings/simple_menu_items/edit.html.erb | 9 ++--- .../settings/simple_menu_items/index.html.erb | 16 +++++--- .../settings/simple_menu_items/show.html.erb | 8 ++-- 13 files changed, 80 insertions(+), 52 deletions(-) diff --git a/app/controllers/settings/menu_categories_controller.rb b/app/controllers/settings/menu_categories_controller.rb index daa76d62..d7f373aa 100644 --- a/app/controllers/settings/menu_categories_controller.rb +++ b/app/controllers/settings/menu_categories_controller.rb @@ -5,7 +5,7 @@ class Settings::MenuCategoriesController < ApplicationController # GET /settings/menu_categories # GET /settings/menu_categories.json def index - @settings_menu_categories = MenuCategory.all + @settings_menu_categories = MenuCategory.all.page(params[:page]).per(10) end # GET /settings/menu_categories/1 @@ -63,7 +63,7 @@ class Settings::MenuCategoriesController < ApplicationController # DELETE /settings/menu_categories/1 # DELETE /settings/menu_categories/1.json def destroy - @settings_menu_category.destroy + # @settings_menu_category.destroy respond_to do |format| format.html { redirect_to settings_menu_categories_path, notice: 'Menu category was successfully destroyed.' } format.json { head :no_content } diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb index b10f31c9..e0ecde30 100644 --- a/app/controllers/settings/menus_controller.rb +++ b/app/controllers/settings/menus_controller.rb @@ -4,12 +4,13 @@ class Settings::MenusController < ApplicationController # GET /settings/menus # GET /settings/menus.json def index - @settings_menus = Menu.all + @settings_menus = Menu.all.page(params[:page]).per(10) end # GET /settings/menus/1 # GET /settings/menus/1.json def show + @settings_menu_categories = @settings_menu.menu_categories.page(params[:page]).per(10) end # GET /settings/menus/new @@ -25,7 +26,7 @@ class Settings::MenusController < ApplicationController # POST /settings/menus.json def create @settings_menu = Menu.new(settings_menu_params) - + @settings_menu.created_by = current_login_employee.name respond_to do |format| if @settings_menu.save format.html { redirect_to settings_menus_path, notice: 'Menu was successfully created.' } @@ -42,7 +43,7 @@ class Settings::MenusController < ApplicationController def update respond_to do |format| if @settings_menu.update(settings_menu_params) - format.html { redirect_to settings_menu_path(@settings_menu), notice: 'Menu was successfully updated.' } + format.html { redirect_to settings_menus_path, notice: 'Menu was successfully updated.' } format.json { render :show, status: :ok, location: @settings_menu } else format.html { render :edit } diff --git a/app/controllers/settings/set_menu_items_controller.rb b/app/controllers/settings/set_menu_items_controller.rb index 1f227246..eb9ea830 100644 --- a/app/controllers/settings/set_menu_items_controller.rb +++ b/app/controllers/settings/set_menu_items_controller.rb @@ -28,7 +28,7 @@ class Settings::SetMenuItemsController < ApplicationController respond_to do |format| if @settings_menu_item.save - format.html { redirect_to settings_menu_items_path, notice: 'Menu item was successfully created.' } + format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully created.' } format.json { render :show, status: :created, location: @settings_menu_item } else format.html { render :new } @@ -42,7 +42,7 @@ class Settings::SetMenuItemsController < ApplicationController def update respond_to do |format| if @settings_menu_item.update(settings_menu_item_params) - format.html { redirect_to settings_menu_item_path(@settings_menu_item), notice: 'Menu item was successfully updated.' } + format.html { redirect_to settings_menu_category_set_menu_items_path(@settings_menu_item), notice: 'Menu item was successfully updated.' } format.json { render :show, status: :ok, location: @settings_menu_item } else format.html { render :edit } diff --git a/app/controllers/settings/simple_menu_items_controller.rb b/app/controllers/settings/simple_menu_items_controller.rb index c9114330..e3ab6714 100644 --- a/app/controllers/settings/simple_menu_items_controller.rb +++ b/app/controllers/settings/simple_menu_items_controller.rb @@ -1,12 +1,12 @@ class Settings::SimpleMenuItemsController < ApplicationController before_action :set_settings_menu_item, only: [:show, :edit, :update, :destroy] - before_action :set_settings_menu_category, only: [:index, :show, :edit, :new] + before_action :set_settings_menu_category, only: [:index, :show, :edit, :new, :update] # GET /settings/menu_items # GET /settings/menu_items.json def index @settings_menu_items = @category.menu_items end - + # GET /settings/menu_items/1 # GET /settings/menu_items/1.json def show @@ -25,10 +25,13 @@ class Settings::SimpleMenuItemsController < ApplicationController # POST /settings/menu_items.json def create @settings_menu_item = MenuItem.new(settings_menu_item_params) - + if params[:menu_item_id].nil? + @settings_menu_item.menu_category_id = params[:menu_category_id] + end + @settings_menu_item.created_by = current_login_employee.name respond_to do |format| if @settings_menu_item.save - format.html { redirect_to settings_menu_items_path, notice: 'Menu item was successfully created.' } + format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully created.' } format.json { render :show, status: :created, location: @settings_menu_item } else format.html { render :new } @@ -42,7 +45,7 @@ class Settings::SimpleMenuItemsController < ApplicationController def update respond_to do |format| if @settings_menu_item.update(settings_menu_item_params) - format.html { redirect_to settings_menu_item_path(@settings_menu_item), notice: 'Menu item was successfully updated.' } + format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully updated.' } format.json { render :show, status: :ok, location: @settings_menu_item } else format.html { render :edit } @@ -54,9 +57,9 @@ class Settings::SimpleMenuItemsController < ApplicationController # DELETE /settings/menu_items/1 # DELETE /settings/menu_items/1.json def destroy - @settings_menu_item.destroy + # @settings_menu_item.destroy respond_to do |format| - format.html { redirect_to settings_menu_items_path, notice: 'Menu item was successfully destroyed.' } + format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully destroyed.' } format.json { head :no_content } end end diff --git a/app/models/menu.rb b/app/models/menu.rb index 44daca13..ac9ea4d3 100644 --- a/app/models/menu.rb +++ b/app/models/menu.rb @@ -1,8 +1,8 @@ class Menu < ApplicationRecord has_many :menu_categories, dependent: :destroy - validates_presence_of :name, :is_active, :valid_days, :valid_time_from, :valid_time_to - + validates_presence_of :name, :valid_days, :valid_time_from, :valid_time_to + validates_format_of :valid_days, :with => /\A([0-7]{1}(,[0-7]{1})*)?\Z/i, :on => :create #Default Scope to pull the active version only default_scope { where(is_active: true).order("created_at desc") } diff --git a/app/views/settings/menu_categories/index.html.erb b/app/views/settings/menu_categories/index.html.erb index 4474ae60..495addcc 100644 --- a/app/views/settings/menu_categories/index.html.erb +++ b/app/views/settings/menu_categories/index.html.erb @@ -40,3 +40,4 @@ + <%= paginate @settings_menu_categories, param_name: :page, :outer_window => 3 %> diff --git a/app/views/settings/menu_categories/show.html.erb b/app/views/settings/menu_categories/show.html.erb index f151a356..21885b8b 100644 --- a/app/views/settings/menu_categories/show.html.erb +++ b/app/views/settings/menu_categories/show.html.erb @@ -1,15 +1,12 @@ - - -
+

Menu Category

@@ -47,20 +44,41 @@ <%= link_to "New Simple Menu Item",new_settings_menu_category_simple_menu_item_path(@settings_menu_category),:class => 'btn btn-primary btn-sm' %> <%= link_to "New Set Menu Item",new_settings_menu_category_set_menu_item_path(@settings_menu_category),:class => 'btn btn-primary btn-sm' %> - - - + + + + + + + + - + <% settings_menu_items = @settings_menu_category.menu_items %> + <% settings_menu_items.each do |settings_menu_item| %> + + + + + + + + + + + + + <% end %>
Item code NameAlt nameTypeParent ItemCreated byCreated at
<%= settings_menu_item.item_code %><%= settings_menu_item.name %><%= settings_menu_item.alt_name %><%= settings_menu_item.type %><%= settings_menu_item.parent.name rescue "-" %><%= settings_menu_item.created_by %><%=l settings_menu_item.created_at, :format => :short %><%= link_to 'Show', settings_menu_category_simple_menu_item_path(@settings_menu_category, settings_menu_item ) %><%= link_to 'Edit', edit_settings_menu_category_simple_menu_item_path(@settings_menu_category, settings_menu_item) %><%= link_to 'Destroy', settings_menu_category_simple_menu_item_path(@settings_menu_category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %>
+
-
+ + \ No newline at end of file diff --git a/app/views/settings/menus/index.html.erb b/app/views/settings/menus/index.html.erb index 47c031ca..1f1bf994 100644 --- a/app/views/settings/menus/index.html.erb +++ b/app/views/settings/menus/index.html.erb @@ -2,9 +2,8 @@ + <%= paginate @settings_menus, param_name: :page, :outer_window => 3 %> diff --git a/app/views/settings/menus/show.html.erb b/app/views/settings/menus/show.html.erb index 34b2c3c0..28efe8af 100644 --- a/app/views/settings/menus/show.html.erb +++ b/app/views/settings/menus/show.html.erb @@ -1,8 +1,8 @@ +<%= paginate @settings_menu_categories, param_name: :page, :outer_window => 3 %> diff --git a/app/views/settings/simple_menu_items/_form.html.erb b/app/views/settings/simple_menu_items/_form.html.erb index 836f3f61..d187847a 100644 --- a/app/views/settings/simple_menu_items/_form.html.erb +++ b/app/views/settings/simple_menu_items/_form.html.erb @@ -1,4 +1,4 @@ -<%= simple_form_for([:settings,:menu_category, @settings_menu_item]) do |f| %> +<%= simple_form_for([:settings,@category, @settings_menu_item]) do |f| %> <%= f.error_notification %>
diff --git a/app/views/settings/simple_menu_items/edit.html.erb b/app/views/settings/simple_menu_items/edit.html.erb index 40c675ef..5d4d9b8e 100644 --- a/app/views/settings/simple_menu_items/edit.html.erb +++ b/app/views/settings/simple_menu_items/edit.html.erb @@ -1,17 +1,14 @@ +<%= render 'form', settings_menu_item: @settings_menu_item %>-->
- <%= render 'form', settings_menu_item: @settings_menu_item %> + <%= render 'form', settings_simple_menu_item: @settings_menu_item %>
diff --git a/app/views/settings/simple_menu_items/index.html.erb b/app/views/settings/simple_menu_items/index.html.erb index 89fc850f..6de3d619 100644 --- a/app/views/settings/simple_menu_items/index.html.erb +++ b/app/views/settings/simple_menu_items/index.html.erb @@ -5,7 +5,7 @@
  • Menu Items
  • - <%= link_to t('.new', :default => t("helpers.links.new")),new_settings_menu_category_menu_item_path(@category),:class => 'btn btn-primary btn-sm' %> + <%= link_to t('.new', :default => t("helpers.links.new")),new_settings_menu_category_simple_menu_item_path(@category),:class => 'btn btn-primary btn-sm' %>
    @@ -40,7 +40,13 @@
    -

    Menu Items

    +

    Menu Items + + <%= link_to "New Simple Menu Item",new_settings_menu_category_simple_menu_item_path(@category),:class => 'btn btn-primary btn-sm' %> + <%= link_to "New Set Menu Item",new_settings_menu_category_set_menu_item_path(@category),:class => 'btn btn-primary btn-sm' %> + +

    +

    <%= @settings_menu_items.count %>

    @@ -67,9 +73,9 @@ - - - + + + <% end %> diff --git a/app/views/settings/simple_menu_items/show.html.erb b/app/views/settings/simple_menu_items/show.html.erb index 66ae3e84..f69c83d4 100644 --- a/app/views/settings/simple_menu_items/show.html.erb +++ b/app/views/settings/simple_menu_items/show.html.erb @@ -36,13 +36,13 @@ - - - + + + - +
    <%= settings_menu_item.created_by %> <%=l settings_menu_item.created_at, :format => :short %><%= link_to 'Show', settings_menu_category_menu_item_path(@category, settings_menu_item ) %><%= link_to 'Edit', edit_settings_menu_category_menu_item_path(@category, settings_menu_item) %><%= link_to 'Destroy', settings_menu_category_menu_item_path(@category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %><%= link_to 'Show', settings_menu_category_simple_menu_item_path(@category, settings_menu_item ) %><%= link_to 'Edit', edit_settings_menu_category_simple_menu_item_path(@category, settings_menu_item) %><%= link_to 'Destroy', settings_menu_category_simple_menu_item_path(@category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %>
    <%= @settings_menu_item.name rescue "-" %> <%= @settings_menu_item.alt_name %> <%= @settings_menu_item.type %><%= @settings_menu_item.menu_category %><%= @settings_menu_item.menu_item %><%= @settings_menu_item.menu_qty %><%= @settings_menu_item.menu_category_id %><%= @settings_menu_item.menu_item_id %><%= @settings_menu_item.min_qty %> <%= @settings_menu_item.min_selectable_item %> <%= @settings_menu_item.max_selectable_item %> <%=l @settings_menu_item.created_at, format: :short %><%= link_to 'Edit', edit_settings_menu_menu_item_path(@settings_menu_category, @settings_menu_category) %><%= link_to 'Edit', edit_settings_menu_category_simple_menu_item_path(@category, @settings_menu_item) %>
    From 5a564abca92785e1ba29cf95c5f591b7edef1fed Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 31 May 2017 22:14:46 +0630 Subject: [PATCH 08/39] oqs sample --- Gemfile | 4 +- Gemfile.lock | 2 - app/assets/javascripts/OQS.js | 20 ++ app/controllers/oqs/home_controller.rb | 26 +- app/models/order_queue_item.rb | 13 + app/models/order_queue_station.rb | 5 +- app/models/test.rb | 2 + app/views/oqs/home/index.html.erb | 329 +++--------------- ...0170531093542_create_order_queue_items.rb} | 0 spec/models/test_spec.rb | 5 + 10 files changed, 126 insertions(+), 280 deletions(-) create mode 100644 app/models/test.rb rename db/migrate/{20170531070951_create_order_queue_items.rb => 20170531093542_create_order_queue_items.rb} (100%) create mode 100644 spec/models/test_spec.rb diff --git a/Gemfile b/Gemfile index 23f3c908..789e27f3 100644 --- a/Gemfile +++ b/Gemfile @@ -9,8 +9,8 @@ end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.0' # Use mysql as the database for Active Record -gem 'mysql2', '>= 0.3.18', '< 0.5' -#gem 'pg' +# gem 'mysql2', '>= 0.3.18', '< 0.5' +gem 'pg' # redis server for cable gem 'redis', '~> 3.0' diff --git a/Gemfile.lock b/Gemfile.lock index 829845e5..9d85889c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,7 +96,6 @@ GEM mini_portile2 (2.1.0) minitest (5.10.2) multi_json (1.12.1) - mysql2 (0.4.6) nio4r (2.1.0) nokogiri (1.7.2) mini_portile2 (~> 2.1.0) @@ -233,7 +232,6 @@ DEPENDENCIES jbuilder (~> 2.5) jquery-rails listen (~> 3.0.5) - mysql2 (>= 0.3.18, < 0.5) pg prawn prawn-table diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index fc91e269..091b6822 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -15,3 +15,23 @@ //= require jquery_ujs //= require turbolinks //= require cable + +$(document).ready(function(){ + $('.queue_station').on('click',function(){ + var title=$(this).children().children('.card-title').text(); + var titles=title.split(' '); + + var orderBy=$(this).children().children().children().children('.order-by').text(); + var orderAt=$(this).children().children().children().children('.order-at').text(); + var orderCustomer=$(this).children().children('.order-customer').text(); + + $('#order-title').text($('#order-title').text() + titles[0]); + $('#order-by').text(orderBy); + $('#order-at').text(orderAt); + $('#order-customer').text(orderCustomer); + $('#order-from').text(titles[0]); + + $('#order-items').text(titles[1]); + $('#order-qty').text(titles[2].substr(2).replace(']','')); + }); +}); diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 07f12b93..356508c4 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -2,12 +2,34 @@ class Oqs::HomeController < BaseOqsController def index @queue_stations=OrderQueueStation.all + #sample Data + @queue_items_details = { :queue_id => 1, :order_id => 1, :station_name => 'Queue Station 1', :zone => 'Table4', :item_name => 'beef', :price => 10.00, :qty => 2, :customer => 'Wathon', :item_order_by => 'Yan', :created_at => '2007-05-17'} + # @queue_items_details = OrderItem.select("oqs as queue_id, oqs.station_name, oqs.is_active, oqpz.zone_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.created_at") + # .joins("join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = order_queue_items.order_queue_station_id") + # .joins("right join order_queue_stations as oqs ON oqs.id = order_queue_items.order_queue_station_id") + # .joins("right join orders as od ON od.id = order_queue_items.order_id") + # .joins("right join order_items as odt ON odt.item_code = order_queue_items.item_code") + # .order("odt.item_name DESC") + + # puts @queue_items_details # @queue_stations.each do |que| - # Contact.find(:all, :joins => ['left join sales s on s.customer_id = contacts.id'], :conditions => ["contact_type = 'Customer' AND name IS NOT NULL"],:group => ["contacts.id"]) - # AssignedOrderItem.find(:all, :conditions=>["order_queue_station_id=#{que.id}"], :group => ["order_queue_station_id"]) + # zone_id = OrderQueueProcessByZone.where('order_queue_station_id=#{que.id}').select(:zone_id).take + # type = DiningFacility.find_by_zone_id(zone_id).select(:type).take + # end + # @queue_items_details = { :queue_id, :zone_id, :item_code, :item_name, :item_options, :price, :qty, :order_by, :order_at } + # @queue_stations.each do |que| + # # Contact.find(:all, :joins => ['left join sales s on s.customer_id = contacts.id'], :conditions => ["contact_type = 'Customer' AND name IS NOT NULL"],:group => ["contacts.id"]) + # assigned_items=AssignedOrderItem.find(:all, :conditions=>["order_queue_station_id = #{que.id}"], :group => ["order_queue_station_id"]) + # assigned_items.each do |ass_items| + # order_item_details=OrderItems.joins('left join order').where("item_code = #{ ass_items.item_code } AND order_item_status = 1") + # end # # AssignedOrderItem.where("order_queue_station_id = :que_id", {:que_id => que_id}).get # end end + def show end end + + + diff --git a/app/models/order_queue_item.rb b/app/models/order_queue_item.rb index 7f94fbec..fed1139d 100644 --- a/app/models/order_queue_item.rb +++ b/app/models/order_queue_item.rb @@ -1,2 +1,15 @@ class OrderQueueItem < ApplicationRecord + belongs_to :order + belongs_to :order_queue_station + + def self.add_order_item (order, item_code, order_queue_station ) + order_queue_item = OrderQueueItem.new() + order_queue_item.order = order + order_queue_item.item_code = item_code + order_queue_item.order_queue_station = order_queue_station + order_queue_item.print_status = false + order_queue_item.delivery_status = false + order_queue_item.queue_status = true + order_queue_item.save + end end diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index b2feb596..ffd7e110 100644 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -8,7 +8,7 @@ class OrderQueueStation < ApplicationRecord scope :active, -> {where(is_active: true)} - def process_order (order) + def process_order (order) oqs_stations = OrderQueueStation.active order_items = order.order_items @@ -20,10 +20,11 @@ class OrderQueueStation < ApplicationRecord #Loop through the processing items pq_items.each do |pq_item| #Processing through the looping items - order_items.each do |order_item| + order_items.each do |order_item| if (pq_item == order_item.item_code) #Same Order_items can appear in two location. AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) + OrderQueueItem.add_order_item(order, order_item.item_code, oqs) end end diff --git a/app/models/test.rb b/app/models/test.rb new file mode 100644 index 00000000..fe0afa77 --- /dev/null +++ b/app/models/test.rb @@ -0,0 +1,2 @@ +class Test < ApplicationRecord +end diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 1f449cbc..24fa00d0 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -6,31 +6,25 @@
    -
    +
    @@ -41,11 +35,9 @@ Printed at 12:23 | Completed at 12:43

    - -
    -
    + -
    - -
    -
    -
    -

    1. Table 4 - Beef Steak [x1]

    -

    Medium, Fries, Salad

    -

    Order at 12:23, Kyaw Lwin

    -
    - -
    - - -
    -
    - - -
    - -
    -
    -
    -

    Card title that wraps to a new line

    -

    This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

    -
    -
    -
    -
    -

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

    -
    - - Someone famous in Source Title - -
    -
    -
    -
    -
    -

    Card title

    -

    This card has supporting text below as a natural lead-in to additional content.

    -

    Last updated 3 mins ago

    -
    -
    -
    -
    -

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat.

    -
    - - Someone famous in Source Title - -
    -
    -
    -
    -
    -

    Card title

    -

    This card has supporting text below as a natural lead-in to additional content.

    -

    Last updated 3 mins ago

    -
    -
    -
    - - -
    - -
    -
    -
    -

    Card title that wraps to a new line

    -

    This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

    -

    Last updated 3 mins ago

    + <% + @queue_stations.each do |que| + %> + +
    role="tabpanel"> + +
    + <% + if @queue_items_details[:station_name] == que.station_name + %> +
    +
    +

    <%= @queue_items_details[:zone] + ' ' + @queue_items_details[:item_name] + ' [x' + @queue_items_details[:qty].to_s + ']' %>

    +

    Medium, Fries, Salad

    +

    + Order at + + <%= @queue_items_details[:created_at] %> + - + + <%= @queue_items_details[:item_order_by] %> + + +

    + +
    + +
    + <% + end + %> +
    -
    -
    -

    Card title

    -

    This card has supporting text below as a natural lead-in to additional content.

    -

    Last updated 3 mins ago

    -
    -
    - -
    -
    -

    Card title

    -

    This card has supporting text below as a natural lead-in to additional content.

    -

    Last updated 3 mins ago

    -
    -
    -
    - - -
    - + + <% end %>
    @@ -318,7 +103,7 @@
    -
    ORDER DETAILS - Table 4
    +
    ORDER DETAILS -
    @@ -332,13 +117,13 @@ - Kyaw Lwin - 20/04/17 9:30PM - John Smith + Kyaw Lwin + 20/04/17 9:30PM + John Smith Table/Room - Table 4 + @@ -355,12 +140,12 @@ - - diff --git a/db/migrate/20170531070951_create_order_queue_items.rb b/db/migrate/20170531093542_create_order_queue_items.rb similarity index 100% rename from db/migrate/20170531070951_create_order_queue_items.rb rename to db/migrate/20170531093542_create_order_queue_items.rb diff --git a/spec/models/test_spec.rb b/spec/models/test_spec.rb new file mode 100644 index 00000000..2b626b06 --- /dev/null +++ b/spec/models/test_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Test, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 44c4dd0d78e01029a2284b1bd5f45ed13d9967ae Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 31 May 2017 22:16:55 +0630 Subject: [PATCH 09/39] nothing change --- Gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index 789e27f3..3d31db9c 100644 --- a/Gemfile +++ b/Gemfile @@ -10,6 +10,8 @@ end gem 'rails', '~> 5.1.0' # Use mysql as the database for Active Record # gem 'mysql2', '>= 0.3.18', '< 0.5' + +#Use PosgreSQL gem 'pg' # redis server for cable From 4271681638f973e68ba6afea7072390f5ac9cf66 Mon Sep 17 00:00:00 2001 From: Min Zeya Phyo Date: Thu, 1 Jun 2017 10:49:20 +0800 Subject: [PATCH 10/39] Support both mysql and pg --- Gemfile | 2 +- Gemfile.lock | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index d64ba992..29d7238a 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.0' # Use mysql as the database for Active Record -#gem 'mysql2', '>= 0.3.18', '< 0.5' +gem 'mysql2', '>= 0.3.18', '< 0.5' gem 'pg' # Use Puma as the app server gem 'puma', '~> 3.0' diff --git a/Gemfile.lock b/Gemfile.lock index ccd4aef2..878496fc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -233,6 +233,7 @@ DEPENDENCIES jbuilder (~> 2.5) jquery-rails listen (~> 3.0.5) + mysql2 (>= 0.3.18, < 0.5) pg prawn prawn-table From 03bf7997084cbb65de1b811b75a284ada2bada98 Mon Sep 17 00:00:00 2001 From: PhyoTheingi Date: Thu, 1 Jun 2017 10:03:07 +0630 Subject: [PATCH 11/39] Set_item Create --- .../settings/set_menu_items_controller.rb | 17 ++++++++++------- .../settings/simple_menu_items_controller.rb | 2 +- .../settings/set_menu_items/_form.html.erb | 7 +++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/controllers/settings/set_menu_items_controller.rb b/app/controllers/settings/set_menu_items_controller.rb index eb9ea830..438b2f08 100644 --- a/app/controllers/settings/set_menu_items_controller.rb +++ b/app/controllers/settings/set_menu_items_controller.rb @@ -1,12 +1,12 @@ class Settings::SetMenuItemsController < ApplicationController before_action :set_settings_menu_item, only: [:show, :edit, :update, :destroy] - before_action :set_settings_menu_category, only: [:index, :show, :edit, :new] + before_action :set_settings_menu_category, only: [:index, :show, :edit, :new, :update] # GET /settings/menu_items # GET /settings/menu_items.json def index @settings_menu_items = @category.menu_items end - + # GET /settings/menu_items/1 # GET /settings/menu_items/1.json def show @@ -25,7 +25,10 @@ class Settings::SetMenuItemsController < ApplicationController # POST /settings/menu_items.json def create @settings_menu_item = MenuItem.new(settings_menu_item_params) - + if params[:simple_menu_item][:menu_item_id] == '' + @settings_menu_item.menu_category_id = params[:menu_category_id] + end + @settings_menu_item.created_by = current_login_employee.name respond_to do |format| if @settings_menu_item.save format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully created.' } @@ -42,7 +45,7 @@ class Settings::SetMenuItemsController < ApplicationController def update respond_to do |format| if @settings_menu_item.update(settings_menu_item_params) - format.html { redirect_to settings_menu_category_set_menu_items_path(@settings_menu_item), notice: 'Menu item was successfully updated.' } + format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully updated.' } format.json { render :show, status: :ok, location: @settings_menu_item } else format.html { render :edit } @@ -54,9 +57,9 @@ class Settings::SetMenuItemsController < ApplicationController # DELETE /settings/menu_items/1 # DELETE /settings/menu_items/1.json def destroy - @settings_menu_item.destroy + # @settings_menu_item.destroy respond_to do |format| - format.html { redirect_to settings_menu_items_path, notice: 'Menu item was successfully destroyed.' } + format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully destroyed.' } format.json { head :no_content } end end @@ -73,6 +76,6 @@ class Settings::SetMenuItemsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_menu_item_params - params.require(:menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by) + params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by) end end diff --git a/app/controllers/settings/simple_menu_items_controller.rb b/app/controllers/settings/simple_menu_items_controller.rb index e3ab6714..e81d6817 100644 --- a/app/controllers/settings/simple_menu_items_controller.rb +++ b/app/controllers/settings/simple_menu_items_controller.rb @@ -25,7 +25,7 @@ class Settings::SimpleMenuItemsController < ApplicationController # POST /settings/menu_items.json def create @settings_menu_item = MenuItem.new(settings_menu_item_params) - if params[:menu_item_id].nil? + if params[:simple_menu_item][:menu_item_id] == '' @settings_menu_item.menu_category_id = params[:menu_category_id] end @settings_menu_item.created_by = current_login_employee.name diff --git a/app/views/settings/set_menu_items/_form.html.erb b/app/views/settings/set_menu_items/_form.html.erb index 27127684..bdf0e97e 100644 --- a/app/views/settings/set_menu_items/_form.html.erb +++ b/app/views/settings/set_menu_items/_form.html.erb @@ -1,4 +1,4 @@ -<%= simple_form_for([:setting, @settings_menu_item]) do |f| %> +<%= simple_form_for([:settings,@category, @settings_menu_item]) do |f| %> <%= f.error_notification %>
    @@ -6,12 +6,11 @@ <%= f.input :name %> <%= f.input :alt_name %> <%= f.input :type %> - <%= f.association :menu_category %> - <%= f.association :menu_item %> + <%= f.input :menu_item_id, :label => "Parent Menu Item", :collection => MenuItem.collection %> + <%= f.input :min_qty %> <%= f.input :min_selectable_item %> <%= f.input :max_selectable_item %> - <%= f.input :created_by %>
    From 2a323c8d0d9174f619332914e6a118663e0bc02c Mon Sep 17 00:00:00 2001 From: Yan Date: Thu, 1 Jun 2017 12:07:27 +0630 Subject: [PATCH 12/39] deleted order queue item --- Gemfile | 9 ++++---- Gemfile.lock | 23 ++++++++++++++++++- app/models/order.rb | 2 +- app/models/order_queue_item.rb | 15 ------------ app/models/order_queue_station.rb | 3 +-- ...20170531093542_create_order_queue_items.rb | 13 ----------- 6 files changed, 29 insertions(+), 36 deletions(-) delete mode 100644 app/models/order_queue_item.rb delete mode 100644 db/migrate/20170531093542_create_order_queue_items.rb diff --git a/Gemfile b/Gemfile index e5a86c8e..f3664096 100644 --- a/Gemfile +++ b/Gemfile @@ -9,16 +9,14 @@ end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.0' # Use mysql as the database for Active Record -# gem 'mysql2', '>= 0.3.18', '< 0.5' +gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL -gem 'pg' +#gem 'pg' # redis server for cable gem 'redis', '~> 3.0' -gem 'mysql2', '>= 0.3.18', '< 0.5' - # Use Puma as the app server gem 'puma', '~> 3.0' # Use SCSS for stylesheets @@ -45,6 +43,9 @@ gem 'to_xls-rails' #Reporting gem #gem 'compendium' +# Pagination +gem 'kaminari', :git => "git://github.com/amatsuda/kaminari.git", :branch => 'master' + # Use jquery as the JavaScript library gem 'jquery-rails' diff --git a/Gemfile.lock b/Gemfile.lock index a63a5ab4..0c3a3a27 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,21 @@ +GIT + remote: git://github.com/amatsuda/kaminari.git + revision: c3c853a944cd2bff072ae05e48c563b2c9a29597 + branch: master + specs: + kaminari (1.0.1) + activesupport (>= 4.1.0) + kaminari-actionview (= 1.0.1) + kaminari-activerecord (= 1.0.1) + kaminari-core (= 1.0.1) + kaminari-actionview (1.0.1) + actionview + kaminari-core (= 1.0.1) + kaminari-activerecord (1.0.1) + activerecord + kaminari-core (= 1.0.1) + kaminari-core (1.0.1) + GEM remote: https://rubygems.org/ specs: @@ -96,11 +114,12 @@ GEM mini_portile2 (2.1.0) minitest (5.10.2) multi_json (1.12.1) - nio4r (2.1.0) mysql2 (0.4.6) + nio4r (2.1.0) nokogiri (1.7.2) mini_portile2 (~> 2.1.0) pdf-core (0.7.0) + pg (0.20.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) @@ -231,8 +250,10 @@ DEPENDENCIES font-awesome-rails jbuilder (~> 2.5) jquery-rails + kaminari! listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) + pg prawn prawn-table puma (~> 3.0) diff --git a/app/models/order.rb b/app/models/order.rb index c638c3c6..3f74284f 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -209,6 +209,7 @@ class Order < ApplicationRecord def send_order_broadcast #Send to background job for processing OrderBroadcastJob.perform_later(self.id) + end #Origami: Cashier : to view order type Table def self.get_order_table @@ -242,6 +243,5 @@ class Order < ApplicationRecord left join order_items on order_items.order_id = orders.id") .where("dining_facilities.is_active=?",true) .group("orders.id") ->>>>>>> 47469cf466f1464fa4289e78c68b60e279174c60 end end diff --git a/app/models/order_queue_item.rb b/app/models/order_queue_item.rb deleted file mode 100644 index fed1139d..00000000 --- a/app/models/order_queue_item.rb +++ /dev/null @@ -1,15 +0,0 @@ -class OrderQueueItem < ApplicationRecord - belongs_to :order - belongs_to :order_queue_station - - def self.add_order_item (order, item_code, order_queue_station ) - order_queue_item = OrderQueueItem.new() - order_queue_item.order = order - order_queue_item.item_code = item_code - order_queue_item.order_queue_station = order_queue_station - order_queue_item.print_status = false - order_queue_item.delivery_status = false - order_queue_item.queue_status = true - order_queue_item.save - end -end diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index ffd7e110..b0619af2 100644 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -23,8 +23,7 @@ class OrderQueueStation < ApplicationRecord order_items.each do |order_item| if (pq_item == order_item.item_code) #Same Order_items can appear in two location. - AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) - OrderQueueItem.add_order_item(order, order_item.item_code, oqs) + AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) end end diff --git a/db/migrate/20170531093542_create_order_queue_items.rb b/db/migrate/20170531093542_create_order_queue_items.rb deleted file mode 100644 index 1ebc1c94..00000000 --- a/db/migrate/20170531093542_create_order_queue_items.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateOrderQueueItems < ActiveRecord::Migration[5.1] - def change - create_table :order_queue_items do |t| - t.string :item_code, :null => false, :index => true - t.references :order_queue_station, foreign_key: true - t.references :order, foreign_key: true - t.boolean :print_status - t.boolean :delivery_status - t.boolean :queue_status - t.timestamps - end - end -end From 0a223a03f588f78210530eb0892c45ef92984f2f Mon Sep 17 00:00:00 2001 From: Nweni Date: Thu, 1 Jun 2017 13:12:36 +0630 Subject: [PATCH 13/39] remove order_queue_item --- app/models/order_queue_item.rb | 2 -- .../20170531070951_create_order_queue_items.rb | 13 ------------- 2 files changed, 15 deletions(-) delete mode 100644 app/models/order_queue_item.rb delete mode 100644 db/migrate/20170531070951_create_order_queue_items.rb diff --git a/app/models/order_queue_item.rb b/app/models/order_queue_item.rb deleted file mode 100644 index 7f94fbec..00000000 --- a/app/models/order_queue_item.rb +++ /dev/null @@ -1,2 +0,0 @@ -class OrderQueueItem < ApplicationRecord -end diff --git a/db/migrate/20170531070951_create_order_queue_items.rb b/db/migrate/20170531070951_create_order_queue_items.rb deleted file mode 100644 index 1ebc1c94..00000000 --- a/db/migrate/20170531070951_create_order_queue_items.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateOrderQueueItems < ActiveRecord::Migration[5.1] - def change - create_table :order_queue_items do |t| - t.string :item_code, :null => false, :index => true - t.references :order_queue_station, foreign_key: true - t.references :order, foreign_key: true - t.boolean :print_status - t.boolean :delivery_status - t.boolean :queue_status - t.timestamps - end - end -end From a7d7260157f0402ce9d71e4c2700a79f282d8282 Mon Sep 17 00:00:00 2001 From: PhyoTheingi Date: Thu, 1 Jun 2017 14:00:08 +0630 Subject: [PATCH 14/39] Bug Fix --- app/controllers/settings/set_menu_items_controller.rb | 3 ++- app/controllers/settings/simple_menu_items_controller.rb | 2 +- app/models/menu.rb | 2 +- app/views/settings/set_menu_items/edit.html.erb | 2 +- app/views/settings/set_menu_items/index.html.erb | 3 ++- app/views/settings/set_menu_items/new.html.erb | 2 +- app/views/settings/set_menu_items/show.html.erb | 4 ++-- app/views/settings/simple_menu_items/edit.html.erb | 2 +- app/views/settings/simple_menu_items/index.html.erb | 4 ++-- app/views/settings/simple_menu_items/new.html.erb | 2 +- app/views/settings/simple_menu_items/show.html.erb | 2 +- 11 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/controllers/settings/set_menu_items_controller.rb b/app/controllers/settings/set_menu_items_controller.rb index 438b2f08..b488ac6f 100644 --- a/app/controllers/settings/set_menu_items_controller.rb +++ b/app/controllers/settings/set_menu_items_controller.rb @@ -4,7 +4,7 @@ class Settings::SetMenuItemsController < ApplicationController # GET /settings/menu_items # GET /settings/menu_items.json def index - @settings_menu_items = @category.menu_items + @settings_menu_items = @category.menu_items.page(params[:page]).per(10) end # GET /settings/menu_items/1 @@ -15,6 +15,7 @@ class Settings::SetMenuItemsController < ApplicationController # GET /settings/menu_items/new def new @settings_menu_item = MenuItem.new + @settings_menu_item.type = "SetMenuItem" end # GET /settings/menu_items/1/edit diff --git a/app/controllers/settings/simple_menu_items_controller.rb b/app/controllers/settings/simple_menu_items_controller.rb index e81d6817..6b3c4bb4 100644 --- a/app/controllers/settings/simple_menu_items_controller.rb +++ b/app/controllers/settings/simple_menu_items_controller.rb @@ -4,7 +4,7 @@ class Settings::SimpleMenuItemsController < ApplicationController # GET /settings/menu_items # GET /settings/menu_items.json def index - @settings_menu_items = @category.menu_items + @settings_menu_items = @category.menu_items.page(params[:page]).per(10) end # GET /settings/menu_items/1 diff --git a/app/models/menu.rb b/app/models/menu.rb index ac9ea4d3..0c956a1e 100644 --- a/app/models/menu.rb +++ b/app/models/menu.rb @@ -2,7 +2,7 @@ class Menu < ApplicationRecord has_many :menu_categories, dependent: :destroy validates_presence_of :name, :valid_days, :valid_time_from, :valid_time_to - validates_format_of :valid_days, :with => /\A([0-7]{1}(,[0-7]{1})*)?\Z/i, :on => :create + validates_format_of :valid_days, :with => /\A([0-7]{1}(,[0-7]{1})*)?\Z/i #Default Scope to pull the active version only default_scope { where(is_active: true).order("created_at desc") } diff --git a/app/views/settings/set_menu_items/edit.html.erb b/app/views/settings/set_menu_items/edit.html.erb index 40c675ef..abe7cea7 100644 --- a/app/views/settings/set_menu_items/edit.html.erb +++ b/app/views/settings/set_menu_items/edit.html.erb @@ -9,7 +9,7 @@ diff --git a/app/views/settings/set_menu_items/index.html.erb b/app/views/settings/set_menu_items/index.html.erb index 89fc850f..f497027c 100644 --- a/app/views/settings/set_menu_items/index.html.erb +++ b/app/views/settings/set_menu_items/index.html.erb @@ -1,7 +1,7 @@
    + <%= paginate @settings_menu_items, param_name: :page, :outer_window => 3 %> diff --git a/app/views/settings/set_menu_items/new.html.erb b/app/views/settings/set_menu_items/new.html.erb index bfc07ae3..7b234827 100644 --- a/app/views/settings/set_menu_items/new.html.erb +++ b/app/views/settings/set_menu_items/new.html.erb @@ -9,7 +9,7 @@ diff --git a/app/views/settings/set_menu_items/show.html.erb b/app/views/settings/set_menu_items/show.html.erb index 66ae3e84..271039ef 100644 --- a/app/views/settings/set_menu_items/show.html.erb +++ b/app/views/settings/set_menu_items/show.html.erb @@ -2,8 +2,8 @@
    - Menu Items Name
    - Less Sweet, No MSG +
    + - 5 + +
    @@ -84,3 +83,4 @@ + <%= paginate @settings_menu_items, param_name: :page, :outer_window => 3 %> diff --git a/app/views/settings/simple_menu_items/new.html.erb b/app/views/settings/simple_menu_items/new.html.erb index a9bf5dee..2f3cb6a4 100644 --- a/app/views/settings/simple_menu_items/new.html.erb +++ b/app/views/settings/simple_menu_items/new.html.erb @@ -9,7 +9,7 @@ diff --git a/app/views/settings/simple_menu_items/show.html.erb b/app/views/settings/simple_menu_items/show.html.erb index f69c83d4..60e7c596 100644 --- a/app/views/settings/simple_menu_items/show.html.erb +++ b/app/views/settings/simple_menu_items/show.html.erb @@ -2,7 +2,7 @@ - + <% if settings_menu_item.type == "SimpleMenuItem" %> + <% else %> + + + + <% end %> <% end %> diff --git a/app/views/settings/menu_item_attributes/show.html.erb b/app/views/settings/menu_item_attributes/show.html.erb index 5517c716..35e4e6ab 100644 --- a/app/views/settings/menu_item_attributes/show.html.erb +++ b/app/views/settings/menu_item_attributes/show.html.erb @@ -2,7 +2,7 @@ @@ -40,7 +40,13 @@
    -

    Menu Items

    +

    Menu Items + + <%= link_to "New Simple Menu Item",new_settings_menu_category_simple_menu_item_path(@category),:class => 'btn btn-primary btn-sm' %> + <%= link_to "New Set Menu Item",new_settings_menu_category_set_menu_item_path(@category),:class => 'btn btn-primary btn-sm' %> + + +

    <%= settings_menu_item.parent.name rescue "-" %> <%= settings_menu_item.created_by %> <%=l settings_menu_item.created_at, :format => :short %><%= link_to 'Show', settings_menu_category_simple_menu_item_path(@settings_menu_category, settings_menu_item ) %> <%= link_to 'Edit', edit_settings_menu_category_simple_menu_item_path(@settings_menu_category, settings_menu_item) %> <%= link_to 'Destroy', settings_menu_category_simple_menu_item_path(@settings_menu_category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %><%= link_to 'Show', settings_menu_category_set_menu_item_path(@settings_menu_category, settings_menu_item ) %><%= link_to 'Edit', edit_settings_menu_category_set_menu_item_path(@settings_menu_category, settings_menu_item) %><%= link_to 'Destroy', settings_menu_category_set_menu_item_path(@settings_menu_category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %>
    @@ -67,9 +73,15 @@ - - - + <% if settings_menu_item.type == "SimpleMenuItem" %> + + + + <% else %> + + + + <% end %> <% end %> diff --git a/app/views/settings/set_menu_items/show.html.erb b/app/views/settings/set_menu_items/show.html.erb index 271039ef..a76f851a 100644 --- a/app/views/settings/set_menu_items/show.html.erb +++ b/app/views/settings/set_menu_items/show.html.erb @@ -36,13 +36,13 @@ - - - + + + - +
    <%= settings_menu_item.created_by %> <%=l settings_menu_item.created_at, :format => :short %><%= link_to 'Show', settings_menu_category_menu_item_path(@category, settings_menu_item ) %><%= link_to 'Edit', edit_settings_menu_category_menu_item_path(@category, settings_menu_item) %><%= link_to 'Destroy', settings_menu_category_menu_item_path(@category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %><%= link_to 'Show', settings_menu_category_simple_menu_item_path(@category, settings_menu_item ) %><%= link_to 'Edit', edit_settings_menu_category_simple_menu_item_path(@category, settings_menu_item) %><%= link_to 'Destroy', settings_menu_category_simple_menu_item_path(@category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %><%= link_to 'Show', settings_menu_category_set_menu_item_path(@category, settings_menu_item ) %><%= link_to 'Edit', edit_settings_menu_category_set_menu_item_path(@category, settings_menu_item) %><%= link_to 'Destroy', settings_menu_category_set_menu_item_path(@category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %>
    <%= @settings_menu_item.name rescue "-" %> <%= @settings_menu_item.alt_name %> <%= @settings_menu_item.type %><%= @settings_menu_item.menu_category %><%= @settings_menu_item.menu_item %><%= @settings_menu_item.menu_qty %><%= @settings_menu_item.menu_category_id %><%= @settings_menu_item.menu_item_id %><%= @settings_menu_item.min_qty %> <%= @settings_menu_item.min_selectable_item %> <%= @settings_menu_item.max_selectable_item %> <%=l @settings_menu_item.created_at, format: :short %><%= link_to 'Edit', edit_settings_menu_menu_item_path(@settings_menu_category, @settings_menu_category) %><%= link_to 'Edit', edit_settings_menu_category_set_menu_item_path(@category, @settings_menu_item) %>
    diff --git a/app/views/settings/simple_menu_items/_form.html.erb b/app/views/settings/simple_menu_items/_form.html.erb index d187847a..885f725e 100644 --- a/app/views/settings/simple_menu_items/_form.html.erb +++ b/app/views/settings/simple_menu_items/_form.html.erb @@ -5,6 +5,7 @@ <%= f.input :item_code %> <%= f.input :name %> <%= f.input :alt_name %> + <%= f.input :type %> <%= f.input :menu_item_id, :label => "Parent Menu Item", :collection => MenuItem.collection %> <%= f.input :min_qty %> <%= f.input :min_selectable_item %> diff --git a/app/views/settings/simple_menu_items/index.html.erb b/app/views/settings/simple_menu_items/index.html.erb index ac840784..4a9efb75 100644 --- a/app/views/settings/simple_menu_items/index.html.erb +++ b/app/views/settings/simple_menu_items/index.html.erb @@ -72,9 +72,15 @@ <%= settings_menu_item.created_by %> <%=l settings_menu_item.created_at, :format => :short %> + <% if settings_menu_item.type == "SimpleMenuItem" %> <%= link_to 'Show', settings_menu_category_simple_menu_item_path(@category, settings_menu_item ) %> <%= link_to 'Edit', edit_settings_menu_category_simple_menu_item_path(@category, settings_menu_item) %> <%= link_to 'Destroy', settings_menu_category_simple_menu_item_path(@category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %> + <% else %> + <%= link_to 'Show', settings_menu_category_set_menu_item_path(@category, settings_menu_item ) %> + <%= link_to 'Edit', edit_settings_menu_category_set_menu_item_path(@category, settings_menu_item) %> + <%= link_to 'Destroy', settings_menu_category_set_menu_item_path(@category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %> + <% end %> <% end %> From f28f0bf292dbcfc682327e8933b682cb000f9510 Mon Sep 17 00:00:00 2001 From: Yan Date: Thu, 1 Jun 2017 18:37:15 +0630 Subject: [PATCH 18/39] UI updated --- Gemfile | 2 +- Gemfile.lock | 3 - app/assets/javascripts/OQS.js | 27 +++-- app/controllers/oqs/home_controller.rb | 54 ++++++--- app/views/oqs/home/index.html.erb | 153 +++++++++++++++---------- 5 files changed, 149 insertions(+), 90 deletions(-) diff --git a/Gemfile b/Gemfile index 08464196..1481501c 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,7 @@ gem 'mysql2', '>= 0.3.18', '< 0.5' #gem 'pg' # 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 0c3a3a27..e2c1dd73 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -119,7 +119,6 @@ GEM nokogiri (1.7.2) mini_portile2 (~> 2.1.0) pdf-core (0.7.0) - pg (0.20.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) @@ -253,13 +252,11 @@ DEPENDENCIES kaminari! listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) - pg prawn prawn-table 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/OQS.js b/app/assets/javascripts/OQS.js index 091b6822..eb2bc9cb 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -17,21 +17,32 @@ //= require cable $(document).ready(function(){ - $('.queue_station').on('click',function(){ - var title=$(this).children().children('.card-title').text(); - var titles=title.split(' '); - + $('.queue_station').on('click',function(){ + var orderZone=$(this).children().children().children('.order-zone').text(); + var orderItem=$(this).children().children().children('.order-item').text(); + var orderQty=$(this).children().children().children('.order-qty').text(); var orderBy=$(this).children().children().children().children('.order-by').text(); var orderAt=$(this).children().children().children().children('.order-at').text(); var orderCustomer=$(this).children().children('.order-customer').text(); - $('#order-title').text($('#order-title').text() + titles[0]); + $('#order-title').text("ORDER DETAILS - " + orderZone); $('#order-by').text(orderBy); $('#order-at').text(orderAt); $('#order-customer').text(orderCustomer); - $('#order-from').text(titles[0]); + $('#order-from').text(orderZone); - $('#order-items').text(titles[1]); - $('#order-qty').text(titles[2].substr(2).replace(']','')); + $('#order-items').text(orderItem); + $('#order-qty').text(orderQty); + }); + + // complete for queue item + $('.order-complete').on('click',function(){ + var assigned_item_id=$(this).attr('id').substr(15); + $.ajax({ + url: "", + data: "" + }).done(function(){ + + }); }); }); diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 0f73d20d..f59f2f18 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -1,31 +1,47 @@ class Oqs::HomeController < BaseOqsController def index @queue_stations=OrderQueueStation.all + + @queue_items_details = queue_items_query('false') - #sample Data - @queue_items_details = { :queue_id => 1, :order_id => 1, :station_name => 'Queue Station 1', :zone => 'Table4', :item_name => 'beef', :price => 10.00, :qty => 2, :customer => 'Wathon', :item_order_by => 'Yan', :created_at => '2007-05-17'} - # @queue_items_details = OrderItem.select("oqs as queue_id, oqs.station_name, oqs.is_active, oqpz.zone_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.created_at") - # .joins("join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = order_queue_items.order_queue_station_id") - # .joins("right join order_queue_stations as oqs ON oqs.id = order_queue_items.order_queue_station_id") - # .joins("right join orders as od ON od.id = order_queue_items.order_id") - # .joins("right join order_items as odt ON odt.item_code = order_queue_items.item_code") - # .order("odt.item_name DESC") + @queue_completed_item = queue_items_query('true') + + @queue_stations_items=Array.new - + # Calculate Count for each station tab + @queue_stations.each do |que| + i=0 + @queue_items_details.each do |qid| + if qid.station_name == que.station_name + i+=1 + @queue_stations_items.push({:station_name => que.station_name ,:item_count => i }) + break + end + end + end - # Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price, - # order_items.id as order_items_id,dining_facilities.name as table_name") - # .joins("left join booking_orders on booking_orders.order_id = orders.id - # left join bookings on bookings.id = booking_orders.id - # left join dining_facilities on dining_facilities.id = bookings.dining_facility_id - # left join order_items on order_items.order_id = orders.id") - # .where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,"dine_in",true) - # .group("orders.id") + @queue_stations_items end def show end + + def update_delivery_status + + end + + # Query for OQS with status + def queue_items_query(status) + AssignedOrderItem.select("assigned_order_items.id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at") + .joins("join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id + left join dining_facilities as df on df.zone_id = oqpz.zone_id + left join order_queue_stations as oqs ON oqs.id = assigned_order_items.order_queue_station_id + left join orders as od ON od.id = assigned_order_items.order_id + left join order_items as odt ON odt.item_code = assigned_order_items.item_code + left join customers as cus ON cus.id = od.customer_id") + .where('assigned_order_items.delivery_status=' + status) + .group('oqs.station_name') + .order("odt.item_name DESC") + end end - - diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 24fa00d0..4e0b16ad 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -1,14 +1,16 @@
    -
    - + +
    -
    +
    -
    -
    -
    -
    -

    9. Table 4 - Beef Steak [x3]

    -

    Well Done, Fries, Salad

    -

    - Order at 12:23, Kyaw Lwin | - Printed at 12:23 | - Completed at 12:43 -

    -
    -
    - +
    +
    + <% + @queue_completed_item.each do |qid| + %> +
    +
    +

    + + <%= qid.zone %> + - + + <%= qid.item_name %> + [x + + <%= qid.qty %> + ] +

    +

    Medium, Fries, Salad

    +

    + Order at + + <%= qid.created_at.strftime("%Y %m %d") %> + - + + <%= qid.item_order_by %> + + +

    + +
    + +
    + <% + end + %>
    -
    + - <% + + <% @queue_stations.each do |que| %> -
    role="tabpanel"> +
    role="tabpanel"> -
    - <% - if @queue_items_details[:station_name] == que.station_name +
    + <% + @queue_items_details.each do |qid| + if qid.station_name == que.station_name %>
    -

    <%= @queue_items_details[:zone] + ' ' + @queue_items_details[:item_name] + ' [x' + @queue_items_details[:qty].to_s + ']' %>

    +

    + + <%= qid.zone %> + - + + <%= qid.item_name %> + [x + + <%= qid.qty %> + ] +

    Medium, Fries, Salad

    Order at - <%= @queue_items_details[:created_at] %> + <%= qid.created_at.strftime("%Y %m %d") %> - - <%= @queue_items_details[:item_order_by] %> + <%= qid.item_order_by %>

    - +
    <% + end end %> @@ -93,17 +130,16 @@
    - <% end %> + <% end %> +
    - - -
    +
    -
    ORDER DETAILS -
    +
    ORDER DETAILS -
    @@ -117,28 +153,26 @@ - Kyaw Lwin - 20/04/17 9:30PM - John Smith + + + Table/Room - + +
    +
    - -
    ItemsQTY + QTY
    -
    -
    - - +
    From 7020d4957a9e23670782b37c63f869fa3b011506 Mon Sep 17 00:00:00 2001 From: PhyoTheingi Date: Thu, 1 Jun 2017 18:44:30 +0630 Subject: [PATCH 19/39] constraint to min_qty --- app/controllers/settings/simple_menu_items_controller.rb | 4 ++-- app/models/menu_item.rb | 1 + app/views/settings/set_menu_items/new.html.erb | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/settings/simple_menu_items_controller.rb b/app/controllers/settings/simple_menu_items_controller.rb index 6b3c4bb4..4057cf72 100644 --- a/app/controllers/settings/simple_menu_items_controller.rb +++ b/app/controllers/settings/simple_menu_items_controller.rb @@ -1,6 +1,6 @@ class Settings::SimpleMenuItemsController < ApplicationController - before_action :set_settings_menu_item, only: [:show, :edit, :update, :destroy] - before_action :set_settings_menu_category, only: [:index, :show, :edit, :new, :update] + before_action :set_settings_menu_item, only: [:show, :edit, :update, :destroy ] + before_action :set_settings_menu_category, only: [:index, :show, :edit, :new, :update ,:create] # GET /settings/menu_items # GET /settings/menu_items.json def index diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb index 70528e83..e84ce61e 100644 --- a/app/models/menu_item.rb +++ b/app/models/menu_item.rb @@ -3,6 +3,7 @@ class MenuItem < ApplicationRecord has_many :menu_item_instances belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id" + validates_presence_of :item_code, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item default_scope { order('item_code asc') } diff --git a/app/views/settings/set_menu_items/new.html.erb b/app/views/settings/set_menu_items/new.html.erb index 7b234827..6c7b6e76 100644 --- a/app/views/settings/set_menu_items/new.html.erb +++ b/app/views/settings/set_menu_items/new.html.erb @@ -13,5 +13,5 @@
  • New
  • - <%= render 'form', settings_menu_item: @settings_menu_item %> + <%= render 'form', settings_set_menu_item: @settings_menu_item %> From 0fa9cd0cacd4b8269791aceb4ed5500fbb6ca0df Mon Sep 17 00:00:00 2001 From: PhyoTheingi Date: Fri, 2 Jun 2017 09:50:48 +0630 Subject: [PATCH 20/39] Sub Menu Item Showing --- .../settings/set_menu_items_controller.rb | 1 + .../settings/simple_menu_items_controller.rb | 1 + .../settings/set_menu_items/show.html.erb | 46 ++++++++++++++++++- .../settings/simple_menu_items/show.html.erb | 46 ++++++++++++++++++- 4 files changed, 92 insertions(+), 2 deletions(-) diff --git a/app/controllers/settings/set_menu_items_controller.rb b/app/controllers/settings/set_menu_items_controller.rb index b488ac6f..cc5e89e8 100644 --- a/app/controllers/settings/set_menu_items_controller.rb +++ b/app/controllers/settings/set_menu_items_controller.rb @@ -10,6 +10,7 @@ class Settings::SetMenuItemsController < ApplicationController # GET /settings/menu_items/1 # GET /settings/menu_items/1.json def show + @sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10) end # GET /settings/menu_items/new diff --git a/app/controllers/settings/simple_menu_items_controller.rb b/app/controllers/settings/simple_menu_items_controller.rb index 4057cf72..2a391d8f 100644 --- a/app/controllers/settings/simple_menu_items_controller.rb +++ b/app/controllers/settings/simple_menu_items_controller.rb @@ -10,6 +10,7 @@ class Settings::SimpleMenuItemsController < ApplicationController # GET /settings/menu_items/1 # GET /settings/menu_items/1.json def show + @sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10) end # GET /settings/menu_items/new diff --git a/app/views/settings/set_menu_items/show.html.erb b/app/views/settings/set_menu_items/show.html.erb index a76f851a..238fa038 100644 --- a/app/views/settings/set_menu_items/show.html.erb +++ b/app/views/settings/set_menu_items/show.html.erb @@ -9,7 +9,6 @@ -

    Menu Item

    @@ -48,5 +47,50 @@
    +
    +
    +
    +

    Sub Menu Items

    + + + + + + + + + + + + + + + + <% @sub_menu.each do |settings_menu_item| %> + + + + + + + + + + <% if settings_menu_item.type == "SimpleMenuItem" %> + + + + <% else %> + + + + <% end %> + + <% end %> + +
    Item codeNameAlt nameTypeParent ItemCreated byCreated at
    <%= settings_menu_item.item_code %><%= settings_menu_item.name %><%= settings_menu_item.alt_name %><%= settings_menu_item.type %><%= settings_menu_item.parent.name rescue "-" %><%= settings_menu_item.created_by %><%=l settings_menu_item.created_at, :format => :short %><%= link_to 'Show', settings_menu_category_simple_menu_item_path(@category, settings_menu_item ) %><%= link_to 'Edit', edit_settings_menu_category_simple_menu_item_path(@category, settings_menu_item) %><%= link_to 'Destroy', settings_menu_category_simple_menu_item_path(@category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %><%= link_to 'Show', settings_menu_category_set_menu_item_path(@category, settings_menu_item ) %><%= link_to 'Edit', edit_settings_menu_category_set_menu_item_path(@category, settings_menu_item) %><%= link_to 'Destroy', settings_menu_category_set_menu_item_path(@category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %>
    +
    +
    + <%= paginate @sub_menu, param_name: :page, :outer_window => 3 %>
    diff --git a/app/views/settings/simple_menu_items/show.html.erb b/app/views/settings/simple_menu_items/show.html.erb index 60e7c596..97e12695 100644 --- a/app/views/settings/simple_menu_items/show.html.erb +++ b/app/views/settings/simple_menu_items/show.html.erb @@ -9,7 +9,6 @@
    -

    Menu Item

    @@ -48,5 +47,50 @@
    +
    +
    +
    +

    Sub Menu Items

    + + + + + + + + + + + + + + + + <% @sub_menu.each do |settings_menu_item| %> + + + + + + + + + + <% if settings_menu_item.type == "SimpleMenuItem" %> + + + + <% else %> + + + + <% end %> + + <% end %> + +
    Item codeNameAlt nameTypeParent ItemCreated byCreated at
    <%= settings_menu_item.item_code %><%= settings_menu_item.name %><%= settings_menu_item.alt_name %><%= settings_menu_item.type %><%= settings_menu_item.parent.name rescue "-" %><%= settings_menu_item.created_by %><%=l settings_menu_item.created_at, :format => :short %><%= link_to 'Show', settings_menu_category_simple_menu_item_path(@category, settings_menu_item ) %><%= link_to 'Edit', edit_settings_menu_category_simple_menu_item_path(@category, settings_menu_item) %><%= link_to 'Destroy', settings_menu_category_simple_menu_item_path(@category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %><%= link_to 'Show', settings_menu_category_set_menu_item_path(@category, settings_menu_item ) %><%= link_to 'Edit', edit_settings_menu_category_set_menu_item_path(@category, settings_menu_item) %><%= link_to 'Destroy', settings_menu_category_set_menu_item_path(@category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %>
    +
    +
    + <%= paginate @sub_menu, param_name: :page, :outer_window => 3 %>
    From 95fd260c76ddcd1389be888196fd3bfbd0bc41c7 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 2 Jun 2017 11:28:07 +0630 Subject: [PATCH 21/39] updated ui --- app/assets/javascripts/OQS.js | 54 ++++++++++++++------------ app/controllers/oqs/home_controller.rb | 11 +++++- app/views/oqs/home/index.html.erb | 1 + config/routes.rb | 2 + 4 files changed, 43 insertions(+), 25 deletions(-) diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index eb2bc9cb..04b81bea 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -17,32 +17,38 @@ //= require cable $(document).ready(function(){ - $('.queue_station').on('click',function(){ - var orderZone=$(this).children().children().children('.order-zone').text(); - var orderItem=$(this).children().children().children('.order-item').text(); - var orderQty=$(this).children().children().children('.order-qty').text(); - var orderBy=$(this).children().children().children().children('.order-by').text(); - var orderAt=$(this).children().children().children().children('.order-at').text(); - var orderCustomer=$(this).children().children('.order-customer').text(); + $('.queue_station').on('click',function(){ + var orderZone=$(this).children().children().children('.order-zone').text(); + var orderItem=$(this).children().children().children('.order-item').text(); + var orderQty=$(this).children().children().children('.order-qty').text(); + var orderBy=$(this).children().children().children().children('.order-by').text(); + var orderAt=$(this).children().children().children().children('.order-at').text(); + var orderCustomer=$(this).children().children('.order-customer').text(); - $('#order-title').text("ORDER DETAILS - " + orderZone); - $('#order-by').text(orderBy); - $('#order-at').text(orderAt); - $('#order-customer').text(orderCustomer); - $('#order-from').text(orderZone); + $('#order-title').text("ORDER DETAILS - " + orderZone); + $('#order-by').text(orderBy); + $('#order-at').text(orderAt); + $('#order-customer').text(orderCustomer); + $('#order-from').text(orderZone); - $('#order-items').text(orderItem); - $('#order-qty').text(orderQty); + $('#order-items').text(orderItem); + $('#order-qty').text(orderQty); }); - // complete for queue item - $('.order-complete').on('click',function(){ - var assigned_item_id=$(this).attr('id').substr(15); - $.ajax({ - url: "", - data: "" - }).done(function(){ - - }); - }); + // complete for queue item + $('.order-complete').on('click',function(){ + var assigned_item_id=$(this).attr('id').substr(15); + var params = { 'id':assigned_item_id }; + // $(this).parent().parent(".queue_station").remove(); + $.ajax({ + type: 'POST', + url: '/oqs/update_delivery', + data: params, + dataType: 'json', + success: function(data){ + $('.order-complete').parent().parent(".queue_station").remove(); + alert('updated!'); + } + }); + }); }); diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index f59f2f18..e448ff23 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -26,8 +26,17 @@ class Oqs::HomeController < BaseOqsController def show end + # update delivery status when complete click def update_delivery_status - + puts "WWWW" + params[:id] + assigned_item_id = params[:id] + assigned_item=AssignedOrderItem.find(assigned_item_id) + assigned_item.delivery_status=true + assigned_item.save + # respond_to do |format| + # format.json { render json: "updated" } + # end + flash[:success] = "updated!" end # Query for OQS with status diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 4e0b16ad..7982e00d 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -200,3 +200,4 @@
    + diff --git a/config/routes.rb b/config/routes.rb index 7b9dd91d..54cc4d7e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -92,6 +92,8 @@ Rails.application.routes.draw do #--------- Order Queue Station ------------# namespace :oqs do root "home#index" + + post 'update_delivery', to: "home#update_delivery_status" #dashboard # end From a9259ca845f4802348cf7a3c6f01ed3a0b00184b Mon Sep 17 00:00:00 2001 From: Nweni Date: Fri, 2 Jun 2017 11:30:10 +0630 Subject: [PATCH 22/39] order --- app/controllers/api/orders_controller.rb | 4 ++-- app/models/order.rb | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index 57f2e48c..607a7bef 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -36,8 +36,8 @@ class Api::OrdersController < Api::ApiController #Create Table Booking or Room Booking if !params["booking_id"].nil? && params[:booking_id].to_i > 0 - @order.new_booking = false - # @order.new_booking = true + #@order.new_booking = false + @order.new_booking = true @order.booking_id = params[:booking_id] end diff --git a/app/models/order.rb b/app/models/order.rb index 3f74284f..4bbe4a28 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -16,6 +16,7 @@ class Order < ApplicationRecord # option_values : [], # sub_order_items : [], # } + def generate booking = nil @@ -200,7 +201,7 @@ class Order < ApplicationRecord #Process order items and send to order queue def process_order_queue - #Send to background job for processing + #Send to background job for processing OrderQueueProcessorJob.perform_later(self.id) end @@ -220,7 +221,7 @@ class Order < ApplicationRecord left join dining_facilities on dining_facilities.id = bookings.dining_facility_id left join order_items on order_items.order_id = orders.id") .where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,"dine_in",true) - .group("orders.id") + .group("orders.id") end #Origami: Cashier : to view order type Room def self.get_order_rooms From 0c82c162935a874d9e4648dbdf3d6ad015743156 Mon Sep 17 00:00:00 2001 From: PhyoTheingi Date: Fri, 2 Jun 2017 11:38:46 +0630 Subject: [PATCH 23/39] Order Queue Station Bug Fix --- .../settings/order_queue_stations_controller.rb | 6 +++--- .../settings/order_queue_stations/edit.html.erb | 16 ++++++++++++---- .../settings/order_queue_stations/show.html.erb | 8 ++++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb index ec85e56a..e0cf0d08 100644 --- a/app/controllers/settings/order_queue_stations_controller.rb +++ b/app/controllers/settings/order_queue_stations_controller.rb @@ -1,5 +1,5 @@ class Settings::OrderQueueStationsController < ApplicationController - before_action :set_settings_order_queue_station, only: [:show, :edit,:new, :update, :destroy] + before_action :set_settings_order_queue_station, only: [:show, :edit, :update, :destroy] # GET /settings/order_queue_stations # GET /settings/order_queue_stations.json @@ -25,10 +25,10 @@ class Settings::OrderQueueStationsController < ApplicationController # POST /settings/order_queue_stations.json def create @settings_order_queue_station = OrderQueueStation.new(settings_order_queue_station_params) - + @settings_order_queue_station.created_by = current_login_employee.name respond_to do |format| if @settings_order_queue_station.save - format.html { redirect_to @settings_order_queue_station, notice: 'Order queue station was successfully created.' } + format.html { redirect_to settings_order_queue_stations_path, notice: 'Order queue station was successfully created.' } format.json { render :show, status: :created, location: @settings_order_queue_station } else format.html { render :new } diff --git a/app/views/settings/order_queue_stations/edit.html.erb b/app/views/settings/order_queue_stations/edit.html.erb index af08ffda..27cf2fc8 100644 --- a/app/views/settings/order_queue_stations/edit.html.erb +++ b/app/views/settings/order_queue_stations/edit.html.erb @@ -1,6 +1,14 @@ -

    Editing Settings Order Queue Station

    + -<%= link_to 'Show', @settings_order_queue_station %> | -<%= link_to 'Back', settings_order_queue_stations_path %> +
    + + <%= render 'form', settings_order_queue_station: @settings_order_queue_station %> +
    \ No newline at end of file diff --git a/app/views/settings/order_queue_stations/show.html.erb b/app/views/settings/order_queue_stations/show.html.erb index 00004528..1a80c2c0 100644 --- a/app/views/settings/order_queue_stations/show.html.erb +++ b/app/views/settings/order_queue_stations/show.html.erb @@ -1,3 +1,11 @@ + +

    <%= notice %>

    From 17206001c432ab807b8e44ccee39144285b07391 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 2 Jun 2017 13:58:35 +0630 Subject: [PATCH 24/39] updated oqs ui --- app/assets/javascripts/OQS.js | 26 +++++++++++++++++++++----- app/controllers/oqs/home_controller.rb | 9 ++------- app/views/oqs/home/index.html.erb | 6 ++++-- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 04b81bea..dd8bed28 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -36,18 +36,34 @@ $(document).ready(function(){ }); // complete for queue item - $('.order-complete').on('click',function(){ + $('.order-complete').on('click',function(){ + var _self= $(this); var assigned_item_id=$(this).attr('id').substr(15); var params = { 'id':assigned_item_id }; - // $(this).parent().parent(".queue_station").remove(); + var station=$(this).parent().parent(".queue_station").parent().parent().attr('id'); + $.ajax({ type: 'POST', url: '/oqs/update_delivery', data: params, dataType: 'json', - success: function(data){ - $('.order-complete').parent().parent(".queue_station").remove(); - alert('updated!'); + success: function(data){ + var queue_station=_self.parent().parent(".queue_station"); + + // Remove a queue card from current station + queue_station.remove(); + + // Remove a queue card from current station + queue_station.children('.card-footer').remove(); + + // Add removed queue card from station to completed + $("#completed").children('.card-columns').append(queue_station); + + // update queue item count in station + $("#"+station+"_count").text(parseInt($("#"+station+"_count").text())-1); + $("#completed_count").text(parseInt($("#completed_count").text())+1); + + alert("updated!"); } }); }); diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index e448ff23..bbfb166d 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -28,15 +28,10 @@ class Oqs::HomeController < BaseOqsController # update delivery status when complete click def update_delivery_status - puts "WWWW" + params[:id] assigned_item_id = params[:id] assigned_item=AssignedOrderItem.find(assigned_item_id) assigned_item.delivery_status=true - assigned_item.save - # respond_to do |format| - # format.json { render json: "updated" } - # end - flash[:success] = "updated!" + assigned_item.save end # Query for OQS with status @@ -49,7 +44,7 @@ class Oqs::HomeController < BaseOqsController left join order_items as odt ON odt.item_code = assigned_order_items.item_code left join customers as cus ON cus.id = od.customer_id") .where('assigned_order_items.delivery_status=' + status) - .group('oqs.station_name') + .group('assigned_order_items.id') .order("odt.item_name DESC") end end diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 7982e00d..69fe3f20 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -6,7 +6,7 @@

    diff --git a/app/views/settings/menu_item_instances/show.json.jbuilder b/app/views/settings/menu_item_instances/show.json.jbuilder new file mode 100644 index 00000000..4a11737c --- /dev/null +++ b/app/views/settings/menu_item_instances/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "settings_menu_items/settings_menu_item", settings_menu_item: @settings_menu_item diff --git a/app/views/settings/processing_items/_form.html.erb b/app/views/settings/processing_items/_form.html.erb index 2038b0ea..60e493d8 100644 --- a/app/views/settings/processing_items/_form.html.erb +++ b/app/views/settings/processing_items/_form.html.erb @@ -29,7 +29,9 @@
    <% end %>
    +
    <%= f.button :submit, label: "Add Menu Items to Queue Station" %>
    +
    <% end %> diff --git a/app/views/settings/simple_menu_items/show.html.erb b/app/views/settings/simple_menu_items/show.html.erb index 97e12695..7f68c9aa 100644 --- a/app/views/settings/simple_menu_items/show.html.erb +++ b/app/views/settings/simple_menu_items/show.html.erb @@ -93,4 +93,45 @@
    <%= paginate @sub_menu, param_name: :page, :outer_window => 3 %> + +
    +
    +
    +

    Menu Item Instances + + <%= link_to t('.new', :default => t("helpers.links.new")),new_settings_menu_item_menu_item_instance_path(@settings_menu_item),:class => 'btn btn-primary btn-sm' %> + + +

    + + + + + + + + + + + + + + + + + <% @menu_item_instance.each do |settings_menu_item| %> + + + + + + + + + + <% end %> + +
    Menu Item Iditem_instance_codeitem_attributespriceis_on_promotionpromotion_priceCreated at
    <%= settings_menu_item.menu_item_id %><%= settings_menu_item.item_instance_code %><%= settings_menu_item.item_attributes %><%= settings_menu_item.price %><%= settings_menu_item.is_on_promotion %><%= settings_menu_item.promotion_price %><%=l settings_menu_item.created_at, :format => :short %>
    +
    +
    From 7d5e5e7129db972bc06856fdab1d51d7ba37c9be Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 2 Jun 2017 14:47:34 +0630 Subject: [PATCH 26/39] update menu item instance --- app/controllers/settings/menu_item_instances_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/settings/menu_item_instances_controller.rb b/app/controllers/settings/menu_item_instances_controller.rb index fecc3cd7..00f980e9 100644 --- a/app/controllers/settings/menu_item_instances_controller.rb +++ b/app/controllers/settings/menu_item_instances_controller.rb @@ -74,6 +74,6 @@ class Settings::MenuItemInstancesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_menu_item_instance_params - params.require(:menu_item_instance).permit(:name, :value) + params.require(:menu_item_instance).permit(:item_instance_code, :item_instance_name, :price, :is_on_promotion, :promotion_price, :is_available) end end From 98a7c31ffa2ff3c515f82c83653797e87d63ebf7 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 2 Jun 2017 16:21:47 +0630 Subject: [PATCH 27/39] initial setup for print --- config/routes.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index eadc26b0..5af42077 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,7 @@ require 'sidekiq/web' Rails.application.routes.draw do - + root 'home#index' mount Sidekiq::Web => '/kiq' @@ -181,7 +181,8 @@ Rails.application.routes.draw do # end # end - + #----------- Print Setup --------# + resources :print_settings # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end From 022a2e005f4a734dd4481d1589830520d192decb Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 2 Jun 2017 16:22:15 +0630 Subject: [PATCH 28/39] initial print setup --- app/assets/javascripts/print_settings.coffee | 3 + app/assets/stylesheets/print_settings.scss | 3 + app/controllers/print_settings_controller.rb | 74 +++++++++ app/helpers/print_settings_helper.rb | 2 + app/models/print_setting.rb | 2 + app/views/print_settings/_form.html.erb | 22 +++ .../_print_setting.json.jbuilder | 2 + app/views/print_settings/edit.html.erb | 6 + app/views/print_settings/index.html.erb | 49 ++++++ app/views/print_settings/index.json.jbuilder | 1 + app/views/print_settings/new.html.erb | 5 + app/views/print_settings/show.html.erb | 64 ++++++++ app/views/print_settings/show.json.jbuilder | 1 + .../20170602093159_create_print_settings.rb | 20 +++ .../print_settings_controller_spec.rb | 141 ++++++++++++++++++ spec/helpers/print_settings_helper_spec.rb | 15 ++ spec/models/print_setting_spec.rb | 5 + spec/requests/print_settings_spec.rb | 10 ++ spec/routing/print_settings_routing_spec.rb | 39 +++++ .../print_settings/edit.html.erb_spec.rb | 51 +++++++ .../print_settings/index.html.erb_spec.rb | 52 +++++++ .../views/print_settings/new.html.erb_spec.rb | 51 +++++++ .../print_settings/show.html.erb_spec.rb | 36 +++++ test/system/print_settings_test.rb | 9 ++ 24 files changed, 663 insertions(+) create mode 100644 app/assets/javascripts/print_settings.coffee create mode 100644 app/assets/stylesheets/print_settings.scss create mode 100644 app/controllers/print_settings_controller.rb create mode 100644 app/helpers/print_settings_helper.rb create mode 100644 app/models/print_setting.rb create mode 100644 app/views/print_settings/_form.html.erb create mode 100644 app/views/print_settings/_print_setting.json.jbuilder create mode 100644 app/views/print_settings/edit.html.erb create mode 100644 app/views/print_settings/index.html.erb create mode 100644 app/views/print_settings/index.json.jbuilder create mode 100644 app/views/print_settings/new.html.erb create mode 100644 app/views/print_settings/show.html.erb create mode 100644 app/views/print_settings/show.json.jbuilder create mode 100644 db/migrate/20170602093159_create_print_settings.rb create mode 100644 spec/controllers/print_settings_controller_spec.rb create mode 100644 spec/helpers/print_settings_helper_spec.rb create mode 100644 spec/models/print_setting_spec.rb create mode 100644 spec/requests/print_settings_spec.rb create mode 100644 spec/routing/print_settings_routing_spec.rb create mode 100644 spec/views/print_settings/edit.html.erb_spec.rb create mode 100644 spec/views/print_settings/index.html.erb_spec.rb create mode 100644 spec/views/print_settings/new.html.erb_spec.rb create mode 100644 spec/views/print_settings/show.html.erb_spec.rb create mode 100644 test/system/print_settings_test.rb diff --git a/app/assets/javascripts/print_settings.coffee b/app/assets/javascripts/print_settings.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/print_settings.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/print_settings.scss b/app/assets/stylesheets/print_settings.scss new file mode 100644 index 00000000..7dd1ef04 --- /dev/null +++ b/app/assets/stylesheets/print_settings.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the print_settings controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/print_settings_controller.rb b/app/controllers/print_settings_controller.rb new file mode 100644 index 00000000..fa5af7e8 --- /dev/null +++ b/app/controllers/print_settings_controller.rb @@ -0,0 +1,74 @@ +class PrintSettingsController < ApplicationController + before_action :set_print_setting, only: [:show, :edit, :update, :destroy] + + # GET /print_settings + # GET /print_settings.json + def index + @print_settings = PrintSetting.all + end + + # GET /print_settings/1 + # GET /print_settings/1.json + def show + end + + # GET /print_settings/new + def new + @print_setting = PrintSetting.new + end + + # GET /print_settings/1/edit + def edit + end + + # POST /print_settings + # POST /print_settings.json + def create + @print_setting = PrintSetting.new(print_setting_params) + + respond_to do |format| + if @print_setting.save + format.html { redirect_to @print_setting, notice: 'Print setting was successfully created.' } + format.json { render :show, status: :created, location: @print_setting } + else + format.html { render :new } + format.json { render json: @print_setting.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /print_settings/1 + # PATCH/PUT /print_settings/1.json + def update + respond_to do |format| + if @print_setting.update(print_setting_params) + format.html { redirect_to @print_setting, notice: 'Print setting was successfully updated.' } + format.json { render :show, status: :ok, location: @print_setting } + else + format.html { render :edit } + format.json { render json: @print_setting.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /print_settings/1 + # DELETE /print_settings/1.json + def destroy + @print_setting.destroy + respond_to do |format| + format.html { redirect_to print_settings_url, notice: 'Print setting was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_print_setting + @print_setting = PrintSetting.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def print_setting_params + params.require(:print_setting).permit(:name, :unique_code, :template, :db_name, :db_type, :db_username, :db_password, :printer_name, :api_settings, :page_width, :page_height, :print_copies) + end +end diff --git a/app/helpers/print_settings_helper.rb b/app/helpers/print_settings_helper.rb new file mode 100644 index 00000000..3e712d7c --- /dev/null +++ b/app/helpers/print_settings_helper.rb @@ -0,0 +1,2 @@ +module PrintSettingsHelper +end diff --git a/app/models/print_setting.rb b/app/models/print_setting.rb new file mode 100644 index 00000000..b715af52 --- /dev/null +++ b/app/models/print_setting.rb @@ -0,0 +1,2 @@ +class PrintSetting < ApplicationRecord +end diff --git a/app/views/print_settings/_form.html.erb b/app/views/print_settings/_form.html.erb new file mode 100644 index 00000000..e6ed306b --- /dev/null +++ b/app/views/print_settings/_form.html.erb @@ -0,0 +1,22 @@ +<%= simple_form_for(@print_setting) do |f| %> + <%= f.error_notification %> + +
    + <%= f.input :name %> + <%= f.input :unique_code %> + <%= f.input :template %> + <%= f.input :db_name %> + <%= f.input :db_type %> + <%= f.input :db_username %> + <%= f.input :db_password %> + <%= f.input :printer_name %> + <%= f.input :api_settings %> + <%= f.input :page_width %> + <%= f.input :page_height %> + <%= f.input :print_copies %> +
    + +
    + <%= f.button :submit %> +
    +<% end %> diff --git a/app/views/print_settings/_print_setting.json.jbuilder b/app/views/print_settings/_print_setting.json.jbuilder new file mode 100644 index 00000000..b1835de6 --- /dev/null +++ b/app/views/print_settings/_print_setting.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! print_setting, :id, :name,, :unique_code,, :template,, :db_name,, :db_type,, :db_username,, :db_password,, :printer_name,, :api_settings,, :page_width, :page_height, :print_copies, :created_at, :updated_at +json.url print_setting_url(print_setting, format: :json) diff --git a/app/views/print_settings/edit.html.erb b/app/views/print_settings/edit.html.erb new file mode 100644 index 00000000..fdae5f78 --- /dev/null +++ b/app/views/print_settings/edit.html.erb @@ -0,0 +1,6 @@ +

    Editing Print Setting

    + +<%= render 'form', print_setting: @print_setting %> + +<%= link_to 'Show', @print_setting %> | +<%= link_to 'Back', print_settings_path %> diff --git a/app/views/print_settings/index.html.erb b/app/views/print_settings/index.html.erb new file mode 100644 index 00000000..32d3dead --- /dev/null +++ b/app/views/print_settings/index.html.erb @@ -0,0 +1,49 @@ +

    <%= notice %>

    + +

    Print Settings

    + + + + + + + + + + + + + + + + + + + + + + <% @print_settings.each do |print_setting| %> + + + + + + + + + + + + + + + + + + <% end %> + +
    NameUnique codeTemplateDb nameDb typeDb usernameDb passwordPrinter nameApi settingsPage widthPage heightPrint copies
    <%= print_setting.name %><%= print_setting.unique_code %><%= print_setting.template %><%= print_setting.db_name %><%= print_setting.db_type %><%= print_setting.db_username %><%= print_setting.db_password %><%= print_setting.printer_name %><%= print_setting.api_settings %><%= print_setting.page_width %><%= print_setting.page_height %><%= print_setting.print_copies %><%= link_to 'Show', print_setting %><%= link_to 'Edit', edit_print_setting_path(print_setting) %><%= link_to 'Destroy', print_setting, method: :delete, data: { confirm: 'Are you sure?' } %>
    + +
    + +<%= link_to 'New Print Setting', new_print_setting_path %> diff --git a/app/views/print_settings/index.json.jbuilder b/app/views/print_settings/index.json.jbuilder new file mode 100644 index 00000000..9e448f9f --- /dev/null +++ b/app/views/print_settings/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @print_settings, partial: 'print_settings/print_setting', as: :print_setting diff --git a/app/views/print_settings/new.html.erb b/app/views/print_settings/new.html.erb new file mode 100644 index 00000000..810ad9c9 --- /dev/null +++ b/app/views/print_settings/new.html.erb @@ -0,0 +1,5 @@ +

    New Print Setting

    + +<%= render 'form', print_setting: @print_setting %> + +<%= link_to 'Back', print_settings_path %> diff --git a/app/views/print_settings/show.html.erb b/app/views/print_settings/show.html.erb new file mode 100644 index 00000000..77e89fb7 --- /dev/null +++ b/app/views/print_settings/show.html.erb @@ -0,0 +1,64 @@ +

    <%= notice %>

    + +

    + Name: + <%= @print_setting.name, %> +

    + +

    + Unique code: + <%= @print_setting.unique_code, %> +

    + +

    + Template: + <%= @print_setting.template, %> +

    + +

    + Db name: + <%= @print_setting.db_name, %> +

    + +

    + Db type: + <%= @print_setting.db_type, %> +

    + +

    + Db username: + <%= @print_setting.db_username, %> +

    + +

    + Db password: + <%= @print_setting.db_password, %> +

    + +

    + Printer name: + <%= @print_setting.printer_name, %> +

    + +

    + Api settings: + <%= @print_setting.api_settings, %> +

    + +

    + Page width: + <%= @print_setting.page_width %> +

    + +

    + Page height: + <%= @print_setting.page_height %> +

    + +

    + Print copies: + <%= @print_setting.print_copies %> +

    + +<%= link_to 'Edit', edit_print_setting_path(@print_setting) %> | +<%= link_to 'Back', print_settings_path %> diff --git a/app/views/print_settings/show.json.jbuilder b/app/views/print_settings/show.json.jbuilder new file mode 100644 index 00000000..10305122 --- /dev/null +++ b/app/views/print_settings/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "print_settings/print_setting", print_setting: @print_setting diff --git a/db/migrate/20170602093159_create_print_settings.rb b/db/migrate/20170602093159_create_print_settings.rb new file mode 100644 index 00000000..a5ce89d6 --- /dev/null +++ b/db/migrate/20170602093159_create_print_settings.rb @@ -0,0 +1,20 @@ +class CreatePrintSettings < ActiveRecord::Migration[5.1] + def change + create_table :print_settings do |t| + t.string :name, :null => false + t.string :unique_code, :null => false + t.string :template, :null => false + t.string :db_name, :null => false + t.string :db_type, :null => false + t.string :db_username, :null => false + t.string :db_password + t.string :printer_name, :null => false + t.string :api_settings + t.decimal :page_width, :null => false, :default => 200 + t.decimal :page_height, :null => false, :default => 800 + t.integer :print_copies, :null => false, :default => 1 + + t.timestamps + end + end +end diff --git a/spec/controllers/print_settings_controller_spec.rb b/spec/controllers/print_settings_controller_spec.rb new file mode 100644 index 00000000..b64bdbb3 --- /dev/null +++ b/spec/controllers/print_settings_controller_spec.rb @@ -0,0 +1,141 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to specify the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. +# +# Compared to earlier versions of this generator, there is very limited use of +# stubs and message expectations in this spec. Stubs are only used when there +# is no simpler way to get a handle on the object needed for the example. +# Message expectations are only used when there is no simpler way to specify +# that an instance is receiving a specific message. +# +# Also compared to earlier versions of this generator, there are no longer any +# expectations of assigns and templates rendered. These features have been +# removed from Rails core in Rails 5, but can be added back in via the +# `rails-controller-testing` gem. + +RSpec.describe PrintSettingsController, type: :controller do + + # This should return the minimal set of attributes required to create a valid + # PrintSetting. As you add validations to PrintSetting, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + # This should return the minimal set of values that should be in the session + # in order to pass any filters (e.g. authentication) defined in + # PrintSettingsController. Be sure to keep this updated too. + let(:valid_session) { {} } + + describe "GET #index" do + it "returns a success response" do + print_setting = PrintSetting.create! valid_attributes + get :index, params: {}, session: valid_session + expect(response).to be_success + end + end + + describe "GET #show" do + it "returns a success response" do + print_setting = PrintSetting.create! valid_attributes + get :show, params: {id: print_setting.to_param}, session: valid_session + expect(response).to be_success + end + end + + describe "GET #new" do + it "returns a success response" do + get :new, params: {}, session: valid_session + expect(response).to be_success + end + end + + describe "GET #edit" do + it "returns a success response" do + print_setting = PrintSetting.create! valid_attributes + get :edit, params: {id: print_setting.to_param}, session: valid_session + expect(response).to be_success + end + end + + describe "POST #create" do + context "with valid params" do + it "creates a new PrintSetting" do + expect { + post :create, params: {print_setting: valid_attributes}, session: valid_session + }.to change(PrintSetting, :count).by(1) + end + + it "redirects to the created print_setting" do + post :create, params: {print_setting: valid_attributes}, session: valid_session + expect(response).to redirect_to(PrintSetting.last) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'new' template)" do + post :create, params: {print_setting: invalid_attributes}, session: valid_session + expect(response).to be_success + end + end + end + + describe "PUT #update" do + context "with valid params" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested print_setting" do + print_setting = PrintSetting.create! valid_attributes + put :update, params: {id: print_setting.to_param, print_setting: new_attributes}, session: valid_session + print_setting.reload + skip("Add assertions for updated state") + end + + it "redirects to the print_setting" do + print_setting = PrintSetting.create! valid_attributes + put :update, params: {id: print_setting.to_param, print_setting: valid_attributes}, session: valid_session + expect(response).to redirect_to(print_setting) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'edit' template)" do + print_setting = PrintSetting.create! valid_attributes + put :update, params: {id: print_setting.to_param, print_setting: invalid_attributes}, session: valid_session + expect(response).to be_success + end + end + end + + describe "DELETE #destroy" do + it "destroys the requested print_setting" do + print_setting = PrintSetting.create! valid_attributes + expect { + delete :destroy, params: {id: print_setting.to_param}, session: valid_session + }.to change(PrintSetting, :count).by(-1) + end + + it "redirects to the print_settings list" do + print_setting = PrintSetting.create! valid_attributes + delete :destroy, params: {id: print_setting.to_param}, session: valid_session + expect(response).to redirect_to(print_settings_url) + end + end + +end diff --git a/spec/helpers/print_settings_helper_spec.rb b/spec/helpers/print_settings_helper_spec.rb new file mode 100644 index 00000000..29cb2eec --- /dev/null +++ b/spec/helpers/print_settings_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the PrintSettingsHelper. For example: +# +# describe PrintSettingsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe PrintSettingsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/print_setting_spec.rb b/spec/models/print_setting_spec.rb new file mode 100644 index 00000000..d2ee515b --- /dev/null +++ b/spec/models/print_setting_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe PrintSetting, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/requests/print_settings_spec.rb b/spec/requests/print_settings_spec.rb new file mode 100644 index 00000000..9c205c7a --- /dev/null +++ b/spec/requests/print_settings_spec.rb @@ -0,0 +1,10 @@ +require 'rails_helper' + +RSpec.describe "PrintSettings", type: :request do + describe "GET /print_settings" do + it "works! (now write some real specs)" do + get print_settings_path + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/routing/print_settings_routing_spec.rb b/spec/routing/print_settings_routing_spec.rb new file mode 100644 index 00000000..9018c57a --- /dev/null +++ b/spec/routing/print_settings_routing_spec.rb @@ -0,0 +1,39 @@ +require "rails_helper" + +RSpec.describe PrintSettingsController, type: :routing do + describe "routing" do + + it "routes to #index" do + expect(:get => "/print_settings").to route_to("print_settings#index") + end + + it "routes to #new" do + expect(:get => "/print_settings/new").to route_to("print_settings#new") + end + + it "routes to #show" do + expect(:get => "/print_settings/1").to route_to("print_settings#show", :id => "1") + end + + it "routes to #edit" do + expect(:get => "/print_settings/1/edit").to route_to("print_settings#edit", :id => "1") + end + + it "routes to #create" do + expect(:post => "/print_settings").to route_to("print_settings#create") + end + + it "routes to #update via PUT" do + expect(:put => "/print_settings/1").to route_to("print_settings#update", :id => "1") + end + + it "routes to #update via PATCH" do + expect(:patch => "/print_settings/1").to route_to("print_settings#update", :id => "1") + end + + it "routes to #destroy" do + expect(:delete => "/print_settings/1").to route_to("print_settings#destroy", :id => "1") + end + + end +end diff --git a/spec/views/print_settings/edit.html.erb_spec.rb b/spec/views/print_settings/edit.html.erb_spec.rb new file mode 100644 index 00000000..4530d45c --- /dev/null +++ b/spec/views/print_settings/edit.html.erb_spec.rb @@ -0,0 +1,51 @@ +require 'rails_helper' + +RSpec.describe "print_settings/edit", type: :view do + before(:each) do + @print_setting = assign(:print_setting, PrintSetting.create!( + :name, => "MyString", + :unique_code, => "MyString", + :template, => "MyString", + :db_name, => "MyString", + :db_type, => "MyString", + :db_username, => "MyString", + :db_password, => "MyString", + :printer_name, => "MyString", + :api_settings, => "MyString", + :page_width => "", + :page_height => "", + :print_copies => 1 + )) + end + + it "renders the edit print_setting form" do + render + + assert_select "form[action=?][method=?]", print_setting_path(@print_setting), "post" do + + assert_select "input[name=?]", "print_setting[name,]" + + assert_select "input[name=?]", "print_setting[unique_code,]" + + assert_select "input[name=?]", "print_setting[template,]" + + assert_select "input[name=?]", "print_setting[db_name,]" + + assert_select "input[name=?]", "print_setting[db_type,]" + + assert_select "input[name=?]", "print_setting[db_username,]" + + assert_select "input[name=?]", "print_setting[db_password,]" + + assert_select "input[name=?]", "print_setting[printer_name,]" + + assert_select "input[name=?]", "print_setting[api_settings,]" + + assert_select "input[name=?]", "print_setting[page_width]" + + assert_select "input[name=?]", "print_setting[page_height]" + + assert_select "input[name=?]", "print_setting[print_copies]" + end + end +end diff --git a/spec/views/print_settings/index.html.erb_spec.rb b/spec/views/print_settings/index.html.erb_spec.rb new file mode 100644 index 00000000..b5e76904 --- /dev/null +++ b/spec/views/print_settings/index.html.erb_spec.rb @@ -0,0 +1,52 @@ +require 'rails_helper' + +RSpec.describe "print_settings/index", type: :view do + before(:each) do + assign(:print_settings, [ + PrintSetting.create!( + :name, => "Name,", + :unique_code, => "Unique Code,", + :template, => "Template,", + :db_name, => "Db Name,", + :db_type, => "Db Type,", + :db_username, => "Db Username,", + :db_password, => "Db Password,", + :printer_name, => "Printer Name,", + :api_settings, => "Api Settings,", + :page_width => "", + :page_height => "", + :print_copies => 2 + ), + PrintSetting.create!( + :name, => "Name,", + :unique_code, => "Unique Code,", + :template, => "Template,", + :db_name, => "Db Name,", + :db_type, => "Db Type,", + :db_username, => "Db Username,", + :db_password, => "Db Password,", + :printer_name, => "Printer Name,", + :api_settings, => "Api Settings,", + :page_width => "", + :page_height => "", + :print_copies => 2 + ) + ]) + end + + it "renders a list of print_settings" do + render + assert_select "tr>td", :text => "Name,".to_s, :count => 2 + assert_select "tr>td", :text => "Unique Code,".to_s, :count => 2 + assert_select "tr>td", :text => "Template,".to_s, :count => 2 + assert_select "tr>td", :text => "Db Name,".to_s, :count => 2 + assert_select "tr>td", :text => "Db Type,".to_s, :count => 2 + assert_select "tr>td", :text => "Db Username,".to_s, :count => 2 + assert_select "tr>td", :text => "Db Password,".to_s, :count => 2 + assert_select "tr>td", :text => "Printer Name,".to_s, :count => 2 + assert_select "tr>td", :text => "Api Settings,".to_s, :count => 2 + assert_select "tr>td", :text => "".to_s, :count => 2 + assert_select "tr>td", :text => "".to_s, :count => 2 + assert_select "tr>td", :text => 2.to_s, :count => 2 + end +end diff --git a/spec/views/print_settings/new.html.erb_spec.rb b/spec/views/print_settings/new.html.erb_spec.rb new file mode 100644 index 00000000..a4a79d4f --- /dev/null +++ b/spec/views/print_settings/new.html.erb_spec.rb @@ -0,0 +1,51 @@ +require 'rails_helper' + +RSpec.describe "print_settings/new", type: :view do + before(:each) do + assign(:print_setting, PrintSetting.new( + :name, => "MyString", + :unique_code, => "MyString", + :template, => "MyString", + :db_name, => "MyString", + :db_type, => "MyString", + :db_username, => "MyString", + :db_password, => "MyString", + :printer_name, => "MyString", + :api_settings, => "MyString", + :page_width => "", + :page_height => "", + :print_copies => 1 + )) + end + + it "renders new print_setting form" do + render + + assert_select "form[action=?][method=?]", print_settings_path, "post" do + + assert_select "input[name=?]", "print_setting[name,]" + + assert_select "input[name=?]", "print_setting[unique_code,]" + + assert_select "input[name=?]", "print_setting[template,]" + + assert_select "input[name=?]", "print_setting[db_name,]" + + assert_select "input[name=?]", "print_setting[db_type,]" + + assert_select "input[name=?]", "print_setting[db_username,]" + + assert_select "input[name=?]", "print_setting[db_password,]" + + assert_select "input[name=?]", "print_setting[printer_name,]" + + assert_select "input[name=?]", "print_setting[api_settings,]" + + assert_select "input[name=?]", "print_setting[page_width]" + + assert_select "input[name=?]", "print_setting[page_height]" + + assert_select "input[name=?]", "print_setting[print_copies]" + end + end +end diff --git a/spec/views/print_settings/show.html.erb_spec.rb b/spec/views/print_settings/show.html.erb_spec.rb new file mode 100644 index 00000000..8dd2a3eb --- /dev/null +++ b/spec/views/print_settings/show.html.erb_spec.rb @@ -0,0 +1,36 @@ +require 'rails_helper' + +RSpec.describe "print_settings/show", type: :view do + before(:each) do + @print_setting = assign(:print_setting, PrintSetting.create!( + :name, => "Name,", + :unique_code, => "Unique Code,", + :template, => "Template,", + :db_name, => "Db Name,", + :db_type, => "Db Type,", + :db_username, => "Db Username,", + :db_password, => "Db Password,", + :printer_name, => "Printer Name,", + :api_settings, => "Api Settings,", + :page_width => "", + :page_height => "", + :print_copies => 2 + )) + end + + it "renders attributes in

    " do + render + expect(rendered).to match(/Name,/) + expect(rendered).to match(/Unique Code,/) + expect(rendered).to match(/Template,/) + expect(rendered).to match(/Db Name,/) + expect(rendered).to match(/Db Type,/) + expect(rendered).to match(/Db Username,/) + expect(rendered).to match(/Db Password,/) + expect(rendered).to match(/Printer Name,/) + expect(rendered).to match(/Api Settings,/) + expect(rendered).to match(//) + expect(rendered).to match(//) + expect(rendered).to match(/2/) + end +end diff --git a/test/system/print_settings_test.rb b/test/system/print_settings_test.rb new file mode 100644 index 00000000..a0b4ab23 --- /dev/null +++ b/test/system/print_settings_test.rb @@ -0,0 +1,9 @@ +require "application_system_test_case" + +class PrintSettingsTest < ApplicationSystemTestCase + # test "visiting the index" do + # visit print_settings_url + # + # assert_selector "h1", text: "PrintSetting" + # end +end From 6d705e2860f2b638670be3bb93a98ed8fb5a2d81 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 2 Jun 2017 16:52:58 +0630 Subject: [PATCH 29/39] merge with master --- app/controllers/oqs/print_controller.rb | 5 +++++ app/helpers/oqs/print_helper.rb | 2 ++ app/views/oqs/home/index.html.erb | 2 +- app/views/oqs/print/print.html.erb | 2 ++ config/routes.rb | 2 ++ spec/controllers/oqs/print_controller_spec.rb | 12 ++++++++++++ spec/helpers/oqs/print_helper_spec.rb | 15 +++++++++++++++ spec/views/oqs/print/print.html.erb_spec.rb | 5 +++++ 8 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 app/controllers/oqs/print_controller.rb create mode 100644 app/helpers/oqs/print_helper.rb create mode 100644 app/views/oqs/print/print.html.erb create mode 100644 spec/controllers/oqs/print_controller_spec.rb create mode 100644 spec/helpers/oqs/print_helper_spec.rb create mode 100644 spec/views/oqs/print/print.html.erb_spec.rb diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb new file mode 100644 index 00000000..2b60fc3c --- /dev/null +++ b/app/controllers/oqs/print_controller.rb @@ -0,0 +1,5 @@ +class Oqs::PrintController < ApplicationController + def print + + end +end diff --git a/app/helpers/oqs/print_helper.rb b/app/helpers/oqs/print_helper.rb new file mode 100644 index 00000000..8deee2c2 --- /dev/null +++ b/app/helpers/oqs/print_helper.rb @@ -0,0 +1,2 @@ +module Oqs::PrintHelper +end diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 69fe3f20..5527f530 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -197,7 +197,7 @@

    diff --git a/app/views/oqs/print/print.html.erb b/app/views/oqs/print/print.html.erb new file mode 100644 index 00000000..857c6622 --- /dev/null +++ b/app/views/oqs/print/print.html.erb @@ -0,0 +1,2 @@ +

    Oqs::Print#print

    +

    Find me in app/views/oqs/print/print.html.erb

    diff --git a/config/routes.rb b/config/routes.rb index eadc26b0..df6e2466 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -99,6 +99,8 @@ Rails.application.routes.draw do root "home#index" post 'update_delivery', to: "home#update_delivery_status" + + get 'print/print' #dashboard # end diff --git a/spec/controllers/oqs/print_controller_spec.rb b/spec/controllers/oqs/print_controller_spec.rb new file mode 100644 index 00000000..4c1ab5fb --- /dev/null +++ b/spec/controllers/oqs/print_controller_spec.rb @@ -0,0 +1,12 @@ +require 'rails_helper' + +RSpec.describe Oqs::PrintController, type: :controller do + + describe "GET #print" do + it "returns http success" do + get :print + expect(response).to have_http_status(:success) + end + end + +end diff --git a/spec/helpers/oqs/print_helper_spec.rb b/spec/helpers/oqs/print_helper_spec.rb new file mode 100644 index 00000000..9bd805c3 --- /dev/null +++ b/spec/helpers/oqs/print_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the Oqs::PrintHelper. For example: +# +# describe Oqs::PrintHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe Oqs::PrintHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/oqs/print/print.html.erb_spec.rb b/spec/views/oqs/print/print.html.erb_spec.rb new file mode 100644 index 00000000..425bd139 --- /dev/null +++ b/spec/views/oqs/print/print.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "print/print.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end From 63be238e091d87d23c0f63eb87b3f8d798cba3ed Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 2 Jun 2017 18:26:44 +0630 Subject: [PATCH 30/39] uncomplete print, need for print_settings --- app/assets/javascripts/OQS.js | 13 +++++++++++++ app/assets/stylesheets/OQS.scss | 4 ++++ app/controllers/oqs/print_controller.rb | 5 ++++- app/models/printer/order_queue_printer.rb | 4 ++-- app/views/oqs/home/index.html.erb | 7 +++++-- config/routes.rb | 2 +- 6 files changed, 29 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index dd8bed28..80a09b47 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -33,6 +33,9 @@ $(document).ready(function(){ $('#order-items').text(orderItem); $('#order-qty').text(orderQty); + + $('.queue_station').removeClass('selected-item'); + $(this).addClass('selected-item'); }); // complete for queue item @@ -67,4 +70,14 @@ $(document).ready(function(){ } }); }); + + $('#print_order_item').on('click',function(){ + var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); + var params = { 'id':assigned_item_id }; + $.ajax({ + type: 'GET', + url: '/oqs/print/print/'+assigned_item_id, + success: function(data){ } + }); + }); }); diff --git a/app/assets/stylesheets/OQS.scss b/app/assets/stylesheets/OQS.scss index 23a49d41..07c98b85 100644 --- a/app/assets/stylesheets/OQS.scss +++ b/app/assets/stylesheets/OQS.scss @@ -14,3 +14,7 @@ .order-void { background-color: #FFCCDD; } + +.selected-item { + background-color: blue; +} diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb index 2b60fc3c..d22a464a 100644 --- a/app/controllers/oqs/print_controller.rb +++ b/app/controllers/oqs/print_controller.rb @@ -1,5 +1,8 @@ class Oqs::PrintController < ApplicationController def print - + assigned_item_id=params[:id] + assigned_order_item=AssignedOrderItem.select("order_id, item_code").where('id='+assigned_item_id) + order_queue_printer= OrderQueuePrinter.new + order_queue_printer.print_order_item(assigned_order_item[0].order_id, assigned_order_item[0].item_code ) end end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 4e520ed9..869e12c4 100644 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -1,11 +1,11 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker - def print_order_item(order_queue_id) + def print_order_item(order_id, item_code) #Use CUPS service #Generate PDF #Print pdf = OrderItemPdf.new - pdf.render_file "tmp/order_item_queue_#{order_id}_#{order_item_id}" + ".pdf" + pdf.render_file "tmp/order_item_queue_#{order_id}_#{item_code}" + ".pdf" self.print("tmp/receipt.pdf") end diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 5527f530..af0f0642 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -69,6 +69,7 @@

    +
    +
    diff --git a/config/routes.rb b/config/routes.rb index df6e2466..30c0d827 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -100,7 +100,7 @@ Rails.application.routes.draw do post 'update_delivery', to: "home#update_delivery_status" - get 'print/print' + get 'print/print/:id', to: "print#print" #dashboard # end From 3d05a91adf28b1a4e0dedcc76c5688378ff4120c Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 2 Jun 2017 18:49:44 +0630 Subject: [PATCH 31/39] Print ui update --- app/views/print_settings/show.html.erb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/print_settings/show.html.erb b/app/views/print_settings/show.html.erb index 77e89fb7..12d15696 100644 --- a/app/views/print_settings/show.html.erb +++ b/app/views/print_settings/show.html.erb @@ -2,47 +2,47 @@

    Name: - <%= @print_setting.name, %> + <%= @print_setting.name %>

    Unique code: - <%= @print_setting.unique_code, %> + <%= @print_setting.unique_code %>

    Template: - <%= @print_setting.template, %> + <%= @print_setting.template %>

    Db name: - <%= @print_setting.db_name, %> + <%= @print_setting.db_name %>

    Db type: - <%= @print_setting.db_type, %> + <%= @print_setting.db_type %>

    Db username: - <%= @print_setting.db_username, %> + <%= @print_setting.db_username %>

    Db password: - <%= @print_setting.db_password, %> + <%= @print_setting.db_password %>

    Printer name: - <%= @print_setting.printer_name, %> + <%= @print_setting.printer_name %>

    Api settings: - <%= @print_setting.api_settings, %> + <%= @print_setting.api_settings %>

    From 90ca4651aa43e87824340cbc46ee79b79e179266 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 2 Jun 2017 18:50:21 +0630 Subject: [PATCH 32/39] add print controller --- app/controllers/oqs/print_controller.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 app/controllers/oqs/print_controller.rb diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb new file mode 100644 index 00000000..951a8be7 --- /dev/null +++ b/app/controllers/oqs/print_controller.rb @@ -0,0 +1,17 @@ +class Oqs::PrintController < ApplicationController + def print + unique_code =params[:unique_code] + assigned_item_id=params[:id] + if unique_code=="OrderItemPdf" + # print_settings=PrintingSetting.find_by_unique_cod(unique_code) + # obj= OrderQueuePrinter.new(print_settings) + # obj.print_order_item(print_settings,assigned_item_id) + + + end + + # assigned_order_item=AssignedOrderItem.select("order_id, item_code").where('id='+assigned_item_id) + + # order_queue_printer.print_order_item(assigned_order_item[0].order_id, assigned_order_item[0].item_code ) + end +end From 2716b913f2afa125c6c06d47db7adeedb4de3baa Mon Sep 17 00:00:00 2001 From: PhyoTheingi Date: Sat, 3 Jun 2017 11:59:29 +0630 Subject: [PATCH 33/39] Setting Instances Update --- .../menu_item_instances_controller.rb | 70 +++++++++++---- .../settings/set_menu_items_controller.rb | 1 + .../settings/menu_categories/show.html.erb | 7 +- .../menu_item_instances/_form.html.erb | 2 +- .../menu_item_instances/edit.html.erb | 6 +- .../settings/menu_item_instances/new.html.erb | 9 +- .../menu_item_instances/show.html.erb | 90 +++++-------------- .../settings/set_menu_items/index.html.erb | 2 +- .../settings/set_menu_items/show.html.erb | 46 +++++++++- .../settings/simple_menu_items/index.html.erb | 2 +- .../settings/simple_menu_items/show.html.erb | 19 ++-- config/routes.rb | 7 +- 12 files changed, 152 insertions(+), 109 deletions(-) diff --git a/app/controllers/settings/menu_item_instances_controller.rb b/app/controllers/settings/menu_item_instances_controller.rb index fecc3cd7..775be176 100644 --- a/app/controllers/settings/menu_item_instances_controller.rb +++ b/app/controllers/settings/menu_item_instances_controller.rb @@ -1,6 +1,6 @@ class Settings::MenuItemInstancesController < ApplicationController before_action :set_settings_menu_item_instance, only: [:show, :edit, :update, :destroy] - before_action :set_settings_menu_item, only: [:index, :show, :edit, :new, :update] + before_action :set_settings_menu_item, only: [ :show, :edit, :new, :update] # GET /settings/menu_item_instances # GET /settings/menu_item_instances.json @@ -11,29 +11,51 @@ class Settings::MenuItemInstancesController < ApplicationController # GET /settings/menu_item_instances/1 # GET /settings/menu_item_instances/1.json def show + @category = MenuCategory.find(@item.menu_category_id) end # GET /settings/menu_item_instances/new def new - @settings_menu_item_instance = MenuItemInstance.new + if params[:simple_menu_item_id] + @aa = MenuItem.find(params[:simple_menu_item_id]) + else + @aa = MenuItem.find(params[:set_menu_item_id]) + end + @category = MenuCategory.find(@item.menu_category_id) + @settings_menu_item_instances = MenuItemInstance.new end # GET /settings/menu_item_instances/1/edit def edit + if params[:simple_menu_item_id] + @aa = MenuItem.find(params[:simple_menu_item_id]) + else + @aa = MenuItem.find(params[:set_menu_item_id]) + end + @category = MenuCategory.find(@item.menu_category_id) end # POST /settings/menu_item_instances # POST /settings/menu_item_instances.json def create - @settings_menu_item_instance = MenuItemInstance.new(settings_menu_item_instance_params) + @settings_menu_item_instances = MenuItemInstance.new(settings_menu_item_instance_params) + if params[:simple_menu_item_id] + @settings_menu_item_instances.menu_item_id = params[:simple_menu_item_id] + catID = MenuItem.find(params[:simple_menu_item_id]) + else + @settings_menu_item_instances.menu_item_id = params[:set_menu_item_id] + catID = MenuItem.find(params[:set_menu_item_id]) + end + + category = MenuCategory.find(catID.menu_category_id) respond_to do |format| - if @settings_menu_item_instance.save - format.html { redirect_to settings_menu_item_instances_path, notice: 'Menu item instance was successfully created.' } - format.json { render :show, status: :created, location: @settings_menu_item_instance } + if @settings_menu_item_instances.save + format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully created.' } + format.json { render :show, status: :created, location: @settings_menu_item_instances } else format.html { render :new } - format.json { render json: @settings_menu_item_instance.errors, status: :unprocessable_entity } + format.json { render json: @settings_menu_item_instances.errors, status: :unprocessable_entity } end end end @@ -41,13 +63,19 @@ class Settings::MenuItemInstancesController < ApplicationController # PATCH/PUT /settings/menu_item_instances/1 # PATCH/PUT /settings/menu_item_instances/1.json def update + if params[:simple_menu_item_id] + catID = MenuItem.find(params[:simple_menu_item_id]) + else + catID = MenuItem.find(params[:set_menu_item_id]) + end + category = MenuCategory.find(catID.menu_category_id) respond_to do |format| - if @settings_menu_item_instance.update(settings_menu_item_instance_params) - format.html { redirect_to settings_menu_item_instance_path(@settings_menu_item_instance), notice: 'Menu item instance was successfully updated.' } - format.json { render :show, status: :ok, location: @settings_menu_item_instance } + if @settings_menu_item_instances.update(settings_menu_item_instance_params) + format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully updated.' } + format.json { render :show, status: :ok, location: @settings_menu_item_instances } else format.html { render :edit } - format.json { render json: @settings_menu_item_instance.errors, status: :unprocessable_entity } + format.json { render json: @settings_menu_item_instances.errors, status: :unprocessable_entity } end end end @@ -55,9 +83,15 @@ class Settings::MenuItemInstancesController < ApplicationController # DELETE /settings/menu_item_instances/1 # DELETE /settings/menu_item_instances/1.json def destroy - # @settings_menu_item_instance.destroy + @settings_menu_item_instances.destroy + if params[:simple_menu_item_id] + catID = MenuItem.find(params[:simple_menu_item_id]) + else + catID = MenuItem.find(params[:set_menu_item_id]) + end + category = MenuCategory.find(catID.menu_category_id) respond_to do |format| - format.html { redirect_to settings_menu_item_instances_path, notice: 'Menu item instance was successfully destroyed.' } + format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully destroyed.' } format.json { head :no_content } end end @@ -65,15 +99,19 @@ class Settings::MenuItemInstancesController < ApplicationController private # Use callbacks to share common setup or constraints between actions. def set_settings_menu_item_instance - @set_settings_menu_item_instances = MenuItemInstance.find(params[:id]) + @settings_menu_item_instances = MenuItemInstance.find(params[:id]) end def set_settings_menu_item - @item = MenuItem.find(params[:menu_item_id]) + if params[:simple_menu_item_id] + @item = MenuItem.find(params[:simple_menu_item_id]) + else + @item = MenuItem.find(params[:set_menu_item_id]) + end end # Never trust parameters from the scary internet, only allow the white list through. def settings_menu_item_instance_params - params.require(:menu_item_instance).permit(:name, :value) + params.require(:menu_item_instance).permit(:item_instance_code, :item_instance_name, :price, :is_on_promotion, :promotion_price, :is_available,:menu_category_id,:menu_item_id) end end diff --git a/app/controllers/settings/set_menu_items_controller.rb b/app/controllers/settings/set_menu_items_controller.rb index cc5e89e8..7ef6cc18 100644 --- a/app/controllers/settings/set_menu_items_controller.rb +++ b/app/controllers/settings/set_menu_items_controller.rb @@ -11,6 +11,7 @@ class Settings::SetMenuItemsController < ApplicationController # GET /settings/menu_items/1.json def show @sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10) + @menu_item_instance = MenuItemInstance.where("menu_item_id=?",params[:id]).page(params[:page]).per(10) end # GET /settings/menu_items/new diff --git a/app/views/settings/menu_categories/show.html.erb b/app/views/settings/menu_categories/show.html.erb index dcd7b45d..88430b51 100644 --- a/app/views/settings/menu_categories/show.html.erb +++ b/app/views/settings/menu_categories/show.html.erb @@ -28,7 +28,7 @@ <%= @settings_menu_category.name rescue "-" %> <%= @settings_menu_category.alt_name %> <%= @settings_menu_category.order_by %> - <%=l @settings_menu_category.created_at, format: :short %> + <%= @settings_menu_category.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %> <%= link_to 'Edit', edit_settings_menu_menu_category_path(@settings_menu_category, @settings_menu_category) %> @@ -37,6 +37,7 @@


    +<% if @settings_menu_category.menu_items.count > 0 %>

    Menu Items @@ -69,7 +70,7 @@ <%= settings_menu_item.type %> <%= settings_menu_item.parent.name rescue "-" %> <%= settings_menu_item.created_by %> - <%=l settings_menu_item.created_at, :format => :short %> + <%= settings_menu_item.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %> <% if settings_menu_item.type == "SimpleMenuItem" %> <%= link_to 'Show', settings_menu_category_simple_menu_item_path(@settings_menu_category, settings_menu_item ) %> <%= link_to 'Edit', edit_settings_menu_category_simple_menu_item_path(@settings_menu_category, settings_menu_item) %> @@ -85,5 +86,5 @@

    - +<% end %>
    \ No newline at end of file diff --git a/app/views/settings/menu_item_instances/_form.html.erb b/app/views/settings/menu_item_instances/_form.html.erb index b369a1d3..e2751fee 100644 --- a/app/views/settings/menu_item_instances/_form.html.erb +++ b/app/views/settings/menu_item_instances/_form.html.erb @@ -1,4 +1,4 @@ -<%= simple_form_for([:settings,:menu_item, @settings_menu_item_instance]) do |f| %> +<%= simple_form_for([:settings, @item, @settings_menu_item_instances]) do |f| %> <%= f.error_notification %>
    diff --git a/app/views/settings/menu_item_instances/edit.html.erb b/app/views/settings/menu_item_instances/edit.html.erb index 158b7c1c..887806cb 100644 --- a/app/views/settings/menu_item_instances/edit.html.erb +++ b/app/views/settings/menu_item_instances/edit.html.erb @@ -4,9 +4,11 @@ - <%= render 'form', settings_set_menu_item: @settings_menu_item %> + <%= render 'form', settings_menu_item_menu_item_instances: @settings_menu_item_instances %>
    diff --git a/app/views/settings/menu_item_instances/new.html.erb b/app/views/settings/menu_item_instances/new.html.erb index 9fae5b34..b4de46cf 100644 --- a/app/views/settings/menu_item_instances/new.html.erb +++ b/app/views/settings/menu_item_instances/new.html.erb @@ -1,17 +1,16 @@ +<%= render 'form', settings_menu_item: @settings_menu_item %>-->
    - <%= render 'form', settings_set_menu_instance: @settings_menu_item_instance %> + <%= render 'form', settings_simple_menu_item_menu_item_instances: @settings_menu_item_instances %>
    diff --git a/app/views/settings/menu_item_instances/show.html.erb b/app/views/settings/menu_item_instances/show.html.erb index 238fa038..44c84be4 100644 --- a/app/views/settings/menu_item_instances/show.html.erb +++ b/app/views/settings/menu_item_instances/show.html.erb @@ -1,9 +1,10 @@ diff --git a/app/views/settings/set_menu_items/index.html.erb b/app/views/settings/set_menu_items/index.html.erb index bfe6a99f..8d529a43 100644 --- a/app/views/settings/set_menu_items/index.html.erb +++ b/app/views/settings/set_menu_items/index.html.erb @@ -71,7 +71,7 @@ <%= settings_menu_item.type %> <%= settings_menu_item.parent.name rescue "-" %> <%= settings_menu_item.created_by %> - <%=l settings_menu_item.created_at, :format => :short %> + <%= settings_menu_item.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %> <% if settings_menu_item.type == "SimpleMenuItem" %> <%= link_to 'Show', settings_menu_category_simple_menu_item_path(@category, settings_menu_item ) %> diff --git a/app/views/settings/set_menu_items/show.html.erb b/app/views/settings/set_menu_items/show.html.erb index 238fa038..c0aeca31 100644 --- a/app/views/settings/set_menu_items/show.html.erb +++ b/app/views/settings/set_menu_items/show.html.erb @@ -40,13 +40,14 @@ <%= @settings_menu_item.min_qty %> <%= @settings_menu_item.min_selectable_item %> <%= @settings_menu_item.max_selectable_item %> - <%=l @settings_menu_item.created_at, format: :short %> + <%= @settings_menu_item.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %> <%= link_to 'Edit', edit_settings_menu_category_set_menu_item_path(@category, @settings_menu_item) %>
    +<% if @sub_menu.count > 0 %>
    @@ -75,7 +76,7 @@ <%= settings_menu_item.type %> <%= settings_menu_item.parent.name rescue "-" %> <%= settings_menu_item.created_by %> - <%=l settings_menu_item.created_at, :format => :short %> + <%= settings_menu_item.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %> <% if settings_menu_item.type == "SimpleMenuItem" %> <%= link_to 'Show', settings_menu_category_simple_menu_item_path(@category, settings_menu_item ) %> @@ -93,4 +94,45 @@
    <%= paginate @sub_menu, param_name: :page, :outer_window => 3 %> +<% end %> +
    +
    +
    +

    Menu Item Instances + + <%= link_to t('.new', :default => t("helpers.links.new")),new_settings_menu_item_menu_item_instance_path(@settings_menu_item),:class => 'btn btn-primary btn-sm' %> + + +

    + + + + + + + + + + + + + + + + + <% @menu_item_instance.each do |settings_menu_item| %> + + + + + + + + + + <% end %> + +
    item_instance_codeitem_attributespriceis_on_promotionpromotion_priceCreated at
    <%= settings_menu_item.item_instance_code %><%= settings_menu_item.item_attributes %><%= settings_menu_item.price %><%= settings_menu_item.is_on_promotion %><%= settings_menu_item.promotion_price %><%= settings_menu_item.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %>
    +
    +
    diff --git a/app/views/settings/simple_menu_items/index.html.erb b/app/views/settings/simple_menu_items/index.html.erb index 4a9efb75..b82af610 100644 --- a/app/views/settings/simple_menu_items/index.html.erb +++ b/app/views/settings/simple_menu_items/index.html.erb @@ -70,7 +70,7 @@ <%= settings_menu_item.type %> <%= settings_menu_item.parent.name rescue "-" %> <%= settings_menu_item.created_by %> - <%=l settings_menu_item.created_at, :format => :short %> + <%= settings_menu_item.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %> <% if settings_menu_item.type == "SimpleMenuItem" %> <%= link_to 'Show', settings_menu_category_simple_menu_item_path(@category, settings_menu_item ) %> diff --git a/app/views/settings/simple_menu_items/show.html.erb b/app/views/settings/simple_menu_items/show.html.erb index 7f68c9aa..878cd2e5 100644 --- a/app/views/settings/simple_menu_items/show.html.erb +++ b/app/views/settings/simple_menu_items/show.html.erb @@ -40,13 +40,14 @@ <%= @settings_menu_item.min_qty %> <%= @settings_menu_item.min_selectable_item %> <%= @settings_menu_item.max_selectable_item %> - <%=l @settings_menu_item.created_at, format: :short %> + <%= @settings_menu_item.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %> <%= link_to 'Edit', edit_settings_menu_category_simple_menu_item_path(@category, @settings_menu_item) %>
    +<% if @sub_menu.count > 0 %>
    @@ -75,7 +76,7 @@ <%= settings_menu_item.type %> <%= settings_menu_item.parent.name rescue "-" %> <%= settings_menu_item.created_by %> - <%=l settings_menu_item.created_at, :format => :short %> + <%= settings_menu_item.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %> <% if settings_menu_item.type == "SimpleMenuItem" %> <%= link_to 'Show', settings_menu_category_simple_menu_item_path(@category, settings_menu_item ) %> @@ -93,20 +94,20 @@
    <%= paginate @sub_menu, param_name: :page, :outer_window => 3 %> - +<% end %>

    Menu Item Instances - <%= link_to t('.new', :default => t("helpers.links.new")),new_settings_menu_item_menu_item_instance_path(@settings_menu_item),:class => 'btn btn-primary btn-sm' %> + <%= link_to t('.new', :default => t("helpers.links.new")),new_settings_simple_menu_item_menu_item_instance_path(@settings_menu_item),:class => 'btn btn-primary btn-sm' %>

    - + @@ -121,13 +122,17 @@ <% @menu_item_instance.each do |settings_menu_item| %> - + - + + + + + <% end %> diff --git a/config/routes.rb b/config/routes.rb index ed2cdab0..baa2e6e4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -105,12 +105,15 @@ Rails.application.routes.draw do resources :menu_categories do #menu_items - #resources :menu_items + # resources :menu_items resources :simple_menu_items resources :set_menu_items end - resources :menu_items do + resources :simple_menu_items do + resources :menu_item_instances + end + resources :set_menu_items do resources :menu_item_instances end #menu_item_attributes From 2e2bda168cf08b57742b83ca7da81186d8a6f120 Mon Sep 17 00:00:00 2001 From: Yan Date: Sat, 3 Jun 2017 12:41:24 +0630 Subject: [PATCH 34/39] print developing --- app/controllers/oqs/print_controller.rb | 23 +++++----------- app/models/printer/order_queue_printer.rb | 33 +++++++++++++++++++---- app/pdf/order_item_pdf.rb | 21 ++++++++++++--- 3 files changed, 52 insertions(+), 25 deletions(-) diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb index d41559ee..368a513d 100644 --- a/app/controllers/oqs/print_controller.rb +++ b/app/controllers/oqs/print_controller.rb @@ -1,25 +1,16 @@ class Oqs::PrintController < ApplicationController def print - unique_code=="OrderItemPdf" + unique_code="OrderItemPdf" assigned_item_id=params[:id] assigned_order_item=AssignedOrderItem.select("order_id, item_code").where('id='+assigned_item_id) - print_settings=PrintingSetting.find_by_unique_cod(unique_code) - # order_queue_printer= OrderQueuePrinter.new(print_settings) + print_settings=PrintSetting.find_by_unique_code(unique_code) + order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) order_queue_printer.print_order_item(print_settings,assigned_order_item[0].order_id, assigned_order_item[0].item_code ) - unique_code =params[:unique_code] - assigned_item_id=params[:id] - # if unique_code=="OrderItemPdf" - # print_settings=PrintingSetting.find_by_unique_cod(unique_code) - # obj= OrderQueuePrinter.new(print_settings) - # obj.print_order_item(print_settings,assigned_item_id) - - - # end - - # assigned_order_item=AssignedOrderItem.select("order_id, item_code").where('id='+assigned_item_id) - - # order_queue_printer.print_order_item(assigned_order_item[0].order_id, assigned_order_item[0].item_code ) + # update print status when complete click + assigned_item=AssignedOrderItem.find(assigned_item_id) + assigned_item.print_status=true + assigned_item.save end end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index e81934a7..6a8a4b78 100644 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -4,20 +4,43 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker #Use CUPS service #Generate PDF #Print - order_item=OrderItem.find_by_item_code(item_code) - pdf = OrderItemPdf.new(printer_settings,order_item) - pdf.render_file "tmp/order_item_queue_#{order_id}_#{item_code}" + ".pdf" + order_item= print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code) + pdf = OrderItemPdf.new(order_item[0],printer_settings) + pdf.render_file "tmp/receipt.pdf" self.print("tmp/receipt.pdf") end - def print_order_summary(booking_id) + def print_order_summary(printer_settings,booking_id) #Use CUPS service #Generate PDF #Print + order=print_query('booking',booking_id) filename = "tmp/order_summary_#{booking_id}" + ".pdf" - pdf = OrderSummaryPdf.new + pdf = OrderSummaryPdf.new(order,printer_settings) pdf.render_file filename self.print(filename) end + + # Query for OQS with status + def print_query(type, code) + if type == 'order_item' + OrderItem.select("order_items.item_code, order_items.item_name,order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining") + .joins("left join orders ON orders.id = order_items.order_id + left join booking_orders AS bo ON bo.order_id=order_items.order_id + left join bookings AS b ON b.id = bo.booking_id + left join dining_facilities AS df ON df.id = b.dining_facility_id + left join customers as cus ON cus.id = orders.customer_id") + .where("order_items.item_code=" + code) + .group("order_items.item_code") + else + OrderItem.select("order_items.item_code, order_items.item_name, df.name as dining") + .joins("left join orders ON orders.id = order_items.order_id + left join booking_orders AS bo ON bo.order_id=order_items.order_id + left join bookings AS b ON b.id = bo.booking_id + left join dining_facilities AS df ON df.id = b.dining_facility_id") + .where("booking.id=" + code) + end + + end end diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 76df37e2..356327b4 100644 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -5,14 +5,27 @@ class OrderItemPdf < Prawn::Document # font "public/fonts/#{font_name}".to_s + ".ttf".to_s # font "public/fonts/Zawgyi-One.ttf" - # font "public/fonts/padauk.ttf" - - + # font "public/fonts/padauk.ttf" font_size 9 - text "#{"table_name"}", :size => 15 + text "#{order_item.dining}", :size => 15 stroke_horizontal_rule move_down 5 + cashier_info(order_item.order_by,order_item.order_at, order_item.customer) + + end + + def cashier_info(order_by, order_at, customer) + move_down 5 + y_position = cursor + + bounding_box([0,y_position], :width =>200, :height => 20) do + text "OrderBy:#{order_by} Customer:#{customer} Date:#{order_at.strftime("%Y %m %d")}", :size => 7,:align => :left + end + + stroke_horizontal_rule + + move_down 5 end end From 4dbf52d5a42cb88458bd9927c128ae3b6e8502ea Mon Sep 17 00:00:00 2001 From: Min Zeya Phyo Date: Sat, 3 Jun 2017 12:48:05 +0630 Subject: [PATCH 35/39] remove ignore for gemfile and gemfile.lock, re-add mysql2 --- .gitignore | 4 ++-- Gemfile | 2 +- Gemfile.lock | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index c29faad2..02338531 100644 --- a/.gitignore +++ b/.gitignore @@ -43,5 +43,5 @@ config/deploy/config/* .byebug_history # Gem files -Gemfile -Gemfile.lock \ No newline at end of file +#Gemfile +#Gemfile.lock diff --git a/Gemfile b/Gemfile index 7668adad..29843573 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.0' # Use mysql as the database for Active Record -#gem 'mysql2', '>= 0.3.18', '< 0.5' +gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL gem 'pg' diff --git a/Gemfile.lock b/Gemfile.lock index 24527519..0c3a3a27 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -114,6 +114,7 @@ GEM mini_portile2 (2.1.0) minitest (5.10.2) multi_json (1.12.1) + mysql2 (0.4.6) nio4r (2.1.0) nokogiri (1.7.2) mini_portile2 (~> 2.1.0) @@ -251,6 +252,7 @@ DEPENDENCIES jquery-rails kaminari! listen (~> 3.0.5) + mysql2 (>= 0.3.18, < 0.5) pg prawn prawn-table From aa36c679ab7f63e5cf349810464ae240619428ba Mon Sep 17 00:00:00 2001 From: Yan Date: Sat, 3 Jun 2017 13:25:23 +0630 Subject: [PATCH 36/39] oqs item count fixed --- app/controllers/oqs/home_controller.rb | 21 ++++++++++----------- app/views/oqs/home/index.html.erb | 26 +++++++++----------------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index bbfb166d..1292a5e6 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -1,23 +1,22 @@ class Oqs::HomeController < BaseOqsController def index - @queue_stations=OrderQueueStation.all + queue_stations=OrderQueueStation.all - @queue_items_details = queue_items_query('false') + @queue_items_details = queue_items_query(0) - @queue_completed_item = queue_items_query('true') + @queue_completed_item = queue_items_query(1) @queue_stations_items=Array.new # Calculate Count for each station tab - @queue_stations.each do |que| + queue_stations.each do |que| i=0 @queue_items_details.each do |qid| - if qid.station_name == que.station_name - i+=1 - @queue_stations_items.push({:station_name => que.station_name ,:item_count => i }) - break + if qid.station_name == que.station_name + i=i+1 end - end + end + @queue_stations_items.push({:station_name => que.station_name, :is_active => que.is_active ,:item_count => i }) end @queue_stations_items @@ -43,8 +42,8 @@ class Oqs::HomeController < BaseOqsController left join orders as od ON od.id = assigned_order_items.order_id left join order_items as odt ON odt.item_code = assigned_order_items.item_code left join customers as cus ON cus.id = od.customer_id") - .where('assigned_order_items.delivery_status=' + status) - .group('assigned_order_items.id') + .where("assigned_order_items.delivery_status = #{status}") + .group("assigned_order_items.id") .order("odt.item_name DESC") end end diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index af0f0642..982264ab 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -12,25 +12,17 @@ <% # For Tab Disable for Station is inactive status="" - @queue_stations.each do |que| - if que.is_active == false + @queue_stations_items.each do |qsi| + if qsi[:is_active] == false status="disabled" end %> <% end %> @@ -84,15 +76,15 @@ <% - @queue_stations.each do |que| + @queue_stations_items.each do |qsi| %> -
    role="tabpanel"> +
    role="tabpanel">
    <% @queue_items_details.each do |qid| - if qid.station_name == que.station_name + if qid.station_name == qsi[:station_name] %>
    From eab356233cd312795e2a469c73ce84451e0c5e3b Mon Sep 17 00:00:00 2001 From: Min Zeya Phyo Date: Sat, 3 Jun 2017 15:04:53 +0630 Subject: [PATCH 37/39] add new model - shop - it will be use to define what is setup --- app/assets/stylesheets/application.scss | 25 ++++++++++++++++++++++++- app/views/layouts/application.html.erb | 1 - config/application.rb | 3 +++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 7aa6d6c5..9456be10 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -9,6 +9,29 @@ // padding-top: 4.5rem; // } +.setting_nav{ + background-color: #2f5663; +} + +ul.navbar-nav li a{ + text-decoration :none; + color :#e6e6e6; +} + +ul.dropdown-menu li a{ + text-decoration :none; + color :#525252; +} + +.setting_breadcrumb{ + background-color: transparent !important; + margin-bottom: 0px !important; +} +.page-header{ + border-bottom :0px solid #000 !important; + margin :0px !important; +} + /*----- Order Processing Items -----*/ .opi_ul { display:block; @@ -33,4 +56,4 @@ /*----- Header Bar -----*/ -/*----- Header Bar -----*/ \ No newline at end of file +/*----- Header Bar -----*/ diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 44624a43..04d23403 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -10,7 +10,6 @@ <%= csrf_meta_tags %> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> - <%= stylesheet_link_tag 'settings', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> diff --git a/config/application.rb b/config/application.rb index 9ca67743..90f088bd 100644 --- a/config/application.rb +++ b/config/application.rb @@ -14,5 +14,8 @@ module SXRestaurants config.active_record.time_zone_aware_types = [:datetime, :time] config.active_job.queue_adapter = :sidekiq + # config.generators do |g| + # g.orm :active_record, primary_key_type: :uuid + # end end end From a01c4bd9cfb089da39c8c5e33512e937d99ada71 Mon Sep 17 00:00:00 2001 From: PhyoTheingi Date: Sat, 3 Jun 2017 17:09:56 +0630 Subject: [PATCH 38/39] Menu Item instances and OQS json saving --- .../menu_item_instances_controller.rb | 19 ++++++++----------- .../order_queue_stations_controller.rb | 3 ++- .../settings/simple_menu_items_controller.rb | 2 +- app/models/menu_item_attribute.rb | 4 +++- .../settings/menu_categories/show.html.erb | 2 -- .../menu_item_instances/_form.html.erb | 2 +- .../menu_item_instances/show.html.erb | 2 +- app/views/settings/menus/show.html.erb | 2 +- .../settings/set_menu_items/new.html.erb | 4 +--- .../settings/set_menu_items/show.html.erb | 5 ++++- .../settings/simple_menu_items/new.html.erb | 4 +--- .../settings/simple_menu_items/show.html.erb | 2 +- 12 files changed, 24 insertions(+), 27 deletions(-) diff --git a/app/controllers/settings/menu_item_instances_controller.rb b/app/controllers/settings/menu_item_instances_controller.rb index 775be176..97115e4e 100644 --- a/app/controllers/settings/menu_item_instances_controller.rb +++ b/app/controllers/settings/menu_item_instances_controller.rb @@ -16,22 +16,12 @@ class Settings::MenuItemInstancesController < ApplicationController # GET /settings/menu_item_instances/new def new - if params[:simple_menu_item_id] - @aa = MenuItem.find(params[:simple_menu_item_id]) - else - @aa = MenuItem.find(params[:set_menu_item_id]) - end @category = MenuCategory.find(@item.menu_category_id) @settings_menu_item_instances = MenuItemInstance.new end # GET /settings/menu_item_instances/1/edit def edit - if params[:simple_menu_item_id] - @aa = MenuItem.find(params[:simple_menu_item_id]) - else - @aa = MenuItem.find(params[:set_menu_item_id]) - end @category = MenuCategory.find(@item.menu_category_id) end @@ -51,6 +41,8 @@ class Settings::MenuItemInstancesController < ApplicationController category = MenuCategory.find(catID.menu_category_id) respond_to do |format| if @settings_menu_item_instances.save + @settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes] + @settings_menu_item_instances.save format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully created.' } format.json { render :show, status: :created, location: @settings_menu_item_instances } else @@ -63,6 +55,8 @@ class Settings::MenuItemInstancesController < ApplicationController # PATCH/PUT /settings/menu_item_instances/1 # PATCH/PUT /settings/menu_item_instances/1.json def update + puts "params[:menu_item_instance][:item_attributes]" + puts params[:menu_item_instance][:item_attributes] if params[:simple_menu_item_id] catID = MenuItem.find(params[:simple_menu_item_id]) else @@ -70,7 +64,10 @@ class Settings::MenuItemInstancesController < ApplicationController end category = MenuCategory.find(catID.menu_category_id) respond_to do |format| + if @settings_menu_item_instances.update(settings_menu_item_instance_params) + @settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].reject(&:blank?) + @settings_menu_item_instances.save format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully updated.' } format.json { render :show, status: :ok, location: @settings_menu_item_instances } else @@ -112,6 +109,6 @@ class Settings::MenuItemInstancesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_menu_item_instance_params - params.require(:menu_item_instance).permit(:item_instance_code, :item_instance_name, :price, :is_on_promotion, :promotion_price, :is_available,:menu_category_id,:menu_item_id) + params.require(:menu_item_instance).permit(:item_instance_code, :item_instance_name, :price, :item_attributes, :is_on_promotion, :promotion_price, :is_available,:menu_category_id,:menu_item_id) end end diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb index e0cf0d08..46fcb54d 100644 --- a/app/controllers/settings/order_queue_stations_controller.rb +++ b/app/controllers/settings/order_queue_stations_controller.rb @@ -4,7 +4,7 @@ class Settings::OrderQueueStationsController < ApplicationController # GET /settings/order_queue_stations # GET /settings/order_queue_stations.json def index - @settings_order_queue_stations = OrderQueueStation.all + @settings_order_queue_stations = OrderQueueStation.all.active end # GET /settings/order_queue_stations/1 @@ -40,6 +40,7 @@ class Settings::OrderQueueStationsController < ApplicationController # PATCH/PUT /settings/order_queue_stations/1 # PATCH/PUT /settings/order_queue_stations/1.json def update + params[:order_queue_station][:processing_items] = params[:order_queue_station][:processing_items].split(/,/).inspect respond_to do |format| if @settings_order_queue_station.update(settings_order_queue_station_params) format.html { redirect_to settings_order_queue_station_path(@settings_order_queue_station), notice: 'Order queue station was successfully updated.' } diff --git a/app/controllers/settings/simple_menu_items_controller.rb b/app/controllers/settings/simple_menu_items_controller.rb index d2083e59..08186297 100644 --- a/app/controllers/settings/simple_menu_items_controller.rb +++ b/app/controllers/settings/simple_menu_items_controller.rb @@ -78,6 +78,6 @@ class Settings::SimpleMenuItemsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_menu_item_params - params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by) + params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:item_attributes, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by) end end diff --git a/app/models/menu_item_attribute.rb b/app/models/menu_item_attribute.rb index ebaa060e..a2fd0d1c 100644 --- a/app/models/menu_item_attribute.rb +++ b/app/models/menu_item_attribute.rb @@ -1,4 +1,6 @@ class MenuItemAttribute < ApplicationRecord validates_presence_of :attribute_type, :name, :value - + def self.collection + MenuItemAttribute.select("id, name").map { |e| [e.name, e.id] } + end end diff --git a/app/views/settings/menu_categories/show.html.erb b/app/views/settings/menu_categories/show.html.erb index 88430b51..21f2ba37 100644 --- a/app/views/settings/menu_categories/show.html.erb +++ b/app/views/settings/menu_categories/show.html.erb @@ -37,7 +37,6 @@

    -<% if @settings_menu_category.menu_items.count > 0 %>

    Menu Items @@ -86,5 +85,4 @@

    Menu Item Id item_instance_code item_attributes price
    <%= settings_menu_item.menu_item_id %> <%= settings_menu_item.item_instance_code %> <%= settings_menu_item.item_attributes %> <%= settings_menu_item.price %> <%= settings_menu_item.is_on_promotion %> <%= settings_menu_item.promotion_price %><%=l settings_menu_item.created_at, :format => :short %><%= settings_menu_item.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %><%= link_to 'Show', settings_simple_menu_item_menu_item_instance_path(@settings_menu_item, settings_menu_item ) %><%= link_to 'Edit', edit_settings_simple_menu_item_menu_item_instance_path(@settings_menu_item, settings_menu_item) %><%= link_to 'Destroy', settings_simple_menu_item_menu_item_instance_path(@settings_menu_item, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %>
    -<% end %>
    \ No newline at end of file diff --git a/app/views/settings/menu_item_instances/_form.html.erb b/app/views/settings/menu_item_instances/_form.html.erb index e2751fee..759aec65 100644 --- a/app/views/settings/menu_item_instances/_form.html.erb +++ b/app/views/settings/menu_item_instances/_form.html.erb @@ -5,7 +5,7 @@ <%= f.input :item_instance_code %> <%= f.input :item_instance_name %> <%= f.input :price %> - + <%= f.input :item_attributes, collection: MenuItemAttribute.collection, input_html: { multiple: true } %> <%= f.input :is_on_promotion %> <%= f.input :promotion_price %> diff --git a/app/views/settings/menu_item_instances/show.html.erb b/app/views/settings/menu_item_instances/show.html.erb index 44c84be4..4474d567 100644 --- a/app/views/settings/menu_item_instances/show.html.erb +++ b/app/views/settings/menu_item_instances/show.html.erb @@ -34,7 +34,7 @@ <%= @settings_menu_item_instances.is_on_promotion %> <%= @settings_menu_item_instances.promotion_price %> <%= @settings_menu_item_instances.is_available %> - <%=l @settings_menu_item_instances.created_at, format: :short %> + <%= @settings_menu_item_instances.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %> <% if params[:simple_menu_item_id] %> <%= link_to 'Edit', edit_settings_simple_menu_item_menu_item_instance_path(@item,@settings_menu_item_instances) %> <% else %> diff --git a/app/views/settings/menus/show.html.erb b/app/views/settings/menus/show.html.erb index 28efe8af..b318be63 100644 --- a/app/views/settings/menus/show.html.erb +++ b/app/views/settings/menus/show.html.erb @@ -32,7 +32,7 @@ <%= @settings_menu.valid_time_from.strftime("%H:%M") rescue "-" %> <%= @settings_menu.valid_time_to.strftime("%H:%M") rescue "-" %> <%= @settings_menu.created_by %> - <%=l @settings_menu.created_at, format: :short %> + <%= @settings_menu.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %> <%= link_to 'Edit', edit_settings_menu_path(@settings_menu) %> diff --git a/app/views/settings/set_menu_items/new.html.erb b/app/views/settings/set_menu_items/new.html.erb index 6c7b6e76..c7d277bf 100644 --- a/app/views/settings/set_menu_items/new.html.erb +++ b/app/views/settings/set_menu_items/new.html.erb @@ -1,8 +1,6 @@ +<%= render 'form', settings_menu_item: @settings_menu_item %> -->
    diff --git a/app/views/settings/set_menu_items/show.html.erb b/app/views/settings/set_menu_items/show.html.erb index c0aeca31..2365c310 100644 --- a/app/views/settings/set_menu_items/show.html.erb +++ b/app/views/settings/set_menu_items/show.html.erb @@ -100,7 +100,7 @@

    Menu Item Instances - <%= link_to t('.new', :default => t("helpers.links.new")),new_settings_menu_item_menu_item_instance_path(@settings_menu_item),:class => 'btn btn-primary btn-sm' %> + <%= link_to t('.new', :default => t("helpers.links.new")),new_settings_set_menu_item_menu_item_instance_path(@settings_menu_item),:class => 'btn btn-primary btn-sm' %>

    @@ -129,6 +129,9 @@ <%= settings_menu_item.is_on_promotion %> <%= settings_menu_item.promotion_price %> <%= settings_menu_item.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %> + <%= link_to 'Show', settings_set_menu_item_menu_item_instance_path(@settings_menu_item, settings_menu_item ) %> + <%= link_to 'Edit', edit_settings_set_menu_item_menu_item_instance_path(@settings_menu_item, settings_menu_item) %> + <%= link_to 'Destroy', settings_set_menu_item_menu_item_instance_path(@settings_menu_item, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %> <% end %> diff --git a/app/views/settings/simple_menu_items/new.html.erb b/app/views/settings/simple_menu_items/new.html.erb index 2f3cb6a4..5781850d 100644 --- a/app/views/settings/simple_menu_items/new.html.erb +++ b/app/views/settings/simple_menu_items/new.html.erb @@ -1,8 +1,6 @@ +<%= render 'form', settings_menu_item: @settings_menu_item %>-->
    diff --git a/app/views/settings/simple_menu_items/show.html.erb b/app/views/settings/simple_menu_items/show.html.erb index 878cd2e5..6e93d3cc 100644 --- a/app/views/settings/simple_menu_items/show.html.erb +++ b/app/views/settings/simple_menu_items/show.html.erb @@ -3,7 +3,7 @@ From e3e41bd64e2721a37ec0d6527594ff1e01063904 Mon Sep 17 00:00:00 2001 From: Nweni Date: Sun, 4 Jun 2017 10:12:33 +0630 Subject: [PATCH 39/39] Update --- Gemfile | 4 ++-- Gemfile.lock | 4 ++-- app/jobs/order_broadcast_job.rb | 8 ++++++++ app/models/order.rb | 6 +++--- app/models/order_item.rb | 3 ++- 5 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 app/jobs/order_broadcast_job.rb diff --git a/Gemfile b/Gemfile index d42da647..d64ba992 100644 --- a/Gemfile +++ b/Gemfile @@ -9,8 +9,8 @@ end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.0' # Use mysql as the database for Active Record -gem 'mysql2', '>= 0.3.18', '< 0.5' -#gem 'pg' +#gem 'mysql2', '>= 0.3.18', '< 0.5' +gem 'pg' # Use Puma as the app server gem 'puma', '~> 3.0' # Use SCSS for stylesheets diff --git a/Gemfile.lock b/Gemfile.lock index 6936e5f1..c47d6574 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,11 +96,11 @@ GEM mini_portile2 (2.1.0) minitest (5.10.2) multi_json (1.12.1) - mysql2 (0.4.6) nio4r (2.1.0) nokogiri (1.7.2) mini_portile2 (~> 2.1.0) pdf-core (0.7.0) + pg (0.20.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) @@ -232,7 +232,7 @@ DEPENDENCIES jbuilder (~> 2.5) jquery-rails listen (~> 3.0.5) - mysql2 (>= 0.3.18, < 0.5) + pg prawn prawn-table puma (~> 3.0) diff --git a/app/jobs/order_broadcast_job.rb b/app/jobs/order_broadcast_job.rb new file mode 100644 index 00000000..95d14f56 --- /dev/null +++ b/app/jobs/order_broadcast_job.rb @@ -0,0 +1,8 @@ +class OrderBroadcastJob < ApplicationJob + queue_as :default + + def perform(message) + order = Order.find(message) # message come as order_id + # ApplicationCable.server.broadcast "order_queue_station_channel", order: order + end +end diff --git a/app/models/order.rb b/app/models/order.rb index 273cd62c..fbbc70c5 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -211,7 +211,7 @@ class Order < ApplicationRecord left join dining_facilities on dining_facilities.id = bookings.dining_facility_id left join order_items on order_items.order_id = orders.id") .where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,"dine_in",true) - .group("orders.id") + .group("orders.id,order_items.id,dining_facilities.name") end #Origami: Cashier : to view order type Room def self.get_order_rooms @@ -222,7 +222,7 @@ class Order < ApplicationRecord left join dining_facilities on dining_facilities.id = bookings.dining_facility_id left join order_items on order_items.order_id = orders.id") .where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,"dine_in",true) - .group("orders.id") + .group("orders.id,order_items.id,dining_facilities.name") end #Origami: Cashier : to view orders def self.get_orders @@ -233,6 +233,6 @@ class Order < ApplicationRecord left join dining_facilities on dining_facilities.id = bookings.dining_facility_id left join order_items on order_items.order_id = orders.id") .where("dining_facilities.is_active=?",true) - .group("orders.id") + .group("orders.id,order_items.id,dining_facilities.name") end end diff --git a/app/models/order_item.rb b/app/models/order_item.rb index f839ad99..0e95b0b3 100644 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -37,6 +37,7 @@ class OrderItem < ApplicationRecord def self.get_order_items_details(order_id) order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price") .joins("left join orders on orders.id = order_items.order_id") - .where("order_items.order_id=?",order_id) + .where("order_items.order_id=?",order_id) + end end