réseaux etc

This commit is contained in:
Nicolas Bally 2017-05-18 01:21:04 +02:00
parent 6fe10f5faa
commit 6e04868116
86 changed files with 1325 additions and 336 deletions

View File

@ -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;
}
}
}
}
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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,20 +138,20 @@ 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
@no_search = true
@customer = Customer.find_by_id(params[:id])
@annonce_message.annonce = @annonce
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
@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

View File

@ -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,10 +40,13 @@ 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])
end

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,4 +0,0 @@
class CreditExpense < ActiveRecord::Base
belongs_to :credit
belongs_to :expense
end

View File

@ -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

View File

@ -3,6 +3,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,52 +131,12 @@ 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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,4 @@
class OfferReseaux < ActiveRecord::Base
belongs_to :offer
belongs_to :reseaux
end

13
app/models/reseaux.rb Normal file
View File

@ -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

View File

@ -0,0 +1,4 @@
class ReseauxCustomer < ActiveRecord::Base
belongs_to :reseaux
belongs_to :customer
end

View File

@ -6,7 +6,12 @@
=f.inputs do
.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"

View File

@ -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

View File

@ -2,7 +2,13 @@
.content
=f.inputs do
.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"

View File

@ -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"

View File

@ -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)

View File

@ -0,0 +1,2 @@
%h1 Modifier un réseau
=render :partial => "form"

View File

@ -0,0 +1,16 @@
%table.table.admin_table.table-hover.table-striped
%thead.rows_header
%tr
%th
Nom
%th Utilisateurs
%th{:style => "width:100px"}
&nbsp;
%tbody.rows
=render @reseauxes
%br
= link_to "Ajouter un reseaux", new_admin_reseaux_path, class:"btn btn-primary"

View File

@ -0,0 +1,2 @@
%h1 Ajouter un réseau
=render :partial => "admin/reseauxes/form"

View File

@ -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;"}
&nbsp;
%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"}
&nbsp;
%tbody.rows
=render @reseaux.needs

View File

@ -57,7 +57,7 @@
-else
%li= link_to " Contacts", admin_conversations_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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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}

View File

@ -0,0 +1,3 @@
$("#message_form").html("<%= escape_javascript(render(:partial => "form")) %>");
$(".answer_link").hide();

View File

@ -0,0 +1,3 @@
$("#message_form").html("");
$(".answer_link").show();
$("#message_answers").html("<%= escape_javascript(render(:partial => "message_answers")) %>");

View File

@ -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

View File

@ -0,0 +1 @@
=render :partial => "show"

View File

@ -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();

View File

@ -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 ?"

View File

@ -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

View File

@ -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

View File

@ -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}

View File

@ -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)

20
app/views/public/customers/mail.haml Executable file → Normal file
View File

@ -1,24 +1,20 @@
.center
.center.padding
-if @customer
%h1 Nouveau message privé
%p
à
%strong=@annonce_message.destinataire.pseudo
%strong=@customer_message.destinataire.pseudo
-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
=f.input :tel, :label => "Votre numéro de téléphone :"
=f.input :expediteur_mail, :label => "Votre mail :"
=semantic_form_for [:public, @customer_message] do |f|
=f.input :name, :label => "Nom :" if !@customer_message.expediteur
=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"

View File

@ -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
%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
.center.search_results.padding
%h2
Annonces de cet utilisateur
=render :partial => "public/annonces/index"

View File

@ -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'}

View File

@ -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'}

View File

@ -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}"

View File

@ -49,7 +49,7 @@
.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)

View File

@ -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 loffre 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"

View File

@ -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 loffre 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"

View File

@ -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)

View File

@ -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"}
&nbsp;
%tbody.rows
=render @reseauxes

View File

@ -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;"}
&nbsp;
%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

View File

@ -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"

View File

@ -10,6 +10,8 @@
= 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
.div.pull-right

View File

@ -14,7 +14,6 @@ default: &default
development:
<<: *default
username: root
password: mysqlpassword
host: "127.0.0.1"
socket: /var/run/mysqld/mysqld.sock

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,5 @@
class AddReferentToCustomers < ActiveRecord::Migration
def change
add_column :customers, :referent, :boolean, :default => false
end
end

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,5 @@
class AddChefReseauToCustomers < ActiveRecord::Migration
def change
add_column :customers, :chef_reseau, :boolean, :default => false
end
end

View File

@ -0,0 +1,5 @@
class AddQteToWishes < ActiveRecord::Migration
def change
add_column :wishes, :qte, :decimal, precision: 10, scale: 2, :default => 1
end
end

View File

@ -0,0 +1,5 @@
class AddQteToOffers < ActiveRecord::Migration
def change
add_column :offers, :qte, :decimal, precision: 10, scale: 2, :default => 1
end
end

View File

@ -0,0 +1,5 @@
class AddQteToAcceptedOffers < ActiveRecord::Migration
def change
add_column :accepted_offers, :qte, :decimal, precision: 10, scale: 2, :default => 1
end
end

View File

@ -0,0 +1,5 @@
class AddGainToOffers < ActiveRecord::Migration
def change
add_column :offers, :gain, :decimal, precision: 10, scale: 2
end
end

View File

@ -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

View File

@ -11,7 +11,7 @@
#
# 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
@ -21,6 +21,7 @@ ActiveRecord::Schema.define(version: 20161018122307) do
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|
@ -498,6 +518,8 @@ ActiveRecord::Schema.define(version: 20161018122307) do
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,6 +546,16 @@ 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
@ -532,6 +564,8 @@ ActiveRecord::Schema.define(version: 20161018122307) do
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
@ -620,6 +672,7 @@ ActiveRecord::Schema.define(version: 20161018122307) do
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

BIN
fichier-final.pdf Normal file

Binary file not shown.

BIN
pdf/documents/3-2.pdf Normal file

Binary file not shown.

BIN
pdf/documents/3.pdf Normal file

Binary file not shown.

BIN
pdf/documents/3_temp.pdf Normal file

Binary file not shown.

BIN
sortie.pdf Normal file

Binary file not shown.

9
test/fixtures/offer_reseauxes.yml vendored Normal file
View File

@ -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:

9
test/fixtures/reseaux_customers.yml vendored Normal file
View File

@ -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:

11
test/fixtures/reseauxes.yml vendored Normal file
View File

@ -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

View File

@ -0,0 +1,7 @@
require 'test_helper'
class OfferReseauxTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class ReseauxCustomerTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class ReseauxTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

0
untitled.txt Normal file
View File