Skip to content

Commit

Permalink
Display points into capital[#296] (#300)
Browse files Browse the repository at this point in the history
* Sum of all of Redemption Requests[#296]

A helper method added to print the total capital value of redeemable
points.

* Sum of all Redemption Requests [#296]

A helper method added to display the capital value of total redeemable points.
  • Loading branch information
Amit authored and sethu committed Jul 12, 2017
1 parent 128a74c commit 0b24b0a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 3 additions & 1 deletion app/controllers/admin/redeem_requests_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions app/helpers/admin/redeem_requests_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
module Admin::RedeemRequestsHelper

def total_capital_of_points
RedeemRequest.where(status: false).sum(:points)/10
end

end
11 changes: 6 additions & 5 deletions app/views/admin/redeem_requests/index.html.haml
Original file line number Diff line number Diff line change
@@ -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|
Expand All @@ -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

0 comments on commit 0b24b0a

Please sign in to comment.