suite
This commit is contained in:
parent
0b9daf14b2
commit
1b60863a55
@ -54,6 +54,9 @@ class Admin::PCustomerSheetsController < ApplicationController
|
||||
@p_customer_sheets = @p_customer_sheets.where("p_customer_sheets.created_at <= ?", @stop.end_of_day) if @stop
|
||||
|
||||
|
||||
@p_customer_sheets = @p_customer_sheets.where("state != 'panier' or cc_p_sheet_line_count > 0")
|
||||
|
||||
|
||||
if params[:search][:state].to_s != ""
|
||||
@p_customer_sheets = @p_customer_sheets.where(:state => params[:search][:state])
|
||||
end
|
||||
|
@ -31,10 +31,9 @@ class Admin::PCustomersController < ApplicationController
|
||||
def index
|
||||
@p_customers = PCustomer.order("created_at DESC").all
|
||||
|
||||
@fav_p_customers = PCustomer.where(:fav => true).order(:name).all
|
||||
|
||||
if params[:search].to_s != ""
|
||||
@p_customers = @p_customers.for_search(params[:search])
|
||||
if params[:search][:name].to_s != ""
|
||||
@p_customers = @p_customers.for_search(params[:search][:name])
|
||||
end
|
||||
|
||||
per_page = (params[:per_page] and params[:per_page] != "") ? params[:per_page] : 50
|
||||
|
@ -31,6 +31,25 @@ class PCustomer < ActiveRecord::Base
|
||||
has_many :mail_histories
|
||||
|
||||
|
||||
|
||||
#acts_as_caching :fields => [:total_ht, :total_tva, :total_ttc]
|
||||
|
||||
|
||||
acts_as_sorting :fields => {
|
||||
|
||||
#:code => {:name => "Code", :reorder => true},
|
||||
:show_name => {:name => "Nom", :reorder => false},
|
||||
:particular_cp => {:name => "CP", :reorder => false},
|
||||
:particular_city => {:name => "Ville", :reorder => true},
|
||||
:email => {:name => "Email", :reorder => true},
|
||||
:cache_encours => {:name => "Encours", :reorder => true},
|
||||
:emails => {:name => "Nbr emails", :reorder => true},
|
||||
:actions => {:name => "Actions", :reorder => false}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
attr_accessor :valid_public, :generate_mdp, :valid_siren
|
||||
before_validation do
|
||||
self.generate_token if !self.token? and self.email?
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
class PCustomerSheet < ActiveRecord::Base
|
||||
|
||||
acts_as_caching :fields => [:total_ht, :total_tva, :total_ttc]
|
||||
acts_as_caching :fields => [:total_ht, :total_tva, :total_ttc, :p_sheet_line_count]
|
||||
|
||||
acts_as_sorting :fields => {
|
||||
:id => {:name => "ID", :reorder => true},
|
||||
@ -34,6 +34,9 @@ class PCustomerSheet < ActiveRecord::Base
|
||||
end
|
||||
|
||||
|
||||
def ca_p_sheet_line_count
|
||||
self.p_sheet_lines.count
|
||||
end
|
||||
|
||||
|
||||
has_many :p_documents, :as => :element
|
||||
|
@ -1,7 +1,6 @@
|
||||
-totals = PSheetLine.totals(p_customer_sheet.p_sheet_lines)
|
||||
|
||||
-if (p_customer_sheet.state != "panier" or p_customer_sheet.p_sheet_lines.count > 0)
|
||||
%tr#p_customer_sheet{:id => p_customer_sheet.id}
|
||||
%tr#p_customer_sheet{:id => p_customer_sheet.id}
|
||||
-tr = {}
|
||||
|
||||
-tr[:id] = capture do
|
||||
@ -37,7 +36,7 @@
|
||||
=link_to i(:copy), dup_admin_p_customer_sheet_path(p_customer_sheet), :data => {:confirm => 'Voulez-vous vraiment dupliquer cette commande ?'}
|
||||
|
||||
-if p_customer_sheet.state == "brouillon"
|
||||
= link_to i(:"trash-o"), [:admin, p_customer_sheet], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet auteur ? ' } , :remote => true
|
||||
= link_to i(:"trash-o"), [:admin, p_customer_sheet], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cette offre ? ' } , :remote => true
|
||||
= link_to i(:pencil), edit_admin_p_customer_sheet_path(p_customer_sheet), :remote => false
|
||||
= link_to i(:eye), admin_p_customer_sheet_path(p_customer_sheet), :remote => false
|
||||
|
||||
|
@ -1,19 +1,21 @@
|
||||
%tr#p_customer{:id => p_customer.id, :class => ("table-warning" if !p_customer.account_validated)}
|
||||
%td= p_customer.email
|
||||
%td= p_customer.code
|
||||
%td= p_customer.show_name
|
||||
-tr = {}
|
||||
|
||||
|
||||
-tr[:particular_cp] = capture do
|
||||
%td= p_customer.particular.cp if p_customer.particular
|
||||
|
||||
-tr[:particular_city] = capture do
|
||||
%td= p_customer.particular.city if p_customer.particular
|
||||
|
||||
-tr[:cache_encours] = capture do
|
||||
%td
|
||||
-if p_customer.cache_encours < 0
|
||||
%span{:style => "color:green"}=number_to_currency p_customer.cache_encours
|
||||
-elsif p_customer.cache_encours > 0
|
||||
%span=number_to_currency p_customer.cache_encours
|
||||
|
||||
|
||||
-if false
|
||||
%td{:style => "text-align:right;"}=number_to_currency p_customer.p_customer_sheets.sum(:a_ok_total)
|
||||
-tr[:emails] = capture do
|
||||
%td
|
||||
-emails = []
|
||||
|
||||
@ -35,9 +37,11 @@
|
||||
=emails.size
|
||||
|
||||
|
||||
|
||||
-tr[:actions] = capture do
|
||||
%td.actions
|
||||
= link_to i(:"trash-o"), [:admin, p_customer], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet auteur ? ' } , :remote => true
|
||||
= link_to i(:pencil), edit_admin_p_customer_path(p_customer), :remote => true
|
||||
= link_to i(:eye), admin_p_customer_path(p_customer)
|
||||
|
||||
=render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_customer}
|
||||
|
||||
|
@ -7,57 +7,25 @@
|
||||
|
||||
|
||||
|
||||
-if false and params[:search].to_s == "" and ! params[:page]
|
||||
.qi_row
|
||||
.qi_pannel.qi_plain.padding
|
||||
|
||||
|
||||
%table.table
|
||||
%tr
|
||||
%th Email
|
||||
%th Code
|
||||
%th Nom
|
||||
%th CP
|
||||
%th Ville
|
||||
%th Encours
|
||||
%th Nbr emails
|
||||
%th
|
||||
|
||||
|
||||
%tbody#p_customers_rows
|
||||
=render @fav_p_customers
|
||||
|
||||
|
||||
.qi_row
|
||||
.qi_pannel.qi_plain.padding
|
||||
|
||||
.qi_search_row
|
||||
=form_tag "", :method => "get", :onsubmit => "" do
|
||||
-params[:search] =params[:search] || {}
|
||||
|
||||
|
||||
=text_field_tag :search, params[:search],:class => "form-control", :placeholder => "Rechercher"
|
||||
|
||||
|
||||
=submit_tag "Recherche", :class => "btn btn-default", :style => "margin-bottom: 10px;"
|
||||
|
||||
|
||||
|
||||
%table.table
|
||||
%table
|
||||
%tr
|
||||
%th Email
|
||||
%th Code
|
||||
%th Nom
|
||||
%th CP
|
||||
%th Ville
|
||||
%th Encours
|
||||
%th Nbr emails
|
||||
%th
|
||||
%td Nom :
|
||||
%td=text_field_tag "search[name]", params[:search][:name],:class => "form-control"
|
||||
|
||||
|
||||
%tbody#p_customers_rows
|
||||
=render @p_customers
|
||||
|
||||
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_customers}
|
||||
|
||||
|
||||
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_customers}
|
||||
|
||||
|
||||
|
||||
#pagination
|
||||
= paginate @p_customers #, :remote => true
|
||||
|
||||
|
11
db/migrate/20200319215725_add_cache_to_p_customer_sheets.rb
Normal file
11
db/migrate/20200319215725_add_cache_to_p_customer_sheets.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class AddCacheToPCustomerSheets < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :p_customer_sheets, :cc_p_sheet_line_count, :integer
|
||||
add_column :p_customer_sheets, :ac_p_sheet_line_count, :integer
|
||||
|
||||
PCustomerSheet.all.each do |pcs|
|
||||
pcs.save
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20200318223627) do
|
||||
ActiveRecord::Schema.define(version: 20200319215725) do
|
||||
|
||||
create_table "admin_admin_roles", force: :cascade do |t|
|
||||
t.integer "admin_id", limit: 4
|
||||
@ -871,6 +871,8 @@ ActiveRecord::Schema.define(version: 20200318223627) do
|
||||
t.decimal "cc_total_ttc", precision: 14, scale: 2
|
||||
t.decimal "ac_total_ttc", precision: 14, scale: 2
|
||||
t.boolean "archived", default: false
|
||||
t.integer "cc_p_sheet_line_count", limit: 4
|
||||
t.integer "ac_p_sheet_line_count", limit: 4
|
||||
end
|
||||
|
||||
add_index "p_customer_sheets", ["p_payment_type_id"], name: "index_p_customer_sheets_on_p_payment_type_id", using: :btree
|
||||
|
Loading…
x
Reference in New Issue
Block a user