diff --git a/app/assets/stylesheets/public.scss b/app/assets/stylesheets/public.scss index dbf3bab..8d4c5af 100755 --- a/app/assets/stylesheets/public.scss +++ b/app/assets/stylesheets/public.scss @@ -1158,4 +1158,10 @@ height: 100%; } +} + +.center{ + padding:0 20px; + margin:auto; + } \ No newline at end of file diff --git a/app/controllers/public/needs_controller.rb b/app/controllers/public/needs_controller.rb index f5d0651..1f76345 100755 --- a/app/controllers/public/needs_controller.rb +++ b/app/controllers/public/needs_controller.rb @@ -10,9 +10,16 @@ class Public::NeedsController < ApplicationController before_filter :check_owner, only: [:destroy,:edit,:update] def index + params[:type] = params[:type] || 1 + + params[:type] = params[:type].to_i + session[:reseaux_id] = nil if params[:no_reseaux] # Get only public needs @needs = Need.shared + + @needs = @needs.where(:need_type => params[:type]) + if session[:reseaux_id].to_i > 0 @needs = @needs.where(:reseaux_id => session[:reseaux_id]) else @@ -78,7 +85,9 @@ class Public::NeedsController < ApplicationController def download_devis @need = Need.find(params[:need_id]) - + + params[:type] = @need.need_type + if @need.author.id != current_customer.id flash[:error] = "Vous n'êtes pas le propriétaire" return redirect_to :back @@ -90,6 +99,7 @@ class Public::NeedsController < ApplicationController def new @need = Need.new() + end def destroy @@ -102,10 +112,12 @@ class Public::NeedsController < ApplicationController def edit @need = Need.find(params[:id]) + end def show @need = Need.find(params[:id]) + params[:type] = @need.need_type @comment = Message.new() @comments = @need.messages.order(created_at: :desc).page params[:page] end @@ -122,6 +134,7 @@ class Public::NeedsController < ApplicationController def create @need = Need.new(need_params) + params[:type] = @need.need_type @need.reseaux_id = session[:reseaux_id] @need.author = current_customer @@ -151,6 +164,7 @@ class Public::NeedsController < ApplicationController def wish @need = Need.find(params[:id]) + params[:type] = @need.need_type admins = Admin.where.not(email: nil) if (!@need.customers.include?(current_customer)) @need.customers << current_customer diff --git a/app/views/admin/needs/_form.html.haml b/app/views/admin/needs/_form.html.haml index 750a4e0..0e00703 100755 --- a/app/views/admin/needs/_form.html.haml +++ b/app/views/admin/needs/_form.html.haml @@ -6,6 +6,7 @@ =f.inputs do + =f.input :need_type, :label => "Type :", :collection => [["Besoin spécifique", 1],["Centrale d'achat", 2]], :as => :select, :include_blank => false =f.input :reseaux_id, :label => "Réseau :", :collection => Reseaux.where(:parent_id => nil).all, :as => :select, :include_blank => false =f.input :title, :label => "Titre : " diff --git a/app/views/public/my_account/my_reseauxes.html.haml b/app/views/public/my_account/my_reseauxes.html.haml index a762502..3b261e8 100644 --- a/app/views/public/my_account/my_reseauxes.html.haml +++ b/app/views/public/my_account/my_reseauxes.html.haml @@ -12,12 +12,13 @@ %br Choissisez le réseaux sur lequel vous souhaitez vous connecter : .reseauxes_home - =link_to public_needs_path(:no_reseaux => true), :class => "reseauxes" do - .arrow - =ic :"angle-right" - Plateforme Négos - %span - Vous choisissez, nous négocions ! + -if false + =link_to public_needs_path(:no_reseaux => true), :class => "reseauxes" do + .arrow + =ic :"angle-right" + Plateforme Négos + %span + Vous choisissez, nous négocions ! -current_customer.reseauxes.where(:parent_id => nil).each do |reseaux| =link_to public_reseaux_products_path(:reseaux_id => reseaux.id), :class => "reseauxes" do .arrow diff --git a/app/views/public/needs/_need_item.html.haml b/app/views/public/needs/_need_item.html.haml index 5dcd1df..80b0e75 100755 --- a/app/views/public/needs/_need_item.html.haml +++ b/app/views/public/needs/_need_item.html.haml @@ -19,26 +19,27 @@ =i(:"tag") + " " + need.category.name -else Non catégorisé - -if need.verified? - %span.state.state-info.pull-right - =need.human_state - -elsif need.negociating? - %span.state.state-warning.pull-right - =need.human_state - -elsif need.failed? - %span.state.state-danger.pull-right - =need.human_state - -elsif need.negociated? - %span.state.state-success.pull-right - -offers = need.offers.order(price: :asc) - -if offers.size > 1 - Négocié à partir de - %strong="#{number_to_currency(offers.first.price, locale: :fr)}" - -elsif offers.size == 1 - Négocié à - %strong="#{number_to_currency(offers.first.price, locale: :fr)}" - -else - Négocié + -if params[:type].to_i == 1 + -if need.verified? + %span.state.state-info.pull-right + =need.human_state + -elsif need.negociating? + %span.state.state-warning.pull-right + =need.human_state + -elsif need.failed? + %span.state.state-danger.pull-right + =need.human_state + -elsif need.negociated? + %span.state.state-success.pull-right + -offers = need.offers.order(price: :asc) + -if offers.size > 1 + Négocié à partir de + %strong="#{number_to_currency(offers.first.price, locale: :fr)}" + -elsif offers.size == 1 + Négocié à + %strong="#{number_to_currency(offers.first.price, locale: :fr)}" + -else + Négocié @@ -46,9 +47,10 @@ %p.description=need.description - .counters - .item=i(:"hand-paper-o") + " " + need.wishes.length.to_s - .item=i(:"comment-o") + " " + need.messages.length.to_s + -if params[:type].to_i == 1 + .counters + .item=i(:"hand-paper-o") + " " + need.wishes.length.to_s + .item=i(:"comment-o") + " " + need.messages.length.to_s -if !@read_only -if(need.verified?) - @wish = need.wishes.where(need_id: need.id, customer_id: current_customer.id).first diff --git a/app/views/public/needs/index.html.haml b/app/views/public/needs/index.html.haml index 923e949..09c32db 100755 --- a/app/views/public/needs/index.html.haml +++ b/app/views/public/needs/index.html.haml @@ -11,8 +11,9 @@ .row.col-md-3 .white.side-menu - =link_to "Proposer un nouveau besoin", new_public_need_path,style:'display:block', class: 'btn btn-primary' - %br + -if params[:type].to_i == 1 + =link_to "Proposer un nouveau besoin", new_public_need_path,style:'display:block', class: 'btn btn-primary' + %br = semantic_form_for :search, :html => {id: :search_form, :method => :get } do |f| = f.inputs do =f.input :q, :as => :search, label: "Recherche", input_html: {value: params[:q], :name => 'q' }, placeholder: "Rechercher un besoin" diff --git a/app/views/public/needs/show.html.haml b/app/views/public/needs/show.html.haml index 3ef90b8..573f496 100755 --- a/app/views/public/needs/show.html.haml +++ b/app/views/public/needs/show.html.haml @@ -1,35 +1,37 @@ .center.white.show-need .top-left-info - -if @need.verified? - %span.state.state-info.pull-right - =@need.human_state - -elsif @need.negociating? - %span.state.state-warning.pull-right - =@need.human_state - -elsif @need.failed? - %span.state.state-danger.pull-right - =@need.human_state - -elsif @need.negociated? - %span.state.state-success.pull-right - -offers = @need.offers.order(price: :asc) - -if offers.size > 1 - Négocié à partir de - %strong="#{number_to_currency(offers.first.price, locale: :fr)}" - -elsif offers.size == 1 - Négocié à - %strong="#{number_to_currency(offers.first.price, locale: :fr)}" - -else - Négocié + -if params[:type].to_i == 1 + -if @need.verified? + %span.state.state-info.pull-right + =@need.human_state + -elsif @need.negociating? + %span.state.state-warning.pull-right + =@need.human_state + -elsif @need.failed? + %span.state.state-danger.pull-right + =@need.human_state + -elsif @need.negociated? + %span.state.state-success.pull-right + -offers = @need.offers.order(price: :asc) + -if offers.size > 1 + Négocié à partir de + %strong="#{number_to_currency(offers.first.price, locale: :fr)}" + -elsif offers.size == 1 + Négocié à + %strong="#{number_to_currency(offers.first.price, locale: :fr)}" + -else + Négocié .content %h1= @need.title.upcase - -if @need.author - %p.info - =i(:"clock-o") + " Proposé par " - %strong=@need.author.anonyme_nick - ="il y a #{time_ago_in_words(@need.created_at)}" - -else - %p.info=i(:"clock-o") + " Ajouté il y a #{time_ago_in_words(@need.created_at)}" + -if params[:type].to_i == 1 + -if @need.author + %p.info + =i(:"clock-o") + " Proposé par " + %strong=@need.author.anonyme_nick + ="il y a #{time_ago_in_words(@need.created_at)}" + -else + %p.info=i(:"clock-o") + " Ajouté il y a #{time_ago_in_words(@need.created_at)}" -if @need.category @@ -127,17 +129,17 @@ -if @need.verified? - @wish = @need.wishes.where(need_id: @need.id, customer_id: current_customer.id).first -if(@wish) - =link_to i(:"check") + " Intéressé", edit_public_need_wish_path(@need, @wish) , :class => "btn btn-square btn-lg btn-success pull-right" + =link_to i(:"check") + " Intéressé - Client", edit_public_need_wish_path(@need, @wish) , :class => "btn btn-square btn-lg btn-success pull-right" -else - =link_to i(:"hand-paper-o") + " Ça m'intéresse !", new_public_need_wish_path(@need) , :class => "btn btn-square btn-lg btn-primary pull-right" + =link_to i(:"hand-paper-o") + " Ça m'intéresse ! - Client", new_public_need_wish_path(@need) , :class => "btn btn-square btn-lg btn-primary pull-right" %br %br %br - @wish_furbish = @need.need_furbish_interests.where(customer_id: current_customer.id).first -if @wish_furbish - =link_to i(:"check") + " Interessé en tant que fournisseur", public_need_furbish_interest_path(@wish_furbish) , :class => "btn btn-square btn-lg btn-success pull-right", :method => :delete + =link_to i(:"check") + " Interessé - Fournisseur", public_need_furbish_interest_path(@wish_furbish) , :class => "btn btn-square btn-lg btn-success pull-right", :method => :delete -else - =link_to i(:"hand-paper-o") + " Ça m'intéresse en tant que fournisseur !", new_public_need_furbish_interest_path(:need_id => @need.id) , :class => "btn btn-square btn-lg btn-primary pull-right" + =link_to i(:"hand-paper-o") + " Ça m'intéresse ! - Fournisseur", new_public_need_furbish_interest_path(:need_id => @need.id) , :class => "btn btn-square btn-lg btn-primary pull-right" -elsif @need.negociating? @@ -169,27 +171,29 @@ .clear + %br - %hr - %h2= i(:"comments") + " Fil de discussion" - = semantic_form_for [:public, @need, @comment ], :html => {id: :message_form, :method => :post } do |f| + -if params[:type].to_i == 1 + %hr + %h2= i(:"comments") + " Fil de discussion" + = semantic_form_for [:public, @need, @comment ], :html => {id: :message_form, :method => :post } do |f| - -if(@need.customers.include?(current_customer)) - %h4 Écrire un nouveau message - = f.inputs do - = f.input :content, as: :text, label: false, rows: 5, :input_html => {:style => "height:100px;"} + -if(@need.customers.include?(current_customer)) + %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" - -else - .alert.alert-danger - %p= "L'envoi de message est ouvert seulement aux personnes intéressés par le besoin" - .clear + =f.submit "Envoyer", :class => "btn btn-square btn-primary pull-right" + -else + .alert.alert-danger + %p= "L'envoi de message est ouvert seulement aux personnes intéressés par le besoin" + .clear - %h4= " #{pluralize(@need.messages.count, 'Message')} actuellement" + %h4= " #{pluralize(@need.messages.count, 'Message')} actuellement" - =render collection: @comments, partial: 'message' + =render collection: @comments, partial: 'message' - .pagination= paginate @comments + .pagination= paginate @comments diff --git a/app/views/public/shared/_menu.html.haml b/app/views/public/shared/_menu.html.haml index c1d0f57..eb545bf 100755 --- a/app/views/public/shared/_menu.html.haml +++ b/app/views/public/shared/_menu.html.haml @@ -6,11 +6,18 @@ -if !@my_reseauxes -if current_customer.account_validated? %li=link_to ic(:home)+" Accueil", public_my_reseauxes_path, :class => "btn" - -if !@reseaux - %li=link_to ic(:"youtube-play")+" Présentation Négos","", :class => "btn negos-video" - -if current_customer.account_validated? - %li=link_to ic(:star)+" Besoins", public_needs_path, :class => "btn" + -if false + -if !@reseaux + %li=link_to ic(:"youtube-play")+" Présentation Négos","", :class => "btn negos-video" + -if current_customer.account_validated? + %li=link_to ic(:star)+" Besoins", public_needs_path, :class => "btn" + + + + - unread_message = ContactMessage.where(contact_id: current_customer.id, read_by_customer: false).count + + %li=link_to ic(:comment)+" Nous contacter" + (unread_message > 0 ? " (#{unread_message})" : ""), public_contact_messages_path, :class => "btn" %li=link_to ic(:user)+" Mon compte", public_my_account_path, :class => "btn" diff --git a/app/views/public/shared/_sub_menu.html.haml b/app/views/public/shared/_sub_menu.html.haml index d2df122..c287ecf 100644 --- a/app/views/public/shared/_sub_menu.html.haml +++ b/app/views/public/shared/_sub_menu.html.haml @@ -3,10 +3,11 @@ .center -if current_customer.account_validated? - =link_to "Besoins", public_needs_path, :class => ("active" if @needs) + =link_to "Besoins spécifiques", public_needs_path(:type => 1), :class => ("active" if @needs and params[:type].to_i == 1) + =link_to "Centrale d'achat", public_needs_path(:type => 2), :class => ("active" if @needs and params[:type].to_i == 2) -if session[:reseaux_id].to_i > 0 - =link_to "Offres", public_reseaux_products_path(:reseaux_id => session[:reseaux_id].to_i), :class => ("active" if @products or @product) + =link_to "Offres exclusives", public_reseaux_products_path(:reseaux_id => session[:reseaux_id].to_i), :class => ("active" if @products or @product) .clear diff --git a/db/migrate/20181016180809_add_need_type_to_needs.rb b/db/migrate/20181016180809_add_need_type_to_needs.rb new file mode 100644 index 0000000..96be006 --- /dev/null +++ b/db/migrate/20181016180809_add_need_type_to_needs.rb @@ -0,0 +1,5 @@ +class AddNeedTypeToNeeds < ActiveRecord::Migration + def change + add_column :needs, :need_type, :integer, :default => 1 + end +end diff --git a/db/schema.rb b/db/schema.rb index 2ef3b8d..7cf1936 100755 --- a/db/schema.rb +++ b/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: 20180921093741) do +ActiveRecord::Schema.define(version: 20181016180809) do create_table "abonnements", force: :cascade do |t| t.integer "abonnement_type_id", limit: 4 @@ -567,8 +567,8 @@ ActiveRecord::Schema.define(version: 20180921093741) do create_table "needs", force: :cascade do |t| t.string "title", limit: 255 t.text "description", limit: 65535 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "author_id", limit: 4 t.datetime "deleted_at" t.string "state", limit: 255 @@ -579,6 +579,7 @@ ActiveRecord::Schema.define(version: 20180921093741) do t.integer "referent_negos_id", limit: 4 t.integer "referent_technique_id", limit: 4 t.integer "reseaux_id", limit: 4 + t.integer "need_type", limit: 4, default: 1 end add_index "needs", ["author_id"], name: "index_needs_on_author_id", using: :btree