mirror of
https://github.com/internetee/registry.git
synced 2025-05-22 04:09:52 +02:00
107279984-filter_changes
This commit is contained in:
parent
cbe0193cbf
commit
96552a0344
2 changed files with 49 additions and 5 deletions
|
@ -19,11 +19,51 @@ class Admin::AccountActivitiesController < AdminController
|
|||
end
|
||||
|
||||
@q = AccountActivity.includes(:invoice, account: :registrar).search(params[:q])
|
||||
@b = AccountActivity.search(balance_params)
|
||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||
@b = AccountActivity.search(balance_params).result.where.not(id: @q.result.map(&:id))
|
||||
|
||||
|
||||
|
||||
@account_activities = @q.result.page(params[:page]).per(params[:results_per_page])
|
||||
sort = @account_activities.orders.map(&:to_sql).join(",")
|
||||
|
||||
|
||||
if params[:page] && params[:page].to_i > 1
|
||||
|
||||
|
||||
@sum = @q.result.reorder(sort).limit(@account_activities.offset_value) + @b.result.where.not(id: @q.result.map(&:id))
|
||||
|
||||
else
|
||||
|
||||
@sum = @b.result.where.not(id: @q.result.map(&:id))
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# throw "cdsfs"
|
||||
|
||||
# if params[:page] && params[:page].to_i > 1
|
||||
#
|
||||
# @b = @q.result.page(params[:page].to_i - 1)
|
||||
#
|
||||
# @b = @b.per(params[:results_per_page])
|
||||
#
|
||||
#
|
||||
# else
|
||||
#
|
||||
# @b = AccountActivity.search(balance_params)
|
||||
#
|
||||
# @b = @b.result.where.not(id: @q.result.map(&:id))
|
||||
#
|
||||
# end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { @account_activities = @q.result.page(params[:page]) }
|
||||
format.html
|
||||
format.csv do
|
||||
send_data @q.result.to_csv, filename: "account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"
|
||||
end
|
||||
|
|
|
@ -29,7 +29,11 @@
|
|||
.form-group
|
||||
= f.label t(:receipt_date_until)
|
||||
= f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control datepicker', placeholder: t(:receipt_date_until), autocomplete: 'off'
|
||||
.col-md-6{style: 'padding-top: 25px;'}
|
||||
.col-md-3
|
||||
.form-group
|
||||
= label_tag t(:results_per_page)
|
||||
= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page)
|
||||
.col-md-3{style: 'padding-top: 25px;'}
|
||||
%button.btn.btn-default.search
|
||||
|
||||
%span.glyphicon.glyphicon-search
|
||||
|
@ -41,7 +45,7 @@
|
|||
.col-md-3
|
||||
.col-md-2
|
||||
.col-md-4{class: 'text-right'}
|
||||
= t(:starting_balance) + " #{@b.sum('sum').to_f} EUR"
|
||||
= t(:starting_balance) + " #{@sum.to_a.map(&:sum).sum.to_f} EUR"
|
||||
|
||||
%hr
|
||||
|
||||
|
@ -62,7 +66,7 @@
|
|||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'sum')
|
||||
%tbody
|
||||
-total = @b.sum('sum').to_f
|
||||
-total = @sum.to_a.map(&:sum).sum.to_f
|
||||
- @account_activities.each do |x|
|
||||
%tr
|
||||
%td= link_to(x.account.registrar.try(:code), admin_registrar_path(x.account.registrar))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue