diff --git a/app/assets/javascripts/manager.js b/app/assets/javascripts/manager.js index 2cc2489..14e60b3 100755 --- a/app/assets/javascripts/manager.js +++ b/app/assets/javascripts/manager.js @@ -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(){ diff --git a/app/assets/stylesheets/public.scss b/app/assets/stylesheets/public.scss index da4f2b5..8e296b4 100755 --- a/app/assets/stylesheets/public.scss +++ b/app/assets/stylesheets/public.scss @@ -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{ diff --git a/app/assets/stylesheets/public/boutique.css.scss b/app/assets/stylesheets/public/boutique.css.scss new file mode 100644 index 0000000..0be8d28 --- /dev/null +++ b/app/assets/stylesheets/public/boutique.css.scss @@ -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; + } +} \ No newline at end of file diff --git a/app/controllers/admin/product_categories_controller.rb b/app/controllers/admin/product_categories_controller.rb new file mode 100755 index 0000000..b4f1b41 --- /dev/null +++ b/app/controllers/admin/product_categories_controller.rb @@ -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 diff --git a/app/controllers/admin/product_collections_controller.rb b/app/controllers/admin/product_collections_controller.rb new file mode 100755 index 0000000..048f6e2 --- /dev/null +++ b/app/controllers/admin/product_collections_controller.rb @@ -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 diff --git a/app/controllers/admin/product_images_controller.rb b/app/controllers/admin/product_images_controller.rb new file mode 100755 index 0000000..d9b9ab7 --- /dev/null +++ b/app/controllers/admin/product_images_controller.rb @@ -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 diff --git a/app/controllers/admin/product_order_payments_controller.rb b/app/controllers/admin/product_order_payments_controller.rb new file mode 100755 index 0000000..703e178 --- /dev/null +++ b/app/controllers/admin/product_order_payments_controller.rb @@ -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 diff --git a/app/controllers/admin/product_orders_controller.rb b/app/controllers/admin/product_orders_controller.rb new file mode 100755 index 0000000..7f86e45 --- /dev/null +++ b/app/controllers/admin/product_orders_controller.rb @@ -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 diff --git a/app/controllers/admin/product_sizes_controller.rb b/app/controllers/admin/product_sizes_controller.rb new file mode 100755 index 0000000..b5be386 --- /dev/null +++ b/app/controllers/admin/product_sizes_controller.rb @@ -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 diff --git a/app/controllers/admin/products_controller.rb b/app/controllers/admin/products_controller.rb new file mode 100755 index 0000000..7fb8234 --- /dev/null +++ b/app/controllers/admin/products_controller.rb @@ -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 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 13118ca..37cec7d 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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]) diff --git a/app/controllers/public/product_categories_controller.rb b/app/controllers/public/product_categories_controller.rb new file mode 100755 index 0000000..0c53aa5 --- /dev/null +++ b/app/controllers/public/product_categories_controller.rb @@ -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 diff --git a/app/controllers/public/product_customers_auths_controller.rb b/app/controllers/public/product_customers_auths_controller.rb new file mode 100755 index 0000000..8d64d48 --- /dev/null +++ b/app/controllers/public/product_customers_auths_controller.rb @@ -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 diff --git a/app/controllers/public/product_customers_controller.rb b/app/controllers/public/product_customers_controller.rb new file mode 100755 index 0000000..9036dff --- /dev/null +++ b/app/controllers/public/product_customers_controller.rb @@ -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 diff --git a/app/controllers/public/product_order_products_controller.rb b/app/controllers/public/product_order_products_controller.rb new file mode 100755 index 0000000..b1f13df --- /dev/null +++ b/app/controllers/public/product_order_products_controller.rb @@ -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 diff --git a/app/controllers/public/product_orders_controller.rb b/app/controllers/public/product_orders_controller.rb new file mode 100755 index 0000000..f4e91cb --- /dev/null +++ b/app/controllers/public/product_orders_controller.rb @@ -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 diff --git a/app/controllers/public/products_controller.rb b/app/controllers/public/products_controller.rb new file mode 100755 index 0000000..3eb1a6a --- /dev/null +++ b/app/controllers/public/products_controller.rb @@ -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 diff --git a/app/controllers/public/reseauxes_controller.rb b/app/controllers/public/reseauxes_controller.rb index b4d3ff9..d618fe0 100755 --- a/app/controllers/public/reseauxes_controller.rb +++ b/app/controllers/public/reseauxes_controller.rb @@ -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 diff --git a/app/helpers/document_line_helper.rb b/app/helpers/document_line_helper.rb old mode 100755 new mode 100644 index 0351312..0e4de6b --- a/app/helpers/document_line_helper.rb +++ b/app/helpers/document_line_helper.rb @@ -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 diff --git a/app/inputs/qi_image_select_input.rb b/app/inputs/qi_image_select_input.rb old mode 100755 new mode 100644 index 66f168d..96118e3 --- a/app/inputs/qi_image_select_input.rb +++ b/app/inputs/qi_image_select_input.rb @@ -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 diff --git a/app/models/lang_site.rb b/app/models/lang_site.rb new file mode 100644 index 0000000..24172d2 --- /dev/null +++ b/app/models/lang_site.rb @@ -0,0 +1,4 @@ +class LangSite < ActiveRecord::Base + has_many :menu_item_langs + +end diff --git a/app/models/product.rb b/app/models/product.rb new file mode 100755 index 0000000..d5e955d --- /dev/null +++ b/app/models/product.rb @@ -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 diff --git a/app/models/product_category.rb b/app/models/product_category.rb new file mode 100755 index 0000000..8d6bd06 --- /dev/null +++ b/app/models/product_category.rb @@ -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 diff --git a/app/models/product_category_lang.rb b/app/models/product_category_lang.rb new file mode 100755 index 0000000..a71f61a --- /dev/null +++ b/app/models/product_category_lang.rb @@ -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 diff --git a/app/models/product_collection.rb b/app/models/product_collection.rb new file mode 100755 index 0000000..ca72e23 --- /dev/null +++ b/app/models/product_collection.rb @@ -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 diff --git a/app/models/product_collection_lang.rb b/app/models/product_collection_lang.rb new file mode 100755 index 0000000..281fae4 --- /dev/null +++ b/app/models/product_collection_lang.rb @@ -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 diff --git a/app/models/product_customer.rb b/app/models/product_customer.rb new file mode 100755 index 0000000..0d3be3c --- /dev/null +++ b/app/models/product_customer.rb @@ -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 diff --git a/app/models/product_fdp.rb b/app/models/product_fdp.rb new file mode 100644 index 0000000..d17463c --- /dev/null +++ b/app/models/product_fdp.rb @@ -0,0 +1,9 @@ +class ProductFdp < ActiveRecord::Base + + def name + self.fdp_description + + end + + +end diff --git a/app/models/product_image.rb b/app/models/product_image.rb new file mode 100755 index 0000000..c35fd0b --- /dev/null +++ b/app/models/product_image.rb @@ -0,0 +1,11 @@ +class ProductImage < ActiveRecord::Base + belongs_to :image_file + + belongs_to :product + + + + + + +end diff --git a/app/models/product_lang.rb b/app/models/product_lang.rb new file mode 100755 index 0000000..f57ae05 --- /dev/null +++ b/app/models/product_lang.rb @@ -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 diff --git a/app/models/product_option.rb b/app/models/product_option.rb new file mode 100755 index 0000000..3a4cd77 --- /dev/null +++ b/app/models/product_option.rb @@ -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 diff --git a/app/models/product_option_lang.rb b/app/models/product_option_lang.rb new file mode 100755 index 0000000..d28cc89 --- /dev/null +++ b/app/models/product_option_lang.rb @@ -0,0 +1,3 @@ +class ProductOptionLang < ActiveRecord::Base + belongs_to :product_option +end diff --git a/app/models/product_order.rb b/app/models/product_order.rb new file mode 100755 index 0000000..7371510 --- /dev/null +++ b/app/models/product_order.rb @@ -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 diff --git a/app/models/product_order_payment.rb b/app/models/product_order_payment.rb new file mode 100644 index 0000000..b069ebc --- /dev/null +++ b/app/models/product_order_payment.rb @@ -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 diff --git a/app/models/product_order_product.rb b/app/models/product_order_product.rb new file mode 100755 index 0000000..0097cf4 --- /dev/null +++ b/app/models/product_order_product.rb @@ -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 diff --git a/app/models/product_product_size.rb b/app/models/product_product_size.rb new file mode 100755 index 0000000..2fd19f7 --- /dev/null +++ b/app/models/product_product_size.rb @@ -0,0 +1,4 @@ +class ProductProductSize < ActiveRecord::Base + belongs_to :product + belongs_to :product_size +end diff --git a/app/models/product_size.rb b/app/models/product_size.rb new file mode 100755 index 0000000..5970733 --- /dev/null +++ b/app/models/product_size.rb @@ -0,0 +1,5 @@ +class ProductSize < ActiveRecord::Base + + has_many :product_product_sizes + has_many :products, :through => :product_product_sizes +end diff --git a/app/models/product_stock.rb b/app/models/product_stock.rb new file mode 100644 index 0000000..2c941da --- /dev/null +++ b/app/models/product_stock.rb @@ -0,0 +1,5 @@ +class ProductStock < ActiveRecord::Base + belongs_to :product + belongs_to :product_size + belongs_to :product_option +end diff --git a/app/models/reseaux.rb b/app/models/reseaux.rb index 1acd109..ee0449a 100644 --- a/app/models/reseaux.rb +++ b/app/models/reseaux.rb @@ -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 diff --git a/app/views/admin/product_categories/_form.html.haml b/app/views/admin/product_categories/_form.html.haml new file mode 100755 index 0000000..c763cc2 --- /dev/null +++ b/app/views/admin/product_categories/_form.html.haml @@ -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" diff --git a/app/views/admin/product_categories/_index_block.html.haml b/app/views/admin/product_categories/_index_block.html.haml new file mode 100755 index 0000000..ddf2e95 --- /dev/null +++ b/app/views/admin/product_categories/_index_block.html.haml @@ -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(); \ No newline at end of file diff --git a/app/views/admin/product_categories/_product_category.html.haml b/app/views/admin/product_categories/_product_category.html.haml new file mode 100755 index 0000000..690ad9e --- /dev/null +++ b/app/views/admin/product_categories/_product_category.html.haml @@ -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} + + + + diff --git a/app/views/admin/product_categories/cible.html.haml b/app/views/admin/product_categories/cible.html.haml new file mode 100755 index 0000000..a034103 --- /dev/null +++ b/app/views/admin/product_categories/cible.html.haml @@ -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] diff --git a/app/views/admin/product_categories/create.js.erb b/app/views/admin/product_categories/create.js.erb new file mode 100755 index 0000000..ed2d594 --- /dev/null +++ b/app/views/admin/product_categories/create.js.erb @@ -0,0 +1,4 @@ +close_pane_hover(); + +$('#product_category_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>"); + diff --git a/app/views/admin/product_categories/destroy.js.erb b/app/views/admin/product_categories/destroy.js.erb new file mode 100755 index 0000000..0084c50 --- /dev/null +++ b/app/views/admin/product_categories/destroy.js.erb @@ -0,0 +1,4 @@ +$('#product_category_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>"); + + +<%= flash_js %> diff --git a/app/views/admin/product_categories/edit.js.erb b/app/views/admin/product_categories/edit.js.erb new file mode 100755 index 0000000..06a7cbc --- /dev/null +++ b/app/views/admin/product_categories/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600); \ No newline at end of file diff --git a/app/views/admin/product_categories/index.html.haml b/app/views/admin/product_categories/index.html.haml new file mode 100755 index 0000000..ba3d38a --- /dev/null +++ b/app/views/admin/product_categories/index.html.haml @@ -0,0 +1,13 @@ + + +.qi_header + %h1 + Boutique + %span + Liste des catégories + + + +.qi_row + .qi_pannel.qi_plain.padding + =render :partial => "index_block" diff --git a/app/views/admin/product_categories/index.js.erb b/app/views/admin/product_categories/index.js.erb new file mode 100755 index 0000000..8f29080 --- /dev/null +++ b/app/views/admin/product_categories/index.js.erb @@ -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')) %>"); + +} + diff --git a/app/views/admin/product_categories/new.js.erb b/app/views/admin/product_categories/new.js.erb new file mode 100755 index 0000000..06a7cbc --- /dev/null +++ b/app/views/admin/product_categories/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600); \ No newline at end of file diff --git a/app/views/admin/product_categories/reorder.js.erb b/app/views/admin/product_categories/reorder.js.erb new file mode 100755 index 0000000..0084c50 --- /dev/null +++ b/app/views/admin/product_categories/reorder.js.erb @@ -0,0 +1,4 @@ +$('#product_category_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>"); + + +<%= flash_js %> diff --git a/app/views/admin/product_categories/show.html.haml b/app/views/admin/product_categories/show.html.haml new file mode 100755 index 0000000..87b6d7a --- /dev/null +++ b/app/views/admin/product_categories/show.html.haml @@ -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 diff --git a/app/views/admin/product_categories/update.js.erb b/app/views/admin/product_categories/update.js.erb new file mode 100755 index 0000000..b286dc4 --- /dev/null +++ b/app/views/admin/product_categories/update.js.erb @@ -0,0 +1,4 @@ +$('#product_category_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>"); + +close_pane_hover(); +<%= flash_js %> diff --git a/app/views/admin/product_categories/update_row.js.erb b/app/views/admin/product_categories/update_row.js.erb new file mode 100755 index 0000000..d5231d2 --- /dev/null +++ b/app/views/admin/product_categories/update_row.js.erb @@ -0,0 +1,2 @@ +close_pane_hover(); +$('#product_category_row_<%= @product_category.id %>').replaceWith("<%= escape_javascript(render(@product_category))%>"); diff --git a/app/views/admin/product_collections/_form.html.haml b/app/views/admin/product_collections/_form.html.haml new file mode 100755 index 0000000..654142a --- /dev/null +++ b/app/views/admin/product_collections/_form.html.haml @@ -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" + + + \ No newline at end of file diff --git a/app/views/admin/product_collections/_index_block.html.haml b/app/views/admin/product_collections/_index_block.html.haml new file mode 100755 index 0000000..e092f31 --- /dev/null +++ b/app/views/admin/product_collections/_index_block.html.haml @@ -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(); \ No newline at end of file diff --git a/app/views/admin/product_collections/_product_collection.html.haml b/app/views/admin/product_collections/_product_collection.html.haml new file mode 100755 index 0000000..7fefa55 --- /dev/null +++ b/app/views/admin/product_collections/_product_collection.html.haml @@ -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} + + + + diff --git a/app/views/admin/product_collections/cible.html.haml b/app/views/admin/product_collections/cible.html.haml new file mode 100755 index 0000000..a034103 --- /dev/null +++ b/app/views/admin/product_collections/cible.html.haml @@ -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] diff --git a/app/views/admin/product_collections/create.js.erb b/app/views/admin/product_collections/create.js.erb new file mode 100755 index 0000000..9a936c3 --- /dev/null +++ b/app/views/admin/product_collections/create.js.erb @@ -0,0 +1,5 @@ + + +$('#product_collection_index').html("<%= escape_javascript(render(@product_category.product_collections)) %>"); + +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/product_collections/destroy.js.erb b/app/views/admin/product_collections/destroy.js.erb new file mode 100755 index 0000000..1c10e06 --- /dev/null +++ b/app/views/admin/product_collections/destroy.js.erb @@ -0,0 +1,2 @@ +$('#product_collection_row_<%= @product_collection.id %>').remove(); +<%= flash_js %> diff --git a/app/views/admin/product_collections/edit.js.erb b/app/views/admin/product_collections/edit.js.erb new file mode 100755 index 0000000..06a7cbc --- /dev/null +++ b/app/views/admin/product_collections/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600); \ No newline at end of file diff --git a/app/views/admin/product_collections/index.html.haml b/app/views/admin/product_collections/index.html.haml new file mode 100755 index 0000000..3bc1db6 --- /dev/null +++ b/app/views/admin/product_collections/index.html.haml @@ -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" diff --git a/app/views/admin/product_collections/index.js.erb b/app/views/admin/product_collections/index.js.erb new file mode 100755 index 0000000..ef2ed51 --- /dev/null +++ b/app/views/admin/product_collections/index.js.erb @@ -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')) %>"); + +} + diff --git a/app/views/admin/product_collections/new.js.erb b/app/views/admin/product_collections/new.js.erb new file mode 100755 index 0000000..06a7cbc --- /dev/null +++ b/app/views/admin/product_collections/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600); \ No newline at end of file diff --git a/app/views/admin/product_collections/reorder.js.erb b/app/views/admin/product_collections/reorder.js.erb new file mode 100755 index 0000000..bbafe32 --- /dev/null +++ b/app/views/admin/product_collections/reorder.js.erb @@ -0,0 +1,4 @@ +$('#product_collection_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>"); + + +<%= flash_js %> diff --git a/app/views/admin/product_collections/show.html.haml b/app/views/admin/product_collections/show.html.haml new file mode 100755 index 0000000..1fa56b6 --- /dev/null +++ b/app/views/admin/product_collections/show.html.haml @@ -0,0 +1,2 @@ +%h1 + =@product_collection.lang("fr").name \ No newline at end of file diff --git a/app/views/admin/product_collections/update.js.erb b/app/views/admin/product_collections/update.js.erb new file mode 100755 index 0000000..895a6a7 --- /dev/null +++ b/app/views/admin/product_collections/update.js.erb @@ -0,0 +1,4 @@ +$('#product_collection_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>"); + +close_pane_hover(); +<%= flash_js %> diff --git a/app/views/admin/product_collections/update_row.js.erb b/app/views/admin/product_collections/update_row.js.erb new file mode 100755 index 0000000..7fde0c8 --- /dev/null +++ b/app/views/admin/product_collections/update_row.js.erb @@ -0,0 +1,2 @@ +close_pane_hover(); +$('#product_collection_row_<%= @product_collection.id %>').replaceWith("<%= escape_javascript(render(@product_collection))%>"); diff --git a/app/views/admin/product_images/_form.html.haml b/app/views/admin/product_images/_form.html.haml new file mode 100755 index 0000000..e45ef8b --- /dev/null +++ b/app/views/admin/product_images/_form.html.haml @@ -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" + + + + diff --git a/app/views/admin/product_images/_product_image.html.haml b/app/views/admin/product_images/_product_image.html.haml new file mode 100755 index 0000000..507ad76 --- /dev/null +++ b/app/views/admin/product_images/_product_image.html.haml @@ -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 + + \ No newline at end of file diff --git a/app/views/admin/product_images/create.js.erb b/app/views/admin/product_images/create.js.erb new file mode 100755 index 0000000..ab4926b --- /dev/null +++ b/app/views/admin/product_images/create.js.erb @@ -0,0 +1 @@ +$('#product_images').prepend("<%= escape_javascript(render(@product_images)) %>"); \ No newline at end of file diff --git a/app/views/admin/product_images/destroy.js.erb b/app/views/admin/product_images/destroy.js.erb new file mode 100755 index 0000000..6a6b8d7 --- /dev/null +++ b/app/views/admin/product_images/destroy.js.erb @@ -0,0 +1,4 @@ + +$("#product_image_<%= @product_image.id.to_s %>").fadeOut(500).delay(6000).remove(); + +<%= flash_js %> \ No newline at end of file diff --git a/app/views/admin/product_images/edit.js.erb b/app/views/admin/product_images/edit.js.erb new file mode 100755 index 0000000..3d94bc2 --- /dev/null +++ b/app/views/admin/product_images/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>"); \ No newline at end of file diff --git a/app/views/admin/product_images/reorder.js.erb b/app/views/admin/product_images/reorder.js.erb new file mode 100755 index 0000000..e69de29 diff --git a/app/views/admin/product_images/update.js.erb b/app/views/admin/product_images/update.js.erb new file mode 100755 index 0000000..0249891 --- /dev/null +++ b/app/views/admin/product_images/update.js.erb @@ -0,0 +1,5 @@ +close_pane_hover(); +$('#product_image_<%= @product_image.id %>').effect("highlight", 1000); + + +<%= flash_js %> \ No newline at end of file diff --git a/app/views/admin/product_options/_form.html.haml b/app/views/admin/product_options/_form.html.haml new file mode 100755 index 0000000..4c502b9 --- /dev/null +++ b/app/views/admin/product_options/_form.html.haml @@ -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 + \ No newline at end of file diff --git a/app/views/admin/product_order_payments/_form.html.haml b/app/views/admin/product_order_payments/_form.html.haml new file mode 100755 index 0000000..5192c0a --- /dev/null +++ b/app/views/admin/product_order_payments/_form.html.haml @@ -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" + \ No newline at end of file diff --git a/app/views/admin/product_order_payments/_product_order_payment.html.haml b/app/views/admin/product_order_payments/_product_order_payment.html.haml new file mode 100644 index 0000000..d676fe6 --- /dev/null +++ b/app/views/admin/product_order_payments/_product_order_payment.html.haml @@ -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 \ No newline at end of file diff --git a/app/views/admin/product_order_payments/create.js.erb b/app/views/admin/product_order_payments/create.js.erb new file mode 100755 index 0000000..f759dc5 --- /dev/null +++ b/app/views/admin/product_order_payments/create.js.erb @@ -0,0 +1,4 @@ +$('#product_orders').html("<%= escape_javascript(render(:partial => "index_block")) %>"); + +close_pane_hover(); + diff --git a/app/views/admin/product_order_payments/edit.js.erb b/app/views/admin/product_order_payments/edit.js.erb new file mode 100755 index 0000000..06a7cbc --- /dev/null +++ b/app/views/admin/product_order_payments/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600); \ No newline at end of file diff --git a/app/views/admin/product_order_payments/new.js.erb b/app/views/admin/product_order_payments/new.js.erb new file mode 100755 index 0000000..06a7cbc --- /dev/null +++ b/app/views/admin/product_order_payments/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600); \ No newline at end of file diff --git a/app/views/admin/product_order_payments/update.js.erb b/app/views/admin/product_order_payments/update.js.erb new file mode 100755 index 0000000..0ecd70b --- /dev/null +++ b/app/views/admin/product_order_payments/update.js.erb @@ -0,0 +1,4 @@ +$('#product_order_payments').html("<%= escape_javascript(render(@product_order_payment.product_order.product_order_payments)) %>"); + +close_pane_hover(); +<%= flash_js %> diff --git a/app/views/admin/product_order_products/_product_order_product.html.haml b/app/views/admin/product_order_products/_product_order_product.html.haml new file mode 100755 index 0000000..dc977ac --- /dev/null +++ b/app/views/admin/product_order_products/_product_order_product.html.haml @@ -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 diff --git a/app/views/admin/product_orders/_form.html.haml b/app/views/admin/product_orders/_form.html.haml new file mode 100755 index 0000000..1520642 --- /dev/null +++ b/app/views/admin/product_orders/_form.html.haml @@ -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" + \ No newline at end of file diff --git a/app/views/admin/product_orders/_index_block.html.haml b/app/views/admin/product_orders/_index_block.html.haml new file mode 100755 index 0000000..c68149f --- /dev/null +++ b/app/views/admin/product_orders/_index_block.html.haml @@ -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 diff --git a/app/views/admin/product_orders/_product_order.html.haml b/app/views/admin/product_orders/_product_order.html.haml new file mode 100755 index 0000000..765d579 --- /dev/null +++ b/app/views/admin/product_orders/_product_order.html.haml @@ -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} + + + + + diff --git a/app/views/admin/product_orders/bill.html.haml b/app/views/admin/product_orders/bill.html.haml new file mode 100644 index 0000000..6cf86d8 --- /dev/null +++ b/app/views/admin/product_orders/bill.html.haml @@ -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 + " + + + + + \ No newline at end of file diff --git a/app/views/admin/product_orders/create.js.erb b/app/views/admin/product_orders/create.js.erb new file mode 100755 index 0000000..f759dc5 --- /dev/null +++ b/app/views/admin/product_orders/create.js.erb @@ -0,0 +1,4 @@ +$('#product_orders').html("<%= escape_javascript(render(:partial => "index_block")) %>"); + +close_pane_hover(); + diff --git a/app/views/admin/product_orders/destroy.js.erb b/app/views/admin/product_orders/destroy.js.erb new file mode 100755 index 0000000..8a8b7d4 --- /dev/null +++ b/app/views/admin/product_orders/destroy.js.erb @@ -0,0 +1,2 @@ +$('#product_order_row_<%= @product_order.id %>').remove(); +<%= flash_js %> diff --git a/app/views/admin/product_orders/edit.js.erb b/app/views/admin/product_orders/edit.js.erb new file mode 100755 index 0000000..06a7cbc --- /dev/null +++ b/app/views/admin/product_orders/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600); \ No newline at end of file diff --git a/app/views/admin/product_orders/index.html.haml b/app/views/admin/product_orders/index.html.haml new file mode 100755 index 0000000..bef4dca --- /dev/null +++ b/app/views/admin/product_orders/index.html.haml @@ -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" diff --git a/app/views/admin/product_orders/index.js.erb b/app/views/admin/product_orders/index.js.erb new file mode 100755 index 0000000..c412429 --- /dev/null +++ b/app/views/admin/product_orders/index.js.erb @@ -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')) %>"); + +} + diff --git a/app/views/admin/product_orders/new.js.erb b/app/views/admin/product_orders/new.js.erb new file mode 100755 index 0000000..06a7cbc --- /dev/null +++ b/app/views/admin/product_orders/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600); \ No newline at end of file diff --git a/app/views/admin/product_orders/show.html.haml b/app/views/admin/product_orders/show.html.haml new file mode 100755 index 0000000..0df6979 --- /dev/null +++ b/app/views/admin/product_orders/show.html.haml @@ -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") + diff --git a/app/views/admin/product_orders/update.js.erb b/app/views/admin/product_orders/update.js.erb new file mode 100755 index 0000000..b87b342 --- /dev/null +++ b/app/views/admin/product_orders/update.js.erb @@ -0,0 +1,4 @@ +$('#product_order_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>"); + +close_pane_hover(); +<%= flash_js %> diff --git a/app/views/admin/product_orders/update_row.js.erb b/app/views/admin/product_orders/update_row.js.erb new file mode 100755 index 0000000..ebf056e --- /dev/null +++ b/app/views/admin/product_orders/update_row.js.erb @@ -0,0 +1,2 @@ +$('#product_order_row_<%= @product_order.id %>').replaceWith("<%= escape_javascript(render(@product_order))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/product_sizes/_form.html.haml b/app/views/admin/product_sizes/_form.html.haml new file mode 100755 index 0000000..89a0d69 --- /dev/null +++ b/app/views/admin/product_sizes/_form.html.haml @@ -0,0 +1,7 @@ += semantic_form_for [:admin,@product_size], :remote => true do |form| + + .content + = form.input :name + .actions + = form.submit "Sauvegarder" + \ No newline at end of file diff --git a/app/views/admin/product_sizes/_product_size.html.haml b/app/views/admin/product_sizes/_product_size.html.haml new file mode 100755 index 0000000..235c3d4 --- /dev/null +++ b/app/views/admin/product_sizes/_product_size.html.haml @@ -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} + + + + diff --git a/app/views/admin/product_sizes/create.js.erb b/app/views/admin/product_sizes/create.js.erb new file mode 100755 index 0000000..36a9dcf --- /dev/null +++ b/app/views/admin/product_sizes/create.js.erb @@ -0,0 +1,4 @@ +close_pane_hover(); + +$('#product_sizes').html("<%= escape_javascript(render(@product_sizes)) %>"); + diff --git a/app/views/admin/product_sizes/destroy.js.erb b/app/views/admin/product_sizes/destroy.js.erb new file mode 100755 index 0000000..c6f8409 --- /dev/null +++ b/app/views/admin/product_sizes/destroy.js.erb @@ -0,0 +1,5 @@ + +$('#product_size_<%= @product_size.id %>').remove(); + + +<%= flash_js %> diff --git a/app/views/admin/product_sizes/edit.js.erb b/app/views/admin/product_sizes/edit.js.erb new file mode 100755 index 0000000..06a7cbc --- /dev/null +++ b/app/views/admin/product_sizes/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600); \ No newline at end of file diff --git a/app/views/admin/product_sizes/index.html.haml b/app/views/admin/product_sizes/index.html.haml new file mode 100755 index 0000000..2a8498f --- /dev/null +++ b/app/views/admin/product_sizes/index.html.haml @@ -0,0 +1,18 @@ +.qi_header + .right= link_to 'Ajouter une taille', new_admin_product_size_path, :class => "btn btn-primary", :remote => true + %h1 + + Boutique + %span + Liste des tailles + + + +.qi_row + .qi_pannel.qi_plain.padding + %table.table + %tr + %th + Nom + %th + %tbody#product_sizes=render @product_sizes diff --git a/app/views/admin/product_sizes/new.js.erb b/app/views/admin/product_sizes/new.js.erb new file mode 100755 index 0000000..06a7cbc --- /dev/null +++ b/app/views/admin/product_sizes/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600); \ No newline at end of file diff --git a/app/views/admin/product_sizes/update_row.js.erb b/app/views/admin/product_sizes/update_row.js.erb new file mode 100755 index 0000000..7092f40 --- /dev/null +++ b/app/views/admin/product_sizes/update_row.js.erb @@ -0,0 +1,2 @@ +close_pane_hover(); +$('#product_size_<%= @product_size.id %>').replaceWith("<%= escape_javascript(render(@product_size))%>"); diff --git a/app/views/admin/products/_form.html.haml b/app/views/admin/products/_form.html.haml new file mode 100755 index 0000000..67e2f17 --- /dev/null +++ b/app/views/admin/products/_form.html.haml @@ -0,0 +1,42 @@ += semantic_form_for [:admin,@product], :remote => true do |form| + + .content + =form.input :reseaux_id, :label => "Réseau :", :collection => Reseaux.where(:parent_id => nil).all, :as => :select, :include_blank => false + + =#form.input :product_category_id, :label => "Catégorie :", :collection => @categories_select, :as => :select, :include_blank => false + + -if @product.product_category_id + =form.input :product_collection_id, :label => "Collection :", :collection => ProductCollection.where(:product_category_id => @product.product_category_id).map{|i| [i.lang("fr").name, i.id]}, :as => :select, :include_blank => true + + =form.semantic_fields_for :product_langs do |product_lang| + + + + = product_lang.inputs do + = product_lang.hidden_field :id + = product_lang.hidden_field :lang + = product_lang.input :title, :as => :string, :label => "Nom (#{product_lang.object.lang}) :" + = product_lang.input :description, :label => "Descirption (#{product_lang.object.lang}) :" + + =form.input :price_ht, :label => "Prix (HT) :" + =form.input :price_reduced_ht, :label => "Prix (HT) avec réduction :" + + + + %hr + %h3 + Options + %p= link_to_add_fields "Ajouter une ligne", form, :product_options + + .product_options_form + =form.semantic_fields_for :product_options do |form| + =render :partial => "admin/product_options/form", :locals => {:form => form} + %hr + %h3 Tailles possibles : + =form.input :product_sizes, :collection => ProductSize.where("archived is null").order(:position).all, :as => :check_boxes, :label => "Tailles" + + + + .actions + = form.submit "Sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/products/_index_block.html.haml b/app/views/admin/products/_index_block.html.haml new file mode 100755 index 0000000..26d61dd --- /dev/null +++ b/app/views/admin/products/_index_block.html.haml @@ -0,0 +1,35 @@ +%table.table#products + %thead + %tr + %th + %th + Catégorie + %th + Nom du produit + %th + %tbody.products_sortable=render @products + + +:coffeescript + + adjustment = "" + + $('.products_sortable').sortable({ + itemSelector:".gallery_image", + stop: (event, ui) -> + + result = [] + $(".product_row").each -> + result.push $(this).data("id") + + + $.ajax({ + url:"/admin/products/reorder.js", + type: "POST", + data: { + products_ids : result, + test: "jj" + } + + }) + }); \ No newline at end of file diff --git a/app/views/admin/products/_product.html.haml b/app/views/admin/products/_product.html.haml new file mode 100755 index 0000000..3d3c4bc --- /dev/null +++ b/app/views/admin/products/_product.html.haml @@ -0,0 +1,19 @@ +%tr#product_row.product_row{:id => product.id, :data => {:id => product.id}} + %td{:style => "width:200px;"} + =image_tag product.default_image.image_file.file.large.medium.small.thumb.url if product.default_image + %td + =product.product_category.lang("fr").name if product.product_category + %td + =product.lang("fr").title + + %td.actions + + = link_to i(:"trash-o"), [:admin, product], :data =>{:remote => true, :confirm => 'Voulez-vous vraiment supprimer cet élément de menu ?'}, :method => :delete #, if current_admin.super_admin? || !product.super_admin + = link_to i(:eye), [:admin, product] + = link_to i(:"shopping-cart"), stock_admin_product_path(product), :data => {:remote => true} + = link_to i(:pencil), edit_admin_product_path(product), :data => {:remote => true} + + + + + diff --git a/app/views/admin/products/_stock_form.html.haml b/app/views/admin/products/_stock_form.html.haml new file mode 100755 index 0000000..1cc6a99 --- /dev/null +++ b/app/views/admin/products/_stock_form.html.haml @@ -0,0 +1,26 @@ += semantic_form_for [:admin,@product], :remote => true do |form| + + .content + %table.table + %tr + %td Option + %td Taille + %td Stock théorique + %td Stock réél + + =form.semantic_fields_for :product_stocks do |product_stock| + + = product_stock.inputs do + %tr + %td + = product_stock.object.product_option.lang(I18n.locale).name if product_stock.object.product_option + %td + = product_stock.object.product_size.name if product_stock.object.product_size + + + %td=product_stock.text_field :stock_th + %td=product_stock.text_field :stock + + .actions + = form.submit "Sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/products/cible.html.haml b/app/views/admin/products/cible.html.haml new file mode 100755 index 0000000..a034103 --- /dev/null +++ b/app/views/admin/products/cible.html.haml @@ -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] diff --git a/app/views/admin/products/create.js.erb b/app/views/admin/products/create.js.erb new file mode 100755 index 0000000..fca8275 --- /dev/null +++ b/app/views/admin/products/create.js.erb @@ -0,0 +1,4 @@ +$('#products').html("<%= escape_javascript(render(:partial => "index_block")) %>"); + +close_pane_hover(); + diff --git a/app/views/admin/products/destroy.js.erb b/app/views/admin/products/destroy.js.erb new file mode 100755 index 0000000..3eb9aef --- /dev/null +++ b/app/views/admin/products/destroy.js.erb @@ -0,0 +1,2 @@ +$('#product_row_<%= @product.id %>').remove(); +<%= flash_js %> diff --git a/app/views/admin/products/edit.js.erb b/app/views/admin/products/edit.js.erb new file mode 100755 index 0000000..06a7cbc --- /dev/null +++ b/app/views/admin/products/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600); \ No newline at end of file diff --git a/app/views/admin/products/index.html.haml b/app/views/admin/products/index.html.haml new file mode 100755 index 0000000..9c0c499 --- /dev/null +++ b/app/views/admin/products/index.html.haml @@ -0,0 +1,15 @@ + + +.qi_header + .right= link_to 'Ajouter un produit', new_admin_product_path, :class => "btn btn-success", :remote => true + %h1 + + Boutique + %span + Liste des produits + + + +.qi_row + .qi_pannel.qi_plain.padding + =render :partial => "index_block" diff --git a/app/views/admin/products/index.js.erb b/app/views/admin/products/index.js.erb new file mode 100755 index 0000000..ac9e769 --- /dev/null +++ b/app/views/admin/products/index.js.erb @@ -0,0 +1,13 @@ + + +if($('#product_index').length > 0){ + $('#product_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>"); + +} +else{ + + + $('body').html("<%= escape_javascript(render(:template => 'admin/products/index.html.haml')) %>"); + +} + diff --git a/app/views/admin/products/new.js.erb b/app/views/admin/products/new.js.erb new file mode 100755 index 0000000..06a7cbc --- /dev/null +++ b/app/views/admin/products/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600); \ No newline at end of file diff --git a/app/views/admin/products/reorder.js.erb b/app/views/admin/products/reorder.js.erb new file mode 100755 index 0000000..827e69c --- /dev/null +++ b/app/views/admin/products/reorder.js.erb @@ -0,0 +1,4 @@ +$('#product_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>"); + + +<%= flash_js %> diff --git a/app/views/admin/products/show.html.haml b/app/views/admin/products/show.html.haml new file mode 100755 index 0000000..5b83bcc --- /dev/null +++ b/app/views/admin/products/show.html.haml @@ -0,0 +1,49 @@ +.qi_header + .right + = link_to i(:"shopping-cart"), stock_admin_product_path(@product), :data => {:remote => true} + = link_to i(:pencil), edit_admin_product_path(@product), :data => {:remote => true} + %h1 + + Boutique + %span + Détail d'un produit : + =@product.lang("fr").title + + + +.qi_row + + + + .qi_pannel.qi_plain.padding + =simple_format @product.lang("fr").description + .qi_sub_header + %h2 Images du produit + + %p + =link_to "Ajouter des images", "#", :onclick => "select_product_images_from_manager('#{@product.id.to_s}');return false;", :class => "btn btn-primary" + %br + #product_images + =render :collection => @product.product_images.order("position"), :partial => "admin/product_images/product_image" + %p{:style => "clear:both;"} + + :coffeescript + + adjustment = "" + + $('#product_images').sortable({ + + stop: () -> + result = [] + $(this).find(".product_image").each -> + result.push $(this).data("id") + + $.ajax({ + url:"/admin/product_images/reorder.js", + type: "GET", + data: { + order : result + } + + }) + }); \ No newline at end of file diff --git a/app/views/admin/products/stock.js.erb b/app/views/admin/products/stock.js.erb new file mode 100755 index 0000000..dbe1a88 --- /dev/null +++ b/app/views/admin/products/stock.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "stock_form"))%>",550,600); \ No newline at end of file diff --git a/app/views/admin/products/update.js.erb b/app/views/admin/products/update.js.erb new file mode 100755 index 0000000..d12b3e3 --- /dev/null +++ b/app/views/admin/products/update.js.erb @@ -0,0 +1,4 @@ +$('#product_index').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>"); + +close_pane_hover(); +<%= flash_js %> diff --git a/app/views/admin/products/update_row.js.erb b/app/views/admin/products/update_row.js.erb new file mode 100755 index 0000000..dc81b6c --- /dev/null +++ b/app/views/admin/products/update_row.js.erb @@ -0,0 +1,2 @@ +$('#product_row_<%= @product.id %>').replaceWith("<%= escape_javascript(render(@product))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/reseauxes/_form.html.haml b/app/views/admin/reseauxes/_form.html.haml index f9ff6ac..b3e0f31 100755 --- a/app/views/admin/reseauxes/_form.html.haml +++ b/app/views/admin/reseauxes/_form.html.haml @@ -12,5 +12,9 @@ -if !@reseaux.parent =f.input :chef_reseau, :label => "Chef réseau : ", :collection => Customer.where(:chef_reseau => true).pluck(Arel.sql("CONCAT(`firstname`, ' ', `name`)"), :id) - + + =f.input :logo_image_file_id, :label => "Logo :", :as => :qi_image_select + =f.input :background_image_file_id, :label => "Image de fond :", :as => :qi_image_select + + .actions= f.submit "Sauvegarder", :class => "btn btn-primary" diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index fa920b6..9c3e3c1 100755 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -58,7 +58,19 @@ %li= link_to " Contacts", admin_conversations_path %li= link_to "Moniteur d'activité", admin_connected_customers_path %li= link_to "Réseaux", admin_reseauxes_path - + + %li.dropdown + %a{:href => "#", :class => "dropdown-toggle", :data => {:toggle => "dropdown"}} + Boutique + %b.caret + %ul.dropdown-menu + %li= link_to "Catégories", admin_product_categories_path + %li= link_to "Produits", admin_products_path + %li= link_to "Tailles", admin_product_sizes_path + %li= link_to "Commandes", admin_product_orders_path + %li=# link_to "Codes de reduction", admin_vourcher_codes_path + + %ul.nav.navbar-nav.navbar-right %li.dropdown %a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"} diff --git a/app/views/layouts/public.html.haml b/app/views/layouts/public.html.haml index 27efb78..ee8c85d 100755 --- a/app/views/layouts/public.html.haml +++ b/app/views/layouts/public.html.haml @@ -27,25 +27,32 @@ - %body + %body{:class => ("reseaux_body " if @reseaux_layout).to_s} .top - + #menu =render :partial => "public/shared/menu" .clear - - - - -if @biglogo - =link_to image_tag("/logo.png", :id => "big-logo"), "/" + + -if @reseaux_layout + =link_to image_tag("/logo-mb.png", :id => "logo-mb"), "/" + -if @reseaux_layout + .reseaux_top{:style => "background-image:url('"+(@reseaux.background_image_file.file.large.url if @reseaux.background_image_file).to_s+"');"} + =link_to "" do + =image_tag @reseaux.logo_image_file.file.large.url, :class => "logo_reseaux" if @reseaux.logo_image_file + + -else - =link_to image_tag("/logo.png", :id => "logo"), "/" + -if @biglogo + =link_to image_tag("/logo.png", :id => "big-logo"), "/" + -else + =link_to image_tag("/logo.png", :id => "logo"), "/" #main .body-container diff --git a/app/views/public/product_categories/_bandeau.html.haml b/app/views/public/product_categories/_bandeau.html.haml new file mode 100644 index 0000000..0b3e2aa --- /dev/null +++ b/app/views/public/product_categories/_bandeau.html.haml @@ -0,0 +1,5 @@ +=link_to public_product_category_path(:id => product_category.id, :slug => product_category.lang(I18n.locale).slug) do + .category-container + =image_tag product_category.image_file.file.url if product_category.image_file + .category-title + = product_category.lang(I18n.locale).name \ No newline at end of file diff --git a/app/views/public/product_categories/_product_category.html.haml b/app/views/public/product_categories/_product_category.html.haml new file mode 100755 index 0000000..74334c7 --- /dev/null +++ b/app/views/public/product_categories/_product_category.html.haml @@ -0,0 +1,5 @@ +%li + =link_to product_category.lang(I18n.locale).name, public_product_category_path(:id => product_category.id, :slug => product_category.lang(I18n.locale).slug), :class => ("active" if @product_category and product_category.id == @product_category.id) if product_category.lang(I18n.locale).slug? + + %ul + = render product_category.children.order(:position) \ No newline at end of file diff --git a/app/views/public/product_categories/index.html.haml b/app/views/public/product_categories/index.html.haml new file mode 100644 index 0000000..fdfdb8f --- /dev/null +++ b/app/views/public/product_categories/index.html.haml @@ -0,0 +1,21 @@ +-@facebook_img = "/fb-boutique.jpg" +-@description = " " +-@title = "La boutique One Voice" + + +-ProductCategory.order(:position).all.each do |product_category| + %center + %h2=product_category.lang("fr").name + =render :partial => "public/products/product_index", :locals => {:products => product_category.products.not_archived.limit(30)} + -if product_category.products.not_archived.count > 30 + %p=link_to "Voir tous les articles de la catégorie "+product_category.lang("fr").name+" (#{product_category.products.not_archived.count}) >", public_product_category_path(:id => product_category.id, :slug => product_category.lang(I18n.locale).slug) + + %br + %br + %br + .clear + +%br +%br +%br +%br diff --git a/app/views/public/product_categories/show.html.haml b/app/views/public/product_categories/show.html.haml new file mode 100755 index 0000000..3b3e472 --- /dev/null +++ b/app/views/public/product_categories/show.html.haml @@ -0,0 +1,52 @@ +#product_category_container{:id => @product_category.id} + -if @product_category.color? + + .product_category_top{:class =>( "big_cat" if @product_category.children.count > 0 )} + + %h1.category-title + =@product_category_lang.name + -if @product_category_lang.description? + .description + -if @product_category.image_file_left + =image_tag @product_category.image_file_left.file.large.medium.small.thumb.url, :class => "left_image" + -if @product_category.image_file_right + =image_tag @product_category.image_file_right.file.large.medium.small.thumb.url, :class => "right_image" + + + =@product_category_lang.description + + .clear + -if @product_category.top_image_id + %center=image_tag @product_category.top_image.file.large.url + + + =render @product_category.product_collections + -if @product_category.products.not_archived.where(:product_collection_id => nil).count > 0 + =render :partial => "public/products/product_index", :locals => {:products => @product_category.products.not_archived.where(:product_collection_id => nil)} + + + +-content_for :bandeau do + =render :partial => "public/product_categories/bandeau",:collection => @product_category.children.order(:position), :as => :product_category diff --git a/app/views/public/product_collections/_product_collection.html.haml b/app/views/public/product_collections/_product_collection.html.haml new file mode 100755 index 0000000..584ff13 --- /dev/null +++ b/app/views/public/product_collections/_product_collection.html.haml @@ -0,0 +1,32 @@ +.collection#product_collection_container{:id => product_collection.id} + %h2 + %span=product_collection.lang(I18n.locale).name + collection + + .collection_products + =render :partial => "public/products/product_index", :locals => {:products => product_collection.products.not_archived} + + -if product_collection.color? + \ No newline at end of file diff --git a/app/views/public/product_customers/_new_form.haml b/app/views/public/product_customers/_new_form.haml new file mode 100755 index 0000000..6ee6fbf --- /dev/null +++ b/app/views/public/product_customers/_new_form.haml @@ -0,0 +1,22 @@ + +#new_product_customer_form_container + + %h1= qit "Pas encore de compte ?", "Pas encore de compte ?" + + = semantic_form_for [:public, @product_customer] do |f| + + =f.inputs do + + + + + = f.input :email, :label => qit("email-label","email :"), :placeholder => qit("email","Email") + + = f.input :password, :label => qit("password-label","Mot de passe :"), :placeholder => qit("password","Mot de passe") + + + + + + =f.submit qit("account-create-save","Créer mon compte !"), :class => "btn btn-primary order_button" + diff --git a/app/views/public/product_customers/new.haml b/app/views/public/product_customers/new.haml new file mode 100755 index 0000000..6f27fa4 --- /dev/null +++ b/app/views/public/product_customers/new.haml @@ -0,0 +1,2 @@ + +=render :partial => "public/product_customers/new_form" diff --git a/app/views/public/product_customers_auths/new.haml b/app/views/public/product_customers_auths/new.haml new file mode 100755 index 0000000..707e51c --- /dev/null +++ b/app/views/public/product_customers_auths/new.haml @@ -0,0 +1,42 @@ +.forum_connect + + .connexion + + .inner + + .formtastic + + .connexion_form + + + + %h1= qit "Vous avez déjà un compte title", "Vous avez déjà un compte ?" + + = form_tag public_product_customers_auths_path do + =hidden_field_tag :for_annonce, params[:for_annonce] + =hidden_field_tag :for_mail, params[:for_mail] + + + %p + = label_tag :email, qit("email-label","email :") + + = text_field_tag :email, params[:email], :class => "form-control", :placeholder => qit("email","Email") + + %p + = label_tag :password, qit("password-label","Mot de passe :") + + = password_field_tag :password, "", :class => "form-control", :placeholder => qit("password","Mot de passe") + + %p + =check_box_tag :remember_me, 1,params[:remember_me], :style => "display:inline-block;width:auto;" + = label_tag :remember_me, qit("keep-connect-label","Rester connecté ?"), :style => "display:inline-block;width:auto;" + + %p + + = submit_tag qit("login-submit", "Se connecter"), :class => "btn btn-primary order_button" + %p + =link_to qit("lost-password","Mot de passe perdu ?"), new_public_password_reset_path + + .inscription + .inner + =render :partial => "public/product_customers/new_form" \ No newline at end of file diff --git a/app/views/public/product_images/_product_image.html.haml b/app/views/public/product_images/_product_image.html.haml new file mode 100755 index 0000000..aabf98f --- /dev/null +++ b/app/views/public/product_images/_product_image.html.haml @@ -0,0 +1,3 @@ +-if product_image.image_file + .product_image + =image_tag product_image.image_file.file.large.medium.small.url \ No newline at end of file diff --git a/app/views/public/product_order_products/_product_order_product.html.haml b/app/views/public/product_order_products/_product_order_product.html.haml new file mode 100755 index 0000000..4f8e8df --- /dev/null +++ b/app/views/public/product_order_products/_product_order_product.html.haml @@ -0,0 +1,29 @@ +%tr + %td{:style => "width:100px"} + =link_to public_product_path(:id => product_order_product.product.id, :slug => product_order_product.product.lang(I18n.locale).slug) do + =image_tag product_order_product.product.default_image.image_file.file.large.medium.small.thumb.url if product_order_product.product.default_image + %td + %strong + =link_to public_product_path(:id => product_order_product.product.id, :slug => product_order_product.product.lang(I18n.locale).slug) do + = product_order_product.product.lang(:fr).title + %br + = product_order_product.product_size.name if product_order_product.product_size + = product_order_product.product_option.lang(I18n.locale).name if product_order_product.product_option + + + + + + %td.boutique-right + = number_to_currency(product_order_product.product.final_price_ttc.to_f, locale: :fr) + %td{:style => "width:150px;text-align:center;"} + -if !@recap + .qty_form + = form_for [:public, product_order_product] do |f| + = f.text_field :qty, :style => "width:30px;" + = f.submit "Mettre à jour" + =link_to ic(:"trash-o"), public_product_order_product_path(:id => product_order_product.id, :product_order_product => {:qty => 0}), :method => :put + -else + =product_order_product.qty + %td.boutique-right + = number_to_currency(product_order_product.final_price_ttc_with_qty, locale: :fr) diff --git a/app/views/public/product_order_products/create.js.erb b/app/views/public/product_order_products/create.js.erb new file mode 100644 index 0000000..687d8fe --- /dev/null +++ b/app/views/public/product_order_products/create.js.erb @@ -0,0 +1,10 @@ +$("#cart_infos").html("<%= escape_javascript(render(:partial => "public/shared/cart")) %>"); + + + +$(".cart_link").animate({color: "#fecb31"}, function (){ + $(".cart_link").animate({color: "black"}); + +}); + +$(".cart_link").effect( "bounce", {times:5}, 1000 ); \ No newline at end of file diff --git a/app/views/public/product_orders/_mail_recap.html.haml b/app/views/public/product_orders/_mail_recap.html.haml new file mode 100644 index 0000000..8e74d32 --- /dev/null +++ b/app/views/public/product_orders/_mail_recap.html.haml @@ -0,0 +1,61 @@ +%table{:style => "width:100%;"} + %tr + %td + %h3=qit "Adresse de facturation-mail", "Adresse de facturation" + =render :partial => "public/particulars/particular", :object => @product_order.particular_bill if @product_order.particular_bill + %td + %h3=qit "Adresse de livraison-mail", "Adresse de livraison" + =render :partial => "public/particulars/particular", :object => @product_order.particular_send if @product_order.particular_send +%br +%table.order_table{:style => "width:100%;"} + -@product_order.product_order_products.order(:product_id).each do |product_order_product| + %tr + %td{:style => "width:120px"} + =image_tag "https://#{HOSTNAME}"+product_order_product.product.default_image.image_file.file.large.medium.small.thumb.url, :style => "width:100%;" if product_order_product.product and product_order_product.product.default_image + %td{:style => "vertical-align:top;"} + %strong= product_order_product.archived_product.lang(:fr).title + %br + + = product_order_product.archived_product_size.name if product_order_product.archived_product_size + + = product_order_product.archived_product_option.lang(I18n.locale).name if product_order_product.archived_product_option + + %td{:style => "text-align:right;vertical-align:top;"} + = number_to_currency(product_order_product.archived_product.price_ttc.to_f, locale: :fr) if product_order_product.archived_product + %td{:style => "text-align:center;vertical-align:top;"} + =product_order_product.qty + %td{:style => "text-align:right;vertical-align:top;"} + = number_to_currency(product_order_product.archived_price_ttc_with_qty, locale: :fr) if product_order_product.archived_product + + + + %tr + %td{:colspan => 3, :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 => 3, :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 => 3, :style => "border:0;"} + %td=qit "frais de port dans tableau", "Frais de port :" + %td= number_to_currency(@product_order.archived_total_fdp, locale: :fr) + %tr + %td{:colspan => 3, :style => "border:0;"} + %td + %strong Total : + %td + %strong + = number_to_currency(@product_order.archived_total_ttc, locale: :fr) diff --git a/app/views/public/product_orders/_particular_form.html.haml b/app/views/public/product_orders/_particular_form.html.haml new file mode 100755 index 0000000..c9ac836 --- /dev/null +++ b/app/views/public/product_orders/_particular_form.html.haml @@ -0,0 +1,26 @@ + + +=f.hidden_field :particular_type +=f.hidden_field :skip_validation, :class => "skip_validation" + +%table{:style => "width:100%;"} + %tr + %td{:style => "width:20%"} + =f.input :civilite, :label => qit("don-particular-civilite","Civilité"), :as => :select, :collection => [[qit("don-particular-civilite-mme","Mme."), "Mme"], [qit("don-particular-civilite-m","M."), "M"]], :include_blank => false + %td{:style => "width:40%"} + =f.input :firstname, :label => qit("don-particular-firstname","Prénom") + %td{:style => "width:40%"} + =f.input :name, :label => qit("don-particular-name","Nom") + +=f.input :address_2, :label => "Adresse" +=f.input :address_3, :label => "Adresse suite" +%table{:style => "width:100%;"} + %tr + %td{:style => "width:30%"} + =f.input :cp, :label => "Code postal" + %td{:style => "width:70%"} + =f.input :city, :label => "Ville" + +=f.input :country, :label => "Pays", :collection => [[ "France", "FR"], [ "Suisse", "CH"], [ "Belgique", "BE"]], :include_blank => false, :as => :select + +=f.input :tel, :label => "Téléphone" diff --git a/app/views/public/product_orders/my_cart.html.haml b/app/views/public/product_orders/my_cart.html.haml new file mode 100755 index 0000000..2cc67cd --- /dev/null +++ b/app/views/public/product_orders/my_cart.html.haml @@ -0,0 +1,61 @@ +.padding.center#my_cart + + %h1 + Ma commande + + -if @product_order.product_order_products.count > 0 + %table.table + %thead + %tr + %th + %th + Article + %th + Prix U. + %th + Qte + %th + Prix + + %tbody + =render @product_order.product_order_products.order(:product_id) + + -if @product_order.vourcher_code + %div.boutique-right + = "Total articles : " + number_to_currency(@product_order.total_articles, locale: :fr) + .clear + %div.boutique-right + ="Code de réduction " + ="("+@product_order.vourcher_code.slug+") :" + =number_to_currency @product_order.vourcher_reduction + .clear + %div.boutique-right{:style => "width:auto;"} + = "Total : " + %strong=number_to_currency((@product_order.total_articles-@product_order.vourcher_reduction) , locale: :fr) + .clear + %br + %br + + %center + + =link_to "Commander", particulars_public_product_orders_path, :class => "btn btn-primary order_button" + -else + %center + Vous n'avez pas de produits dans votre panier. + + %br + %br + =link_to "Visitez notre boutique !", boutique_path, :class => "btn btn-primary" + + + %br + %br + + -if 1==2 + %div + %br + %center + =form_tag vourcher_public_product_orders_path do + =qit "Code de réduction label", "Code de réduction :" + =text_field_tag :vourcher_code + =submit_tag "Envoyer le code" \ No newline at end of file diff --git a/app/views/public/product_orders/paid_by_ogone.html.haml b/app/views/public/product_orders/paid_by_ogone.html.haml new file mode 100644 index 0000000..8372ff7 --- /dev/null +++ b/app/views/public/product_orders/paid_by_ogone.html.haml @@ -0,0 +1,10 @@ + +%p Vous allez être redirigé automatiquement sur le serveur de paiement sécurisé par Ogone. Si ce n'est pas le cas, merci de cliquer sur "payer maintenant" +%form{:action => CONFIG_OGONE["ecom_url"], :id => "ogone_form"} + -form_content = ogone_fields(@ogone_options) + -form_content << '' + =raw form_content + +:javascript + $("#ogone_form").submit() + diff --git a/app/views/public/product_orders/paid_by_ogone_confirm.html.haml b/app/views/public/product_orders/paid_by_ogone_confirm.html.haml new file mode 100644 index 0000000..cfd659e --- /dev/null +++ b/app/views/public/product_orders/paid_by_ogone_confirm.html.haml @@ -0,0 +1,13 @@ +.center + %h1 Votre paiement a été accepté ! + + %center + %p + Nous vous remercions sincèrement pour votre commande que nous vous expédierons le plus rapidement possible. + + %br + %br + %br + %br + %br + \ No newline at end of file diff --git a/app/views/public/product_orders/paid_by_payplug_confirm.html.haml b/app/views/public/product_orders/paid_by_payplug_confirm.html.haml new file mode 100644 index 0000000..372e6cd --- /dev/null +++ b/app/views/public/product_orders/paid_by_payplug_confirm.html.haml @@ -0,0 +1,4 @@ +.center + %h1=qit "titre paiement accepté (par payplug)", "Votre paiement a été accepté" + %p + =qit "texte paiement accepté (par payplug)", "Merci pour votre commande." diff --git a/app/views/public/product_orders/particulars.html.haml b/app/views/public/product_orders/particulars.html.haml new file mode 100755 index 0000000..787296f --- /dev/null +++ b/app/views/public/product_orders/particulars.html.haml @@ -0,0 +1,58 @@ +#my_cart + %h1 Coordonnées + = semantic_form_for [:public,@product_order], :url => particulars_save_public_product_orders_path(), :html => { :method => :post, :onchange =>"cb_infos();"}do |f| + + =f.semantic_fields_for :product_customer do |f| + + + .row + .columns.span_6{:style => "padding:10px;"} + + %h3= qit "Adresse de facturation titre", "Adresse de facturation" + %p +   + =f.semantic_fields_for :particular_bill do |f| + .particular_form=render :partial => "particular_form", :locals => {:f => f} + + + + + + + -@particular_idem = f.object.particular_idem + + + + .columns.span_6{:style => "padding:10px;"} + %h3=qit "Adresse de livraison titre", "Adresse de livraison" + %p=f.input :particular_idem, :label => qit("phrase-adresse-identique","Adresse de livraison identique à l'adresse de facturation ?"), :input_html => {:onchange => "particular_idem()", :id => "particular_idem_checkbox"} + + #particular_send + + =f.semantic_fields_for :particular_send do |f| + + .particular_form=render :partial => "particular_form", :locals => {:f => f} + + + .clear + %br + + .actions + %center + =f.submit "Passer commande", :class => "btn btn-primary order_button" + =#f.submit qit("Choisir le mode de livraison - bouton", "Choisir le mode de livraison"), :class => "btn btn-primary order_button" + + %br + %br + + :coffeescript + @particular_idem = -> + if $("#particular_idem_checkbox").is(':checked') + $('#particular_send').hide() + $('#particular_send .skip_validation').val(1) + else + $('#particular_send').show() + $('#particular_send .skip_validation').val('') + + :javascript + particular_idem(); diff --git a/app/views/public/product_orders/payment_instructions.html.haml b/app/views/public/product_orders/payment_instructions.html.haml new file mode 100644 index 0000000..3fa20c8 --- /dev/null +++ b/app/views/public/product_orders/payment_instructions.html.haml @@ -0,0 +1,24 @@ +.center + %h1=qit "Titre dans instruction commande par chèque", "Merci pour votre commande !" + + %p + Pour finaliser celle-ci, merci de nous envoyer votre réglement par chèque d'un montant de + = number_to_currency(@product_order_ar.total_ttc, locale: :fr) + à l'ordre de One Voice à l'adresse suivante : + %br + %strong One Voice + %br + 38 rue Saint Cornély + %br + 56340 Carnac + %br + France + %br + %br + %br + =#%p Si vous souhaitez finalement payer cette commande par carte banque vous pouvez la retrouver dans votre compte client. + + + + + diff --git a/app/views/public/product_orders/select_fdp.html.haml b/app/views/public/product_orders/select_fdp.html.haml new file mode 100755 index 0000000..b132487 --- /dev/null +++ b/app/views/public/product_orders/select_fdp.html.haml @@ -0,0 +1,22 @@ +#my_cart + %h1=qit "Livraison", "Livraison" + = semantic_form_for [:public,@product_order], :url => select_fdp_save_public_product_orders_path(), :html => { :method => :post, :onchange =>"cb_infos();"}do |f| + + =f.hidden_field :force_fdp_validation + .radio_buttons.input.optional.form-group + %label + =qit "Mode de livraison :", "Mode de livraison :" + -( @product_order.particular_send.country == "FR" ? ProductFdp.where("archived is null").where(:country => "FR").all : ProductFdp.where("archived is null").where(:country => "all").all).each do |fdp| + + .radio + =label_tag "product_order_product_fdp_id_#{fdp.id}" do + =radio_button_tag "product_order[product_fdp_id]", fdp.id, (true if f.object.product_fdp_id == fdp.id ) + =fdp.fdp_description + =number_to_currency @product_order.total_fdp(fdp) + + + + .actions + %center + =f.submit qit("Valider bouton choix livraison", "Valider"), :class => "btn btn-primary order_button" + diff --git a/app/views/public/product_orders/select_payment.html.haml b/app/views/public/product_orders/select_payment.html.haml new file mode 100755 index 0000000..df7e8de --- /dev/null +++ b/app/views/public/product_orders/select_payment.html.haml @@ -0,0 +1,86 @@ +#my_cart + .order_recap + %h1=qit "titre page validation de commande", "Validation de votre commande" + %br + -@recap = true + %table.table + =render @product_order.product_order_products.order(:product_id) + + + %tr + %td{:colspan => 3, :style => "border:0;"} + %td Total : + %td.boutique-right= number_to_currency(@product_order.total_articles, locale: :fr) + + -if @product_order.vourcher_code + %tr + %td{:colspan => 3, :style => "border:0;"} + %td + =qit "Code réduction tableau", "Code de réduction " + ="("+@product_order.vourcher_code.slug+") :" + %td.boutique-right + ="-" + =number_to_currency @product_order.vourcher_reduction, locale: :fr + + + + + %tr + %td{:colspan => 3, :style => "border:0;"} + %td=qit "frais de port dans tableau", "Frais de port :" + %td.boutique-right= number_to_currency(@product_order.total_fdp, locale: :fr) + %tr + %td{:colspan => 3, :style => "border:0;"} + %td + %strong Total : + %td.boutique-right + %strong + = number_to_currency(@product_order.total_ttc, locale: :fr) + + + + + + .clear + + + = semantic_form_for [:public,@product_order], :url => select_payment_save_public_product_orders_path(), :html => { :method => :post, :onchange =>"cb_infos();"}do |f| + + =f.hidden_field :force_payment + + + %h3=qit "paiement titre", "Paiement" + + + -if params[:paid_fail] + %p=qit "texte erreur de paiement", "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." + + %br + + + + =f.input :product_order_payment_type_ok_id, :label => false, :collection => [["Chèque",1],["Carte bancaire",3]], :as => :radio, :include_blank => false + + + .cb_infos + =qit "texte redirection paiement sécurisé", "Vous serez redirigé vers la page de paiement sécurisé." + %br + + =f.input :cgv, :label => qit("phrase jaccepte les cgv","J'accepte les conditions générales de vente.") + .actions + %center + =f.submit qit("Valider ma commande bouton", "Valider ma commande"), :class => "btn btn-primary order_button" + + %br + %br + + + + :coffeescript + @cb_infos = -> + if $('#product_order_product_order_payment_type_ok_id_3').is(':checked') + $(".cb_infos").show() + else + $(".cb_infos").hide() + :javascript + cb_infos(); \ No newline at end of file diff --git a/app/views/public/products/_product.html.haml b/app/views/public/products/_product.html.haml new file mode 100755 index 0000000..bb91c81 --- /dev/null +++ b/app/views/public/products/_product.html.haml @@ -0,0 +1,23 @@ +=link_to public_reseaux_product_path(:reseaux_id => params[:reseaux_id],:id => product.id, :slug => product.lang(I18n.locale).slug) do + .product.product-item + .inner + =image_tag product.default_image.image_file.file.large.medium.url if product.default_image + + .description + %h3.product-title + =product.lang(I18n.locale).title + %div.product-price + -if !product.price_reduced_ht + = number_to_currency(product.price_ttc, locale: :fr) + -else + = number_to_currency(product.price_reduced_ttc, locale: :fr) + %del.strip + = number_to_currency(product.price_ttc, locale: :fr) + -if product.in_stock > 0 + .stock + + + + + + \ No newline at end of file diff --git a/app/views/public/products/_product_index.html.haml b/app/views/public/products/_product_index.html.haml new file mode 100644 index 0000000..f2302c0 --- /dev/null +++ b/app/views/public/products/_product_index.html.haml @@ -0,0 +1,11 @@ +.products_grid + -i = 0 + -products.each do |product| + -i += 1 + + =render product + + -if !i.odd? + =#.clear + + .clear \ No newline at end of file diff --git a/app/views/public/products/index.html.haml b/app/views/public/products/index.html.haml new file mode 100644 index 0000000..403639f --- /dev/null +++ b/app/views/public/products/index.html.haml @@ -0,0 +1,6 @@ + +.center.row + %h1 Produits exclusifs réservés à ce réseau + + .boutique_body.products + =render Product.all diff --git a/app/views/public/products/show.html.haml b/app/views/public/products/show.html.haml new file mode 100755 index 0000000..4055488 --- /dev/null +++ b/app/views/public/products/show.html.haml @@ -0,0 +1,108 @@ +.center.row.boutique_body + %h1{:style => "text-align:left;"} Détail d'un produit + .clear + .product_show + + .row + + .col_image + =image_tag @product.default_image.image_file.file.large.medium.url, :id => "product_default_image", :data => {:zoom_image => @product.default_image.image_file.file.url } if @product.default_image + + -if @product.product_images.count > 1 + .product_images + -@product.product_images.order(:position).each do |product_image| + =link_to image_tag(product_image.image_file.file.square.url), "#", :onclick => "$('#product_default_image').attr('data-zoom-image', $(this).data('zoom-url'));$('#product_default_image').attr('src', $(this).data('large-url'));$('#product_default_image').data('elevateZoom').swaptheimage($(this).data('large-url'), $(this).data('zoom-url')); return false;", :data => {:large_url => product_image.image_file.file.large.medium.url, :zoom_url => product_image.image_file.file.url} + + .col_description + .product_description + %h1= @product_lang.title + =simple_format @product_lang.description + + .price + -if !@product.price_reduced_ht? + = number_to_currency(@product.price_ttc, locale: :fr) + -else + = number_to_currency(@product.price_reduced_ttc, locale: :fr) + + -if @product.price_reduced_ht? + .price_reduced + %span.strip + = number_to_currency(@product.price_ttc, locale: :fr) + + + + -@porduct_order_product = ProductOrderProduct.new(product_id: @product.id ) + -@porduct_order_product.product_option_id = @product.product_options_in_stock.first.id if @product.product_options_in_stock.first + -@porduct_order_product.product_size_id = @product.product_sizes_in_stock(@porduct_order_product.product_option_id).first.id if @product.product_sizes_in_stock(@porduct_order_product.product_option_id).first + + + + -if @product.product_stocks.where("stock_th > 0").count > 0 + = form_for [:public, @porduct_order_product], :remote => true do |f| + = f.hidden_field :product_id + + .product_options + -@product.product_options_in_stock.each do |product_option| + + =link_to product_option.lang(I18n.locale).name, "#", :onclick => "$('#product_option_id').val($(this).data('id'));option_active();update_size_in_stocks($(this).data('sizes-in-stock'));return false;", :data => {:id => product_option.id, :sizes_in_stock => @product.product_sizes_in_stock_id(product_option.id)}, :id => "product_option_link_#{product_option.id}", :class => "product_option_link" + + + = f.hidden_field :product_option_id, :id => "product_option_id" + + + + + #product_sizes.product_sizes + -@product.product_sizes_in_stock(:all).each do |product_size| + =link_to product_size.name, "#", :onclick => "$('#product_size_id').val($(this).data('id'));size_active();return false;", :data => {:id => product_size.id }, :id => "product_size_link_#{product_size.id}", :class => "product_size_link "+("in_stock" if @product.product_sizes_in_stock_id(@porduct_order_product.product_option_id).include?(product_size.id)).to_s + + + + + = f.hidden_field :product_size_id, :id => "product_size_id" + + + + = f.submit "Ajouter à la commande", :class => "add_to_cart btn" + + -if 1==2 + -if [1,2,14,15,33,13,30].include?(@product.product_category_id) + .size_guide + =link_to "Guide des tailles", "/fr/guide-des-tailles.html", :target => "_blank" + + + :coffeescript + @size_active = -> + $(".product_size_link").removeClass("active") + $("#product_size_link_"+ $("#product_size_id").val()).addClass("active") + :javascript + size_active(); + + :coffeescript + @option_active = -> + $(".product_option_link").removeClass("active") + $("#product_option_link_"+ $("#product_option_id").val()).addClass("active") + :javascript + option_active(); + + :coffeescript + @update_size_in_stocks =(ids) -> + $(".product_size_link").removeClass("in_stock") + $.each ids, (index, value) -> + $("#product_size_link_"+ value).addClass("in_stock") + $(".in_stock").first().click() + + :javascript + //update_size_in_stocks([1,2]); + + :scss + .product_sizes a{ + display:none; + &.in_stock{ + display:inline-block; + } + } + + -else + .no_stock + Ce produit n'est plus en stock. \ No newline at end of file diff --git a/app/views/public/shared/_cart.html.haml b/app/views/public/shared/_cart.html.haml new file mode 100644 index 0000000..6ae09dd --- /dev/null +++ b/app/views/public/shared/_cart.html.haml @@ -0,0 +1,2 @@ +-if @product_order.product_order_products.sum(:qty) > 0 + = link_to i(:"shopping-cart")+(" #{@product_order.product_order_products.sum(:qty)}" if @product_order.product_order_products.sum(:qty) > 0).to_s, public_my_cart_path, :class => "cart_link" diff --git a/app/views/public/shared/_menu.html.haml b/app/views/public/shared/_menu.html.haml index 51dd1b4..25856da 100755 --- a/app/views/public/shared/_menu.html.haml +++ b/app/views/public/shared/_menu.html.haml @@ -17,6 +17,11 @@ %li=link_to ic(:envelope)+" Conversations", public_customer_messages_path, :class => "btn" %li=link_to "Se déconnecter", logout_public_customers_auths_path, :class => "btn" + + + %li + %span#cart_infos + =render :partial => "public/shared/cart" -else diff --git a/config/routes.rb b/config/routes.rb index 025a958..d255f78 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -169,7 +169,76 @@ Rails.application.routes.draw do get "sitemap.:f" => "public/sitemap#sitemap" namespace :public do - resources :reseauxes + get :my_cart, to: "product_orders#my_cart" + + + resources :militer_cats + + resources :product_sizes + + resources :product_images + + resources :product_categories + + resources :products + + resources :product_orders do + member do + get :payment_instructions + end + + collection do + get :paid_by_ogone + get :paid_by_ogone_confirm + + post :payplug_ipn + + post :vourcher + + get :particulars + post :particulars_save + get :select_payment + get :select_fdp + post :select_fdp_save + get :select_fdp_save + post :select_payment_save + + + get :payment_instructions + + end + + end + resources :product_order_products + + + resources :product_customers do + member do + get :confirm + get :mail + get :mail_confirm + get :show_details + end + + collection do + get :find_parrain + end + + end + + resources :product_customers_auths do + + collection do + + get :logout + + end + end + + resources :reseauxes do + resources :products + + end resources :virements resources :comments resources :customer_messages do @@ -237,6 +306,48 @@ Rails.application.routes.draw do end namespace :admin do + + resources :product_order_payments + resources :product_orders do + member do + get :ship + + get :bill + end + end + + + resources :product_sizes do + collection do + get :reorder + end + end + resources :product_images do + collection do + get :reorder + end + end + resources :product_categories do + collection do + post :reorder + end + resources :product_collections + end + resources :products do + collection do + post :reorder + end + + member do + get :stock + end + + end + + + + + resources :reseauxes resources :documents diff --git a/db/migrate/0000_create_lang_sites.rb b/db/migrate/0000_create_lang_sites.rb new file mode 100644 index 0000000..5602eef --- /dev/null +++ b/db/migrate/0000_create_lang_sites.rb @@ -0,0 +1,15 @@ +class CreateLangSites < ActiveRecord::Migration + def change + create_table :lang_sites do |t| + t.string :name + t.string :slug + t.boolean :enabled + + t.timestamps null: false + end + + LangSite.create(:name => "Français", :slug => "fr", :enabled => true) + + + end +end diff --git a/db/migrate/20160209225738_create_product_categories.rb b/db/migrate/20160209225738_create_product_categories.rb new file mode 100755 index 0000000..04b3caf --- /dev/null +++ b/db/migrate/20160209225738_create_product_categories.rb @@ -0,0 +1,9 @@ +class CreateProductCategories < ActiveRecord::Migration + def change + create_table :product_categories do |t| + t.integer :parent_id + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20160209230130_create_product_category_langs.rb b/db/migrate/20160209230130_create_product_category_langs.rb new file mode 100755 index 0000000..46aa7bd --- /dev/null +++ b/db/migrate/20160209230130_create_product_category_langs.rb @@ -0,0 +1,13 @@ +class CreateProductCategoryLangs < ActiveRecord::Migration + def change + create_table :product_category_langs do |t| + t.string :name + t.string :slug + t.string :lang + t.references :product_category, index: true + + t.timestamps null: false + end + add_foreign_key :product_category_langs, :product_categories + end +end diff --git a/db/migrate/20160209230957_create_product_collections.rb b/db/migrate/20160209230957_create_product_collections.rb new file mode 100755 index 0000000..5dbcad1 --- /dev/null +++ b/db/migrate/20160209230957_create_product_collections.rb @@ -0,0 +1,10 @@ +class CreateProductCollections < ActiveRecord::Migration + def change + create_table :product_collections do |t| + t.references :product_category, index: true + + t.timestamps null: false + end + add_foreign_key :product_collections, :product_categories + end +end diff --git a/db/migrate/20160209231058_create_product_collection_langs.rb b/db/migrate/20160209231058_create_product_collection_langs.rb new file mode 100755 index 0000000..baee059 --- /dev/null +++ b/db/migrate/20160209231058_create_product_collection_langs.rb @@ -0,0 +1,13 @@ +class CreateProductCollectionLangs < ActiveRecord::Migration + def change + create_table :product_collection_langs do |t| + t.string :name + t.string :slug + t.string :lang + t.references :product_collection, index: true + + t.timestamps null: false + end + add_foreign_key :product_collection_langs, :product_collections + end +end diff --git a/db/migrate/20160209232420_add_position_to_product_categories.rb b/db/migrate/20160209232420_add_position_to_product_categories.rb new file mode 100755 index 0000000..13842ac --- /dev/null +++ b/db/migrate/20160209232420_add_position_to_product_categories.rb @@ -0,0 +1,6 @@ +class AddPositionToProductCategories < ActiveRecord::Migration + def change + add_column :product_categories, :position, :integer + add_column :product_categories, :description, :text + end +end diff --git a/db/migrate/20160214154854_create_products.rb b/db/migrate/20160214154854_create_products.rb new file mode 100755 index 0000000..48bff49 --- /dev/null +++ b/db/migrate/20160214154854_create_products.rb @@ -0,0 +1,13 @@ +class CreateProducts < ActiveRecord::Migration + def change + create_table :products do |t| + t.decimal :price_ht, precision: 10, scale: 2 + t.decimal :price_reduced_ht, precision: 10, scale: 2 + t.boolean :enabled + t.integer :default_image_id + t.integer :position + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20160214155054_create_product_langs.rb b/db/migrate/20160214155054_create_product_langs.rb new file mode 100755 index 0000000..2185b5d --- /dev/null +++ b/db/migrate/20160214155054_create_product_langs.rb @@ -0,0 +1,17 @@ +class CreateProductLangs < ActiveRecord::Migration + def change + create_table :product_langs do |t| + t.string :title + t.string :lang + t.text :description + t.string :slug + t.references :product_category, index: true + t.references :product_collection, index: true + t.references :product, index: true + + t.timestamps null: false + end + add_foreign_key :product_langs, :product_categories + add_foreign_key :product_langs, :product_collections + end +end diff --git a/db/migrate/20160214173635_create_product_options.rb b/db/migrate/20160214173635_create_product_options.rb new file mode 100755 index 0000000..d61f706 --- /dev/null +++ b/db/migrate/20160214173635_create_product_options.rb @@ -0,0 +1,10 @@ +class CreateProductOptions < ActiveRecord::Migration + def change + create_table :product_options do |t| + t.references :product, index: true + + t.timestamps null: false + end + add_foreign_key :product_options, :products + end +end diff --git a/db/migrate/20160214173944_create_product_option_langs.rb b/db/migrate/20160214173944_create_product_option_langs.rb new file mode 100755 index 0000000..dfb3a2a --- /dev/null +++ b/db/migrate/20160214173944_create_product_option_langs.rb @@ -0,0 +1,12 @@ +class CreateProductOptionLangs < ActiveRecord::Migration + def change + create_table :product_option_langs do |t| + t.string :lang + t.references :product_option, index: true + t.string :name + + t.timestamps null: false + end + add_foreign_key :product_option_langs, :product_options + end +end diff --git a/db/migrate/20160214183718_create_product_images.rb b/db/migrate/20160214183718_create_product_images.rb new file mode 100755 index 0000000..9a045a8 --- /dev/null +++ b/db/migrate/20160214183718_create_product_images.rb @@ -0,0 +1,14 @@ +class CreateProductImages < ActiveRecord::Migration + def change + create_table :product_images do |t| + t.string :title + t.text :description + t.integer :position + t.references :image_file, index: true + t.references :product + + t.timestamps null: false + end + add_foreign_key :product_images, :image_files + end +end diff --git a/db/migrate/20160214204019_add_cats_to_products.rb b/db/migrate/20160214204019_add_cats_to_products.rb new file mode 100755 index 0000000..fa68f51 --- /dev/null +++ b/db/migrate/20160214204019_add_cats_to_products.rb @@ -0,0 +1,8 @@ +class AddCatsToProducts < ActiveRecord::Migration + def change + add_reference :products, :product_category, index: true + add_foreign_key :products, :product_categories + add_reference :products, :product_collection, index: true + add_foreign_key :products, :product_collections + end +end diff --git a/db/migrate/20160216174039_create_product_sizes.rb b/db/migrate/20160216174039_create_product_sizes.rb new file mode 100755 index 0000000..fd58126 --- /dev/null +++ b/db/migrate/20160216174039_create_product_sizes.rb @@ -0,0 +1,9 @@ +class CreateProductSizes < ActiveRecord::Migration + def change + create_table :product_sizes do |t| + t.string :name + t.integer :position + t.timestamps null: false + end + end +end diff --git a/db/migrate/20160216174106_create_product_product_sizes.rb b/db/migrate/20160216174106_create_product_product_sizes.rb new file mode 100755 index 0000000..73adef9 --- /dev/null +++ b/db/migrate/20160216174106_create_product_product_sizes.rb @@ -0,0 +1,13 @@ +class CreateProductProductSizes < ActiveRecord::Migration + def change + create_table :product_product_sizes do |t| + t.references :product, index: true + t.references :product_size, index: true + + + t.timestamps null: false + end + add_foreign_key :product_product_sizes, :products + add_foreign_key :product_product_sizes, :product_sizes + end +end diff --git a/db/migrate/20160229230155_create_product_orders.rb b/db/migrate/20160229230155_create_product_orders.rb new file mode 100755 index 0000000..25553c6 --- /dev/null +++ b/db/migrate/20160229230155_create_product_orders.rb @@ -0,0 +1,23 @@ +class CreateProductOrders < ActiveRecord::Migration + def change + create_table :product_orders do |t| + t.decimal :amount, precision: 10, scale: 2 + t.boolean :particular_idem, :default => false + t.boolean :paid, :default => false + t.integer :particular_bill_id + t.string :particular_send_id + t.string :token + t.boolean :completed_finish, :default => false + t.integer :product_order_payment_ok + t.integer :product_order_payment_type_ok_id + t.integer :bill_index + t.string :bill_number + t.string :bill_year + t.boolean :bill_ok, :default => false + t.references :product_customer + t.datetime :paid_at + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20160229231722_create_product_order_products.rb b/db/migrate/20160229231722_create_product_order_products.rb new file mode 100755 index 0000000..86b0dad --- /dev/null +++ b/db/migrate/20160229231722_create_product_order_products.rb @@ -0,0 +1,19 @@ +class CreateProductOrderProducts < ActiveRecord::Migration + def change + create_table :product_order_products do |t| + t.references :product_order + t.references :product + t.string :name + t.decimal :price_ht, precision: 10, scale: 2 + t.decimal :price_reduced_ht, precision: 10, scale: 2 + t.integer :product_archived_id + t.decimal :qty + t.decimal :total, precision: 10, scale: 2 + t.integer :product_size_id + t.integer :product_option_id + + t.timestamps null: false + end + + end +end diff --git a/db/migrate/20160229231818_add_archived_to_products.rb b/db/migrate/20160229231818_add_archived_to_products.rb new file mode 100755 index 0000000..0653402 --- /dev/null +++ b/db/migrate/20160229231818_add_archived_to_products.rb @@ -0,0 +1,5 @@ +class AddArchivedToProducts < ActiveRecord::Migration + def change + add_column :products, :archived, :boolean, :default => false + end +end diff --git a/db/migrate/20160302205347_create_product_customers.rb b/db/migrate/20160302205347_create_product_customers.rb new file mode 100755 index 0000000..64a7b99 --- /dev/null +++ b/db/migrate/20160302205347_create_product_customers.rb @@ -0,0 +1,28 @@ +class CreateProductCustomers < ActiveRecord::Migration + def change + create_table :product_customers do |t| + t.string :email + + t.string :password_digest, :null => false, :default => "" + + ## Recoverable + t.string :reset_password_token + t.datetime :reset_password_sent_at + + ## Rememberable + t.datetime :remember_created_at + + ## Trackable + t.integer :sign_in_count, :default => 0 + t.datetime :current_sign_in_at + t.datetime :last_sign_in_at + t.string :current_sign_in_ip + t.string :last_sign_in_ip + + t.boolean :lock + t.datetime :locked_at + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20160303203749_add_remote_ip_to_product_customer.rb b/db/migrate/20160303203749_add_remote_ip_to_product_customer.rb new file mode 100755 index 0000000..ac9dd2f --- /dev/null +++ b/db/migrate/20160303203749_add_remote_ip_to_product_customer.rb @@ -0,0 +1,6 @@ +class AddRemoteIpToProductCustomer < ActiveRecord::Migration + def change + add_column :product_customers, :remote_ip, :string + add_column :product_customers, :token, :string + end +end diff --git a/db/migrate/20160303214530_add_particulars_to_product_customers.rb b/db/migrate/20160303214530_add_particulars_to_product_customers.rb new file mode 100755 index 0000000..c2e5c6d --- /dev/null +++ b/db/migrate/20160303214530_add_particulars_to_product_customers.rb @@ -0,0 +1,7 @@ +class AddParticularsToProductCustomers < ActiveRecord::Migration + def change + add_column :product_customers, :particular_idem, :boolean, :default => false + add_column :product_customers, :particular_bill_id, :integer + add_column :product_customers, :particular_send_id, :integer + end +end diff --git a/db/migrate/20160304111746_add_archived_options_to_product_order_product.rb b/db/migrate/20160304111746_add_archived_options_to_product_order_product.rb new file mode 100644 index 0000000..b7468c1 --- /dev/null +++ b/db/migrate/20160304111746_add_archived_options_to_product_order_product.rb @@ -0,0 +1,6 @@ +class AddArchivedOptionsToProductOrderProduct < ActiveRecord::Migration + def change + add_column :product_order_products, :archived_product_option_id, :integer + add_column :product_order_products, :archived_product_size_id, :integer + end +end diff --git a/db/migrate/20160304115835_change_product_order_product_attribute_name.rb b/db/migrate/20160304115835_change_product_order_product_attribute_name.rb new file mode 100644 index 0000000..584604b --- /dev/null +++ b/db/migrate/20160304115835_change_product_order_product_attribute_name.rb @@ -0,0 +1,5 @@ +class ChangeProductOrderProductAttributeName < ActiveRecord::Migration + def change + rename_column :product_order_products, :product_archived_id, :archived_product_id + end +end diff --git a/db/migrate/20160304132328_add_image_file_to_product_categories.rb b/db/migrate/20160304132328_add_image_file_to_product_categories.rb new file mode 100644 index 0000000..9bae606 --- /dev/null +++ b/db/migrate/20160304132328_add_image_file_to_product_categories.rb @@ -0,0 +1,5 @@ +class AddImageFileToProductCategories < ActiveRecord::Migration + def change + add_column :product_categories, :image_file_id, :integer + end +end diff --git a/db/migrate/20160304215405_add_descriptio_to_product_category_langs.rb b/db/migrate/20160304215405_add_descriptio_to_product_category_langs.rb new file mode 100644 index 0000000..22ed55e --- /dev/null +++ b/db/migrate/20160304215405_add_descriptio_to_product_category_langs.rb @@ -0,0 +1,5 @@ +class AddDescriptioToProductCategoryLangs < ActiveRecord::Migration + def change + add_column :product_category_langs, :description, :text + end +end diff --git a/db/migrate/20160304215502_add_descriptio_to_product_collection_langs.rb b/db/migrate/20160304215502_add_descriptio_to_product_collection_langs.rb new file mode 100644 index 0000000..0bcaaaf --- /dev/null +++ b/db/migrate/20160304215502_add_descriptio_to_product_collection_langs.rb @@ -0,0 +1,5 @@ +class AddDescriptioToProductCollectionLangs < ActiveRecord::Migration + def change + add_column :product_collection_langs, :description, :text + end +end diff --git a/db/migrate/20160305180845_add_image_to_collection.rb b/db/migrate/20160305180845_add_image_to_collection.rb new file mode 100644 index 0000000..145f8df --- /dev/null +++ b/db/migrate/20160305180845_add_image_to_collection.rb @@ -0,0 +1,5 @@ +class AddImageToCollection < ActiveRecord::Migration + def change + add_column :product_collections, :image_fille_id, :integer + end +end diff --git a/db/migrate/20160306133908_create_product_stocks.rb b/db/migrate/20160306133908_create_product_stocks.rb new file mode 100644 index 0000000..4199e50 --- /dev/null +++ b/db/migrate/20160306133908_create_product_stocks.rb @@ -0,0 +1,19 @@ +class CreateProductStocks < ActiveRecord::Migration + def change + create_table :product_stocks do |t| + t.references :product, index: true + t.integer :product_size_id + t.integer :product_option_id + t.integer :stock + t.integer :stock_th + + t.timestamps null: false + end + add_foreign_key :product_stocks, :products + + Product.all.each do |product| + product.save + end + + end +end diff --git a/db/migrate/20160309104918_create_product_fdps.rb b/db/migrate/20160309104918_create_product_fdps.rb new file mode 100644 index 0000000..c062f2c --- /dev/null +++ b/db/migrate/20160309104918_create_product_fdps.rb @@ -0,0 +1,19 @@ +class CreateProductFdps < ActiveRecord::Migration + def change + create_table :product_fdps do |t| + t.decimal :price, precision: 10, scale: 2 + t.text :country + t.string :fdp_description + t.decimal :price_max, precision: 10, scale: 2 + t.string :delais + + t.timestamps null: false + end + + + ProductFdp.create(:fdp_description => "LIVRAISON EN FRANCE METROPOLITAINE ET CORSE", :price => 7, :price_max =>999999, :delais => "2 à 5 jours ouvrés", :country => "FR") + + ProductFdp.create(:fdp_description => "LIVRAISON VERS L'OUTRE MER ET L’INTERNATIONAL", :price => 15, :price_max => 999999, :delais => "5 à 10 jours ouvrés", :country => "all") + + end +end diff --git a/db/migrate/20160309111107_add_product_fdp_to_product_order.rb b/db/migrate/20160309111107_add_product_fdp_to_product_order.rb new file mode 100644 index 0000000..9a501b9 --- /dev/null +++ b/db/migrate/20160309111107_add_product_fdp_to_product_order.rb @@ -0,0 +1,5 @@ +class AddProductFdpToProductOrder < ActiveRecord::Migration + def change + add_column :product_orders, :product_fdp_id, :integer + end +end diff --git a/db/migrate/20160309193926_create_product_order_payments.rb b/db/migrate/20160309193926_create_product_order_payments.rb new file mode 100644 index 0000000..cf097a4 --- /dev/null +++ b/db/migrate/20160309193926_create_product_order_payments.rb @@ -0,0 +1,24 @@ +class CreateProductOrderPayments < ActiveRecord::Migration + def change + create_table :product_order_payments do |t| + t.integer :product_order_payment_type_id + + t.integer :product_order_id + + t.decimal :amount + t.string :check_number + t.string :check_bank + t.string :payplug_payment_id + t.string :payplug_card_id + t.string :payplug_card_expiry_month + t.string :payplug_card_expiry_year + t.string :payplug_card_last_number + t.datetime :paid_at + t.datetime :tr_canceled_at + t.boolean :tr_canceled, :default => false + t.string :token + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20160309234817_add_archive_fdp_to_product_orders.rb b/db/migrate/20160309234817_add_archive_fdp_to_product_orders.rb new file mode 100644 index 0000000..0e33142 --- /dev/null +++ b/db/migrate/20160309234817_add_archive_fdp_to_product_orders.rb @@ -0,0 +1,7 @@ +class AddArchiveFdpToProductOrders < ActiveRecord::Migration + def change + add_column :product_orders, :product_fdp_archived_id, :integer + + add_column :product_fdps, :archived, :boolean + end +end diff --git a/db/migrate/20160312131410_add_archived_to_product_options.rb b/db/migrate/20160312131410_add_archived_to_product_options.rb new file mode 100644 index 0000000..a249f04 --- /dev/null +++ b/db/migrate/20160312131410_add_archived_to_product_options.rb @@ -0,0 +1,10 @@ +class AddArchivedToProductOptions < ActiveRecord::Migration + def change + add_column :product_options, :archived, :boolean + add_column :product_option_langs, :archived, :boolean + add_column :product_sizes, :archived, :boolean + add_column :product_langs, :archived, :boolean + + + end +end \ No newline at end of file diff --git a/db/migrate/20160312234811_add_cgv_to_product_orders.rb b/db/migrate/20160312234811_add_cgv_to_product_orders.rb new file mode 100644 index 0000000..8d85992 --- /dev/null +++ b/db/migrate/20160312234811_add_cgv_to_product_orders.rb @@ -0,0 +1,5 @@ +class AddCgvToProductOrders < ActiveRecord::Migration + def change + add_column :product_orders, :cgv, :boolean + end +end diff --git a/db/migrate/20160328212528_add_color_to_product_categories.rb b/db/migrate/20160328212528_add_color_to_product_categories.rb new file mode 100644 index 0000000..ad8f13a --- /dev/null +++ b/db/migrate/20160328212528_add_color_to_product_categories.rb @@ -0,0 +1,7 @@ +class AddColorToProductCategories < ActiveRecord::Migration + def change + add_column :product_categories, :color, :string + add_column :product_categories, :image_file_left_id, :integer + add_column :product_categories, :image_file_right_id, :integer + end +end diff --git a/db/migrate/20160328212556_add_color_to_product_collections.rb b/db/migrate/20160328212556_add_color_to_product_collections.rb new file mode 100644 index 0000000..c79e819 --- /dev/null +++ b/db/migrate/20160328212556_add_color_to_product_collections.rb @@ -0,0 +1,5 @@ +class AddColorToProductCollections < ActiveRecord::Migration + def change + add_column :product_collections, :color, :string + end +end diff --git a/db/migrate/20160330180631_add_top_image_to_product_categories.rb b/db/migrate/20160330180631_add_top_image_to_product_categories.rb new file mode 100644 index 0000000..3d22add --- /dev/null +++ b/db/migrate/20160330180631_add_top_image_to_product_categories.rb @@ -0,0 +1,5 @@ +class AddTopImageToProductCategories < ActiveRecord::Migration + def change + add_column :product_categories, :top_image_id, :integer + end +end diff --git a/db/migrate/20170912112150_add_images_to_reseauxes.rb b/db/migrate/20170912112150_add_images_to_reseauxes.rb new file mode 100644 index 0000000..bb43794 --- /dev/null +++ b/db/migrate/20170912112150_add_images_to_reseauxes.rb @@ -0,0 +1,8 @@ +class AddImagesToReseauxes < ActiveRecord::Migration + def change + add_column :reseauxes, :logo_image_file_id, :integer + add_column :reseauxes, :background_image_file_id, :integer + add_column :reseauxes, :title, :string + + end +end diff --git a/db/migrate/20170912122525_add_reseaux_to_products.rb b/db/migrate/20170912122525_add_reseaux_to_products.rb new file mode 100644 index 0000000..bc36579 --- /dev/null +++ b/db/migrate/20170912122525_add_reseaux_to_products.rb @@ -0,0 +1,5 @@ +class AddReseauxToProducts < ActiveRecord::Migration + def change + add_column :products, :reseaux_id, :integer + end +end diff --git a/db/migrate/20170912164519_add_customer_to_product_orders.rb b/db/migrate/20170912164519_add_customer_to_product_orders.rb new file mode 100644 index 0000000..48694cb --- /dev/null +++ b/db/migrate/20170912164519_add_customer_to_product_orders.rb @@ -0,0 +1,5 @@ +class AddCustomerToProductOrders < ActiveRecord::Migration + def change + add_column :product_orders, :customer_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 12a6dd8..51aa35c 100755 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170605134146) do +ActiveRecord::Schema.define(version: 20170912164519) do create_table "accepted_offers", force: :cascade do |t| t.datetime "created_at", null: false @@ -413,6 +413,14 @@ ActiveRecord::Schema.define(version: 20170605134146) do t.datetime "updated_at" end + create_table "lang_sites", force: :cascade do |t| + t.string "name", limit: 255 + t.string "slug", limit: 255 + t.boolean "enabled", limit: 1 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "link_contents", force: :cascade do |t| t.integer "type", limit: 4 t.string "name", limit: 255 @@ -600,6 +608,242 @@ ActiveRecord::Schema.define(version: 20170605134146) do t.datetime "updated_at" end + create_table "product_categories", force: :cascade do |t| + t.integer "parent_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "position", limit: 4 + t.text "description", limit: 65535 + t.integer "image_file_id", limit: 4 + t.string "color", limit: 255 + t.integer "image_file_left_id", limit: 4 + t.integer "image_file_right_id", limit: 4 + t.integer "top_image_id", limit: 4 + end + + create_table "product_category_langs", force: :cascade do |t| + t.string "name", limit: 255 + t.string "slug", limit: 255 + t.string "lang", limit: 255 + t.integer "product_category_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.text "description", limit: 65535 + end + + add_index "product_category_langs", ["product_category_id"], name: "index_product_category_langs_on_product_category_id", using: :btree + + create_table "product_collection_langs", force: :cascade do |t| + t.string "name", limit: 255 + t.string "slug", limit: 255 + t.string "lang", limit: 255 + t.integer "product_collection_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.text "description", limit: 65535 + end + + add_index "product_collection_langs", ["product_collection_id"], name: "index_product_collection_langs_on_product_collection_id", using: :btree + + create_table "product_collections", force: :cascade do |t| + t.integer "product_category_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "image_fille_id", limit: 4 + t.string "color", limit: 255 + end + + add_index "product_collections", ["product_category_id"], name: "index_product_collections_on_product_category_id", using: :btree + + create_table "product_customers", force: :cascade do |t| + t.string "email", limit: 255 + t.string "password_digest", limit: 255, default: "", null: false + t.string "reset_password_token", limit: 255 + t.datetime "reset_password_sent_at" + t.datetime "remember_created_at" + t.integer "sign_in_count", limit: 4, default: 0 + t.datetime "current_sign_in_at" + t.datetime "last_sign_in_at" + t.string "current_sign_in_ip", limit: 255 + t.string "last_sign_in_ip", limit: 255 + t.boolean "lock", limit: 1 + t.datetime "locked_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "remote_ip", limit: 255 + t.string "token", limit: 255 + t.boolean "particular_idem", limit: 1, default: false + t.integer "particular_bill_id", limit: 4 + t.integer "particular_send_id", limit: 4 + end + + create_table "product_fdps", force: :cascade do |t| + t.decimal "price", precision: 10, scale: 2 + t.text "country", limit: 65535 + t.string "fdp_description", limit: 255 + t.decimal "price_max", precision: 10, scale: 2 + t.string "delais", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "archived", limit: 1 + end + + create_table "product_images", force: :cascade do |t| + t.string "title", limit: 255 + t.text "description", limit: 65535 + t.integer "position", limit: 4 + t.integer "image_file_id", limit: 4 + t.integer "product_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "product_images", ["image_file_id"], name: "index_product_images_on_image_file_id", using: :btree + + create_table "product_langs", force: :cascade do |t| + t.string "title", limit: 255 + t.string "lang", limit: 255 + t.text "description", limit: 65535 + t.string "slug", limit: 255 + t.integer "product_category_id", limit: 4 + t.integer "product_collection_id", limit: 4 + t.integer "product_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "archived", limit: 1 + end + + add_index "product_langs", ["product_category_id"], name: "index_product_langs_on_product_category_id", using: :btree + add_index "product_langs", ["product_collection_id"], name: "index_product_langs_on_product_collection_id", using: :btree + add_index "product_langs", ["product_id"], name: "index_product_langs_on_product_id", using: :btree + + create_table "product_option_langs", force: :cascade do |t| + t.string "lang", limit: 255 + t.integer "product_option_id", limit: 4 + t.string "name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "archived", limit: 1 + end + + add_index "product_option_langs", ["product_option_id"], name: "index_product_option_langs_on_product_option_id", using: :btree + + create_table "product_options", force: :cascade do |t| + t.integer "product_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "archived", limit: 1 + end + + add_index "product_options", ["product_id"], name: "index_product_options_on_product_id", using: :btree + + create_table "product_order_payments", force: :cascade do |t| + t.integer "product_order_payment_type_id", limit: 4 + t.integer "product_order_id", limit: 4 + t.decimal "amount", precision: 10 + t.string "check_number", limit: 255 + t.string "check_bank", limit: 255 + t.string "payplug_payment_id", limit: 255 + t.string "payplug_card_id", limit: 255 + t.string "payplug_card_expiry_month", limit: 255 + t.string "payplug_card_expiry_year", limit: 255 + t.string "payplug_card_last_number", limit: 255 + t.datetime "paid_at" + t.datetime "tr_canceled_at" + t.boolean "tr_canceled", limit: 1, default: false + t.string "token", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "product_order_products", force: :cascade do |t| + t.integer "product_order_id", limit: 4 + t.integer "product_id", limit: 4 + t.string "name", limit: 255 + t.decimal "price_ht", precision: 10, scale: 2 + t.decimal "price_reduced_ht", precision: 10, scale: 2 + t.integer "archived_product_id", limit: 4 + t.decimal "qty", precision: 10 + t.decimal "total", precision: 10, scale: 2 + t.integer "product_size_id", limit: 4 + t.integer "product_option_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "archived_product_option_id", limit: 4 + t.integer "archived_product_size_id", limit: 4 + end + + create_table "product_orders", force: :cascade do |t| + t.decimal "amount", precision: 10, scale: 2 + t.boolean "particular_idem", limit: 1, default: false + t.boolean "paid", limit: 1, default: false + t.integer "particular_bill_id", limit: 4 + t.string "particular_send_id", limit: 255 + t.string "token", limit: 255 + t.boolean "completed_finish", limit: 1, default: false + t.integer "product_order_payment_ok", limit: 4 + t.integer "product_order_payment_type_ok_id", limit: 4 + t.integer "bill_index", limit: 4 + t.string "bill_number", limit: 255 + t.string "bill_year", limit: 255 + t.boolean "bill_ok", limit: 1, default: false + t.integer "product_customer_id", limit: 4 + t.datetime "paid_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "product_fdp_id", limit: 4 + t.integer "product_fdp_archived_id", limit: 4 + t.boolean "cgv", limit: 1 + t.integer "customer_id", limit: 4 + end + + create_table "product_product_sizes", force: :cascade do |t| + t.integer "product_id", limit: 4 + t.integer "product_size_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "product_product_sizes", ["product_id"], name: "index_product_product_sizes_on_product_id", using: :btree + add_index "product_product_sizes", ["product_size_id"], name: "index_product_product_sizes_on_product_size_id", using: :btree + + create_table "product_sizes", force: :cascade do |t| + t.string "name", limit: 255 + t.integer "position", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "archived", limit: 1 + end + + create_table "product_stocks", force: :cascade do |t| + t.integer "product_id", limit: 4 + t.integer "product_size_id", limit: 4 + t.integer "product_option_id", limit: 4 + t.integer "stock", limit: 4 + t.integer "stock_th", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "product_stocks", ["product_id"], name: "index_product_stocks_on_product_id", using: :btree + + create_table "products", force: :cascade do |t| + t.decimal "price_ht", precision: 10, scale: 2 + t.decimal "price_reduced_ht", precision: 10, scale: 2 + t.boolean "enabled", limit: 1 + t.integer "default_image_id", limit: 4 + t.integer "position", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "product_category_id", limit: 4 + t.integer "product_collection_id", limit: 4 + t.boolean "archived", limit: 1, default: false + t.integer "reseaux_id", limit: 4 + end + + add_index "products", ["product_category_id"], name: "index_products_on_product_category_id", using: :btree + add_index "products", ["product_collection_id"], name: "index_products_on_product_collection_id", using: :btree + create_table "reseaux_customers", force: :cascade do |t| t.integer "reseaux_id", limit: 4 t.integer "customer_id", limit: 4 @@ -611,13 +855,16 @@ ActiveRecord::Schema.define(version: 20170605134146) do add_index "reseaux_customers", ["reseaux_id"], name: "index_reseaux_customers_on_reseaux_id", using: :btree create_table "reseauxes", force: :cascade do |t| - t.string "name", limit: 255 - t.text "description", limit: 65535 - t.integer "chef_reseau_id", limit: 4 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "token", limit: 255 - t.integer "parent_id", limit: 4 + t.string "name", limit: 255 + t.text "description", limit: 65535 + t.integer "chef_reseau_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "token", limit: 255 + t.integer "parent_id", limit: 4 + t.integer "logo_image_file_id", limit: 4 + t.integer "background_image_file_id", limit: 4 + t.string "title", limit: 255 end create_table "sessions", force: :cascade do |t| @@ -710,6 +957,19 @@ ActiveRecord::Schema.define(version: 20170605134146) do add_foreign_key "domain_needs", "needs" add_foreign_key "offer_reseauxes", "offers" add_foreign_key "offer_reseauxes", "reseauxes" + add_foreign_key "product_category_langs", "product_categories" + add_foreign_key "product_collection_langs", "product_collections" + add_foreign_key "product_collections", "product_categories" + add_foreign_key "product_images", "image_files" + add_foreign_key "product_langs", "product_categories" + add_foreign_key "product_langs", "product_collections" + add_foreign_key "product_option_langs", "product_options" + add_foreign_key "product_options", "products" + add_foreign_key "product_product_sizes", "product_sizes" + add_foreign_key "product_product_sizes", "products" + add_foreign_key "product_stocks", "products" + add_foreign_key "products", "product_categories" + add_foreign_key "products", "product_collections" add_foreign_key "reseaux_customers", "customers" add_foreign_key "reseaux_customers", "reseauxes" add_foreign_key "thing_conversations", "conversations" diff --git a/public/logo-mb.png b/public/logo-mb.png new file mode 100644 index 0000000..17f3ccb Binary files /dev/null and b/public/logo-mb.png differ