negos_app/app/views/public/needs/show.html.haml
2018-09-21 12:01:08 +02:00

196 lines
8.2 KiB
Plaintext
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

.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é
.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 @need.category
%p.info=i(:"tag") + " " + @need.category_path
-else
%p.info=i(:"tag") + " Non catégorisé"
.description
=simple_format @need.description
-if @need.image_file
%img{src: @need.image_file.file.url}
%br
%br
-if @need.verified?
-if @need.customers.include?(current_customer)
.alert.alert-success
%h3= i(:"check") + ' Vous êtes intéressé par ce besoin'
%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
.alert.alert-info
%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 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 Une fois la négociation terminée, vous serez libre d'accepter ou non l'offre.
-elsif @need.negociating?
-if @need.customers.include?(current_customer)
.alert.alert-warning
%h3 Négociation en cours...
%p Ce besoin a suscité un interêt suffisant pour que nous engagions une négociation auprès des fournisseurs.
%p Une fois la négociation terminée, vous serez libre daccepter ou non loffre proposée.
%p <strong>Afin den bénéficier, merci de nous retourner au plus vite le mandat signé</strong>
-else
.alert.alert-warning
%h3 Négociation en cours...
%p Ce besoin a suscité un interêt suffisant pour que nous engagions une négociation auprès des fournisseurs.
.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.
-elsif @need.negociated?
-if @need.customers.include?(current_customer)
.alert.alert-success
%h3 Négociation terminée
%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 l'offre.
%p <strong>Une fois l'offre acceptée, vous devrez nous retourner au plus vite le mandat signé</strong>
-else
.alert.alert-success
%h3 Négociation terminée
%p= "Nous avons négocié ce besoin au prix de revient de #{number_to_currency(offers.first.price, locale: :fr)}"
.alert.alert-danger
%p= "Malheureusement, vous n'avez pas marqué votre interêt pour ce besoin pendant la période de sondage, vous ne pouvez donc pas profiter de cette négociation."
-elsif @need.failed?
.alert.alert-danger
%h3 Négociation échouée
%p= "Désolé, nous n'avons pas été en mesure de négocier un prix acceptable pour ce besoin."
.clear
.counters
-if(@need.wishes.length > 0)
.item=i(:"hand-paper-o") + " " + " #{pluralize(@need.wishes.length, 'utilisateur')} #{"intéressé".pluralize(@need.wishes.length)} par ce besoin"
-else
.item=i(:"hand-paper-o") + " Aucun utilisateur n'est intéressé par ce besoin"
%p
.item
Quantité :
.clock{:style => "margin:2em;"}
<script type="text/javascript">
=raw "var clock_max = #{@need.wishes.sum(:qte)};"
</script>
:javascript
var countup;
var clock = $('.clock').FlipClock(0, {
clockFace: 'Counter',
minimumDigits: 1,
callbacks:{
init:function (){
}
}
});
if(clock_max > 0){
countup = setInterval(function() {
clock.increment();
if(clock.getTime().time >= clock_max) {
clock.stop();
clearInterval(countup);
}
}, 0);}
-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"
-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"
%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
-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"
-elsif @need.negociating?
-elsif @need.negociated?
-if @need.offers.length > 0
%h2= i(:"gift") + " Les offres négociées"
-@need.offers.each do |offer|
.offer
.price
=number_to_currency(offer.price, locale: :fr)
-if offer.need.customers.include?(current_customer)
-if !offer.customers.include?(current_customer)
.accept-offer
=link_to i(:"check") + " J'accepte l'offre et je retourne le mandat signé", accept_public_need_offer_path(@need, offer), class: "btn btn-lg btn-success "
-else
.offer-accepted
=i(:"check") + " Offre Acceptée"
.my-account-link
Vous devez maintenant nous retourner le mandat signé, rendez-vous rubrique
=link_to "Mon compte", public_my_account_path
pour gérer vos offres acceptées.
-else
.offer-not-aceptable
Offre non disponible
.clear
%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;"}
=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"
=render collection: @comments, partial: 'message'
.pagination= paginate @comments