diff --git a/app/assets/stylesheets/public.scss b/app/assets/stylesheets/public.scss
index e69de29..ba8a349 100644
--- a/app/assets/stylesheets/public.scss
+++ b/app/assets/stylesheets/public.scss
@@ -0,0 +1,5 @@
+
+@import "bootstrap";
+
+@import "fontawesome/font-awesome";
+
diff --git a/app/controllers/admin/p_payments_controller.rb b/app/controllers/admin/p_payments_controller.rb
index 4e75c93..71b1213 100644
--- a/app/controllers/admin/p_payments_controller.rb
+++ b/app/controllers/admin/p_payments_controller.rb
@@ -153,7 +153,7 @@ class Admin::PPaymentsController < ApplicationController
def new
- @p_payment = PPayment.new(:p_payment_type_id => 41)
+ @p_payment = PPayment.new(:p_payment_type_id => 2, :paid => true)
@p_payment.p_customer = PCustomer.find(params[:p_customer_id]) if params[:p_customer_id]
@@ -227,7 +227,7 @@ class Admin::PPaymentsController < ApplicationController
def update_ogone_infos
- params.delete(:search)
+
@check = OgoneRails::CheckAuth.new( request )
if @check.valid?
diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb
index be3760b..6a86269 100644
--- a/app/controllers/admin/price_documents_controller.rb
+++ b/app/controllers/admin/price_documents_controller.rb
@@ -234,34 +234,39 @@ class Admin::PriceDocumentsController < ApplicationController
@price_document = PriceDocument.find_by_token(params[:id])
- @p_payment = PPayment.create(:p_customer => @price_document.p_customer, :amount => @price_document.tot_amount_ttc, :p_payment_type_id => 1, :paid_at => Time.now)
+
+ if @price_document.to_paid_ttc > 0.0
+ @p_payment = PPayment.create(:price_document_id => @price_document.id, :p_customer => @price_document.p_customer, :amount => @price_document.to_paid_ttc, :p_payment_type_id => 1, :paid_at => Time.now)
- #render :inline => @p_payment.errors.messages
- if false # @p_payment.paid
- render :inline => "paiement déjà enregistré"
- #redirect_to new_public_donator_transaction_path(:paid => true)
- else
+ #render :inline => @p_payment.errors.messages
+ if false # @p_payment.paid
+ render :inline => "paiement déjà enregistré"
+ #redirect_to new_public_donator_transaction_path(:paid => true)
+ else
- @ogone_options = {
- :amount => @p_payment.amount,
- :accept_url => "http://#{HOSTNAME}"+paid_by_ogone_confirm_admin_p_payment_path(@p_payment.id),
- :decline_url => "http://#{HOSTNAME}"+paid_by_ogone_admin_price_document_path(@price_document.token),
- :exception_url => "http://#{HOSTNAME}"+paid_by_ogone_admin_price_document_path(@price_document.token),
- :cancel_url => "http://#{HOSTNAME}"+paid_by_ogone_admin_price_document_path(@price_document.token),
- :orderid => @p_payment.token,
- :PARAMVAR => "ogoneipn",
- :PSPID => OgoneRails::pspid,
- :currency => OgoneRails::currency,
- :language => OgoneRails::language,
+ @ogone_options = {
+ :amount => @p_payment.amount,
+ :accept_url => "http://#{HOSTNAME}"+paid_by_ogone_confirm_admin_p_payment_path(@p_payment.id),
+ :decline_url => "http://#{HOSTNAME}"+paid_by_ogone_admin_price_document_path(@price_document.token),
+ :exception_url => "http://#{HOSTNAME}"+paid_by_ogone_admin_price_document_path(@price_document.token),
+ :cancel_url => "http://#{HOSTNAME}"+paid_by_ogone_admin_price_document_path(@price_document.token),
+ :orderid => @p_payment.token,
+ :PARAMVAR => "ogoneipn",
+ :PSPID => OgoneRails::pspid,
+ :currency => OgoneRails::currency,
+ :language => OgoneRails::language,
- }
+ }
- end
+ end
+ else
+
+ end
render :layout => "public"
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 5afa893..66d8005 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -10,12 +10,14 @@ class ApplicationController < ActionController::Base
- before_action :popups
before_action :debug_translation
before_action :get_sorting
+ before_action :set_qi_order
+
+
def get_sorting( column_default=nil, direction_default="desc")
@@ -29,7 +31,7 @@ class ApplicationController < ActionController::Base
end
- before_action :set_qi_order
+
def set_qi_order
params[:search] = params[:search] || {}
@@ -122,10 +124,7 @@ class ApplicationController < ActionController::Base
end
end
end
- def popups
-
-
- end
+
def get_public_layout
"public"
@@ -143,9 +142,9 @@ class ApplicationController < ActionController::Base
@lang = LangSite.find_by_slug I18n.locale.to_s
end
- def default_url_options(options={})
- { :lang => I18n.locale } #
- end
+ #def default_url_options(options={})
+ # { :lang => I18n.locale } #
+ #end
diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb
index 8ecdbb3..b83e098 100644
--- a/app/models/p_customer.rb
+++ b/app/models/p_customer.rb
@@ -262,9 +262,15 @@ class PCustomer < ApplicationRecord
def show_name
if self.particular
n = ""
- n += self.particular.organisation+" " if self.particular.organisation?
- #n += self.particular.name+" " if self.particular.name?
- #n += self.particular.firstname+" " if self.particular.firstname?
+
+ if self.particular.organisation?
+ n += self.particular.organisation
+ n += self.particular.com_name+" " if self.particular.com_name?
+ else
+ n += self.particular.civilite+" " if self.particular.civilite?
+ n += self.particular.name+" " if self.particular.name?
+ n += self.particular.firstname+" " if self.particular.firstname?
+ end
return n
end
end
diff --git a/app/models/p_payment.rb b/app/models/p_payment.rb
index 17182e8..3b21325 100644
--- a/app/models/p_payment.rb
+++ b/app/models/p_payment.rb
@@ -34,6 +34,8 @@ class PPayment < ApplicationRecord
}
+ belongs_to :price_document
+
def verify(size=16)
if !self.token
@@ -57,6 +59,11 @@ class PPayment < ApplicationRecord
end
+ after_commit do
+ self.auto_affect
+ end
+
+
after_save do
self.generate_p_compta_element
end
@@ -79,7 +86,7 @@ class PPayment < ApplicationRecord
after_initialize do
self.p_payment_type_id = 1 if !self.p_payment_type_id?
- self.paid = true
+ #self.paid = true
end
@@ -121,6 +128,8 @@ class PPayment < ApplicationRecord
p_payment_document.save
end
+
+
#self.p_customer.update_caches if self.p_customer
true
end
@@ -149,5 +158,34 @@ class PPayment < ApplicationRecord
+ def auto_affect
+
+ price_document = self.price_document
+
+ if self.paid and price_document and price_document.d_number?
+
+ if self.reste_to_affect > 0.0 and price_document.to_paid_ttc > 0.0
+
+
+
+ if self.reste_to_affect > price_document.to_paid_ttc
+ total_to_affect_now = price_document.to_paid_ttc
+ else
+ total_to_affect_now = self.reste_to_affect
+ end
+
+ total_to_affect_now = total_to_affect_now.to_f
+
+ self.p_payment_documents.create(:price_document => price_document, :amount => total_to_affect_now)
+
+
+ end
+ end
+
+
+
+ end
+
+
end
diff --git a/app/models/price_document.rb b/app/models/price_document.rb
index 8b1a44d..bba61f4 100644
--- a/app/models/price_document.rb
+++ b/app/models/price_document.rb
@@ -34,6 +34,7 @@ class PriceDocument < ApplicationRecord
:cc_tot_amount_ht => {:name => "Montant HT", :reorder => true, :format => :currency},
:cc_tot_amount_tva => {:name => "Montant TVA", :reorder => true, :format => :currency},
:cc_tot_amount_ttc => {:name => "Montant TTC", :reorder => true, :format => :currency},
+ :cc_to_paid_ttc => {:name => "Solde", :reorder => true, :format => :currency},
:accounting_zone_id => "Zone",
:p_commercial => {:name => "Commercial", :reorder => false},
diff --git a/app/views/admin/p_payments/_essentials_form.html.haml b/app/views/admin/p_payments/_essentials_form.html.haml
index 4e639b0..de96cfe 100644
--- a/app/views/admin/p_payments/_essentials_form.html.haml
+++ b/app/views/admin/p_payments/_essentials_form.html.haml
@@ -8,6 +8,10 @@
%tr
%td{:style => "width:200px;"}
= form.input :p_payment_type_id, :label => "Type de paiement :", :include_blank => false, :collection => PPaymentType.order(:name).all, :as => :select, :input_html => {:class => "payment_type_id_select", :readonly => (true if form.object.compta_locked)}
+
+ %td{:style => "width:160px;"}
+ = form.input :paid, :label => "Paiement confirmé ?" ,:input_html => {:readonly => (true if form.object.compta_locked)}
+
%td{:style => "width:160px;"}
= form.input :paid_at, :label => "Date de paiement :" , :as => :date, :input_html => {:readonly => (true if form.object.compta_locked)}
diff --git a/app/views/admin/p_payments/_p_payment.html.haml b/app/views/admin/p_payments/_p_payment.html.haml
index 91bb68f..b6620f5 100644
--- a/app/views/admin/p_payments/_p_payment.html.haml
+++ b/app/views/admin/p_payments/_p_payment.html.haml
@@ -7,7 +7,9 @@
-tr[:paid_at] = capture do
%td= l(p_payment.paid_at, :format => :date) if p_payment.paid_at
-tr[:p_customer] = capture do
- %td=link_to(p_payment.p_customer.show_name, [:admin, p_payment.p_customer]) if p_payment.p_customer
+ %td
+
+ =link_to(p_payment.p_customer.show_name, [:admin, p_payment.p_customer]) if p_payment.p_customer
-tr[:payment_type] = capture do
%td= p_payment.p_payment_type.name if p_payment.p_payment_type
diff --git a/app/views/admin/price_documents/_price_document.html.haml b/app/views/admin/price_documents/_price_document.html.haml
index 684fd9c..14c6e0c 100644
--- a/app/views/admin/price_documents/_price_document.html.haml
+++ b/app/views/admin/price_documents/_price_document.html.haml
@@ -46,14 +46,16 @@
= link_to i(:"trash-o"), [:admin, price_document], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
= link_to i(:pencil), edit_admin_price_document_path(price_document)
= link_to i(:"check-circle-o"), generate_number_admin_price_document_path(price_document), data: { confirm: 'Voulez-vous vraiment valider cette facture et générer son numéro ? ' }
-
+
+ -else
+ = link_to i(:"credit-card"), paid_by_ogone_admin_price_document_path(price_document.token), :remote => false, :target => "_blank" if price_document.to_paid_ttc > 0.0
=# link_to i(:eye), admin_price_document_path(price_document), :remote => true
= link_to i(:copy), new_admin_price_document_path(:to_dup => price_document.id)
= link_to i(:eye), admin_price_document_path(price_document.id), :remote => false, :target => "_blank"
- = link_to i(:"credit-card"), paid_by_ogone_admin_price_document_path(price_document.token), :remote => false, :target => "_blank"
+
= link_to i(:download), print_admin_price_document_path(price_document.token), :remote => false, :target => "_blank"
diff --git a/app/views/admin/price_documents/_search_to_affect.html.haml b/app/views/admin/price_documents/_search_to_affect.html.haml
index 47dfb36..54973ba 100644
--- a/app/views/admin/price_documents/_search_to_affect.html.haml
+++ b/app/views/admin/price_documents/_search_to_affect.html.haml
@@ -86,6 +86,7 @@
%td.search_op
%td.search_label
Soldé ?
+
%td=select_tag :solde, options_for_select([["Non","0"], ["Oui","1"]], params[:solde]), :include_blank => true
%td.search_op
%td
@@ -109,7 +110,7 @@
%table.table.table-stripped.table-hover
- -@price_documents.where(:price_document_type_id => 4).each do |price_document|
+ -@price_documents.where(:price_document_type_id => 1).where("d_number is not NULL").each do |price_document|
%tr.price_document_search#price_document_search{:data => {:id => price_document.id}}
%td{:style => "width:30px;text-align:center;"}=ic :check if price_document.solded
%td{:style => "width:100px"}=l price_document.date, :format => "%y/%m/%Y"
diff --git a/app/views/admin/price_documents/paid_by_ogone.html.haml b/app/views/admin/price_documents/paid_by_ogone.html.haml
index b9c703a..326de60 100644
--- a/app/views/admin/price_documents/paid_by_ogone.html.haml
+++ b/app/views/admin/price_documents/paid_by_ogone.html.haml
@@ -1,18 +1,32 @@
-%center
- =#%p Vous allez être redirigé automatiquement sur le serveur de paiement sécurisé par Ogone. Si ce n'est pas le cas, merci de cliquer sur "payer maintenant"
- %form{:action => CONFIG_OGONE["ecom_url"], :id => "ogone_form"}
- -form_content = ogone_fields(@ogone_options)
- %p
- Montant :
- =number_to_currency @price_document.tot_amount_ttc
+%div{:style => "position:fixed;top:0;left:0;right:0;bottom:0;background:url('/fond.jpg') center center fixed;background-size:cover;"}
+
+ %div{:style => "width:90%;max-width:500px;background:rgba(255,255,255,0.95);text-align:center;padding:20px 10px;margin:auto;margin-top:30px;border-radius:5px;box-shadow:0 0 10px rgba(0,0,0,0.5)"}
+ %center=image_tag "/logo-lockaz.png", :style => "width:300px;margin-top:10px;margin-bottom:10px;"
+ =#%p Vous allez être redirigé automatiquement sur le serveur de paiement sécurisé par Ogone. Si ce n'est pas le cas, merci de cliquer sur "payer maintenant"
+
+ -if @p_payment
+
+ %form{:action => CONFIG_OGONE["ecom_url"], :id => "ogone_form"}
+ -form_content = ogone_fields(@ogone_options)
+ %br
+ %br
+ %p
+ Montant à régler :
+ %strong=number_to_currency @p_payment.amount
- -form_content << ''
+ -form_content << ''
+ %br
+ =raw form_content
+ %br
+ %br
+ %p Vous allez être redirigé sur le serveur de paiement sécurisé par Ingenico/Ogone en cliquant sur "Payer maintenant"
+ %p Olwen Capital, notre partenaire pour le paiement en ligne apparaitra sur votre relevé de compte
- %p Vous allez être redirigé sur le serveur de paiement sécurisé par Ingenico/Ogone en cliquant sur "Payer maintenant"
- %p Olwen Capital, notre partenaire pour le paiement en ligne apparaitra sur votre relevé de compte
-
- =raw form_content
+
- =#:javascript
- =#$("#ogone_form").submit()
+ -else
+ Il semblerait que votre réglement ait déjà été effectué, vous pouvez-nous contacter si besoin.
+
+ =#:javascript
+ =#$("#ogone_form").submit()
diff --git a/app/views/layouts/public.html.haml b/app/views/layouts/public.html.haml
index b8bc802..0271a3d 100644
--- a/app/views/layouts/public.html.haml
+++ b/app/views/layouts/public.html.haml
@@ -57,7 +57,7 @@
=flash[:alert]
- %center=image_tag "/logo-lockaz.png", :style => "width:300px;margin-top:10px;margin-bottom:10px;"
+
=yield
diff --git a/config/routes.rb b/config/routes.rb
index 933b7c6..9d019fd 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -226,8 +226,11 @@ Rails.application.routes.draw do
end
collection do
get :ogone_ipn
+
+ get :search_to_affect
+ get :doublons
+ get :multiple
end
-
end
end
diff --git a/public/fond.jpg b/public/fond.jpg
new file mode 100644
index 0000000..503ffa3
Binary files /dev/null and b/public/fond.jpg differ