diff --git a/app/assets/stylesheets/public.scss b/app/assets/stylesheets/public.scss index bd69ca5..16091e6 100755 --- a/app/assets/stylesheets/public.scss +++ b/app/assets/stylesheets/public.scss @@ -245,7 +245,7 @@ position:relative; } -.annonce_message_li{ +.customer_message_li{ &.active, &:hover{ background:#3677AF; color:white; @@ -293,7 +293,7 @@ position:relative; border-bottom:1px solid gray; } -.annonce_message_show{ +.customer_message_show{ background:white;min-height:600px; padding-top:10px; padding-bottom:10px; @@ -698,3 +698,237 @@ height: 100%; max-width: 100%; } + + +.customer_message_li{ + &.active, &:hover{ + background:#3677AF; + color:white; + text-decoration:none; + border-color:transparent; + .time{ + color:white; + + } + } + display:block; + text-align:left; + padding:10px 10px; + color:#454340; + + img{ + float:left; + border-radius:50%; + height:60px; + margin-right:5px; + + } + .new{ + + display:inline-block; + width:10px; + height:10px; + background:#3677AF; + border-radius:50%; + } + .pseudo{ + + font-weight:600; + margin-bottom:10px; + + } + .time{ + font-size:0.7em; + color:rgba(120,118,115,1); + float:right; + margin-left:10px; + + } + border-radius:0; + border-bottom:1px solid gray; + +} + +.message_avertissement{ + padding:10px; + h3{ + margin-top:0; + } + background-color: #fcf8e3; + border-top: 1px solid #faebcc; + color: #8a6d3b; +} + + +.customer_message_show_container{ + padding:0 !important; + background:white; + border:1px solid #ddd; + border-radius:3px; + .speak_with{ + padding:10px; + line-height:60px; + background-color: #f5f5f5; + border-bottom: 1px solid #ddd; + img{ + float:left; + border-radius:50%; + height:60px; + margin-right:5px; + + } + } + +} +.customer_message_list{ + padding:0; + padding-right:5px; +} +.customer_message_show{ + + + .customer_message_container{ + + padding:10px; + margin-bottom:20px; + .side{ + float:left; + width:150px; + text-align:center; + position:relative; + .square{ + position:absolute; + background-color: #f5f5f5; + top:16px; + width:12px; + height:12px; + right:-6px; + transform: rotate(45deg); + + } + img{ + + border-radius:50%; + height:60px; + + + } + .pseudo{ + + font-weight:600; + margin-bottom:10px; + + } + .time{ + font-size:0.7em; + color:rgba(120,118,115,1); + + + } + + + } + .content{ + background-color: #f5f5f5; + padding:15px; + margin-left:150px; + min-height:150px; + border-radius:10px; + margin-right:80px; + + } + .ip_country{ + font-size:0.8em; + margin-left:150px; + margin-right:80px; + padding-top:5px; + } + + &.me{ + + .ip_country{ + font-size:0.8em; + margin-right:150px; + margin-left:80px; + } + + .side{ + .square{ + right:auto; + left:-6px; + + } + + + float:right; + } + + .content{ + margin-left:80px; + margin-right:150px; + + } + + + } + + &.desactivated{ + + .side{ + .square{ + background-color: #fcf8e3; + + } + + + + } + + .content{ + background-color: #fcf8e3; + color: #8a6d3b; + h3{ + margin-top:0; + } + + } + + + } + } + .message_annonce{ + + background:rgba(252,248,228,0.5); + padding:10px; + margin-bottom:10px; + a{ + //color:white; + + } + + } +} + + +@media screen and (max-width:740px) { + .customer_message_show{ + + .customer_message_container{ + + .content{ + margin-right:0px; + + } + + &.me{ + .content{ + margin-left:0px; + + } + + } + + } + } + +} diff --git a/app/controllers/admin/offers_controller.rb b/app/controllers/admin/offers_controller.rb index a213ece..d887937 100755 --- a/app/controllers/admin/offers_controller.rb +++ b/app/controllers/admin/offers_controller.rb @@ -229,7 +229,7 @@ class Admin::OffersController < ApplicationController private def offer_params - params.require(:offer).permit(:supplier, :price, :fee_percentage) + params.require(:offer).permit! #(:supplier, :price, :fee_percentage, :reseaux_ids, :gain) end end diff --git a/app/controllers/admin/reseauxes_controller.rb b/app/controllers/admin/reseauxes_controller.rb new file mode 100755 index 0000000..a5135e2 --- /dev/null +++ b/app/controllers/admin/reseauxes_controller.rb @@ -0,0 +1,64 @@ +class Admin::ReseauxesController < ApplicationController + layout "admin" + + + def index + @reseauxes = Reseaux.order(:name) + end + + def new + @reseaux = Reseaux.new() + + end + + def create + @reseaux = Reseaux.new(reseaux_params) + + if @reseaux.save + flash[:notice] = "Catégorie créée avec succès." + redirect_to admin_reseauxes_path + else + + render "new" + end + end + + def edit + @reseaux = Reseaux.find(params[:id]) + + end + + def show + @reseaux = Reseaux.find(params[:id]) + + end + + def update + @reseaux = Reseaux.find(params[:id]) + if @reseaux.update_attributes(reseaux_params) + flash[:notice] = "Catégorie modifiée avec succès." + redirect_to admin_reseauxes_path + else + + render :action => "edit" + end + end + + def destroy + @reseaux = Reseaux.find(params[:id]) + if !@reseaux.superadmin and @reseaux.destroy + flash[:notice] = "Reseauxe supprimée avec succès." + else + flash[:error] = "Impossible de supprimer ce reseauxe." + end + + redirect_to :action => :index + end + + def reseaux_params + params.require(:reseaux).permit! + end + + + +end diff --git a/app/controllers/public/customer_messages_controller.rb b/app/controllers/public/customer_messages_controller.rb new file mode 100644 index 0000000..3151bce --- /dev/null +++ b/app/controllers/public/customer_messages_controller.rb @@ -0,0 +1,124 @@ +class Public::CustomerMessagesController < ApplicationController + layout "public" + + before_filter :auth_customer + + def index + + @no_search = true + + + + @customer_messages = CustomerMessage.where("destinataire_id = ? or expediteur_id = ?",current_customer.id, current_customer.id).where("parent_id is null") + + @customer_messages = @customer_messages.order("last_message_at DESC, created_at DESC").all + + + + + end + + + def show + @customer_message = CustomerMessage.where("destinataire_id = ? or expediteur_id = ?",current_customer.id, current_customer.id).find(params[:id]) + @customer_message.readed = true + @customer_message.save + end + + def answer + @parent_customer_message = CustomerMessage.where("destinataire_id = ? or expediteur_id = ?",current_customer.id, current_customer.id).find(params[:id]) + @customer_message = CustomerMessage.new() + @customer_message.expediteur = current_customer + @customer_message.destinataire = @parent_customer_message.expediteur + end + + def answer_save + + @parent_customer_message = CustomerMessage.where("destinataire_id = ? or expediteur_id = ?",current_customer.id, current_customer.id).find(params[:id]) + @customer_message = CustomerMessage.new(params.require(:customer_message).permit!) + @customer_message.expediteur = current_customer + if @parent_customer_message.expediteur == current_customer + @customer_message.destinataire = @parent_customer_message.destinataire + else + @customer_message.destinataire = @parent_customer_message.expediteur + end + @customer_message.parent_id = @parent_customer_message.id + + if @customer_message.save + @parent_customer_message.last_message_at = Time.now + @parent_customer_message.save + + else + render :action => :answer + end + + + end + + + def new + + end + + def edit + + end + + + + def create + @customer_message = CustomerMessage.new(params.require(:customer_message).permit!) + @customer_message.expediteur = current_customer if current_customer + @customer_message.remote_ip = request.remote_ip + @customer_message.last_message_at = Time.now + + if @customer_message.save + redirect_to public_customer_messages_path + end + end + + + def update + @annonce = current_customer.annonces.find(params[:id]) + + + + + respond_to do |format| + if @annonce.update_attributes(params.require(:annonce).permit!) + + + + format.html { + redirect_to public_my_account_path + } + format.js + + else + + format.html { render :action => "edit" } + format.js { "" } + end + end + + + + end + + + + def destroy + + #@annonce = current_customer.annonces.find(params[:id]) + #@annonce.enabled = nil + #@annonce.save + + #redirect_to public_my_account_path, :notice => "Votre annonce a bien été désactivée" + + + + end + + + +end diff --git a/app/controllers/public/customers_controller.rb b/app/controllers/public/customers_controller.rb index 180b7f6..771e337 100755 --- a/app/controllers/public/customers_controller.rb +++ b/app/controllers/public/customers_controller.rb @@ -16,11 +16,7 @@ class Public::CustomersController < ApplicationController def show - per_page = (params[:per_page] and params[:per_page] != "") ? params[:per_page] : 10 - page = (params[:page] and params[:page] != "") ? params[:page] : 1 - - @customer = Customer.find(params[:id]) - @annonces = @customer.annonces.valid_to_show.order("list_head DESC, created_at DESC").page(page).per(per_page).all + @customer = current_customer.own_customers.find(params[:id]) end @@ -142,22 +138,22 @@ class Public::CustomersController < ApplicationController + def mail - @customer = Customer.find(params[:id]) - @annonce_message = AnnonceMessage.new(:destinataire => @customer) - if params[:annonce_id] and @annonce = @customer.annonces.where(:id => params[:annonce_id]).first - - @annonce_message.annonce = @annonce - + @no_search = true + @customer = Customer.find_by_id(params[:id]) + + if @customer + @customer_message = CustomerMessage.new(:destinataire => @customer) + + + @customer_message.expediteur = current_customer if current_customer + if @customer_message.expediteur + @customer_message.expediteur_mail = current_customer.email + end end - - @annonce_message.expediteur = current_customer if current_customer - if @annonce_message.expediteur - @annonce_message.expediteur_mail = current_customer.email - @annonce_message.tel = current_customer.tel_number - end - + end diff --git a/app/controllers/public/offers_controller.rb b/app/controllers/public/offers_controller.rb index 69ade48..bbb9014 100755 --- a/app/controllers/public/offers_controller.rb +++ b/app/controllers/public/offers_controller.rb @@ -11,6 +11,16 @@ class Public::OffersController < ApplicationController return redirect_back_or_default :root end @accepted_offer = AcceptedOffer.new + @accepted_offer.offer = @offer + + end + + def accept_save + if @offer.customers.include?(current_customer) + flash[:error] = "Vous avez déjà accepter cette offre" + return redirect_back_or_default :root + end + @accepted_offer = AcceptedOffer.new(params.require(:accepted_offer).permit(:qte)) @accepted_offer.customer = current_customer @accepted_offer.offer = @offer @@ -30,9 +40,12 @@ class Public::OffersController < ApplicationController - redirect_back_or_default :root + redirect_to public_need_path(@need) + else + render :action => :accept end end + def get_need @need = Need.find(params[:need_id]) diff --git a/app/controllers/public/reseauxes_controller.rb b/app/controllers/public/reseauxes_controller.rb new file mode 100755 index 0000000..b9c27b1 --- /dev/null +++ b/app/controllers/public/reseauxes_controller.rb @@ -0,0 +1,18 @@ +class Public::ReseauxesController < ApplicationController + layout "public" + + + def index + @reseauxes = current_customer.own_reseauxes.order(:name) + if @reseauxes.count == 1 + redirect_to public_reseaux_path(@reseauxes.first) + end + end + + def show + @reseaux = current_customer.own_reseauxes.find(params[:id]) + + end + + +end diff --git a/app/controllers/public/wishes_controller.rb b/app/controllers/public/wishes_controller.rb index e77edcb..7851898 100644 --- a/app/controllers/public/wishes_controller.rb +++ b/app/controllers/public/wishes_controller.rb @@ -5,7 +5,7 @@ class Public::WishesController < ApplicationController before_filter :check_enabled def new - @wish = Wish.new + @wish = Wish.new(:qte => 1) @need = Need.find(params[:need_id]) @wish.need = @need end @@ -92,7 +92,7 @@ class Public::WishesController < ApplicationController def wishes_params - params.require(:wish).permit(:devis, :note, :need_id) + params.require(:wish).permit(:devis, :note, :need_id, :qte) end end diff --git a/app/models/accepted_offer.rb b/app/models/accepted_offer.rb index a40bb60..d6a9807 100755 --- a/app/models/accepted_offer.rb +++ b/app/models/accepted_offer.rb @@ -34,4 +34,8 @@ class AcceptedOffer < ActiveRecord::Base "Documents retournés et vérifiés" end end + + def total + self.offer.price * qte + end end diff --git a/app/models/binary_point.rb b/app/models/binary_point.rb deleted file mode 100755 index 7024d4a..0000000 --- a/app/models/binary_point.rb +++ /dev/null @@ -1,22 +0,0 @@ -class BinaryPoint < ActiveRecord::Base - belongs_to :customer - belongs_to :order - - - scope :left, lambda { - where(:side => 1) - } - - scope :right, lambda { - where(:side => 2) - } - - after_save do - if self.side == 1 - self.customer.update_left_binary_points - else - self.customer.update_right_binary_points - end - end - -end diff --git a/app/models/count_part_com.rb b/app/models/count_part_com.rb deleted file mode 100755 index e2dc522..0000000 --- a/app/models/count_part_com.rb +++ /dev/null @@ -1,43 +0,0 @@ -class CountPartCom < ActiveRecord::Base - - def self.last_paid - CountPartCom.where(:paid => true).order("last_day DESC").first - end - - def paid_now - if !self.paid - start = CountPartCom.last_paid.last_day.tomorrow.beginning_of_day - stop = self.last_day.end_of_day - - self.amount = Order.com_part_between(start, stop) - self.nbr_parts = Credit.parts_at(stop) - self.part_price = self.amount / self.nbr_parts - - control_i = 0.0 - - - Customer.all.each do |customer| - if customer.callif(stop) - puts "NOUVELLE COM" - puts "Parts" - puts customer.callif(stop)[3] - com = customer.callif(stop)[3] * self.part_price - puts "Com" - puts com - control_i = control_i + com - if com > 0.0 - customer.commissions.create :count_part_com => self, :amount => com, :commission_type_id => 3 - end - end - - end - self.paid = true - self.paid_at = Time.now - self.control_amount = control_i - - self.save - end - return self - end - -end diff --git a/app/models/credit.rb b/app/models/credit.rb deleted file mode 100755 index 4e1bd80..0000000 --- a/app/models/credit.rb +++ /dev/null @@ -1,33 +0,0 @@ -class Credit < ActiveRecord::Base - has_many :credit_expenses - has_one :credit_product, :through => :order - belongs_to :order, :foreign_key => :operation_id - scope :between, lambda { |start, stop| - where("(credits.created_at <= ? and credits.expire_after >= ?)", stop.end_of_day,start.beginning_of_day) - } - - scope :plus, lambda { - where(:cred => true) - } - - scope :moins, lambda { - where(:debt => true) - } - - scope :boughts, lambda { - includes(:order).where(:orders => {:paid => true}) - - } - - def solde - - self.value - self.credit_expenses.sum(:value) - - - end - - def self.parts_at(date) - Credit.between(date, date).includes(:order).where("orders.unpaid is null").sum("orders.nbr_parts") - end - -end diff --git a/app/models/credit_expense.rb b/app/models/credit_expense.rb deleted file mode 100755 index fcdde83..0000000 --- a/app/models/credit_expense.rb +++ /dev/null @@ -1,4 +0,0 @@ -class CreditExpense < ActiveRecord::Base - belongs_to :credit - belongs_to :expense -end diff --git a/app/models/credit_product.rb b/app/models/credit_product.rb deleted file mode 100755 index 9bb6e64..0000000 --- a/app/models/credit_product.rb +++ /dev/null @@ -1,30 +0,0 @@ -class CreditProduct < ActiveRecord::Base - - def price_ttc - self.price_ht * 1.2 - end - - - def price_ht_final(customer) - self.price_ht - customer.credits.between(Date.today, Date.today).boughts.sum("orders.price_ht") - end - - def price_ttc_final(customer) - self.price_ht_final(customer)* 1.2 - - end - - def nbr_credits_final(customer) - self.nbr_credits - customer.credits_boughts(Date.today) - end - - def binary_points_final(customer) - self.binary_points - customer.credits.between(Date.today, Date.today).boughts.sum("orders.binary_points") - end - - def nbr_parts_final(customer) - self.parts - customer.credits.between(Date.today, Date.today).boughts.sum("orders.nbr_parts") - end - -end - diff --git a/app/models/customer.rb b/app/models/customer.rb index 87959f8..92be9ff 100755 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -2,6 +2,16 @@ class Customer < ActiveRecord::Base has_many :domains, :through => :domain_customers has_many :domain_customers, :dependent => :destroy + + has_many :reseaux_customers + has_many :reseauxes, :through => :reseaux_customers + + has_many :own_reseauxes, :class_name => "Reseaux", :foreign_key => :chef_reseau_id + has_many :own_customers, :through => :own_reseauxes, :source => :customers + + + + scope :search, -> (search) { where('name LIKE ? OR firstname LIKE ? OR organisation LIKE ?', "%#{search}%", "%#{search}%", "%#{search}%") @@ -23,15 +33,12 @@ class Customer < ActiveRecord::Base has_many :customer_newsgroups has_many :newsgroups, :through => :customer_newsgroups - has_many :credits - has_many :expenses - has_many :credit_expenses - has_many :mlm_points + has_many :orders has_many :commissions has_many :virements - has_many :inbox_messages, :class_name => "AnnonceMessage", :foreign_key => :destinataire_id + has_many :inbox_messages, :class_name => "CustomerMessage", :foreign_key => :destinataire_id has_secure_password @@ -124,53 +131,13 @@ class Customer < ActiveRecord::Base end - def mlm_detail_ids - - i = 0 - - parents_id = [self.id] - - mlm_children_ids = [] - - mlm_children_id_by_levels = [] - - while i != 14 do - i += 1 - - - parents_id = Customer.where(:parent_id => parents_id).select(:id).map{ |v| v.id} - - mlm_children_id_by_levels[i] = parents_id - mlm_children_ids.concat parents_id - - - - end - - { - :mlm_children_id_by_levels => mlm_children_id_by_levels, - :mlm_children_ids => mlm_children_ids - } - - - end + def anonyme_nick "Utilisateur#{id}" end - def mlm_children_id_by_levels - self.mlm_detail_ids[:mlm_children_id_by_levels] - end - - def mlm_children_ids - self.mlm_detail_ids[:mlm_children_ids] - end - - def solde_commissions - self.commissions.sum(:amount) - end - + def max_virement self.commissions.sum(:amount).floor - 5.0 diff --git a/app/models/customer_message.rb b/app/models/customer_message.rb new file mode 100644 index 0000000..21a1533 --- /dev/null +++ b/app/models/customer_message.rb @@ -0,0 +1,13 @@ +class CustomerMessage < ActiveRecord::Base + belongs_to :need + belongs_to :expediteur, :class_name => "Customer" + belongs_to :destinataire, :class_name => "Customer" + + validates :message, :presence => true + acts_as_tree + + + def not_blocked + true + end +end diff --git a/app/models/need.rb b/app/models/need.rb index e591df0..29cf65b 100755 --- a/app/models/need.rb +++ b/app/models/need.rb @@ -2,6 +2,11 @@ class Need < ActiveRecord::Base include Workflow + + belongs_to :referent_technique, :class_name => "Customer" + belongs_to :referent_negos, :class_name => "Customer" + + has_many :domains, :through => :domain_needs has_many :domain_needs, :dependent => :destroy diff --git a/app/models/offer.rb b/app/models/offer.rb index b945ae2..ef9670f 100755 --- a/app/models/offer.rb +++ b/app/models/offer.rb @@ -9,5 +9,6 @@ class Offer < ActiveRecord::Base :presence => true, numericality: {greater_than_or_equal_to: 0} - + has_many :offer_reseauxes + has_many :reseauxes, :through => :offer_reseauxes end diff --git a/app/models/offer_reseaux.rb b/app/models/offer_reseaux.rb new file mode 100644 index 0000000..5dbe611 --- /dev/null +++ b/app/models/offer_reseaux.rb @@ -0,0 +1,4 @@ +class OfferReseaux < ActiveRecord::Base + belongs_to :offer + belongs_to :reseaux +end diff --git a/app/models/reseaux.rb b/app/models/reseaux.rb new file mode 100644 index 0000000..c10789c --- /dev/null +++ b/app/models/reseaux.rb @@ -0,0 +1,13 @@ +class Reseaux < ActiveRecord::Base + belongs_to :chef_reseau, :class_name => "Customer" + + has_many :reseaux_customers + has_many :customers, :through => :reseaux_customers + + has_many :needs, :through => :customers + + has_many :offer_reseauxes + has_many :offers, :through => :offer_reseauxes + + +end diff --git a/app/models/reseaux_customer.rb b/app/models/reseaux_customer.rb new file mode 100644 index 0000000..efb166f --- /dev/null +++ b/app/models/reseaux_customer.rb @@ -0,0 +1,4 @@ +class ReseauxCustomer < ActiveRecord::Base + belongs_to :reseaux + belongs_to :customer +end diff --git a/app/views/admin/customers/_form.html.haml b/app/views/admin/customers/_form.html.haml index ff8b43f..71a9bb1 100755 --- a/app/views/admin/customers/_form.html.haml +++ b/app/views/admin/customers/_form.html.haml @@ -6,7 +6,12 @@ =f.inputs do - =f.input :domains, :label => "Domaine : ", :collection => Domain.all, :as => :check_boxes + + .row.qi_cancel_margins + .col-sm-6 + =f.input :domains, :label => "Domaine : ", :collection => Domain.all, :as => :check_boxes + .col-sm-6 + =f.input :reseauxes, :label => "Réseaux : ", :collection => Reseaux.all, :as => :check_boxes =f.input :organisation, :label => "Société : " @@ -40,6 +45,7 @@ =f.input :newsgroups, :label => "Newsletters :", :collection => Newsgroup.all, :as => :check_boxes - + =f.input :referent, :label => "Possibilité d'être référent ?" + =f.input :chef_reseau, :label => "Possibilité d'être chef réseau ?" .actions= f.submit "Sauvegarder", :class => "btn btn-primary" diff --git a/app/views/admin/needs/_form.html.haml b/app/views/admin/needs/_form.html.haml index 9a237ec..5157bba 100755 --- a/app/views/admin/needs/_form.html.haml +++ b/app/views/admin/needs/_form.html.haml @@ -13,6 +13,11 @@ =f.input :author, :label => "Auteur", include_blank: "Administrateur" =f.input :domains, :label => "Domaine : ", :collection => Domain.all, :as => :check_boxes + + =f.input :referent_technique, :label => "Référent technique : ", :collection => Customer.where(:referent => true).pluck(Arel.sql("CONCAT(`firstname`, ' ', `name`)"), :id) + + =f.input :referent_negos, :label => "Référent négociation : ", :collection => Customer.where(:referent => true).pluck(Arel.sql("CONCAT(`firstname`, ' ', `name`)"), :id) + -#= f.input :note, :label => "Informations supplémentaires pour Négos (Si vous n'avez pas attaché de proposition, merci de préciser son prix dans ce champ)", :rows => 5, :input_html => {:style => "height:100px;"} .actions diff --git a/app/views/admin/offers/_form.html.haml b/app/views/admin/offers/_form.html.haml index 9218102..69d9dca 100755 --- a/app/views/admin/offers/_form.html.haml +++ b/app/views/admin/offers/_form.html.haml @@ -2,7 +2,13 @@ .content =f.inputs do - =f.input :supplier, :label => "Nom du fournisseur : " - =f.input :price, :label => "Prix négocié : " - + .row.qi_cancel_margins + .col-sm-6 + =f.input :supplier, :label => "Nom du fournisseur : " + =f.input :price, :label => "Prix négocié : " + =f.input :gain, :label => "Gain : " + .col-sm-6 + =f.input :reseauxes, :label => "Réseaux commissionnés : ", :collection => Reseaux.all, :as => :check_boxes + .clear + .actions= f.submit "Sauvegarder", :class => "btn btn-primary" diff --git a/app/views/admin/reseauxes/_form.html.haml b/app/views/admin/reseauxes/_form.html.haml new file mode 100755 index 0000000..4862479 --- /dev/null +++ b/app/views/admin/reseauxes/_form.html.haml @@ -0,0 +1,9 @@ +=semantic_form_for [:admin, @reseaux] do |f| + .content + + + =f.inputs do + =f.input :name, :label => "Nom du réseau : " + =f.input :chef_reseau, :label => "Chef réseau : ", :collection => Customer.where(:chef_reseau => true).pluck(Arel.sql("CONCAT(`firstname`, ' ', `name`)"), :id) + + .actions= f.submit "Sauvegarder", :class => "btn btn-primary" diff --git a/app/views/admin/reseauxes/_reseaux.html.haml b/app/views/admin/reseauxes/_reseaux.html.haml new file mode 100755 index 0000000..1152656 --- /dev/null +++ b/app/views/admin/reseauxes/_reseaux.html.haml @@ -0,0 +1,12 @@ + +%tr{:id => reseaux.id} + %td + = reseaux.name + %td + = reseaux.customers.count + + + %td.actions{:style => "width:150px;text-align:right"} + = link_to i(:"trash-o"), [:admin, reseaux], :data => {:confirm => 'Voulez-vous vraiment supprimer ce reseauxe ?'}, :method => :delete + = link_to i(:pencil), edit_admin_reseaux_path(reseaux) + = link_to i(:eye), admin_reseaux_path(reseaux) diff --git a/app/views/admin/reseauxes/edit.html.haml b/app/views/admin/reseauxes/edit.html.haml new file mode 100755 index 0000000..8291775 --- /dev/null +++ b/app/views/admin/reseauxes/edit.html.haml @@ -0,0 +1,2 @@ +%h1 Modifier un réseau +=render :partial => "form" diff --git a/app/views/admin/reseauxes/index.html.haml b/app/views/admin/reseauxes/index.html.haml new file mode 100755 index 0000000..7926082 --- /dev/null +++ b/app/views/admin/reseauxes/index.html.haml @@ -0,0 +1,16 @@ + +%table.table.admin_table.table-hover.table-striped + %thead.rows_header + + %tr + %th + Nom + %th Utilisateurs + %th{:style => "width:100px"} +   + + %tbody.rows + =render @reseauxes + +%br += link_to "Ajouter un reseaux", new_admin_reseaux_path, class:"btn btn-primary" diff --git a/app/views/admin/reseauxes/new.html.haml b/app/views/admin/reseauxes/new.html.haml new file mode 100755 index 0000000..19b253b --- /dev/null +++ b/app/views/admin/reseauxes/new.html.haml @@ -0,0 +1,2 @@ +%h1 Ajouter un réseau +=render :partial => "admin/reseauxes/form" diff --git a/app/views/admin/reseauxes/show.html.haml b/app/views/admin/reseauxes/show.html.haml new file mode 100644 index 0000000..2e578f0 --- /dev/null +++ b/app/views/admin/reseauxes/show.html.haml @@ -0,0 +1,62 @@ +-@read_only = true + +%h1 Détail d'un réseau +%h2=@reseaux.name + + +%h2 Membres du réseau + +%table.table.table-hover.table-striped.customer_table + %thead#customer_rows_header.rows_header + + %tr + %th + Société + %th + Nom + %th + Téléphone + %th + Ville + %th + Email confirmé ? + %th + Email + + + + %th{:style => "width:100px;text-align:right;"} +   + + + + + %tbody#customer_rows.rows + + =render @reseaux.customers + +%h2 Besoins + +%table.table.admin_table.table-hover.table-striped + %thead.rows_header + + %tr + %th + Titre + %th + Image? + %th + Catégorie + + %th{style: 'text-align:center' } + Commentaires/Intérêts + %th{style: 'text-align:center' } + Propositions + %th + Statut + %th{:style => "width:200px"} +   + + %tbody.rows + + =render @reseaux.needs \ No newline at end of file diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 0dcfe97..fa920b6 100755 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -56,8 +56,8 @@ %li=link_to content_tag(:span,unread_messages , style:"background-color:#D9534F", class: 'badge') + " Contacts", admin_conversations_path -else %li= link_to " Contacts", admin_conversations_path - %li= link_to " Moniteur d'activité", admin_connected_customers_path - + %li= link_to "Moniteur d'activité", admin_connected_customers_path + %li= link_to "Réseaux", admin_reseauxes_path %ul.nav.navbar-nav.navbar-right %li.dropdown diff --git a/app/views/public/customer_messages/_customer_message.html.haml b/app/views/public/customer_messages/_customer_message.html.haml new file mode 100644 index 0000000..5e7e7f3 --- /dev/null +++ b/app/views/public/customer_messages/_customer_message.html.haml @@ -0,0 +1,23 @@ +=link_to [:public, customer_message], :class => "customer_message_li", :id => "customer_message_#{customer_message.id}", :remote => true do + + + .time + =l customer_message.created_at, :format => "%d/%m/%y" + .pseudo + -if !customer_message.readed or customer_message.children.where(:destinataire_id => current_customer.id).where("readed is null").first + .new + + + + -if customer_message.expediteur and customer_message.expediteur == current_customer + moi + -else + = customer_message.expediteur.anonyme_nick + + + + -if answer = customer_message.children.order("created_at DESC").first + = truncate(answer.message) + -else + = truncate(customer_message.message) + .clear \ No newline at end of file diff --git a/app/views/public/customer_messages/_customer_message_show.html.haml b/app/views/public/customer_messages/_customer_message_show.html.haml new file mode 100644 index 0000000..759e6ac --- /dev/null +++ b/app/views/public/customer_messages/_customer_message_show.html.haml @@ -0,0 +1,41 @@ +-if customer_message.destinataire == current_customer + -customer_message.readed = true + -customer_message.save + +.customer_message_container{:class => ("me" if customer_message.expediteur and customer_message.expediteur == current_customer).to_s } + + + + + .side + + .square + + .pseudo + + + -if customer_message.expediteur and customer_message.expediteur == current_customer + moi + -else + =link_to customer_message.expediteur.anonyme_nick, [:public, customer_message.expediteur] + + + + + + + + + .time + =l customer_message.created_at, :format => "%d/%m/%y" + + .content + + + -if customer_message.title + %p + =customer_message.title + %hr + + =simple_format customer_message.message + \ No newline at end of file diff --git a/app/views/public/customer_messages/_form.html.haml b/app/views/public/customer_messages/_form.html.haml new file mode 100644 index 0000000..eb7c7f2 --- /dev/null +++ b/app/views/public/customer_messages/_form.html.haml @@ -0,0 +1,11 @@ +=semantic_form_for [:public, @customer_message], :url => answer_save_public_customer_message_path(@parent_customer_message), :remote => true do |f| + + =#f.input :tel, :label => qit("votre-numero-de-telephone-label","Votre numéro de téléphone :") + =#f.input :expediteur_mail, :label => qit("your-mail-label","Votre mail :") + + =f.input :message, :label => "Message" + =f.hidden_field :destinataire_id + + + + =f.submit "Envoyer mon message", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/public/customer_messages/_message_answers.html.haml b/app/views/public/customer_messages/_message_answers.html.haml new file mode 100644 index 0000000..9b9c491 --- /dev/null +++ b/app/views/public/customer_messages/_message_answers.html.haml @@ -0,0 +1,6 @@ +-if @parent_customer_message + -@answer = @parent_customer_message +-else + -@answer = @customer_message + +=render :partial => "customer_message_show", :collection => @answer.children.order("created_at DESC"), :as => :customer_message \ No newline at end of file diff --git a/app/views/public/customer_messages/_show.html.haml b/app/views/public/customer_messages/_show.html.haml new file mode 100644 index 0000000..9b3281f --- /dev/null +++ b/app/views/public/customer_messages/_show.html.haml @@ -0,0 +1,22 @@ +-if @customer_message.expediteur and @customer_message.expediteur != current_customer + .speak_with + + Discussion avec + =link_to @customer_message.expediteur.anonyme_nick, [:public, @customer_message.expediteur] + +-if @customer_message.destinataire and @customer_message.destinataire != current_customer + .speak_with + Discussion avec + =link_to @customer_message.destinataire.anonyme_nick, [:public, @customer_message.destinataire] + + +.answer_link + + %p{:style => "margin:40px;"} + %center=link_to "Répondre", answer_public_customer_message_path(@customer_message), :remote => true, :class => "btn btn-primary" +#message_form +#message_answers + =render :partial => "message_answers" +=render :partial => "customer_message_show", :locals => {:customer_message => @customer_message} + + diff --git a/app/views/public/customer_messages/answer.js.erb b/app/views/public/customer_messages/answer.js.erb new file mode 100644 index 0000000..2ed8a69 --- /dev/null +++ b/app/views/public/customer_messages/answer.js.erb @@ -0,0 +1,3 @@ +$("#message_form").html("<%= escape_javascript(render(:partial => "form")) %>"); +$(".answer_link").hide(); + diff --git a/app/views/public/customer_messages/answer_save.js.erb b/app/views/public/customer_messages/answer_save.js.erb new file mode 100644 index 0000000..b3f8b1a --- /dev/null +++ b/app/views/public/customer_messages/answer_save.js.erb @@ -0,0 +1,3 @@ +$("#message_form").html(""); +$(".answer_link").show(); +$("#message_answers").html("<%= escape_javascript(render(:partial => "message_answers")) %>"); \ No newline at end of file diff --git a/app/views/public/customer_messages/index.html.haml b/app/views/public/customer_messages/index.html.haml new file mode 100644 index 0000000..ee08797 --- /dev/null +++ b/app/views/public/customer_messages/index.html.haml @@ -0,0 +1,16 @@ + +.center.padding + + %h1 Boite de réception + + .col-md-3.customer_message_list + + .inner.height_frame{:style => "overflow:auto;height:300px;"} + + =render @customer_messages + + .col-md-9.customer_message_show_container + .customer_message_show.inner.height_frame{:style => "overflow:auto;height:300px;"} + + .clear + %br diff --git a/app/views/public/customer_messages/show.html.haml b/app/views/public/customer_messages/show.html.haml new file mode 100644 index 0000000..eca5e0d --- /dev/null +++ b/app/views/public/customer_messages/show.html.haml @@ -0,0 +1 @@ +=render :partial => "show" \ No newline at end of file diff --git a/app/views/public/customer_messages/show.js.erb b/app/views/public/customer_messages/show.js.erb new file mode 100644 index 0000000..1a8f790 --- /dev/null +++ b/app/views/public/customer_messages/show.js.erb @@ -0,0 +1,4 @@ +$(".customer_message_show").html("<%= escape_javascript(render(:partial => "show")) %>"); +$(".customer_message_li").removeClass("active"); +$("#customer_message_<%= @customer_message.id %>").addClass("active"); +$("#customer_message_<%= @customer_message.id %> .new").hide(); diff --git a/app/views/public/customers/_annonce_account.haml b/app/views/public/customers/_annonce_account.haml deleted file mode 100755 index b63b3a7..0000000 --- a/app/views/public/customers/_annonce_account.haml +++ /dev/null @@ -1,11 +0,0 @@ -%tr.vertical_center.forum_user#forum_user{:id => forum_user.id} - - %td=image_tag (forum_user.avatar? ? forum_user.avatar.square.url : ""), :class => "avatar", :style => "width:50px; border-radius:50%;" - - %td=link_to forum_user.firstname.to_s+" "+forum_user.name.to_s, forum_forum_user_path(forum_user) - %td=forum_user.topics.count - %td=forum_user.messages.count - - -if moderator? - %td - =link_to i(:"trash-o"), [:forum, forum_user], :method => :delete, :confirm => "Voulez-vous vraiment supprimer cet utilisateur ?" \ No newline at end of file diff --git a/app/views/public/customers/_annonce_account_binary.haml b/app/views/public/customers/_annonce_account_binary.haml deleted file mode 100755 index 5148e9e..0000000 --- a/app/views/public/customers/_annonce_account_binary.haml +++ /dev/null @@ -1,8 +0,0 @@ --inline_b = inline_b || nil -.binary_account{:class => "level_#{@i_table}"} - - =image_tag(customer_binary.avatar_url) - =link_to customer_binary.pseudo, show_details_public_customer_path(customer_binary) --if (@i_table != @nbr_levels )and !inline_b - .binary_line - .line \ No newline at end of file diff --git a/app/views/public/customers/_annonce_account_binary_nil.haml b/app/views/public/customers/_annonce_account_binary_nil.haml deleted file mode 100755 index 56c4a31..0000000 --- a/app/views/public/customers/_annonce_account_binary_nil.haml +++ /dev/null @@ -1,6 +0,0 @@ -.binary_account.binary_account_nill{:class => "level_#{@i_table}"} - =image_tag("/default-nill.png") - Libre --if @i_table != @nbr_levels - .binary_line - .line \ No newline at end of file diff --git a/app/views/public/customers/_binary_table.haml b/app/views/public/customers/_binary_table.haml deleted file mode 100755 index 36e654a..0000000 --- a/app/views/public/customers/_binary_table.haml +++ /dev/null @@ -1,21 +0,0 @@ --i_table += 1 - --liste_o = liste -%table.binary_table - - %tr - %td - -@i_table = i_table - -liste = liste_o+"[1]" - =eval "tree_profile @binary_table#{liste}[0] rescue tree_profile_nil" - -@i_table = 0 - -if i_table < @nbr_levels - =render :partial => "public/customers/binary_table", :locals => {:i_table => i_table, :side => 1, :liste => liste} - - %td - -@i_table = i_table - -liste = liste_o+"[2]" - =eval "tree_profile @binary_table#{liste}[0] rescue tree_profile_nil" - -@i_table = 0 - -if i_table < @nbr_levels - =render :partial => "public/customers/binary_table", :locals => {:i_table => i_table, :side => 2, :liste => liste} \ No newline at end of file diff --git a/app/views/public/customers/_customer.html.haml b/app/views/public/customers/_customer.html.haml new file mode 100755 index 0000000..abfdce4 --- /dev/null +++ b/app/views/public/customers/_customer.html.haml @@ -0,0 +1,31 @@ +-css_class = "" +-css_class "danger" if customer.lock + +%tr#customer_row{:id => customer.id, :class => css_class} + %td + =customer.organisation + %td + =customer.name + =customer.firstname + %td + -if customer.phone? + = i("phone") + " #{customer.phone}" + %td + =customer.city + + %td + = "Oui" if customer.enabled + = "Non" if !customer.enabled + %td + =link_to customer.email, "mailto:#{customer.email}" + + %td + =number_to_currency customer.accepted_offers.joins(:offer).where(:state => "documents_completed").sum("offers.price").to_f + + %td=time_ago_in_words(customer.last_activity) if customer.last_activity + + + %td.actions{:style => "width:150px;text-align:right;"} + =link_to i(:eye), public_customer_path(customer) + =link_to i(:envelope), mail_public_customer_path(customer) + \ No newline at end of file diff --git a/app/views/public/customers/mail.haml b/app/views/public/customers/mail.haml old mode 100755 new mode 100644 index e7cda7b..588e634 --- a/app/views/public/customers/mail.haml +++ b/app/views/public/customers/mail.haml @@ -1,28 +1,24 @@ -.center - %h1 Nouveau message privé +.center.padding + -if @customer - %p - à - %strong=@annonce_message.destinataire.pseudo + %h1 Nouveau message privé - -if @annonce %p - Message au sujet de l'annonce : - %strong= @annonce.title - =semantic_form_for [:public, @annonce_message] do |f| - =f.input :name, :label => "Nom :" if !@annonce_message.expediteur + à + %strong=@customer_message.destinataire.pseudo + - =f.input :tel, :label => "Votre numéro de téléphone :" - =f.input :expediteur_mail, :label => "Votre mail :" - - =f.input :title, :label => "Sujet :" - =f.input :message, :label => "Message" - =f.hidden_field :destinataire_id - =f.hidden_field :annonce_id - - - =f.submit "Envoyer mon message", :class => "btn btn-primary" - - %br - %br + =semantic_form_for [:public, @customer_message] do |f| + =f.input :name, :label => "Nom :" if !@customer_message.expediteur + + + =f.input :message, :label => "Message" + =f.hidden_field :destinataire_id + + + + =f.submit "Envoyer mon message", :class => "btn btn-primary" + + %br + %br \ No newline at end of file diff --git a/app/views/public/customers/show.haml b/app/views/public/customers/show.haml index 1e5593d..ad0bec1 100755 --- a/app/views/public/customers/show.haml +++ b/app/views/public/customers/show.haml @@ -1,19 +1,98 @@ +-@read_only = true + .center.padding + + + + %h2= @customer.pseudo_admin + + + .row - .columns.span_2 - =image_tag (@customer.avatar ? @customer.avatar.square.url : ""), :class => "avatar", :style => "width:100%; border-radius:50%;" - .clear - %br - .columns.span_10 - %h1 - =@customer.pseudo - =simple_format @customer.bio + .col-md-6 + %table.table.table-striped + %tbody + %tr -.clear -.center.search_results.padding - %h2 - Annonces de cet utilisateur - - - =render :partial => "public/annonces/index" + %td + Date d'inscription : + %td + =l @customer.created_at, :format => :date + + %tr + %td + Dernière activité + %td + =time_ago_in_words(@customer.last_activity) if @customer.last_activity + %tr + %td + Organisation : + %td + =@customer.organisation + %tr + %td + Nom : + %td + =@customer.name + %tr + %td + Prénom : + %td + =@customer.firstname + + %tr + %td + Téléphone : + %td + =@customer.phone + + %tr + %td + Email : + %td + =link_to @customer.email, "mailto:#{@customer.email}" + + + + .col-md-6 + %table.table.table-striped + %tbody + %tr + %td + Adresse : + %td=@customer.address + %tr + %td + Adresse (suite) : + %td + =@customer.address2 + %tr + %td + Code postal + %td + =@customer.cp + %tr + %td + Ville : + %td + =@customer.city + + + %h3 Offres acceptées par ce membre + %table.table.table-hover.table-striped.customer_table + %tr + %th Besoin + %th Offre + -@customer.accepted_offers.joins(:offer).where(:state => "documents_completed").each do |accepted_offer| + %tr + %td + =link_to accepted_offer.offer.need.title.upcase, public_need_path(accepted_offer.offer.need) + %td=number_to_currency accepted_offer.offer.price + + %h3 Intérêts de ce membre + + + =render collection: @customer.needs, partial: 'public/needs/need_item', as: :need + + .clear \ No newline at end of file diff --git a/app/views/public/needs/_accepted_offer.html.haml b/app/views/public/needs/_accepted_offer.html.haml index b66f1c6..549c553 100755 --- a/app/views/public/needs/_accepted_offer.html.haml +++ b/app/views/public/needs/_accepted_offer.html.haml @@ -10,6 +10,11 @@ =link_to accepted_offer.offer.need.title, public_need_path(accepted_offer.offer.need) %td =number_to_currency(accepted_offer.offer.price, locale: :fr) + %td + =accepted_offer.qte + %td + =number_to_currency(accepted_offer.total, locale: :fr) + %td{style: 'text-align:center'} =accepted_offer.human_state %td{style: 'text-align:right'} diff --git a/app/views/public/needs/_accepted_offers_index.html.haml b/app/views/public/needs/_accepted_offers_index.html.haml index e43fd91..bc1850c 100755 --- a/app/views/public/needs/_accepted_offers_index.html.haml +++ b/app/views/public/needs/_accepted_offers_index.html.haml @@ -5,7 +5,10 @@ Titre du besoin %th Prix négocié - + %th + Qte + %th + Prix total %th{style: 'text-align:center'} État %th{style: 'text-align:right'} diff --git a/app/views/public/needs/_message.html.haml b/app/views/public/needs/_message.html.haml index 05a3172..31814a0 100755 --- a/app/views/public/needs/_message.html.haml +++ b/app/views/public/needs/_message.html.haml @@ -3,6 +3,12 @@ -if message.customer %h4 =message.customer.anonyme_nick + -if @need.referent_technique and message.customer.id == @need.referent_technique.id and message.customer.id == @need.referent_negos.id + (référent technique & négociation) + -elsif @need.referent_technique and message.customer.id == @need.referent_technique.id + (référent technique) + -elsif @need.referent_negos and message.customer.id == @need.referent_negos.id + (référent négociation) -elsif message.admin %h4 ="#{message.admin.fullname}" diff --git a/app/views/public/needs/_need_item.html.haml b/app/views/public/needs/_need_item.html.haml index 2ad74c2..5dcd1df 100755 --- a/app/views/public/needs/_need_item.html.haml +++ b/app/views/public/needs/_need_item.html.haml @@ -49,25 +49,25 @@ .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 + -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" + -elsif(need.negociating?) + -if(need.customers.include?(current_customer)) + =link_to "Négociation en cours...", public_need_path(need), class: "btn btn-warning pull-right" + -else + =link_to i(:"times-circle") + " Négociation en cours...", public_need_path(need) , class: "btn btn-warning pull-right" - -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" - -elsif(need.negociating?) - -if(need.customers.include?(current_customer)) - =link_to "Négociation en cours...", public_need_path(need), class: "btn btn-warning pull-right" - -else - =link_to i(:"times-circle") + " Négociation en cours...", public_need_path(need) , class: "btn btn-warning pull-right" - - -elsif(need.negociated?) - -if(need.customers.include?(current_customer)) - =link_to i(:"download") +" Voir les offres", public_need_path(need), class: "btn btn-success pull-right" - -else - =link_to i(:"times-circle") + " Négociation terminée", public_need_path(need) , class: "btn btn-danger pull-right" + -elsif(need.negociated?) + -if(need.customers.include?(current_customer)) + =link_to i(:"download") +" Voir les offres", public_need_path(need), class: "btn btn-success pull-right" + -else + =link_to i(:"times-circle") + " Négociation terminée", public_need_path(need) , class: "btn btn-danger pull-right" - .clear + .clear diff --git a/app/views/public/needs/show.html.haml b/app/views/public/needs/show.html.haml index 2dfc65a..7c6e7c4 100755 --- a/app/views/public/needs/show.html.haml +++ b/app/views/public/needs/show.html.haml @@ -114,7 +114,7 @@ -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), data: {confirm: "Pour que l’offre soit validée veuillez retourné le mandat signé que vous allez recevoir"}, 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), class: "btn btn-lg btn-success " -else .offer-accepted =i(:"check") + " Offre Acceptée" diff --git a/app/views/public/offers/accept.html.haml b/app/views/public/offers/accept.html.haml new file mode 100644 index 0000000..f745309 --- /dev/null +++ b/app/views/public/offers/accept.html.haml @@ -0,0 +1,11 @@ +.center + %h1 Accepter cette offre + = semantic_form_for [:public, @accepted_offer], :url => accept_save_public_need_offer_path(@offer.need, @offer), :method => :post do |f| + %p + Pour que l’offre soit validée veuillez retourné le mandat signé que vous allez recevoir + =f.inputs do + = f.input :qte, :label => "Quantité demandée :" + + + %br + =f.submit "Sauvegarder", :class => "btn btn-primary" diff --git a/app/views/public/reseauxes/_reseaux.html.haml b/app/views/public/reseauxes/_reseaux.html.haml new file mode 100755 index 0000000..8bdb85d --- /dev/null +++ b/app/views/public/reseauxes/_reseaux.html.haml @@ -0,0 +1,10 @@ + +%tr{:id => reseaux.id} + %td + = reseaux.name + %td + = reseaux.customers.count + + + %td.actions{:style => "width:150px;text-align:right"} + = link_to i(:eye), public_reseaux_path(reseaux) diff --git a/app/views/public/reseauxes/index.html.haml b/app/views/public/reseauxes/index.html.haml new file mode 100755 index 0000000..dff07d8 --- /dev/null +++ b/app/views/public/reseauxes/index.html.haml @@ -0,0 +1,13 @@ +.center.row + %table.table.admin_table.table-hover.table-striped + %thead.rows_header + + %tr + %th + Nom + %th Utilisateurs + %th{:style => "width:100px"} +   + + %tbody.rows + =render @reseauxes diff --git a/app/views/public/reseauxes/show.html.haml b/app/views/public/reseauxes/show.html.haml new file mode 100644 index 0000000..0c1cc52 --- /dev/null +++ b/app/views/public/reseauxes/show.html.haml @@ -0,0 +1,86 @@ +-@read_only = true + +.center.row + %h1 + Mon réseau : + =@reseaux.name + + + %h3 Membres du réseau + %div{:style => "position:relative"} + %table.table.table-hover.table-striped.customer_table + %thead#customer_rows_header.rows_header + + %tr + %th + Société + %th + Nom + %th + Téléphone + %th + Ville + + %th + Email + %th + CA + %th + Gains + + %th Dernière activité + + + + %th{:style => "width:100px;text-align:right;"} +   + + + + + %tbody#customer_rows.rows + -gain = 0.0 + -@reseaux.customers.each do |customer| + -css_class = "" + -css_class "danger" if customer.lock + + %tr#customer_row{:id => customer.id, :class => css_class} + %td + =customer.organisation + %td + =customer.name + =customer.firstname + %td + -if customer.phone? + = i("phone") + " #{customer.phone}" + %td + =customer.city + + + %td + =link_to customer.email, "mailto:#{customer.email}" + + %td + =number_to_currency customer.accepted_offers.joins(:offer).where(:state => "documents_completed").sum("offers.price * accepted_offers.qte").to_f + + %td + -g = customer.accepted_offers.joins(:offer).where(:state => "documents_completed").sum("offers.gain * accepted_offers.qte").to_f + =number_to_currency g + -gain += g + + + %td=time_ago_in_words(customer.last_activity) if customer.last_activity + + + %td.actions{:style => "width:150px;text-align:right;"} + =link_to i(:eye), public_customer_path(customer) + =link_to i(:envelope), mail_public_customer_path(customer) + + + %div{:style => "position:absolute;top:-30px;right:10px;"} + Gains : + =number_to_currency gain + + %h3 Les besoins de mon réseau + + =render collection: @reseaux.needs, partial: 'public/needs/need_item', as: :need diff --git a/app/views/public/shared/_menu.html.haml b/app/views/public/shared/_menu.html.haml index b263b06..38c0eb8 100755 --- a/app/views/public/shared/_menu.html.haml +++ b/app/views/public/shared/_menu.html.haml @@ -10,6 +10,12 @@ - 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" + + -if current_customer.own_reseauxes.count > 0 + %li=link_to ic(:users)+" Mon réseau", public_reseauxes_path, :class => "btn" + + %li=link_to ic(:envelope)+" Conversations", public_customer_messages_path, :class => "btn" + %li=link_to "Se déconnecter", logout_public_customers_auths_path, :class => "btn" diff --git a/app/views/public/wishes/_form.html.haml b/app/views/public/wishes/_form.html.haml index ff96e39..47e58a5 100644 --- a/app/views/public/wishes/_form.html.haml +++ b/app/views/public/wishes/_form.html.haml @@ -9,6 +9,8 @@ = f.input :devis, type: :file, :label => "Votre proposition (Fichier au format PDF)" = f.input :note, :label => "Informations supplémentaires (Si vous n'avez pas attaché de proposition, merci de préciser son prix dans ce champ)", :rows => 5, :input_html => {:style => "height:100px;"} + + = f.input :qte, :label => "Quantité : ", :input_html => {:style => ""} %br diff --git a/config/database.yml b/config/database.yml index 5476b46..07da583 100755 --- a/config/database.yml +++ b/config/database.yml @@ -14,7 +14,6 @@ default: &default development: <<: *default username: root - password: mysqlpassword host: "127.0.0.1" socket: /var/run/mysqld/mysqld.sock diff --git a/config/environments/development.rb b/config/environments/development.rb index 88882de..2bf00e2 100755 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -41,7 +41,7 @@ Rails.application.configure do config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { address: "localhost", port: 1025 } - config.action_mailer.default_url_options = { host: 'rails-144740.nitrousapp.com', port: 3000} + config.action_mailer.default_url_options = { host: 'localhost', port: 3000} HOSTNAME="localhost:3000" diff --git a/config/routes.rb b/config/routes.rb index f6ba520..9b8a59c 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -116,6 +116,7 @@ Rails.application.routes.draw do resources :offers do member do get :accept + post :accept_save end end member do @@ -167,9 +168,18 @@ Rails.application.routes.draw do get "sitemap.:f" => "public/sitemap#sitemap" namespace :public do + + resources :reseauxes resources :virements resources :comments - resources :annonce_messages + resources :customer_messages do + member do + get :answer + post :answer_save + end + end + + resources :customers do member do get :confirm @@ -227,7 +237,7 @@ Rails.application.routes.draw do end namespace :admin do - + resources :reseauxes resources :documents resources :domains diff --git a/db/migrate/20150704130444_create_customer_messages.rb b/db/migrate/20150704130444_create_customer_messages.rb new file mode 100644 index 0000000..a106b04 --- /dev/null +++ b/db/migrate/20150704130444_create_customer_messages.rb @@ -0,0 +1,22 @@ +class CreateCustomerMessages < ActiveRecord::Migration + def change + create_table :customer_messages do |t| + t.string :title + t.text :message + + t.string :tel + t.integer :expediteur_id + t.string :expediteur_mail + t.string :destinataire_mail + t.integer :destinataire_id + t.integer :parent_id + t.datetime :last_message_at + t.string :remote_ip + t.boolean :enabled + t.boolean :readed + + t.timestamps null: false + end + + end +end diff --git a/db/migrate/20170517084633_add_referent_to_customers.rb b/db/migrate/20170517084633_add_referent_to_customers.rb new file mode 100644 index 0000000..d210487 --- /dev/null +++ b/db/migrate/20170517084633_add_referent_to_customers.rb @@ -0,0 +1,5 @@ +class AddReferentToCustomers < ActiveRecord::Migration + def change + add_column :customers, :referent, :boolean, :default => false + end +end diff --git a/db/migrate/20170517085613_add_referents_to_needs.rb b/db/migrate/20170517085613_add_referents_to_needs.rb new file mode 100644 index 0000000..0b6f370 --- /dev/null +++ b/db/migrate/20170517085613_add_referents_to_needs.rb @@ -0,0 +1,6 @@ +class AddReferentsToNeeds < ActiveRecord::Migration + def change + add_column :needs, :referent_negos_id, :integer + add_column :needs, :referent_technique_id, :integer + end +end diff --git a/db/migrate/20170517090646_create_reseauxes.rb b/db/migrate/20170517090646_create_reseauxes.rb new file mode 100644 index 0000000..f2279f3 --- /dev/null +++ b/db/migrate/20170517090646_create_reseauxes.rb @@ -0,0 +1,11 @@ +class CreateReseauxes < ActiveRecord::Migration + def change + create_table :reseauxes do |t| + t.string :name + t.text :description + t.integer :chef_reseau_id + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20170517090709_create_reseaux_customers.rb b/db/migrate/20170517090709_create_reseaux_customers.rb new file mode 100644 index 0000000..5a050fd --- /dev/null +++ b/db/migrate/20170517090709_create_reseaux_customers.rb @@ -0,0 +1,12 @@ +class CreateReseauxCustomers < ActiveRecord::Migration + def change + create_table :reseaux_customers do |t| + t.references :reseaux, index: true + t.references :customer, index: true + + t.timestamps null: false + end + add_foreign_key :reseaux_customers, :reseauxes + add_foreign_key :reseaux_customers, :customers + end +end diff --git a/db/migrate/20170517095531_add_chef_reseau_to_customers.rb b/db/migrate/20170517095531_add_chef_reseau_to_customers.rb new file mode 100644 index 0000000..7967473 --- /dev/null +++ b/db/migrate/20170517095531_add_chef_reseau_to_customers.rb @@ -0,0 +1,5 @@ +class AddChefReseauToCustomers < ActiveRecord::Migration + def change + add_column :customers, :chef_reseau, :boolean, :default => false + end +end diff --git a/db/migrate/20170517220522_add_qte_to_wishes.rb b/db/migrate/20170517220522_add_qte_to_wishes.rb new file mode 100644 index 0000000..cfb2f4b --- /dev/null +++ b/db/migrate/20170517220522_add_qte_to_wishes.rb @@ -0,0 +1,5 @@ +class AddQteToWishes < ActiveRecord::Migration + def change + add_column :wishes, :qte, :decimal, precision: 10, scale: 2, :default => 1 + end +end diff --git a/db/migrate/20170517222240_add_qte_to_offers.rb b/db/migrate/20170517222240_add_qte_to_offers.rb new file mode 100644 index 0000000..9a3c846 --- /dev/null +++ b/db/migrate/20170517222240_add_qte_to_offers.rb @@ -0,0 +1,5 @@ +class AddQteToOffers < ActiveRecord::Migration + def change + add_column :offers, :qte, :decimal, precision: 10, scale: 2, :default => 1 + end +end diff --git a/db/migrate/20170517224054_add_qte_to_accepted_offers.rb b/db/migrate/20170517224054_add_qte_to_accepted_offers.rb new file mode 100644 index 0000000..f5345d9 --- /dev/null +++ b/db/migrate/20170517224054_add_qte_to_accepted_offers.rb @@ -0,0 +1,5 @@ +class AddQteToAcceptedOffers < ActiveRecord::Migration + def change + add_column :accepted_offers, :qte, :decimal, precision: 10, scale: 2, :default => 1 + end +end diff --git a/db/migrate/20170517224743_add_gain_to_offers.rb b/db/migrate/20170517224743_add_gain_to_offers.rb new file mode 100644 index 0000000..8a27c60 --- /dev/null +++ b/db/migrate/20170517224743_add_gain_to_offers.rb @@ -0,0 +1,5 @@ +class AddGainToOffers < ActiveRecord::Migration + def change + add_column :offers, :gain, :decimal, precision: 10, scale: 2 + end +end diff --git a/db/migrate/20170517225135_create_offer_reseauxes.rb b/db/migrate/20170517225135_create_offer_reseauxes.rb new file mode 100644 index 0000000..6131dea --- /dev/null +++ b/db/migrate/20170517225135_create_offer_reseauxes.rb @@ -0,0 +1,12 @@ +class CreateOfferReseauxes < ActiveRecord::Migration + def change + create_table :offer_reseauxes do |t| + t.references :offer, index: true + t.references :reseaux, index: true + + t.timestamps null: false + end + add_foreign_key :offer_reseauxes, :offers + add_foreign_key :offer_reseauxes, :reseauxes + end +end diff --git a/db/schema.rb b/db/schema.rb index 2910c70..df95cc3 100755 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,16 +11,17 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20161018122307) do +ActiveRecord::Schema.define(version: 20170517225135) do create_table "accepted_offers", force: :cascade do |t| - 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 "offer_id", limit: 4 t.integer "customer_id", limit: 4 t.string "devis", limit: 255 t.string "state", limit: 255 t.string "string", limit: 255 + t.decimal "qte", precision: 10, scale: 2, default: 1.0 end add_index "accepted_offers", ["customer_id"], name: "index_accepted_offers_on_customer_id", using: :btree @@ -157,6 +158,23 @@ ActiveRecord::Schema.define(version: 20161018122307) do t.datetime "updated_at", null: false end + create_table "customer_messages", force: :cascade do |t| + t.string "title", limit: 255 + t.text "message", limit: 65535 + t.string "tel", limit: 255 + t.integer "expediteur_id", limit: 4 + t.string "expediteur_mail", limit: 255 + t.string "destinataire_mail", limit: 255 + t.integer "destinataire_id", limit: 4 + t.integer "parent_id", limit: 4 + t.datetime "last_message_at" + t.string "remote_ip", limit: 255 + t.boolean "enabled", limit: 1 + t.boolean "readed", limit: 1 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "customer_newsgroups", force: :cascade do |t| t.integer "customer_id", limit: 4 t.integer "newsgroup_id", limit: 4 @@ -227,6 +245,8 @@ ActiveRecord::Schema.define(version: 20161018122307) do t.text "particulars_text", limit: 65535 t.float "capital", limit: 24 t.string "role_signataire", limit: 255 + t.boolean "referent", limit: 1, default: false + t.boolean "chef_reseau", limit: 1, default: false end create_table "data_files", force: :cascade do |t| @@ -487,17 +507,19 @@ ActiveRecord::Schema.define(version: 20161018122307) do add_index "need_categories", ["parent_id"], name: "index_need_categories_on_parent_id", using: :btree 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.integer "author_id", limit: 4 + t.string "title", limit: 255 + t.text "description", limit: 65535 + 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 - t.integer "category_id", limit: 4 - t.string "devis", limit: 255 - t.integer "image_file_id", limit: 4 - t.text "note", limit: 65535 + t.string "state", limit: 255 + t.integer "category_id", limit: 4 + t.string "devis", limit: 255 + t.integer "image_file_id", limit: 4 + t.text "note", limit: 65535 + t.integer "referent_negos_id", limit: 4 + t.integer "referent_technique_id", limit: 4 end add_index "needs", ["author_id"], name: "index_needs_on_author_id", using: :btree @@ -524,14 +546,26 @@ ActiveRecord::Schema.define(version: 20161018122307) do t.datetime "updated_at" end + create_table "offer_reseauxes", force: :cascade do |t| + t.integer "offer_id", limit: 4 + t.integer "reseaux_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "offer_reseauxes", ["offer_id"], name: "index_offer_reseauxes_on_offer_id", using: :btree + add_index "offer_reseauxes", ["reseaux_id"], name: "index_offer_reseauxes_on_reseaux_id", using: :btree + create_table "offers", force: :cascade do |t| - 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.float "price", limit: 24 t.float "fee_percentage", limit: 24 t.integer "need_id", limit: 4 t.string "supplier", limit: 255 t.datetime "deleted_at" + t.decimal "qte", precision: 10, scale: 2, default: 1.0 + t.decimal "gain", precision: 10, scale: 2 end add_index "offers", ["deleted_at"], name: "index_offers_on_deleted_at", using: :btree @@ -554,6 +588,24 @@ ActiveRecord::Schema.define(version: 20161018122307) do t.datetime "updated_at" end + create_table "reseaux_customers", force: :cascade do |t| + t.integer "reseaux_id", limit: 4 + t.integer "customer_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "reseaux_customers", ["customer_id"], name: "index_reseaux_customers_on_customer_id", using: :btree + add_index "reseaux_customers", ["reseaux_id"], name: "index_reseaux_customers_on_reseaux_id", using: :btree + + create_table "reseauxes", force: :cascade do |t| + t.string "name", limit: 255 + t.text "description", limit: 65535 + t.integer "chef_reseau_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "sessions", force: :cascade do |t| t.string "session_id", limit: 255, null: false t.text "data", limit: 65535 @@ -616,10 +668,11 @@ ActiveRecord::Schema.define(version: 20161018122307) do create_table "wishes", force: :cascade do |t| t.integer "customer_id", limit: 4 t.integer "need_id", limit: 4 - 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.text "note", limit: 65535 t.string "devis", limit: 255 + t.decimal "qte", precision: 10, scale: 2, default: 1.0 end add_foreign_key "customer_newsgroups", "customers" @@ -630,4 +683,8 @@ ActiveRecord::Schema.define(version: 20161018122307) do add_foreign_key "domain_need_categories", "need_categories" add_foreign_key "domain_needs", "domains" add_foreign_key "domain_needs", "needs" + add_foreign_key "offer_reseauxes", "offers" + add_foreign_key "offer_reseauxes", "reseauxes" + add_foreign_key "reseaux_customers", "customers" + add_foreign_key "reseaux_customers", "reseauxes" end diff --git a/fichier-final.pdf b/fichier-final.pdf new file mode 100644 index 0000000..bf94b7a Binary files /dev/null and b/fichier-final.pdf differ diff --git a/pdf/documents/3-2.pdf b/pdf/documents/3-2.pdf new file mode 100644 index 0000000..608914a Binary files /dev/null and b/pdf/documents/3-2.pdf differ diff --git a/pdf/documents/3.pdf b/pdf/documents/3.pdf new file mode 100644 index 0000000..07c79ae Binary files /dev/null and b/pdf/documents/3.pdf differ diff --git a/pdf/documents/3_temp.pdf b/pdf/documents/3_temp.pdf new file mode 100644 index 0000000..06c637f Binary files /dev/null and b/pdf/documents/3_temp.pdf differ diff --git a/sortie.pdf b/sortie.pdf new file mode 100644 index 0000000..814f65c Binary files /dev/null and b/sortie.pdf differ diff --git a/test/fixtures/offer_reseauxes.yml b/test/fixtures/offer_reseauxes.yml new file mode 100644 index 0000000..0e1b134 --- /dev/null +++ b/test/fixtures/offer_reseauxes.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + offer_id: + reseaux_id: + +two: + offer_id: + reseaux_id: diff --git a/test/fixtures/reseaux_customers.yml b/test/fixtures/reseaux_customers.yml new file mode 100644 index 0000000..cb71fc2 --- /dev/null +++ b/test/fixtures/reseaux_customers.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + reseaux_id: + customer_id: + +two: + reseaux_id: + customer_id: diff --git a/test/fixtures/reseauxes.yml b/test/fixtures/reseauxes.yml new file mode 100644 index 0000000..bbe9f82 --- /dev/null +++ b/test/fixtures/reseauxes.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + description: MyText + chef_reseau_id: 1 + +two: + name: MyString + description: MyText + chef_reseau_id: 1 diff --git a/test/models/offer_reseaux_test.rb b/test/models/offer_reseaux_test.rb new file mode 100644 index 0000000..671b796 --- /dev/null +++ b/test/models/offer_reseaux_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class OfferReseauxTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/reseaux_customer_test.rb b/test/models/reseaux_customer_test.rb new file mode 100644 index 0000000..7c23f81 --- /dev/null +++ b/test/models/reseaux_customer_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ReseauxCustomerTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/reseaux_test.rb b/test/models/reseaux_test.rb new file mode 100644 index 0000000..e387ce0 --- /dev/null +++ b/test/models/reseaux_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ReseauxTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/untitled.txt b/untitled.txt new file mode 100644 index 0000000..e69de29