Koha/acqui/basketheader.pl
Jesse Weaver b29493265b Bug 15685: Allow creation of items (AcqCreateItem) to be customizable per-basket
This adds a new basket attribute (create_items) that can optionally be
set to override AcqCreateItem.

The following have been modified to reflect this (with the value of
create_items that causes them to behave differently in parentheses):
  * Cancelling receipt of an order (receiving)
  * Creating an order by hand or from MARC (ordering)
  * Receiving an order (receiving)
  * Showing orders with uncertain price (ordering)
  * Showing orders (receiving)
  * Showing acquisition details in the OPAC (ordering)

Test plan:
  1) Create baskets with "Create items when:" set to ordering,
     receiving, cataloging and unset.
  2) Test each of the above for each of these baskets, verifying that
     the basket-specific attribute overrides AcqCreateItem if set and
     falls back to the syspref otherwise.

NOTE: A check of AcqCreateItem in opac-detail.tt was removed because it
was redundant; the code path in question cannot be triggered unless
create_items/AcqCreateItems is set to the correct value anyway.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Barbara Fondren <bfondren@roundrocktexas.gov>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-10-11 13:06:06 -03:00

167 lines
5.3 KiB
Perl
Executable file

#!/usr/bin/perl
#script to add basket and edit header options (name, notes and contractnumber)
#written by john.soros@biblibre.com 15/09/2008
# Copyright 2008 - 2009 BibLibre SARL
#
# 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 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.
#
# 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
basketheader.pl
=head1 DESCRIPTION
This script is used to edit the basket's "header", or add a new basket, the header contains the supplier ID,
notes to the supplier, local notes, and the contractnumber, which identifies the basket to a specific contract.
=head1 CGI PARAMETERS
=over 4
=item booksellerid
C<$booksellerid> is the id of the supplier we add the basket to.
=item basketid
If it exists, C<$basketno> is the basket we edit
=back
=cut
use strict;
use warnings;
use CGI qw ( -utf8 );
use C4::Context;
use C4::Auth;
use C4::Output;
use C4::Acquisition qw/GetBasket NewBasket ModBasketHeader/;
use C4::Contract qw/GetContracts/;
use Koha::Acquisition::Booksellers;
my $input = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "acqui/basketheader.tt",
query => $input,
type => "intranet",
authnotrequired => 0,
flagsrequired => { acquisition => 'order_manage' },
debug => 1,
}
);
#parameters:
my $booksellerid = $input->param('booksellerid');
my $basketno = $input->param('basketno');
my $basket;
my $op = $input->param('op');
my $is_an_edit = $input->param('is_an_edit');
if ( $op eq 'add_form' ) {
my @contractloop;
if ( $basketno ) {
#this is an edit
$basket = GetBasket($basketno);
if (! $booksellerid) {
$booksellerid=$basket->{'booksellerid'};
}
my $contracts = GetContracts({
booksellerid => $booksellerid,
activeonly => 1,
});
@contractloop = @$contracts;
for (@contractloop) {
if ( $basket->{'contractnumber'} eq $_->{'contractnumber'} ) {
$_->{'selected'} = 1;
}
}
$template->param( is_an_edit => 1);
} else {
#new basket
my $basket;
my $contracts = GetContracts({
booksellerid => $booksellerid,
activeonly => 1,
});
push(@contractloop, @$contracts);
}
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
my $count = scalar @contractloop;
if ( $count > 0) {
$template->param(contractloop => \@contractloop,
basketcontractnumber => $basket->{'contractnumber'});
}
my @booksellers = Koha::Acquisition::Booksellers->search(
undef,
{ order_by => { -asc => 'name' } } );
$template->param( add_form => 1,
basketname => $basket->{'basketname'},
basketnote => $basket->{'note'},
basketbooksellernote => $basket->{'booksellernote'},
booksellername => $bookseller->name,
booksellerid => $booksellerid,
basketno => $basketno,
booksellers => \@booksellers,
is_standing => $basket->{is_standing},
);
my $billingplace = $basket->{'billingplace'} || C4::Context->userenv->{"branch"};
my $deliveryplace = $basket->{'deliveryplace'} || C4::Context->userenv->{"branch"};
$template->param( billingplace => $billingplace );
$template->param( deliveryplace => $deliveryplace );
#End Edit
} elsif ( $op eq 'add_validate' ) {
#we are confirming the changes, save the basket
if ( $is_an_edit ) {
ModBasketHeader(
$basketno,
scalar $input->param('basketname'),
scalar $input->param('basketnote'),
scalar $input->param('basketbooksellernote'),
scalar $input->param('basketcontractnumber') || undef,
scalar $input->param('basketbooksellerid'),
scalar $input->param('deliveryplace'),
scalar $input->param('billingplace'),
scalar $input->param('is_standing') ? 1 : undef,
scalar $input->param('create_items')
);
} else { #New basket
$basketno = NewBasket(
$booksellerid,
$loggedinuser,
scalar $input->param('basketname'),
scalar $input->param('basketnote'),
scalar $input->param('basketbooksellernote'),
scalar $input->param('basketcontractnumber') || undef,
scalar $input->param('deliveryplace'),
scalar $input->param('billingplace'),
scalar $input->param('is_standing') ? 1 : undef,
scalar $input->param('create_items')
);
}
print $input->redirect('basket.pl?basketno='.$basketno);
exit 0;
}
output_html_with_http_headers $input, $cookie, $template->output;