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

(-)a/catalogue/issuehistory.pl (-21 / +8 lines)
Lines 24-31 use C4::Output qw( output_html_with_http_headers ); Link Here
24
24
25
use C4::Search qw( enabled_staff_search_views );
25
use C4::Search qw( enabled_staff_search_views );
26
use C4::Serials qw( CountSubscriptionFromBiblionumber );
26
use C4::Serials qw( CountSubscriptionFromBiblionumber );
27
use Koha::Checkouts;
28
use Koha::Old::Checkouts;
29
27
30
use Koha::Biblios;
28
use Koha::Biblios;
31
29
Lines 40-68 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
40
);
38
);
41
39
42
my $biblionumber = $query->param('biblionumber');
40
my $biblionumber = $query->param('biblionumber');
41
my $biblio       = Koha::Biblios->find($biblionumber);
43
42
44
my @checkouts = Koha::Checkouts->search(
43
$template->param(
45
    { biblionumber => $biblionumber },
44
    current_checkouts_count => $biblio->current_checkouts->count,
46
    {
45
    past_checkouts_count    => $biblio->old_checkouts->count,
47
        join       => 'item',
46
    biblio                  => $biblio,
48
        order_by   => 'timestamp',
49
    }
50
);
51
my @old_checkouts = Koha::Old::Checkouts->search(
52
    { biblionumber => $biblionumber },
53
    {
54
        join       => 'item',
55
        order_by   => 'timestamp',
56
    }
57
);
47
);
58
48
59
my $biblio = Koha::Biblios->find( $biblionumber );
49
# variables for biblio-view-menu.inc
60
61
$template->param(
50
$template->param(
62
    checkouts => [ @checkouts, @old_checkouts ],
51
    issuehistoryview => 1,
63
    biblio    => $biblio,
52
    C4::Search::enabled_staff_search_views,
64
	issuehistoryview => 1,
65
	C4::Search::enabled_staff_search_views,
66
    subscriptionsnumber => CountSubscriptionFromBiblionumber($biblionumber),
53
    subscriptionsnumber => CountSubscriptionFromBiblionumber($biblionumber),
67
);
54
);
68
55
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt (-75 / +203 lines)
Lines 45-119 Link Here
45
[% SET show_patron_column = Koha.Preference('intranetreadinghistory') AND CAN_user_circulate_circulate_remaining_permissions %]
45
[% SET show_patron_column = Koha.Preference('intranetreadinghistory') AND CAN_user_circulate_circulate_remaining_permissions %]
46
46
47
<div class="searchresults">
47
<div class="searchresults">
48
    [% IF checkouts %]
48
[% IF current_checkouts_count + past_checkouts_count > 0 %]
49
        <h4>Checked out [% checkouts.size | html %] times</h4>
49
    <h3>Checked out [% current_checkouts_count + past_checkouts_count | html %] times</h3>
50
        <table id="table_issues">
50
51
            <thead><tr>
51
    <h4>Current checkouts</h4>
52
            [% IF show_patron_column %]
52
[% IF current_checkouts_count > 0 %]
53
    <table id="current_checkouts">
54
        <thead><tr>
55
        [% IF show_patron_column %]
53
            <th>Patron</th>
56
            <th>Patron</th>
54
            [% END %]
57
        [% END %]
55
            <th>Barcode</th>
58
            <th>Barcode</th>
56
            <th>Checked out from</th>
59
            <th>Checked out from</th>
57
            [% IF Koha.Preference('RecordStaffUserOnCheckout') %]
60
        [% IF Koha.Preference('RecordStaffUserOnCheckout') %]
58
            <th>Checked out by</th>
61
            <th>Checked out by</th>
59
            [% END %]
62
        [% END %]
60
            <th>Renewed</th>
63
            <th>Renewed</th>
61
            <th>Checkout on</th>
64
            <th>Checkout on</th>
62
            <th>Due date</th>
65
            <th>Due date</th>
63
            <th>Checkin on</th>
66
        </tr></thead>
64
            </tr></thead>
67
    </table>
65
            <tbody>
68
[% ELSE %]
66
        [% FOREACH checkout IN checkouts %]
69
    <div class="dialog message">
67
            <tr>
70
        <p>Not currently checked out.</p>
68
                [% IF show_patron_column %]
71
    </div>
69
                    <td>
