Lines 28-64
this script is the main page for acqui
Link Here
|
28 |
|
28 |
|
29 |
use Modern::Perl; |
29 |
use Modern::Perl; |
30 |
|
30 |
|
31 |
use CGI qw ( -utf8 ); |
31 |
use CGI qw ( -utf8 ); |
32 |
use C4::Auth qw( get_template_and_user ); |
32 |
use C4::Auth qw( get_template_and_user ); |
33 |
use C4::Output qw( output_html_with_http_headers ); |
33 |
use C4::Output qw( output_html_with_http_headers ); |
34 |
use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget ); |
34 |
use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget ); |
35 |
use C4::Members; |
35 |
use C4::Members (); |
36 |
use Koha::Acquisition::Currencies; |
36 |
use Koha::Acquisition::Currencies (); |
37 |
use Koha::Patrons; |
37 |
use Koha::Patrons (); |
38 |
use Koha::Suggestions; |
38 |
use Koha::Suggestions (); |
39 |
use Koha::DateUtils qw( dt_from_string ); |
39 |
use Koha::DateUtils qw( dt_from_string ); |
40 |
|
40 |
|
41 |
my $query = CGI->new; |
41 |
my $query = CGI->new; |
42 |
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user( |
42 |
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user( |
43 |
{ template_name => 'acqui/acqui-home.tt', |
43 |
{ |
44 |
query => $query, |
44 |
template_name => 'acqui/acqui-home.tt', |
45 |
type => 'intranet', |
45 |
query => $query, |
46 |
flagsrequired => { acquisition => '*' }, |
46 |
type => 'intranet', |
|
|
47 |
flagsrequired => { acquisition => '*' }, |
47 |
} |
48 |
} |
48 |
); |
49 |
); |
49 |
|
50 |
|
50 |
my $status = $query->param('status') || "ASKED"; |
51 |
my $status = $query->param('status') || "ASKED"; |
|
|
52 |
|
51 |
# Get current branch count and total viewable count, if they don't match then pass |
53 |
# Get current branch count and total viewable count, if they don't match then pass |
52 |
# both to template |
54 |
# both to template |
53 |
if( C4::Context->only_my_library ){ |
55 |
if ( C4::Context->only_my_library ) { |
54 |
my $local_pendingsuggestions_count = Koha::Suggestions->search({ status => "ASKED", branchcode => C4::Context->userenv()->{'branch'}, archived => 0 })->count(); |
56 |
my $local_pendingsuggestions_count = Koha::Suggestions->search( |
|
|
57 |
{ status => "ASKED", branchcode => C4::Context->userenv()->{'branch'}, archived => 0 } )->count(); |
55 |
$template->param( suggestions_count => $local_pendingsuggestions_count ); |
58 |
$template->param( suggestions_count => $local_pendingsuggestions_count ); |
56 |
} else { |
59 |
} else { |
57 |
my $pendingsuggestions = Koha::Suggestions->search({ status => "ASKED", archived => 0 }); |
60 |
my $pendingsuggestions = Koha::Suggestions->search( { status => "ASKED", archived => 0 } ); |
58 |
my $local_pendingsuggestions_count = $pendingsuggestions->search({ 'me.branchcode' => C4::Context->userenv()->{'branch'} })->count(); |
61 |
my $local_pendingsuggestions_count = |
|
|
62 |
$pendingsuggestions->search( { 'me.branchcode' => C4::Context->userenv()->{'branch'} } )->count(); |
59 |
my $pendingsuggestions_count = $pendingsuggestions->count(); |
63 |
my $pendingsuggestions_count = $pendingsuggestions->count(); |
60 |
$template->param( |
64 |
$template->param( |
61 |
all_pendingsuggestions => $pendingsuggestions_count != $local_pendingsuggestions_count ? $pendingsuggestions_count : 0, |
65 |
all_pendingsuggestions => $pendingsuggestions_count != $local_pendingsuggestions_count |
|
|
66 |
? $pendingsuggestions_count |
67 |
: 0, |
62 |
suggestions_count => $local_pendingsuggestions_count |
68 |
suggestions_count => $local_pendingsuggestions_count |
63 |
); |
69 |
); |
64 |
} |
70 |
} |
Lines 71-86
my $totordered = 0;
Link Here
|
71 |
my $totcomtd = 0; |
77 |
my $totcomtd = 0; |
72 |
my $totavail = 0; |
78 |
my $totavail = 0; |
73 |
|
79 |
|
74 |
my $total_active = 0; |
80 |
my $total_active = 0; |
75 |
my $totspent_active = 0; |
81 |
my $totspent_active = 0; |
76 |
my $totordered_active = 0; |
82 |
my $totordered_active = 0; |
77 |
my $totavail_active = 0; |
83 |
my $totavail_active = 0; |
78 |
|
84 |
|
79 |
my @budget_loop; |
85 |
my @budget_loop; |
80 |
my %patrons = ( $loggedinuser => Koha::Patrons->find($loggedinuser) ); |
86 |
my %patrons = ( $loggedinuser => Koha::Patrons->find($loggedinuser) ); |
81 |
my $loggedinpatron = $patrons{$loggedinuser}->unblessed; |
87 |
my $loggedinpatron = $patrons{$loggedinuser}->unblessed; |
82 |
foreach my $budget ( @{$budget_arr} ) { |
88 |
foreach my $budget ( @{$budget_arr} ) { |
83 |
next unless (CanUserUseBudget($loggedinpatron, $budget, $userflags)); |
89 |
next unless ( CanUserUseBudget( $loggedinpatron, $budget, $userflags ) ); |
84 |
|
90 |
|
85 |
if ( my $borrowernumber = $budget->{budget_owner_id} ) { |
91 |
if ( my $borrowernumber = $budget->{budget_owner_id} ) { |
86 |
unless ( exists $patrons{$borrowernumber} ) { |
92 |
unless ( exists $patrons{$borrowernumber} ) { |
Lines 99-118
foreach my $budget ( @{$budget_arr} ) {
Link Here
|
99 |
$budget->{budget_ordered} = 0; |
105 |
$budget->{budget_ordered} = 0; |
100 |
} |
106 |
} |
101 |
$budget->{'budget_avail'} = |
107 |
$budget->{'budget_avail'} = |
102 |
$budget->{'budget_amount'} - ( $budget->{'budget_spent'} + $budget->{'budget_ordered'} ); |
108 |
$budget->{'budget_amount'} - ( $budget->{'budget_spent'} + $budget->{'budget_ordered'} ); |
103 |
$budget->{'total_avail'} = |
109 |
$budget->{'total_avail'} = |
104 |
$budget->{'budget_amount'} - ( $budget->{'total_spent'} + $budget->{'total_ordered'} ); |
110 |
$budget->{'budget_amount'} - ( $budget->{'total_spent'} + $budget->{'total_ordered'} ); |
105 |
|
111 |
|
106 |
$total += $budget->{'budget_amount'}; |
112 |
$total += $budget->{'budget_amount'}; |
107 |
$totspent += $budget->{'budget_spent'}; |
113 |
$totspent += $budget->{'budget_spent'}; |
108 |
$totordered += $budget->{'budget_ordered'}; |
114 |
$totordered += $budget->{'budget_ordered'}; |
109 |
$totavail += $budget->{'budget_avail'}; |
115 |
$totavail += $budget->{'budget_avail'}; |
110 |
|
116 |
|
111 |
if ($budget->{budget_period_active}){ |
117 |
if ( $budget->{budget_period_active} ) { |
112 |
$total_active += $budget->{'budget_amount'}; |
118 |
$total_active += $budget->{'budget_amount'}; |
113 |
$totspent_active += $budget->{'budget_spent'}; |
119 |
$totspent_active += $budget->{'budget_spent'}; |
114 |
$totordered_active += $budget->{'budget_ordered'}; |
120 |
$totordered_active += $budget->{'budget_ordered'}; |
115 |
$totavail_active += $budget->{'budget_avail'}; |
121 |
$totavail_active += $budget->{'budget_avail'}; |
116 |
} |
122 |
} |
117 |
|
123 |
|
118 |
push @budget_loop, $budget; |
124 |
push @budget_loop, $budget; |
Lines 139-145
$template->param(
Link Here
|
139 |
); |
145 |
); |
140 |
|
146 |
|
141 |
my $cur = Koha::Acquisition::Currencies->get_active; |
147 |
my $cur = Koha::Acquisition::Currencies->get_active; |
142 |
if ( $cur ) { |
148 |
if ($cur) { |
143 |
$template->param( |
149 |
$template->param( |
144 |
currency => $cur->currency, |
150 |
currency => $cur->currency, |
145 |
); |
151 |
); |
146 |
- |
|
|