From 001d168942ef143679019b505359558b2ac97fdc Mon Sep 17 00:00:00 2001 From: Moe Su Date: Mon, 12 Jun 2017 18:35:38 +0630 Subject: [PATCH 01/10] For pull --- dump.rdb | Bin 20860 -> 21696 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/dump.rdb b/dump.rdb index 4d2c7d9e5136fdfd8a4a5fb5cafdaedbad0830f9..ffce1d8fcbcb4fbe52f00cb8c1c4ed00b07d77c2 100644 GIT binary patch delta 1710 zcmW-hOKhBH6^6gx|JXC*8QV&eLPDd=jK|~n((m_ozZe?orchK`1=)Zpu=37E zW7KS%N@iNZ5v+tUkYJ=CGhRZ&gMl$R=TP9OSQK_lGgJ`@Qw0wJgfj+kL?JX<-u`tO`~0ncH#UCvD+X6I)TlLq0IeBl2GKm8- zPH};~)Um#~H-4tfl+LJNTCsd`Yqd7U5uxkt`@Q^1H?iXD2ai|}u~iB(ra9Eob10F+ zm=ZJlSKu3m_m)osGW^*WgSXK*AGEZB31y>?)+mkYn|ZZ6#xp@QQ~A`^>amnlqTcKd zIyWkc`{1c@P$|isM!V>lidLoIHDwBB&$QP&18##ol1X8%KtY z46++(2!^#A*CsWVgi>Pz^43yOe>Si5W*#ZZj43P`85*(+>WN}+_6D8pLeSKrxgR9Z zweF2V7Kwy27m5VxK%zm5JBdX90Q3%jc#v%$)YLm{og;xGVf_G=lTY==aK@=< zE76~*HoB{|5sgKsa;I~ssv^tJhIYUH46Y$cp5$sj-^iTpug_NDXG~%?lxAxMw(UA+`P2~Fc6XmwlL2$tdk zDl|Q_Zy= zRBt{&M)Fq0^!l9&kkfwv;?c{^=K-7D263qlEWE%!E{3{eJ~-sVD}Cw< z1ud~9&F{?JFKqlV&Dwx0EdUMAm!NYrdLPWUo|&B)X60_SQ*ePB+nNzT&l(GywlaKneUEi0fWMR?p&%Y)br~pv_vc| z1FoM3^6uJ>8cT88QjadDibgy46u_-V5-t8&`Do>pl(9_d<>B~wKPH6zZDGH2F7Z|$ zS-c9MdX@aV;8h&9?~f{wAj1u%!bbVT2YbtB`dPU|P#mJoF`F*|JA0emN)31V>8pE{ iGbxpsczkhK)5Qnni;s@{?tg`~XG(Bg+>YtDKl?w4fCB*l delta 870 zcmW;JU29xL9LMq5J$X3kwn0<06~%qZmc%%RdHVlnCQva+wa}`CdLbI6&YYRag;cC< zMG9f_5|s7M8x^B%;j9;;7(uALP!L~44xz2!tydz!ByZsNf#3JuoyLD(H9ldFKY#s& zH~-CVUXOuZjaTop4?bP_eC}ND)m!abCkXkYMMzG_%D1D&(#g@s`D>#~jroBL+RLaU zMPQLCpE&gp5@igXF~~DrN*HY|4ra36rE`}%FYl7ky)`l1`r-+NB9z*5uUT@SStz*< zX=UP>^26wE#Bjyk=q+<)wLoPRD-<_e$j*D@{da%ZZMCNi!_ED>jrw-g=0byF!crGG zr-}zdee{VY!;Du(W~D`0pRI_hX?4okGz7%p5?HQ4+lYW5gzkJ+=T!zmW4D?>X^g5{ z)h=mITE#c_$14@Nz4!HcJ9=BDC>T``4OM{y^#PCu>Ci`mnKo#ELLvG12)8bCP<7 ziW;l5^-Op)q5D+5Jbq9d%RwZ~fOFdqQ$lIu7=P&(;tq}R47Y{W7OWMA#`#V|!=UBH z54U%S?){jdQLO(uQD=4<$*#RKDmMX;32g?qOYvWch7L89*b2b2edU&MsU1;rT^%7Vm@l85mk`9x4Jj|_HnLJ11qGF zfOhZL`fj7$)J%M{Q*T#I7xZ&aPFbYU@UXCv8Bguv<_z@$OYnf@;P39~;Q{op*vW%Z z+{*xF;h#qG3+D+RJl(X2M<3@(6$XG?tY@pOc2g+%W%bwgMl*Od|7^xJ)r%i3Y|NQN z4TwMmbKs;zpY-Z)N5D_HU@2+?TrK9rpZRslpmR{#Qy1-&tCia;!^Xi{{ixk0=fVI From 16e163f98776ee240d98c90adf588705cea85acc Mon Sep 17 00:00:00 2001 From: Moe Su Date: Tue, 13 Jun 2017 09:33:16 +0630 Subject: [PATCH 02/10] For Pull --- app/models/order.rb | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/app/models/order.rb b/app/models/order.rb index 5a4d6e2d..1b60a7b4 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -244,22 +244,9 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("sales.sale_status='completed'") -<<<<<<< HEAD .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") end - - #Origami: Cashier : to view booking order Table - def self.get_booking_order_table - booking_orders = Booking.select("sales.receipt_no,orders.status as order_status, - bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") - .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") - .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") - .joins("left join orders on orders.order_id = booking_orders.order_id") - .joins("left join sales on sales.sale_id = bookings.sale_id") - .where("sales.sale_status<>'completed' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true) - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.customer_id,sales.customer_id,orders.order_id") - end - + #Origami: Cashier : to view order type Room def self.get_booking_order_rooms booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status, From c05a64bae765202f9724e7e458a6d032643c9e95 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 13 Jun 2017 10:36:40 +0630 Subject: [PATCH 03/10] update customer amount --- Gemfile | 4 +- Gemfile.lock | 14 +-- app/assets/javascripts/application.js | 8 +- app/assets/javascripts/cable.js | 8 +- app/assets/javascripts/report.js | 4 + app/assets/stylesheets/application.css | 0 app/assets/stylesheets/application.scss | 2 +- app/controllers/crm/customers_controller.rb | 14 ++- .../origami/payments_controller.rb | 25 +++++ app/models/order.rb | 12 -- app/views/crm/customers/index.html.erb | 106 ++++++++---------- app/views/origami/customers/index.html.erb | 34 +----- app/views/origami/payments/show.html.erb | 4 +- 13 files changed, 105 insertions(+), 130 deletions(-) create mode 100644 app/assets/javascripts/report.js create mode 100644 app/assets/stylesheets/application.css diff --git a/Gemfile b/Gemfile index 7295ffab..e6e99241 100644 --- a/Gemfile +++ b/Gemfile @@ -95,6 +95,6 @@ gem 'httparty', '~> 0.15.5' # gem 'momentjs-rails', '>= 2.9.0' # gem 'bootstrap-datepicker-rails' -# gem 'momentjs-rails', '>= 2.9.0' -# gem 'bootstrap3-datetimepicker-rails', '~> 4.17.47' +# # gem 'momentjs-rails', '>= 2.9.0' +# gem 'bootstrap3-datetimepicker-rails'z gem 'bootstrap-datepicker-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 6a7c6340..7b18943d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -80,8 +80,8 @@ GEM httparty (0.15.5) multi_xml (>= 0.5.2) i18n (0.8.4) - jbuilder (2.6.4) - activesupport (>= 3.0.0) + jbuilder (2.7.0) + activesupport (>= 4.2.0) multi_json (>= 1.2) jquery-rails (4.3.1) rails-dom-testing (>= 1, < 3) @@ -95,20 +95,20 @@ GEM rb-inotify (~> 0.9, >= 0.9.7) loofah (2.0.3) nokogiri (>= 1.5.9) - mail (2.6.5) + mail (2.6.6) mime-types (>= 1.16, < 4) method_source (0.8.2) mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) - mini_portile2 (2.1.0) + mini_portile2 (2.2.0) minitest (5.10.2) multi_json (1.12.1) multi_xml (0.6.0) mysql2 (0.4.6) nio4r (2.1.0) - nokogiri (1.7.2) - mini_portile2 (~> 2.1.0) + nokogiri (1.8.0) + mini_portile2 (~> 2.2.0) pdf-core (0.7.0) prawn (2.2.2) pdf-core (~> 0.7.0) @@ -179,7 +179,7 @@ GEM activesupport (>= 3.2.1) shoulda-matchers (3.1.1) activesupport (>= 4.0.0) - sidekiq (5.0.0) + sidekiq (5.0.2) concurrent-ruby (~> 1.0) connection_pool (~> 2.2, >= 2.2.0) rack-protection (>= 1.5.0) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 59e4a386..f4ee96ab 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -17,11 +17,7 @@ //= require turbolinks //= require cable //= require settings/processing_items -//= require bootstrap-datepicker/core -//= require bootstrap-datepicker/locales/bootstrap-datepicker.es +//= require bootstrap-datepicker + -$(document).on("focus", "[data-behaviour~='datepicker']", function(e){ - $(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true}); - $('.dropdown-toggle').dropdown(); -}); diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js index ce5ac871..43efe3f2 100644 --- a/app/assets/javascripts/cable.js +++ b/app/assets/javascripts/cable.js @@ -6,9 +6,9 @@ //= require_tree ./channels // Temp Disable -// (function() { -// this.App || (this.App = {}); +(function() { + this.App || (this.App = {}); -// App.cable = ActionCable.createConsumer(); + App.cable = ActionCable.createConsumer(); -// }).call(this); +}).call(this); diff --git a/app/assets/javascripts/report.js b/app/assets/javascripts/report.js new file mode 100644 index 00000000..09f74075 --- /dev/null +++ b/app/assets/javascripts/report.js @@ -0,0 +1,4 @@ +$(document).on("focus", "[data-behaviour~='datepicker']", function(e){ + $(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true}); + $('.dropdown-toggle').dropdown(); +}); \ No newline at end of file diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 00000000..e69de29b diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 468ac33d..c3030dfb 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -2,7 +2,7 @@ @import "bootstrap"; @import "font-awesome"; @import "theme"; -@import 'bootstrap-datepicker'; +@import "bootstrap-datepicker"; /* Show it is fixed to the top */ // body { diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 525302c8..2933cda8 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -10,13 +10,13 @@ class Crm::CustomersController < BaseCrmController @crm_customers = Customer.order("customer_id").page(params[:page]) #@products = Product.order("name").page(params[:page]).per(5) else - @crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page]) - end + @crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page]) end #@crm_customers = Customer.all @crm_customer = Customer.new - if @crm_customer.valid? - @crm_customer.errors.messages - end + + + # puts @crm_customer.valid? + # @membership = Customer.get_member_group # if @membership["status"] == true # @member_group = @membership["data"] @@ -57,8 +57,9 @@ class Crm::CustomersController < BaseCrmController def create @crm_customers = Customer.new(customer_params) - + respond_to do |format| + puts @crm_customers.errors.to_json if @crm_customers.save name = customer_params[:name] phone = customer_params[:contact_no] @@ -105,6 +106,7 @@ class Crm::CustomersController < BaseCrmController if params[:sale_id] format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'} else + format.html { redirect_to crm_customers_path} format.json { render json: @crm_customers.errors, status: :unprocessable_entity } end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 290a2911..1e08f8a8 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -20,6 +20,31 @@ class Origami::PaymentsController < BaseOrigamiController @cash = 0.0 @other = 0.0 @sale_data = Sale.find_by_sale_id(sale_id) + + #get customer amount + @customer = Customer.find(@sale_data.customer_id) + + membership = MembershipSetting.find_by_membership_type("paypar_url") + + memberaction = MembershipAction.find_by_membership_type("get_all_member_account") + merchant_uid = memberaction.merchant_account_id.to_s + url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + + response = HTTParty.get(url, :body => { membership_id: @customer.membership_id,merchant_uid:merchant_uid}.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' + } + ) + + @balance = 0.00 + response["data"].each do |res| + if res["accountable_type"] == "RebateAccount" + @balance = res["balance"] + end + end + #end customer amount + @sale_data.sale_payments.each do |spay| if spay.payment_method == "cash" @cash = spay.payment_amount diff --git a/app/models/order.rb b/app/models/order.rb index 5a4d6e2d..ac51c115 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -244,21 +244,9 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("sales.sale_status='completed'") -<<<<<<< HEAD .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") end - #Origami: Cashier : to view booking order Table - def self.get_booking_order_table - booking_orders = Booking.select("sales.receipt_no,orders.status as order_status, - bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") - .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") - .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") - .joins("left join orders on orders.order_id = booking_orders.order_id") - .joins("left join sales on sales.sale_id = bookings.sale_id") - .where("sales.sale_status<>'completed' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true) - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.customer_id,sales.customer_id,orders.order_id") - end #Origami: Cashier : to view order type Room def self.get_booking_order_rooms diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 9f62b55b..034f06b7 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -66,37 +66,32 @@ -
<%= 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.input :email, :class => "form-control col-md-6 email" %>
- - <%= f.text_field :date_of_birth,:class => "form-control datepicker date_of_birth "%> + <%= f.input :date_of_birth,:class=>"form-control date_of_birth"%>
-
+
+ -
+
@@ -115,21 +110,8 @@
- - diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index 070d6d26..f7b4a692 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -38,6 +38,7 @@ Company Contact no Email + Date of Birth @@ -47,11 +48,11 @@ <%= crm_customer.name %> - <%= crm_customer.company %> + <%= crm_customer.company rescue '-' %> <%= crm_customer.contact_no %> <%= crm_customer.email %> - <%= link_to 'Destroy', crm_customer_path(crm_customer), method: :delete, data: { confirm: 'Are you sure?' } %> + <%= crm_customer.date_of_birth rescue '-' %> @@ -84,8 +85,6 @@
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %> - -
@@ -93,11 +92,11 @@
- - <%= f.text_field :date_of_birth,:class=>"form-control date_of_birth datepicker"%> + <%= f.input :date_of_birth,:class=>"form-control date_of_birth"%>
+ -
- - - - -
<%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %> - <%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %> +
<%end%> @@ -128,17 +117,6 @@ diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index f7b4a692..80150220 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -78,17 +78,25 @@
<%= f.input :name, :class => "form-control col-md-6 name" %> - + <% if flash[:errors] && !flash[:errors].empty? then -%> + <%= flash[:errors]["name"] %> + <% end -%>
<%= f.input :company, :class => "form-control col-md-6 company" %>
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %> + <% if flash[:errors] && !flash[:errors].empty? then -%> + <%= flash[:errors]["contact_no"] %> + <% end -%>
- <%= f.input :email, :class => "form-control col-md-6 email" %> + <%= f.input :email, :class => "form-control col-md-6 email" %> + <% if flash[:errors] && !flash[:errors].empty? then -%> + <%= flash[:errors]["email"] %> + <% end -%>
@@ -103,7 +111,11 @@ <%end %> - + + <% if flash[:errors] && !flash[:errors].empty? then -%> + <%= flash[:errors]["member_group_id"] %> + <% end -%> +
From 99d00f6d2ab8f183428220cb224c7a353a89fcef Mon Sep 17 00:00:00 2001 From: Phyo Date: Tue, 13 Jun 2017 12:04:31 +0630 Subject: [PATCH 05/10] Redeem amount validation --- .../origami/redeem_payments_controller.rb | 5 +-- app/models/sale_payment.rb | 36 +++++++++---------- .../origami/redeem_payments/index.html.erb | 29 ++++++++------- 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/app/controllers/origami/redeem_payments_controller.rb b/app/controllers/origami/redeem_payments_controller.rb index 5fd386e8..b68fd30a 100644 --- a/app/controllers/origami/redeem_payments_controller.rb +++ b/app/controllers/origami/redeem_payments_controller.rb @@ -4,6 +4,7 @@ class Origami::RedeemPaymentsController < BaseOrigamiController payment_method = params[:payment_method] @membership_rebate_balance=0 sale_data = Sale.find_by_sale_id(@sale_id) + @food_prices, @beverage_prices = SaleItem.calculate_food_beverage(sale_data.sale_items) if sale_data if sale_data.customer_id customer_data= Customer.find_by_customer_id(sale_data.customer_id) @@ -28,8 +29,8 @@ class Origami::RedeemPaymentsController < BaseOrigamiController else @out = false,0 end - - + + else @out = false, 0 end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 526ef03c..894592b5 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -96,7 +96,7 @@ class SalePayment < ApplicationRecord else response = false; end - + else response =false; end @@ -241,7 +241,7 @@ class SalePayment < ApplicationRecord def rebat(sObj) food_prices, beverage_prices = SaleItem.calculate_food_beverage(sObj.sale_items) generic_customer_id = sObj.customer.membership_id - if generic_customer_id != nil || generic_customer_id != "" + if generic_customer_id != nil || generic_customer_id != "" || generic_customer_id != 0 paypar = sObj.sale_payments payparcost = 0 paypar.each do |pp| @@ -250,24 +250,22 @@ class SalePayment < ApplicationRecord end end total_amount = food_prices - payparcost - puts "aaaa" - puts food_prices - puts payparcost - puts total_amount - receipt_no = sObj.receipt_no - membership = MembershipSetting.find_by_membership_type("paypar_url") - memberaction = MembershipAction.find_by_membership_type("rebate") - campaign_type_id = memberaction.additional_parameter["campaign_type_id"] - app_token = membership.auth_token.to_s - url = membership.gateway_url.to_s + memberaction.gateway_url.to_s - response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,total_amount: total_amount,campaign_type_id: campaign_type_id, - receipt_no: receipt_no}.to_json, - :headers => { - 'Content-Type' => 'application/json', - 'Accept' => 'application/json' - }) + if total_amount > 0 + receipt_no = sObj.receipt_no + membership = MembershipSetting.find_by_membership_type("paypar_url") + memberaction = MembershipAction.find_by_membership_type("rebate") + campaign_type_id = memberaction.additional_parameter["campaign_type_id"] + app_token = membership.auth_token.to_s + url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,total_amount: total_amount,campaign_type_id: campaign_type_id, + receipt_no: receipt_no}.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' + }) - puts response.to_json + puts response.to_json + end end end diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index 4daa672b..ae714bea 100644 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -18,6 +18,7 @@
+

