0247b6741e
This patch includes: - the subroutines GetContract and GetContracts has been moved from C4::Acquisition.pm to C4::Contract.pm and adapted for a general use - adaptation of acqui/basket.pl, acqui/basketheader.pl, acqui/neworderempty.pl, acqui/supplier.pl and admin/aqcontract.pl - the unit tests for the module C4::Contract.pm Test plan: 1) Apply the patch 2) Execute the unit tests by launching: prove t/db_dependent/Contract.t t/Acquisition/ t/db_dependent/Acquisition/ t/db_dependent/Acquisition.t 3) The command has to be a success : t/db_dependent/Contract.t ................................. ok t/Acquisition/CanUserManageBasket.t ....................... ok t/Acquisition/Invoice.t ................................... ok t/db_dependent/Acquisition/GetBasketsInfosByBookseller.t .. ok t/db_dependent/Acquisition/GetOrdersByBiblionumber.t ...... ok t/db_dependent/Acquisition/Invoices.t ..................... ok t/db_dependent/Acquisition/OrderFromSubscription.t ........ ok t/db_dependent/Acquisition/TransferOrder.t ................ 1/11 # Transfering order to basket2 t/db_dependent/Acquisition/TransferOrder.t ................ ok t/db_dependent/Acquisition/close_reopen_basket.t .......... ok t/db_dependent/Acquisition.t .............................. ok All tests successful. Files=10, Tests=284, 15 wallclock secs ( 0.11 usr 0.02 sys + 12.88 cusr 0.77 csys = 13.78 CPU) Result: PASS 4) Log on with a superlibrarian permission 5) Go on the page acqui/supplier.pl (Acquisitions > Button "New vendor") 6) Record a vendor with a nonzero "name" 7) Go on the page admin/aqcontract.pl (click on the "Contracts" item in the menu) 8) Click on the button "New" > "Contract" and record a new one 9) Verify the displayed data are correct about the contract 10) "Edit" the contract with different values and verify the data are updated 11) Click on "Delete" in order to delete the contract, verify the displayed data are correct but cancel the operation 12) Click on "New" > "Basket" and verify there is the created contract in field "Contract", then record a basket by selectioning the created contract 13) Verify the contract name displayed is correct 14) Record an active budget and a fund linked to this budget 15) Go on the new basket (Home > Acquisitions > Search the created vendor) 16) Click on "Add to basket" then "From a new (empty) record" and verify the displayed contract name is correct Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Tested with both patches applied. Works as described following test plan, all points (I did 14 first) All test pass No koha-qa errors Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
168 lines
5.3 KiB
Perl
Executable file
168 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 2 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, write to the Free Software Foundation, Inc.,
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
=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;
|
|
use C4::Context;
|
|
use C4::Auth;
|
|
use C4::Branch;
|
|
use C4::Output;
|
|
use C4::Acquisition qw/GetBasket NewBasket ModBasketHeader/;
|
|
use C4::Bookseller qw/GetBookSellerFromId GetBookSeller/;
|
|
use C4::Contract qw/GetContracts/;
|
|
|
|
|
|
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 $branches = GetBranches;
|
|
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 = GetBookSellerFromId($booksellerid);
|
|
my $count = scalar @contractloop;
|
|
if ( $count > 0) {
|
|
$template->param(contractloop => \@contractloop,
|
|
basketcontractnumber => $basket->{'contractnumber'});
|
|
}
|
|
my @booksellers = C4::Bookseller::GetBookSeller();
|
|
$template->param( add_form => 1,
|
|
basketname => $basket->{'basketname'},
|
|
basketnote => $basket->{'note'},
|
|
basketbooksellernote => $basket->{'booksellernote'},
|
|
booksellername => $bookseller->{'name'},
|
|
booksellerid => $booksellerid,
|
|
basketno => $basketno,
|
|
booksellers => \@booksellers,
|
|
deliveryplace => $basket->{deliveryplace},
|
|
billingplace => $basket->{billingplace},
|
|
);
|
|
|
|
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 @billingplaceloop;
|
|
|
|
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
|
|
if ( $is_an_edit ) {
|
|
ModBasketHeader(
|
|
$basketno,
|
|
$input->param('basketname'),
|
|
$input->param('basketnote'),
|
|
$input->param('basketbooksellernote'),
|
|
$input->param('basketcontractnumber') || undef,
|
|
$input->param('basketbooksellerid'),
|
|
$input->param('deliveryplace'),
|
|
$input->param('billingplace'),
|
|
);
|
|
} else { #New basket
|
|
$basketno = NewBasket(
|
|
$booksellerid,
|
|
$loggedinuser,
|
|
$input->param('basketname'),
|
|
$input->param('basketnote'),
|
|
$input->param('basketbooksellernote'),
|
|
$input->param('basketcontractnumber') || undef,
|
|
$input->param('deliveryplace'),
|
|
$input->param('billingplace'),
|
|
);
|
|
}
|
|
print $input->redirect('basket.pl?basketno='.$basketno);
|
|
exit 0;
|
|
}
|
|
output_html_with_http_headers $input, $cookie, $template->output;
|