diff --git a/app/assets/javascripts/settings/orders.coffee b/app/assets/javascripts/settings/orders.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/settings/orders.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/settings/orders.scss b/app/assets/stylesheets/settings/orders.scss new file mode 100644 index 00000000..436ceee1 --- /dev/null +++ b/app/assets/stylesheets/settings/orders.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the settings/orders 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/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 8c477355..9f73edcf 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -30,6 +30,15 @@ class Crm::CustomersController < BaseCrmController # GET /crm/customers/1 # GET /crm/customers/1.json def show + @orders = Order.where("customer_id=?", params[:id]) + + if @orders + @order_items = [] + @orders.each do |bo| + @order_items = @order_items + bo.order_items + end + + end end # GET /crm/customers/new @@ -108,6 +117,7 @@ class Crm::CustomersController < BaseCrmController end end end +end # PATCH/PUT /crm/customers/1 # PATCH/PUT /crm/customers/1.json @@ -158,24 +168,6 @@ class Crm::CustomersController < BaseCrmController end end - # DELETE /crm/customers/1 - # DELETE /crm/customers/1.json - - # def get_sale_id - - # @sale_id = params[:sale_id] - # @crm_customers = Customer.all - # @crm_customer = Customer.new - # @membership = Customer.get_member_group - # if @membership["status"] == true - # @member_group = @membership["data"] - # end - # respond_to do |format| - # format.html { render action: "index"} - # format.json { render json: @crm_customers } - # end - # end - private # Use callbacks to share common setup or constraints between actions. def set_crm_customer diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 309903b2..1b16ab54 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -41,8 +41,24 @@ class Origami::HomeController < BaseOrigamiController end def get_customer - @customer = Customer.find(params[:customer_id]) - render :json => @customer.to_json + @customer = Customer.find(params[:customer_id]) + + membership = MembershipSetting.find_by_membership_type("paypar_url") + + memberaction = MembershipAction.find_by_membership_type("get_all_member_account") + app_token = membership.auth_token.to_s + url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + + response = HTTParty.post(url, :body => { membership_id: @customer.membership_id}.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' + } + ) + + + + render :json => response.to_json end end diff --git a/app/controllers/settings/orders_controller.rb b/app/controllers/settings/orders_controller.rb new file mode 100644 index 00000000..b5bbdc1c --- /dev/null +++ b/app/controllers/settings/orders_controller.rb @@ -0,0 +1,32 @@ +class Settings::OrdersController < ApplicationController + def index + + filter = params[:filter] + if filter.nil? + orders = Order.order("order_id desc").limit(1000) + else + order = Order.where("order_id LIKE ?", "%#{filter}%").order("order_id desc").limit(1000).page(params[:page]) + if order.count > 0 + orders = order + else + orders = Order.order("order_id desc").limit(1000) + flash[:notice] = "There is no data." + end + end + @orders = Kaminari.paginate_array(orders).page(params[:page]).per(50) + respond_to do |format| + format.html # index.html.erb + format.json { render json: @orders } + end + end + def show + + @order = Order.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @order } + end + end + +end diff --git a/app/controllers/settings/sales_controller.rb b/app/controllers/settings/sales_controller.rb new file mode 100644 index 00000000..6bb58244 --- /dev/null +++ b/app/controllers/settings/sales_controller.rb @@ -0,0 +1,42 @@ +class Settings::SalesController < ApplicationController + def index + + search_date = params[:date] + receipt_no = params[:receipt_no] + today = Date.today + + if receipt_no.nil? && search_date.nil? + @sales = Sale.where("NOT sale_status = 'void'" ).order("sale_id desc").limit(500) + else + if !search_date.blank? && receipt_no.blank? + sale = Sale.where("DATE_FORMAT(receipt_date,'%Y-%b-%d') = ?", search_date).order("sale_id desc").limit(500).page(params[:page]) + elsif !search_date.blank? && !receipt_no.blank? + sale = Sale.where("receipt_no LIKE ? or DATE_FORMAT(receipt_date,'%Y-%b-%d') = ?", "%#{receipt_no}%", search_date).order("sale_id desc").limit(500).page(params[:page]) + else + sale = Sale.where("receipt_no LIKE ?", receipt_no).order("sale_id desc").limit(500).page(params[:page]) + end + if sale.count > 0 + @sales = sale + else + @sales = Sale.where("NOT sale_status = 'void'").order("sale_id desc").limit(500) + end + end + @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50) + respond_to do |format| + format.html # index.html.erb + format.json { render json: @sales } + end + end + + def show + + @sale = Sale.find(params[:id]) + # @sale_receivables = SaleReceivable.where('sale_id = ?', @sale.id) + respond_to do |format| + format.html # show.html.erb + format.json { render json: @sale } + end + end + + +end \ No newline at end of file diff --git a/app/helpers/settings/orders_helper.rb b/app/helpers/settings/orders_helper.rb new file mode 100644 index 00000000..f5825365 --- /dev/null +++ b/app/helpers/settings/orders_helper.rb @@ -0,0 +1,2 @@ +module Settings::OrdersHelper +end diff --git a/app/views/crm/customers/_error_messages.html.erb b/app/views/crm/customers/_error_messages.html.erb new file mode 100644 index 00000000..bbff284b --- /dev/null +++ b/app/views/crm/customers/_error_messages.html.erb @@ -0,0 +1,9 @@ +
+ +
diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index e4f6d07d..c3fb4064 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -51,7 +51,7 @@ <%= crm_customer.contact_no %> <%= crm_customer.email %> - <%= link_to 'Destroy', crm_customer_path(crm_customer), method: :delete, data: { confirm: 'Are you sure?' } %> + <%= link_to 'Show', crm_customer_path(crm_customer) %> diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index da88e887..45529dc6 100644 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -1,40 +1,84 @@ -

