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

(-)a/C4/Members.pm (-40 / +56 lines)
Lines 950-1005 sub IssueSlip { Link Here
950
    my $patron = Koha::Patrons->find( $borrowernumber );
950
    my $patron = Koha::Patrons->find( $borrowernumber );
951
    return unless $patron;
951
    return unless $patron;
952
952
953
    my @issues = @{ GetPendingIssues($borrowernumber) };
953
    my $pending_checkouts = $patron->pending_checkouts; # Should be $patron->checkouts->pending?
954
955
    for my $issue (@issues) {
956
        $issue->{date_due} = $issue->{date_due_sql};
957
        if ($quickslip) {
958
            my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
959
            if ( substr( $issue->{issuedate}, 0, 10 ) eq $today
960
                or substr( $issue->{lastreneweddate}, 0, 10 ) eq $today ) {
961
                  $issue->{now} = 1;
962
            };
963
        }
964
    }
965
966
    # Sort on timestamp then on issuedate then on issue_id
967
    # useful for tests and could be if modified in a batch
968
    @issues = sort {
969
            $b->{timestamp} <=> $a->{timestamp}
970
         or $b->{issuedate} <=> $a->{issuedate}
971
         or $b->{issue_id}  <=> $a->{issue_id}
972
    } @issues;
973
954
974
    my ($letter_code, %repeat, %loops);
955
    my ($letter_code, %repeat, %loops);
975
    if ( $quickslip ) {
956
    if ( $quickslip ) {
957
        my $today_start = dt_from_string->set( hour => 0, minute => 0, second => 0 );
958
        my $today_end = dt_from_string->set( hour => 23, minute => 59, second => 0 );
959
        $today_start = Koha::Database->new->schema->storage->datetime_parser->format_datetime( $today_start );
960
        $today_end = Koha::Database->new->schema->storage->datetime_parser->format_datetime( $today_end );
976
        $letter_code = 'ISSUEQSLIP';
961
        $letter_code = 'ISSUEQSLIP';
977
        my @checkouts = map {
962
978
                'biblio'       => $_,
963
        # issue date or lastreneweddate is today
979
                'items'        => $_,
964
        my $todays_checkouts = $pending_checkouts->search(
980
                'biblioitems'  => $_,
965
            {
981
                'issues'       => $_,
966
                -or => {
982
            }, grep { $_->{'now'} } @issues;
967
                    issuedate => {
968
                        '>=' => $today_start,
969
                        '<=' => $today_end,
970
                    },
971
                    lastreneweddate =>
972
                      { '>=' => $today_start, '<=' => $today_end, }
973
                }
974
            }
975
        );
976
        my @checkouts;
977
        while ( my $c = $todays_checkouts->next ) {
978
            my $all = $c->unblessed_all_relateds;
979
            push @checkouts, {
980
                biblio      => $all,
981
                items       => $all,
982
                biblioitems => $all,
983
                issues      => $all,
984
            };
985
        }
986
983
        %repeat =  (
987
        %repeat =  (
984
            checkedout => \@checkouts, # History syntax
988
            checkedout => \@checkouts, # Historical syntax
985
        );
989
        );
986
        %loops = (
990
        %loops = (
987
            issues => [ map { $_->{issues}{itemnumber} } @checkouts ], # TT syntax
991
            issues => [ map { $_->{issues}{itemnumber} } @checkouts ], # TT syntax
988
        );
992
        );
989
    }
993
    }
990
    else {
994
    else {
991
        my @checkouts = map {
995
        my $today = Koha::Database->new->schema->storage->datetime_parser->format_datetime( dt_from_string );
992
            'biblio'        => $_,
996
        # Checkouts due in the future
993
              'items'       => $_,
997
        my $checkouts = $pending_checkouts->search({ date_due => { '>' => $today } });
994
              'biblioitems' => $_,
998
        my @checkouts; my @overdues;
995
              'issues'      => $_,
999
        while ( my $c = $checkouts->next ) {
996
        }, grep { !$_->{'overdue'} } @issues;
1000
            my $all = $c->unblessed_all_relateds;
997
        my @overdues = map {
1001
            push @checkouts, {
998
            'biblio'        => $_,
1002
                biblio      => $all,
999
              'items'       => $_,
1003
                items       => $all,
1000
              'biblioitems' => $_,
1004
                biblioitems => $all,
1001
              'issues'      => $_,
1005
                issues      => $all,
1002
        }, grep { $_->{'overdue'} } @issues;
1006
            };
1007
        }
1008
1009
        # Checkouts due in the past are overdues
1010
        my $overdues = $pending_checkouts->search({ date_due => { '<=' => $today } });
1011
        while ( my $o = $overdues->next ) {
1012
            my $all = $o->unblessed_all_relateds;
1013
            push @overdues, {
1014
                biblio      => $all,
1015
                items       => $all,
1016
                biblioitems => $all,
1017
                issues      => $all,
1018
            };
1019
        }
1003
        my $news = GetNewsToDisplay( "slip", $branch );
1020
        my $news = GetNewsToDisplay( "slip", $branch );
1004
        my @news = map {
1021
        my @news = map {
1005
            $_->{'timestamp'} = $_->{'newdate'};
1022
            $_->{'timestamp'} = $_->{'newdate'};
1006
- 

Return to bug 19935