reseaux products

This commit is contained in:
Nicolas Bally 2017-09-19 11:33:15 +02:00
parent eef6f4ff7c
commit b7dc991c7c
191 changed files with 5682 additions and 27 deletions

View File

@ -156,6 +156,17 @@ function select_cible_from_manager(input_id){
function select_product_images_from_manager(product_id){
manager_prompt("/admin/image_files/?manager=true&multiple=true",function(m_return){
$.ajax({url:"/admin/product_images/", type: "POST", data : { image_file_ids : m_return, product_id : product_id }});
});
}
function initialize_manager(){

View File

@ -12,11 +12,48 @@
@import "public/account";
@import "public/affiliation";
@import "public/need";
@import "public/boutique";
@import "vendor/flipclock";
.reseaux_body{
.top{
#menu{
padding-right:110px;
}
#logo-mb{
position:absolute;
right:0px;
top:0px;
width:120px;
z-index:2;
}
}
#main .body-container{
padding-top:10px;
}
h1{
font-size:1.3em;
text-transform:uppercase;
}
}
.reseaux_top{
background:center center;
background-size:cover;
position:relative;
.logo_reseaux{
margin:30px 40px;
width:300px;
}
}
#main{

View File

@ -0,0 +1,225 @@
$orange:black;
$dark_orange:#206e95;
.boutique_body{
.product_description{
h1{
margin-top:0;
}
}
.col_image{
background:white;
text-align:center;
}
.table{
th{
background:transparent;
color:black;
border-bottom:1px solid gray;
}
}
h1{
text-align:center;
font-size:2em;
}
.btn{
padding:6px 12px;
padding-top:4px;
color:white;
background:$dark_orange;
font-size:1em;
cursor:pointer;
}
.formtastic{
.btn{
background:$orange;
}
}
.product-item{
box-sizing:border-box;
width:24%;
display:inline-block;
padding:10px;
.product-price{
color:rgba(0,0,0,0.8);
.strip{
text-decoration: line-through;
}
}
.inner{
.description{
padding:20px;
}
max-width:270px;
position:relative;
margin:10px auto;
background:white;
.special{
position:absolute;
top:-20px;
right:-20px;
width:60px;
}
h3{
font-size: 1.2em;
//line-height: 0.8em;
color:$dark_orange;
margin-top:0px;
min-height:2.2em;
margin-bottom:10px;
}
.stock{
height:6px;
width:6px;
background:green;
border-radius:50%;
position:relative;
top:-10px;
display:inline-block;
}
}
}
.products_grid{
text-align:center;
}
}
.product_show{
.price{
font-weight:bold;
margin-top:2em;
//font-size:1.5em;
}
h1{
font-size:1.8em;
padding-top:20px;
color:$dark_orange;
text-align:left;
}
.add_to_cart{
margin:1em 0;
}
.row{
.col_image{
float:left;
width:40%;
box-sizing:border-box;
.product_images{
img{
width:20%;
}
}
}
.col_description{
box-sizing:border-box;
margin-left:40%;
padding:0 40px;
}
}
}
#my_cart{
td{
vertical-align:top;
padding:5px;
a{
color:black;
}
}
.choice, .radio{
input{
display:inline-block;
width:auto;
margin-right:5px;
}
}
}
.product_sizes{
margin:2em 0;
a{
display:inline-block;
text-align:center;
border: 1px solid $orange;
line-height:1.9em;
padding-top:0.2em;
width:2.2em;
border-radius:50%;
color:black;
text-decoration:none;
font-weight:bold;
&.active, &:hover{
background : $orange;
color:white !important;
}
}
}
.size_guide{
margin-top:2em;
}
.product_options{
margin:2em 0;
a{
display:inline-block;
text-align:center;
border: 1px solid $orange;
line-height:1.9em;
padding-top:0.2em;
padding-left:10px;
padding-right:10px;
margin:0 10px;
margin-left:0;
color:black;
text-decoration:none;
font-weight:bold;
&.active, &:hover{
background : $orange;
color:white !important;
}
}
}
.boutique-right{
text-align:right;
width:100px;
}
.particular_form{
td{
padding:0 !important;
}
}

View File

@ -0,0 +1,177 @@
# -*- encoding : utf-8 -*-
class Admin::ProductCategoriesController < ApplicationController
before_filter :auth_admin
layout "admin"
before_filter :find_product_categories
def index
end
def reorder
i = 1
params[:product_categories_ids].each do |id|
product_category = ProductCategory.find(id)
product_category.position = i
puts i
product_category.update_attributes :position => i
i = i + 1
end
if params[:menu_id] and params[:menu_id] != "" and @menu = Menu.find(params[:menu_id])
find_product_categories
end
flash[:success] = "Menus réorganisés avec succcès."
end
def cible
@product_categories = ProductCategory.all
render :layout => false
end
def new
@product_category = ProductCategory.new(:parent_id => params[:parent_id])
@product_category.product_category_langs << ProductCategoryLang.new(:lang => LangSite.first.slug, :parent_id => params[:parent_id])
end
def edit
@product_category = ProductCategory.find(params[:id])
end
def show
@product_category = ProductCategory.find(params[:id])
end
def create
@product_category = ProductCategory.new(params.require(:product_category).permit!)
if @product_category.save
params[:parent_id] =@product_category.parent_id
self.find_product_categories
flash[:notice] = "La catégorie à été ajouté avec succès."
else
render :action => "new"
end
end
def update
@product_category = ProductCategory.find(params[:id])
if request.xhr?
@product_category_parent = @product_category.parent if @product_category.parent
@product_categories = ProductCategory.where(:parent_id => @product_category.parent_id).order(:position)
end
if params[:product_category][:parent_id] and params[:product_category][:parent_id] == "no-menu-selected"
params[:product_category][:parent_id] = nil
end
@reorder = true if params[:reorder]
respond_to do |format|
if @product_category.update_attributes(params.require(:product_category).permit!)
#ProductCategory.all.each do |mi|
# mi.set_permalink
#end
flash[:notice] = "Le menu à été modifié avec succès."
format.html { redirect_to(admin_product_categories_path(:parent_id => @product_category.parent_id)) }
if @reorder
format.js {
render :action => "update" }
else
format.js {
@product_category = ProductCategory.find(@product_category.id)
render :action => "update_row" }
end
else
if @reorder
format.js { render :action => "update_reorder_failled" }
else
format.html { render :action => "edit" }
format.js { render :action => "edit" }
end
end
end
end
def destroy
@product_category = ProductCategory.find(params[:id])
params[:parent_id] = @product_category.parent_id
@product_category.destroy
find_product_categories
flash[:notice] = "La catégorie à bien été supprimée."
end
protected
def find_product_categories
params[:parent_id] = nil if !params[:parent_id] or params[:parent_id] == ""
@product_category_parent = ProductCategory.find(params[:parent_id]) if params[:parent_id]
@product_categories = ProductCategory.where(:parent_id => params[:parent_id]).order("position ASC")
end
end

View File

@ -0,0 +1,174 @@
# -*- encoding : utf-8 -*-
class Admin::ProductCollectionsController < ApplicationController
before_filter :auth_admin
layout "admin"
before_filter :find_product_collections
def index
end
def reorder
i = 1
params[:product_collections_ids].each do |id|
product_collection = ProductCollection.find(id)
product_collection.position = i
puts i
product_collection.update_attributes :position => i
i = i + 1
end
if params[:menu_id] and params[:menu_id] != "" and @menu = Menu.find(params[:menu_id])
find_product_collections
end
flash[:success] = "Collections réorganisées avec succcès."
end
def cible
@product_collections = ProductCollection.all
render :layout => false
end
def new
@product_category = ProductCategory.find(params[:product_category_id])
@product_collection = ProductCollection.new(:product_category_id => @product_category.id)
LangSite.all.each do |ls|
@product_collection.product_collection_langs << ProductCollectionLang.new(:lang => ls.slug)
end
end
def edit
@product_category = ProductCategory.find(params[:product_category_id])
@product_collection = ProductCollection.find(params[:id])
end
def show
@product_collection = ProductCollection.find(params[:id])
end
def create
@product_category = ProductCategory.find(params[:product_category_id])
@product_collection = ProductCollection.new(params.require(:product_collection).permit!)
if @product_collection.save
@product_collections = @product_collection.product_category.product_collections.order(:position)
flash[:notice] = "La collection à bien été créée."
else
render :action => "new"
end
end
def update
@product_category = ProductCategory.find(params[:product_category_id])
@product_collection = ProductCollection.find(params[:id])
@reorder = true if params[:reorder]
respond_to do |format|
if @product_collection.update_attributes(params.require(:product_collection).permit!)
#ProductCollection.all.each do |mi|
# mi.set_permalink
#end
flash[:notice] = "La collection à été modifié avec succès."
format.html { redirect_to(admin_product_collections_path(:parent_id => @product_collection.parent_id)) }
if @reorder
format.js {
render :action => "update" }
else
format.js {
@product_collection = ProductCollection.find(@product_collection.id)
render :action => "update_row" }
end
else
flash[:error] = "Cette collection n'a pas pu être déplacée. Vérifiez que son lien permanent n'éxiste pas déjà dans l'élément cible."
if @reorder
format.js { render :action => "update_reorder_failled" }
else
format.html { render :action => "edit" }
format.js { render :action => "edit" }
end
end
end
end
def destroy
@product_collection = ProductCollection.find(params[:id])
@product_collection.destroy
flash[:notice] = "La collection à bien été supprimée."
end
protected
def find_product_collections
params[:parent_id] = nil if !params[:parent_id] or params[:parent_id] == ""
@product_collection_parent = ProductCollection.find(params[:parent_id]) if params[:parent_id]
@product_collections = ProductCollection.where(:parent_id => params[:parent_id]).order("position ASC")
end
end

View File

