Koha/serials/claims.pl
Jonathan Druart 7690cd5ad1 Bug 5342: Serial claiming improvements: add a counter
This patch adds a new DB field serial.claims_count
This field already exists for late orders. It makes sense to introduce
it for serial.

Test plan:
0/
 a) Does not apply the patch.
 b) Remove all your claimissues notices and be sure you have some serial issues
    in late.
 c) remove email address for the vendor you will use.
 d) remove email address for the logged in user.
 e) Export claims using the csv export => The selected issues will be
 marked as claimed.
 f) logout/login (to update the email address).
1/ Apply the patch and execute the updatedb entry.
2/ Go on the Serials > Claims page
3/ Verify that you get a warning message 'No claimissue notice defined'
4/ Verify the vendor list is correct (with the number of serial in late.
You should not get any changes here.
5/ Select one vendor and verify that the issue which was claimed before
has a claim count set to 1.
6/ Verify that you are not able to send notification to the vendor.
7/ Create a claimissue notice.
Something like:
  <<LibrarianFirstname>>
  <<LibrarianSurname>>
  The following issues are in late:
  <order><<biblio.title>>, <<biblio.author>> (<<biblio.serial>>)</order>
8/ Go on the Serials > Claims page, the warning message does not appear
anymore.
9/ Select issues. Select a notice. And "Send notification".
You should get an error (no email defined for this vendor).
10/ Add an email for the vendor.
11/ Select issues. Select a notice. And "Send notification".
You should get an error (no email defined for your user).
12/ Add an email address to your user
logout/login
13/ Select issues. Select a notice. And "Send notification".
You should get a happy message: the email has been sent!
14/ The email will contain the order tags if bug 12851 is not
pushed/applied.

Signed-off-by: Paola Rossi <paola.rossi@cineca.it>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works as described, some small issues fixed in a follow-up.
Note: If you change the email address of your staff user, you will
have to log out and back in to make the change take effect.

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2014-10-28 10:07:37 -03:00

113 lines
3.7 KiB
Perl
Executable file

#!/usr/bin/perl
# Parts Copyright 2010 Biblibre
# 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::Auth;
use C4::Serials;
use C4::Acquisition;
use C4::Output;
use C4::Bookseller qw( GetBookSeller );
use C4::Context;
use C4::Letters;
use C4::Branch; # GetBranches GetBranchesLoop
use C4::Csv qw( GetCsvProfiles );
my $input = CGI->new;
my $serialid = $input->param('serialid');
my $op = $input->param('op');
my $claimletter = $input->param('claimletter');
my $supplierid = $input->param('supplierid');
my $suppliername = $input->param('suppliername');
# open template first (security & userenv set here)
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => 'serials/claims.tt',
query => $input,
type => 'intranet',
authnotrequired => 0,
flagsrequired => {serials => 'claim_serials'},
debug => 1,
});
# supplierlist is returned in name order
my $supplierlist = GetSuppliersWithLateIssues();
for my $s (@{$supplierlist} ) {
$s->{count} = scalar GetLateOrMissingIssues($s->{id});
if ($supplierid && $s->{id} == $supplierid) {
$s->{selected} = 1;
}
}
my $branchloop = GetBranchesLoop();
my $preview=0;
if($op && $op eq 'preview'){
$preview = 1;
} else {
my @serialnums=$input->param('serialid');
if (@serialnums) { # i.e. they have been flagged to generate claims
my $err;
eval {
$err = SendAlerts('claimissues',\@serialnums,$input->param("letter_code"));
if ( not ref $err or not exists $err->{error} ) {
UpdateClaimdateIssues(\@serialnums);
}
};
if ( $@ ) {
$template->param(error_claim => $@);
} elsif ( ref $err and exists $err->{error} ) {
if ( $err->{error} eq "no_email" ) {
$template->param( error_claim => 'no_vendor_email' );
} elsif ( $err->{error} =~ m|Bad or missing From address| ) {
$template->param( error_claim => 'no_loggedin_user_email' );
}
} else {
$template->param( info_claim => 1 );
}
}
}
my $letters = GetLetters({ module => 'claimissues' });
my @missingissues;
my @supplierinfo;
if ($supplierid) {
@missingissues = GetLateOrMissingIssues($supplierid);
@supplierinfo=GetBookSeller($supplierid);
}
$template->param(
suploop => $supplierlist,
phone => $supplierinfo[0]->{phone},
booksellerfax => $supplierinfo[0]->{booksellerfax},
bookselleremail => $supplierinfo[0]->{bookselleremail},
preview => $preview,
missingissues => \@missingissues,
supplierid => $supplierid,
claimletter => $claimletter,
supplierloop => \@supplierinfo,
branchloop => $branchloop,
csv_profiles => C4::Csv::GetCsvProfiles( "sql" ),
letters => $letters,
(uc(C4::Context->preference("marcflavour"))) => 1
);
output_html_with_http_headers $input, $cookie, $template->output;