suite
This commit is contained in:
parent
10bf7b95d0
commit
8399f37b09
108
app/controllers/admin/abonnements_controller.rb
Executable file
108
app/controllers/admin/abonnements_controller.rb
Executable file
@ -0,0 +1,108 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
|
||||
class Admin::AbonnementsController < ApplicationController
|
||||
before_filter :auth_admin
|
||||
|
||||
layout "admin"
|
||||
|
||||
|
||||
before_filter :find_abonnements
|
||||
|
||||
|
||||
def index
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def new
|
||||
@abonnement = Abonnement.new()
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@abonnement = Abonnement.find(params[:id])
|
||||
end
|
||||
|
||||
def show
|
||||
@abonnement = Abonnement.find(params[:id])
|
||||
end
|
||||
|
||||
|
||||
def create
|
||||
@abonnement = Abonnement.new(params.require(:abonnement).permit!)
|
||||
|
||||
|
||||
if @abonnement.save
|
||||
|
||||
find_abonnements
|
||||
flash[:notice] = "La catégorie à été ajouté avec succès."
|
||||
|
||||
|
||||
else
|
||||
render :action => "new"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def update
|
||||
@abonnement = Abonnement.find(params[:id])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
if @abonnement.update_attributes(params.require(:abonnement).permit!)
|
||||
|
||||
|
||||
|
||||
flash[:notice] = "Le menu à été modifié avec succès."
|
||||
|
||||
if @reorder
|
||||
format.js {
|
||||
|
||||
render :action => "update" }
|
||||
else
|
||||
format.js {
|
||||
@abonnement = Abonnement.find(@abonnement.id)
|
||||
render :action => "update_row" }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
@abonnement = Abonnement.find(params[:id])
|
||||
@abonnement.destroy
|
||||
find_abonnements
|
||||
|
||||
flash[:notice] = "La catégorie à bien été supprimée."
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
|
||||
def find_abonnements
|
||||
|
||||
@abonnements = Abonnement.order("created_at DESC").all
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
@ -10,7 +10,11 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
|
||||
def get_reseaux
|
||||
if session[:reseaux_id] and current_customer and !params[:no_reseaux]
|
||||
if params[:reseaux_id] and current_customer and !params[:no_reseaux]
|
||||
@reseaux = current_customer.reseauxes.find(params[:reseaux_id])
|
||||
@reseaux_layout = true
|
||||
session[:reseaux_id] = @reseaux.id
|
||||
elsif session[:reseaux_id] and current_customer and !params[:no_reseaux]
|
||||
@reseaux = current_customer.reseauxes.find(session[:reseaux_id])
|
||||
@reseaux_layout = true
|
||||
elsif !params[:no_reseaux]
|
||||
@ -72,6 +76,8 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
def require_negos_abo
|
||||
get_reseaux
|
||||
|
||||
if !current_abo and (!session[:reseaux_id] or (@reseaux and @reseaux.abo_needed))
|
||||
redirect_to new_public_abonnement_path
|
||||
end
|
||||
|
@ -10,6 +10,15 @@ class Public::NeedsController < ApplicationController
|
||||
before_filter :check_owner, only: [:destroy,:edit,:update]
|
||||
|
||||
def index
|
||||
#dsffsd = sdfd
|
||||
|
||||
if params[:reseaux_id]
|
||||
@reseaux = Reseaux.find(params[:reseaux_id])
|
||||
session[:reseaux_id] = @reseaux.id
|
||||
elsif session[:reseaux_id]
|
||||
@reseaux = Reseaux.find(session[:reseaux_id])
|
||||
end
|
||||
|
||||
params[:type] = params[:type] || 1
|
||||
|
||||
params[:type] = params[:type].to_i
|
||||
|
@ -3,6 +3,7 @@
|
||||
class Public::ProductsController < ApplicationController
|
||||
|
||||
before_filter :auth_customer
|
||||
before_filter :require_negos_abo
|
||||
layout "public"
|
||||
|
||||
def show
|
||||
|
@ -1,5 +1,6 @@
|
||||
class Abonnement < ActiveRecord::Base
|
||||
belongs_to :reseaux
|
||||
belongs_to :customer
|
||||
has_many :payments, :as => :element
|
||||
|
||||
def after_paid
|
||||
|
@ -288,6 +288,10 @@ class Customer < ActiveRecord::Base
|
||||
"#{firstname.capitalize} #{name.upcase}"
|
||||
end
|
||||
|
||||
def name_for_label
|
||||
"#{self.organisation} #{self.name.upcase} #{self.firstname.capitalize} - #{self.email}"
|
||||
end
|
||||
|
||||
def pseudo
|
||||
if self.pro
|
||||
self.organisation
|
||||
|
30
app/views/admin/abonnements/_abonnement.html.haml
Executable file
30
app/views/admin/abonnements/_abonnement.html.haml
Executable file
@ -0,0 +1,30 @@
|
||||
|
||||
%tr#abonnement.abonnement{:id => abonnement.id}
|
||||
|
||||
%td=abonnement.id
|
||||
%td
|
||||
-if abonnement.reseaux
|
||||
=abonnement.reseaux.name
|
||||
%td
|
||||
-if abonnement.customer
|
||||
=abonnement.customer.organisation
|
||||
=abonnement.customer.name
|
||||
=abonnement.customer.firstname
|
||||
|
||||
%td=abonnement.slug
|
||||
%td=l abonnement.start_at
|
||||
%td=l abonnement.end_at
|
||||
%td=number_to_currency abonnement.price
|
||||
%td=ic :check if abonnement.paid
|
||||
|
||||
|
||||
|
||||
|
||||
%td.actions
|
||||
=# link_to i(:"trash-o"), [:admin, abonnement], :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_abonnement_path(abonnement), :data => {:remote => true}
|
||||
|
||||
|
||||
|
||||
|
19
app/views/admin/abonnements/_form.html.haml
Executable file
19
app/views/admin/abonnements/_form.html.haml
Executable file
@ -0,0 +1,19 @@
|
||||
= semantic_form_for [:admin,@abonnement], :remote => true do |form|
|
||||
|
||||
.content
|
||||
= form.input :reseaux_id, :label => "Réseau :", :collection => Reseaux.where(:parent_id => nil).all, :as => :select, :include_blank => true
|
||||
=form.input :customer_id, :label => "Client :", :collection => Customer.order(:organisation, :name).all, :as => :select, :include_blank => true, :member_label => :name_for_label
|
||||
|
||||
= form.input :start_at, :label => "Début", :as => :date
|
||||
= form.input :end_at, :label => "Fin", :as => :date
|
||||
|
||||
= form.input :price, :label => "Prix :"
|
||||
= form.input :paid, :label => "Payé ?"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.actions
|
||||
= form.submit "Sauvegarder"
|
||||
|
4
app/views/admin/abonnements/create.js.erb
Executable file
4
app/views/admin/abonnements/create.js.erb
Executable file
@ -0,0 +1,4 @@
|
||||
close_pane_hover();
|
||||
|
||||
$('#abonnements').html("<%= escape_javascript(render(@abonnements)) %>");
|
||||
|
5
app/views/admin/abonnements/destroy.js.erb
Executable file
5
app/views/admin/abonnements/destroy.js.erb
Executable file
@ -0,0 +1,5 @@
|
||||
|
||||
$('#abonnement_<%= @abonnement.id %>').remove();
|
||||
|
||||
|
||||
<%= flash_js %>
|
1
app/views/admin/abonnements/edit.js.erb
Executable file
1
app/views/admin/abonnements/edit.js.erb
Executable file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600);
|
27
app/views/admin/abonnements/index.html.haml
Executable file
27
app/views/admin/abonnements/index.html.haml
Executable file
@ -0,0 +1,27 @@
|
||||
.qi_header
|
||||
.right= link_to 'Ajouter un abonnement manuellement', new_admin_abonnement_path, :class => "btn btn-primary", :remote => true
|
||||
%h1
|
||||
|
||||
Boutique
|
||||
%span
|
||||
Liste des documents
|
||||
|
||||
|
||||
|
||||
.qi_row
|
||||
.qi_pannel.qi_plain.padding
|
||||
%table.table
|
||||
|
||||
%tr
|
||||
%th ID
|
||||
%th Réseaux
|
||||
%th Client
|
||||
%th Slug
|
||||
%th Début
|
||||
%th Fin
|
||||
%th Prix
|
||||
%th Payé ?
|
||||
|
||||
%th
|
||||
|
||||
%tbody#abonnements=render @abonnements
|
1
app/views/admin/abonnements/new.js.erb
Executable file
1
app/views/admin/abonnements/new.js.erb
Executable file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600);
|
2
app/views/admin/abonnements/update_row.js.erb
Executable file
2
app/views/admin/abonnements/update_row.js.erb
Executable file
@ -0,0 +1,2 @@
|
||||
close_pane_hover();
|
||||
$('#abonnement_<%= @abonnement.id %>').replaceWith("<%= escape_javascript(render(@abonnement))%>");
|
@ -72,6 +72,7 @@
|
||||
%li= link_to "Type de documents", admin_product_order_document_types_path
|
||||
%li=# link_to "Codes de reduction", admin_vourcher_codes_path
|
||||
%li=link_to "Pages statiques", admin_menu_items_path(:menu_id => 1)
|
||||
%li=link_to "Abos", admin_abonnements_path()
|
||||
|
||||
%ul.nav.navbar-nav.navbar-right
|
||||
%li.dropdown
|
||||
|
@ -336,6 +336,14 @@ Rails.application.routes.draw do
|
||||
end
|
||||
|
||||
namespace :admin do
|
||||
resources :abonnements do
|
||||
|
||||
member do
|
||||
get :force
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
resources :fournisseurs
|
||||
resources :product_order_documents
|
||||
resources :product_order_document_types
|
||||
|
Loading…
x
Reference in New Issue
Block a user