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 (-65 / +154 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
            [% ELSE %]
62
        [% ELSE %]
60
            <th class="NoVisible">Checked out by</th>
63
            <th class="NoVisible">Checked out by</th>
61
            [% END %]
64
        [% END %]
62
            <th>Renewed</th>
65
            <th>Renewed</th>
63
            <th>Checkout on</th>
66
            <th>Checkout on</th>
64
            <th>Due date</th>
67
            <th>Due date</th>
65
            <th>Checkin on</th>
68
        </tr></thead>
66
            </tr></thead>
69
    </table>
67
            <tbody>
70
[% ELSE %]
68
        [% FOREACH checkout IN checkouts %]
71
    <div class="dialog message">
69
            <tr>
72
        <p>Not currently checked out.</p>
70
                [% IF show_patron_column %]
73
    </div>
71
                    <td>
74
[% END %]
72
                        [% IF checkout.patron %][%# Not set for deleted patron records %]
75
73
                            [% INCLUDE 'patron-title.inc' patron => checkout.patron hide_patron_infos_if_needed=1 %]
76
    <h4>Past checkouts</h4>
74
                        [% END %]
77
75
                    </td>
78
[% IF past_checkouts_count > 0 %]
76
                [% END %]
79
    <table id="old_checkouts">
77
                <td>
80
        <thead><tr>
78
                    [% IF checkout.item.barcode %] [%# FIXME This test is not mandatory I think %]
81
        [% IF show_patron_column %]
79
                        <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% checkout.item.biblionumber | uri %]&amp;itemnumber=[% checkout.item.itemnumber | uri %]">[% checkout.item.barcode | html %]</a>
82
            <th>Patron</th>
80
                    [% ELSE %]
81
                        &nbsp;
82
                    [% END %]</td>
83
                <td>[% IF checkout.branchcode %]
84
                        [% Branches.GetName( checkout.branchcode ) | html %]
85
                    [% ELSE %]
86
                        &nbsp;
87
                    [% END %]</td>
88
                <td>[% IF checkout.issuer_id %]
89
                    <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% checkout.issuer_id | uri %]">
90
                    [% INCLUDE 'patron-title.inc' patron=checkout.issuer %]
91
                    </a>
92
                    [% END %]</td>
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 %]
83
        [% END %]
110
        </tbody>
84
            <th>Barcode</th>
111
		</table>
85
            <th>Checked out from</th>
112
    [% ELSE %]
86
        [% IF Koha.Preference('RecordStaffUserOnCheckout') %]
113
        <div class="dialog message"><p>
87
            <th>Checked out by</th>
114
        <strong>[% biblio.title | html %][% IF biblio.author %], by [% biblio.author | html %][% END %]</strong> has never been checked out.</p></div>
88
        [% ELSE %]
89
            <th class="NoVisible">Checked out by</th>
90
        [% END %]
91
            <th>Renewed</th>
92
            <th>Checkout on</th>
93
            <th>Due date</th>
94
            <th>Checkin on</th>
95
        </tr></thead>
96
    </table>
97
[% ELSE %]
98
    <div class="dialog message">
99
        <p>No past checkouts.</p>
100
    </div>
101
[% END %]
115
102
116
    [% END %]
103
[% ELSE %]
104
    <div class="dialog message">
105
        <p>
106
            <strong>[% biblio.title | html %][% IF biblio.author %], by [% biblio.author | html %][% END %]</strong> has never been checked out.
107
        </p>
108
    </div>
109
[% END %]
117
</div>
110
</div>
118
111
119
            </main>
112
            </main>
Lines 129-146 Link Here
129
[% MACRO jsinclude BLOCK %]
122
[% MACRO jsinclude BLOCK %]
130
[% INCLUDE 'datatables.inc' %]
123
[% INCLUDE 'datatables.inc' %]
131
[% INCLUDE 'columns_settings.inc' %]
124
[% INCLUDE 'columns_settings.inc' %]
125
[% INCLUDE 'js-date-format.inc' %]
126
[% INCLUDE 'js-patron-format.inc' %]
132
    <script id="js">
127
    <script id="js">
