diff --git a/app/assets/stylesheets/public.scss b/app/assets/stylesheets/public.scss index 005ae1b..7292c8d 100755 --- a/app/assets/stylesheets/public.scss +++ b/app/assets/stylesheets/public.scss @@ -32,7 +32,7 @@ body{ font-size:15px; color:#333333; background:white; - + padding-top:60px; @@ -66,9 +66,11 @@ body{ } .category-container{ - + background:center center no-repeat; + background-size:100%; + background-size:cover; display:block; - min-height:500px; + min-height:200px; img{ width:100%; } @@ -78,7 +80,7 @@ body{ .category-title{ color:white; - font-size: 80px; + font-size: 1.5em; display:block; text-align:center; width:100%; @@ -94,6 +96,7 @@ body{ #footer{ display:block; height:390px; + margin-top:100px; background: url("/images/footer_background.jpg") center center; background-size:cover !important; background-size:100%; @@ -164,7 +167,7 @@ body{ background-size:100%; background-size:cover; - min-height:400px; + img{ width:100%; } @@ -363,12 +366,15 @@ img{ .center{ margin:auto; - max-width:900px; + max-width:1100px; } .product_show{ - + #product_description{ + + max-width:700px; + } .col_images{ float:left; box-sizing:border-box; diff --git a/app/controllers/public/account_ribs_controller.rb b/app/controllers/public/account_ribs_controller.rb new file mode 100644 index 0000000..588a321 --- /dev/null +++ b/app/controllers/public/account_ribs_controller.rb @@ -0,0 +1,102 @@ +class Public::AccountRibsController < ApplicationController + layout "public" + + before_filter :auth_product_customer + + + + def index + + + + @account_rib = current_product_customer.account_ribs.all + + + end + + + def show + @account_rib = AccountRib.find(params[:id]) + session[:mail_prev] = public_account_rib_path(@account_rib) + end + + + def new + @no_search = true + @account_rib = current_product_customer.account_ribs.new(:country => "France") + + + end + + def edit + @account_rib = current_account_rib_account.account_rib.find(params[:id]) + + end + + + + def create + + + @account_rib = current_product_customer.account_ribs.new(params.require(:account_rib).permit!) + + + + + if @account_rib.save + + + redirect_to public_account_ribs_path + + + + else + render :action => "new" + end + end + + + def update + @account_rib = current_product_customer.account_ribs.find(params[:id]) + + + + + respond_to do |format| + if @account_rib.update_attributes(params.require(:account_rib).permit!) + + + + format.html { + redirect_to public_my_account_path + } + format.js + + else + + format.html { render :action => "edit" } + format.js { "" } + end + end + + + + end + + + + def destroy + + @account_rib = current_account_rib_account.account_rib.find(params[:id]) + @account_rib.enabled = nil + @account_rib.save + + redirect_to public_my_account_path, :notice => "Votre account_rib a bien été désactivée" + + + + end + + + +end diff --git a/app/controllers/public/commissions_controller.rb b/app/controllers/public/commissions_controller.rb new file mode 100644 index 0000000..4340a36 --- /dev/null +++ b/app/controllers/public/commissions_controller.rb @@ -0,0 +1,22 @@ +class Public::CommissionsController < ApplicationController + layout "public" + + + + def index + @no_search = true + per_page = (params[:per_page] and params[:per_page] != "") ? params[:per_page] : 20 + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @commissions = current_product_customer.commissions.order("created_at DESC").page(page).per(per_page) + + + + + + end + + + + + +end diff --git a/app/controllers/public/my_account_controller.rb b/app/controllers/public/my_account_controller.rb new file mode 100644 index 0000000..3702252 --- /dev/null +++ b/app/controllers/public/my_account_controller.rb @@ -0,0 +1,58 @@ +class Public::MyAccountController < ApplicationController + + layout "public" + + before_filter :auth_product_customer + + def index + + end + + def edit_infos + @no_search = true + end + + def my_annonces + @no_search = true + end + + def binary + @no_search = true + if params[:parrain_id] and current_product_customer.binary_child_ids.include?(params[:parrain_id].to_i) + @parrain = ProductCustomer.find(params[:parrain_id]) + + + + else + @parrain = current_product_customer + end + end + + def filleuls + @no_search = true + @filleuls = current_product_customer.children + + session[:mail_prev] = public_filleuls_path + + end + + def reconfirm + @no_search = true + ProductCustomerMailer.confirm(current_product_customer).deliver + + redirect_to public_my_account_path, :notice => "Le mail vous a été renvoyé" + end + + + def favoris + + per_page = (params[:per_page] and params[:per_page] != "") ? params[:per_page] : 10 + + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + + @annonces = current_product_customer.annonce_favs.valid_to_show + @annonces = @annonces.page(page).per(per_page).all + end + + +end diff --git a/app/controllers/public/product_customers_auths_controller.rb b/app/controllers/public/product_customers_auths_controller.rb index 8d64d48..44ee70b 100755 --- a/app/controllers/public/product_customers_auths_controller.rb +++ b/app/controllers/public/product_customers_auths_controller.rb @@ -19,6 +19,13 @@ class Public::ProductCustomersAuthsController < ApplicationController end @product_customer = ProductCustomer.new() + if cookies[:mlm_token] and @parent = ProductCustomer.find_parrain(cookies[:mlm_token]) + @product_customer.parent_code = @parent.mlm_token.upcase + + elsif params[:p] and @parent = ProductCustomer.find_parrain(params[:p]) + @product_customer.parent_code = @parent.mlm_token.upcase + + end end diff --git a/app/controllers/public/product_customers_controller.rb b/app/controllers/public/product_customers_controller.rb index 0eafd0e..f3d68b6 100755 --- a/app/controllers/public/product_customers_controller.rb +++ b/app/controllers/public/product_customers_controller.rb @@ -1,7 +1,7 @@ class Public::ProductCustomersController < ApplicationController layout "public" - before_filter :auth_product_customer, :except => [:new, :create, :confirm, :find_parrain] + before_filter :auth_product_customer, :except => [:new, :create, :confirm, :find_parrain, :parrainage] def index @@ -27,10 +27,18 @@ class Public::ProductCustomersController < ApplicationController params[:for_annonce] = nil end + + params[:for_mail] =nil if params[:for_mail] == "" @product_customer = ProductCustomer.new() + if cookies[:mlm_token] and @parent = ProductCustomer.find_parrain(cookies[:mlm_token]) + @product_customer.parent_code = @parent.mlm_token.upcase + elsif params[:p] and @parent = ProductCustomer.find_parrain(params[:p]) + @product_customer.parent_code = @parent.mlm_token.upcase + + end if cookies[:mlm_token] and @parent = ProductCustomer.find_parrain(cookies[:mlm_token]) @product_customer.parent_code = @parent.mlm_token.upcase diff --git a/app/controllers/public/virements_controller.rb b/app/controllers/public/virements_controller.rb new file mode 100644 index 0000000..d4b5b9a --- /dev/null +++ b/app/controllers/public/virements_controller.rb @@ -0,0 +1,156 @@ +class Public::VirementsController < ApplicationController + layout "public" + + before_filter :auth_product_customer + + + + def index + + + + @virements = current_product_customer.virements.all + + + end + + + def show + @virement = current_product_customer.virements.find_by_token(params[:id]) + + @temp_file = "#{Rails.root}/pdf/virements/#{@virement.token}_temp.pdf" + @final_file = "#{Rails.root}/pdf/virements/#{@virement.token}.pdf" + + + view = ActionView::Base.new(Rails.root.join('app/views')) + view.class.include ApplicationHelper + view.class.include Rails.application.routes.url_helpers + + pdf = view.render( + :pdf => "#{@virement.token}", + :template => "public/virements/show.html.haml", + + :locals => {:@virement => @virement, :current_product_customer => current_product_customer}) + + # then save to a file + pdf = WickedPdf.new.pdf_from_string(pdf, :margin => { top: 0, # default 10 (mm) + bottom: 0, + left: 0, + right: 0 }) + + save_path = @temp_file + File.open(save_path, 'wb') do |file| + file << pdf + end + + + + require 'posix/spawn' + + ::POSIX::Spawn::Child.new 'pdftk', @temp_file, 'background', Rails.root.join('pdf_stamp', 'orders.pdf').to_s, 'output', @final_file + + #pdftk /Users/nico/Dev/sideplace_app.old/pdf/order_bills/SP20150700003.pdf background fond.pdf output sortie.pdf + + + + + @data_to_send = File.open( @final_file).read + + send_data @data_to_send, :filename =>"note-commission.pdf" , :type => 'application/pdf',:disposition => (params[:inline] ? 'inline' : "attachment") + + + end + + + def new + @no_search = true + @devise = Devise.first + @virement = current_product_customer.virements.new(:amount_ht => current_product_customer.max_virement, :devise => @devise) + + + end + + def edit + @virement = current_virement_account.virements.find(params[:id]) + + end + + + + def create + + + @virement = current_product_customer.virements.new(params.require(:virement).permit!) + + + + + if @virement.valid? + if params[:confirm] + token = @virement.generate_token + @commission = current_product_customer.commissions.new(:commission_type_id => 4, :amount => ((@virement.amount_ht+5)*(-1)), :devise => @virement.devise) + @virement.commission = @commission + if @virement.save + + redirect_to public_commissions_path + else + render :inline => "test" + end + else + render :action => "confirm" + end + + + + + + else + render :action => "new" + end + end + + + def update + @virement = current_product_customer.virements.find(params[:id]) + + + + + respond_to do |format| + if @virement.update_attributes(params.require(:virement).permit!) + + + + format.html { + redirect_to public_my_account_path + } + format.js + + else + + format.html { render :action => "edit" } + format.js { "" } + end + end + + + + end + + + + def destroy + + @virement = current_virement_account.virements.find(params[:id]) + @virement.enabled = nil + @virement.save + + redirect_to public_my_account_path, :notice => "Votre virement a bien été désactivée" + + + + end + + + +end diff --git a/app/models/account_rib.rb b/app/models/account_rib.rb new file mode 100644 index 0000000..34cf60d --- /dev/null +++ b/app/models/account_rib.rb @@ -0,0 +1,19 @@ +class AccountRib < ActiveRecord::Base + belongs_to :product_customer + + mount_uploader :scan_file, RibUploader + + validates :bank_name, :presence => true + validates :bank_city, :presence => true + validates :country, :presence => true + validates :name, :presence => true + validates :address, :presence => true + validates :tva_number, :presence => true, :if => :tva? + validates :cp, :presence => true + validates :city, :presence => true + validates :iban, :presence => true + validates :bic, :presence => true + + + +end diff --git a/app/models/commission.rb b/app/models/commission.rb new file mode 100644 index 0000000..e005f1c --- /dev/null +++ b/app/models/commission.rb @@ -0,0 +1,18 @@ +class Commission < ActiveRecord::Base + belongs_to :product_customer + has_one :order_solde, :class_name => "Order" + belongs_to :product_order + belongs_to :count_part_com + + has_one :virement + has_one :hipay_virement + + belongs_to :devise + + after_create do + if self.commission_type_id == 1 or self.commission_type_id == 2 or self.commission_type_id == 3 + ProductCustomerMailer.new_commission(self).deliver + end + end + +end diff --git a/app/models/devise.rb b/app/models/devise.rb new file mode 100644 index 0000000..0641c5c --- /dev/null +++ b/app/models/devise.rb @@ -0,0 +1,14 @@ +class Devise < ActiveRecord::Base + + def self.convert(amount, devise_from, devise_to) + result = (amount.to_f/devise_from.rate)*devise_to.rate + + return result.round(2) + + #Devise.convert(10, Devise.find_by_code("EUR"), Devise.find_by_code("USD")) + #Devise.convert(10, Devise.find_by_code("USD"), Devise.find_by_code("EUR")) + #Devise.convert(10, Devise.find_by_code("CHF"), Devise.find_by_code("EUR")) + + end + +end diff --git a/app/models/product.rb b/app/models/product.rb index 8377de8..5bcd93e 100755 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -115,7 +115,7 @@ class Product < ActiveRecord::Base def tva - 0.0 + 0.2 end def price_ttc diff --git a/app/models/product_customer.rb b/app/models/product_customer.rb index 35cb037..1efdb37 100755 --- a/app/models/product_customer.rb +++ b/app/models/product_customer.rb @@ -1,9 +1,12 @@ class ProductCustomer < ActiveRecord::Base - + acts_as_tree has_secure_password validates :email, :presence => true, :uniqueness => true, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i validates_presence_of :password, :on => :create + has_many :product_orders + has_many :commissions + has_many :account_ribs belongs_to :particular_bill, :class_name => "Particular" @@ -86,5 +89,126 @@ class ProductCustomer < 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 = ProductCustomer.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 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(devise_id=1) + self.commissions.where(:devise_id => devise_id).sum(:amount) + end + + + def max_virement(devise_id=1) + self.solde_commissions(1).floor - 5.0 + + end + def mlm_small_percents + [0,10,6,4,0,0,0,0,0,0,0,0] + end + + def callif_now + {:percents => self.mlm_small_percents} + end + + + def mlm_nbr_niveaux + if self.callif_now + 3 + + else + 0 + end + end + + COUNTRY = [ + + "Suisse", + "France", + "Allemagne", + "Autriche", + "Belgique", + "Espagne", + "Estonie", + "Finlande", + "Grèce", + "Irlande", + "Italie", + "Luxembourg", + "Malte", + "Pays-Bas", + "Portugal", + "Slovaquie", + "Slovénie", + "Croatie", + + + "Bulgarie", + "Danemark", + "Hongrie", + "Lettonie", + "Lituanie", + "Pologne", + "République Tchèque", + "Roumanie", + "Royaume Uni", + "Suède", + "Islande", + "Norvège", + "Liechtenstein", + "Monaco", + + "Guadeloupe", + "Guyane", + "Martinique", + "La Réunion", + "Mayotte", + "Polynésie française", + "Saint-Barthélemy", + #"Saint-Martin", + #"Saint-Pierre-et-Miquelon", + "Wallis-et-Futuna", + "Nouvelle-Calédonie" + + + + + ] + + end diff --git a/app/models/product_order.rb b/app/models/product_order.rb index 5f93a3e..e499a21 100755 --- a/app/models/product_order.rb +++ b/app/models/product_order.rb @@ -29,16 +29,29 @@ class ProductOrder < ActiveRecord::Base attr_accessor :force_fdp_validation, :force_payment, :force_cgv_validation def total_ttc - total_articles + total_fdp - vourcher_reduction + total_articles_ttc + total_fdp - vourcher_reduction_ttc end def total_ttc_without_fdp - total_articles - vourcher_reduction + total_articles_ttc - vourcher_reduction_ttc end - def vourcher_reduction + def total_ht_without_fdp + total_articles_ht - vourcher_reduction_ht + end + + def vourcher_reduction_ttc if self.vourcher_code and 1==1 - (total_articles * (self.vourcher_code.percent / 100 )).round(2) + (total_articles_ttc * (self.vourcher_code.percent / 100 )).round(2) + + else + 0.0 + end + end + + def vourcher_reduction_ht + if self.vourcher_code and 1==1 + (total_articles_ht * (self.vourcher_code.percent / 100 )).round(2) else 0.0 @@ -46,9 +59,9 @@ class ProductOrder < ActiveRecord::Base end - def archived_vourcher_reduction + def archived_vourcher_reduction_ttc if self.vourcher_code_archived and 1==1 - (total_articles * (self.vourcher_code_archived.percent / 100 )).round(2) + (total_articles_ttc * (self.vourcher_code_archived.percent / 100 )).round(2) else 0.0 @@ -58,11 +71,11 @@ class ProductOrder < ActiveRecord::Base def archived_total_ttc - archived_total_articles + archived_total_fdp - archived_vourcher_reduction + archived_total_articles_ttc + archived_total_fdp - archived_vourcher_reduction_ttc end - def archived_total_articles + def archived_total_articles_ttc archived_total = 0.0 product_order_products.each do |p| archived_total += p.archived_final_price_ttc_with_qty @@ -72,7 +85,7 @@ class ProductOrder < ActiveRecord::Base def archived_total_fdp(fdp=self.product_fdp_archived) if fdp - if self.archived_total_articles < fdp.price_max + if self.archived_total_articles_ttc < fdp.price_max fdp.price else 0.0 @@ -160,7 +173,7 @@ class ProductOrder < ActiveRecord::Base end - def total_articles + def total_articles_ttc total = 0.0 product_order_products.each do |p| total += p.final_price_ttc_with_qty @@ -168,6 +181,15 @@ class ProductOrder < ActiveRecord::Base total end + + def total_articles_ht + total = 0.0 + product_order_products.each do |p| + total += p.final_price_ht_with_qty + end + total + end + def total_fdp(fdp=self.product_fdp) if fdp if self.total_ttc_without_fdp < fdp.price_max @@ -195,6 +217,34 @@ class ProductOrder < ActiveRecord::Base end + def commission_mlm_now + if self.product_customer.parent + i = 0 + parent_to_commission = self.product_customer.parent + + while parent_to_commission and i <= 12 + i += 1 + + if parent_to_commission.mlm_nbr_niveaux >= i + com_percent = (parent_to_commission.callif_now[:percents][i].to_f/100) + com = (com_percent*self.total_ht_without_fdp.to_f()).round(2) + puts "Commission à #{parent_to_commission.pseudo}: génération #{i}, #{com_percent}%, #{com}" + + parent_to_commission.commissions.create(:product_order => self, :commission_type_id => 10, :amount => com, :percent => com_percent, :generation => i, :devise_id => 1) + + end + + parent_to_commission = parent_to_commission.parent + + + end + + + end + end + + + protected def verify(size=16) diff --git a/app/models/product_order_product.rb b/app/models/product_order_product.rb index 23e9e09..1ccf1ef 100755 --- a/app/models/product_order_product.rb +++ b/app/models/product_order_product.rb @@ -18,6 +18,10 @@ class ProductOrderProduct < ActiveRecord::Base qty.to_f * product.final_price_ttc.to_f end + def final_price_ht_with_qty + qty.to_f * product.final_price_ht.to_f + end + def archived_price_ttc_with_qty diff --git a/app/models/virement.rb b/app/models/virement.rb new file mode 100644 index 0000000..86ccb2c --- /dev/null +++ b/app/models/virement.rb @@ -0,0 +1,63 @@ +class Virement < ActiveRecord::Base + belongs_to :devise + validates :amount_ht, :presence => true + belongs_to :product_customer + belongs_to :virement_remise + belongs_to :commission + belongs_to :account_rib + + + scope :execute_between, lambda { |start, stop| + execute_after(start).execute_before(stop) + } + + + scope :execute_after, lambda { |date| + joins(:virement_remise).where("(virement_remises.created_at >= ?)", date ) + } + scope :execute_before, lambda { |date| + where("(virement_remises.created_at <= ?)", date ) + } + + def generate_token + self.token = loop do + + token = SecureRandom.hex(6) + break token unless Virement.exists?(token: token) + end + + self.token + end + + + def name_for_edi + value = self.account_rib.name.mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n, '').to_s + + # Remove single quotes from input + value.gsub!(/[']+/, '') + + # Replace any non-word character (\W) with a space + value.gsub!(/\W+/, ' ') + + # Remove any whitespace before and after the string + value.strip! + return value + end + + + before_validation do + if self.product_customer.virements.where("sended is null").count >= 1 + errors.add(:amount_ht, "Vous ne pouvez pas avoir plus d'un virements en attente d'execution.") + end + + if !self.product_customer.account_ribs.where(:id => self.account_rib.id, :validated => true).first or !self.account_rib.validated + errors.add(:account_rib, 'Compte sélectionné invalide') + + end + + if self.amount_ht.to_f < 5 or self.amount_ht.to_f > self.product_customer.max_virement + errors.add(:amount_ht, "Le montant doit être compris entre 5 € et #{self.product_customer.max_virement.to_i} €") + + end + end +end diff --git a/app/models/virement_remise.rb b/app/models/virement_remise.rb new file mode 100644 index 0000000..e171ac1 --- /dev/null +++ b/app/models/virement_remise.rb @@ -0,0 +1,20 @@ +class VirementRemise < ActiveRecord::Base + + has_many :virements + + + def init + self.amount = self.virements.sum(:amount_ttc) + + + self.token = loop do + + token = SecureRandom.hex(6) + break token unless VirementRemise.exists?(token: token) + end + + self.save + + + end +end diff --git a/app/uploaders/rib_uploader.rb b/app/uploaders/rib_uploader.rb new file mode 100644 index 0000000..bd1e62b --- /dev/null +++ b/app/uploaders/rib_uploader.rb @@ -0,0 +1,62 @@ +# -*- encoding : utf-8 -*- + +class RibUploader < CarrierWave::Uploader::Base + + # Include RMagick or ImageScience support: + # include CarrierWave::RMagick + # include CarrierWave::ImageScience + + # Choose what kind of storage to use for this uploader: + storage :file + # storage :s3 + + # Override the directory where uploaded files will be stored. + # This is a sensible default for uploaders that are meant to be mounted: + def store_dir + "#{Rails.root}/private_medias/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + end + + def url + #"/download_data_files/#{model.token}" + + end + + def extension_white_list + %w(jpg jpeg png pdf) + end + + # Provide a default URL as a default if there hasn't been a file uploaded: + def default_url + "/images/fallback/" + [version_name, "default.png"].compact.join('_') + end + + # Process files as they are uploaded: + # process :scale => [200, 300] + # + # def scale(width, height) + # # do something + # end + + # Create different versions of your uploaded files: + # version :thumb do + # process :scale => [50, 50] + # end + + # Add a white list of extensions which are allowed to be uploaded. + # For images you might use something like this: + # def extension_white_list + # %w(jpg jpeg gif png) + # end + + # Override the filename of the uploaded files: + # def filename + # "something.jpg" if original_filename + # end + + def filename + File.basename(original_filename, File.extname(original_filename)).to_s.to_slug + File.extname(original_filename).to_s if original_filename + + + end + +end diff --git a/app/views/admin/product_orders/_product_order.html.haml b/app/views/admin/product_orders/_product_order.html.haml index 28ecb9c..28f4a60 100755 --- a/app/views/admin/product_orders/_product_order.html.haml +++ b/app/views/admin/product_orders/_product_order.html.haml @@ -20,7 +20,7 @@ %td - =number_to_currency product_order.archived_total_articles + =number_to_currency product_order.archived_total_articles_ttc %td =number_to_currency product_order.archived_total_fdp diff --git a/app/views/admin/product_orders/show.html.haml b/app/views/admin/product_orders/show.html.haml index 4a85314..d516fa4 100755 --- a/app/views/admin/product_orders/show.html.haml +++ b/app/views/admin/product_orders/show.html.haml @@ -32,7 +32,7 @@ %tr %td{:colspan => 5, :style => "border:0;"} %td Total : - %td= number_to_currency(@product_order.archived_total_articles, locale: :fr) + %td= number_to_currency(@product_order.archived_total_articles_ttc, locale: :fr) -if @product_order.vourcher_code_archived %tr @@ -42,7 +42,7 @@ ="("+@product_order.vourcher_code_archived.slug+") :" %td ="-" - =number_to_currency @product_order.archived_vourcher_reduction, locale: :fr + =number_to_currency @product_order.archived_vourcher_reduction_ttc, locale: :fr %tr %td{:colspan => 5, :style => "border:0;"} diff --git a/app/views/layouts/public.html.haml b/app/views/layouts/public.html.haml index 57125fb..cd88be3 100755 --- a/app/views/layouts/public.html.haml +++ b/app/views/layouts/public.html.haml @@ -50,7 +50,7 @@ =current_product_customer.email - #header{:style => "background-image:url('#{@image_bandeau}');"} + #header{:style => "background-image:url('#{@image_bandeau}');"+("min-height:400px;"if @image_bandeau).to_s} @@ -68,6 +68,8 @@ .top_right %span#cart_infos =render :partial => "public/shared/cart" + + =link_to i(:user), "/public/my_account/index" -if flash[:error] or flash[:notice] or flash[:alert] @@ -147,11 +149,13 @@ }); - #content - =yield + =yield =yield :bandeau -if @menu_item and @menu_item.id == 1 - =render :partial => "public/product_categories/bandeau",:collection => ProductCategory.where(parent_id: nil).order(:position), :as => :product_category + + .center.padding.row + + =render :partial => "public/product_categories/bandeau",:collection => ProductCategory.where(parent_id: nil).order(:position), :as => :product_category diff --git a/app/views/product_orders_mails/confirmation_cb.html.haml b/app/views/product_orders_mails/confirmation_cb.html.haml index 69e5e1c..88c9699 100755 --- a/app/views/product_orders_mails/confirmation_cb.html.haml +++ b/app/views/product_orders_mails/confirmation_cb.html.haml @@ -15,7 +15,7 @@ %strong Vitascreen %br - +33 6 52 66 90 82 + %br =link_to "contact@styandus.com", "mailto:contact@styandus.com" @@ -36,7 +36,7 @@ %strong Vitascreen %br - +33 6 52 66 90 82 + %br =link_to "contact@styandus.com", "mailto:contact@styandus.com" diff --git a/app/views/product_orders_mails/confirmation_cheque.html.haml b/app/views/product_orders_mails/confirmation_cheque.html.haml index abd8136..c80300b 100755 --- a/app/views/product_orders_mails/confirmation_cheque.html.haml +++ b/app/views/product_orders_mails/confirmation_cheque.html.haml @@ -12,12 +12,7 @@ Vous pouvez envoyer un chèque d'un montant de = number_to_currency(@product_order.total_ttc, locale: :fr) à l'ordre de StyAndUs à l'adresse suivante : - %br - Galerie La Forestière - %br - 1 rue de la Forestière - %br - 33970 CAP FERRET + %p Vous trouverez ci-dessous le récapitulatif de cette commande : @@ -28,7 +23,7 @@ %strong Vitascreen %br - +33 6 52 66 90 82 + %br =link_to "contact@styandus.com", "mailto:contact@styandus.com" @@ -46,13 +41,7 @@ Vous pouvez envoyer un chèque d'un montant de = number_to_currency(@product_order.total_ttc, locale: :fr) à l'ordre de StyAndUs à l'adresse suivante : - %br - Galerie La Forestière - %br - 1 rue de la Forestière - %br - 33970 CAP FERRET - + %p Vous trouverez ci-dessous le récapitulatif de cette commande : @@ -62,7 +51,7 @@ %strong Vitascreen %br - +33 6 52 66 90 82 + %br =link_to "contact@styandus.com", "mailto:contact@styandus.com" diff --git a/app/views/public/account_ribs/_form.html.haml b/app/views/public/account_ribs/_form.html.haml new file mode 100644 index 0000000..b24070b --- /dev/null +++ b/app/views/public/account_ribs/_form.html.haml @@ -0,0 +1,26 @@ += semantic_form_for [:public, @account_rib] do |f| + .alert.alert-info + %p + =qit "intro-saisie-rib" do + Merci de saisir votre RIB dans le formulaire suivant, en recopiant les informations telles que présentées sur votre RIB + =f.inputs do + + + = f.input :bank_name, :label => qit("label-nom-banque","Nom de la banque :"), :placeholder => "ex : CA Centre Est" + = f.input :bank_city, :label => qit("label-ville-banque","Ville de la banque :"), :placeholder => "ex : GRENOBLE" + = f.input :name, :label => qit("label-intitule-compte","Intitulé du compte :"), :placeholder => "ex : SARL DUPONT où M SERGE DUPONT" + = f.input :address, :label => qit("label-titulaire-compte", "Adresse du titulaire du compte: "), :placeholder => "ex : 13 rue de les Lilas" + = f.input :address2, :label => qit("label-complement-adresse","Complément d'adresse :"), :placeholder => "" + = f.input :cp, :label => qit("label-code-postal","Code postal :"), :placeholder => "" + = f.input :city, :label => "Ville", :placeholder => "" + + = f.input :country, :label => qit("label-pays-compte","Pays du compte"), :as => :select, :include_blank => false, :collection => ProductCustomer::COUNTRY.sort + = f.input :iban, :label => qit("label-iban","IBAN (sans espaces)"), :placeholder => "ex : FR7644444444444444444444444" + = f.input :bic, :label => qit("label-bic","Code BIC / swift"), :placeholder => "ex : AGRIFRPP878" + =f.input :tva, :label => qit("label-tva-case-a-cocher","Vous êtes un professionnel soumis à la TVA ?") + =f.input :tva_number, :label => qit("label-tva-number","Numéro de TVA intracom. :") + =f.input :scan_file, :label => qit("label-rib-file","Fichier du rib lisible (scanné ou version numérique au format pdf, jpg où png) :") + + =f.submit qit("save", "Sauvegarder"), :class => "btn btn-primary" + %br + %br \ No newline at end of file diff --git a/app/views/public/account_ribs/index.html.haml b/app/views/public/account_ribs/index.html.haml new file mode 100644 index 0000000..e6c16a0 --- /dev/null +++ b/app/views/public/account_ribs/index.html.haml @@ -0,0 +1,38 @@ +=render :partial => "public/my_account/menu" +.center + + + .padding + %h1=qit("title-bank-account","Comptes bancaires") + =link_to qit("add-bank-account","ajouter un compte bancaire"), new_public_account_rib_path, :class => "btn btn-primary" + %table.table{:style => "text-align:left"} + %tr + %th=qit("th-bank-account-alias","Intitulé du compte") + %th=qit("th-country", "Pays") + %th=qit("th-bank", "Banque") + %th=qit("th-iban","Iban") + %th=qit("th-tva","Tva") + %th=qit("th-statut","Statut") + %th + -@account_rib.each do |account_rib| + %tr + %td=account_rib.name + %td=account_rib.country + %td=account_rib.bank_name + %td=account_rib.iban + %td + -if account_rib.tva? + =account_rib.tva_number + %td + -if account_rib.validated? + =qit("bank-account-validate","Validé") + -else + =qit("bank-account-validate-progress","En cours de validation") + + %td + -if account_rib.scan_file? + Fichier reçu : + =account_rib.scan_file.file.filename + + + \ No newline at end of file diff --git a/app/views/public/account_ribs/new.html.haml b/app/views/public/account_ribs/new.html.haml new file mode 100644 index 0000000..69435d1 --- /dev/null +++ b/app/views/public/account_ribs/new.html.haml @@ -0,0 +1,8 @@ +=render :partial => "public/my_account/menu" +.center + + + %h1=qit("add-rib","Ajouter un RIB") + + =render :partial => "form" + \ No newline at end of file diff --git a/app/views/public/commissions/_commission.html.haml b/app/views/public/commissions/_commission.html.haml new file mode 100644 index 0000000..960bc87 --- /dev/null +++ b/app/views/public/commissions/_commission.html.haml @@ -0,0 +1,51 @@ +%tr + %td{:style => "width:120px"} + = l commission.created_at, :format => "%d %b %Y" + %td + -if commission.product_order + =commission.product_order.product_customer.pseudo + %td + + -if commission.commission_type_id == 1 + Commission directe + -elsif commission.commission_type_id == 2 + =i :sitemap + Commission binaire + -elsif commission.commission_type_id == 3 + Commission de participation + -elsif commission.commission_type_id == 4 + Virement vers votre compte + =commission.virement.account_rib.iban+", " + + référence du virement : + =commission.virement.token.upcase + %br + =link_to "Détail PDF", public_virement_path(commission.virement.token) if commission.virement.sended + + -elsif commission.commission_type_id == 14 + Virement vers votre compte hipay + =commission.hipay_virement.hipay_email+", " + + référence du virement : + =commission.hipay_virement.token.upcase + %br + =link_to "Détail PDF", public_hipay_virement_path(commission.hipay_virement.token) if commission.hipay_virement.sended + + + + -elsif commission.commission_type_id == 5 + Utilisation du solde pour commande de crédits + + %td + -if (commission.commission_type_id == 4 and !commission.virement.sended) + =i :"clock-o" + -elsif (commission.commission_type_id == 14 and !commission.hipay_virement.sended) + =i :"clock-o" + -elsif commission.commission_type_id == 5 and !commission.order_solde.paid + =link_to paid_public_order_path(commission.order_solde) do + =i :"clock-o" + finaliser ma commande en payant le solde par CB + + %td{:style => "text-align:right;min-width:100px;", :class => (commission.amount < 0 ? "red" : "green")} + =commission.amount < 0 ? "" : "+ " + =number_to_currency commission.amount \ No newline at end of file diff --git a/app/views/public/commissions/index.html.haml b/app/views/public/commissions/index.html.haml new file mode 100644 index 0000000..5232793 --- /dev/null +++ b/app/views/public/commissions/index.html.haml @@ -0,0 +1,65 @@ +=render :partial => "public/my_account/menu" +.center.padding + + + %h1 Commissions + .row + .col-md-4 + + .white + %h4 + Soldes + -if current_product_customer.commissions.sum(:amount) >= 2.00 + disponibles : + -else + disponible : + %h4{:style => "margin-bottom:0;"} + + %table.table + -Devise.where(:orderable => true).all.each do |devise| + %tr + %td + =devise.name + %td + + =number_to_currency current_product_customer.solde_commissions(devise.id), :unit => devise.icon + + + -if current_product_customer.commissions.sum(:amount) >= 10 and current_product_customer.virements.where("sended is null").count < 1 + + %p=link_to "Demander un retrait de commissions par virement SEPA (€)", new_public_virement_path + + %p=link_to "Demander un retrait de commissions par Hipay", new_public_hipay_virement_path + + .white + %h4 Comptes SEPA + -if current_product_customer.account_ribs.where(:validated => true).count > 0 + %table.table + -current_product_customer.account_ribs.each do |account_rib| + %tr + %td + =account_rib.bank_name + ="-" + =account_rib.iban[0..1] + XXXX + =account_rib.iban[-5..-1] + -elsif current_product_customer.account_ribs.count > 0 + %p Votre rib est en cours de validation par notre équipe, nous vous contacterons si nous avons besoin de plus d'informations. + -else + %p Pour pouvoir demander un virement de commission vous devez d'abord enregistrer un RIB. + + + %p + =link_to "Gérer mes comptes bancaires", public_account_ribs_path + + %p + Lorsque vous avez des commissions vous pouvez les utiliser pour acheter d'autres coffrets de crédits ou demander un virement sur un compte bancaire domicilié dans les pays éligibles. + + + .col-md-8 + .white + %h4 Historique des commissions + %table.table#commissions=render @commissions + + #pagination + = paginate @commissions \ No newline at end of file diff --git a/app/views/public/my_account/_address.html.haml b/app/views/public/my_account/_address.html.haml new file mode 100644 index 0000000..b6b9584 --- /dev/null +++ b/app/views/public/my_account/_address.html.haml @@ -0,0 +1,16 @@ += f.input :address, :label => "Adresse" += f.input :address2, :label => "Adresse (suite)" += f.input :cp, :label => "Code postal" += f.input :city, :label => "Ville" +-if @product_customer.id and ProductCustomer.find(@product_customer.id).country? + %strong Pays : + =@product_customer.country + %br + (pour modifier votre pays merci de contacter le support : support@sideplace.com) +-else + -f.object.country = "France" if !f.object.country? and f.object.force_address? + =# f.input :country, :label => "Pays", :as => :select, :include_blank => (@product_customer.force_address? ? false : true), :collection => ProductCustomer::COUNTRY_ORDER.sort + + = f.input :country, :label => "Pays", :locale => 'fr', :priority_countries => ["FR", "CH", "BE", "US", "GB", "CA"], :include_blank => (@product_customer.force_address? ? false : true) + + diff --git a/app/views/public/my_account/_binary_form.html.haml b/app/views/public/my_account/_binary_form.html.haml new file mode 100644 index 0000000..289e45c --- /dev/null +++ b/app/views/public/my_account/_binary_form.html.haml @@ -0,0 +1,5 @@ +-@product_customer = @product_customer || current_product_customer +- @product_customer.binary_preferences = 0 if !@product_customer.binary_preferences += semantic_form_for [:public, @product_customer], :remote => true do |f| + =f.input :binary_preferences, :collection => [["Automatique : branche la plus faible", 0], ["Branche gauche", 1], ["Branche droite", 2]] , :label => "Sélection de la branche binaire pour les nouveaux affiliés :", :as => :radio, :include_blank => false + =f.submit "Sauvegarder", :class => "btn btn-primary" diff --git a/app/views/public/my_account/_menu.haml b/app/views/public/my_account/_menu.haml new file mode 100644 index 0000000..ecdd59b --- /dev/null +++ b/app/views/public/my_account/_menu.haml @@ -0,0 +1,16 @@ + + +%nav#my_account_menu.navbar.navbar-inverse + .container-fluid + + .navbar-header{:class => ("active" if params[:controller] == "public/my_account" and params[:action] == "index")} + = link_to i(:user)+raw(" Mon compte"), public_my_account_path, :class => "navbar-brand" + %ul.nav.navbar-nav + + + + %li{:class => ("active" if params[:controller] == "public/my_account" and params[:action] == "edit_infos")}= link_to " Profil", public_edit_infos_path + %li{:class => ("active" if params[:controller] == "public/my_account" and params[:action] == "filleuls")}= link_to "Affiliés", public_filleuls_path + + %li{:class => ("active" if (params[:controller] == "public/commissions" and params[:action] == "index") or params[:controller] == "public/account_ribs")}= link_to "Commissions / virements", public_commissions_path + \ No newline at end of file diff --git a/app/views/public/my_account/_note_pays.html.haml b/app/views/public/my_account/_note_pays.html.haml new file mode 100644 index 0000000..7c5feb9 --- /dev/null +++ b/app/views/public/my_account/_note_pays.html.haml @@ -0,0 +1,3 @@ +.alert.alert-info + %strong Note concernant les pays + =render :partial => "public/my_account/text_pays" \ No newline at end of file diff --git a/app/views/public/my_account/_solde_credits.html.haml b/app/views/public/my_account/_solde_credits.html.haml new file mode 100644 index 0000000..2019cd6 --- /dev/null +++ b/app/views/public/my_account/_solde_credits.html.haml @@ -0,0 +1,13 @@ +.center.solde_credits + %p + =image_tag "/credit.png" + A ce jour vous avez + =current_product_customer.solde_credits(Date.today) + -if current_product_customer.solde_credits(Date.today) > 1 + crédits + -else + crédit + %br + %br + =link_to "acheter des crédits", public_credit_products_path, :class => "btn btn-primary btn-lg" + diff --git a/app/views/public/my_account/_text_pays.html.haml b/app/views/public/my_account/_text_pays.html.haml new file mode 100644 index 0000000..aa11e73 --- /dev/null +++ b/app/views/public/my_account/_text_pays.html.haml @@ -0,0 +1,51 @@ + +%p Tout le monde peut déposer des annonces localisées dans quasiment tous les pays du monde. +%p Les clients du monde entier peuvent acheter des crédits d'annonces pour mettre en valeur celles-ci. + +%p Tous nos clients peuvent utiliser les commissions touchées via le programme d'affiliation pour acheter d'autres crédits. + +%p Actuellement les clients ayant un compte dans ces pays peuvent recevoir leurs commissions par virement SEPA : + +%p + =ProductCustomer::COUNTRY.sort.join(" - ") +%hr + +-countries = [] +-HipayCountry.where(:enabled => true).all.each do |hc| + -c = ISO3166::Country.new hc.code_pays + -countries << c.translations["fr"].to_s+" (#{hc.code_pays})" if c.translations["fr"] + + +%p + Les clients de ces pays + ="(#{countries.size})" + peuvent recevoir leur commissions sur leur compte + =link_to "Hipay Wallet*", "https://www.hipaywallet.com", :target => "_blank" + (en le créant gratuitement si ils n'en ont pas déjà un) + =":" + +%p + + .row-fluid{:style => "text-align:left;"} + + .col-md-4 + -count = 0 + -countries.sort.each do |c| + -count += 1 + =c + %br + -if count == 55 or count == 110 + =raw("