mirror of
https://github.com/internetee/registry.git
synced 2025-05-28 16:39:55 +02:00
Add filter to account activities #2691
This commit is contained in:
parent
d6a151b141
commit
ca2a2db9ad
4 changed files with 61 additions and 4 deletions
|
@ -2,9 +2,17 @@ class Registrar::AccountActivitiesController < RegistrarController
|
|||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
params[:q] ||= {}
|
||||
account = current_user.registrar.cash_account
|
||||
|
||||
ca_cache = params[:q][:created_at_lteq]
|
||||
end_time = params[:q][:created_at_lteq].try(:to_date)
|
||||
params[:q][:created_at_lteq] = end_time.try(:end_of_day)
|
||||
|
||||
@q = account.activities.includes(:invoice).search(params[:q])
|
||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||
@account_activities = @q.result.page(params[:page])
|
||||
|
||||
params[:q][:created_at_lteq] = ca_cache
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,5 +13,11 @@ class AccountActivity < ActiveRecord::Base
|
|||
account.balance += sum
|
||||
account.save
|
||||
end
|
||||
|
||||
class << self
|
||||
def types_for_select
|
||||
[CREATE, RENEW, ADD_CREDIT].map { |x| [I18n.t(x), x] }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,16 +2,50 @@
|
|||
= link_to(t(:back_to_billing), registrar_invoices_path, class: 'btn btn-default')
|
||||
= render 'shared/title', name: t(:account_activity)
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
= search_form_for @q, url: [:registrar, :account_activities], html: { style: 'margin-bottom: 0;' } do |f|
|
||||
.row
|
||||
.col-md-6
|
||||
.form-group
|
||||
= f.label t(:activity_type)
|
||||
= f.select :activity_type_in, AccountActivity.types_for_select, {}, class: 'form-control js-combobox', placeholder: t(:choose), multiple: true
|
||||
.col-md-6
|
||||
.form-group
|
||||
= f.label t(:description)
|
||||
= f.search_field :description_cont, class: 'form-control', placeholder: t(:description), autocomplete: 'off'
|
||||
.row
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label t(:receipt_date_from)
|
||||
= f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control datepicker', placeholder: t(:receipt_date_from), autocomplete: 'off'
|
||||
.col-md-3
|
||||
.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-3{style: 'padding-top: 25px;'}
|
||||
%button.btn.btn-default
|
||||
|
||||
%span.glyphicon.glyphicon-search
|
||||
|
||||
%button.btn.btn-default.js-reset-form
|
||||
= t(:clear_fields)
|
||||
%hr
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-5'}= t(:description)
|
||||
%th{class: 'col-xs-3'}= t(:receipt_date)
|
||||
%th{class: 'col-xs-2'}= t(:invoice)
|
||||
%th{class: 'col-xs-2'}= t(:sum)
|
||||
%th{class: 'col-xs-5'}
|
||||
= sort_link(@q, 'description')
|
||||
%th{class: 'col-xs-3'}
|
||||
= sort_link(@q, 'created_at', t(:receipt_date))
|
||||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'invoice_id', t(:invoice))
|
||||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'sum')
|
||||
%tbody
|
||||
- @account_activities.each do |x|
|
||||
%tr
|
||||
|
@ -27,3 +61,8 @@
|
|||
.row
|
||||
.col-md-12
|
||||
= paginate @account_activities
|
||||
|
||||
:coffee
|
||||
$(".js-reset-form").on "click", (e) ->
|
||||
e.preventDefault();
|
||||
window.location = "#{registrar_account_activities_path}"
|
||||
|
|
|
@ -856,3 +856,7 @@ en:
|
|||
blocked_domains: 'Blocked domains'
|
||||
billing_failure_credit_balance_low: 'Billing failure - credit balance low'
|
||||
create: 'Create'
|
||||
activity_type: 'Activity type'
|
||||
receipt_date_from: 'Receipt date from'
|
||||
receipt_date_until: 'Receipt date until'
|
||||
add_credit: 'Add credit'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue