Skip to content

Commit

Permalink
pagination added to reports 2 and 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwen Blel committed Jan 2, 2012
1 parent af0fc0f commit 7c626d4
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 3 deletions.
18 changes: 16 additions & 2 deletions app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,22 @@ def ledger_journal

#journal_operations is an array containing hash generated by plpgsql procedure typed :
# accid int, pid int, jdate date, oldb real, balance real, newb real, jid int, jnumber int

@journal_operations = Report.report_ledger_journal(periods, from_account_number, to_account_number,current_user.current_company, @car, @unit, @project, @journal_type)

@diff = Hash.new

@journal_operations.each do |jo|
if @diff[:"#{jo["accid"]}"].nil?
@diff[:"#{jo["accid"]}"] = jo["balance"].to_f
else
@diff[:"#{jo["accid"]}"] += jo["balance"].to_f
end
end

@journal_operations = @journal_operations.paginate(:page => params[:page],:per_page => 1000)

# TODO: determine diff
end

def subsidiary_ledger_balance
Expand Down Expand Up @@ -151,6 +165,7 @@ def subsidiary_ledger_journal
end
end

@journal_operations = @journal_operations.paginate(:page => params[:page],:per_page => 1000)
end

def open_closed_operations
Expand All @@ -175,8 +190,7 @@ def dagbok
@unit = (unit == 'null' ? nil : Unit.find(unit))
@project = ( project == 'null' ? nil : Project.find(project))
@car = ( car == 'null' ? nil : Car.find(car))
@journal_type = ( journal_type == 'null' ? nil : JournalType.find(journal_type))

@journal_type = ( journal_type == 'null' ? nil : JournalType.find(journal_type))
end

private
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<%= stylesheet_link_tag 'dodo' %>
<%= stylesheet_link_tag 'application' %>
<%= stylesheet_link_tag 'jquery-ui' %>
<%= stylesheet_link_tag 'pagination' %>
<%= javascript_include_tag :defaults %>
<%= javascript_include_tag "dodo" %>
<%= javascript_include_tag "date" %>
Expand Down
10 changes: 9 additions & 1 deletion app/views/reports/ledger_journal.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<p><h1><%= current_user.current_company.to_s %> - <%= current_user.to_s %> (<%= Date.today %>)</h1></p>
<p><h1><%= t(:ledger_balance_period, :scope=>:reports) %><%= title_to_periods_range({:from_period=>@first_period_to_balance, :to_period=>@last_period_to_balance}) %><%= result_from_date(:period => @result_from) %></h1></p>
<% unless @unit.blank?%>
Expand All @@ -15,6 +16,13 @@

<%#accid int, pid int, jdate date, oldb real, balance real, newb real, jid int, jnumber int%>

<%#= will_paginate @journal_operations %>

<div class="digg_pagination">
<%= will_paginate @journal_operations, :container => false %>
</div>


<table class="report">
<thead>
<tr>
Expand Down Expand Up @@ -103,7 +111,7 @@
<%= number_with_precision(jo["newb"], :locale =>I18n.locale) %>
</td>
<td class="diff" style="text-align: right">
<%= number_with_precision(diff, :locale =>I18n.locale) %>
<%= number_with_precision(@diff[:"#{jo["accid"]}"], :locale =>I18n.locale) %>
</td>
</tr>
<%end%>
Expand Down
3 changes: 3 additions & 0 deletions app/views/reports/subsidiary_ledger_journal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<% end %>


<div class="digg_pagination">
<%= will_paginate @journal_operations %>
</div>

<table class="report">
<thead>
Expand Down
54 changes: 54 additions & 0 deletions public/stylesheets/pagination.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
Document : pagination
Created on : 29 déc. 2011, 16:18:10
Author : marven
Description:
Purpose of the stylesheet follows.
*/

.digg_pagination {
background: white;
cursor: default;
/* self-clearing method: */ }
.digg_pagination a, .digg_pagination span, .digg_pagination em {
padding: 0.2em 0.5em;
display: block;
float: left;
margin-right: 1px; }
.digg_pagination .disabled {
color: #999999;
border: 1px solid #dddddd; }
.digg_pagination .current {
font-style: normal;
font-weight: bold;
background: #2e6ab1;
color: white;
border: 1px solid #2e6ab1; }
.digg_pagination a {
text-decoration: none;
color: #105cb6;
border: 1px solid #9aafe5; }
.digg_pagination a:hover, .digg_pagination a:focus {
color: #000033;
border-color: #000033; }
.digg_pagination .page_info {
background: #2e6ab1;
color: white;
padding: 0.4em 0.6em;
width: 22em;
margin-bottom: 0.3em;
text-align: center; }
.digg_pagination .page_info b {
color: #000033;
background: #6aa6ed;
padding: 0.1em 0.25em; }
.digg_pagination:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden; }
* html .digg_pagination {
height: 1%; }
*:first-child + html .digg_pagination {
overflow: hidden; }

0 comments on commit 7c626d4

Please sign in to comment.