Need Images added + Devis attached to devis + text fixing + mail triggers + bug fix

This commit is contained in:
Nicolas VARROT 2016-03-17 16:21:28 +01:00
parent 426591453b
commit 6431ec9e64
48 changed files with 454 additions and 96 deletions

View File

@ -644,6 +644,17 @@ height: 100%;
margin:20px auto; margin:20px auto;
display:block; display:block;
height:200px; height:200px;
margin-bottom:60px;
}
#big-logo{
margin:20px auto;
width:400px;
height:400px;
display:block;
} }

View File

@ -115,14 +115,31 @@
.need-item{ .need-item{
height: 150px; height: 200px;
background-color:#fff; background-color:#fff;
padding-top:30px; padding-top:30px;
position:relative; position:relative;
padding-left:190px;
.need-image{
margin-top:26px;
position: absolute;
top:0px;
left:0px;
width:174px;
height:174px;
background-color: rgb(163, 159, 159);
background-size: cover;
background-position: center center;
background-image: url('/placeholder.png');
}
p.description{ p.description{
font-size:12px; font-size:12px;
color:rgb(163, 159, 159); color:rgb(163, 159, 159);
max-height: 105px;
word-wrap: break-word;
text-overflow: ellipsis;
overflow: hidden;
} }
p.info{ p.info{
@ -157,7 +174,7 @@
position:absolute; position:absolute;
left:0px; left:0px;
bottom:0px; bottom:0px;
padding-left:5px; padding-left:180px;
padding-bottom:5px; padding-bottom:5px;
.item{ .item{
display:inline; display:inline;

View File

@ -11,10 +11,11 @@ class Admin::ContactMessagesController < ApplicationController
@contact_message.read_by_admin = true @contact_message.read_by_admin = true
if @contact_message.save if @contact_message.save
flash[:notice] = "Commentaire envoyé." CustomerMailer.contact_message_received(@contact_message.contact, @contact_message).deliver
flash[:notice] = "Message envoyé."
return redirect_to :back return redirect_to :back
else else
flash[:error] = "Votre commentaire n'a pas pu être envoyé." flash[:error] = "Votre message n'a pas pu être envoyé."
return render 'index' return render 'index'
end end

View File

@ -29,7 +29,7 @@ class Admin::CustomersController < ApplicationController
@customer.account_validated = true @customer.account_validated = true
@customer.account_validated_at = Time.now @customer.account_validated_at = Time.now
@customer.save @customer.save
CustomerMailer.delay.validate_account(@customer) CustomerMailer.validate_account(@customer).deliver
redirect_to :back redirect_to :back
end end

View File

@ -25,6 +25,9 @@ class Admin::DocumentsController < ApplicationController
@document.document = params[:document] @document.document = params[:document]
if @document.save if @document.save
@document.state = :document_available @document.state = :document_available
CustomerMailer.document_available(@accepted_offer.customer, @document).deliver
if @document.returned_document? if @document.returned_document?
@document.remove_returned_document! @document.remove_returned_document!
end end
@ -130,6 +133,7 @@ class Admin::DocumentsController < ApplicationController
if @document.save if @document.save
CustomerMailer.document_verified(@accepted_offer.customer, @document).deliver
flash[:success] = "Document vérifié" flash[:success] = "Document vérifié"
else else
flash[:error] = "Impossible vérifier le document" flash[:error] = "Impossible vérifier le document"

View File

@ -66,6 +66,11 @@ class Admin::NeedsController < ApplicationController
@comments = @need.messages.order(created_at: :desc).page params[:page] @comments = @need.messages.order(created_at: :desc).page params[:page]
end end
def download_devis
@need = Need.find(params[:need_id])
send_file @need.devis.file.path, :filename => "devis-need-#{@need.id}.#{@need.devis.file.extension}"
end
def create def create
@need = Need.new(need_params) @need = Need.new(need_params)
@ -160,7 +165,7 @@ class Admin::NeedsController < ApplicationController
private private
def need_params def need_params
params.require(:need).permit(:title, :description, :category_id, :author_id) params.require(:need).permit(:title, :image_file_id, :description, :category_id, :author_id)
end end
def build_category_tree def build_category_tree

View File

@ -3,7 +3,10 @@ class ApplicationController < ActionController::Base
# For APIs, you may want to use :null_session instead. # For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception protect_from_forgery with: :exception
def auth_customer def auth_customer
session[:devise_id] = params[:d] if params[:d] session[:devise_id] = params[:d] if params[:d]
if !current_customer if !current_customer
session[:before_auth_url] = request.url session[:before_auth_url] = request.url

View File

@ -20,10 +20,16 @@ class Public::ContactMessagesController < ApplicationController
@contact_message.read_by_customer = true @contact_message.read_by_customer = true
if @contact_message.save if @contact_message.save
flash[:notice] = "Commentaire envoyé." flash[:notice] = "Message envoyé."
admins = Admin.where.not(email: nil)
admins.each do |admin|
AdminMailer.customer_send_contact_message(admin, @contact_message).deliver
end
return redirect_to :back return redirect_to :back
else else
flash[:error] = "Votre commentaire n'a pas pu être envoyé." flash[:error] = "Votre message n'a pas pu être envoyé."
return render 'index' return render 'index'
end end

View File

@ -3,6 +3,7 @@ class Public::CustomersAuthsController < ApplicationController
layout "public" layout "public"
def new def new
@biglogo = true
@no_search = true @no_search = true
params[:step] = "login" params[:step] = "login"
if params[:for_annonce] if params[:for_annonce]
@ -26,7 +27,7 @@ class Public::CustomersAuthsController < ApplicationController
end end
def create def create
@biglogo = true
@customer = Customer.new() @customer = Customer.new()
if cookies[:mlm_token] and @parent = Customer.find_parrain(cookies[:mlm_token]) if cookies[:mlm_token] and @parent = Customer.find_parrain(cookies[:mlm_token])
@customer.parent_code = @parent.mlm_token.upcase @customer.parent_code = @parent.mlm_token.upcase
@ -54,7 +55,7 @@ class Public::CustomersAuthsController < ApplicationController
redirect_to :root redirect_to :root
else else
flash.now.alert = "Email ou mot de passe incorect" flash.now.alert = "Email ou mot de passe incorect"
render :action => "new" render :action => "new"
end end
end end

View File

@ -63,8 +63,8 @@ class Public::CustomersController < ApplicationController
@customer = Customer.new(params.require(:customer).permit!) @customer = Customer.new(params.require(:customer).permit!)
if @customer.save if @customer.save
CustomerMailer.delay.confirm(@customer) CustomerMailer.confirm(@customer).deliver
CustomerMailer.delay.notify_ins(@customer) CustomerMailer.notify_ins(@customer).deliver
@customer.authenticate(params[:password]) @customer.authenticate(params[:password])
@ -89,7 +89,7 @@ class Public::CustomersController < ApplicationController
@customer.enabled = true @customer.enabled = true
@customer.save(:validate => false) @customer.save(:validate => false)
CustomerMailer.delay.confirm_ins(@customer) CustomerMailer.confirm_ins(@customer).deliver
cookies[:customer_auth_token] = @customer.token cookies[:customer_auth_token] = @customer.token

View File

@ -13,9 +13,14 @@ class Public::DocumentsController < ApplicationController
def download def download
@document = @accepted_offer.documents.find(params[:id]) @document = @accepted_offer.documents.find(params[:id])
if @document.state == :document_available if @document.state == 'document_available'
@document.state = :document_downloaded @document.state = :document_downloaded
@document.save @document.save
admins = Admin.where.not(email: nil)
admins.each do |admin|
AdminMailer.customer_download_document(admin, @document, current_customer).deliver
end
end end
send_file @document.document.file.path send_file @document.document.file.path
@ -51,7 +56,12 @@ class Public::DocumentsController < ApplicationController
@document = @accepted_offer.documents.find(params[:id]) @document = @accepted_offer.documents.find(params[:id])
@document.returned_document = params[:returned_document] @document.returned_document = params[:returned_document]
if @document.save if @document.save
@document.return_document! @document.state = :document_returned
@document.save
admins = Admin.where.not(email: nil)
admins.each do |admin|
AdminMailer.customer_upload_document(admin, @document, current_customer).deliver
end
flash[:success] = "Document chargé" flash[:success] = "Document chargé"
else else
flash[:error] = "Impossible de charger le document" flash[:error] = "Impossible de charger le document"

View File

@ -15,6 +15,14 @@ class Public::MessagesController < ApplicationController
if(@message.save) if(@message.save)
flash[:notice] = "Commentaire envoyé." flash[:notice] = "Commentaire envoyé."
admins = Admin.where.not(email: nil)
admins.each do |admin|
AdminMailer.customer_post_comment(admin, @need, @message).deliver
end
@need.customers.each do |customer|
CustomerMailer.need_commented(customer, @need, @message).deliver
end
else else
flash[:error] = "Votre commentaire n'a pas pu être envoyé." flash[:error] = "Votre commentaire n'a pas pu être envoyé."
end end

View File

@ -6,7 +6,7 @@ class Public::MyAccountController < ApplicationController
def index def index
@accepted_offers = current_customer.accepted_offers.order(created_at: :desc).page(params[:page_offers]).per(5) @accepted_offers = current_customer.accepted_offers.order(created_at: :desc).page(params[:page_offers]).per(5)
@wishes = current_customer.needs.shared.page(params[:page_wishes]).per(5) @wishes = current_customer.needs.shared.page(params[:page_wishes]).per(5)
@needs = Kaminari.paginate_array(current_customer.owned_needs.order(created_at: :desc)) @needs = Kaminari.paginate_array(current_customer.owned_needs.order(created_at: :desc))
@ -45,7 +45,7 @@ class Public::MyAccountController < ApplicationController
def reconfirm def reconfirm
@no_search = true @no_search = true
CustomerMailer.delay.confirm(current_customer) CustomerMailer.confirm(current_customer).deliver
redirect_to public_my_account_path, :notice => "Le mail vous a été renvoyé" redirect_to public_my_account_path, :notice => "Le mail vous a été renvoyé"
end end

View File

@ -66,6 +66,19 @@ class Public::NeedsController < ApplicationController
end end
def download_devis
@need = Need.find(params[:need_id])
if @need.author.id != current_customer.id
flash[:error] = "Vous n'êtes pas le propriétaire"
return redirect_to :back
end
send_file @need.devis.file.path, filename: "devis-need-#{@need.id}.#{@need.devis.file.extension}"
end
def new def new
@need = Need.new() @need = Need.new()
end end
@ -101,10 +114,13 @@ class Public::NeedsController < ApplicationController
def create def create
@need = Need.new(need_params) @need = Need.new(need_params)
@need.author = current_customer @need.author = current_customer
if !@need.devis?
flash[:error] = "Vous devez joindre un devis au format PDF"
return render :action => "new"
end
if @need.save if @need.save
flash[:notice] = "Votre besoin à été créé avec succès." flash[:notice] = "Votre besoin à été créé avec succès."
redirect_to public_my_account_path redirect_to public_my_account_path
else else
render :action => "new" render :action => "new"
@ -115,13 +131,22 @@ class Public::NeedsController < ApplicationController
def wish def wish
@need = Need.find(params[:id]) @need = Need.find(params[:id])
admins = Admin.where.not(email: nil)
if (!@need.customers.include?(current_customer)) if (!@need.customers.include?(current_customer))
@need.customers << current_customer @need.customers << current_customer
flash[:notice] = "Vous avez signalé votre intérêt pour ce besoin" flash[:notice] = "Vous avez signalé votre intérêt pour ce besoin"
# Find all admins with email
admins.each do |admin|
AdminMailer.customer_interested(admin, @need, current_customer).deliver
end
else else
@need.customers.delete(current_customer) @need.customers.delete(current_customer)
flash[:error] = "Vous n'êtes maintenant plus intéressé par ce besoin" flash[:error] = "Vous n'êtes maintenant plus intéressé par ce besoin"
admins.each do |admin|
AdminMailer.customer_disinterested(admin, @need, current_customer).deliver
end
end end
redirect_to :back redirect_to :back
end end
@ -133,7 +158,7 @@ class Public::NeedsController < ApplicationController
end end
def need_params def need_params
params.require(:need).permit(:title, :description, :category_id) params.require(:need).permit(:title, :devis, :description, :category_id)
end end
def check_owner def check_owner

View File

@ -18,7 +18,17 @@ class Public::OffersController < ApplicationController
@accepted_offer.documents << @document @accepted_offer.documents << @document
if @accepted_offer.save if @accepted_offer.save
admins = Admin.where.not(email: nil)
admins.each do |admin|
AdminMailer.customer_accept_offer(admin, @accepted_offer).deliver
end
CustomerMailer.offer_accepted(current_customer, @accepted_offer).deliver
flash[:notice] = "Proposition acceptée avec succès !" flash[:notice] = "Proposition acceptée avec succès !"
redirect_back_or_default :root redirect_back_or_default :root
end end
end end

View File

@ -10,4 +10,52 @@ class AdminMailer < ApplicationMailer
@need = need @need = need
mail to: admin.email, subject: "Nouvelle proposition de besoin" mail to: admin.email, subject: "Nouvelle proposition de besoin"
end end
# a faire
def customer_interested(admin, need, customer)
@need = need
@customer = customer
mail to: admin.email, subject: "Un client s'est intéressé à un besoin"
end
# a faire
def customer_disinterested(admin, need, customer)
@need = need
@customer = customer
mail to: admin.email, subject: "Un client s'est désintéressé d'un besoin"
end
# a faire
def customer_post_comment(admin, need, comment)
@need = need
@comment = comment
mail to: admin.email, subject: "Un client a laissé un commentaire sur un besoin"
end
# a faire
def customer_accept_offer(admin, accepted_offer)
@accepted_offer = accepted_offer
mail to: admin.email, subject: "Un client a accepté une offre"
end
# a faire
def customer_download_document(admin, document, customer)
@document = document
@customer = customer
mail to: admin.email, subject: "Un client a téléchargé un document"
end
# a faire
def customer_upload_document(admin, document, customer)
@document = document
mail to: admin.email, subject: "Un client a renvoyé un document"
end
# a faire
def customer_send_contact_message(admin, contact_message)
@contact_message = contact_message
mail to: admin.email, subject: "Un client a envoyé un message de contact"
end
end end

View File

@ -50,19 +50,66 @@ class CustomerMailer < ApplicationMailer
def negociate_need(need, customer) def negociate_need(need, customer)
@need = need @need = need
@customer = customer @customer = customer
mail to: @customer.email, :subject => "Négociation en cours !" mail to: @customer.email, :subject => "Négociation en cours pour le besoin #{@need.title}"
end end
def need_negociated(customer ,need)
@need = need
@customer = customer
mail to: @customer.email, :subject => "Besoin #{@need.title} négocié !"
end
def need_negociation_failed(customer, need)
@need = need
@customer = customer
mail to: @customer.email, :subject => "Négociation échouée pour le besoin #{@need.title}"
end
def need_commented(customer, need, comment)
@need = need
@customer = customer
@comment = comment
mail to: @customer.email, :subject => "Nouveau commentaire pour le besoin #{@need.title}"
end
def offer_accepted(customer, accepted_offer)
@accepted_offer = accepted_offer
@customer = customer
mail to: @customer.email, :subject => "Vous avez accepté une proposition"
end
def document_available(customer, document)
@document = document
@customer = customer
mail to: @customer.email, :subject => "Document disponible pour la proposition #{@document.accepted_offer.offer.need.title}"
end
def document_verified(customer, document)
@document = document
@customer = customer
mail to: @customer.email, :subject => "Document vérifié pour la proposition #{@document.accepted_offer.offer.need.title}"
end
def contact_message_received(customer, contact_message)
@contact_message = contact_message
@customer = customer
mail to: @customer.email, :subject => "Message reçu"
end
def new_user(customer) def new_user(customer)
@customer = customer @customer = customer
@parent = @customer.parent @parent = @customer.parent
if @parent if @parent
#mail from: "no-reply@negos.pro", to: @parent.email, :subject => "Vous avez un nouvel affilié sur Negos.pro !" do |format| #mail from: "no-reply@negos.pro", to: @parent.email, :subject => "Vous avez un nouvel affilié sur Negos.pro !" do |format|
# format.html { render layout: false } # format.html { render layout: false }
#end #end
end end
end end

View File

@ -30,13 +30,13 @@ class Admin < ActiveRecord::Base
generate_token(:reset_password_token) generate_token(:reset_password_token)
self.reset_password_sent_at = Time.now self.reset_password_sent_at = Time.now
save! save!
AdminMailer.delay.password_reset(self) AdminMailer.password_reset(self).deliver
end end
def fullname def fullname
"#{firstname.capitalize} #{name.upcase}" "#{firstname.capitalize} #{name.upcase}"
end end
def generate_token(column) def generate_token(column)
begin begin
self[column] = SecureRandom.urlsafe_base64 self[column] = SecureRandom.urlsafe_base64

View File

@ -183,7 +183,7 @@ class Customer < ActiveRecord::Base
self.save(:validate => false) self.save(:validate => false)
CustomerMailer.delay.password_reset(self) CustomerMailer.password_reset(self).deliver
end end

View File

@ -30,12 +30,14 @@ class Need < ActiveRecord::Base
has_many :customers, -> { uniq }, through: :wishes has_many :customers, -> { uniq }, through: :wishes
has_many :messages, dependent: :destroy has_many :messages, dependent: :destroy
has_many :offers, dependent: :destroy has_many :offers, dependent: :destroy
belongs_to :image_file
belongs_to :category, class_name: "NeedCategory" belongs_to :category, class_name: "NeedCategory"
validates :title, :presence => true, length: {within: 4..128} validates :title, :presence => true, length: {within: 4..128}
validates :description, presence: true, length: {maximum: 65535} validates :description, presence: true, length: {maximum: 65535}
belongs_to :author, class_name: 'Customer' belongs_to :author, class_name: 'Customer'
mount_uploader :devis, DevisUploader
# Need's workflow lifecycle # Need's workflow lifecycle
workflow do workflow do
@ -60,41 +62,41 @@ class Need < ActiveRecord::Base
# Find all admins with email # Find all admins with email
admins = Admin.where.not(email: nil) admins = Admin.where.not(email: nil)
admins.each do |admin| admins.each do |admin|
AdminMailer.delay.new_need(admin, self) AdminMailer.new_need(admin, self).deliver
end end
end end
end end
def validate def validate
if self.author if self.author
CustomerMailer.delay.validate_need(self) CustomerMailer.validate_need(self).deliver
end end
end end
def negociate def negociate
customers = self.customers customers = self.customers
customers.each do |customer| customers.each do |customer|
CustomerMailer.delay.negociate_need(self, customer) CustomerMailer.negociate_need(self, customer).deliver
end end
end end
def accept def accept
customers = self.customers customers = self.customers
customers.each do |customer| customers.each do |customer|
CustomerMailer.delay.accept_need(self, customer) CustomerMailer.need_negociated(customer, self).deliver
end end
end end
def reject def reject
customers = self.customers customers = self.customers
customers.each do |customer| customers.each do |customer|
CustomerMailer.delay.reject_need(self, customer) CustomerMailer.need_negociation_failed(customer, self).deliver
end end
end end
def refuse def refuse
if self.author if self.author
CustomerMailer.delay.refuse_need(self) CustomerMailer.refuse_need(self).deliver
end end
end end

View File

@ -6,7 +6,7 @@ class DevisUploader < CarrierWave::Uploader::Base
def filename def filename
"Devis-#{model.offer.need.title}-pour-#{model.customer.organisation}.#{file.extension}" if original_filename.present? "devis.#{file.extension}" if original_filename.present?
end end
def store_dir def store_dir
@ -17,8 +17,5 @@ class DevisUploader < CarrierWave::Uploader::Base
%w(pdf) %w(pdf)
end end
def url
download_admin_offer_accepted_offer_path(model.offer, model)
end
end end

View File

@ -9,8 +9,10 @@
=f.input :title, :label => "Titre : " =f.input :title, :label => "Titre : "
=f.input :category, include_blank: "Toute catégorie", :as => :select, :collection => @tree.map{|c| [(c.level > 0 ? ('&nbsp;&nbsp;&nbsp;' * (c.level - 1)) + "|- ": "").html_safe + c.name, c.id]}, label: "Catégorie de besoin" =f.input :category, include_blank: "Toute catégorie", :as => :select, :collection => @tree.map{|c| [(c.level > 0 ? ('&nbsp;&nbsp;&nbsp;' * (c.level - 1)) + "|- ": "").html_safe + c.name, c.id]}, label: "Catégorie de besoin"
=f.input :description, :label => "Description : ", :rows => 5, :input_html => {:style => "height:100px;"} =f.input :description, :label => "Description : ", :rows => 5, :input_html => {:style => "height:100px;"}
=f.input :image_file_id, :label => "Image", :as => :qi_image_select
=f.input :author, :label => "Auteur", include_blank: "Administrateur" =f.input :author, :label => "Auteur", include_blank: "Administrateur"
=f.input :created_at, :label => "Créé le", disabled: true
=f.input :updated_at, :label => "Dernière modification le", disabled: true
.actions= f.submit "Sauvegarder", :class => "btn btn-primary" .actions
-if @need.devis?
= link_to ic(:download) + " Télécharger le devis attaché par l'émetteur", admin_need_download_devis_path(@need), class: "btn btn-default"
= f.submit "Sauvegarder", :class => "btn btn-primary"

View File

@ -4,6 +4,11 @@
%tr{:id => need.id, class: css_class} %tr{:id => need.id, class: css_class}
%td %td
=link_to need.title, edit_admin_need_path(need) =link_to need.title, edit_admin_need_path(need)
%td
-if need.image_file
=link_to "Oui", need.image_file.file.url, target: "_blank"
-else
Non
%td %td
-if need.category -if need.category
=link_to need.category.name, edit_admin_need_category_path(need.category) =link_to need.category.name, edit_admin_need_category_path(need.category)

View File

@ -13,6 +13,9 @@
Administrateur Administrateur
%td %td
Il y a #{time_ago_in_words( need.created_at)} Il y a #{time_ago_in_words( need.created_at)}
%td
-if need.devis?
=link_to ic(:download) + " Offre/Devis", admin_need_download_devis_path(need), class: "btn btn-primary btn-sm"
%td.actions{:style => "width:150px;text-align:right"} %td.actions{:style => "width:150px;text-align:right"}
-if(need.created?) -if(need.created?)

View File

@ -24,6 +24,8 @@
Émetteur Émetteur
%th %th
Créé Créé
%th
Dévis/Offre
%th{:style => "width:100px"} %th{:style => "width:100px"}
&nbsp; &nbsp;
@ -45,6 +47,8 @@
%tr %tr
%th %th
Titre Titre
%th
Image?
%th %th
Catégorie Catégorie

View File

@ -0,0 +1,7 @@
%p Bonjour,
%p
Le client
%strong= @accepted_offer.customer.fullname
vient d'accepter la proposition concernant le besoin
%strong= @accepted_offer.offer.need.title

View File

@ -0,0 +1,7 @@
%p Bonjour,
%p
Le client
%strong= @customer.fullname
vient de supprimer son intérêt pour le besoin
%strong= @need.title

View File

@ -0,0 +1,9 @@
%p Bonjour,
%p
Le client
%strong= @customer.fullname
vient de télécharger le document
%strong= @document.title
concernant le besoin
%strong= @document.accepted_offer.offer.need.title

View File

@ -0,0 +1,7 @@
%p Bonjour,
%p
Le client
%strong= @customer.fullname
vient de signaler son intérêt pour le besoin
%strong= @need.title

View File

@ -0,0 +1,10 @@
%p Bonjour,
%p
Un client a laissé un commentaire sur le besoin
%strong= @need.title
%p
%strong= @comment.customer.fullname
%p= @comment.content

View File

@ -0,0 +1,8 @@
%p Bonjour,
%p Un client vient de vous envoyer un message de contact. Pour répondre, merci de vous connecter à l'interface administrateur.
%p
%strong= @contact_message.customer.fullname
%p= @contact_message.content

View File

@ -0,0 +1,9 @@
%p Bonjour,
%p
Le client
%strong= @customer.fullname
vient de retourner le document
%strong= @document.title
concernant le besoin
%strong= @document.accepted_offer.offer.need.title

View File

@ -0,0 +1,8 @@
%p Bonjour,
%p Un administrateur Négos vient de répondre à votre message. Pour répondre, connectez-vous à votre espace perso depuis le site.
%p
%strong= @contact_message.admin.author_name
%p= @contact_message.content

View File

@ -0,0 +1,13 @@
%p Bonjour,
%p
Un document est disponible pour une proposition que vous avez récemment acceptée:
%strong= @document.accepted_offer.offer.need.title
%p
Le titre du document concerné est
%strong= @document.title
%p Rendez-vous dans votre espace perso afin de télécharger ce document et nous le retourner complété.
%p Merci

View File

@ -0,0 +1,12 @@
%p Bonjour,
%p
Un document que vous nous avez récemment retourné pour la proposition
%strong= @document.accepted_offer.offer.need.title
vient d'être vérifié
%p
Le titre du document concerné est
%strong= @document.title
%p Merci

View File

@ -0,0 +1,10 @@
%p Bonjour,
%p
Un autre utilisateur a laissé un commentaire sur le besoin
%strong= @need.title
%p
%strong= @comment.customer.fullname
%p= @comment.content

View File

@ -0,0 +1,10 @@
%p Bonjour,
%p
Le besoin
%strong= @need.title
vient d'être négocié !"
%p Rendez-vous sur notre site afin de voir notre proposition
%p Merci

View File

@ -0,0 +1,8 @@
%p Bonjour,
%p
Nous avons le regret de vous annoncer que le besoin
%strong= @need.title
n'a pas pu être négocié.
%p Merci

View File

@ -0,0 +1,7 @@
%p Bonjour,
%p
Vous venez d'accepter une proposition pour le besoin
%strong= @accepted_offer.offer.need.title
%p Merci

View File

@ -3,59 +3,59 @@
%html{:lang => "fr", "xml:lang" => "fr", :xmlns => "http://www.w3.org/1999/xhtml"} %html{:lang => "fr", "xml:lang" => "fr", :xmlns => "http://www.w3.org/1999/xhtml"}
%head %head
%title Négos %title Négos
%meta{:name=>"viewport", :content=>"width=device-width,initial-scale=1"} %meta{:name=>"viewport", :content=>"width=device-width,initial-scale=1"}
%meta{ :"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8" } %meta{ :"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8" }
%meta{ :"name" => "Description", :content => @description } %meta{ :"name" => "Description", :content => @description }
%meta{ :"name" => "Keywords", :content => @keywords } %meta{ :"name" => "Keywords", :content => @keywords }
=#<script type="text/javascript" =#src="https://maps.googleapis.com/maps/api/js?libraries=places&key=AIzaSyDSm3YlFVyeEa6KBPmRRkiylbd-xTl-dkQ"> =#<script type="text/javascript" =#src="https://maps.googleapis.com/maps/api/js?libraries=places&key=AIzaSyDSm3YlFVyeEa6KBPmRRkiylbd-xTl-dkQ">
=#</script> =#</script>
= javascript_include_tag "public" = javascript_include_tag "public"
= csrf_meta_tag = csrf_meta_tag
=#render :partial => "public/shared/ga" =#render :partial => "public/shared/ga"
= stylesheet_link_tag 'public' = stylesheet_link_tag 'public'
= stylesheet_link_tag '/fonts/Stylograph/stylesheet.css' = stylesheet_link_tag '/fonts/Stylograph/stylesheet.css'
<link href='https://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'> <link href='https://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
=javascript_include_tag "https://maps.googleapis.com/maps/api/js?libraries=places&amp;sensor=false" =javascript_include_tag "https://maps.googleapis.com/maps/api/js?libraries=places&amp;sensor=false"
%body %body
.top .top
#menu #menu
=render :partial => "public/shared/menu" =render :partial => "public/shared/menu"
.clear .clear
=link_to image_tag("/logo.png", :id => "logo"), "/"
-if @biglogo
=link_to image_tag("/logo.png", :id => "big-logo"), "/"
-else
=link_to image_tag("/logo.png", :id => "logo"), "/"
#main #main
=yield =yield
%br %br
%br %br
%br %br
.clear .clear
=#render :partial => "public/shared/bottom" =#render :partial => "public/shared/bottom"
#flashs= bootstrap_flash #flashs= bootstrap_flash

View File

@ -1,10 +1,10 @@
.row .row.container
.col-md-6 .col-md-6
.connexion_form .connexion_form
%h1 Vous avez déjà un compte ? %h1 Déjà membre ?
= form_tag public_customers_auths_path do = form_tag public_customers_auths_path do
=hidden_field_tag :for_annonce, params[:for_annonce] =hidden_field_tag :for_annonce, params[:for_annonce]

View File

@ -1,6 +1,9 @@
= semantic_form_for [:public, @need] do |f| = semantic_form_for [:public, @need] do |f|
=f.inputs do =f.inputs do
= f.input :title, :label => "Titre de votre besoin" = f.input :title, :label => "Titre de votre besoin"
= f.input :devis, type: :file, :label => "Devis/Offre (Fichier au format PDF)"
-if @need.devis?
= link_to ic(:download) + " Télécharger le devis actuel", public_need_download_devis_path(@need), class: "btn btn-primary"
= f.input :category, :as => :select, include_blank: "Toute catégorie", :collection => @tree.map{|c| [(c.level > 0 ? ('&nbsp;&nbsp;&nbsp;' * (c.level - 1)) + "|- ": "").html_safe + c.name, c.id]}, label: "Catégorie de besoin" = f.input :category, :as => :select, include_blank: "Toute catégorie", :collection => @tree.map{|c| [(c.level > 0 ? ('&nbsp;&nbsp;&nbsp;' * (c.level - 1)) + "|- ": "").html_safe + c.name, c.id]}, label: "Catégorie de besoin"
= f.input :description, :label => "Description", :rows => 5, :input_html => {:style => "height:100px;"} = f.input :description, :label => "Description", :rows => 5, :input_html => {:style => "height:100px;"}
%br %br

View File

@ -1,9 +1,14 @@
.col-md-6 .col-md-12
.padding.need-item .padding.need-item
%h4 %h4
=link_to need.title.upcase, public_need_path(need) =link_to need.title.upcase, public_need_path(need)
-if need.image_file
%div.need-image{style: "background-image: url('#{need.image_file.file.url}')"}
-else
%div.need-image
-# -if need.author -# -if need.author
-# %p.info=i(:"clock-o") + " Ajouté il y a #{time_ago_in_words(need.created_at)} par #{need.author.anonyme_nick}" -# %p.info=i(:"clock-o") + " Ajouté il y a #{time_ago_in_words(need.created_at)} par #{need.author.anonyme_nick}"
-# -else -# -else
@ -39,7 +44,7 @@
%p.description=truncate(need.description, length: 100) %p.description=need.description
.counters .counters
.item=i(:"hand-paper-o") + " " + need.wishes.length.to_s .item=i(:"hand-paper-o") + " " + need.wishes.length.to_s
@ -54,13 +59,13 @@
-if(need.customers.include?(current_customer)) -if(need.customers.include?(current_customer))
=link_to "Négociation en cours...", public_need_path(need), class: "btn btn-warning pull-right" =link_to "Négociation en cours...", public_need_path(need), class: "btn btn-warning pull-right"
-else -else
=link_to i(:"times-circle") + " Trop tard pour vous !", public_need_path(need) , class: "btn btn-danger pull-right" =link_to i(:"times-circle") + " Négociation en cours...", public_need_path(need) , class: "btn btn-warning pull-right"
-elsif(need.negociated?) -elsif(need.negociated?)
-if(need.customers.include?(current_customer)) -if(need.customers.include?(current_customer))
=link_to i(:"download") +" Voir les propositions", public_need_path(need), class: "btn btn-success pull-right" =link_to i(:"download") +" Voir les propositions", public_need_path(need), class: "btn btn-success pull-right"
-else -else
=link_to i(:"times-circle") + " Trop tard pour vous !", public_need_path(need) , class: "btn btn-danger pull-right" =link_to i(:"times-circle") + " Négociation terminée", public_need_path(need) , class: "btn btn-success pull-right"

View File

@ -39,30 +39,34 @@
%p.description= @need.description %p.description= @need.description
-if @need.image_file
%img{src: @need.image_file.file.url}
%br
%br
-if @need.verified? -if @need.verified?
-if @need.customers.include?(current_customer) -if @need.customers.include?(current_customer)
.alert.alert-success .alert.alert-success
%h3= i(:"check") + ' Vous êtes intéressé par ce besoin' %h3= i(:"check") + ' Vous êtes intéressé par ce besoin'
%p Marquer votre interêt pour un besoin vous permettra d'accéder à des propositions intéressantes si nous décidons par la suite de négocier ce besoin auprès de nos fournisseurs. %p Marquer votre intérêt pour un besoin vous permettra daccéder à des offres intéressantes, si nous décidons par la suite de le négocier auprès des fournisseurs,
-else -else
.alert.alert-info .alert.alert-info
%h3 Vous avez aussi ce besoin ? signalez-le nous ! %h3 Vous avez aussi ce besoin ? signalez-le nous !
%p Vous pouvez marquer votre interêt pour ce besoin en cliquant sur le bouton <strong>Ça m'intéresse !</strong> %p Vous pouvez marquer votre interêt pour ce besoin en cliquant sur le bouton <strong>Ça m'intéresse !</strong>
%p Si il y a un nombre suffisant de personnes avec ce même besoin, une négociation sera entamée auprès de nos fournisseurs afin de vous faire une proposition au meilleur prix. %p Si il y a un nombre suffisant de personnes intéressées par ce même besoin, une négociation sera entamée auprès des fournisseurs afin de vous faire une offre intéressante.
%p Vous ensuite libre d'accepter ou non la proposition %p Une fois la négociation terminée, vous serez libre d'accepter ou non la proposition.
-elsif @need.negociating? -elsif @need.negociating?
-if @need.customers.include?(current_customer) -if @need.customers.include?(current_customer)
.alert.alert-warning .alert.alert-warning
%h3 Négociation en cours... %h3 Négociation en cours...
%p Ce besoin a suscité un interêt suffisant pour que nous engagions une négociation afin de vous proposer cet article au meilleur prix. %p Ce besoin a suscité un interêt suffisant pour que nous engagions une négociation auprès des fournisseurs.
%p Vous avez marqué votre interêt pour ce besoin et vous serez donc prevenu dès que la négociation sera terminée. %p Une fois la négociation terminée, vous serez libre daccepter ou non loffre proposée.
%p Une ou plusieurs propositions vous seront faites et vous serez libre de les accepter ou non. %p <strong>Afin den bénéficier, merci de nous retourner au plus vite le mandat signé</strong>
%p <strong>Attention, accepter la proposition vous engage à payer.</strong>
-else -else
.alert.alert-warning .alert.alert-warning
%h3 Négociation en cours... %h3 Négociation en cours...
%p Ce besoin a suscité un interêt suffisant pour que nous engagions une négociation afin de vous proposer cet article au meilleur prix. %p Ce besoin a suscité un interêt suffisant pour que nous engagions une négociation auprès des fournisseurs.
.alert.alert-danger .alert.alert-danger
%p Malheureusement vous n'avez pas marqué votre interêt pour ce besoin pendant la période de sondage, vous ne pourrez donc pas profiter de cette négociation. %p Malheureusement vous n'avez pas marqué votre interêt pour ce besoin pendant la période de sondage, vous ne pourrez donc pas profiter de cette négociation.
-elsif @need.negociated? -elsif @need.negociated?
@ -71,7 +75,7 @@
%h3 Négociation terminée %h3 Négociation terminée
%p= "Nous avons négocié ce besoin à partir de #{number_to_currency(offers.first.price, locale: :fr)}" %p= "Nous avons négocié ce besoin à partir de #{number_to_currency(offers.first.price, locale: :fr)}"
%p Vous avez maintenant le choix d'accepter ou refuser la proposition. %p Vous avez maintenant le choix d'accepter ou refuser la proposition.
%p <strong>Attention, accepter la proposition vous engage à payer.</strong> %p <strong>Une fois la proposition acceptée, vous devrez nous retourner au plus vite le mandat signé</strong>
-else -else
.alert.alert-success .alert.alert-success
%h3 Négociation terminée %h3 Négociation terminée
@ -111,14 +115,15 @@
=link_to i(:"check") + " Accepter la proposition", accept_public_need_offer_path(@need, offer), data: {confirm: "Voulez-vous vraiment accepter cette proposition ? Attention, cette action vous engage à payer la somme proposée."}, class: "btn btn-lg btn-success " =link_to i(:"check") + " Accepter la proposition", accept_public_need_offer_path(@need, offer), data: {confirm: "Voulez-vous vraiment accepter cette proposition ? Attention, cette action vous engage à payer la somme proposée."}, class: "btn btn-lg btn-success "
-else -else
.offer-accepted .offer-accepted
=i(:"check") + " Propositions Acceptée" =i(:"check") + " Proposition Acceptée"
.my-account-link .my-account-link
Consulter vos propositions acceptées depuis la rubrique Vous devez maintenant nous retourner le mandat signé, rendez-vous rubrique
=link_to "Mon compte", public_my_account_path =link_to "Mon compte", public_my_account_path
pour gérer vos propositions acceptées.
-else -else
.offer-not-aceptable .offer-not-aceptable
Vous n'êtes pas intéressé Proposition non disponible
.clear .clear

View File

@ -103,6 +103,7 @@ Rails.application.routes.draw do
end end
resources :needs do resources :needs do
get :download_devis
resources :messages resources :messages
resources :offers do resources :offers do
member do member do
@ -265,6 +266,7 @@ Rails.application.routes.draw do
resources :need_categories resources :need_categories
resources :needs do resources :needs do
get :download_devis
resources :messages resources :messages
resources :wishes resources :wishes
resources :offers do resources :offers do

View File

@ -0,0 +1,6 @@
class AddImageAndFileToNeed < ActiveRecord::Migration
def change
add_column :needs, :devis, :string
add_reference :needs, :image_file, index: true
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160308112733) do ActiveRecord::Schema.define(version: 20160317130441) do
create_table "accepted_offers", force: :cascade do |t| create_table "accepted_offers", force: :cascade do |t|
t.datetime "created_at", null: false t.datetime "created_at", null: false
@ -438,19 +438,22 @@ ActiveRecord::Schema.define(version: 20160308112733) do
add_index "need_categories", ["parent_id"], name: "index_need_categories_on_parent_id", using: :btree add_index "need_categories", ["parent_id"], name: "index_need_categories_on_parent_id", using: :btree
create_table "needs", force: :cascade do |t| create_table "needs", force: :cascade do |t|
t.string "title", limit: 255 t.string "title", limit: 255
t.text "description", limit: 65535 t.text "description", limit: 65535
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.integer "author_id", limit: 4 t.integer "author_id", limit: 4
t.datetime "deleted_at" t.datetime "deleted_at"
t.string "state", limit: 255 t.string "state", limit: 255
t.integer "category_id", limit: 4 t.integer "category_id", limit: 4
t.string "devis", limit: 255
t.integer "image_file_id", limit: 4
end end
add_index "needs", ["author_id"], name: "index_needs_on_author_id", using: :btree add_index "needs", ["author_id"], name: "index_needs_on_author_id", using: :btree
add_index "needs", ["category_id"], name: "index_needs_on_category_id", using: :btree add_index "needs", ["category_id"], name: "index_needs_on_category_id", using: :btree
add_index "needs", ["deleted_at"], name: "index_needs_on_deleted_at", using: :btree add_index "needs", ["deleted_at"], name: "index_needs_on_deleted_at", using: :btree
add_index "needs", ["image_file_id"], name: "index_needs_on_image_file_id", using: :btree
add_index "needs", ["title"], name: "index_needs_on_title", using: :btree add_index "needs", ["title"], name: "index_needs_on_title", using: :btree
create_table "newsgroups", force: :cascade do |t| create_table "newsgroups", force: :cascade do |t|

BIN
public/placeholder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB