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
11 # under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
15 # Koha is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with Koha; if not, see <http://www.gnu.org/licenses>.
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
54 use C4
::Acquisition qw
/GetBasket NewBasket ModBasketHeader/;
55 use C4
::Contract qw
/GetContracts/;
57 use Koha
::Acquisition
::Booksellers
;
60 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
62 template_name
=> "acqui/basketheader.tt",
66 flagsrequired
=> { acquisition
=> 'order_manage' },
72 my $booksellerid = $input->param('booksellerid');
73 my $basketno = $input->param('basketno');
75 my $op = $input->param('op');
76 my $is_an_edit = $input->param('is_an_edit');
78 if ( $op eq 'add_form' ) {
82 $basket = GetBasket
($basketno);
83 if (! $booksellerid) {
84 $booksellerid=$basket->{'booksellerid'};
86 my $contracts = GetContracts
({
87 booksellerid
=> $booksellerid,
91 @contractloop = @
$contracts;
93 if ( $basket->{'contractnumber'} eq $_->{'contractnumber'} ) {
97 $template->param( is_an_edit
=> 1);
101 my $contracts = GetContracts
({
102 booksellerid
=> $booksellerid,
105 push(@contractloop, @
$contracts);
107 my $bookseller = Koha
::Acquisition
::Booksellers
->find( $booksellerid );
108 my $count = scalar @contractloop;
110 $template->param(contractloop
=> \
@contractloop,
111 basketcontractnumber
=> $basket->{'contractnumber'});
113 my @booksellers = Koha
::Acquisition
::Booksellers
->search(
115 { order_by
=> { -asc
=> 'name' } } );
117 $template->param( add_form
=> 1,
118 basketname
=> $basket->{'basketname'},
119 basketnote
=> $basket->{'note'},
120 basketbooksellernote
=> $basket->{'booksellernote'},
121 booksellername
=> $bookseller->name,
122 booksellerid
=> $booksellerid,
123 basketno
=> $basketno,
124 booksellers
=> \
@booksellers,
125 is_standing
=> $basket->{is_standing
},
128 my $billingplace = $basket->{'billingplace'} || C4
::Context
->userenv->{"branch"};
129 my $deliveryplace = $basket->{'deliveryplace'} || C4
::Context
->userenv->{"branch"};
131 $template->param( billingplace
=> $billingplace );
132 $template->param( deliveryplace
=> $deliveryplace );
135 } elsif ( $op eq 'add_validate' ) {
136 #we are confirming the changes, save the basket
140 scalar $input->param('basketname'),
141 scalar $input->param('basketnote'),
142 scalar $input->param('basketbooksellernote'),
143 scalar $input->param('basketcontractnumber') || undef,
144 scalar $input->param('basketbooksellerid'),
145 scalar $input->param('deliveryplace'),
146 scalar $input->param('billingplace'),
147 scalar $input->param('is_standing') ?
1 : undef,
148 scalar $input->param('create_items')
151 $basketno = NewBasket
(
154 scalar $input->param('basketname'),
155 scalar $input->param('basketnote'),
156 scalar $input->param('basketbooksellernote'),
157 scalar $input->param('basketcontractnumber') || undef,
158 scalar $input->param('deliveryplace'),
159 scalar $input->param('billingplace'),
160 scalar $input->param('is_standing') ?
1 : undef,
161 scalar $input->param('create_items')
164 print $input->redirect('basket.pl?basketno='.$basketno);
167 output_html_with_http_headers
$input, $cookie, $template->output;