Lines 1-7
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
|
2 |
|
3 |
#script to show suppliers and orders |
|
|
4 |
|
5 |
# Copyright 2000-2002 Katipo Communications |
3 |
# Copyright 2000-2002 Katipo Communications |
6 |
# Copyright 2008-2009 BibLibre SARL |
4 |
# Copyright 2008-2009 BibLibre SARL |
7 |
# Copyright 2010 PTFS Europe |
5 |
# Copyright 2010 PTFS Europe |
Lines 27-48
booksellers.pl
Link Here
|
27 |
|
25 |
|
28 |
=head1 DESCRIPTION |
26 |
=head1 DESCRIPTION |
29 |
|
27 |
|
30 |
this script displays the list of suppliers & baskets like C<$supplier> given on input arg. |
28 |
this script displays the baskets for a vendor |
31 |
thus, this page brings differents features like to display supplier's details, |
|
|
32 |
to add an order for a specific supplier or to just add a new supplier. |
33 |
|
29 |
|
34 |
=head1 CGI PARAMETERS |
30 |
=head1 CGI PARAMETERS |
35 |
|
31 |
|
36 |
=over 4 |
32 |
=over 4 |
37 |
|
33 |
|
38 |
=item supplier |
|
|
39 |
|
40 |
C<$supplier> is the string with which we search for a supplier |
41 |
|
42 |
=back |
43 |
|
44 |
=over 4 |
45 |
|
46 |
=item id or booksellerid |
34 |
=item id or booksellerid |
47 |
|
35 |
|
48 |
The id of the supplier whose baskets we will display |
36 |
The id of the supplier whose baskets we will display |
Lines 52-68
The id of the supplier whose baskets we will display
Link Here
|
52 |
=cut |
40 |
=cut |
53 |
|
41 |
|
54 |
use Modern::Perl; |
42 |
use Modern::Perl; |
55 |
use C4::Auth qw( get_template_and_user haspermission ); |
43 |
use C4::Auth qw( get_template_and_user haspermission ); |
56 |
use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget ); |
44 |
use C4::Output qw( output_html_with_http_headers ); |
57 |
use C4::Output qw( output_html_with_http_headers ); |
45 |
use CGI qw ( -utf8 ); |
58 |
use CGI qw ( -utf8 ); |
|
|
59 |
|
46 |
|
60 |
use C4::Acquisition qw( GetBasket GetBasketsInfosByBookseller CanUserManageBasket GetBasketgroup ); |
47 |
use C4::Acquisition qw( GetBasket GetBasketsInfosByBookseller CanUserManageBasket GetBasketgroup ); |
61 |
use C4::Context; |
|
|
62 |
|
48 |
|
63 |
use Koha::Acquisition::Booksellers; |
49 |
use Koha::Acquisition::Booksellers; |
64 |
use Koha::Patrons; |
50 |
use Koha::Patrons; |
65 |
use Koha::Acquisition::Currencies; |
|
|
66 |
|
51 |
|
67 |
my $query = CGI->new; |
52 |
my $query = CGI->new; |
68 |
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user( |
53 |
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user( |
Lines 75-139
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user(
Link Here
|
75 |
); |
60 |
); |
76 |
|
61 |
|
77 |
#parameters |
62 |
#parameters |
78 |
my $supplier = $query->param('supplier'); |
|
|
79 |
my $booksellerid = $query->param('booksellerid'); |
63 |
my $booksellerid = $query->param('booksellerid'); |
80 |
my $allbaskets = $query->param('allbaskets') || 0; |
64 |
my $allbaskets = $query->param('allbaskets') || 0; |
81 |
my @suppliers; |
65 |
my @suppliers; |
82 |
|
66 |
|
|
|
67 |
my $vendor; |
68 |
my $loop_suppliers = []; |
69 |
|
83 |
if ($booksellerid) { |
70 |
if ($booksellerid) { |
84 |
push @suppliers, Koha::Acquisition::Booksellers->find($booksellerid); |
71 |
$vendor = Koha::Acquisition::Booksellers->find($booksellerid); |
85 |
} else { |
|
|
86 |
@suppliers = Koha::Acquisition::Booksellers->search( |
87 |
[ |
88 |
{ name => { -like => "%$supplier%" } }, |
89 |
{ 'aqbookseller_aliases.alias' => { -like => "%$supplier%" } }, |
90 |
], |
91 |
{ |
92 |
order_by => { -asc => 'name' }, |
93 |
join => 'aqbookseller_aliases', |
94 |
distinct => 1, |
95 |
} |
96 |
)->as_list; |
97 |
} |
98 |
|
72 |
|
99 |
my $supplier_count = @suppliers; |
|
|
100 |
if ( $supplier_count == 1 ) { |
101 |
$template->param( |
73 |
$template->param( |
102 |
supplier_name => $suppliers[0]->name, |
74 |
supplier_name => $vendor->name, |
103 |
booksellerid => $suppliers[0]->id, |
75 |
booksellerid => $vendor->id, |
104 |
basketcount => $suppliers[0]->baskets->count, |
76 |
basketcount => $vendor->baskets->count, |
105 |
subscriptionscount => $suppliers[0]->subscriptions->count, |
77 |
subscriptionscount => $vendor->subscriptions->count, |
106 |
active => $suppliers[0]->active, |
78 |
active => $vendor->active, |
107 |
); |
79 |
); |
108 |
} |
|
|
109 |
|
80 |
|
110 |
my $uid; |
|
|
111 |
|
112 |
# FIXME This script should only be accessed by a valid logged in patron |
113 |
if ($loggedinuser) { |
114 |
|
115 |
# FIXME Should not be needed, logged in patron should be cached |
116 |
$uid = Koha::Patrons->find($loggedinuser)->userid; |
117 |
} |
118 |
|
119 |
my $userenv = C4::Context::userenv; |
120 |
my $viewbaskets = C4::Context->preference('AcqViewBaskets'); |
121 |
|
122 |
my $userbranch = $userenv->{branch}; |
123 |
|
124 |
my $budgets = GetBudgetHierarchy; |
125 |
my $has_budgets = 0; |
126 |
foreach my $r ( @{$budgets} ) { |
127 |
next unless ( CanUserUseBudget( $loggedinuser, $r, $userflags ) ); |
128 |
|
129 |
$has_budgets = 1; |
130 |
last; |
131 |
} |
132 |
|
133 |
#build result page |
134 |
my $loop_suppliers = []; |
135 |
|
136 |
for my $vendor (@suppliers) { |
137 |
my $baskets = GetBasketsInfosByBookseller( $vendor->id, $allbaskets ); |
81 |
my $baskets = GetBasketsInfosByBookseller( $vendor->id, $allbaskets ); |
138 |
|
82 |
|
139 |
my $loop_basket = []; |
83 |
my $loop_basket = []; |
Lines 167-179
for my $vendor (@suppliers) {
Link Here
|
167 |
basketcount => $vendor->baskets->count, |
111 |
basketcount => $vendor->baskets->count, |
168 |
subscriptioncount => $vendor->subscriptions->count, |
112 |
subscriptioncount => $vendor->subscriptions->count, |
169 |
}; |
113 |
}; |
170 |
|
|
|
171 |
} |
114 |
} |
|
|
115 |
|
172 |
$template->param( |
116 |
$template->param( |
173 |
loop_suppliers => $loop_suppliers, |
117 |
loop_suppliers => $loop_suppliers, |
174 |
supplier => ( $booksellerid || $supplier ), |
118 |
supplier => $booksellerid, |
175 |
count => $supplier_count, |
119 |
count => $vendor ? 1 : 0, |
176 |
has_budgets => $has_budgets, |
|
|
177 |
); |
120 |
); |
178 |
$template->{VARS}->{'allbaskets'} = $allbaskets; |
121 |
$template->{VARS}->{'allbaskets'} = $allbaskets; |
179 |
|
122 |
|