72
[% END %]
70
                        [% IF checkout.patron %][%# Not set for deleted patron records %]
73
71
                            [% INCLUDE 'patron-title.inc' patron => checkout.patron hide_patron_infos_if_needed=1 %]
74
    <h4>Past checkouts</h4>
72
                        [% END %]
75
73
                    </td>
76
[% IF past_checkouts_count > 0 %]
74
                [% END %]
77
    <table id="old_checkouts">
75
                <td>
78
        <thead><tr>
76
                    [% IF checkout.item.barcode %] [%# FIXME This test is not mandatory I think %]
79
        [% IF show_patron_column %]
77
                        <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% checkout.item.biblionumber | uri %]&amp;itemnumber=[% checkout.item.itemnumber | uri %]">[% checkout.item.barcode | html %]</a>
80
            <th>Patron</th>
78
                    [% ELSE %]
81
        [% END %]
79
                        &nbsp;
82
            <th>Barcode</th>
80
                    [% END %]</td>
83
            <th>Checked out from</th>
81
                <td>[% IF checkout.branchcode %]
84
        [% IF Koha.Preference('RecordStaffUserOnCheckout') %]
82
                        [% Branches.GetName( checkout.branchcode ) | html %]
85
            <th>Checked out by</th>
83
                    [% ELSE %]
84
                        &nbsp;
85
                    [% END %]</td>
86
                [% IF Koha.Preference('RecordStaffUserOnCheckout') %]
87
                <td>[% IF checkout.issuer_id %]
88
                    <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% checkout.issuer_id | uri %]">
89
                    [% INCLUDE 'patron-title.inc' patron=checkout.issuer %]
90
                    </a>
91
                    [% END %]</td>
92
                [% END %]
93
                <td>[% IF checkout.renewals %]
94
                        Yes[% IF checkout.lastreneweddate %], <small>last on: [% checkout.lastreneweddate |$KohaDates  with_hours => 1 %]</small>
95
                            [% END %]
96
                    [% ELSE %]
97
                        No
98
                    [% END %]</td>
99
                <td data-order="[% checkout.issuedate | html %]">
100
                    [% checkout.issuedate |$KohaDates  with_hours => 1 %]
101
                </td>
102
                <td data-order="[% checkout.date_due | html %]">
103
                    [% checkout.date_due |$KohaDates  with_hours => 1 %]
104
                </td>
105
                <td data-order="[% checkout.returndate | html %]">
106
                    [% checkout.returndate |$KohaDates  with_hours => 1 %]
107
                </td>
108
           </tr>
109
        [% END %]
86
        [% END %]
110
        </tbody>
87
            <th>Renewed</th>
111
		</table>
88
            <th>Checkout on</th>
112
    [% ELSE %]
89
            <th>Due date</th>
113
        <div class="dialog message"><p>
90
            <th>Checkin on</th>
114
        <strong>[% biblio.title | html %][% IF biblio.author %], by [% biblio.author | html %][% END %]</strong> has never been checked out.</p></div>
91
        </tr></thead>
92
    </table>
93
[% ELSE %]
94
    <div class="dialog message">
95
        <p>No past checkouts.</p>
96
    </div>
97
[% END %]
115
98
116
    [% END %]
99
[% ELSE %]
100
    <div class="dialog message">
101
        <p>
102
            <strong>[% biblio.title | html %][% IF biblio.author %], by [% biblio.author | html %][% END %]</strong> has never been checked out.
103
        </p>
104
    </div>
105
[% END %]
117
</div>
106
</div>
118
107
119
            </main>
108
            </main>
Lines 129-150 Link Here
129
[% MACRO jsinclude BLOCK %]
118
[% MACRO jsinclude BLOCK %]
130
[% INCLUDE 'datatables.inc' %]
119
[% INCLUDE 'datatables.inc' %]
131
[% INCLUDE 'columns_settings.inc' %]
120
[% INCLUDE 'columns_settings.inc' %]
121
[% INCLUDE 'js-date-format.inc' %]
122
[% INCLUDE 'js-patron-format.inc' %]
132
    <script id="js">
123
    <script id="js">
