View | Details | Raw Unified | Return to bug 14903
Collapse All | Expand All

(-)a/C4/Circulation.pm (-13 / +10 lines)
Lines 22-35 package C4::Circulation; Link Here
22
use strict;
22
use strict;
23
#use warnings; FIXME - Bug 2505
23
#use warnings; FIXME - Bug 2505
24
use DateTime;
24
use DateTime;
25
use Koha::DateUtils;
25
use C4::Context;
26
use C4::Context;
26
use C4::Stats;
27
use C4::Stats;
27
use C4::Reserves;
28
use C4::Reserves;
28
use C4::Biblio;
29
use C4::Biblio;
29
use C4::Items;
30
use C4::Items;
30
use C4::Members;
31
use C4::Members;
31
use C4::Dates;
32
use C4::Dates qw(format_date);
33
use C4::Accounts;
32
use C4::Accounts;
34
use C4::ItemCirculationAlertPreference;
33
use C4::ItemCirculationAlertPreference;
35
use C4::Message;
34
use C4::Message;
Lines 657-663 sub itemissues { Link Here
657
=head2 CanBookBeIssued
656
=head2 CanBookBeIssued
658
657
659
  ( $issuingimpossible, $needsconfirmation ) =  CanBookBeIssued( $borrower, 
658
  ( $issuingimpossible, $needsconfirmation ) =  CanBookBeIssued( $borrower, 
660
                      $barcode, $duedatespec, $inprocess, $ignore_reserves );
659
                      $barcode, $duedate, $inprocess, $ignore_reserves );
661
660
662
Check if a book can be issued.
661
Check if a book can be issued.
663
662
Lines 669-675 C<$issuingimpossible> and C<$needsconfirmation> are some hashref. Link Here
669
668
670
=item C<$barcode> is the bar code of the book being issued.
669
=item C<$barcode> is the bar code of the book being issued.
671
670
672
=item C<$duedatespec> is a C4::Dates object.
671
=item C<$duedates> is a DateTime object.
673
672
674
=item C<$inprocess> boolean switch
673
=item C<$inprocess> boolean switch
675
=item C<$ignore_reserves> boolean switch
674
=item C<$ignore_reserves> boolean switch
Lines 1035-1041 sub CanBookBeIssued { Link Here
1035
                    $needsconfirmation{'rescardnumber'} = $resborrower->{'cardnumber'};
1034
                    $needsconfirmation{'rescardnumber'} = $resborrower->{'cardnumber'};
1036
                    $needsconfirmation{'resborrowernumber'} = $resborrower->{'borrowernumber'};
1035
                    $needsconfirmation{'resborrowernumber'} = $resborrower->{'borrowernumber'};
1037
                    $needsconfirmation{'resbranchname'} = $branchname;
1036
                    $needsconfirmation{'resbranchname'} = $branchname;
1038
                    $needsconfirmation{'reswaitingdate'} = format_date($res->{'waitingdate'});
1037
                    $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
1039
                }
1038
                }
1040
                elsif ( $restype eq "Reserved" ) {
1039
                elsif ( $restype eq "Reserved" ) {
1041
                    # The item is on reserve for someone else.
1040
                    # The item is on reserve for someone else.
Lines 1045-1051 sub CanBookBeIssued { Link Here
1045
                    $needsconfirmation{'rescardnumber'} = $resborrower->{'cardnumber'};
1044
                    $needsconfirmation{'rescardnumber'} = $resborrower->{'cardnumber'};
1046
                    $needsconfirmation{'resborrowernumber'} = $resborrower->{'borrowernumber'};
1045
                    $needsconfirmation{'resborrowernumber'} = $resborrower->{'borrowernumber'};
1047
                    $needsconfirmation{'resbranchname'} = $branchname;
1046
                    $needsconfirmation{'resbranchname'} = $branchname;
1048
                    $needsconfirmation{'resreservedate'} = format_date($res->{'reservedate'});
1047
                    $needsconfirmation{'resreservedate'} = $res->{'reservedate'};
1049
                }
1048
                }
1050
            }
1049
            }
1051
        }
1050
        }
Lines 1212-1224 Issue a book. Does no check, they are done in CanBookBeIssued. If we reach this Link Here
1212
1211
1213
=item C<$barcode> is the barcode of the item being issued.
1212
=item C<$barcode> is the barcode of the item being issued.
1214
1213
1215
=item C<$datedue> is a C4::Dates object for the max date of return, i.e. the date due (optional).
1214
=item C<$datedue> is a DateTime object for the max date of return, i.e. the date due (optional).
1216
Calculated if empty.
1215
Calculated if empty.
1217
1216
1218
=item C<$cancelreserve> is 1 to override and cancel any pending reserves for the item (optional).
1217
=item C<$cancelreserve> is 1 to override and cancel any pending reserves for the item (optional).
1219
1218
1220
=item C<$issuedate> is the date to issue the item in iso (YYYY-MM-DD) format (optional).
1219
=item C<$issuedate> is the date to issue the item in iso (YYYY-MM-DD) format (optional).
1221
Defaults to today.  Unlike C<$datedue>, NOT a C4::Dates object, unfortunately.
1220
Defaults to today.  Unlike C<$datedue>, NOT a DateTime object, unfortunately.
1222
1221
1223
AddIssue does the following things :
1222
AddIssue does the following things :
1224
1223
Lines 1905-1911 sub AddReturn { Link Here
1905
            # define circControlBranch only if dropbox mode is set
1904
            # define circControlBranch only if dropbox mode is set
1906
            # don't allow dropbox mode to create an invalid entry in issues (issuedate > today)
1905
            # don't allow dropbox mode to create an invalid entry in issues (issuedate > today)
1907
            # FIXME: check issuedate > returndate, factoring in holidays
1906
            # FIXME: check issuedate > returndate, factoring in holidays
1908
            #$circControlBranch = _GetCircControlBranch($item,$borrower) unless ( $item->{'issuedate'} eq C4::Dates->today('iso') );;
1907
1909
            $circControlBranch = _GetCircControlBranch($item,$borrower);
1908
            $circControlBranch = _GetCircControlBranch($item,$borrower);
1910
            $issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $dropboxdate ) == -1 ? 1 : 0;
1909
            $issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $dropboxdate ) == -1 ? 1 : 0;
1911
        }
1910
        }
Lines 2851-2857 C<$itemnumber> is the number of the item to renew. Link Here
2851
C<$branch> is the library where the renewal took place (if any).
2850
C<$branch> is the library where the renewal took place (if any).
2852
           The library that controls the circ policies for the renewal is retrieved from the issues record.
2851
           The library that controls the circ policies for the renewal is retrieved from the issues record.
2853
2852
2854
C<$datedue> can be a C4::Dates object used to set the due date.
2853
C<$datedue> can be a DateTime object used to set the due date.
2855
2854
2856
C<$lastreneweddate> is an optional ISO-formatted date used to set issues.lastreneweddate.  If
2855
C<$lastreneweddate> is an optional ISO-formatted date used to set issues.lastreneweddate.  If
2857
this parameter is not supplied, lastreneweddate is set to the current date.
2856
this parameter is not supplied, lastreneweddate is set to the current date.
Lines 3435-3441 $newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower); Link Here
3435
3434
3436
this function calculates the due date given the start date and configured circulation rules,
3435
this function calculates the due date given the start date and configured circulation rules,
3437
checking against the holidays calendar as per the 'useDaysMode' syspref.
3436
checking against the holidays calendar as per the 'useDaysMode' syspref.
3438
C<$startdate>   = C4::Dates object representing start date of loan period (assumed to be today)
3437
C<$startdate>   = DateTime object representing start date of loan period (assumed to be today)
3439
C<$itemtype>  = itemtype code of item in question
3438
C<$itemtype>  = itemtype code of item in question
3440
C<$branch>  = location whose calendar to use
3439
C<$branch>  = location whose calendar to use
3441
C<$borrower> = Borrower object
3440
C<$borrower> = Borrower object
Lines 3877-3884 sub TransferSlip { Link Here
3877
    my $item =  GetItem( $itemnumber, $barcode )
3876
    my $item =  GetItem( $itemnumber, $barcode )
3878
      or return;
3877
      or return;
3879
3878
3880
    my $pulldate = C4::Dates->new();
3881
3882
    return C4::Letters::GetPreparedLetter (
3879
    return C4::Letters::GetPreparedLetter (
3883
        module => 'circulation',
3880
        module => 'circulation',
3884
        letter_code => 'TRANSFERSLIP',
3881
        letter_code => 'TRANSFERSLIP',
(-)a/circ/circulation.pl (-14 / +12 lines)
Lines 30-36 use DateTime::Duration; Link Here
30
use C4::Output;
30
use C4::Output;
31
use C4::Print;
31
use C4::Print;
32
use C4::Auth qw/:DEFAULT get_session haspermission/;
32
use C4::Auth qw/:DEFAULT get_session haspermission/;
33
use C4::Dates qw/format_date/;
34
use C4::Branch; # GetBranches
33
use C4::Branch; # GetBranches
35
use C4::Koha;   # GetPrinter
34
use C4::Koha;   # GetPrinter
36
use C4::Circulation;
35
use C4::Circulation;
Lines 175-180 for my $barcode ( @$barcodes ) { Link Here
175
174
176
my $stickyduedate  = $query->param('stickyduedate') || $session->param('stickyduedate');
175
my $stickyduedate  = $query->param('stickyduedate') || $session->param('stickyduedate');
177
my $duedatespec    = $query->param('duedatespec')   || $session->param('stickyduedate');
176
my $duedatespec    = $query->param('duedatespec')   || $session->param('stickyduedate');
177
$duedatespec = eval { output_pref( { dt => dt_from_string( $duedatespec ), dateformat => 'iso' }); };
178
178
my $issueconfirmed = $query->param('issueconfirmed');
179
my $issueconfirmed = $query->param('issueconfirmed');
179
my $cancelreserve  = $query->param('cancelreserve');
180
my $cancelreserve  = $query->param('cancelreserve');
180
my $print          = $query->param('print') || q{};
181
my $print          = $query->param('print') || q{};
Lines 202-219 if( $onsite_checkout && !$duedatespec_allow ) { Link Here
202
    $datedue = output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
203
    $datedue = output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
203
    $datedue .= ' 23:59:00';
204
    $datedue .= ' 23:59:00';
204
} elsif( $duedatespec_allow ) {
205
} elsif( $duedatespec_allow ) {
205
    if ($duedatespec) {
206
    if ($datedue) {
206
        if ($duedatespec =~ C4::Dates->regexp('syspref')) {
207
        $datedue = eval { dt_from_string( $datedue ) };
207
                $datedue = dt_from_string($duedatespec);
208
        if (! $datedue ) {
208
        } else {
209
            $invalidduedate = 1;
209
            $invalidduedate = 1;
210
            $template->param(IMPOSSIBLE=>1, INVALID_DATE=>$duedatespec);
210
            $template->param( IMPOSSIBLE=>1, INVALID_DATE=>$datedue );
211
        }
211
        }
212
    }
212
    }
213
}
213
}
214
214
215
our $todaysdate = C4::Dates->new->output('iso');
216
217
# check and see if we should print
215
# check and see if we should print
218
if ( @$barcodes == 0 && $print eq 'maybe' ) {
216
if ( @$barcodes == 0 && $print eq 'maybe' ) {
219
    $print = 'yes';
217
    $print = 'yes';
Lines 295-301 if ($borrowernumber) { Link Here
295
            noissues => ($force_allow_issue) ? 0 : "1",
293
            noissues => ($force_allow_issue) ? 0 : "1",
296
            forceallow => $force_allow_issue,
294
            forceallow => $force_allow_issue,
297
            expired => "1",
295
            expired => "1",
298
            renewaldate => format_date("$renew_year-$renew_month-$renew_day")
296
            renewaldate => "$renew_year-$renew_month-$renew_day",
299
        );
297
        );
300
    }
298
    }
301
    # check for NotifyBorrowerDeparture
299
    # check for NotifyBorrowerDeparture
Lines 304-311 if ($borrowernumber) { Link Here
304
            Date_to_Days( $today_year, $today_month, $today_day ) ) 
302
            Date_to_Days( $today_year, $today_month, $today_day ) ) 
305
    {
303
    {
306
        # borrower card soon to expire warn librarian
304
        # borrower card soon to expire warn librarian
307
        $template->param("warndeparture" => format_date($borrower->{dateexpiry}),
305
        $template->param( "warndeparture" => $borrower->{dateexpiry} ,
308
        flagged       => "1",);
306
                          flagged         => "1"
307
                        );
309
        if (C4::Context->preference('ReturnBeforeExpiry')){
308
        if (C4::Context->preference('ReturnBeforeExpiry')){
310
            $template->param("returnbeforeexpiry" => 1);
309
            $template->param("returnbeforeexpiry" => 1);
311
        }
310
        }
Lines 323-330 if ($borrowernumber) { Link Here
323
        );
322
        );
324
323
325
        if ( $borrower->{debarred} ne "9999-12-31" ) {
324
        if ( $borrower->{debarred} ne "9999-12-31" ) {
326
            $template->param( 'userdebarreddate' =>
325
            $template->param( 'userdebarreddate' => $borrower->{debarred} );
327
                  C4::Dates::format_date( $borrower->{debarred} ) );
328
        }
326
        }
329
    }
327
    }
330
328
Lines 590-596 $template->param( Link Here
590
    printer           => $printer,
588
    printer           => $printer,
591
    printername       => $printer,
589
    printername       => $printer,
592
    was_renewed       => $query->param('was_renewed') ? 1 : 0,
590
    was_renewed       => $query->param('was_renewed') ? 1 : 0,
593
    expiry            => format_date($borrower->{'dateexpiry'}),
591
    expiry            => $borrower->{'dateexpiry'},
594
    roadtype          => $roadtype,
592
    roadtype          => $roadtype,
595
    amountold         => $amountold,
593
    amountold         => $amountold,
596
    barcodes          => $barcodes,
594
    barcodes          => $barcodes,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-7 / +6 lines)
Lines 190-196 $(document).ready(function() { Link Here
190
</form>
190
</form>
191
</div>
191
</div>
192
192
193
[% IF ( was_renewed ) %]<div class="dialog message">Patron's account has been renewed until [% expiry %]</div>[% END %]
193
[% IF ( was_renewed ) %]<div class="dialog message">Patron's account has been renewed until [% expiry | $KohaDates %]</div>[% END %]
194
194
195
[% IF additional_materials %]
195
[% IF additional_materials %]
196
    <div id="materials" class="dialog message">Note about the accompanying materials: <br />
196
    <div id="materials" class="dialog message">Note about the accompanying materials: <br />
Lines 237-247 $(document).ready(function() { Link Here
237
[% END %]
237
[% END %]
238
238
239
[% IF ( RESERVE_WAITING ) %]
239
[% IF ( RESERVE_WAITING ) %]
240
    <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>
240
    <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>
241
[% END %]
241
[% END %]
242
242
243
[% IF ( RESERVED ) %]
243
[% IF ( RESERVED ) %]
244
    <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>
244
    <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>
245
[% END %]
245
[% END %]
246
246
247
[% IF ( ISSUED_TO_ANOTHER ) %]
247
[% IF ( ISSUED_TO_ANOTHER ) %]
Lines 724-730 No patron matched <span class="ex">[% message %]</span> Link Here
724
724
725
			[% IF ( warndeparture ) %]
725
			[% IF ( warndeparture ) %]
726
			<li><span class="circ-hlt">Expiration:</span> Patron's card will expire soon.
726
			<li><span class="circ-hlt">Expiration:</span> Patron's card will expire soon.
727
            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>
727
            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>
728
728
729
			</li>
729
			</li>
730
			[% END %]
730
			[% END %]
Lines 737-743 No patron matched <span class="ex">[% message %]</span> Link Here
737
737
738
			[% IF ( expired ) %]
738
			[% IF ( expired ) %]
739
			<li><span class="circ-hlt">Expiration:</span> Patron's card has expired.
739
			<li><span class="circ-hlt">Expiration:</span> Patron's card has expired.
740
            [% 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>
740
            [% 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>
741
741
742
			</li>
742
			</li>
743
			[% END %]
743
			[% END %]
Lines 755-761 No patron matched <span class="ex">[% message %]</span> Link Here
755
                   <span class="circ-hlt"> Restricted:</span> Patron's account is restricted
755
                   <span class="circ-hlt"> Restricted:</span> Patron's account is restricted
756
756
757
                   [% IF ( userdebarreddate ) %]
757
                   [% IF ( userdebarreddate ) %]
758
                       until [% userdebarreddate %]
758
                       until [% userdebarreddate | $KohaDates %]
759
                   [% END %]
759
                   [% END %]
760
760
761
                   [% IF ( debarredcomment ) %]
761
                   [% IF ( debarredcomment ) %]
762
- 

Return to bug 14903