Bug 14903: Remove C4::Dates from circ/circulation.pl (and more)

Patch to remove deprectated C4::Dates from:
- circ/circulation.pl
- C4/Circulation.pm
- koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt

To test:
- Apply patch
- Go to the checkout site (Home > Circulation > Checkouts)
- Verify that data displays properly (including for users with a card
  that expires in the  near future, see syspref 'NotifyBorrowerDeparture')
- Search for regressions
- prove -v t/db_dependent/Circulation.t

(Amended following comment #9 / #11  25.10.2015 /mv)

Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Marc Véron 2015-10-09 18:48:30 +02:00 committed by Tomas Cohen Arazi
parent 201935cb62
commit 421fae24f1
3 changed files with 28 additions and 33 deletions

View File

@ -22,14 +22,13 @@ package C4::Circulation;
use strict;
#use warnings; FIXME - Bug 2505
use DateTime;
use Koha::DateUtils;
use C4::Context;
use C4::Stats;
use C4::Reserves;
use C4::Biblio;
use C4::Items;
use C4::Members;
use C4::Dates;
use C4::Dates qw(format_date);
use C4::Accounts;
use C4::ItemCirculationAlertPreference;
use C4::Message;
@ -657,7 +656,7 @@ sub itemissues {
=head2 CanBookBeIssued
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower,
$barcode, $duedatespec, $inprocess, $ignore_reserves );
$barcode, $duedate, $inprocess, $ignore_reserves );
Check if a book can be issued.
@ -669,7 +668,7 @@ C<$issuingimpossible> and C<$needsconfirmation> are some hashref.
=item C<$barcode> is the bar code of the book being issued.
=item C<$duedatespec> is a C4::Dates object.
=item C<$duedates> is a DateTime object.
=item C<$inprocess> boolean switch
=item C<$ignore_reserves> boolean switch
@ -1035,7 +1034,7 @@ sub CanBookBeIssued {
$needsconfirmation{'rescardnumber'} = $resborrower->{'cardnumber'};
$needsconfirmation{'resborrowernumber'} = $resborrower->{'borrowernumber'};
$needsconfirmation{'resbranchname'} = $branchname;
$needsconfirmation{'reswaitingdate'} = format_date($res->{'waitingdate'});
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
}
elsif ( $restype eq "Reserved" ) {
# The item is on reserve for someone else.
@ -1045,7 +1044,7 @@ sub CanBookBeIssued {
$needsconfirmation{'rescardnumber'} = $resborrower->{'cardnumber'};
$needsconfirmation{'resborrowernumber'} = $resborrower->{'borrowernumber'};
$needsconfirmation{'resbranchname'} = $branchname;
$needsconfirmation{'resreservedate'} = format_date($res->{'reservedate'});
$needsconfirmation{'resreservedate'} = $res->{'reservedate'};
}
}
}
@ -1212,13 +1211,13 @@ Issue a book. Does no check, they are done in CanBookBeIssued. If we reach this
=item C<$barcode> is the barcode of the item being issued.
=item C<$datedue> is a C4::Dates object for the max date of return, i.e. the date due (optional).
=item C<$datedue> is a DateTime object for the max date of return, i.e. the date due (optional).
Calculated if empty.
=item C<$cancelreserve> is 1 to override and cancel any pending reserves for the item (optional).
=item C<$issuedate> is the date to issue the item in iso (YYYY-MM-DD) format (optional).
Defaults to today. Unlike C<$datedue>, NOT a C4::Dates object, unfortunately.
Defaults to today. Unlike C<$datedue>, NOT a DateTime object, unfortunately.
AddIssue does the following things :
@ -1905,7 +1904,7 @@ sub AddReturn {
# define circControlBranch only if dropbox mode is set
# don't allow dropbox mode to create an invalid entry in issues (issuedate > today)
# FIXME: check issuedate > returndate, factoring in holidays
#$circControlBranch = _GetCircControlBranch($item,$borrower) unless ( $item->{'issuedate'} eq C4::Dates->today('iso') );;
$circControlBranch = _GetCircControlBranch($item,$borrower);
$issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $dropboxdate ) == -1 ? 1 : 0;
}
@ -2851,7 +2850,7 @@ C<$itemnumber> is the number of the item to renew.
C<$branch> is the library where the renewal took place (if any).
The library that controls the circ policies for the renewal is retrieved from the issues record.
C<$datedue> can be a C4::Dates object used to set the due date.
C<$datedue> can be a DateTime object used to set the due date.
C<$lastreneweddate> is an optional ISO-formatted date used to set issues.lastreneweddate. If
this parameter is not supplied, lastreneweddate is set to the current date.
@ -3435,7 +3434,7 @@ $newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower);
this function calculates the due date given the start date and configured circulation rules,
checking against the holidays calendar as per the 'useDaysMode' syspref.
C<$startdate> = C4::Dates object representing start date of loan period (assumed to be today)
C<$startdate> = DateTime object representing start date of loan period (assumed to be today)
C<$itemtype> = itemtype code of item in question
C<$branch> = location whose calendar to use
C<$borrower> = Borrower object
@ -3877,8 +3876,6 @@ sub TransferSlip {
my $item = GetItem( $itemnumber, $barcode )
or return;
my $pulldate = C4::Dates->new();
return C4::Letters::GetPreparedLetter (
module => 'circulation',
letter_code => 'TRANSFERSLIP',

View File

@ -30,7 +30,6 @@ use DateTime::Duration;
use C4::Output;
use C4::Print;
use C4::Auth qw/:DEFAULT get_session haspermission/;
use C4::Dates qw/format_date/;
use C4::Branch; # GetBranches
use C4::Koha; # GetPrinter
use C4::Circulation;
@ -175,6 +174,8 @@ for my $barcode ( @$barcodes ) {
my $stickyduedate = $query->param('stickyduedate') || $session->param('stickyduedate');
my $duedatespec = $query->param('duedatespec') || $session->param('stickyduedate');
$duedatespec = eval { output_pref( { dt => dt_from_string( $duedatespec ), dateformat => 'iso' }); };
my $issueconfirmed = $query->param('issueconfirmed');
my $cancelreserve = $query->param('cancelreserve');
my $print = $query->param('print') || q{};
@ -202,18 +203,15 @@ if( $onsite_checkout && !$duedatespec_allow ) {
$datedue = output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
$datedue .= ' 23:59:00';
} elsif( $duedatespec_allow ) {
if ($duedatespec) {
if ($duedatespec =~ C4::Dates->regexp('syspref')) {
$datedue = dt_from_string($duedatespec);
} else {
if ($datedue) {
$datedue = eval { dt_from_string( $datedue ) };
if (! $datedue ) {
$invalidduedate = 1;
$template->param(IMPOSSIBLE=>1, INVALID_DATE=>$duedatespec);
$template->param( IMPOSSIBLE=>1, INVALID_DATE=>$datedue );
}
}
}
our $todaysdate = C4::Dates->new->output('iso');
# check and see if we should print
if ( @$barcodes == 0 && $print eq 'maybe' ) {
$print = 'yes';
@ -295,7 +293,7 @@ if ($borrowernumber) {
noissues => ($force_allow_issue) ? 0 : "1",
forceallow => $force_allow_issue,
expired => "1",
renewaldate => format_date("$renew_year-$renew_month-$renew_day")
renewaldate => "$renew_year-$renew_month-$renew_day",
);
}
# check for NotifyBorrowerDeparture
@ -304,8 +302,9 @@ if ($borrowernumber) {
Date_to_Days( $today_year, $today_month, $today_day ) )
{
# borrower card soon to expire warn librarian
$template->param("warndeparture" => format_date($borrower->{dateexpiry}),
flagged => "1",);
$template->param( "warndeparture" => $borrower->{dateexpiry} ,
flagged => "1"
);
if (C4::Context->preference('ReturnBeforeExpiry')){
$template->param("returnbeforeexpiry" => 1);
}
@ -323,8 +322,7 @@ if ($borrowernumber) {
);
if ( $borrower->{debarred} ne "9999-12-31" ) {
$template->param( 'userdebarreddate' =>
C4::Dates::format_date( $borrower->{debarred} ) );
$template->param( 'userdebarreddate' => $borrower->{debarred} );
}
}
@ -590,7 +588,7 @@ $template->param(
printer => $printer,
printername => $printer,
was_renewed => $query->param('was_renewed') ? 1 : 0,
expiry => format_date($borrower->{'dateexpiry'}),
expiry => $borrower->{'dateexpiry'},
roadtype => $roadtype,
amountold => $amountold,
barcodes => $barcodes,

View File

@ -190,7 +190,7 @@ $(document).ready(function() {
</form>
</div>
[% IF ( was_renewed ) %]<div class="dialog message">Patron's account has been renewed until [% expiry %]</div>[% END %]
[% IF ( was_renewed ) %]<div class="dialog message">Patron's account has been renewed until [% expiry | $KohaDates %]</div>[% END %]
[% IF additional_materials %]
<div id="materials" class="dialog message">Note about the accompanying materials: <br />
@ -237,11 +237,11 @@ $(document).ready(function() {
[% END %]
[% IF ( RESERVE_WAITING ) %]
<li>Item <i>[% getTitleMessageIteminfo %]</i> ([% getBarcodeMessageIteminfo %]) has been waiting for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% resborrowernumber %]">[% resfirstname %] [% ressurname %]</a> ([% rescardnumber %]) at [% resbranchname %] since [% reswaitingdate %]</li>
<li>Item <i>[% getTitleMessageIteminfo %]</i> ([% getBarcodeMessageIteminfo %]) has been waiting for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% resborrowernumber %]">[% resfirstname %] [% ressurname %]</a> ([% rescardnumber %]) at [% resbranchname %] since [% reswaitingdate | $KohaDates %]</li>
[% END %]
[% IF ( RESERVED ) %]
<li>Item <i>[% getTitleMessageIteminfo %]</i> ([% getBarcodeMessageIteminfo %]) has been on hold for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% resborrowernumber %]">[% resfirstname %] [% ressurname %]</a> ([% rescardnumber %]) at [% resbranchname %] since [% resreservedate %]</li>
<li>Item <i>[% getTitleMessageIteminfo %]</i> ([% getBarcodeMessageIteminfo %]) has been on hold for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% resborrowernumber %]">[% resfirstname %] [% ressurname %]</a> ([% rescardnumber %]) at [% resbranchname %] since [% resreservedate | $KohaDates %]</li>
[% END %]
[% IF ( ISSUED_TO_ANOTHER ) %]
@ -724,7 +724,7 @@ No patron matched <span class="ex">[% message %]</span>
[% IF ( warndeparture ) %]
<li><span class="circ-hlt">Expiration:</span> Patron's card will expire soon.
Patron's card expires on [% expiry %] <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% borrowernumber %]&amp;destination=circ&amp;reregistration=y">Renew</a> or <a href="/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% borrowernumber %]&amp;categorycode=[% categorycode %]">Edit Details</a>
Patron's card expires on [% expiry | $KohaDates %] <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% borrowernumber %]&amp;destination=circ&amp;reregistration=y">Renew</a> or <a href="/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% borrowernumber %]&amp;categorycode=[% categorycode %]">Edit Details</a>
</li>
[% END %]
@ -737,7 +737,7 @@ No patron matched <span class="ex">[% message %]</span>
[% IF ( expired ) %]
<li><span class="circ-hlt">Expiration:</span> Patron's card has expired.
[% IF ( expiry ) %]Patron's card expired on [% expiry %][% END %] <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% borrowernumber %]&amp;destination=circ&amp;reregistration=y">Renew</a> or <a href="/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% borrowernumber %]&amp;categorycode=[% categorycode %]">Edit Details</a>
[% IF ( expiry ) %]Patron's card expired on [% expiry | $KohaDates %][% END %] <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% borrowernumber %]&amp;destination=circ&amp;reregistration=y">Renew</a> or <a href="/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% borrowernumber %]&amp;categorycode=[% categorycode %]">Edit Details</a>
</li>
[% END %]
@ -755,7 +755,7 @@ No patron matched <span class="ex">[% message %]</span>
<span class="circ-hlt"> Restricted:</span> Patron's account is restricted
[% IF ( userdebarreddate ) %]
until [% userdebarreddate %]
until [% userdebarreddate | $KohaDates %]
[% END %]
[% IF ( debarredcomment ) %]