133
        $(document).ready(function() {
124
        $(document).ready(function() {
134
            var columns_settings = [% TablesSettings.GetColumns('catalogue', 'detail', 'checkoutshistory-table', 'json') %];
125
            var show_patron_column  = [% IF show_patron_column %]1[% ELSE %]0[% END %];
135
            [% UNLESS show_patron_column %]
126
            var show_issuer_column  = [% IF Koha.Preference('RecordStaffUserOnCheckout') %]1[% ELSE %]0[% END %];
136
            // Remove the patron column definition
127
            var default_sort_column = 3 + show_patron_column + show_issuer_column;
137
            columns_settings.splice(0,1);
128
            var current_checkouts = $("#current_checkouts").api({
138
            [% END %]
129
                "ajax": {
139
            var table = KohaTable("table_issues", {
130
                    "url": '/api/v1/biblios/[% biblio.biblionumber | uri %]/checkouts'
140
                "sDom": 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
131
                },
141
            [% IF Koha.Preference('RecordStaffUserOnCheckout') %]
132
                "header_filter": true,
142
                "aaSorting": [[ 5, "desc" ]],
133
                "embed": [
143
            [% ELSE %]
134
                    "issuer",
144
                "aaSorting": [[ 4, "desc" ]],
135
                    "item",
145
            [% END %]
136
                    "library",
146
                "sPaginationType": "full_numbers"
137
                    "patron"
147
            }, columns_settings);
138
                ],
139
                "order": [ [ default_sort_column, "desc" ] ],
140
                "columns": [
141
                [% IF show_patron_column %]
142
                    {
143
                        "data": "patron.firstname:patron.surname:patron.cardnumber",
144
                        "render": function(data, type, row, meta) {
145
                            return $patron_to_html( row.patron, { display_cardnumber: true, url: true } );
146
                        }
147
                    },
148
                [% END %]
149
                    {
150
                        "data": "item.external_id",
151
                        "render": function(data, type, row, meta) {
152
                            if ( data != null ) {
153
                                return '<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber='+row.item.biblio_id+'&amp;itemnumber='+row.item_id+'">'+row.item.external_id + '</a>';
154
                            }
155
                            else {
156
                                return '';
157
                            }
158
                        }
159
                    },
160
                    {
161
                        "data": "library.name",
162
                        "render": function(data) {
163
                            return escape_str(data);
164
                        }
165
                    },
166
                [% IF Koha.Preference('RecordStaffUserOnCheckout') %]
167
                    {
168
                        "data": "issuer.firstname:issuer.surname:issuer.cardnumber",
169
                        "render": function(data, type, row, meta) {
170
                            return (row.issuer) ? $patron_to_html( row.issuer, { display_cardnumber: true, url: true } ) : '';
171
                        }
172
                    },
173
                [% END %]
174
                    {
175
                        "data": "renewals",
176
                        "render": function( data, type, row ) {
177
                            var res = ( data > 0 ) ? _("Yes") : _("No");
178
                            if ( data > 0 && row.last_renewed_date != null ) {
179
                                res += ', <small>' + _("last on:") + ' ' + $datetime(row.last_renewed_date) + '</small>';
180
                            }
181
182
                            return res;
183
                        }
184
                    },
185
                    {
186
                        "data": "checkout_date",
187
                        "render": function(data) {
188
                            return $datetime(data);
189
                        }
190
                    },
191
                    {
192
                        "data": "due_date",
193
                        "render": function(data) {
194
                            return $datetime(data);
195
                        }
196
                    }
197
                ]
198
            });
199
200
            var old_checkouts = $("#old_checkouts").api({
201
                "ajax": {
202
                    "url": '/api/v1/biblios/[% biblio.biblionumber | uri %]/checkouts?checked_in=1'
203
                },
204
                "header_filter": true,
205
                "embed": [
206
                    "issuer",
207
                    "item",
208
                    "library",
209
                    "patron"
210
                ],
211
                "order": [ [ default_sort_column, "desc" ] ],
212
                "columns": [
213
                [% IF show_patron_column %]
214
                    {
215
                        "data": "patron.firstname:patron.surname:patron.cardnumber",
216
                        "render": function(data, type, row, meta) {
217
                            return $patron_to_html( row.patron, { display_cardnumber: true, url: true } );
218
                        }
219
                    },
220
                [% END %]
221
                    {
222
                        "data": "item.external_id",
223
                        "render": function(data, type, row, meta) {
224
                            if ( data != null ) {
225
                                return '<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber='+encodeURIComponent(row.item.biblio_id)+'&amp;itemnumber='+row.item_id+'">'+row.item.external_id + '</a>';
226
                            }
227
                            else {
228
                                return '';
229
                            }
230
                        }
231
                    },
232
                    {
233
                        "data": "library.name",
234
                        "render": function(data) {
235
                            return escape_str(data);
236
                        }
237
                    },
238
                [% IF Koha.Preference('RecordStaffUserOnCheckout') %]
239
                    {
240
                        "data": "issuer.firstname:issuer.surname:issuer.cardnumber",
241
                        "render": function(data, type, row, meta) {
242
                            return (row.issuer) ? $patron_to_html( row.issuer, { display_cardnumber: true, url: true } ) : '';
243
                        }
244
                    },
245
                [% END %]
246
                    {
247
                        "data": "renewals",
248
                        "render": function( data, type, row ) {
249
                            var res = ( data > 0 ) ? _("Yes") : _("No");
250
                            if ( data > 0 && row.last_renewed_date != null ) {
251
                                res += ', <small>' + _("last on:") + ' ' + $datetime(row.last_renewed_date) + '</small>';
252
                            }
253
254
                            return res;
255
                        }
256
                    },
257
                    {
258
                        "data": "checkout_date",
259
                        "render": function(data) {
260
                            return $datetime(data);
261
                        }
262
                    },
263
                    {
264
                        "data": "due_date",
265
                        "render": function(data) {
266
                            return $datetime(data);
267
                        }
268
                    },
269
                    {
270
                        "data": "checkin_date",
271
                        "render": function(data) {
272
                            return $datetime(data);
273
                        }
274
                    }
275
                ]
276
            });
148
        });
277
        });
149
    </script>
278
    </script>
150
[% END %]
279
[% END %]
151
- 

Return to bug 29275