3 #script to show suppliers and orders
5 # Copyright 2000-2002 Katipo Communications
6 # Copyright 2008-2009 BibLibre SARL
7 # Copyright 2010 PTFS Europe
9 # This file is part of Koha.
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along
21 # with Koha; if not, write to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 this script displays the list of suppliers & baskets like C<$supplier> given on input arg.
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.
40 C<$supplier> is the string with which we search for a supplier
46 =item id or booksellerid
48 The id of the supplier whose baskets we will display
62 use C4
::Acquisition qw
/ GetBasketsInfosByBookseller CanUserManageBasket /;
63 use C4
::Bookseller qw
/ GetBookSellerFromId GetBookSeller /;
64 use C4
::Members qw
/GetMember/;
68 my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user
(
69 { template_name
=> 'acqui/booksellers.tt',
73 flagsrequired
=> { acquisition
=> '*' },
79 my $supplier = $query->param('supplier');
80 my $booksellerid = $query->param('booksellerid');
81 my $allbaskets= $query->param('allbaskets')||0;
85 push @suppliers, GetBookSellerFromId
($booksellerid);
87 @suppliers = GetBookSeller
($supplier);
90 my $supplier_count = @suppliers;
91 if ( $supplier_count == 1 ) {
93 supplier_name
=> $suppliers[0]->{'name'},
94 booksellerid
=> $suppliers[0]->{'id'},
95 basketcount
=> $suppliers[0]->{'basketcount'}
101 $uid = GetMember
( borrowernumber
=> $loggedinuser )->{userid
};
104 my $userenv = C4
::Context
::userenv
;
105 my $viewbaskets = C4
::Context
->preference('AcqViewBaskets');
107 my $userbranch = $userenv->{branch
};
109 my $budgets = GetBudgetHierarchy
;
111 foreach my $r (@
{$budgets}) {
112 if (!defined $r->{budget_amount
} || $r->{budget_amount
} == 0) {
115 next unless (CanUserUseBudget
($loggedinuser, $r, $userflags));
122 my $loop_suppliers = [];
124 for my $vendor (@suppliers) {
125 my $baskets = GetBasketsInfosByBookseller
( $vendor->{id
}, $allbaskets );
127 my $loop_basket = [];
129 for my $basket ( @
{$baskets} ) {
130 if (CanUserManageBasket
($loggedinuser, $basket, $userflags)) {
131 my $member = GetMember
( borrowernumber
=> $basket->{authorisedby
} );
132 foreach (qw(total_items total_biblios expected_items)) {
136 $basket->{authorisedby_firstname
} = $member->{firstname
};
137 $basket->{authorisedby_surname
} = $member->{surname
};
139 if ($basket->{basketgroupid
}) {
140 my $basketgroup = C4
::Acquisition
::GetBasketgroup
($basket->{basketgroupid
});
142 $basket->{basketgroup
} = $basketgroup;
145 push @
{$loop_basket}, $basket;
149 push @
{$loop_suppliers},
150 { loop_basket
=> $loop_basket,
151 booksellerid
=> $vendor->{id
},
152 name
=> $vendor->{name
},
153 active
=> $vendor->{active
},
158 loop_suppliers
=> $loop_suppliers,
159 supplier
=> ( $booksellerid || $supplier ),
160 count
=> $supplier_count,
161 has_budgets
=> $has_budgets,
163 $template->{VARS
}->{'allbaskets'} = $allbaskets;
165 output_html_with_http_headers
$query, $cookie, $template->output;