diff --git a/app/controllers/registrar/account_activities_controller.rb b/app/controllers/registrar/account_activities_controller.rb index 54c3f6d24..43f254c08 100644 --- a/app/controllers/registrar/account_activities_controller.rb +++ b/app/controllers/registrar/account_activities_controller.rb @@ -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 diff --git a/app/models/account_activity.rb b/app/models/account_activity.rb index ecfae8270..92a4c29b9 100644 --- a/app/models/account_activity.rb +++ b/app/models/account_activity.rb @@ -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 diff --git a/app/views/registrar/account_activities/index.haml b/app/views/registrar/account_activities/index.haml index 0efd0ab20..dd4cd254e 100644 --- a/app/views/registrar/account_activities/index.haml +++ b/app/views/registrar/account_activities/index.haml @@ -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}" diff --git a/config/locales/en.yml b/config/locales/en.yml index 0faa3b0ef..7b5fc1eaa 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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'