|
Lines 27-32
This script displays all orders associated to a selected budget.
Link Here
|
| 27 |
|
27 |
|
| 28 |
use strict; |
28 |
use strict; |
| 29 |
use warnings; |
29 |
use warnings; |
|
|
30 |
use Modern::Perl; |
| 30 |
|
31 |
|
| 31 |
use CGI; |
32 |
use CGI; |
| 32 |
use C4::Auth; |
33 |
use C4::Auth; |
|
Lines 36-42
use C4::Biblio;
Link Here
|
| 36 |
use C4::Reports; |
37 |
use C4::Reports; |
| 37 |
use C4::Acquisition; #GetBasket() |
38 |
use C4::Acquisition; #GetBasket() |
| 38 |
|
39 |
|
| 39 |
|
|
|
| 40 |
my $query = new CGI; |
40 |
my $query = new CGI; |
| 41 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
41 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
| 42 |
{ |
42 |
{ |
|
Lines 112-123
if ( $get_orders ) {
Link Here
|
| 112 |
# Format the dates and currencies correctly |
112 |
# Format the dates and currencies correctly |
| 113 |
$order->{'datereceived'} = Koha::DateUtils::output_pref(Koha::DateUtils::dt_from_string($order->{'datereceived'})); |
113 |
$order->{'datereceived'} = Koha::DateUtils::output_pref(Koha::DateUtils::dt_from_string($order->{'datereceived'})); |
| 114 |
$order->{'entrydate'} = Koha::DateUtils::output_pref(Koha::DateUtils::dt_from_string($order->{'entrydate'})); |
114 |
$order->{'entrydate'} = Koha::DateUtils::output_pref(Koha::DateUtils::dt_from_string($order->{'entrydate'})); |
| 115 |
$order->{'listprice'} = sprintf( "%.2f", $order->{'listprice'} ); |
|
|
| 116 |
$order->{'rrp'} = sprintf( "%.2f", $order->{'rrp'} ); |
| 117 |
$order->{'ecost'} = sprintf( "%.2f", $order->{'ecost'}); |
| 118 |
$order->{'total_rrp'} = sprintf( "%.2f", $order->{'total_rrp'}); |
| 119 |
$order->{'total_ecost'} = sprintf( "%.2f", $order->{'total_ecost'}); |
| 120 |
|
| 121 |
$total_quantity += $order->{'quantity'}; |
115 |
$total_quantity += $order->{'quantity'}; |
| 122 |
$total_rrp += $order->{'total_rrp'}; |
116 |
$total_rrp += $order->{'total_rrp'}; |
| 123 |
$total_ecost += $order->{'total_ecost'}; |
117 |
$total_ecost += $order->{'total_ecost'}; |
|
Lines 133-140
if ( $get_orders ) {
Link Here
|
| 133 |
ordersloop => \@orders, |
127 |
ordersloop => \@orders, |
| 134 |
get_orders => $get_orders, |
128 |
get_orders => $get_orders, |
| 135 |
total_quantity => $total_quantity, |
129 |
total_quantity => $total_quantity, |
| 136 |
total_rrp => sprintf( "%.2f", $total_rrp ), |
130 |
total_rrp => $total_rrp, |
| 137 |
total_ecost => sprintf( "%.2f", $total_ecost ), |
131 |
total_ecost => $total_ecost, |
| 138 |
); |
132 |
); |
| 139 |
} |
133 |
} |
| 140 |
# If we are outputting to a file, create it and exit. |
134 |
# If we are outputting to a file, create it and exit. |
|
Lines 161-171
if ( $get_orders ) {
Link Here
|
| 161 |
my @rows; |
155 |
my @rows; |
| 162 |
foreach my $order (@orders) { |
156 |
foreach my $order (@orders) { |
| 163 |
my @row; |
157 |
my @row; |
| 164 |
my $sep=''; |
|
|
| 165 |
if ($order->{'order_vendornote'}){ |
| 166 |
$sep='. Note2:' |
| 167 |
} |
| 168 |
$order->{'order_internalnote'} .= $sep .$order->{'order_vendornote'}; |
| 169 |
push(@row, _surround($order->{'budget_name'})); |
158 |
push(@row, _surround($order->{'budget_name'})); |
| 170 |
push(@row, _surround($order->{'basketno'})); |
159 |
push(@row, _surround($order->{'basketno'})); |
| 171 |
push(@row, _surround($order->{'basketname'})); |
160 |
push(@row, _surround($order->{'basketname'})); |
|
Lines 182-187
if ( $get_orders ) {
Link Here
|
| 182 |
push(@row, _surround($order->{'entrydate'})); |
171 |
push(@row, _surround($order->{'entrydate'})); |
| 183 |
push(@row, _surround($order->{'datereceived'})); |
172 |
push(@row, _surround($order->{'datereceived'})); |
| 184 |
push(@row, _surround($order->{'order_internalnote'})); |
173 |
push(@row, _surround($order->{'order_internalnote'})); |
|
|
174 |
push(@row, _surround($order->{'order_vendornote'})); |
| 185 |
push(@rows, \@row); |
175 |
push(@rows, \@row); |
| 186 |
} |
176 |
} |
| 187 |
|
177 |
|
|
Lines 204-233
else {
Link Here
|
| 204 |
my @CSVdelimiters =(',','#',qw(; tabulation \\ /)); |
194 |
my @CSVdelimiters =(',','#',qw(; tabulation \\ /)); |
| 205 |
|
195 |
|
| 206 |
# getting all budgets |
196 |
# getting all budgets |
| 207 |
# active budgets |
197 |
my $budgets = GetBudgetHierarchy; |
| 208 |
my @active_budgets = C4::Budgets::GetBudgetsByActivity(1); |
198 |
my $budgetloop = []; |
| 209 |
# non active budgets |
199 |
foreach my $budget (@{$budgets}) { |
| 210 |
my @non_active_budgets = C4::Budgets::GetBudgetsByActivity(0); |
200 |
push @{$budgetloop},{ |
| 211 |
my @budgetsloop; |
201 |
value => $budget->{budget_id}, |
| 212 |
foreach my $thisbudget ( sort {$a->{budget_name} cmp $b->{budget_name}} @active_budgets ) { |
202 |
description => $budget->{budget_name}, |
| 213 |
my $budget_period_desc = C4::Budgets::GetBudgetPeriodDescription($thisbudget->{budget_id}); |
203 |
period => $budget->{budget_period_description}, |
| 214 |
my %row = ( |
204 |
active => $budget->{budget_period_active}, |
| 215 |
value => $thisbudget->{budget_id}, |
205 |
}; |
| 216 |
description => $thisbudget->{budget_name}, |
|
|
| 217 |
period => "(" . $budget_period_desc->{budget_period_description} . ")", |
| 218 |
); |
| 219 |
push @budgetsloop, \%row; |
| 220 |
} |
| 221 |
foreach my $thisbudget ( sort {$a->{budget_name} cmp $b->{budget_name}} @non_active_budgets ) { |
| 222 |
my $budget_period_desc = C4::Budgets::GetBudgetPeriodDescription($thisbudget->{budget_id}); |
| 223 |
my %row = ( |
| 224 |
value => $thisbudget->{budget_id}, |
| 225 |
description => "[i] ". $thisbudget->{budget_name}, |
| 226 |
period => "(" . $budget_period_desc->{budget_period_description} . ")", |
| 227 |
); |
| 228 |
push @budgetsloop, \%row; |
| 229 |
} |
206 |
} |
| 230 |
$template->param( budgetsloop => \@budgetsloop, |
207 |
@{$budgetloop} =sort { uc( $a->{description}) cmp uc( $b->{description}) } @{$budgetloop}; |
|
|
208 |
$template->param( budgetsloop => \@{$budgetloop}, |
| 231 |
outputFormatloop => \@outputFormats, |
209 |
outputFormatloop => \@outputFormats, |
| 232 |
delimiterloop => \@CSVdelimiters, |
210 |
delimiterloop => \@CSVdelimiters, |
| 233 |
delimiterPreference => C4::Context->preference('delimiter') |
211 |
delimiterPreference => C4::Context->preference('delimiter') |