suite
This commit is contained in:
parent
ba571a8931
commit
f414b3840d
@ -19,6 +19,56 @@ class Contact < ActiveRecord::Base
|
||||
|
||||
accepts_nested_attributes_for :contact_products
|
||||
|
||||
|
||||
def devis_content
|
||||
r = ""
|
||||
if self.contact_products.count > 0
|
||||
r+= "<table class='table'>"
|
||||
r+= "<tr>"
|
||||
r+= "
|
||||
<td></td>
|
||||
<td>Code</td>
|
||||
<td>Produit</td>
|
||||
<td>Conditionnement</td>
|
||||
<td>Quantité</td>
|
||||
<td>Unité</td>
|
||||
"
|
||||
|
||||
r+= "</tr>"
|
||||
|
||||
self.contact_products.all.each do |cp|
|
||||
r+= "<tr>"
|
||||
|
||||
r+= "<td>"
|
||||
r+= ActionController::Base.helpers.image_tag("https://payreenergies.fr/"+cp.d_product.icon.file.url, :style => "height:80px;").to_s
|
||||
r+= "</td>"
|
||||
r+= "<td>"
|
||||
r+=cp.code.to_s
|
||||
r+= "</td>"
|
||||
r+= "<td>"
|
||||
r+=cp.d_product.name.to_s
|
||||
r+= "</td>"
|
||||
r+= "<td>"
|
||||
r+=cp.ship_type.to_s
|
||||
r+= "</td>"
|
||||
r+= "<td>"
|
||||
r+=cp.qte.to_s
|
||||
r+= "</td>"
|
||||
r+= "<td>"
|
||||
r+=cp.d_product.unit.to_s
|
||||
r+= "</td>"
|
||||
|
||||
r+= "</tr>"
|
||||
|
||||
end
|
||||
|
||||
r+= "</table>"
|
||||
|
||||
end
|
||||
|
||||
return r
|
||||
end
|
||||
|
||||
def email_needed?
|
||||
true if self.email?
|
||||
end
|
||||
@ -28,9 +78,9 @@ class Contact < ActiveRecord::Base
|
||||
end
|
||||
|
||||
before_validation do
|
||||
if (true or ((raison_id == 4 )) and !self.email? and !self.phone?)
|
||||
errors.add(:email, "Vous devez indiquer votre numéro de téléphone et/ou votre email")
|
||||
errors.add(:phone, "Vous devez indiquer votre numéro de téléphone et/ou votre email")
|
||||
if (true or ((raison_id == 4 )) and !self.phone?)
|
||||
#errors.add(:email, "Vous devez indiquer votre numéro de téléphone et/ou votre email")
|
||||
errors.add(:phone, "Vous devez indiquer votre numéro de téléphone")
|
||||
|
||||
end
|
||||
|
||||
@ -52,14 +102,24 @@ class Contact < ActiveRecord::Base
|
||||
:firstname => self.firstname,
|
||||
|
||||
:corporate => self.corporate,
|
||||
|
||||
|
||||
:address => self.address,
|
||||
|
||||
:address2 => self.address2,
|
||||
|
||||
:cp => self.cp,
|
||||
|
||||
:city => self.city,
|
||||
|
||||
:email => self.email,
|
||||
|
||||
:phone => self.phone,
|
||||
|
||||
:message => self.message,
|
||||
|
||||
:provenance_id => self.provenance_id
|
||||
:provenance_id => self.provenance_id,
|
||||
|
||||
:devis_content => self.devis_content
|
||||
}
|
||||
|
||||
|
||||
@ -78,10 +138,15 @@ class Contact < ActiveRecord::Base
|
||||
Curl::PostField.content(:name, @params[:name]),
|
||||
Curl::PostField.content(:firstname, @params[:firstname]),
|
||||
Curl::PostField.content(:corporate, @params[:corporate]),
|
||||
Curl::PostField.content(:address, @params[:address]),
|
||||
Curl::PostField.content(:address2, @params[:address2]),
|
||||
Curl::PostField.content(:cp, @params[:cp]),
|
||||
Curl::PostField.content(:city, @params[:city]),
|
||||
Curl::PostField.content(:email, @params[:email]),
|
||||
Curl::PostField.content(:phone, @params[:phone]),
|
||||
Curl::PostField.content(:message, @params[:message]),
|
||||
Curl::PostField.content(:provenance_id, @params[:provenance_id])
|
||||
Curl::PostField.content(:provenance_id, @params[:provenance_id]),
|
||||
Curl::PostField.content(:devis_content, @params[:devis_content])
|
||||
|
||||
)
|
||||
|
||||
|
@ -3,4 +3,8 @@ class ContactProduct < ActiveRecord::Base
|
||||
belongs_to :d_product
|
||||
|
||||
validates :qte, :presence => true
|
||||
|
||||
before_validation do
|
||||
self.code = self.d_product.code if self.d_product and !self.code
|
||||
end
|
||||
end
|
||||
|
@ -46,9 +46,11 @@
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
|
||||
=raw @contact.devis_content
|
||||
%h2 Interactions
|
||||
|
||||
|
||||
|
||||
#contact_actions
|
||||
=render @contact_actions
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
= form.input :icon_id, :label => "Icone :" , :as => :qi_image_select
|
||||
|
||||
=form.input :code, :label => "Code :"
|
||||
|
||||
=form.input :name, :label => "Nom :"
|
||||
=form.input :description, :label => "Description :"
|
||||
|
||||
|
@ -18,11 +18,15 @@
|
||||
%td
|
||||
=f.hidden_field :d_product_id
|
||||
=image_tag f.object.d_product.icon.file.url
|
||||
|
||||
%td
|
||||
=f.label :qte, "Quantité souhaitée (#{f.object.d_product.unit}) :"
|
||||
%td
|
||||
=f.input :qte, :label => false
|
||||
-p_ids << f.object.d_product_id
|
||||
%td
|
||||
-if f.object.d_product_id == 7
|
||||
=f.select :ship_type, ["En vrac","En sacs"]
|
||||
%td
|
||||
=link_to "supprimer ce produit", public_contact_product_path(:id => f.object.d_product_id), :method => :delete
|
||||
|
||||
@ -66,7 +70,7 @@
|
||||
-if @contact.raison_id == 4
|
||||
%tr
|
||||
%td{:colspan => 2}
|
||||
=f.input :address, :label => false, :placeholder => "Adresse*"
|
||||
=f.input :address, :label => false, :placeholder => "Adresse"
|
||||
%tr
|
||||
%td{:colspan => 2}
|
||||
=f.input :address2, :label => false, :placeholder => "Adresse (suite)"
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
%table
|
||||
%tr
|
||||
%td Civilité
|
||||
%td=@contact.civilite
|
||||
%td Organisation
|
||||
%td=@contact.corporate
|
||||
%tr
|
||||
%td Nom
|
||||
%td=@contact.name
|
||||
@ -17,6 +17,9 @@
|
||||
%tr
|
||||
%td Adresse
|
||||
%td=@contact.address
|
||||
%tr
|
||||
%td Adresse
|
||||
%td=@contact.address2
|
||||
%tr
|
||||
%td Code postal
|
||||
%td=@contact.cp
|
||||
@ -46,4 +49,26 @@
|
||||
%hr
|
||||
=simple_format @contact.message
|
||||
%hr
|
||||
|
||||
-if @contact.contact_products.count > 0
|
||||
%table
|
||||
%tr
|
||||
%td
|
||||
%td Code
|
||||
%td Produit
|
||||
%td Conditionnement
|
||||
%td Quantité
|
||||
%td Unité
|
||||
-@contact.contact_products.all.each do |cp|
|
||||
%tr
|
||||
%td
|
||||
=image_tag "https://payreenergies.fr/"+cp.d_product.icon.file.url, :style => "height:80px;"
|
||||
%td
|
||||
=cp.code
|
||||
%td
|
||||
=cp.d_product.name
|
||||
%td
|
||||
=cp.ship_type
|
||||
%td
|
||||
=cp.qte
|
||||
%td
|
||||
=cp.d_product.unit
|
||||
|
@ -0,0 +1,6 @@
|
||||
class AddStuffToContactProducts < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :contact_products, :code, :string
|
||||
add_column :contact_products, :ship_type, :string
|
||||
end
|
||||
end
|
5
db/migrate/20191103211533_add_stuff_to_d_products.rb
Normal file
5
db/migrate/20191103211533_add_stuff_to_d_products.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddStuffToDProducts < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :d_products, :code, :string
|
||||
end
|
||||
end
|
17
db/schema.rb
17
db/schema.rb
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20190325230219) do
|
||||
ActiveRecord::Schema.define(version: 20191103211533) do
|
||||
|
||||
create_table "admin_admin_roles", force: :cascade do |t|
|
||||
t.integer "admin_id", limit: 4
|
||||
@ -251,12 +251,14 @@ ActiveRecord::Schema.define(version: 20190325230219) do
|
||||
t.integer "contact_id", limit: 4
|
||||
t.integer "d_product_id", limit: 4
|
||||
t.integer "qte", limit: 4
|
||||
t.decimal "price_ht", precision: 10
|
||||
t.decimal "price_ttc", precision: 10
|
||||
t.decimal "price_tot_ht", precision: 10
|
||||
t.decimal "price_tot_ttc", precision: 10
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.decimal "price_ht", precision: 10
|
||||
t.decimal "price_ttc", precision: 10
|
||||
t.decimal "price_tot_ht", precision: 10
|
||||
t.decimal "price_tot_ttc", precision: 10
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "code", limit: 255
|
||||
t.string "ship_type", limit: 255
|
||||
end
|
||||
|
||||
add_index "contact_products", ["contact_id"], name: "index_contact_products_on_contact_id", using: :btree
|
||||
@ -308,6 +310,7 @@ ActiveRecord::Schema.define(version: 20190325230219) do
|
||||
t.datetime "updated_at", null: false
|
||||
t.boolean "orderable", default: true
|
||||
t.string "unit", limit: 255, default: "L"
|
||||
t.string "code", limit: 255
|
||||
end
|
||||
|
||||
create_table "data_file_categories", force: :cascade do |t|
|
||||
|
Loading…
x
Reference in New Issue
Block a user