133
        $(document).ready(function() {
128
        $(document).ready(function() {
129
130
            function initialize_checkouts_table( table_selector, default_sort_column, checked_in, columns_settings ) {
131
132
                var columns = [
133
                [% IF show_patron_column %]
134
                    {
135
                        "data": "patron.firstname:patron.surname:patron.cardnumber",
136
                        "render": function(data, type, row, meta) {
137
                            if ( row.patron != null ) {
138
                                return $patron_to_html( row.patron, { display_cardnumber: true, url: true } );
139
                            }
140
                            else {
141
                                return _("A patron from library %s").format(escape_str(row.library.name));
142
                            }
143
                        }
144
                    },
145
                [% END %]
146
                    {
147
                        "data": "item.external_id",
148
                        "render": function(data, type, row, meta) {
149
                            if ( data != null ) {
150
                                return '<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber='+encodeURIComponent(row.item.biblio_id)+'&amp;itemnumber='+encodeURIComponent(row.item_id)+'">'+escape_str(row.item.external_id)+'</a>';
151
                            }
152
                            else {
153
                                return '';
154
                            }
155
                        }
156
                    },
157
                    {
158
                        "data": "library.name",
159
                        "render": function(data) {
160
                            return escape_str(data);
161
                        }
162
                    },
163
                    {
164
                        "data": "issuer.firstname:issuer.surname:issuer.cardnumber",
165
                        "render": function(data, type, row, meta) {
166
                            return (row.issuer) ? $patron_to_html( row.issuer, { display_cardnumber: true, url: true } ) : '';
167
                        }
168
                    },
169
                    {
170
                        "data": "renewals",
171
                        "render": function( data, type, row ) {
172
                            var res = ( data > 0 ) ? _("Yes") : _("No");
173
                            if ( data > 0 && row.last_renewed_date != null ) {
174
                                res += ', <small>' + _("last on:") + ' ' + $datetime(row.last_renewed_date) + '</small>';
175
                            }
176
177
                            return res;
178
                        }
179
                    },
180
                    {
181
                        "data": "checkout_date",
182
                        "render": function(data) {
183
                            return $datetime(data);
184
                        }
185
                    },
186
                    {
187
                        "data": "due_date",
188
                        "render": function(data) {
189
                            return $datetime(data);
190
                        }
191
                    }
192
                ];
193
194
                var url = '/api/v1/biblios/[% biblio.biblionumber | uri %]/checkouts';
195
196
                if ( checked_in ) {
197
                    columns.push({
198
                        "data": "checkin_date",
199
                        "render": function(data) {
200
                            return $datetime(data);
201
                        }
202
                    });
203
204
                    url += '?checked_in=1';
205
                }
206
207
                return $(table_selector).kohaTable({
208
                    "ajax": {
209
                        "url": url
210
                    },
211
                    "header_filter": true,
212
                    "embed": [
213
                        "issuer",
214
                        "item",
215
                        "library",
216
                        "patron"
217
                    ],
218
                    "order": [ [ default_sort_column, "desc" ] ],
219
                    "columns": columns
220
                }, columns_settings);
221
            }
222
134
            var columns_settings = [% TablesSettings.GetColumns('catalogue', 'detail', 'checkoutshistory-table', 'json') %];
223
            var columns_settings = [% TablesSettings.GetColumns('catalogue', 'detail', 'checkoutshistory-table', 'json') %];
135
            [% UNLESS show_patron_column %]
224
            [% UNLESS show_patron_column %]
136
            // Remove the patron column definition
225
            // Remove the patron column definition
137
            columns_settings.splice(0,1);
226
            columns_settings.splice(0,1);
138
            [% END %]
227
            [% END %]
139
            var table = KohaTable("table_issues", {
228
140
                "sDom": 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
229
            var show_patron_column  = [% IF show_patron_column %]1[% ELSE %]0[% END %];
141
                "aaSorting": [[ 5, "desc" ]],
230
            var default_sort_column = 3 + show_patron_column;
142
                "sPaginationType": "full_numbers"
231
143
            }, columns_settings);
232
            var old_checkouts = initialize_checkouts_table( '#old_checkouts', default_sort_column, true, columns_settings );
233
            var current_checkouts = initialize_checkouts_table( '#current_checkouts', default_sort_column, false, columns_settings.slice(0,-1) );
144
        });
234
        });
145
    </script>
235
    </script>
146
[% END %]
236
[% END %]
147
- 

Return to bug 29275