#
# This file is part of Koha.
#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
=head1 NAME
use strict;
use warnings;
-use CGI;
+use CGI qw ( -utf8 );
use C4::Context;
use C4::Auth;
+use C4::Branch;
use C4::Output;
-use C4::Acquisition qw/GetBasket NewBasket GetContracts ModBasketHeader/;
-use C4::Bookseller qw/GetBookSellerFromId GetBookSeller/;
+use C4::Acquisition qw/GetBasket NewBasket ModBasketHeader/;
+use C4::Contract qw/GetContracts/;
+use Koha::Acquisition::Bookseller;
my $input = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
- template_name => "acqui/basketheader.tmpl",
+ template_name => "acqui/basketheader.tt",
query => $input,
type => "intranet",
authnotrequired => 0,
#parameters:
my $booksellerid = $input->param('booksellerid');
my $basketno = $input->param('basketno');
+my $branches = GetBranches;
my $basket;
my $op = $input ->param('op');
my $is_an_edit= $input ->param('is_an_edit');
if (! $booksellerid) {
$booksellerid=$basket->{'booksellerid'};
}
- @contractloop = &GetContracts($booksellerid, 1);
+ my $contracts = GetContracts({
+ booksellerid => $booksellerid,
+ activeonly => 1,
+ });
+
+ @contractloop = @$contracts;
for (@contractloop) {
if ( $basket->{'contractnumber'} eq $_->{'contractnumber'} ) {
$_->{'selected'} = 1;
} else {
#new basket
my $basket;
- push(@contractloop, &GetContracts($booksellerid, 1));
+ my $contracts = GetContracts({
+ booksellerid => $booksellerid,
+ activeonly => 1,
+ });
+ push(@contractloop, @$contracts);
}
- my $bookseller = GetBookSellerFromId($booksellerid);
+ my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
my $count = scalar @contractloop;
if ( $count > 0) {
$template->param(contractloop => \@contractloop,
basketcontractnumber => $basket->{'contractnumber'});
}
- my @booksellers = GetBookSeller();
+ my @booksellers = Koha::Acquisition::Bookseller->search;
$template->param( add_form => 1,
basketname => $basket->{'basketname'},
basketnote => $basket->{'note'},
booksellerid => $booksellerid,
basketno => $basketno,
booksellers => \@booksellers,
- );
+ deliveryplace => $basket->{deliveryplace},
+ billingplace => $basket->{billingplace},
+ is_standing => $basket->{is_standing},
+ );
+
+ my $billingplace = $basket->{'billingplace'} || C4::Context->userenv->{"branch"};
+ my $deliveryplace = $basket->{'deliveryplace'} || C4::Context->userenv->{"branch"};
+
+ # Build the combobox to select the billing place
+
+ my $branches = C4::Branch::GetBranchesLoop( $billingplace );
+ $template->param( billingplaceloop => $branches );
+ $branches = C4::Branch::GetBranchesLoop( $deliveryplace );
+ $template->param( deliveryplaceloop => $branches );
+
#End Edit
} elsif ( $op eq 'add_validate' ) {
#we are confirming the changes, save the basket
- my $basketno;
if ( $is_an_edit ) {
- $basketno = $input->param('basketno');
- ModBasketHeader( $input->param('basketno'), $input->param('basketname'), $input->param('basketnote'), $input->param('basketbooksellernote'), $input->param('basketcontractnumber') || undef, $input->param('basketbooksellerid') );
+ ModBasketHeader(
+ $basketno,
+ $input->param('basketname'),
+ $input->param('basketnote'),
+ $input->param('basketbooksellernote'),
+ $input->param('basketcontractnumber') || undef,
+ $input->param('basketbooksellerid'),
+ $input->param('deliveryplace'),
+ $input->param('billingplace'),
+ $input->param('is_standing') ? 1 : undef,
+ );
} else { #New basket
- $basketno = NewBasket($booksellerid, $loggedinuser, $input->param('basketname'), $input->param('basketnote'), $input->param('basketbooksellernote'), $input->param('basketcontractnumber'));
+ $basketno = NewBasket(
+ $booksellerid,
+ $loggedinuser,
+ $input->param('basketname'),
+ $input->param('basketnote'),
+ $input->param('basketbooksellernote'),
+ $input->param('basketcontractnumber') || undef,
+ $input->param('deliveryplace'),
+ $input->param('billingplace'),
+ $input->param('is_standing') ? 1 : undef,
+ );
}
print $input->redirect('basket.pl?basketno='.$basketno);
exit 0;