You can rebate upto <%= @food_prices %>

@@ -119,22 +120,26 @@ $("#redeem").click(function(){ redeem_amount = parseInt($("#used_amount").text()); if(redeem_amount<=0 ){ alert("Please type valid amount"); - + }else if(valid_amount< redeem_amount){ alert(" Insufficient Amount!") }else{ - $.ajax({ - type: "POST", - url: "<%=origami_payment_paypar_path%>", - data: {redeem_amount:redeem_amount,membership_id:membership_id,sale_id:sale_id}, - success: function(result){ - if(result.status == true){ - window.location.href = '/origami/sale/'+ sale_id + "/payment" - }else{ - alert(result.message); + if(redeem_amount <= "<%= @food_prices %>"){ + $.ajax({ + type: "POST", + url: "<%=origami_payment_paypar_path%>", + data: {redeem_amount:redeem_amount,membership_id:membership_id,sale_id:sale_id}, + success: function(result){ + if(result.status == true){ + window.location.href = '/origami/sale/'+ sale_id + "/payment" + }else{ + alert(result.message); + } } - } - }) + }) + }else { + alert("Redeem Amount is over!"); + } } }); From ee54f1cdd33f637c38d1a044affad564774f7514 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 13 Jun 2017 12:04:55 +0630 Subject: [PATCH 06/10] validate error --- app/controllers/crm/customers_controller.rb | 11 +++++++---- .../origami/customers_controller.rb | 10 ++++------ app/views/crm/customers/index.html.erb | 16 ++++------------ app/views/layouts/CRM.html.erb | 5 ++++- app/views/layouts/origami.html.erb | 11 +++++++---- app/views/origami/customers/index.html.erb | 18 +++--------------- 6 files changed, 29 insertions(+), 42 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 518f4e33..ae6820df 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -14,9 +14,9 @@ class Crm::CustomersController < BaseCrmController #@crm_customers = Customer.all @crm_customer = Customer.new - - # puts @crm_customer.valid? - + if flash["errors"] + @crm_customer.valid? + end # @membership = Customer.get_member_group # if @membership["status"] == true # @member_group = @membership["data"] @@ -104,7 +104,9 @@ class Crm::CustomersController < BaseCrmController else if params[:sale_id] + flash[:errors] = @crm_customers.errors format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'} + format.json { render json: @crm_customers.errors, status: :unprocessable_entity } else flash[:errors] = @crm_customers.errors format.html { redirect_to crm_customers_path} @@ -148,7 +150,8 @@ end else - format.html { render :index } + flash[:errors] = @crm_customers.errors + format.html { redirect_to crm_customers_path} format.json { render json: @crm_customer.errors, status: :unprocessable_entity } end diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 14af5f49..7d0b5502 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -24,12 +24,10 @@ class Origami::CustomersController < BaseOrigamiController end # @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(2) @crm_customer = Customer.new - # @membership = Customer.get_member_group - # if @membership["status"] == true - # @member_group = @membership["data"] - # end - # puts "Errrrrrrrrrrrrrrrrr" - # puts @crm_customer.valid? + + if flash["errors"] + @crm_customer.valid? + end respond_to do |format| diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 04ba5e32..ba36500c 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -75,9 +75,7 @@
<%= f.input :name, :class => "form-control col-md-6 name" %> - <% if flash[:errors] && !flash[:errors].empty? then -%> - <%= flash[:errors]["name"] %> - <% end -%> +
@@ -85,16 +83,12 @@
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %> - <% if flash[:errors] && !flash[:errors].empty? then -%> - <%= flash[:errors]["contact_no"] %> - <% end -%> +
<%= f.input :email, :class => "form-control col-md-6 email" %> - <% if flash[:errors] && !flash[:errors].empty? then -%> - <%= flash[:errors]["email"] %> - <% end -%> +
@@ -110,9 +104,7 @@ <%= member.name %> <%end %> - <% if flash[:errors] && !flash[:errors].empty? then -%> - <%= flash[:errors]["member_group_id"] %> - <% end -%> +
diff --git a/app/views/layouts/CRM.html.erb b/app/views/layouts/CRM.html.erb index fb851d68..42b559e2 100644 --- a/app/views/layouts/CRM.html.erb +++ b/app/views/layouts/CRM.html.erb @@ -19,7 +19,10 @@ <% flash.each do |type, message| %>
- <%= message %> + + <% if !flash["errors"]%> + <%=message%> + <% end %>
<% end %> <%= yield %> diff --git a/app/views/layouts/origami.html.erb b/app/views/layouts/origami.html.erb index ef5f3789..179d9ae1 100644 --- a/app/views/layouts/origami.html.erb +++ b/app/views/layouts/origami.html.erb @@ -17,10 +17,13 @@ <%= render 'layouts/header_orgiami' %>
<% flash.each do |type, message| %> -
- - <%= message %> -
+ <% if !flash["errors"]%> +
+ + <%=message%> +
+ <% end %> + <% end %> <%= yield %> diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index 80150220..f7b4a692 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -78,25 +78,17 @@
<%= f.input :name, :class => "form-control col-md-6 name" %> - <% if flash[:errors] && !flash[:errors].empty? then -%> - <%= flash[:errors]["name"] %> - <% end -%> +
<%= f.input :company, :class => "form-control col-md-6 company" %>
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %> - <% if flash[:errors] && !flash[:errors].empty? then -%> - <%= flash[:errors]["contact_no"] %> - <% end -%>
- <%= f.input :email, :class => "form-control col-md-6 email" %> - <% if flash[:errors] && !flash[:errors].empty? then -%> - <%= flash[:errors]["email"] %> - <% end -%> + <%= f.input :email, :class => "form-control col-md-6 email" %>
@@ -111,11 +103,7 @@ <%end %> - - <% if flash[:errors] && !flash[:errors].empty? then -%> - <%= flash[:errors]["member_group_id"] %> - <% end -%> - +
From b513aa22abf15a8902c058bf3691df5bb1b5f55b Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 13 Jun 2017 12:27:45 +0630 Subject: [PATCH 07/10] datepicker --- Gemfile | 1 + Gemfile.lock | 3 +++ app/assets/javascripts/CRM.js | 4 +++- app/assets/javascripts/application.js | 2 +- app/assets/javascripts/origami.js | 2 ++ app/assets/stylesheets/CRM.scss | 2 ++ app/assets/stylesheets/application.scss | 2 +- app/assets/stylesheets/origami.scss | 2 ++ app/views/crm/customers/index.html.erb | 12 +++++++++++- app/views/origami/customers/index.html.erb | 11 ++++++++++- 10 files changed, 36 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 53d6f963..36be43b7 100644 --- a/Gemfile +++ b/Gemfile @@ -45,6 +45,7 @@ gem 'to_xls-rails' # Use jquery as the JavaScript library gem 'jquery-rails' +gem 'jquery-ui-rails' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder diff --git a/Gemfile.lock b/Gemfile.lock index 3fabf983..a4441893 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -87,6 +87,8 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) + jquery-ui-rails (6.0.1) + railties (>= 3.2.16) kaminari (0.16.3) actionpack (>= 3.0.0) activesupport (>= 3.0.0) @@ -244,6 +246,7 @@ DEPENDENCIES httparty (~> 0.15.5) jbuilder (~> 2.5) jquery-rails + jquery-ui-rails kaminari (~> 0.16.3) listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) diff --git a/app/assets/javascripts/CRM.js b/app/assets/javascripts/CRM.js index 66f161af..ee1c6a41 100644 --- a/app/assets/javascripts/CRM.js +++ b/app/assets/javascripts/CRM.js @@ -14,4 +14,6 @@ //= require bootstrap //= require jquery_ujs //= require turbolinks -//= require cable \ No newline at end of file +//= require cable +//= require jquery-ui +//= require bootstrap-datepicker \ No newline at end of file diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index f4ee96ab..a05ea4ee 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -17,7 +17,7 @@ //= require turbolinks //= require cable //= require settings/processing_items -//= require bootstrap-datepicker + diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 70594497..0079142f 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -15,6 +15,8 @@ //= require jquery_ujs //= require turbolinks //= require cable +//= require jquery-ui +//= require bootstrap-datepicker $(document).ready(function(){ // Enable/Disable Button diff --git a/app/assets/stylesheets/CRM.scss b/app/assets/stylesheets/CRM.scss index f43cc3f9..a88efe96 100644 --- a/app/assets/stylesheets/CRM.scss +++ b/app/assets/stylesheets/CRM.scss @@ -1,6 +1,8 @@ @import "bootstrap"; @import "font-awesome"; @import "theme"; +@import "jquery-ui"; +@import "bootstrap-datepicker3"; /* Show it is fixed to the top */ // body { diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index c3030dfb..6097a890 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -2,7 +2,7 @@ @import "bootstrap"; @import "font-awesome"; @import "theme"; -@import "bootstrap-datepicker"; + /* Show it is fixed to the top */ // body { diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 1ea32844..71a9915e 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -1,6 +1,8 @@ @import "bootstrap"; @import "font-awesome"; @import "theme"; +@import "jquery-ui"; +@import "bootstrap-datepicker3"; /* Show it is fixed to the top */ // body { diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index ba36500c..3f8e2e1a 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -92,7 +92,8 @@
- <%= f.input :date_of_birth,:class=>"form-control date_of_birth"%> + + <%= f.text_field :date_of_birth,:class=>"form-control datepicker"%>
@@ -119,6 +120,15 @@