@ -0,0 +1,82 @@
# -*- encoding : utf-8 -*-
class Admin::ProductImagesController < ApplicationController
layout "admin"
def reorder
i = 0
params[:order].each do |product_image_id|
i += 1
product_image = ProductImage.find(product_image_id)
product_image.position = i
product_image.save
end
end
def create
@product = Product.find(params[:product_id])
@product_images = []
if params[:image_file_ids].kind_of?(Array)
params[:image_file_ids].each do |image_file_id|
image_file = ImageFile.find(image_file_id)
product_image = ProductImage.create(:image_file_id => image_file.id, :title => image_file.name, :description => image_file.description, :product_id => @product.id )
@product_images << product_image
end
end
respond_to do |format|
format.js
end
end
def edit
@product_image = ProductImage.find(params[:id])
if request.xhr?
render :layout => false
end
end
def show
end
def update
@product_image = ProductImage.find(params[:id])
respond_to do |format|
if @product_image.update_attributes(params.require(:product_image).permit!)
format.js
else
format.html { render :action => "edit", :layout => false}
format.js { render :action => "edit" }
end
end
end
def destroy
@product_image = ProductImage.find(params[:id])
@product_image.destroy
end
end

View File

@ -0,0 +1,82 @@
# -*- encoding : utf-8 -*-
class Admin::ProductOrderPaymentsController < ApplicationController
before_filter :auth_admin
layout "admin"
def new
@product_order_payment = ProductOrderPayment.new()
@product_order_payment.product_order_payment_langs << ProductOrderPaymentLang.new(:lang => LangSite.first.slug)
end
def edit
@product_order_payment = ProductOrderPayment.find(params[:id])
end
def create
@product_order_payment = ProductOrderPayment.new(params.require(:product_order_payment).permit!)
if @product_order_payment.save
self.find_product_order_payments
flash[:notice] = "Le paiement a été ajouté."
else
render :action => "new"
end
end
def update
@product_order_payment = ProductOrderPayment.find(params[:id])
respond_to do |format|
if @product_order_payment.update_attributes(params.require(:product_order_payment).permit!)
@product_order_payment.product_order.verify_paid_status
flash[:notice] = "Le paiement a été mis à jour"
format.js {
render :action => "update"
}
else
flash[:error] = "Le paiement n'a pas pu être mis à jour"
format.html { render :action => "edit" }
format.js { render :action => "edit" }
end
end
end
end

View File

@ -0,0 +1,179 @@
# -*- encoding : utf-8 -*-
class Admin::ProductOrdersController < ApplicationController
before_filter :auth_admin
layout "admin"
before_filter :find_product_orders
def ship
@product_order = ProductOrder.find(params[:id])
@product_order.after_ship
redirect_to :back
end
def index
end
def edit
@product_order = ProductOrder.find(params[:id])
end
def show
@product_order = ProductOrder.find(params[:id])
end
def bill
@product_order = ProductOrder.find(params[:id])
if @product_order.bill_number?
@temp_file = "#{Rails.root}/pdf/donator_transactions_recus/FACTURE_#{@product_order.id}_temp.pdf"
@final_file = "#{Rails.root}/pdf/donator_transactions_recus/FACTURE_#{@product_order.id}.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 => "#{@product_order.id}",
:template => "admin/product_orders/bill.html.haml",
:locals => {:@product_order => @product_order})
# 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', 'facture.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 =>"facture.pdf" , :type => 'application/pdf',:disposition => (params[:inline] ? 'inline' : "attachment")
else
render :inline => "Aucune facture disponnible"
end
end
def create
@product_order = ProductOrder.new(params.require(:product_order).permit!)
if @product_order.save
self.find_product_orders
flash[:notice] = "La catégorie à été ajouté avec succès."
else
render :action => "new"
end
end
def update
@product_order = ProductOrder.find(params[:id])
respond_to do |format|
if @product_order.update_attributes(params.require(:product_order).permit!)
#ProductOrder.all.each do |mi|
# mi.set_permalink
#end
flash[:notice] = "Le menu à été modifié avec succès."
format.html { redirect_to(admin_product_orders_path(:parent_id => @product_order.parent_id)) }
if @reorder
format.js {
render :action => "update" }
else
format.js {
@product_order = ProductOrder.find(@product_order.id)
render :action => "update_row" }
end
else
format.html { render :action => "edit" }
format.js { render :action => "edit" }
end
end
end
def destroy
@product_order = ProductOrder.find(params[:id])
@product_order.destroy
flash[:notice] = "La commande à bien été supprimée."
end
protected
def find_product_orders
@product_orders = ProductOrder.where(:completed_finish => true).order("created_at DESC")
end
end

View File

@ -0,0 +1,142 @@
# -*- encoding : utf-8 -*-
class Admin::ProductSizesController < ApplicationController
before_filter :auth_admin
layout "admin"
before_filter :find_product_sizes
def index
end
def reorder
i = 1
params[:product_sizes_ids].each do |id|
product_size = ProductSize.find(id)
product_size.position = i
puts i
product_size.update_attributes :position => i
i = i + 1
end
if params[:menu_id] and params[:menu_id] != "" and @menu = Menu.find(params[:menu_id])
find_product_sizes
end
flash[:success] = "Menus réorganisés avec succcès."
end
def cible
@product_sizes = ProductSize.all
render :layout => false
end
def new
@product_size = ProductSize.new()
end
def edit
@product_size = ProductSize.find(params[:id])
end
def show
@product_size = ProductSize.find(params[:id])
end
def create
@product_size = ProductSize.new(params.require(:product_size).permit!)
if @product_size.save
find_product_sizes
flash[:notice] = "La catégorie à été ajouté avec succès."
else
render :action => "new"
end
end
def update
@product_size = ProductSize.find(params[:id])
respond_to do |format|
if @product_size.update_attributes(params.require(:product_size).permit!)
flash[:notice] = "Le menu à été modifié avec succès."
if @reorder
format.js {
render :action => "update" }
else
format.js {
@product_size = ProductSize.find(@product_size.id)
render :action => "update_row" }
end
end
end
end
def destroy
@product_size = ProductSize.find(params[:id])
@product_size.destroy
find_product_sizes
flash[:notice] = "La catégorie à bien été supprimée."
end
protected
def find_product_sizes
@product_sizes = ProductSize.where("archived is null").order("position ASC")
end
end

View File

@ -0,0 +1,190 @@
# -*- encoding : utf-8 -*-
class Admin::ProductsController < ApplicationController
before_filter :auth_admin
layout "admin"
before_filter :find_products
before_filter :collection_for_parent_select, :except => [:index, :show]
def collection_for_parent_select
@categories_select = []
ProductCategory.where("parent_id is null").each do |product_category|
ancestry_options product_category
end
#ancestry_options(ProductCategory.joins(:product_category_langs).order('product_category_langs.name').unscoped.all) {|i| "#{'-' * i.ancestors.size} #{i.lang('fr').name}" }
end
def ancestry_options(item)
@categories_select << [('--' * item.ancestors.size).to_s+item.lang("fr").name,item.id]
item.children.each do |product_category|
ancestry_options product_category
end
end
def index
end
def reorder
i = 1
params[:products_ids].each do |id|
product = Product.find(id)
product.position = i
puts i
product.update_attributes :position => i
i = i + 1
end
flash[:success] = "Menus réorganisés avec succcès."
end
def cible
@products = Product.all
render :layout => false
end
def new
@product = Product.new()
@product.product_langs << ProductLang.new(:lang => LangSite.first.slug)
end
def edit
@product = Product.find(params[:id])
end
def stock
@product = Product.find(params[:id])
end
def show
@product = Product.find(params[:id])
end
def create
@product = Product.new(params.require(:product).permit!)
if @product.save
self.find_products
flash[:notice] = "La catégorie à été ajouté avec succès."
else
render :action => "new"
end
end
def update
@product = Product.find(params[:id])
@reorder = true if params[:reorder]
respond_to do |format|
if @product.update_attributes(params.require(:product).permit!)
#Product.all.each do |mi|
# mi.set_permalink
#end
flash[:notice] = "Le menu à été modifié avec succès."
format.html { redirect_to(admin_products_path(:parent_id => @product.parent_id)) }
if @reorder
format.js {
render :action => "update" }
else
format.js {
@product = Product.find(@product.id)
render :action => "update_row" }
end
else
flash[:error] = "Cet élément de menu n'a pas pu être déplacé. Vérifiez que son lien permanent n'éxiste pas déjà dans l'élément cible."
if @reorder
format.js { render :action => "update_reorder_failled" }
else
format.html { render :action => "edit" }
format.js { render :action => "edit" }
end
end
end
end
def destroy
@product = Product.find(params[:id])
@product.destroy
flash[:notice] = "Le produit à bien été supprimé."
end
protected
def find_products
@products = Product.not_archived.order("position ASC")
end
end

View File

@ -4,6 +4,28 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_filter :set_order
def set_order
if session[:product_order_id] && @product_order = ProductOrder.where(id: session[:product_order_id]).first
if @product_order.paid
@product_order = ProductOrder.new
@product_order.save
session[:product_order_id] = @product_order.id
end
else
@product_order = ProductOrder.new
@product_order.save
session[:product_order_id] = @product_order.id
end
end
def check_enabled
if (!@current_customer and current_admin and params[:admin])

View File

@ -0,0 +1,22 @@
# -*- encoding : utf-8 -*-
class Public::ProductCategoriesController < ApplicationController
layout "public"
def index
@products = Product.not_archived.where(:product_collection_id => nil)
end
def show
@product_category = ProductCategory.find(params[:id])
@product_category_lang = @product_category.lang(I18n.locale)
@image_bandeau = @product_category.image_file.file.url if @product_category.image_file
end
end

View File

