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

(-)a/C4/Circulation.pm (-1 / +2 lines)
Lines 1527-1533 sub AddIssue { Link Here
1527
                my $userenv = C4::Context->userenv();
1527
                my $userenv = C4::Context->userenv();
1528
                my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : undef;
1528
                my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : undef;
1529
                if ($usernumber) {
1529
                if ($usernumber) {
1530
                    $issue_attributes->{issuer} = $usernumber;
1530
                    $issue_attributes->{issuer_id} = $usernumber;
1531
                }
1531
                }
1532
            }
1532
            }
1533
1533
Lines 1545-1550 sub AddIssue { Link Here
1545
                    }
1545
                    }
1546
                )->store;
1546
                )->store;
1547
            }
1547
            }
1548
            $issue->discard_changes;
1548
            if ( $item_object->location && $item_object->location eq 'CART'
1549
            if ( $item_object->location && $item_object->location eq 'CART'
1549
                && ( !$item_object->permanent_location || $item_object->permanent_location ne 'CART' ) ) {
1550
                && ( !$item_object->permanent_location || $item_object->permanent_location ne 'CART' ) ) {
1550
            ## Item was moved to cart via UpdateItemLocationOnCheckin, anything issued should be taken off the cart.
1551
            ## Item was moved to cart via UpdateItemLocationOnCheckin, anything issued should be taken off the cart.
(-)a/Koha/Checkout.pm (-6 / +6 lines)
Lines 106-123 sub patron { Link Here
106
    return Koha::Patron->_new_from_dbic( $patron_rs );
106
    return Koha::Patron->_new_from_dbic( $patron_rs );
107
}
107
}
108
108
109
=head3 issued_by
109
=head3 issuer
110
110
111
my $issued_by = $checkout->issued_by
111
my $issuer = $checkout->issuer
112
112
113
Return the patron by whom the checkout was done
113
Return the patron by whom the checkout was done
114
114
115
=cut
115
=cut
116
116
117
sub issued_by {
117
sub issuer {
118
    my ( $self ) = @_;
118
    my ( $self ) = @_;
119
    my $issued_by_rs = $self->_result->issuer;
119
    my $issuer_rs = $self->_result->issuer;
120
    return Koha::Patron->_new_from_dbic( $issued_by_rs );
120
    return unless $issuer_rs;
121
    return Koha::Patron->_new_from_dbic( $issuer_rs );
121
}
122
}
122
123
123
=head3 to_api_mapping
124
=head3 to_api_mapping
Lines 131-137 sub to_api_mapping { Link Here
131
    return {
132
    return {
132
        issue_id        => 'checkout_id',
133
        issue_id        => 'checkout_id',
133
        borrowernumber  => 'patron_id',
134
        borrowernumber  => 'patron_id',
134
        issuer          => 'issuer_id',
135
        itemnumber      => 'item_id',
135
        itemnumber      => 'item_id',
136
        date_due        => 'due_date',
136
        date_due        => 'due_date',
137
        branchcode      => 'library_id',
137
        branchcode      => 'library_id',
(-)a/Koha/Old/Checkout.pm (+15 lines)
Lines 74-79 sub patron { Link Here
74
    return Koha::Patron->_new_from_dbic( $patron_rs );
74
    return Koha::Patron->_new_from_dbic( $patron_rs );
75
}
75
}
76
76
77
=head3 issuer
78
79
my $issuer = $checkout->issuer
80
81
Return the patron by whom the checkout was done
82
83
=cut
84
85
sub issuer {
86
    my ( $self ) = @_;
87
    my $issuer_rs = $self->_result->issuer;
88
    return unless $issuer_rs;
89
    return Koha::Patron->_new_from_dbic( $issuer_rs );
90
}
91
77
=head3 to_api_mapping
92
=head3 to_api_mapping
78
93
79
This method returns the mapping for representing a Koha::Old::Checkout object
94
This method returns the mapping for representing a Koha::Old::Checkout object
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt (-3 / +3 lines)
Lines 67-75 Link Here
67
                         
67
                         
68
                    [% END %]</td>
68
                    [% END %]</td>
69
                [% IF Koha.Preference('RecordStaffUserOnCheckout') %]
69
                [% IF Koha.Preference('RecordStaffUserOnCheckout') %]
70
                <td>[% IF checkout.issuer %]
70
                <td>[% IF checkout.issuer_id %]
71
                    <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% checkout.issuer | uri %]">
71
                    <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% checkout.issuer_id | uri %]">
72
                    [% INCLUDE 'patron-title.inc' patron=checkout.issued_by %]
72
                    [% INCLUDE 'patron-title.inc' patron=checkout.issuer_id %]
73
                    </a>
73
                    </a>
74
                    [% END %]</td>
74
                    [% END %]</td>
75
                [% END %]
75
                [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt (-1 / +1 lines)
Lines 98-104 Link Here
98
          </td>
98
          </td>
99
          <td>[% Branches.GetName( issue.branchcode ) | html %]</td>
99
          <td>[% Branches.GetName( issue.branchcode ) | html %]</td>
100
          [% IF Koha.Preference('RecordStaffUserOnCheckout') %]
100
          [% IF Koha.Preference('RecordStaffUserOnCheckout') %]
101
          <td><a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% issue.issuer | uri %]">[% issue.firstname | html %] [% issue.surname | html %]</a></td>
101
          <td><a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% issue.issuer_id | uri %]">[% issue.firstname | html %] [% issue.surname | html %]</a></td>
