From 186cfa5cb00a1c0ee7f0e4512a5f319299bb6412 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 --- 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 c4001d0cef..4511c84db7 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 ); } } @@ -351,7 +349,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'}; @@ -371,7 +369,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; } @@ -379,7 +377,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; @@ -450,16 +448,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'}}; @@ -673,8 +669,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 64ca686727..11ee5f952b 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:
@@ -258,7 +258,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 ) %] @@ -554,7 +554,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 %] @@ -567,7 +567,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 %] @@ -582,7 +582,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 %]
    @@ -619,7 +619,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 %] @@ -724,11 +724,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 %] @@ -797,13 +797,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 %] @@ -965,7 +965,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