Bugzilla – Attachment 50230 Details for
Bug 11371
Add a new report : Orders by budget
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11371 - Add a new report : Orders by budget
Bug-11371---Add-a-new-report--Orders-by-budget.patch (text/plain), 13.33 KB, created by
Bouzid Fergani
on 2016-04-14 12:26:21 UTC
(
hide
)
Description:
Bug 11371 - Add a new report : Orders by budget
Filename:
MIME Type:
Creator:
Bouzid Fergani
Created:
2016-04-14 12:26:21 UTC
Size:
13.33 KB
patch
obsolete
>From b0193980de9258ee1aac0e97007ac42be603a2e4 Mon Sep 17 00:00:00 2001 >From: Bouzid Fergani <bouzid.fergani@inlibro.com> >Date: Wed, 13 Apr 2016 17:03:57 -0400 >Subject: [PATCH] Bug 11371 - Add a new report : Orders by budget > >--- > C4/Budgets.pm | 34 -------------- > .../csv_headers/reports/orders_by_budget.tt | 2 +- > .../prog/en/modules/reports/orders_by_budget.tt | 50 ++++++++++++++------- > reports/orders_by_fund.pl | 52 +++++++--------------- > t/db_dependent/Budgets.t | 21 +-------- > 5 files changed, 51 insertions(+), 108 deletions(-) > >diff --git a/C4/Budgets.pm b/C4/Budgets.pm >index b60ecb1..809f63e 100644 >--- a/C4/Budgets.pm >+++ b/C4/Budgets.pm >@@ -454,40 +454,6 @@ sub GetBudgetPeriod { > return $data; > } > >-# ------------------------------------------------------------------- >- >-=head2 GetBudgetPeriodDescription >- >- $description = GetBudgetPeriodDescription($budget_id); >- >- Return value: hashref >- >- Returns the budget period description for a given budget id. >- >- Description is fetched from aqbudgetperiods, id is compared aqbudgets. (INNER JOIN on budget_period_id) >- >-=cut >- >-sub GetBudgetPeriodDescription { >- my ($budget_id) = @_; >- my $dbh = C4::Context->dbh; >- my $sth; >- if ($budget_id) { >- $sth = $dbh->prepare( >- "SELECT budget_period_description >- FROM aqbudgetperiods bp >- INNER JOIN aqbudgets b >- ON bp.budget_period_id = b.budget_period_id >- WHERE b.budget_id=? >- " >- ); >- $sth->execute($budget_id); >- } >- my $data = $sth->fetchrow_hashref; >- return $data; >-} >- >-# ------------------------------------------------------------------- > sub DelBudgetPeriod{ > my ($budget_period_id) = @_; > my $dbh = C4::Context->dbh; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/reports/orders_by_budget.tt b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/reports/orders_by_budget.tt >index 49dfc9d..2acc795 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/reports/orders_by_budget.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/reports/orders_by_budget.tt >@@ -1 +1 @@ >-Fund[% sep %]"Basket Num"[% sep %]"Basket Name"[% sep %]"authorised By"[% sep %]"Biblio Number"[% sep %]Title[% sep %]Currency[% sep %]"Vendor Price"[% sep %]RRP[% sep %]"Budgeted Cost"[% sep %]Quantity[% sep %]"Total RRP"[% sep %]"Total Cost"[% sep %]"Entry Date"[% sep %]"Date Received"[% sep %]Notes >+Fund[% sep %]"Basket num"[% sep %]"Basket name"[% sep %]"Authorised by"[% sep %]"Biblio number"[% sep %]Title[% sep %]Currency[% sep %]"Vendor price"[% sep %]RRP[% sep %]"Budgeted cost"[% sep %]Quantity[% sep %]"Total RRP"[% sep %]"Total cost"[% sep %]"Entry date"[% sep %]"Date received"[% sep %]"Internal note"[% sep %]"Vendor note" >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/orders_by_budget.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/orders_by_budget.tt >index 8b9a025..2921d85 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/orders_by_budget.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/orders_by_budget.tt >@@ -1,3 +1,4 @@ >+[% USE Price %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Reports › Orders by fund</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -11,6 +12,16 @@ > <script type="text/javascript"> > $(document).ready( function () { > $('#funds').DataTable($.extend(true, {}, dataTablesDefaults,{"sPaginationType": "full_numbers"})); >+ >+ showallbudgets = $('#budgetfilter').html(); >+ $('#budgetfilter .b_inactive').remove(); >+ >+ $('#showbudgets').click(function(){ >+ if ($(this).is(":checked")) >+ $('#budgetfilter').html(showallbudgets); >+ else >+ $('#budgetfilter .b_inactive').remove(); >+ }); > } ); > </script> > <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>[% IF ( get_orders ) %] › <a href="/cgi-bin/koha/reports/orders_by_fund.pl">Orders by fund</a> › Results[% ELSE %] › Orders by fund[% END %]</div> >@@ -39,19 +50,20 @@ > <tr> > <th>Fund</th> > <th>Basket</th> >- <th>Basket Name</th> >- <th>Basket By</th> >+ <th>Basket name</th> >+ <th>Basket by</th> > <th>Title</th> > <th>Currency</th> >- <th>Vendor Price</th> >+ <th>List price</th> > <th>RRP</th> >- <th>Budgeted Cost</th> >+ <th>Budgeted cost</th> > <th>Quantity</th> > <th>Total RRP</th> >- <th>Total Cost</th> >- <th>Entry Date</th> >- <th>Date Received</th> >- <th>Notes</th> >+ <th>Total cost</th> >+ <th>Entry date</th> >+ <th>Date deceived</th> >+ <th>Internal note</th> >+ <th>Vendor note</th> > </tr> > </thead> > <tbody> >@@ -65,19 +77,20 @@ > <td>[% ordersloo.authorisedbyname %]</td> > <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% ordersloo.biblionumber %]"> [% ordersloo.title |html %]</a></td> > <td>[% ordersloo.currency %]</td> >- <td>[% ordersloo.listprice %]</td> >- <td>[% ordersloo.rrp %]</td> >- <td>[% ordersloo.ecost %]</td> >+ <td>[% ordersloo.listprice | $Price %]</td> >+ <td>[% ordersloo.rrp | $Price %]</td> >+ <td>[% ordersloo.ecost | $Price %]</td> > <td>[% ordersloo.quantity %]</td> >- <td>[% ordersloo.total_rrp %]</td> >- <td>[% ordersloo.total_ecost %]</td> >+ <td>[% ordersloo.total_rrp | $Price %]</td> >+ <td>[% ordersloo.total_ecost | $Price %]</td> > <td>[% ordersloo.entrydate %]</td> > <td>[% ordersloo.datereceived %]</td> > <td>[% ordersloo.order_internalnote |html %]</td> >+ <td>[% ordersloo.order_vendornote |html %]</td> > </tr> > [% END %] > </tbody> >- <tfoot><tr><th>TOTAL</th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th>[% total_quantity %]</th><th>[% total_rrp %]</th><th>[% total_ecost %]</th><th></th><th></th><th></th></tr></tfoot> >+ <tfoot><tr><th>TOTAL</th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th>[% total_quantity %]</th><th>[% total_rrp | $Price %]</th><th>[% total_ecost | $Price %]</th><th></th><th></th><th></th></tr></tfoot> > </table> > [% END %] > [% ELSE %] >@@ -90,12 +103,17 @@ > <option value="activebudgets">All active funds</option> > [% FOREACH budgetsloo IN budgetsloop %] > [% IF ( budgetsloo.selected ) %] >- <option value="[% budgetsloo.value %]" selected="selected">[% budgetsloo.description %] [% budgetsloo.period %]</option> >+ <option value="[% budgetsloo.value %]" selected="selected"> > [% ELSE %] >- <option value="[% budgetsloo.value %]">[% budgetsloo.description %] [% budgetsloo.period %]</option> >+ [% bdgclass=budgetsloo.active? "": "b_inactive" %] >+ <option class="[% bdgclass %]" value="[% budgetsloo.value %]"> > [% END %] >+ [% budgetsloo.description %] [% IF !budgetsloo.active %](inactive)[% END %] >+ </option> > [% END %] > </select> >+ <label for="showallbudgets" style="float:none;"> Show inactive:</label> >+ <input type="checkbox" id="showbudgets" /> > </li></ol> > </fieldset> > >diff --git a/reports/orders_by_fund.pl b/reports/orders_by_fund.pl >index 2a8a7cb..ce00d72 100755 >--- a/reports/orders_by_fund.pl >+++ b/reports/orders_by_fund.pl >@@ -27,6 +27,7 @@ This script displays all orders associated to a selected budget. > > use strict; > use warnings; >+use Modern::Perl; > > use CGI; > use C4::Auth; >@@ -36,7 +37,6 @@ use C4::Biblio; > use C4::Reports; > use C4::Acquisition; #GetBasket() > >- > my $query = new CGI; > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { >@@ -112,12 +112,6 @@ if ( $get_orders ) { > # Format the dates and currencies correctly > $order->{'datereceived'} = Koha::DateUtils::output_pref(Koha::DateUtils::dt_from_string($order->{'datereceived'})); > $order->{'entrydate'} = Koha::DateUtils::output_pref(Koha::DateUtils::dt_from_string($order->{'entrydate'})); >- $order->{'listprice'} = sprintf( "%.2f", $order->{'listprice'} ); >- $order->{'rrp'} = sprintf( "%.2f", $order->{'rrp'} ); >- $order->{'ecost'} = sprintf( "%.2f", $order->{'ecost'}); >- $order->{'total_rrp'} = sprintf( "%.2f", $order->{'total_rrp'}); >- $order->{'total_ecost'} = sprintf( "%.2f", $order->{'total_ecost'}); >- > $total_quantity += $order->{'quantity'}; > $total_rrp += $order->{'total_rrp'}; > $total_ecost += $order->{'total_ecost'}; >@@ -133,8 +127,8 @@ if ( $get_orders ) { > ordersloop => \@orders, > get_orders => $get_orders, > total_quantity => $total_quantity, >- total_rrp => sprintf( "%.2f", $total_rrp ), >- total_ecost => sprintf( "%.2f", $total_ecost ), >+ total_rrp => $total_rrp, >+ total_ecost => $total_ecost, > ); > } > # If we are outputting to a file, create it and exit. >@@ -161,11 +155,6 @@ if ( $get_orders ) { > my @rows; > foreach my $order (@orders) { > my @row; >- my $sep=''; >- if ($order->{'order_vendornote'}){ >- $sep='. Note2:' >- } >- $order->{'order_internalnote'} .= $sep .$order->{'order_vendornote'}; > push(@row, _surround($order->{'budget_name'})); > push(@row, _surround($order->{'basketno'})); > push(@row, _surround($order->{'basketname'})); >@@ -182,6 +171,7 @@ if ( $get_orders ) { > push(@row, _surround($order->{'entrydate'})); > push(@row, _surround($order->{'datereceived'})); > push(@row, _surround($order->{'order_internalnote'})); >+ push(@row, _surround($order->{'order_vendornote'})); > push(@rows, \@row); > } > >@@ -204,30 +194,18 @@ else { > my @CSVdelimiters =(',','#',qw(; tabulation \\ /)); > > # getting all budgets >- # active budgets >- my @active_budgets = C4::Budgets::GetBudgetsByActivity(1); >- # non active budgets >- my @non_active_budgets = C4::Budgets::GetBudgetsByActivity(0); >- my @budgetsloop; >- foreach my $thisbudget ( sort {$a->{budget_name} cmp $b->{budget_name}} @active_budgets ) { >- my $budget_period_desc = C4::Budgets::GetBudgetPeriodDescription($thisbudget->{budget_id}); >- my %row = ( >- value => $thisbudget->{budget_id}, >- description => $thisbudget->{budget_name}, >- period => "(" . $budget_period_desc->{budget_period_description} . ")", >- ); >- push @budgetsloop, \%row; >- } >- foreach my $thisbudget ( sort {$a->{budget_name} cmp $b->{budget_name}} @non_active_budgets ) { >- my $budget_period_desc = C4::Budgets::GetBudgetPeriodDescription($thisbudget->{budget_id}); >- my %row = ( >- value => $thisbudget->{budget_id}, >- description => "[i] ". $thisbudget->{budget_name}, >- period => "(" . $budget_period_desc->{budget_period_description} . ")", >- ); >- push @budgetsloop, \%row; >+ my $budgets = GetBudgetHierarchy; >+ my $budgetloop = []; >+ foreach my $budget (@{$budgets}) { >+ push @{$budgetloop},{ >+ value => $budget->{budget_id}, >+ description => $budget->{budget_name}, >+ period => $budget->{budget_period_description}, >+ active => $budget->{budget_period_active}, >+ }; > } >- $template->param( budgetsloop => \@budgetsloop, >+ @{$budgetloop} =sort { uc( $a->{description}) cmp uc( $b->{description}) } @{$budgetloop}; >+ $template->param( budgetsloop => \@{$budgetloop}, > outputFormatloop => \@outputFormats, > delimiterloop => \@CSVdelimiters, > delimiterPreference => C4::Context->preference('delimiter') >diff --git a/t/db_dependent/Budgets.t b/t/db_dependent/Budgets.t >index 3f13f60..e0ed6e9 100755 >--- a/t/db_dependent/Budgets.t >+++ b/t/db_dependent/Budgets.t >@@ -1,6 +1,6 @@ > #!/usr/bin/perl > use Modern::Perl; >-use Test::More tests => 130; >+use Test::More tests => 129; > BEGIN { > use_ok('C4::Budgets') > } >@@ -468,25 +468,6 @@ for my $budget (@$budget_hierarchy_cloned) { > is( $number_of_budgets_not_reset, 0, > 'CloneBudgetPeriod has reset all budgets (funds)' ); > >-#GetBudgetPeriodDescription >-$my_budgetperiod = { >- budget_period_startdate => '2008-01-01', >- budget_period_enddate => '2008-12-31', >- budget_period_description => 'MAPERI', >- budget_period_active => 0, >-}; >-$bpid = AddBudgetPeriod($my_budgetperiod); >-$my_budget = { >- budget_code => 'ABCD', >- budget_amount => '123.132000', >- budget_name => 'Periodiques', >- budget_notes => 'This is a note', >- budget_period_id => $bpid, >-}; >-$budget_id = AddBudget($my_budget); >-my $data=GetBudgetPeriodDescription($budget_id); >-is( $data->{budget_period_description}, 'MAPERI' ,'GetBudgetPeriodDescription return right value'); >- > #GetBudgetsByActivity > my $result=C4::Budgets::GetBudgetsByActivity(1); > isnt( $result, undef ,'GetBudgetsByActivity return correct value with parameter 1'); >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11371
:
23381
|
25397
|
25913
|
25915
|
30545
|
30546
|
35385
|
36620
|
36707
|
37010
|
37011
|
41463
|
41464
|
45243
|
45244
|
45245
|
45288
|
45338
|
45887
|
45890
|
45981
|
45982
|
50230
|
50231
|
50233
|
50466
|
50468
|
50769