@ -0,0 +1,77 @@
# -*- encoding : utf-8 -*-
class Public::ProductCustomersAuthsController < ApplicationController
layout "public"
def new
if params[:r] and params[:r] != ""
session[:before_auth_url] = nil
end
@no_search = true
params[:step] = "login"
if params[:for_annonce] and params[:for_annonce] != ""
session[:for_annonce] = true
else
session[:for_annonce] = nil
params[:for_annonce] =nil
end
@product_customer = ProductCustomer.new()
end
def create
params[:for_annonce] =nil if params[:for_annonce] == ""
params[:for_mail] =nil if params[:for_mail] == ""
@product_customer = ProductCustomer.new()
params[:step] = "login"
@no_search = true
user = ProductCustomer.find_by_email(params[:email])
if user && user.authenticate(params[:password])
#session[:forum_user_id] = user.id
if params[:remember_me]
cookies.permanent[:product_customer_auth_token] = user.token
else
cookies[:product_customer_auth_token] = user.token
end
user.last_sign_in_at = Time.now
user.last_sign_in_ip = user.current_sign_in_ip
user.current_sign_in_ip = request.remote_ip
user.save(:validate => false)
if session[:for_annonce]
session[:for_annonce] = nil
redirect_to new_public_annonce_path
elsif session[:before_auth_url]
url = session[:before_auth_url]
session[:before_auth_url] = nil
redirect_to url
else
redirect_to public_my_account_path
end
else
flash.now.alert = "Email ou mot de passe incorect"
render "new"
end
end
def logout
cookies.delete(:product_customer_auth_token)
session[:before_auth_url] = nil
redirect_to "/", notice: "Déconnecté."
end
end

View File

@ -0,0 +1,119 @@
class Public::ProductCustomersController < ApplicationController
layout "public"
before_filter :auth_product_customer, :except => [:new, :create, :confirm]
def index
@product_customers = ProductCustomer.all
end
def new
if params[:r] and params[:r] != ""
session[:before_auth_url] = nil
end
@no_search = true
if params[:for_annonce] and params[:for_annonce] != ""
session[:for_annonce] = true
params[:step] = "login"
else
session[:for_annonce] = nil
params[:for_annonce] = nil
end
params[:for_mail] =nil if params[:for_mail] == ""
@product_customer = ProductCustomer.new()
end
def edit
@product_customer = ProductCustomer.find(params[:id])
end
def create
@product_customer = ProductCustomer.new(params.require(:product_customer).permit!)
@product_customer.remote_ip = request.remote_ip
if @product_customer.save
#ProductCustomerMailer.confirm(@product_customer).deliver
@product_customer.authenticate(params[:password])
cookies[:product_customer_auth_token] = @product_customer.token
redirect_to particulars_public_product_orders_path
else
render :template => "public/product_customers_auths/new"
end
end
def confirm
@product_customer = ProductCustomer.find_by_token(params[:id])
@product_customer.enabled = true
@product_customer.save(:validate => false)
cookies[:product_customer_auth_token] = @product_customer.token
redirect_to public_my_account_path
#redirect_to "/"
end
def update
@product_customer = ProductCustomer.find(params[:id])
if params[:order]
@product_customer.force_address = true
end
if @product_customer == current_product_customer
if @product_customer.update_attributes(params.require(:product_customer).permit!)
if params[:order]
@product_customer = current_product_customer
@order.product_customer = @product_customer
render :template => "public/orders/new"
else
redirect_to public_my_account_path
end
else
if params[:order]
@order = Order.new(session[:order])
render :template => "public/orders/billing"
else
render :template => "public/my_account/edit_infos"
end
end
end
end
end

View File

@ -0,0 +1,72 @@
class Public::ProductOrderProductsController < ApplicationController
layout "public"
def create
#clear params
params[:product_order_product][:product_size_id] = nil if params[:product_order_product][:product_size_id] == ""
params[:product_order_product][:product_option_id] = nil if params[:product_order_product][:product_option_id] == ""
# Trying to retreive an existing pop in the current cart
existing_product_order_product = @product_order.product_order_products.where(:product_id => params[:product_order_product][:product_id], :product_size_id => params[:product_order_product][:product_size_id], :product_option_id => params[:product_order_product][:product_option_id]).first
# if the pop exists in the current cart, just increase the quantity
if existing_product_order_product
existing_product_order_product.qty += 1
existing_product_order_product.verify_qty
existing_product_order_product.save
else
@product_order_product = ProductOrderProduct.new(params.require(:product_order_product).permit(:product_id, :product_size_id, :product_option_id))
@product_order_product.qty = 1
@product_order_product.save
#@product_order_product.save
@product_order.product_order_products << @product_order_product
#@product_order_product.verify_qty
@product_order_product.save
end
# Make back a redirection
respond_to do |format|
format.js
format.html{
redirect_to :back
}
end
end
def delete
end
def update
@product_order_product = ProductOrderProduct.find(params[:id])
@product_order_product.qty = params[:product_order_product][:qty]
@product_order_product.verify_qty
@product_order_product.save
if @product_order_product.qty == 0
@product_order_product.destroy
end
# Make back a redirection
redirect_to :back
end
end

View File

@ -0,0 +1,498 @@
class Public::ProductOrdersController < ApplicationController
layout "public"
before_filter :cart_not_empty, :only => [:particulars, :particulars_save, :select_payment ,:select_payment_save, :select_fdp, :select_fdp_save ]
skip_before_filter :verify_authenticity_token, :only => [:payplug_ipn]
def get_reseaux
if session[:reseaux_id]
@reseaux = current_customer.reseauxes.find(session[:reseaux_id])
@reseaux_layout = true
end
end
def my_cart
get_reseaux
end
def vourcher
code = params[:vourcher_code]
if vc = VourcherCode.find_by_slug( code)
@product_order.vourcher_code = vc
@product_order.save
redirect_to :back
else
redirect_to :back, :notice => "Le code indiqué n'est pas valide"
end
end
def particulars
get_reseaux
@product_order = ProductOrder.find(session[:product_order_id])
if @product_order.paid
redirect_to new_public_product_order_path(:paid => true)
else
@product_order.customer = current_customer
#@product_order.product_customer.particular_bill.skip_validation = true
#@product_order.product_customer.particular_send.skip_validation = true
@product_order.save
#@product_order.product_customer.particular_bill.skip_validation = false
@product_order.product_order_payment_type_ok_id = 3 if !@product_order.product_order_payment_type_ok_id?
end
end
def particulars_save
@product_order = ProductOrder.find(session[:product_order_id])
#@product_order.product_customer.particular_bill.skip_validation = false
#@product_order.product_customer.particular_bill.skip_email = true
if !@product_order.particular_idem
@product_order.product_customer.particular_send.skip_validation = false
@product_order.product_customer.particular_send.skip_email = true
end
if @product_order.update_attributes(params.require(:product_order).permit!)
@product_order.particular_bill = @product_order.product_customer.particular_bill.dup
@product_order.particular_idem = @product_order.product_customer.particular_idem
if @product_order.particular_idem
@product_order.particular_send = @product_order.product_customer.particular_bill.dup
else
@product_order.product_customer.particular_send.skip_validation = false
@product_order.product_customer.particular_send.skip_email = true
@product_order.particular_send = @product_order.product_customer.particular_send.dup
end
@product_order.save
@product_order.archive_now
redirect_to select_fdp_public_product_orders_path()
else
render :action => :particulars
end
end
def select_fdp
@product_order = ProductOrder.find(session[:product_order_id])
@product_order.force_fdp_validation = true
redirect_to select_fdp_save_public_product_orders_path
end
def select_fdp_save
@product_order = ProductOrder.find(session[:product_order_id])
@product_order.force_fdp_validation = true
@product_order.product_fdp_id = 1
if @product_order.save
#if @product_order.update_attributes(params.require(:product_order).permit!)
redirect_to select_payment_public_product_orders_path()
else
render :action => :select_fdp
end
end
def select_payment
if params[:orderID]
flash.now[:error] = "Votre tentative de paiement par carte bancaire a échouée, ou vous avez annulé votre paiement, merci de bien vouloir essayer de nouveau ou changer de mode de paiement."
end
@product_order = ProductOrder.find(session[:product_order_id])
@product_order.archive_now
if !@product_order.product_order_payment_type_ok_id?
@product_order.product_order_payment_type_ok_id = 3
end
@product_order.force_payment = true
end
def cart_not_empty
@product_order = ProductOrder.find(session[:product_order_id])
if @product_order.product_order_products.count == 0
redirect_to public_my_cart_path
end
end
def select_payment_save
@product_order = ProductOrder.find(session[:product_order_id])
@product_order.archive_now
@product_order.force_payment
@product_order.force_fdp_validation = true
@product_order.force_cgv_validation = true
if @product_order.update_attributes(params.require(:product_order).permit!)
if @product_order.product_order_payment_type_ok_id == 3
redirect_to paid_by_ogone_public_product_orders_path()
else
if @product_order.product_order_payment_type_ok_id == 1
@product_order_payment = ProductOrderPayment.create(:product_order_payment_type_id => @product_order.product_order_payment_type_ok_id)
@product_order.product_order_payments << @product_order_payment
@product_order.product_order_payment_ok = @product_order_payment
end
@product_order.completed_finish = true
@product_order.save
@product_order.after_paid
ProductOrdersMails.confirmation_cheque(@product_order).deliver
session[:product_order_id] = nil
redirect_to payment_instructions_public_product_order_path(@product_order.token)
end
else
render :action => :select_payment
end
end
def payment_instructions
@product_order_ar = ProductOrder.find_by_token(params[:id])
end
def payplug_ipn
payplug_retrieve_payement(params[:id])
response = @response
puts response["metadata"]
@product_order = ProductOrder.find_by_token(response["metadata"]["product_order_id"])
@product_order_payment = ProductOrderPayment.find_by_token(response["metadata"]["product_order_payment_id"])
@product_order_payment.product_order_payment_type_id = 3
@product_order_payment.amount = response["amount"].to_i*0.01
@product_order_payment.payplug_payment_id = response["id"]
if response["card"]
@product_order_payment.payplug_card_id = response["card"]["id"]
@product_order_payment.payplug_card_expiry_month = response["card"]["exp_month"]
@product_order_payment.payplug_card_expiry_year = response["card"]["exp_year"]
@product_order_payment.payplug_card_last_number = response["card"]["last4"]
end
if response["is_paid"] == true || response["is_paid"] == "true"
@product_order_payment.paid_at = Time.now
@product_order.paid = true
@product_order.after_paid
ProductOrdersMails.confirmation_cb(@product_order).deliver
else
@product_order.paid = false
end
@product_order.product_order_payment_ok = @product_order_payment
@product_order.completed_finish = true
@product_order.save
@product_order_payment.save
render :inline => "ok"
end
def paid_by_payplug
@product_order = ProductOrder.find(session[:product_order_id])
if @product_order.paid
redirect_to select_payment_public_order_products_path(@product_order.id)
else
@product_order_payment = ProductOrderPayment.create(:product_order_payment_type_id => 3)
@product_order.product_order_payments << @product_order_payment
session[:product_order_payment_token] = @product_order_payment.token
puts "AAAAAAAAAAAAAA"
puts @product_order.particular_bill
puts "AAAAAAAAAAAAAA"
options = {
:amount => @product_order.total_ttc.to_i,
:email => @product_order.product_customer.email ,
:first_name => @product_order.particular_bill.firstname,
:last_name => @product_order.particular_bill.name,
:return_url => "http://#{HOSTNAME}"+paid_by_payplug_confirm_public_product_orders_path(:token => @product_order_payment.token),
:cancel_url => "http://#{HOSTNAME}"+select_payment_public_product_orders_path(),
:notification_url => "http://#{HOSTNAME}"+payplug_ipn_public_product_orders_path(),
:product_order_id => @product_order.token,
:product_order_payment_id => @product_order_payment.token,
:save_card => false,
}
payplug_init_payement(options)
response = @new_payplug_payment
@product_order_payment.payplug_payment_id = response["id"]
@product_order_payment.save
@product_order.save
redirect_to response["hosted_payment"]["payment_url"]
end
end
def paid_by_ogone
@product_order = ProductOrder.find(session[:product_order_id])
if @product_order.paid
redirect_to public_my_cart_path
else
@product_order_payment = ProductOrderPayment.create(:product_order_payment_type_id => 3)
@product_order.product_order_payments << @product_order_payment
session[:product_order_payment_token] = @product_order_payment.token
@ogone_options = {
:amount => @product_order.total_ttc,
:accept_url => "http://#{HOSTNAME}"+paid_by_ogone_confirm_public_product_orders_path(),
:decline_url => "http://#{HOSTNAME}"+select_payment_public_product_orders_path(),
:exception_url => "http://#{HOSTNAME}"+select_payment_public_product_orders_path(),
:cancel_url => "http://#{HOSTNAME}"+select_payment_public_product_orders_path(),
:orderid => @product_order_payment.token,
:PARAMVAR => "ogoneipnpo",
:PSPID => OgoneRails::pspid,
:currency => OgoneRails::currency,
:language => OgoneRails::language,
}
end
end
def paid_by_payplug_confirm
@product_order_payment = ProductOrderPayment.find_by_token(params[:token])
@product_order_ar = @product_order_payment.product_order
payplug_retrieve_payement @product_order_payment.payplug_payment_id
if @response and @response["is_paid"] == true# || response["is_paid"] == "true"
@paid = true
@product_order = ProductOrder.new
session[:product_order_id] = nil
else
redirect_to select_payment_public_product_orders_path(:paid_fail => 1)
end
end
def paid_by_ogone_confirm
@check = OgoneRails::CheckAuth.new( request )
if @check.valid?
@product_order_payment = ProductOrderPayment.find_by_token(params[:orderID])
@product_order = @product_order_payment.product_order
end
if !@product_order.paid
update_ogone_infos()
end
session[:product_order_id] = nil if @product_order.paid
@past_product_order = @product_order
@product_order = ProductOrder.new
if !@past_product_order.paid
redirect_to select_payment_public_product_orders_path(:orderID => "fail")
end
end
def ogone_ipn
update_ogone_infos()
render :inline => "ok"
end
protected
def update_ogone_infos
@check = OgoneRails::CheckAuth.new( request )
if @check.valid?
@product_order_payment = ProductOrderPayment.find_by_token(params[:orderID])
@product_order = @product_order_payment.product_order
@product_order_payment.product_order_payment_type_id = 3
@product_order_payment.amount = params[:amount].to_f
@product_order_payment.ogone_payid = params[:PAYID]
@product_order_payment.ogone_pm = params[:PM]
@product_order_payment.ogone_status = params[:STATUS]
@product_order_payment.ogone_acceptance = params[:ACCEPTANCE]
@product_order_payment.ogone_cardno = params[:CARDNO]
@product_order_payment.ogone_ed = params[:ED]
@product_order_payment.ogone_cn = params[:CN]
@product_order_payment.ogone_trxdate = params[:TRXDATE]
@product_order_payment.ogone_ncerror = params[:NCERROR]
@product_order_payment.ogone_brand = params[:BRAND]
@product_order_payment.ogone_subbrand = params[:SUBBRAND]
@product_order_payment.ogone_eci = params[:ECI]
@product_order_payment.ogone_ip = params[:IP]
@product_order_payment.ogone_alias = params[:ALIAS]
@product_order_payment.ogone_cb_expiration = Date.parse(params[:ED][2..3].to_s+"/"+params[:ED][0..1].to_s+"/01") if params[:ED]
if params["STATUS"].to_i == 9
if !@product_order.paid
@product_order_payment.paid_at = Time.now
@product_order.paid_at = @product_order_payment.paid_at
@product_order.paid = true
#@gen_recu = true
ProductOrdersMails.confirmation_cb(@product_order).deliver
#@product_order.check_newsletter
end
else
@product_order.paid = false
end
@product_order.completed_finish = true
@product_order_payment.save
@product_order.product_order_payment_ok = @product_order_payment if @product_order.paid
@product_order.product_customer.particular_bill.skip_email = true
@product_order.product_customer.particular_send.skip_email = true
@product_order.save(:validate => false)
@product_order.after_paid
if @gen_recu
#@product_order.generate_recu
end
end
end
end

