3 #script to add basket and edit header options (name, notes and contractnumber)
4 #written by john.soros@biblibre.com 15/09/2008
6 # Copyright 2008 - 2009 BibLibre SARL
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along
20 # with Koha; if not, write to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 This script is used to edit the basket's "header", or add a new basket, the header contains the supplier ID,
30 notes to the supplier, local notes, and the contractnumber, which identifies the basket to a specific contract.
38 C<$booksellerid> is the id of the supplier we add the basket to.
42 If it exists, C<$basketno> is the basket we edit
55 use C4
::Acquisition qw
/GetBasket NewBasket ModBasketHeader/;
56 use C4
::Bookseller qw
/GetBookSellerFromId GetBookSeller/;
57 use C4
::Contract qw
/GetContracts/;
61 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
63 template_name
=> "acqui/basketheader.tt",
67 flagsrequired
=> { acquisition
=> 'order_manage' },
73 my $booksellerid = $input->param('booksellerid');
74 my $basketno = $input->param('basketno');
75 my $branches = GetBranches
;
77 my $op = $input ->param('op');
78 my $is_an_edit= $input ->param('is_an_edit');
80 if ( $op eq 'add_form' ) {
84 $basket = GetBasket
($basketno);
85 if (! $booksellerid) {
86 $booksellerid=$basket->{'booksellerid'};
88 my $contracts = GetContracts
({
89 booksellerid
=> $booksellerid,
93 @contractloop = @
$contracts;
95 if ( $basket->{'contractnumber'} eq $_->{'contractnumber'} ) {
99 $template->param( is_an_edit
=> 1);
103 my $contracts = GetContracts
({
104 booksellerid
=> $booksellerid,
107 push(@contractloop, @
$contracts);
109 my $bookseller = GetBookSellerFromId
($booksellerid);
110 my $count = scalar @contractloop;
112 $template->param(contractloop
=> \
@contractloop,
113 basketcontractnumber
=> $basket->{'contractnumber'});
115 my @booksellers = C4
::Bookseller
::GetBookSeller
();
116 $template->param( add_form
=> 1,
117 basketname
=> $basket->{'basketname'},
118 basketnote
=> $basket->{'note'},
119 basketbooksellernote
=> $basket->{'booksellernote'},
120 booksellername
=> $bookseller->{'name'},
121 booksellerid
=> $booksellerid,
122 basketno
=> $basketno,
123 booksellers
=> \
@booksellers,
124 deliveryplace
=> $basket->{deliveryplace
},
125 billingplace
=> $basket->{billingplace
},
128 my $billingplace = $basket->{'billingplace'} || C4
::Context
->userenv->{"branch"};
129 my $deliveryplace = $basket->{'deliveryplace'} || C4
::Context
->userenv->{"branch"};
131 # Build the combobox to select the billing place
132 my @billingplaceloop;
134 my $branches = C4
::Branch
::GetBranchesLoop
( $billingplace );
135 $template->param( billingplaceloop
=> $branches );
136 $branches = C4
::Branch
::GetBranchesLoop
( $deliveryplace );
137 $template->param( deliveryplaceloop
=> $branches );
140 } elsif ( $op eq 'add_validate' ) {
141 #we are confirming the changes, save the basket
145 $input->param('basketname'),
146 $input->param('basketnote'),
147 $input->param('basketbooksellernote'),
148 $input->param('basketcontractnumber') || undef,
149 $input->param('basketbooksellerid'),
150 $input->param('deliveryplace'),
151 $input->param('billingplace'),
154 $basketno = NewBasket
(
157 $input->param('basketname'),
158 $input->param('basketnote'),
159 $input->param('basketbooksellernote'),
160 $input->param('basketcontractnumber') || undef,
161 $input->param('deliveryplace'),
162 $input->param('billingplace'),
165 print $input->redirect('basket.pl?basketno='.$basketno);
168 output_html_with_http_headers
$input, $cookie, $template->output;