<%= notice %>

- -

- Name: - <%= @crm_customer.name %> -

- -

- Company: - <%= @crm_customer.company %> -

- -

- Contact no: - <%= @crm_customer.contact_no %> -

- -

- Email: - <%= @crm_customer.email %> -

- -

- Date of birth: - <%= @crm_customer.date_of_birth %> -

+
+
+ +
+
-

- Membership type: - <%= @crm_customer.membership_type %> -

+
+
+ +
+
+
+ + + + + + + + + + -

- Membership authentication code: - <%= @crm_customer.membership_authentication_code %> -

+ + + + + + + + + + +
NameEmailContact noCompanyDate Of Birth
<%= @crm_customer.name %><%= @crm_customer.email %><%= @crm_customer.contact_no %><%= @crm_customer.company %><%= @crm_customer.date_of_birth %>
+
+

Order Details

+ + + + + + + + + + + + + + + + <% @order_items.each do |order_item| %> + + + + + + + + + + <% end %> + +
Created at Menu ItemQTYUnit Price OptionStatusWaiter
<%= order_item.created_at %><%= order_item.item_name %><%= order_item.qty %><%= order_item.price %><%= order_item.options %><%= order_item.order_item_status %><%= order_item.item_order_by %>
+
+
+ +
+ + +
+ + + + -<%= link_to 'Edit', edit_crm_customer_path(@crm_customer) %> | -<%= link_to 'Back', crm_customers_path %> diff --git a/app/views/kaminari/_first_page.html.erb b/app/views/kaminari/_first_page.html.erb new file mode 100644 index 00000000..2682d341 --- /dev/null +++ b/app/views/kaminari/_first_page.html.erb @@ -0,0 +1,11 @@ +<%# Link to the "First" page + - available local variables + url: url to the first page + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> + + <%= link_to_unless current_page.first?, t('views.pagination.first').html_safe, url, :remote => remote %> + diff --git a/app/views/kaminari/_gap.html.erb b/app/views/kaminari/_gap.html.erb new file mode 100644 index 00000000..bbb0f983 --- /dev/null +++ b/app/views/kaminari/_gap.html.erb @@ -0,0 +1,8 @@ +<%# Non-link tag that stands for skipped pages... + - available local variables + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> +<%= t('views.pagination.truncate').html_safe %> diff --git a/app/views/kaminari/_last_page.html.erb b/app/views/kaminari/_last_page.html.erb new file mode 100644 index 00000000..53d61307 --- /dev/null +++ b/app/views/kaminari/_last_page.html.erb @@ -0,0 +1,11 @@ +<%# Link to the "Last" page + - available local variables + url: url to the last page + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> + + <%= link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, :remote => remote %> + diff --git a/app/views/kaminari/_next_page.html.erb b/app/views/kaminari/_next_page.html.erb new file mode 100644 index 00000000..4fc20712 --- /dev/null +++ b/app/views/kaminari/_next_page.html.erb @@ -0,0 +1,11 @@ +<%# Link to the "Next" page + - available local variables + url: url to the next page + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> + + <%= link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, :rel => 'next', :remote => remote %> + diff --git a/app/views/kaminari/_page.html.erb b/app/views/kaminari/_page.html.erb new file mode 100644 index 00000000..582af7bc --- /dev/null +++ b/app/views/kaminari/_page.html.erb @@ -0,0 +1,12 @@ +<%# Link showing page number + - available local variables + page: a page object for "this" page + url: url to this page + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> + + <%= link_to_unless page.current?, page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %> + diff --git a/app/views/kaminari/_paginator.html.erb b/app/views/kaminari/_paginator.html.erb new file mode 100644 index 00000000..4fb445fd --- /dev/null +++ b/app/views/kaminari/_paginator.html.erb @@ -0,0 +1,23 @@ +<%# The container tag + - available local variables + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote + paginator: the paginator that renders the pagination tags inside +-%> +<%= paginator.render do -%> + +<% end -%> diff --git a/app/views/kaminari/_prev_page.html.erb b/app/views/kaminari/_prev_page.html.erb new file mode 100644 index 00000000..9c4aff49 --- /dev/null +++ b/app/views/kaminari/_prev_page.html.erb @@ -0,0 +1,11 @@ +<%# Link to the "Previous" page + - available local variables + url: url to the previous page + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> + + <%= link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, :rel => 'prev', :remote => remote %> + diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb new file mode 100644 index 00000000..974dceb8 --- /dev/null +++ b/app/views/origami/customers/index.html.erb @@ -0,0 +1,223 @@ +
+
+ +
+
+ + +
+
+ +
+
+ + + + + + + + + + + + + + + + + + <% @crm_customers.each do |crm_customer| %> + + + + + + + + + + <% end %> + +
+ <%= form_tag crm_customers_path, :method => :get do %> +
+ + +
+ <% end %> +
SelectNameCompanyContact noEmail
+ <%= crm_customer.name %><%= crm_customer.company %><%= crm_customer.contact_no %><%= crm_customer.email %> + <%= link_to 'Destroy', crm_customer_path(crm_customer), method: :delete, data: { confirm: 'Are you sure?' } %> + +
+
+ + <%= paginate @crm_customers %> +
+
+ +
+ +
+ <%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %> + + + + <%= f.error_notification %> + <%= f.hidden_field :id, :class => "form-control col-md-6 " %> + +
+ <%= f.input :name, :class => "form-control col-md-6 name" %> + +
+
+ <%= f.input :company, :class => "form-control col-md-6 company" %> +
+
+ <%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %> + + +
+ +
+ <%= f.input :email, :class => "form-control col-md-6 email" %> +
+ +
+ + <%= f.text_field :date_of_birth,:class=>"form-control date_of_birth datepicker"%> +
+ + + + + + +
+ <%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %> + <%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %> +
+ <%end%> +
+
+ + + + + + + + diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 6ec5c978..459e8061 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -227,14 +227,9 @@ - -<<<<<<< HEAD - - -======= - + + ->>>>>>> 6d4ef8e2adaa39c710a9b30dcb35737b6be2410e diff --git a/app/views/settings/orders/index.html.erb b/app/views/settings/orders/index.html.erb new file mode 100644 index 00000000..bd3df8fb --- /dev/null +++ b/app/views/settings/orders/index.html.erb @@ -0,0 +1,68 @@ +
+
+ +
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + <% @orders.each do |order| %> + + + + + + + + + + + <% end %> + +
+ <%= form_tag settings_orders_path, :method => :get do %> +
+ + +
+ <% end %> +
Order ID TypeCustomerOrder statusOrder dateItems CountAction
<%= order.order_id %><%= order.order_type %><%= order.customer.name rescue '-' %><%= order.status %> <%= order.date.strftime("%d-%m-%Y") %> <%= order.item_count %> <%= link_to 'Show', settings_order_path(order) %>
+
+ + <%= paginate @orders %> +
+
+ +
+
+ + + + + diff --git a/app/views/settings/orders/show.html.erb b/app/views/settings/orders/show.html.erb new file mode 100644 index 00000000..bd17dadb --- /dev/null +++ b/app/views/settings/orders/show.html.erb @@ -0,0 +1,85 @@ +
+
+ +
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + +
TypeCustomerOrder statusOrder dateOrder By
<%= @order.order_type %><%= @order.customer.name rescue '-' %><%= @order.status %> <%= @order.date.strftime("%d-%m-%Y") %> <%= @order.waiter rescue '-' %>
+