View File

@ -0,0 +1,27 @@
# -*- encoding : utf-8 -*-
class Public::ProductsController < ApplicationController
layout "public"
def show
@product = Product.not_archived.find(params[:id])
@product_lang = @product.lang(I18n.locale)
@product_category = @product.product_category
@image_bandeau = @product.product_category.image_file.file.url if @product.product_category and @product.product_category.image_file
@image_bandeau = @product.product_collection.image_file.file.url if @product.product_collection and @product.product_collection.image_file
@reseaux = current_customer.reseauxes.find(@product.reseaux_id)
@reseaux_layout = true
session[:reseaux_id] =@reseaux.id
end
def index
@reseaux = current_customer.reseauxes.find(params[:reseaux_id])
@reseaux_layout = true
session[:reseaux_id] =@reseaux.id
end
end

View File

@ -11,8 +11,15 @@ class Public::ReseauxesController < ApplicationController
def show
#@reseaux = current_customer.own_reseauxes.find(params[:id])
@reseaux = Reseaux.find(params[:id])
@reseaux = current_customer.own_reseauxes.find(params[:id])
#@reseaux = Reseaux.find(params[:id])
end
def products
#@reseaux = Reseaux.find(params[:id])
end

17
app/helpers/document_line_helper.rb Executable file → Normal file
View File

@ -8,10 +8,23 @@ module DocumentLineHelper
def link_to_add_fields(name, f, association)
new_object = f.object.class.reflect_on_association(association).klass.new()
if association == :product_options
new_object.product_option_langs << ProductOptionLang.new(:lang => LangSite.first.slug)
end
fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
render("admin/"+association.to_s + "/form", :form => builder)
end
link_to_function(name, "add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\");")
link_to name,"#", :onclick => "add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\");return false;"
end
end

8
app/inputs/qi_image_select_input.rb Executable file → Normal file
View File

@ -7,11 +7,15 @@ class QiImageSelectInput < Formtastic::Inputs::TextInput
label_html +
template.content_tag(:fieldset, image_preview(method, options, r) + builder.hidden_field(method.to_s, input_html_options.merge!(:id => "input_"+r.to_s)) )
template.content_tag(:fieldset, image_preview(method, options, r) + remove_image_link(method, options, r) + builder.hidden_field(method.to_s, input_html_options.merge!(:id => "input_"+r.to_s)) )
end
def remove_image_link(method, options, r)
template.content_tag(:a, "Supprimer", :href => "#", :onclick => "remove_image_cible('"+r.to_s+"');return false;")
end
def manager_select_link(method, options, r)
template.content_tag(:a, "Modifier cette image", :href => "#", :onclick => "select_image_from_manager('"+r.to_s+"');return false;")
@ -19,7 +23,7 @@ class QiImageSelectInput < Formtastic::Inputs::TextInput
def image_preview(method, options,r)
if object.send("#{method}?") and ImageFile.exists?(object.send("#{method}"))
template.content_tag(:span, template.image_tag(object.image_file.file.large.medium.small.thumb.url, :id => "img_"+r.to_s, :onclick => "select_image_from_manager('"+r.to_s+"');return false;"), :class => "preview ")
template.content_tag(:span, template.image_tag(eval("object.#{method[0..-4]}.file.large.medium.small.thumb.url"), :id => "img_"+r.to_s, :onclick => "select_image_from_manager('"+r.to_s+"');return false;"), :class => "preview ")
else
template.content_tag(:span, template.image_tag("admin/default_image.png", :id => "img_"+r.to_s, :onclick => "select_image_from_manager('"+r.to_s+"');return false;"), :class => "preview ")
end

4
app/models/lang_site.rb Normal file
View File

@ -0,0 +1,4 @@
class LangSite < ActiveRecord::Base
has_many :menu_item_langs
end

182
app/models/product.rb Executable file
View File

