Ameliorations demandees par le client

This commit is contained in:
Nicolas VARROT 2016-10-18 17:19:45 +02:00
parent 81bbd7d5ac
commit 6fe10f5faa
19 changed files with 198 additions and 74 deletions

View File

@ -78,7 +78,7 @@
.my-account-link{ .my-account-link{
display:inline-block; display:inline-block;
color:#3C763D; color:#3C763D;
font-size:10px; font-size:15px;
float:right; float:right;
position:absolute; position:absolute;
right:10px; right:10px;

View File

@ -9,6 +9,32 @@ class Admin::MessagesController < ApplicationController
end end
def create
@message = Message.new
@message.admin = current_admin
@message.content = params[:message][:content]
@need = Need.find(params[:need_id])
@message.need = @need
if @message.save
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
flash[:notice] = "Commentaire envoyé"
redirect_to action: 'index'
else
flash[:error] = "Impossible de créer ce commentaire"
redirect_to action: 'index'
end
end
def destroy def destroy
@message = Message.find(params['id']) @message = Message.find(params['id'])
if @message.destroy if @message.destroy

View File

@ -63,6 +63,7 @@ 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.confirm(@customer).deliver CustomerMailer.confirm(@customer).deliver
CustomerMailer.notify_ins(@customer).deliver CustomerMailer.notify_ins(@customer).deliver
@ -87,6 +88,7 @@ class Public::CustomersController < ApplicationController
else else
render :action => "new" render :action => "new"
end end
end end
@ -108,6 +110,13 @@ class Public::CustomersController < ApplicationController
def update def update
@customer = Customer.find(params[:id]) @customer = Customer.find(params[:id])
@accepted_offers = @customer.accepted_offers.order(created_at: :desc).page(params[:page_offers]).per(5)
@wishes = @customer.wishes.includes(:need).page(params[:page_wishes]).per(5)
@needs = Kaminari.paginate_array(@customer.owned_needs.order(created_at: :desc))
.page(params[:page_needs])
.per(5)
if params[:order] if params[:order]
@customer.force_address = true @customer.force_address = true
@ -118,20 +127,16 @@ class Public::CustomersController < ApplicationController
if @customer.update_attributes(params.require(:customer).permit!) if @customer.update_attributes(params.require(:customer).permit!)
flash[:success] = "Vos informations ont bien été enregistrées"
redirect_to public_my_account_path redirect_to public_my_account_path
else else
if params[:customer][:step2] or params[:customer][:step3] flash[:error] = "Certains champs sont invalides"
render :template => "public/my_account/index"
else
render :template => "public/my_account/edit_infos" render :template => "public/my_account/edit_infos"
end end
end end
end end
end

View File

@ -5,6 +5,7 @@ class Public::MyAccountController < ApplicationController
before_filter :auth_customer before_filter :auth_customer
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.wishes.includes(:need).page(params[:page_wishes]).per(5) @wishes = current_customer.wishes.includes(:need).page(params[:page_wishes]).per(5)
@ -13,8 +14,6 @@ class Public::MyAccountController < ApplicationController
.page(params[:page_needs]) .page(params[:page_needs])
.per(5) .per(5)
end end
def edit_infos def edit_infos

View File

@ -40,12 +40,18 @@ class Customer < ActiveRecord::Base
validates_presence_of :name validates_presence_of :name
validates_presence_of :firstname validates_presence_of :firstname
validates_presence_of :organisation validates_presence_of :organisation
validates_presence_of :phone validates_presence_of :phone
#validates_presence_of :parent_code #validates_presence_of :parent_code
validates :capital, :numericality => true, :presence => true, :if => :step2
validates :role_signataire, :presence => true, :if => :step2
validates_presence_of :password, :on => :create validates_presence_of :password, :on => :create
validates :email, :presence => true, :uniqueness => true, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i validates :email, :presence => true, :uniqueness => true, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i

View File

@ -1,5 +1,6 @@
class Message < ActiveRecord::Base class Message < ActiveRecord::Base
belongs_to :customer belongs_to :customer
belongs_to :admin
belongs_to :need belongs_to :need
paginates_per 5 paginates_per 5

View File

@ -40,29 +40,34 @@
%td{style:"text-align:center"} %td{style:"text-align:center"}
-if !document.document? -if !document.document?
= form_tag admin_offer_accepted_offer_document_upload_document_path(@offer, @accepted_offer, document), name: :document, method: :post, multipart: true do = form_tag admin_offer_accepted_offer_document_upload_document_path(@offer, @accepted_offer, document), name: :document, method: :post, multipart: true do
%span.btn.btn-default.btn-file %span.btn.btn-xs.btn-default.btn-file
="Ouvrir (PDF)" = ic(:'folder-open')
= file_field_tag :document = file_field_tag :document
= submit_tag("Charger" , class:"btn btn-primary") %button.btn.btn-xs.upload-file{type: :submit, title: "Charger"}
= ic(:check)
-else -else
=link_to i(:"download"),public_download_document_path(document.download_token, admin: true),title: "Télécharger le document" =link_to ic(:"download"),public_download_document_path(document.download_token, admin: true),title: "Télécharger le document", class: "btn btn-primary btn-xs"
-if !document.document_verified? -if !document.document_verified?
=link_to i(:"remove"), admin_offer_accepted_offer_document_delete_path(@offer, @accepted_offer, document), title: "Supprimer le fichier chargé", :data => {:confirm => 'Voulez-vous vraiment supprimer le fichier chargé ?'} =link_to ic(:"remove"), admin_offer_accepted_offer_document_delete_path(@offer, @accepted_offer, document), title: "Supprimer le fichier chargé",class: "btn btn-danger btn-xs", :data => {:confirm => 'Voulez-vous vraiment supprimer le fichier chargé ?'}
%td{style:"text-align:center"} %td{style:"text-align:center"}
-if !document.not_available? -if !document.not_available?
-if !document.returned_document? -if !document.returned_document?
= form_tag admin_offer_accepted_offer_document_upload_returned_document_path(@offer, @accepted_offer, document), name: :returned_document, method: :post, multipart: true do = form_tag admin_offer_accepted_offer_document_upload_returned_document_path(@offer, @accepted_offer, document), name: :returned_document, method: :post, multipart: true do
%span.btn.btn-default.btn-file %span.btn.btn-xs.btn-default.btn-file
="Ouvrir (PDF)" = ic(:'folder-open')
= file_field_tag :returned_document = file_field_tag :returned_document
= submit_tag("Charger manuellement" , class:"btn btn-primary") %button.btn.btn-xs.upload-file{type: :submit, title: "Charger manuellement"}
= ic(:check)
-else -else
=link_to i(:"download"), admin_offer_accepted_offer_document_download_returned_path(@offer, @accepted_offer, document, :admin => true),title: "Télécharger le document" =link_to ic(:"download"), admin_offer_accepted_offer_document_download_returned_path(@offer, @accepted_offer, document, :admin => true),class: "btn btn-primary btn-xs", title: "Télécharger le document"
-if !document.document_verified? -if !document.document_verified?
=link_to i(:"remove"), admin_offer_accepted_offer_document_delete_returned_path(@offer, @accepted_offer, document), title: "Supprimer le fichier chargé", :data => {:confirm => 'Voulez-vous vraiment supprimer le fichier chargé ?'} =link_to ic(:"remove"), admin_offer_accepted_offer_document_delete_returned_path(@offer, @accepted_offer, document),class: "btn btn-danger btn-xs", title: "Supprimer le fichier chargé", :data => {:confirm => 'Voulez-vous vraiment supprimer le fichier chargé ?'}
-if document.document_returned? -if document.document_returned?
=link_to i(:"check"), admin_offer_accepted_offer_document_verify_returned_path(@offer, @accepted_offer, document), :data => {:confirm => 'Voulez-vous vraiment marquer le document retourné par le client comme vérifié ?'}, title: "Marquer le document comme vérifié" =link_to ic(:"check"), admin_offer_accepted_offer_document_verify_returned_path(@offer, @accepted_offer, document),class: "btn btn-success btn-xs", :data => {:confirm => 'Voulez-vous vraiment marquer le document retourné par le client comme vérifié ?'}, title: "Marquer le document comme vérifié"
-else -else
Charger un document d'abord Charger un document d'abord
@ -80,3 +85,12 @@
=link_to ic(:check) + " Je confirme que tous les documents ont été retournés et vérifiés", validate_all_documents_admin_offer_accepted_offer_path(@offer, @accepted_offer), class:"btn btn-lg btn-success pull-right",:data => {:confirm => 'Voulez-vous vraiment confirmer que tous les documents ont été retournés et vérifiés ?'} =link_to ic(:check) + " Je confirme que tous les documents ont été retournés et vérifiés", validate_all_documents_admin_offer_accepted_offer_path(@offer, @accepted_offer), class:"btn btn-lg btn-success pull-right",:data => {:confirm => 'Voulez-vous vraiment confirmer que tous les documents ont été retournés et vérifiés ?'}
=link_to ic(:"chevron-circle-left") + " Gestion des propositions par client pour le besoin #{@offer.need.title}", accepted_admin_offer_path(@offer), class: "btn btn-default" =link_to ic(:"chevron-circle-left") + " Gestion des propositions par client pour le besoin #{@offer.need.title}", accepted_admin_offer_path(@offer), class: "btn btn-default"
:javascript
$(".upload-file").prop("disabled","disabled");
$(".btn-file input").change(function(){
$(this).parent().next(".upload-file").prop("disabled","");
$(this).parent().next(".upload-file").addClass("btn-success");
})

View File

@ -19,6 +19,8 @@
=#f.hidden_field :step2 =#f.hidden_field :step2
=f.input :tva_number, :label => "Numéro de TVA intra. :" =f.input :tva_number, :label => "Numéro de TVA intra. :"
=f.input :siret, :label => "Numéro de siret :" =f.input :siret, :label => "Numéro de siret :"
=f.input :capital, :label => "Capital :"
=f.input :role_signataire, :label => "Fonction du signataire :"
= f.input :address, :label => "Adresse" = f.input :address, :label => "Adresse"
= f.input :address2, :label => "Adresse (suite)" = f.input :address2, :label => "Adresse (suite)"
= f.input :cp, :label => "Code postal" = f.input :cp, :label => "Code postal"
@ -41,5 +43,3 @@
.actions= f.submit "Sauvegarder", :class => "btn btn-primary" .actions= f.submit "Sauvegarder", :class => "btn btn-primary"

View File

@ -1,6 +1,13 @@
.white.padding.message-item .white.padding.message-item
%h4=message.customer.anonyme_nick -if message.customer
%h4
=message.customer.anonyme_nick
="(#{message.customer.fullname} de #{message.customer.organisation})"
-elsif message.admin
%h4="#{message.admin.fullname} (ADMINISTRATEUR)"
%p.info="Posté le #{message.created_at.strftime('%d/%m/%Y à %H:%M')}, il y a #{time_ago_in_words(message.created_at)}" %p.info="Posté le #{message.created_at.strftime('%d/%m/%Y à %H:%M')}, il y a #{time_ago_in_words(message.created_at)}"

View File

@ -1,5 +1,16 @@
%h1= "Commentaires du besoin #{@need.title}" %h1= "Commentaires du besoin #{@need.title}"
= semantic_form_for [:admin, @need, Message.new], :html => {id: :message_form, :method => :post } do |f|
%h4 Écrire un nouveau message
= f.inputs do
= f.input :content, as: :text, label: false, rows: 5, :input_html => {:style => "height:100px;"}
=f.submit "Envoyer", :class => "btn btn-square btn-primary pull-right"
%h4= " #{pluralize(@need.messages.count, 'Commentaire')} pour ce besoin" %h4= " #{pluralize(@need.messages.count, 'Commentaire')} pour ce besoin"
=render collection: @comments, partial: 'message' =render collection: @comments, partial: 'message'

14
app/views/admin_mailer/customer_post_comment.html.haml Normal file → Executable file
View File

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

16
app/views/customer_mailer/need_commented.html.haml Normal file → Executable file
View File

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

View File

@ -1,23 +1,34 @@
%tr{class: document.document_verified? ? "success" : ""} %tr{class: document.document_verified? ? "success" : ""}
%td %td
= i(:file) + " " + document.title = i(:file) + " " + document.title
%td{style:"text-align:center"} %td{style:"text-align:center;vertical-align:middle"}
-if document.document? -if document.document?
=link_to ic(:download), public_download_document_path(document.download_token),class: "btn btn-primary btn-sm",title: "Télécharger le document" =link_to ic(:download), public_download_document_path(document.download_token),class: "btn btn-primary btn-xs",title: "Télécharger le document"
-else -else
Pas encore disponible Pas encore disponible
%td{style:"text-align:center"} %td{style:"text-align:center;vertical-align:middle"}
-if !document.not_available? -if !document.not_available?
-if !document.returned_document? -if !document.returned_document?
= form_tag upload_returned_public_accepted_offer_document_path(@accepted_offer, document), name: :returned_document, method: :post, multipart: true do = form_tag upload_returned_public_accepted_offer_document_path(@accepted_offer, document), name: :returned_document, method: :post, multipart: true do
%span.btn.btn-default.btn-file %span.btn.btn-xs.btn-default.btn-file
="Ouvrir (PDF)" = ic(:'folder-open')
= file_field_tag :returned_document = file_field_tag :returned_document
= submit_tag("Charger" , class:"btn btn-primary") %button.btn.btn-xs.upload-file{type: :submit, title: "Valider le document"}
-else = ic(:check)
=link_to i(:"download"),download_returned_public_accepted_offer_document_path(@accepted_offer, document), class:"btn btn-sm btn-primary",title: "Télécharger le document"
-if !document.document_verified?
=link_to i(:"remove"),destroy_returned_public_accepted_offer_document_path(@accepted_offer, document), class:"btn btn-sm btn-danger", title: "Supprimer le fichier chargé", :data => {:confirm => 'Voulez-vous vraiment supprimer le fichier chargé ?'}
%td{style:"text-align:right"} -else
=link_to i(:"download"),download_returned_public_accepted_offer_document_path(@accepted_offer, document), class:"btn btn-xs btn-primary",title: "Télécharger le document"
-if !document.document_verified?
=link_to i(:"remove"),destroy_returned_public_accepted_offer_document_path(@accepted_offer, document), class:"btn btn-xs btn-danger", title: "Supprimer le fichier chargé", :data => {:confirm => 'Voulez-vous vraiment supprimer le fichier chargé ?'}
-else
= "Pas encore disponible"
%td{style:"text-align:right;vertical-align:middle"}
=document.human_state =document.human_state
:javascript
$(".upload-file").prop("disabled","disabled");
$(".btn-file input").change(function(){
$(this).parent().next(".upload-file").prop("disabled","");
$(this).parent().next(".upload-file").addClass("btn-success");
})

View File

@ -11,6 +11,8 @@
=f.hidden_field :step2 =f.hidden_field :step2
=f.input :tva_number, :label => "Numéro de TVA intra. :" =f.input :tva_number, :label => "Numéro de TVA intra. :"
=f.input :siret, :label => "Numéro de siret :" =f.input :siret, :label => "Numéro de siret :"
=f.input :capital, :label => "Capital :"
=f.input :role_signataire, :label => "Fonction du signataire :"
=render :partial => "public/my_account/address", :locals => {:f => f} =render :partial => "public/my_account/address", :locals => {:f => f}
=#%h2 Préférences concernant les envois de mail =#%h2 Préférences concernant les envois de mail

View File

@ -1,6 +1,14 @@
.white.padding.message-item .white.padding.message-item
%h4= i(:"user") + " " + message.customer.anonyme_nick -if message.customer
%h4
=message.customer.anonyme_nick
-elsif message.admin
%h4
="#{message.admin.fullname}"
%span{style:"color:red"}
="ADMINISTRATEUR"
%p.info=i(:"clock-o") + " Posté le #{message.created_at.strftime('%d/%m/%Y à %H:%M')}, il y a #{time_ago_in_words(message.created_at)}" %p.info=i(:"clock-o") + " Posté le #{message.created_at.strftime('%d/%m/%Y à %H:%M')}, il y a #{time_ago_in_words(message.created_at)}"
%p= message.content %p= message.content

View File

@ -114,7 +114,7 @@
-if offer.need.customers.include?(current_customer) -if offer.need.customers.include?(current_customer)
-if !offer.customers.include?(current_customer) -if !offer.customers.include?(current_customer)
.accept-offer .accept-offer
=link_to i(:"check") + " Accepter l'offre", accept_public_need_offer_path(@need, offer), data: {confirm: "Voulez-vous vraiment accepter cette offre ? Attention, cette action vous engage à payer la somme proposée."}, class: "btn btn-lg btn-success " =link_to i(:"check") + " J'accepte l'offre et je retourne le mandat signé", accept_public_need_offer_path(@need, offer), data: {confirm: "Pour que loffre soit validée veuillez retourné le mandat signé que vous allez recevoir"}, class: "btn btn-lg btn-success "
-else -else
.offer-accepted .offer-accepted
=i(:"check") + " Offre Acceptée" =i(:"check") + " Offre Acceptée"

View File

@ -0,0 +1,6 @@
class AddSomeExtraFields < ActiveRecord::Migration
def change
add_column :customers, :capital,:float
add_column :customers, :role_signataire,:string
end
end

View File

@ -0,0 +1,5 @@
class AddAdminToMessage < ActiveRecord::Migration
def change
add_reference :messages, :admin, 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: 20160926090902) do ActiveRecord::Schema.define(version: 20161018122307) 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
@ -225,6 +225,8 @@ ActiveRecord::Schema.define(version: 20160926090902) do
t.float "longitude", limit: 24 t.float "longitude", limit: 24
t.datetime "last_activity" t.datetime "last_activity"
t.text "particulars_text", limit: 65535 t.text "particulars_text", limit: 65535
t.float "capital", limit: 24
t.string "role_signataire", limit: 255
end end
create_table "data_files", force: :cascade do |t| create_table "data_files", force: :cascade do |t|
@ -468,8 +470,11 @@ ActiveRecord::Schema.define(version: 20160926090902) do
t.integer "customer_id", limit: 4 t.integer "customer_id", limit: 4
t.integer "need_id", limit: 4 t.integer "need_id", limit: 4
t.text "content", limit: 65535 t.text "content", limit: 65535
t.integer "admin_id", limit: 4
end end
add_index "messages", ["admin_id"], name: "index_messages_on_admin_id", using: :btree
create_table "need_categories", force: :cascade do |t| create_table "need_categories", force: :cascade do |t|
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false