Koha/admin/aqcontract.pl
Owen Leonard 81c90ba3bf Bug 8913 [Revised] Improve acquisitions navigation
This patch adds a new menu for vendor-related pages in which
vendor related "views" can be linked to: baskets, basket groups,
contracts, invoices, uncertain prices.

The acquisitions toolbar is pared down to vendor-related actions:
New basket, contract, or vendor; edit vendor, delete vendor,
receive shipment.

Other small improvements have been made to other pages: corrections
to breadcrumbs and title tags, adding useful links betweeen pages.

Vendor menu and toolbar are added to booksellers.pl
when there is only one "search result" (i.e. a vendor id is passed).

- Menu appears when booksellerid variable is present
- Redundant heading removed
- Additional variables added to enable proper display of the toolbar

- Revision corrects broken links pointed out by QA.
- Revision adds check of existing baskets and subscriptions as a
  condition on display of the vendor delete button.

TODO: Add coverage of Basket groups page.

To test, navigate Acquisitions pages and test as many links and buttons
as you can, confirming that nothing is broken on vendor pages, invoice
pages, contract pages, uncertain price pages, etc.

Signed-off-by: Nicole C. Engard <nengard@bywatersolutions.com>

All tests pass - I like this very much!

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
All tests and QA script pass.

Tests done:
1) New toolbar - vendor search
  - no results = button to create new vendor shows
  - 1 result = additional new options show
  - more than one result = button to create new vendor shows

2) Vendor views
  - acq toolbar consistent with 1 result in vendor search
  - new tabs on the left
  - checked all links have the needed parameters and work correctly

3) New toolbar - different pages
  - Toolbar is formatted consistently
  - Delete vendor shows only up when it should - no baskets or
    subscriptions
  - Links work correctly

Works nicely, great groundwork for further improvements.

TODO Add new toolbar to (new) invoices page.
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
2013-02-20 09:17:21 -05:00

163 lines
5.7 KiB
Perl
Executable file

#!/usr/bin/perl
#script to administer the contract table
#written 02/09/2008 by john.soros@biblibre.com
# 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.
use strict;
use warnings;
use CGI;
use C4::Context;
use C4::Auth;
use C4::Output;
use C4::Dates qw/format_date format_date_in_iso/;
use C4::Bookseller qw/GetBookSellerFromId/;
use C4::Contract;
my $input = new CGI;
my $contractnumber = $input->param('contractnumber');
my $booksellerid = $input->param('booksellerid');
my $op = $input->param('op') || '';
my $bookseller = GetBookSellerFromId($booksellerid);
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{ template_name => "admin/aqcontract.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
flagsrequired => { acquisition => 'contracts_manage' },
debug => 1,
}
);
$template->param(
contractnumber => $contractnumber,
booksellerid => $booksellerid,
booksellername => $bookseller->{name},
basketcount => $bookseller->{'basketcount'},
subscriptioncount => $bookseller->{'subscriptioncount'},
);
#ADD_FORM: called if $op is 'add_form'. Used to create form to add or modify a record
if ( $op eq 'add_form' ) {
$template->param( add_form => 1 );
# if contractnumber exists, it's a modify action, so read values to modify...
if ($contractnumber) {
my $contract =
@{ GetContract( { contractnumber => $contractnumber } ) }[0];
$template->param(
contractnumber => $contract->{contractnumber},
contractname => $contract->{contractname},
contractdescription => $contract->{contractdescription},
contractstartdate => format_date( $contract->{contractstartdate} ),
contractenddate => format_date( $contract->{contractenddate} ),
);
} else {
$template->param(
contractnumber => undef,
contractname => undef,
contractdescription => undef,
contractstartdate => undef,
contractenddate => undef,
);
}
# END $OP eq ADD_FORM
}
#ADD_VALIDATE: called by add_form, used to insert/modify data in DB
elsif ( $op eq 'add_validate' ) {
## Please see file perltidy.ERR
$template->param( add_validate => 1 );
my $is_a_modif = $input->param("is_a_modif");
if ( $is_a_modif ) {
ModContract({
contractstartdate => format_date_in_iso( $input->param('contractstartdate') ),
contractenddate => format_date_in_iso( $input->param('contractenddate') ),
contractname => $input->param('contractname'),
contractdescription => $input->param('contractdescription'),
booksellerid => $input->param('booksellerid'),
contractnumber => $input->param('contractnumber'),
});
} else {
AddContract({
contractname => $input->param('contractname'),
contractdescription => $input->param('contractdescription'),
booksellerid => $input->param('booksellerid'),
contractstartdate => format_date_in_iso( $input->param('contractstartdate') ),
contractenddate => format_date_in_iso( $input->param('contractenddate') ),
});
}
print $input->redirect("/cgi-bin/koha/acqui/supplier.pl?booksellerid=$booksellerid");
exit;
# END $OP eq ADD_VALIDATE
}
#DELETE_CONFIRM: called by default form, used to confirm deletion of data in DB
elsif ( $op eq 'delete_confirm' ) {
$template->param( delete_confirm => 1 );
my $contract = @{GetContract( { contractnumber => $contractnumber } )}[0];
$template->param(
contractnumber => $$contract{contractnumber},
contractname => $$contract{contractname},
contractdescription => $$contract{contractdescription},
contractstartdate => format_date( $$contract{contractstartdate} ),
contractenddate => format_date( $$contract{contractenddate} ),
);
# END $OP eq DELETE_CONFIRM
}
#DELETE_CONFIRMED: called by delete_confirm, used to effectively confirm deletion of data in DB
elsif ( $op eq 'delete_confirmed' ) {
$template->param( delete_confirmed => 1 );
DelContract( { contractnumber => $contractnumber } );
print $input->redirect("/cgi-bin/koha/acqui/supplier.pl?booksellerid=$booksellerid");
exit;
# END $OP eq DELETE_CONFIRMED
}
# DEFAULT: Builds a list of contracts and displays them
else {
$template->param(else => 1);
# get contracts
my @contracts = @{GetContract( { booksellerid => $booksellerid } )};
# format dates
for ( @contracts ) {
$$_{contractstartdate} = format_date($$_{contractstartdate});
$$_{contractenddate} = format_date($$_{contractenddate});
}
$template->param(loop => \@contracts);
#---- END $OP eq DEFAULT
}
output_html_with_http_headers $input, $cookie, $template->output;