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 GetContracts ModBasketHeader/;
56 use C4::Bookseller qw/GetBookSellerFromId GetBookSeller/;
60 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
62 template_name => "acqui/basketheader.tmpl",
66 flagsrequired => { acquisition => 'order_manage' },
72 my $booksellerid = $input->param('booksellerid');
73 my $basketno = $input->param('basketno');
74 my $branches = GetBranches;
76 my $op = $input ->param('op');
77 my $is_an_edit= $input ->param('is_an_edit');
79 if ( $op eq 'add_form' ) {
83 $basket = GetBasket($basketno);
84 if (! $booksellerid) {
85 $booksellerid=$basket->{'booksellerid'};
87 @contractloop = &GetContracts($booksellerid, 1);
89 if ( $basket->{'contractnumber'} eq $_->{'contractnumber'} ) {
93 $template->param( is_an_edit => 1);
97 push(@contractloop, &GetContracts($booksellerid, 1));
99 my $bookseller = GetBookSellerFromId($booksellerid);
100 my $count = scalar @contractloop;
102 $template->param(contractloop => \@contractloop,
103 basketcontractnumber => $basket->{'contractnumber'});
105 my @booksellers = C4::Bookseller::GetBookSeller();
106 $template->param( add_form => 1,
107 basketname => $basket->{'basketname'},
108 basketnote => $basket->{'note'},
109 basketbooksellernote => $basket->{'booksellernote'},
110 booksellername => $bookseller->{'name'},
111 booksellerid => $booksellerid,
112 basketno => $basketno,
113 booksellers => \@booksellers,
114 deliveryplace => $basket->{deliveryplace},
115 billingplace => $basket->{billingplace},
118 my $billingplace = $basket->{'billingplace'} || C4::Context->userenv->{"branch"};
119 my $deliveryplace = $basket->{'deliveryplace'} || C4::Context->userenv->{"branch"};
121 # Build the combobox to select the billing place
122 my @billingplaceloop;
124 my $branches = C4::Branch::GetBranchesLoop( $billingplace );
125 $template->param( billingplaceloop => $branches );
126 $branches = C4::Branch::GetBranchesLoop( $deliveryplace );
127 $template->param( deliveryplaceloop => $branches );
130 } elsif ( $op eq 'add_validate' ) {
131 #we are confirming the changes, save the basket
135 $input->param('basketname'),
136 $input->param('basketnote'),
137 $input->param('basketbooksellernote'),
138 $input->param('basketcontractnumber') || undef,
139 $input->param('basketbooksellerid'),
140 $input->param('deliveryplace'),
141 $input->param('billingplace'),
144 $basketno = NewBasket(
147 $input->param('basketname'),
148 $input->param('basketnote'),
149 $input->param('basketbooksellernote'),
150 $input->param('basketcontractnumber') || undef,
152 $input->param('deliveryplace'),
153 $input->param('billingplace'),
156 print $input->redirect('basket.pl?basketno='.$basketno);
159 output_html_with_http_headers $input, $cookie, $template->output;