@ -0,0 +1,182 @@
class Product < ActiveRecord::Base
belongs_to :reseaux
has_many :product_product_sizes, :dependent => :destroy
has_many :product_sizes, :through => :product_product_sizes
has_many :product_stocks, :dependent => :destroy
accepts_nested_attributes_for :product_stocks
has_many :product_langs, :dependent => :destroy
has_many :product_images, :dependent => :destroy
accepts_nested_attributes_for :product_langs
scope :not_archived, -> { where(:archived => 0).order("position ASC") }
validates :price_ht, :presence => true
after_save do
self.generate_stock
end
def in_stock
product_stocks.where("stock_th > 0").count
end
def generate_stock
ids_saveds = []
ids_new_saveds = []
if self.product_options.count > 0
self.product_options.each do |product_option|
if self.product_sizes.count > 0
self.product_sizes.each do |product_size|
if !(product_stock = self.product_stocks.where(:product_size_id => product_size.id, :product_option_id => product_option.id).first)
product_stock = self.product_stocks.create(:product_size_id => product_size.id, :product_option_id => product_option.id, :stock_th => 1, :stock => 1)
ids_new_saveds << product_stock.id
end
ids_saveds << product_stock.id
end
else
if !(product_stock = self.product_stocks.where(:product_size_id => nil, :product_option_id => product_option.id).first)
product_stock = self.product_stocks.create(:product_option_id => product_option.id, :stock_th => 1, :stock => 1)
ids_new_saveds << product_stock.id
end
ids_saveds << product_stock.id
end
end
else
if self.product_sizes.count > 0
self.product_sizes.each do |product_size|
if !(product_stock = self.product_stocks.where(:product_size_id => product_size.id, :product_option_id => nil).first)
product_stock = self.product_stocks.create(:product_size_id => product_size.id, :stock_th => 1, :stock => 1)
ids_new_saveds << product_stock.id
end
ids_saveds << product_stock.id
end
else
if !(product_stock = self.product_stocks.where(:product_size_id => nil, :product_option_id => nil).first)
product_stock = self.product_stocks.create(:stock_th => 1, :stock => 1)
ids_new_saveds << product_stock.id
end
ids_saveds << product_stock.id
end
end
self.product_stocks.where("id not IN (?)", ids_saveds).destroy_all
end
def product_options_in_stock_id
self.product_stocks.where("stock_th > 0").group(:product_option_id).map {|s| s.product_option_id}
end
def product_options_in_stock
self.product_options.where(:id => self.product_options_in_stock_id)
end
def product_sizes_in_stock_id(product_option_id=nil)
to_ids = self.product_stocks.where("stock_th > 0")
to_ids = to_ids.where(:product_option_id => product_option_id) if product_option_id != :all
to_ids.map {|s| s.product_size_id}
end
def product_sizes_in_stock(product_option_id=nil)
self.product_sizes.where(:id => self.product_sizes_in_stock_id(product_option_id))
end
def tva
0.0
end
def price_ttc
price_ht+(price_ht*self.tva)
end
def price_reduced_ttc
price_reduced_ht+(price_reduced_ht*self.tva)
end
def final_price_ht
if price_reduced_ht?
price_reduced_ht
else
price_ht
end
end
def final_price_ttc
final_price_ht+(final_price_ht*self.tva)
end
def lang(lang)
self.product_langs.find_by_lang(lang)
end
has_many :product_options, :dependent => :destroy
accepts_nested_attributes_for :product_options, :allow_destroy => true
#belongs_to :default_image, :class_name => "ProductImage"
def default_image
self.product_images.order(:position).first
end
belongs_to :product_collection
belongs_to :product_category
before_validation do
if self.product_collection_id
if !self.product_category or !self.product_category.product_collections.where(:id => self.product_collection_id)
self.product_collection_id = nil
end
end
end
end

34
app/models/product_category.rb Executable file
View File

@ -0,0 +1,34 @@
class ProductCategory < ActiveRecord::Base
acts_as_tree
has_many :product_category_langs, :dependent => :destroy
belongs_to :image_file
belongs_to :image_file_left, :class_name => "ImageFile"
belongs_to :image_file_right, :class_name => "ImageFile"
belongs_to :top_image, :class_name => "ImageFile"
accepts_nested_attributes_for :product_category_langs
has_many :product_collections, :dependent => :destroy
has_many :products, :dependent => :nullify
def lang(lang)
self.product_category_langs.find_by_lang(lang)
end
before_validation do
self.parent_id = nil if self.parent_id == 0
errors.add(:parent_id, 'doit être différent de la page actuelle') if parent_id == id and id != nil
if self.id
errors.add(:parent_id, 'attention la page parente à pour page parente celle-ci = boucle') if self.parent_id and self.id == ProductCategory.find(self.parent_id).parent_id
end
end
end

View File

@ -0,0 +1,26 @@
class ProductCategoryLang < ActiveRecord::Base
belongs_to :product_category
validates :name, :presence => true
validates :slug, :presence => true#, :uniqueness => {:scope => :lang}
attr_accessor :parent_id
before_validation do
self.slug = self.name.to_slug
if self.id?
parent_id_test = self.product_category.parent_id
else
parent_id_test = parent_id
end
search_test = ProductCategoryLang.joins(:product_category).where("lang = ?", self.lang).where("product_categories.parent_id "+(parent_id_test ? "=" : "IS")+" ? and slug = ? ", parent_id_test, self.slug)
search_test = search_test.where("product_categories.id != ?", self.id) if self.id
if search_test.first
#errors.add(:slug, 'est déjà utilisé')
end
end
end

View File

@ -0,0 +1,22 @@
class ProductCollection < ActiveRecord::Base
belongs_to :product_category
has_many :product_collection_langs, :dependent => :destroy
accepts_nested_attributes_for :product_collection_langs
has_many :products, :dependent => :nullify
belongs_to :image_file
before_validation do
self.product_collection_langs.each do |product_collection_lang|
product_collection_lang.product_category_id = self.product_category_id
end
end
def lang(lang)
self.product_collection_langs.find_by_lang(lang)
end
end

View File

@ -0,0 +1,25 @@
class ProductCollectionLang < ActiveRecord::Base
belongs_to :product_collection
validates :name, :presence => true
validates :slug, :presence => true#, :uniqueness => {:scope => [:lang]}
attr_accessor :product_category_id
before_validation do
self.slug = self.name.to_slug
search_test = ProductCollectionLang.joins(:product_collection).where("lang = ?", self.lang).where("product_collections.product_category_id = ? and slug = ? ", self.product_category_id, self.slug)
search_test = search_test.where("product_collections.id != ?", self.id) if self.id
if search_test.first
#errors.add(:slug, 'est déjà utilisé')
end
end
end

47
app/models/product_customer.rb Executable file
View File

@ -0,0 +1,47 @@
class ProductCustomer < ActiveRecord::Base
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
belongs_to :particular_bill, :class_name => "Particular"
accepts_nested_attributes_for :particular_bill
belongs_to :particular_send, :class_name => "Particular"
accepts_nested_attributes_for :particular_send
before_create do
self.generate_token
self.particular_bill = Particular.create(:particular_type => "facturation", :skip_validation => true)
self.particular_idem = true
self.particular_send = Particular.create(:particular_type => "expedition", :skip_validation => true)
end
def send_password_reset
begin
self[:reset_password_token] = SecureRandom.urlsafe_base64
end while ProductCustomer.exists?(:reset_password_token => self[:reset_password_token])
self.reset_password_sent_at = Time.now
self.save(:validate => false)
ProductCustomerMailer.password_reset(self).deliver
end
def generate_token
begin
self.token = SecureRandom.urlsafe_base64
puts self.token
end while ProductCustomer.exists?(:token => self.token)
end
end

View File

@ -0,0 +1,9 @@
class ProductFdp < ActiveRecord::Base
def name
self.fdp_description
end
end

11
app/models/product_image.rb Executable file
View File

@ -0,0 +1,11 @@
class ProductImage < ActiveRecord::Base
belongs_to :image_file
belongs_to :product
end

16
app/models/product_lang.rb Executable file
View File

@ -0,0 +1,16 @@
class ProductLang < ActiveRecord::Base
belongs_to :product_category
belongs_to :product_collection
#validates :slug, :uniqueness => {:scope => :lang}
before_validation do
self.slug = self.title.to_slug
errors.add(:title, 'doit être présent') if !title? and self.lang == "fr"
errors.add(:title, 'doit être présent') if !slug? and self.lang == "fr"
end
end

13
app/models/product_option.rb Executable file
View File

@ -0,0 +1,13 @@
class ProductOption < ActiveRecord::Base
belongs_to :product
has_many :product_option_langs, :dependent => :destroy
accepts_nested_attributes_for :product_option_langs
def lang(lang)
self.product_option_langs.find_by_lang(lang)
end
end

View File

@ -0,0 +1,3 @@
class ProductOptionLang < ActiveRecord::Base
belongs_to :product_option
end

294
app/models/product_order.rb Executable file
View File

