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

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

Return to bug 19935