From 958b65d0045949b406b16a370ad06a239184828d Mon Sep 17 00:00:00 2001 From: Ian Walls Date: Fri, 9 Mar 2012 13:55:38 -0500 Subject: [PATCH] Bug 7444: Update circ/circulation.pl to use KohaDates TT Plugin Removes all date formatting done in circ/circulation, and sets any/all date outputs to iso format. The formatting of dates is now handled in the template using the KohaDates plugin. This allows use to remove a dependency on C4/Dates.pm from the script. This patch also removes the usage of C4/Overdues/CheckBorrowerDebarred. Since borrowers.debarred is returned by GetMemberDetails, it doesn't make sense to include another module to run another MySQL query just to fetch the date again. To Test: 1. View the checkout page for a patron with materials checked out today and in days past, as well as items on reserve. 2. View a patron who is nearing their expiry date 3. Renew a patron 4. Renew a material from the checkout page using the renewal date selector 5. Attempt to checkout a book to a patron that is on hold for someone else 6. Attempt to checkout a book that is currently checked out 7. View a debarred patron In all cases, any dates displayed should be in syspref format Signed-off-by: Martin Renvoize Signed-off-by: Paul Poulain Signed-off-by: Chris Cormack --- circ/circulation.pl | 28 ++++++++----------- .../prog/en/modules/circ/circulation.tt | 22 +++++++-------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/circ/circulation.pl b/circ/circulation.pl index 14eaf1a29f..c3c9f2c049 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -27,11 +27,9 @@ use CGI; use C4::Output; use C4::Print; use C4::Auth qw/:DEFAULT get_session/; -use C4::Dates qw/format_date/; use C4::Branch; # GetBranches use C4::Koha; # GetPrinter use C4::Circulation; -use C4::Overdues qw/CheckBorrowerDebarred/; use C4::Members; use C4::Biblio; use C4::Reserves; @@ -241,7 +239,7 @@ if ($borrowernumber) { flagged => "1", noissues => "1", expired => "1", - renewaldate => format_date("$renew_year-$renew_month-$renew_day") + renewaldate => "$renew_year-$renew_month-$renew_day", ); } # check for NotifyBorrowerDeparture @@ -250,7 +248,7 @@ 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}), + $template->param("warndeparture" => $borrower->{dateexpiry}, flagged => "1",); if (C4::Context->preference('ReturnBeforeExpiry')){ $template->param("returnbeforeexpiry" => 1); @@ -262,12 +260,12 @@ if ($borrowernumber) { finetotal => $fines ); - my $debar = CheckBorrowerDebarred($borrowernumber); + my $debar = $borrower->{debarred}; if ($debar) { $template->param( 'userdebarred' => 1 ); $template->param( 'debarredcomment' => $borrower->{debarredcomment} ); if ( $debar ne "9999-12-31" ) { - $template->param( 'userdebarreddate' => C4::Dates::format_date($debar) ); + $template->param( 'userdebarreddate' => $debar ); } } @@ -349,7 +347,7 @@ if ($borrowernumber) { $getreserv{transfered} = 0; $getreserv{nottransfered} = 0; - $getreserv{reservedate} = format_date( $num_res->{'reservedate'} ); + $getreserv{reservedate} = $num_res->{'reservedate'}; $getreserv{reservenumber} = $num_res->{'reservenumber'}; $getreserv{title} = $getiteminfo->{'title'}; $getreserv{itemtype} = $itemtypeinfo->{'description'}; @@ -369,7 +367,7 @@ if ($borrowernumber) { $getWaitingReserveInfo{biblionumber} = $getiteminfo->{'biblionumber'}; $getWaitingReserveInfo{itemtype} = $itemtypeinfo->{'description'}; $getWaitingReserveInfo{author} = $getiteminfo->{'author'}; - $getWaitingReserveInfo{reservedate} = format_date( $num_res->{'reservedate'} ); + $getWaitingReserveInfo{reservedate} = $num_res->{'reservedate'}; $getWaitingReserveInfo{waitingat} = GetBranchName( $num_res->{'branchcode'} ); $getWaitingReserveInfo{waitinghere} = 1 if $num_res->{'branchcode'} eq $branch; } @@ -377,7 +375,7 @@ if ($borrowernumber) { if ($transfertwhen) { $getreserv{color} = 'transfered'; $getreserv{transfered} = 1; - $getreserv{datesent} = format_date($transfertwhen); + $getreserv{datesent} = $transfertwhen; $getreserv{frombranch} = GetBranchName($transfertfrom); } elsif ($getiteminfo->{'holdingbranch'} ne $num_res->{'branchcode'}) { $getreserv{nottransfered} = 1; @@ -448,16 +446,14 @@ sub build_issue_data { $it->{'can_renew'} = $can_renew; $it->{'can_confirm'} = !$can_renew && !$restype; $it->{'renew_error'} = $restype; - $it->{'checkoutdate'} = C4::Dates->new($it->{'issuedate'},'iso')->output('syspref'); + $it->{'checkoutdate'} = $it->{'issuedate'}; + $it->{'duedate'} = $it->{'date_due'}; + $it->{'od'} = ( $it->{'date_due'} lt $todaysdate ) ? 1 : 0 ; $it->{'issuingbranchname'} = GetBranchName($it->{'branchcode'}); $totalprice += $it->{'replacementprice'}; $it->{'itemtype'} = $itemtypeinfo->{'description'}; $it->{'itemtype_image'} = $itemtypeinfo->{'imageurl'}; - $it->{'dd'} = output_pref($it->{'date_due'}); - $it->{'displaydate'} = output_pref($it->{'issuedate'}); - #$it->{'od'} = ( $it->{'date_due'} lt $todaysdate ) ? 1 : 0 ; - $it->{'od'} = $it->{'overdue'}; ($it->{'author'} eq '') and $it->{'author'} = ' '; $it->{'renew_failed'} = $renew_failed{$it->{'itemnumber'}}; @@ -671,8 +667,8 @@ $template->param( surname => $borrower->{'surname'}, showname => $borrower->{'showname'}, category_type => $borrower->{'category_type'}, - dateexpiry => format_date($newexpiry), - expiry => format_date($borrower->{'dateexpiry'}), + dateexpiry => $newexpiry, + expiry => $borrower->{'dateexpiry'}, categorycode => $borrower->{'categorycode'}, categoryname => $borrower->{description}, address => $address, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index f327b43716..f8a1009efa 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -226,7 +226,7 @@ function refocus(calendar) { -[% IF ( dateexpiry ) %]
Patron's account has been renewed until [% dateexpiry %]
[% END %] +[% IF ( dateexpiry ) %]
Patron's account has been renewed until [% dateexpiry | $KohaDates %]
[% END %] [% IF additional_materials %]
Note about the accompanying materials:
@@ -254,7 +254,7 @@ function refocus(calendar) { [% END %] [% IF ( RESERVED ) %] -
  • Item [% getTitleMessageIteminfo %] ([% getBarcodeMessageIteminfo %]) has been on hold for [% resfirstname %] [% ressurname %] ([% rescardnumber %]) at [% resbranchname %] since [% resreservedate %]
  • +
  • Item [% getTitleMessageIteminfo %] ([% getBarcodeMessageIteminfo %]) has been on hold for [% resfirstname %] [% ressurname %] ([% rescardnumber %]) at [% resbranchname %] since [% resreservedate | $KohaDates %]
  • [% END %] [% IF ( ISSUED_TO_ANOTHER ) %] @@ -550,7 +550,7 @@ No patron matched [% message %] [% IF ( warndeparture ) %]
  • Expiration: Patron's card will expire soon. - Patron's card expires on [% expiry %] Renew or Edit Details + Patron's card expires on [% expiry | $KohaDates %] Renew or Edit Details
  • [% END %] @@ -563,7 +563,7 @@ No patron matched [% message %] [% IF ( expired ) %]
  • Expiration: Patron's card has expired. - [% IF ( expiry ) %]Patron's card expired on [% expiry %][% END %] Renew or Edit Details + [% IF ( expiry ) %]Patron's card expired on [% expiry | $KohaDates %][% END %] Renew or Edit Details
  • [% END %] @@ -578,7 +578,7 @@ No patron matched [% message %] [% IF ( userdebarred ) %]
  • - Restricted: Patron's account is restricted [% IF (userdebarreddate ) %] until [% userdebarreddate %] [% END %] [% IF (debarredcomment ) %] with the comment "[% debarredcomment %]"[% END %] + Restricted: Patron's account is restricted [% IF (userdebarreddate ) %] until [% userdebarreddate | $KohaDates %] [% END %] [% IF (debarredcomment ) %] with the comment "[% debarredcomment %]"[% END %]
    @@ -615,7 +615,7 @@ No patron matched [% message %]

    Holds waiting:

    [% FOREACH WaitingReserveLoo IN WaitingReserveLoop %]
      -
    • [% WaitingReserveLoo.title |html %] ([% WaitingReserveLoo.itemtype %]), [% IF ( WaitingReserveLoo.author ) %]by [% WaitingReserveLoo.author %][% END %] Hold placed on [% WaitingReserveLoo.reservedate %]. +
    • [% WaitingReserveLoo.title |html %] ([% WaitingReserveLoo.itemtype %]), [% IF ( WaitingReserveLoo.author ) %]by [% WaitingReserveLoo.author %][% END %] Hold placed on [% WaitingReserveLoo.reservedate | $KohaDates %]. [% IF ( WaitingReserveLoo.waitingat ) %]
      [% IF ( WaitingReserveLoo.waitinghere ) %][% ELSE %][% END %]Waiting at [% WaitingReserveLoo.waitingat %] [% END %] @@ -720,11 +720,11 @@ No patron matched [% message %] [% END %] [% IF ( todayissue.od ) %][% ELSE %][% END %] - [% todayissue.dd %] + [% todayissue.duedate | $KohaDates %] [% todayissue.title |html %][% IF ( todayissue.author ) %], by [% todayissue.author %][% END %][% IF ( todayissue.itemnotes ) %]- [% todayissue.itemnotes %][% END %] [% todayissue.barcode %] [% UNLESS ( noItemTypeImages ) %] [% IF ( todayissue.itemtype_image ) %][% END %][% END %][% todayissue.itemtype %] - [% todayissue.checkoutdate %] + [% todayissue.checkoutdate | $KohaDates %] [% IF ( todayissue.multiple_borrowers ) %][% todayissue.firstname %] [% todayissue.surname %][% END %] [% todayissue.issuingbranchname %] [% todayissue.itemcallnumber %] @@ -793,13 +793,13 @@ No patron matched [% message %] [% END %] [% IF ( previssue.od ) %][% ELSE %][% END %] - [% previssue.dd %] + [% previssue.duedate | $KohaDates %] [% previssue.title |html %][% IF ( previssue.author ) %], by [% previssue.author %][% END %] [% IF ( previssue.itemnotes ) %]- [% previssue.itemnotes %][% END %] [% previssue.barcode %] [% previssue.itemtype %] - [% previssue.displaydate %] + [% previssue.issuedate | $KohaDates %] [% IF ( previssue.multiple_borrowers ) %][% previssue.firstname %] [% previssue.surname %][% END %] [% previssue.issuingbranchname %] [% previssue.itemcallnumber %] @@ -961,7 +961,7 @@ No patron matched [% message %] [% FOREACH reservloo IN reservloop %] - [% reservloo.reservedate %] + [% reservloo.reservedate | $KohaDates %] [% reservloo.title |html %][% IF ( reservloo.author ) %], by [% reservloo.author %][% END %] [% reservloo.itemcallnumber %] [% IF ( reservloo.barcodereserv ) %]Item [% reservloo.barcodereserv %] -- 2.39.5