Order Items

+ + + + + + + + + + + + + + + + + <% @order.order_items.each do |order| %> + + + + + + + + + + + + <% end %> + +
Item NameQty Unit PriceTotal PriceOptionStatusOrder ByCreated at
<%= order.item_name %><%= order.qty %><%= order.price %><%= order.qty * order.price %> <%= order.options %> <%= order.order_item_status %> <%= order.item_order_by %> <%= order.created_at.strftime("%d-%m-%Y") %>
+ + Back + +
+
+ +
+
+ + + + + diff --git a/app/views/settings/sales/index.html.erb b/app/views/settings/sales/index.html.erb new file mode 100644 index 00000000..c53a6e8d --- /dev/null +++ b/app/views/settings/sales/index.html.erb @@ -0,0 +1,85 @@ +
+
+ +
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + <% @sales.each do |sale| %> + + + + + + + + + + + + <% end %> + +
+ <%= form_tag settings_sales_path, :method => :get do %> +
+ + + + +
+ <% end %> +
Sale Id Receipt no Grand totalTax amountCashierSales statusReceipt DateAction
<%= sale.sale_id %><%= sale.receipt_no %><%= sale.grand_total rescue '-' %><%= sale.total_tax %><%= sale.cashier_name rescue '-' %> <%= sale.sale_status %> <%= sale.receipt_date.strftime("%d-%m-%Y") %> <%= link_to 'Show', settings_sale_path(sale) %>
+
+ + <%= paginate @sales %> +
+
+ +
+
+ + + + + + + diff --git a/app/views/settings/sales/show.html.erb b/app/views/settings/sales/show.html.erb new file mode 100644 index 00000000..484de762 --- /dev/null +++ b/app/views/settings/sales/show.html.erb @@ -0,0 +1,103 @@ +
+
+ +
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + <% @sale.sale_items.each do |s| %> + + + + + + + + + <% end %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Receipt Date Receipt noCashierOSales statusReceipt generated at
<%= @sale.receipt_date.strftime("%d-%M-%Y") %><%= @sale.receipt_no %><%= @sale.cashier rescue '-' %> <%= @sale.sale_status %> <%= @sale.requested_at.strftime("%d-%m-%Y") %>
Sale item name QtyUnit priceTotal pirce Created at
<%=s.product_name rescue ' '%><%=s.qty rescue ' '%><%= number_with_precision(s.price, :precision => 2, :delimiter => ',') rescue ' '%><%= number_with_precision(s.qty * s.price, :precision => 2, :delimiter => ',') rescue ' '%><%=l s.created_at.utc.getlocal , :format => :short rescue ' ' %>
Total<%= number_with_precision(@sale.total_amount, :precision => 2, :delimiter => ',') rescue ' '%>
Tax<%= number_with_precision(@sale.total_tax, :precision => 2, :delimiter => ',') rescue ' '%>
Discount<%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%>
Grand Total<%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%>
 