102
          [% END %]
102
          [% END %]
103
          <td>
103
          <td>
104
            [% IF issue.date_due %]
104
            [% IF issue.date_due %]
(-)a/t/db_dependent/Circulation.t (-8 / +6 lines)
Lines 4610-4629 subtest 'AddIssue records staff who checked out item if appropriate' => sub { Link Here
4610
4610
4611
    $module->mock( 'userenv', sub { { branch => $library->{id} } } );
4611
    $module->mock( 'userenv', sub { { branch => $library->{id} } } );
4612
4612
4613
    my $library =
4613
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
4614
      $builder->build_object( { class => 'Koha::Libraries' } )->store;
4615
    my $patron = $builder->build_object(
4614
    my $patron = $builder->build_object(
4616
        {
4615
        {
4617
            class => 'Koha::Patrons',
4616
            class => 'Koha::Patrons',
4618
            value => { categorycode => $patron_category->{categorycode} }
4617
            value => { categorycode => $patron_category->{categorycode} }
4619
        }
4618
        }
4620
    )->store;
4619
    );
4621
    my $issuer = $builder->build_object(
4620
    my $issuer = $builder->build_object(
4622
        {
4621
        {
4623
            class => 'Koha::Patrons',
4622
            class => 'Koha::Patrons',
4624
            value => { categorycode => $patron_category->{categorycode} }
4623
            value => { categorycode => $patron_category->{categorycode} }
4625
        }
4624
        }
4626
    )->store;
4625
    );
4627
    my $item = $builder->build_sample_item(
4626
    my $item = $builder->build_sample_item(
4628
        {
4627
        {
4629
            library  => $library->{branchcode}
4628
            library  => $library->{branchcode}
Lines 4632-4642 subtest 'AddIssue records staff who checked out item if appropriate' => sub { Link Here
4632
4631
4633
    $module->mock( 'userenv', sub { { branch => $library->id, number => $issuer->{borrowernumber} } } );
4632
    $module->mock( 'userenv', sub { { branch => $library->id, number => $issuer->{borrowernumber} } } );
4634
4633
4635
    my $dt_from     = dt_from_string();
4634
    my $dt_from = dt_from_string();
4636
    my $dt_to       = dt_from_string()->add( days => 7 );
4635
    my $dt_to   = dt_from_string()->add( days => 7 );
4637
4636
4638
    my $issue =
4637
    my $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4639
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4640
4638
4641
    is( $issue->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" );
4639
    is( $issue->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" );
4642
4640
(-)a/t/db_dependent/Koha/Checkouts.t (-7 / +6 lines)
Lines 133-156 subtest 'issuer' => sub { Link Here
133
    my $item = $builder->build_sample_item;
133
    my $item = $builder->build_sample_item;
134
    my $checkout = Koha::Checkout->new({
134
    my $checkout = Koha::Checkout->new({
135
        borrowernumber => $patron->borrowernumber,
135
        borrowernumber => $patron->borrowernumber,
136
        issuer         => $issuer->borrowernumber,
136
        issuer_id      => $issuer->borrowernumber,
137
        itemnumber     => $item->itemnumber,
137
        itemnumber     => $item->itemnumber,
138
        branchcode     => $library->{branchcode},
138
        branchcode     => $library->{branchcode},
139
    })->store;
139
    })->store;
140
140
141
    my $i = $checkout->issued_by;
141
    my $i = $checkout->issuer;
142
    is( ref($i), 'Koha::Patron',
142
    is( ref($i), 'Koha::Patron',
143
        'Koha::Checkout->issued_by should return a Koha::Patron' );
143
        'Koha::Checkout->issuer should return a Koha::Patron' );
144
    is( $i->borrowernumber, $issuer->borrowernumber,
144
    is( $i->borrowernumber, $issuer->borrowernumber,
145
        'Koha::Checkout->issued_by should return the correct patron' );
145
        'Koha::Checkout->issuer should return the correct patron' );
146
146
147
    # Testing Koha::Old::Checkout->patron now
147
    # Testing Koha::Old::Checkout->patron now
148
    my $issue_id = $checkout->issue_id;
148
    my $issue_id = $checkout->issue_id;
149
    C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $checkout->itemnumber );
149
    C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $checkout->itemnumber );
150
    $i->delete;
150
    $i->delete;
151
    my $old_issue = Koha::Old::Checkouts->find($issue_id);
151
    my $old_issue = Koha::Old::Checkouts->find($issue_id);
152
    is( $old_issue->issuer, undef,
152
    is( $old_issue->issuer_id, undef,
153
        'Koha::Checkout->issuer should return undef if the patron record has been deleted'
153
        'Koha::Checkout->issuer_id should return undef if the patron record has been deleted'
154
    );
154
    );
155
155
156
};
156
};
157
- 

Return to bug 23916