diff --git a/app/controllers/admin/redeem_requests_controller.rb b/app/controllers/admin/redeem_requests_controller.rb index a14227a0..a95acda9 100644 --- a/app/controllers/admin/redeem_requests_controller.rb +++ b/app/controllers/admin/redeem_requests_controller.rb @@ -1,12 +1,14 @@ class Admin::RedeemRequestsController < ApplicationController + include Admin::RedeemRequestsHelper before_action :authenticate_user! before_action :authenticate_admin! + def index #status(false) = status(Open) #status(true) = status(Close) @status = params[:status] ? params[:status] : false - @redeem_requests = RedeemRequest.where(:status => @status).desc(:created_at).page(params[:page]) + @redeem_requests = RedeemRequest.where(:status => @status).desc(:created_at).page(params[:page]) if request.xhr? respond_to do|format| format.js diff --git a/app/helpers/admin/redeem_requests_helper.rb b/app/helpers/admin/redeem_requests_helper.rb index 70f1e2b9..8d5bd72e 100644 --- a/app/helpers/admin/redeem_requests_helper.rb +++ b/app/helpers/admin/redeem_requests_helper.rb @@ -1,2 +1,7 @@ module Admin::RedeemRequestsHelper + + def total_capital_of_points + RedeemRequest.where(status: false).sum(:points)/10 + end + end diff --git a/app/views/admin/redeem_requests/index.html.haml b/app/views/admin/redeem_requests/index.html.haml index 9a0ca001..eaa2bb50 100644 --- a/app/views/admin/redeem_requests/index.html.haml +++ b/app/views/admin/redeem_requests/index.html.haml @@ -1,16 +1,17 @@ %section.content-header - %h1 - Redeem Requests + %h1 + Redeem Requests + %span.badge $ #{total_capital_of_points} %label.slide %input.check#redeem{checked: 'checked', name: 'status', type: 'checkbox', data: {toggle: 'toggle', width: '100', height: '40', on: 'Status Open', off: 'Status Close'}} - #console-event + #console-event %section.content .row .col-xs-12 .box.box-primary .box-body.table-responsive#user_table = render partial: 'redeem' -.modal.fade#coupon-code-modal +.modal.fade#coupon-code-modal .modal-dialog .modal-content = simple_form_for(RedeemRequest.new, url: '#', method: 'put') do |f| @@ -25,4 +26,4 @@ = f.input :status, as: :select, collection: { 'Closed' => 'true', 'Open' => 'false'}, include_blank: false .modal-footer %button.btn.btn-default{'data-dismiss' => 'modal', :type => 'button'} Cancel - %button.btn.btn-primary{:type => 'submit'} Save + %button.btn.btn-primary{:type => 'submit'} Save \ No newline at end of file