[Koha-patches] [PATCH] Bug 7444: Update circ/circulation.pl to use KohaDates TT Plugin
Martin Renvoize
martin.renvoize at ptfs-europe.com
Sun Jun 10 16:08:22 CEST 2012
From: Ian Walls <koha.sekjal at gmail.com>
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 <martin.renvoize at ptfs-europe.com>
---
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 c4001d0..4511c84 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 64ca686..1deccb4 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) {
</form>
</div>
-[% IF ( dateexpiry ) %]<div class="dialog message">Patron's account has been renewed until [% dateexpiry %]</div>[% END %]
+[% IF ( dateexpiry ) %]<div class="dialog message">Patron's account has been renewed until [% dateexpiry | $KohaDates %]</div>[% END %]
[% IF additional_materials %]
<div id="materials" class="dialog message">Note about the accompanying materials: <br />
@@ -258,7 +258,7 @@ function refocus(calendar) {
[% 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 ) %]
@@ -554,7 +554,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 %]&cardnumber=[% cardnumber %]&destination=circ&reregistration=y">Renew</a> or <a href="/cgi-bin/koha/members/memberentry.pl?op=modify&destination=circ&borrowernumber=[% borrowernumber %]&categorycode=[% categorycode %]">Edit Details</a>
+ Patron's card expires on [% expiry | $KohaDates %] <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% borrowernumber %]&cardnumber=[% cardnumber %]&destination=circ&reregistration=y">Renew</a> or <a href="/cgi-bin/koha/members/memberentry.pl?op=modify&destination=circ&borrowernumber=[% borrowernumber %]&categorycode=[% categorycode %]">Edit Details</a>
</li>
[% END %]
@@ -567,7 +567,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 %]&cardnumber=[% cardnumber %]&destination=circ&reregistration=y">Renew</a> or <a href="/cgi-bin/koha/members/memberentry.pl?op=modify&destination=circ&borrowernumber=[% borrowernumber %]&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 %]&cardnumber=[% cardnumber %]&destination=circ&reregistration=y">Renew</a> or <a href="/cgi-bin/koha/members/memberentry.pl?op=modify&destination=circ&borrowernumber=[% borrowernumber %]&categorycode=[% categorycode %]">Edit Details</a>
</li>
[% END %]
@@ -582,7 +582,7 @@ No patron matched <span class="ex">[% message %]</span>
[% IF ( userdebarred ) %]
<li class="blocker">
- <span class="circ-hlt"> Restricted:</span> Patron's account is restricted [% IF (userdebarreddate ) %] until [% userdebarreddate %] [% END %] [% IF (debarredcomment ) %] with the comment "[% debarredcomment %]"[% END %]
+ <span class="circ-hlt"> Restricted:</span> Patron's account is restricted [% IF (userdebarreddate ) %] until [% userdebarreddate | $KohaDates %] [% END %] [% IF (debarredcomment ) %] with the comment "[% debarredcomment %]"[% END %]
<form class="inline compact" action="/cgi-bin/koha/members/setstatus.pl" method="post">
<input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
<input type="hidden" name="destination" value="circ" />
@@ -619,7 +619,7 @@ No patron matched <span class="ex">[% message %]</span>
<h4>Holds waiting:</h4>
[% FOREACH WaitingReserveLoo IN WaitingReserveLoop %]
<ul>
- <li> <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% WaitingReserveLoo.biblionumber %]">[% WaitingReserveLoo.title |html %]</a> ([% WaitingReserveLoo.itemtype %]), [% IF ( WaitingReserveLoo.author ) %]by [% WaitingReserveLoo.author %][% END %] Hold placed on [% WaitingReserveLoo.reservedate %].
+ <li> <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% WaitingReserveLoo.biblionumber %]">[% WaitingReserveLoo.title |html %]</a> ([% WaitingReserveLoo.itemtype %]), [% IF ( WaitingReserveLoo.author ) %]by [% WaitingReserveLoo.author %][% END %] Hold placed on [% WaitingReserveLoo.reservedate | $KohaDates %].
[% IF ( WaitingReserveLoo.waitingat ) %]
<br />[% IF ( WaitingReserveLoo.waitinghere ) %]<strong class="waitinghere">[% ELSE %]<strong>[% END %]Waiting at [% WaitingReserveLoo.waitingat %]</strong>
[% END %]
@@ -724,11 +724,11 @@ No patron matched <span class="ex">[% message %]</span>
<tr class="highlight">
[% END %]
[% IF ( todayissue.od ) %]<td class="od">[% ELSE %]<td>[% END %]
- [% todayissue.dd %]
+ [% todayissue.duedate | $KohaDates %]
</td>
<td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% todayissue.biblionumber %]&type=intra"><strong>[% todayissue.title |html %]</strong></a>[% IF ( todayissue.author ) %], by [% todayissue.author %][% END %][% IF ( todayissue.itemnotes ) %]- <span class="circ-hlt">[% todayissue.itemnotes %]</span>[% END %] <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% todayissue.biblionumber %]&itemnumber=[% todayissue.itemnumber %]#item[% todayissue.itemnumber %]">[% todayissue.barcode %]</a></td>
<td>[% UNLESS ( noItemTypeImages ) %] [% IF ( todayissue.itemtype_image ) %]<img src="[% todayissue.itemtype_image %]" alt="" />[% END %][% END %][% todayissue.itemtype %]</td>
- <td>[% todayissue.checkoutdate %]</td>
+ <td>[% todayissue.checkoutdate | $KohaDates %]</td>
[% IF ( todayissue.multiple_borrowers ) %]<td>[% todayissue.firstname %] [% todayissue.surname %]</td>[% END %]
<td>[% todayissue.issuingbranchname %]</td>
<td>[% todayissue.itemcallnumber %]</td>
@@ -797,13 +797,13 @@ No patron matched <span class="ex">[% message %]</span>
<tr class="highlight">
[% END %]
[% IF ( previssue.od ) %]<td class="od">[% ELSE %]<td>[% END %]
- [% previssue.dd %]
+ [% previssue.duedate | $KohaDates %]
</td>
<td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% previssue.biblionumber %]&type=intra"><strong>[% previssue.title |html %]</strong></a>[% IF ( previssue.author ) %], by [% previssue.author %][% END %] [% IF ( previssue.itemnotes ) %]- [% previssue.itemnotes %][% END %] <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% previssue.biblionumber %]&itemnumber=[% previssue.itemnumber %]#item[% previssue.itemnumber %]">[% previssue.barcode %]</a></td>
<td>
[% previssue.itemtype %]
</td>
- <td>[% previssue.displaydate %]</td>
+ <td>[% previssue.issuedate | $KohaDates %]</td>
[% IF ( previssue.multiple_borrowers ) %]<td>[% previssue.firstname %] [% previssue.surname %]</td>[% END %]
<td>[% previssue.issuingbranchname %]</td>
<td>[% previssue.itemcallnumber %]</td>
@@ -965,7 +965,7 @@ No patron matched <span class="ex">[% message %]</span>
<tbody>
[% FOREACH reservloo IN reservloop %]
<tr class="[% reservloo.color %]">
- <td>[% reservloo.reservedate %]</td>
+ <td>[% reservloo.reservedate | $KohaDates %]</td>
<td><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% reservloo.biblionumber %]"><strong>[% reservloo.title |html %]</strong></a>[% IF ( reservloo.author ) %], by [% reservloo.author %][% END %]</td>
<td>[% reservloo.itemcallnumber %]</td>
<td><em>[% IF ( reservloo.barcodereserv ) %]Item [% reservloo.barcodereserv %]
--
1.7.2.5
More information about the Koha-patches
mailing list