Pay Amount<%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%>
Change<%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%>
+ + + Back + +
+
+ +
+
+ + + + + diff --git a/config/routes.rb b/config/routes.rb index 2c9be9e0..7dff2ad3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -166,6 +166,8 @@ Rails.application.routes.draw do resources :lookups #orders resources :orders + #sales + resources :sales #cashier_terminals resources :cashier_terminals #order_job_stations diff --git a/db/migrate/20170611084537_create_membership_actions.rb b/db/migrate/20170611084537_create_membership_actions.rb index 74695871..4a164add 100644 --- a/db/migrate/20170611084537_create_membership_actions.rb +++ b/db/migrate/20170611084537_create_membership_actions.rb @@ -8,7 +8,7 @@ class CreateMembershipActions < ActiveRecord::Migration[5.1] t.string :auth_token t.string :merchant_account_id t.string :created_by - t.jsonb :additional_parameter + t.string :additional_parameter,array: true, :default =>'{}' t.timestamps end diff --git a/spec/controllers/settings/orders_controller_spec.rb b/spec/controllers/settings/orders_controller_spec.rb new file mode 100644 index 00000000..e715e84f --- /dev/null +++ b/spec/controllers/settings/orders_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Settings::OrdersController, type: :controller do + +end diff --git a/spec/helpers/settings/orders_helper_spec.rb b/spec/helpers/settings/orders_helper_spec.rb new file mode 100644 index 00000000..028e7209 --- /dev/null +++ b/spec/helpers/settings/orders_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the Settings::OrdersHelper. For example: +# +# describe Settings::OrdersHelper 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 Settings::OrdersHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end