@ -0,0 +1,294 @@
class ProductOrder < ActiveRecord::Base
belongs_to :customer
has_many :product_order_products
has_many :product_order_payments
belongs_to :product_order_payment_ok, :class_name => "ProductOrderPayment"
belongs_to :particular_bill, :class_name => "Particular"
accepts_nested_attributes_for :particular_bill
belongs_to :particular_send, :class_name => "Particular"
accepts_nested_attributes_for :particular_send
belongs_to :product_customer
accepts_nested_attributes_for :product_customer
belongs_to :product_fdp
belongs_to :product_fdp_archived, :class_name => "ProductFdp"
belongs_to :vourcher_code
belongs_to :vourcher_code_archived, :class_name => "VourcherCode"
validates :product_fdp, :presence => true, :if => :force_fdp_validation?
validates :cgv, :presence => {:message => "Vous devez accepter les conditions générales de vente."}, :if => :force_cgv_validation?
attr_accessor :force_fdp_validation, :force_payment, :force_cgv_validation
def prodons_country
countr = particular_bill.country
if countr.to_s == "FR"
else
c = ISO3166::Country.new countr
c.translation('fr')
end
end
def prodons_date
if self.paid_at?
date = self.paid_at
else
date = self.created_at
end
date.strftime("%d/%m/%Y")
end
def verify_paid_status
product_order_payments_to_count = self.product_order_payments.where("paid_at IS NOT NULL").order("paid_at DESC")
amount_paid = product_order_payments_to_count.sum(:amount)
if product_order_payments_to_count.first and amount_paid >= self.total_ttc
self.paid = true
self.paid_at = product_order_payments_to_count.first.paid_at
else
self.paid = nil
self.paid_at = nil
end
self.save
end
def total_ttc
total_articles + total_fdp - vourcher_reduction
end
def total_ttc_without_fdp
total_articles - vourcher_reduction
end
def vourcher_reduction
if self.vourcher_code and 1==1
(total_articles * (self.vourcher_code.percent / 100 )).round(2)
else
0.0
end
end
def archived_vourcher_reduction
if self.vourcher_code_archived and 1==1
(total_articles * (self.vourcher_code_archived.percent / 100 )).round(2)
else
0.0
end
end
def archived_total_ttc
archived_total_articles + archived_total_fdp - archived_vourcher_reduction
end
def archived_total_articles
archived_total = 0.0
product_order_products.each do |p|
archived_total += p.archived_final_price_ttc_with_qty
end
archived_total
end
def archived_total_fdp(fdp=self.product_fdp_archived)
if fdp
if self.archived_total_articles < fdp.price_max
fdp.price
else
0.0
end
else
0.0
end
end
def generate_bill_number
if !self.bill_number and self.paid and self.product_order_payment_type_ok_id == 3
self.paid_at = self.product_order_payment_ok.paid_at
self.bill_year = self.paid_at.year
last_number = 0
last_number = ProductOrder.where("paid_at is not null").where(:bill_year => self.bill_year ).order("bill_index DESC").first.bill_index if ProductOrder.where("paid_at is not null").where(:bill_year => self.bill_year ).first
self.bill_index = last_number+1
self.bill_number = "WEB"+self.bill_year.to_s+('%04d' % self.bill_index)
self.save(:validate => false)
end
end
def after_paid
self.product_order_products.each do |p|
p.update_stock_th
end
self.generate_bill_number
end
def after_ship
if !self.shiped
self.product_order_products.each do |p|
p.update_stock
end
self.shiped = true
self.shiped_at = Time.now
self.save
end
end
def archive_now
self.product_order_products.each do |p|
# Archive the product
p.archived_product = p.product.dup
p.archived_product.archived = true
p.verify_qty
p.save
# Archive product langs
p.product.product_langs.each do |pl|
dup_pl = pl.dup
dup_pl.archived = true
p.archived_product.product_langs << dup_pl
p.save
end
# Archive the pop size
if p.product_size
dup_product_size = p.product_size.dup
dup_product_size.archived = true
p.archived_product_size = dup_product_size
end
if p.product_option# Archive the pop option
dup_product_option = p.product_option.dup
dup_product_option.product_id = nil
dup_product_option.archived = true
p.archived_product_option = dup_product_option
p.product_option.product_option_langs.each do |pl|
p.archived_product_option.product_option_langs << pl.dup
p.save
end
end
# save
p.save
end
if self.product_fdp
a_product_fdp = self.product_fdp.dup
a_product_fdp.archived = true
a_product_fdp.save
self.product_fdp_archived_id = a_product_fdp.id
self.save
end
if self.vourcher_code
a_vourcher_code = self.vourcher_code.dup
a_vourcher_code.archived = true
a_vourcher_code.save
self.vourcher_code_archived_id = a_vourcher_code.id
self.save
end
end
def total_articles
total = 0.0
product_order_products.each do |p|
total += p.final_price_ttc_with_qty
end
total
end
def total_fdp(fdp=self.product_fdp)
if fdp
if self.total_ttc_without_fdp < fdp.price_max
fdp.price
else
0.0
end
else
0.0
end
end
def force_fdp_validation?
true if self.force_fdp_validation
end
def force_cgv_validation?
true if self.force_cgv_validation
end
before_validation do
self.verify
end
protected
def verify(size=16)
if !self.token
s = ""
size.times { s << (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }
self.token = s
end
end
end

View File

@ -0,0 +1,21 @@
class ProductOrderPayment < ActiveRecord::Base
belongs_to :product_order
before_validation do
self.verify
end
protected
def verify(size=16)
if !self.token
s = ""
size.times { s << (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }
self.token = s
end
end
end

View File

@ -0,0 +1,74 @@
class ProductOrderProduct < ActiveRecord::Base
belongs_to :order
belongs_to :product
belongs_to :product_size
belongs_to :product_option
belongs_to :archived_product, class_name: "Product"
belongs_to :archived_product_size, class_name: "ProductSize"
belongs_to :archived_product_option, class_name: "ProductOption"
def price_ttc_with_qty
qty.to_f * product.price_ttc.to_f
end
def final_price_ttc_with_qty
qty.to_f * product.final_price_ttc.to_f
end
def archived_price_ttc_with_qty
if archived_product
qty.to_f * archived_product.price_ttc.to_f
else
0
end
end
def archived_final_price_ttc_with_qty
if archived_product
qty.to_f * archived_product.final_price_ttc.to_f
else
0
end
end
def verify_qty
product_stock_t = self.product.product_stocks.where(:product_option_id => self.product_option_id,:product_size_id => self.product_size_id).first
if product_stock_t and self.qty > product_stock_t.stock_th
self.qty = product_stock_t.stock_th
elsif !product_stock_t
self.qty = 0
end
end
def update_stock_th
product_stock_t = self.product.product_stocks.where(:product_option_id => self.product_option_id,:product_size_id => self.product_size_id).first
if product_stock_t
product_stock_t.stock_th = product_stock_t.stock_th - self.qty
product_stock_t.save
end
end
def update_stock
product_stock = self.product.product_stocks.where(:product_option_id => self.product_option_id,:product_size_id => self.product_size_id).first
if product_stock
product_stock.stock = product_stock.stock - self.qty
product_stock.save
end
end
end

View File

@ -0,0 +1,4 @@
class ProductProductSize < ActiveRecord::Base
belongs_to :product
belongs_to :product_size
end

5
app/models/product_size.rb Executable file
View File

@ -0,0 +1,5 @@
class ProductSize < ActiveRecord::Base
has_many :product_product_sizes
has_many :products, :through => :product_product_sizes
end

View File

@ -0,0 +1,5 @@
class ProductStock < ActiveRecord::Base
belongs_to :product
belongs_to :product_size
belongs_to :product_option
end

View File

@ -1,6 +1,9 @@
class Reseaux < ActiveRecord::Base
belongs_to :chef_reseau, :class_name => "Customer"
belongs_to :logo_image_file, :class_name => "ImageFile"
belongs_to :background_image_file, :class_name => "ImageFile"
has_many :reseaux_customers
has_many :customers, :through => :reseaux_customers

View File

@ -0,0 +1,25 @@
= semantic_form_for [:admin,@product_category], :remote => true do |form|
= form.input :parent_id,:as => :hidden
.content
= form.input :image_file_id, :label => "Image", :as => :qi_image_select
=form.semantic_fields_for :product_category_langs do |product_category_lang|
= product_category_lang.inputs do
= product_category_lang.hidden_field :id
= product_category_lang.hidden_field :parent_id
= product_category_lang.hidden_field :lang
= product_category_lang.input :name, :as => :string, :label => "Nom (#{product_category_lang.object.lang}) :"
= product_category_lang.input :description, :label => "Description (#{product_category_lang.object.lang}) :"
= form.input :image_file_left_id, :label => "Image gauche :", :as => :qi_image_select
= form.input :image_file_right_id, :label => "Image droite :", :as => :qi_image_select
= form.input :top_image_id, :label => "Grande image du haut :", :as => :qi_image_select
= form.input :color, :label => "Couleur :"
.actions
= form.submit "Sauvegarder"

View File

@ -0,0 +1,46 @@
#product_category_index
%ul.breadcrumb
= link_to 'Ajouter une catégorie', new_admin_product_category_path(:parent_id => params[:parent_id]), :class => "btn btn-primary",:remote => true, :style => "float:right;"
%li
-if @product_category_parent
-@product_category_parent.ancestors.reverse.each do |product_category|
%li
=link_to product_category.lang("fr").name, admin_product_categories_path( :parent_id =>product_category.id), :remote => true
%span.divider /
%li
=@product_category_parent.lang("fr").name
%span.divider /
%p{:style => "clear:both;"}
-if @product_category_parent
.prevv_folder.receptable{:data => { :param_test => true, :parent_id => (@product_category_parent.parent ? @product_category_parent.parent.id : "no-menu-selected")} }
=ic(:"folder-o")
=link_to "...", admin_product_categories_path( :parent_id => (@product_category_parent.parent ? @product_category_parent.parent.id : nil)), :remote => true
#sortable_product_category{:data => {:parent_id => (@product_category_parent ? @product_category_parent.id : "")} }
-if @product_categories.size > 0
=render @product_categories
-else
.no_product_categories
Il n'y a aucun éléments de menu actuellement.
:javascript
init_product_categories_list();

View File

@ -0,0 +1,31 @@
#product_category_row.product_category_row.row{:id => product_category.id,:"data-menu-item-id" => product_category.id}
.col-xs-2.receptable{:data => {:parent_id => product_category.id}}
.btn-group
%span.handle.btn=i(:arrows, :icon => false)
=link_to (product_category.children.size > 0 ? i(:"folder", :icon => false) : i(:"folder-o", :icon => false) )+(product_category.children.size if product_category.children.size > 0).to_s, admin_product_categories_path(:parent_id => product_category.id), :remote => true, :class => "btn"
.col-xs-4
=product_category.lang("fr").name
(
=product_category.product_collections.count
collections
)
.col-xs-4
=#link_to "/"+product_category.permalink+".html", product_category_path(:url => product_category.url)
.col-xs-2.actions{:style => "text-align:right;"}
= link_to i(:"trash-o"), [:admin, product_category], :data =>{:remote => true, :confirm => 'Voulez-vous vraiment supprimer cet élément de menu ?'}, :method => :delete #, if current_admin.super_admin? || !product_category.super_admin
= link_to i(:eye), [:admin, product_category]
= link_to i(:pencil), edit_admin_product_category_path(product_category), :data => {:remote => true}

View File

@ -0,0 +1,6 @@
-Event.all.each do |event|
%h4
=event.title
= link_to i(:check_alt, :gray_light,12), "#",:onclick => "manager_send_cible("+event.id.to_s+", 'Folder', '#{escape_javascript(event.cible_name)}');return false;" if params[:manager]

View File

@ -0,0 +1,4 @@
close_pane_hover();
$('#product_category_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>");

View File

@ -0,0 +1,4 @@
$('#product_category_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>");
<%= flash_js %>

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600);

View File

@ -0,0 +1,13 @@
.qi_header
%h1
Boutique
%span
Liste des catégories
.qi_row
.qi_pannel.qi_plain.padding
=render :partial => "index_block"

View File

@ -0,0 +1,13 @@
if($('#product_category_index').length > 0){
$('#product_category_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>");
}
else{
$('body').html("<%= escape_javascript(render(:template => 'admin/product_categories/index.html.haml')) %>");
}

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600);

View File

@ -0,0 +1,4 @@
$('#product_category_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>");
<%= flash_js %>

View File

@ -0,0 +1,25 @@
.qi_header
%h1
Boutique
%span
Détail de la catégorie :
=@product_category.lang("fr").name
.qi_row
.qi_pannel.qi_plain.padding
=simple_format @product_category.lang("fr").description
.sub_header
.right= link_to 'Ajouter une collection', new_admin_product_category_product_collection_path(@product_category), :class => "btn btn-primary", :remote => true
%h2 Collections
%table.table#product_collection_index=render @product_category.product_collections

View File

@ -0,0 +1,4 @@
$('#product_category_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>");
close_pane_hover();
<%= flash_js %>

View File

@ -0,0 +1,2 @@
close_pane_hover();
$('#product_category_row_<%= @product_category.id %>').replaceWith("<%= escape_javascript(render(@product_category))%>");

View File

@ -0,0 +1,23 @@
= semantic_form_for [:admin, @product_category,@product_collection], :remote => true do |form|
= form.input :product_category_id, :as => :hidden
.content
=form.semantic_fields_for :product_collection_langs do |product_collection_lang|
= product_collection_lang.inputs do
= product_collection_lang.hidden_field :id
= product_collection_lang.hidden_field :lang
= product_collection_lang.input :name, :as => :string, :label => "Nom (#{product_collection_lang.object.lang}) :"
= product_collection_lang.input :description, :as => :string, :label => "Description (#{product_collection_lang.object.lang}) :"
= form.input :color, :label => "Couleur :"
.actions
= form.submit "Sauvegarder"

View File

@ -0,0 +1,53 @@
#product_collection_index
%ul.breadcrumb
= link_to 'Ajouter une catégorie', new_admin_product_collection_path(:parent_id => params[:parent_id]), :class => "btn btn-primary",:remote => true, :style => "float:right;"
%li
-if @product_collection_parent
-@product_collection_parent.ancestors.reverse.each do |product_collection|
%li
=link_to product_collection.lang("fr").name, admin_product_collections_path( :parent_id =>product_collection.id), :remote => true
%span.divider /
%li
=@product_collection_parent.lang("fr").name
%span.divider /
%p{:style => "clear:both;"}
-if @product_collection_parent
.prevv_folder.receptable{:data => { :param_test => true, :parent_id => (@product_collection_parent.parent ? @product_collection_parent.parent.id : "no-menu-selected")} }
.row-fluid
.span1
=i(:"folder-close", :icon => false)
.span2=link_to "...", admin_product_collections_path( :parent_id => (@product_collection_parent.parent ? @product_collection_parent.parent.id : nil)), :remote => true
.span3
.span4
.span2.actions
#sortable_product_collection{:data => {:parent_id => (@product_collection_parent ? @product_collection_parent.id : "")} }
-if @product_collections.size > 0
=render @product_collections
-else
.no_product_collections
Il n'y a aucun éléments de menu actuellement.
:javascript
init_product_collections_list();

View File

@ -0,0 +1,15 @@
%tr#product_collection_row.product_collection_row{:id => product_collection.id}
%td
=product_collection.lang("fr").name
%td.actions
= link_to i(:"trash-o"), [:admin, product_collection.product_category,product_collection], :data =>{:remote => true, :confirm => 'Voulez-vous vraiment supprimer cet élément de menu ?'}, :method => :delete #, if current_admin.super_admin? || !product_collection.super_admin
= link_to i(:eye), [:admin, product_collection.product_category, product_collection]
= link_to i(:pencil), edit_admin_product_category_product_collection_path(product_collection.product_category,product_collection), :data => {:remote => true}

View File

@ -0,0 +1,6 @@
-Event.all.each do |event|
%h4
=event.title
= link_to i(:check_alt, :gray_light,12), "#",:onclick => "manager_send_cible("+event.id.to_s+", 'Folder', '#{escape_javascript(event.cible_name)}');return false;" if params[:manager]

View File

@ -0,0 +1,5 @@
$('#product_collection_index').html("<%= escape_javascript(render(@product_category.product_collections)) %>");
close_pane_hover();

View File

@ -0,0 +1,2 @@
$('#product_collection_row_<%= @product_collection.id %>').remove();
<%= flash_js %>

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600);

View File

@ -0,0 +1,6 @@
.header
.right= link_to 'Ajouter une collection', new_admin_product_category_product_collection_path(@product_category), :class => "btn", :remote => true
%h1 Liste des collections
.grid_12
=render :partial => "index_block"

View File

@ -0,0 +1,13 @@
if($('#product_collection_index').length > 0){
$('#product_collection_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>");
}
else{
$('body').html("<%= escape_javascript(render(:template => 'admin/product_collections/index.html.haml')) %>");
}

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600);

View File

@ -0,0 +1,4 @@
$('#product_collection_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>");
<%= flash_js %>

View File

@ -0,0 +1,2 @@
%h1
=@product_collection.lang("fr").name

View File

@ -0,0 +1,4 @@
$('#product_collection_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>");
close_pane_hover();
<%= flash_js %>

View File

@ -0,0 +1,2 @@
close_pane_hover();
$('#product_collection_row_<%= @product_collection.id %>').replaceWith("<%= escape_javascript(render(@product_collection))%>");

View File

@ -0,0 +1,19 @@
= semantic_form_for [:portlet, @product_image], :remote => true do |form|
.content
%h3 Modifier les infos
= form.inputs do
= form.input :title, :label => "Titre :"
= form.input :tags, :label => "Tags :"
= form.input :description, :label => "Description :", :as => :text, :input_html => {:class => "text_editor"}
.actions
=form.submit "Sauvegarder", :class => "btn btn-primary"

View File

@ -0,0 +1,9 @@
-if product_image.image_file
.product_image.image_square#product_image{:id => product_image.id, :data => { :title => product_image.title , :description => product_image.description, :id => product_image.id} }
.img{:style => "background-image : url('#{product_image.image_file.file.large.medium.small.thumb.url}');"}
.actions
=link_to i(:"trash-o"), [:admin, product_image], :data => {:confirm => 'Voulez-vous vraiment supprimer cette image ?'}, :method => :delete, :remote => true
=#link_to i(:pencil), edit_admin_product_image_path(product_image), :remote => true

View File

@ -0,0 +1 @@
$('#product_images').prepend("<%= escape_javascript(render(@product_images)) %>");

View File

@ -0,0 +1,4 @@
$("#product_image_<%= @product_image.id.to_s %>").fadeOut(500).delay(6000).remove();
<%= flash_js %>

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>");

View File

View File

@ -0,0 +1,5 @@
close_pane_hover();
$('#product_image_<%= @product_image.id %>').effect("highlight", 1000);
<%= flash_js %>

View File

@ -0,0 +1,15 @@
.field
.product_option_form
%hr
.product_option
=form.semantic_fields_for :product_option_langs do |product_option_lang|
= product_option_lang.inputs do
= product_option_lang.hidden_field :id
= product_option_lang.hidden_field :lang
= product_option_lang.input :name, :as => :string, :label => product_option_lang.object.lang
= link_to_remove_fields i(:"trash-o"), form

View File

@ -0,0 +1,11 @@
= semantic_form_for [:admin,@product_order_payment], :remote => true do |form|
.content
=form.input :paid_at, :label => "Payée le ?", :as => :qi_date_picker
=form.input :amount, :label => "Montant : "
.actions
= form.submit "Sauvegarder", :class => "btn btn-primary"

View File

@ -0,0 +1,20 @@
%tr
%td=product_order_payment.token
%td=l product_order_payment.paid_at if product_order_payment.paid_at?
%td
-if product_order_payment.product_order_payment_type_id == 3
CB
-elsif product_order_payment.product_order_payment_type_id == 1
Chèque
%td=product_order_payment.ogone_payid
%td=product_order_payment.ogone_status
%td=product_order_payment.ogone_ncerror
%td
=product_order_payment.ogone_cardno
%td= number_to_currency product_order_payment.amount if product_order_payment.amount
%td.actions
-if product_order_payment.product_order_payment_type_id == 1
=link_to i(:pencil), edit_admin_product_order_payment_path(product_order_payment), :remote => true

View File

@ -0,0 +1,4 @@
$('#product_orders').html("<%= escape_javascript(render(:partial => "index_block")) %>");
close_pane_hover();

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600);

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600);

View File

@ -0,0 +1,4 @@
$('#product_order_payments').html("<%= escape_javascript(render(@product_order_payment.product_order.product_order_payments)) %>");
close_pane_hover();
<%= flash_js %>

View File

@ -0,0 +1,21 @@
%tr
%td{:style => "width:280px"}
=image_tag product_order_product.product.default_image.image_file.file.large.medium.small.thumb.url if product_order_product.product and product_order_product.product.default_image
%td
-if product_order_product.product
=link_to admin_product_path(product_order_product.product) do
= product_order_product.archived_product.lang(:fr).title
-else
= product_order_product.archived_product.lang(:fr).title
%td
= product_order_product.archived_product_size.name if product_order_product.archived_product_size
%td
= product_order_product.archived_product_option.lang(I18n.locale).name if product_order_product.archived_product_option
%td
= number_to_currency(product_order_product.archived_product.final_price_ttc.to_f, locale: :fr) if product_order_product.archived_product
%td
=product_order_product.qty
%td
= number_to_currency(product_order_product.archived_final_price_ttc_with_qty, locale: :fr) if product_order_product.archived_product

View File

@ -0,0 +1,10 @@
= semantic_form_for [:admin,@product_order], :remote => true do |form|
.content
=form.input :paid, :label => "Payée ?"
=form.input :paid_at, :label => "Payée le ?", :as => :qi_datepicker
.actions
= form.submit "Sauvegarder", :class => "btn btn-primary"

View File

@ -0,0 +1,17 @@
%table.table#product_orders
%tr
%th ID
%th
Nom
%th Pays d'exp.
%th
Paiement
%th
Payé ?
%th
Total
%th
Numéro facture
%th
=render @product_orders

View File

@ -0,0 +1,46 @@
%tr#product_order_row.product_order_row{:id => product_order.id, :class => ("success" if product_order.shiped)}
%td
=product_order.id
%td
-if product_order.particular_bill
=product_order.particular_bill.name
=product_order.particular_bill.firstname
%td
=product_order.particular_send.country
%td
-if product_order.product_order_payment_type_ok_id == 3
CB
-elsif product_order.product_order_payment_type_ok_id == 1
Chèque
%td
="oui" if product_order.paid
%td
=number_to_currency product_order.archived_total_ttc
%td
-if product_order.paid
=link_to product_order.bill_number, bill_admin_product_order_path(product_order), :target => "_blank"
%td.actions
=# link_to i(:"trash-o"), [:admin, product_order], :data =>{:remote => true, :confirm => 'Voulez-vous vraiment supprimer cet élément de menu ?'}, :method => :delete #, if current_admin.super_admin? || !product_order.super_admin
= link_to i(:eye), [:admin, product_order]
=# link_to i(:pencil), edit_admin_product_order_path(product_order), :data => {:remote => true}

View File

@ -0,0 +1,232 @@
!!!
%html
%head
%meta{:"http-equiv" => "Content-Type", :content=>"text/html; charset=UTF-8"}
%meta{:name=>"viewport", :content=>"width=device-width,initial-scale=1"}
:css
body{
font-size:11pt;
padding :0px;
margin:0px;
background-color: transparent;
font-family:"Arial" ;
padding:1cm;
}
#main{
//margin-left:4.2cm;
}
td, th{
//border:1px solid black;
padding:5px;
vertical-align:top;
}
th{
font-weight:normal;
border-bottom:1px solid gray;
text-align:left;
}
table{
border-collapse:collapse;
}
tr{
page-break-inside:avoid;
}
#bottom{
page-break-inside:avoid;
}
.right{
text-align:right;
}
.line p{
margin:0px;
}
.description{
padding-top:2pt;
display:block;
}
.bot_separate{
height:50pt;
}
.upcase{
text-transform:uppercase;
}
h3{
font-size:1em;
margin-bottom:5px;
font-weight:normal;
}
%body
#main
%div{:style => "position:absolute;top:1cm;right:1cm;text-align:right;"}
Facture n°
=@product_order.bill_number
%br
=l @product_order.paid_at, :format => :date
%div{:style => "height:300px;"}
%table.table{:style => "position:absolute;right:1cm;top:220px"}
%tr
%td{:style => "min-width:6cm;"}
%h3 Adresse de facturation
%strong
=@product_order.particular_bill.firstname
=@product_order.particular_bill.name
%br
=@product_order.particular_bill.address_2
-if @product_order.particular_bill.address_3?
%br
=@product_order.particular_bill.address_3
%br
=@product_order.particular_bill.cp
=@product_order.particular_bill.city
%br
=@product_order.particular_bill.country
%td
%h3 Adresse de livraison
%strong
=@product_order.particular_send.firstname
=@product_order.particular_send.name
%br
=@product_order.particular_send.address_2
-if @product_order.particular_send.address_3?
%br
=@product_order.particular_send.address_3
%br
=@product_order.particular_send.cp
=@product_order.particular_send.city
%br
=@product_order.particular_send.country
%table.table{:style => "width:100%;margin:1cm 0;"}
%tr
%th
Description
%th
Taille
%th
Option
%th
Qté
%th
Unitaire
%th
Montant
-@product_order.product_order_products.order(:product_id).each do |product_order_product|
%tr
%td
= product_order_product.archived_product.lang(:fr).title
%td
= product_order_product.archived_product_size.name if product_order_product.archived_product_size
%td
= product_order_product.archived_product_option.lang(I18n.locale).name if product_order_product.archived_product_option
%td
= number_to_currency(product_order_product.archived_product.final_price_ttc.to_f, locale: :fr) if product_order_product.archived_product
%td
=product_order_product.qty
%td
= number_to_currency(product_order_product.archived_final_price_ttc_with_qty, locale: :fr) if product_order_product.archived_product
%tr
%td{:colspan => 4, :style => "border:0;"}
%td Total :
%td= number_to_currency(@product_order.archived_total_articles, locale: :fr)
-if @product_order.vourcher_code_archived
%tr
%td{:colspan => 4, :style => "border:0;"}
%td
=qit "Code réduction tableau", "Code de réduction "
="("+@product_order.vourcher_code_archived.slug+") :"
%td
="-"
=number_to_currency @product_order.archived_vourcher_reduction, locale: :fr
%tr
%td{:colspan => 4, :style => "border:0;"}
%td Frais de port :
%td= number_to_currency(@product_order.archived_total_fdp, locale: :fr)
%tr
%td{:colspan => 4, :style => "border:0;"}
%td
%strong Total :
%td
%strong
= number_to_currency(@product_order.archived_total_ttc, locale: :fr)
%p
Mode de paiment :
-if @product_order.product_order_payment_type_ok_id == 3
CB
-elsif @product_order.product_order_payment_type_ok_id == 1
Chèque
%br
%p
Association à but non lucratif, non soumise à la TVA
%br
TVA non applicable, article 293B du code général des impots
<!---
.fdp
%table.table
%tr
%td
=@product_order.product_fdp_archived.fdp_description
%td
=number_to_currency @product_order.product_fdp_archived.price
="--->"

View File

@ -0,0 +1,4 @@
$('#product_orders').html("<%= escape_javascript(render(:partial => "index_block")) %>");
close_pane_hover();

View File

@ -0,0 +1,2 @@
$('#product_order_row_<%= @product_order.id %>').remove();
<%= flash_js %>

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600);

View File

@ -0,0 +1,13 @@
.qi_header
.right=# link_to 'Ajouter une taille', new_admin_product_size_path, :class => "btn btn-primary", :remote => true
%h1
Boutique
%span
Liste des commandes
.qi_row
.qi_pannel.qi_plain.padding
=render :partial => "index_block"

View File

@ -0,0 +1,13 @@
if($('#product_order_index').length > 0){
$('#product_order_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>");
}
else{
$('body').html("<%= escape_javascript(render(:template => 'admin/product_orders/index.html.haml')) %>");
}

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600);

View File

@ -0,0 +1,104 @@
.qi_header
.right=# link_to 'Ajouter une taille', new_admin_product_size_path, :class => "btn btn-primary", :remote => true
%h1
Boutique
%span
Détail de la commande
="#"+@product_order.id.to_s
.qi_row
.qi_pannel.qi_plain.padding
%p
Payée ?
="oui" if @product_order.paid
=link_to "Facture", bill_admin_product_order_path(@product_order)
-if @product_order.paid
-if !@product_order.shiped
%p
=link_to ic(:truck)+" Signaler comme expédiée", ship_admin_product_order_path(@product_order), :data => {:confirm => "Les stocks seront mis à jour"}, :class => "btn btn-success"
-else
%p
Envoyée le
=l @product_order.shiped_at if @product_order.shiped_at?
%p
Mode de paiment :
-if @product_order.product_order_payment_type_ok_id == 3
CB
-elsif @product_order.product_order_payment_type_ok_id == 1
Chèque
%table.table
%tr
%td
%h3 Adresse de facturation
=render @product_order.particular_bill if @product_order.particular_bill
%td
%h3 Adresse de livraison
=render @product_order.particular_send if @product_order.particular_send
%table.table
=render @product_order.product_order_products.order(:product_id)
%tr
%td{:colspan => 5, :style => "border:0;"}
%td Total :
%td= number_to_currency(@product_order.archived_total_articles, locale: :fr)
-if @product_order.vourcher_code_archived
%tr
%td{:colspan => 5, :style => "border:0;"}
%td
=qit "Code réduction tableau", "Code de réduction "
="("+@product_order.vourcher_code_archived.slug+") :"
%td
="-"
=number_to_currency @product_order.archived_vourcher_reduction, locale: :fr
%tr
%td{:colspan => 5, :style => "border:0;"}
%td Frais de port :
%td= number_to_currency(@product_order.archived_total_fdp, locale: :fr)
%tr
%td{:colspan => 5, :style => "border:0;"}
%td
%strong Total :
%td
%strong
= number_to_currency(@product_order.archived_total_ttc, locale: :fr)
.fdp
%table.table
%tr
%td
=@product_order.product_fdp_archived.fdp_description
%td
=number_to_currency @product_order.product_fdp_archived.price
%br
%table.table
%thead
%tr
%th Identifiant paiement
%th Date de paiement
%th Type de paiement
%th ID Ogone
%th Status Ogone
%th Erreur Ogone
%th N°Carte
%th Montant
%th
%tbody#product_order_payments
=render @product_order.product_order_payments.order("created_at DESC")

View File

@ -0,0 +1,4 @@
$('#product_order_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>");
close_pane_hover();
<%= flash_js %>

View File

@ -0,0 +1,2 @@
$('#product_order_row_<%= @product_order.id %>').replaceWith("<%= escape_javascript(render(@product_order))%>");
close_pane_hover();

View File

@ -0,0 +1,7 @@
= semantic_form_for [:admin,@product_size], :remote => true do |form|
.content
= form.input :name
.actions
= form.submit "Sauvegarder"

View File

@ -0,0 +1,12 @@
%tr#product_size.product_size{:id => product_size.id}
%td=product_size.name
%td.actions
= link_to i(:"trash-o"), [:admin, product_size], :data =>{:remote => true, :confirm => 'Voulez-vous vraiment supprimer cette taille ? Elle sera supprimée de tous les produits qui la contenait'}, :method => :delete
= link_to i(:pencil), edit_admin_product_size_path(product_size), :data => {:remote => true}

View File

@ -0,0 +1,4 @@
close_pane_hover();
$('#product_sizes').html("<%= escape_javascript(render(@product_sizes)) %>");

View File

@ -0,0 +1,5 @@
$('#product_size_<%= @product_size.id %>').remove();
<%= flash_js %>

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600);

Some files were not shown because too many files have changed in this diff Show More