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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt (-75 / +180 lines)
Lines 49-130 Link Here
49
    <div class="dialog alert">Staff members are not allowed to access patron's holds history</div>
49
    <div class="dialog alert">Staff members are not allowed to access patron's holds history</div>
50
[% ELSIF is_anonymous %]
50
[% ELSIF is_anonymous %]
51
    <div class="dialog alert">This is the anonymous patron, so no holds history is displayed.</div>
51
    <div class="dialog alert">This is the anonymous patron, so no holds history is displayed.</div>
52
[% ELSIF ( !holds ) %]
53
    <div class="dialog message">This patron has no holds history.</div>
54
[% ELSE %]
52
[% ELSE %]
55
53
56
[% SET show_itemtype_column = Koha.Preference('AllowHoldItemTypeSelection') %]
54
    [% SET show_itemtype_column = Koha.Preference('AllowHoldItemTypeSelection') %]
57
55
58
<div id="holdshistory" class="page-section">
56
    <div id="holdshistory" class="page-section">
59
  <table id="table_holdshistory">
57
        <h2>Current holds</h2>
60
      <thead>
58
        [% IF patron.holds.count %]
61
        <tr>
59
            <table id="table_holdshistory">
62
        <th class="anti-the">Title</th>
60
                <thead>
63
        <th>Author</th>
61
                    <tr>
64
        <th>Barcode</th>
62
                        <th class="anti-the">Title</th>
65
        <th>Call number</th>
63
                        <th>Author</th>
66
        <th>Library</th>
64
                        <th>Barcode</th>
67
        <th>Hold date</th>
65
                        <th>Call number</th>
68
        <th>Expiration date</th>
66
                        <th>Library</th>
69
        <th>Waiting date</th>
67
                        <th>Hold date</th>
70
        <th>Cancellation date</th>
68
                        <th>Expiration date</th>
71
        [% IF show_itemtype_column %]
69
                        <th>Waiting date</th>
72
          <th>Requested item type</th>
70
                        <th>Cancellation date</th>
71
                        [% IF show_itemtype_column %]
72
                            <th>Requested item type</th>
73
                        [% END %]
74
                        <th>Status</th>
75
                    </tr>
76
              </thead>
77
          </table>
78
        [% ELSE %]
79
            <div class="dialog message">This patron has no current holds.</div>
73
        [% END %]
80
        [% END %]
74
        <th>Status</th>
75
        </tr>
76
      </thead>
77
      <tbody>
78
      [% FOREACH hold IN holds %]
79
        <tr>
80
          <td>[% INCLUDE 'biblio-title.inc' biblio=hold.biblio link = 1 %]</td>
81
          <td>[% hold.biblio.author | html %]</td>
82
          <td>[% hold.item.barcode | html %]</td>
83
          <td>[% hold.item.itemcallnumber | html %]</td>
84
          <td>[% Branches.GetName( hold.branchcode ) | html %]</td>
85
          <td data-order="[% hold.reservedate | html %]">[% hold.reservedate | $KohaDates %]</td>
86
          <td data-order="[% hold.expirationdate | html %]">
87
                [% hold.expirationdate | $KohaDates %]
88
          </td>
89
          <td data-order="[% hold.waitingdate | html %]">
90
                [% hold.waitingdate | $KohaDates %]
91
          </td>
92
          <td data-order="[% hold.cancellationdate | html %]">
93
                [% hold.cancellationdate | $KohaDates %]
94
          </td>
95
          [% IF show_itemtype_column %]
96
            <td>
97
              [% IF hold.itemtype %]
98
                  [% ItemTypes.GetDescription( hold.itemtype ) | html %]
99
              [% ELSE %]
100
                  <span>Any item type</span>
101
              [% END %]
102
            </td>
103
          [% END %]
104
          <td>
105
          [% IF hold.found == 'F' %]
106
              <span>Fulfilled</span>
107
          [% ELSIF hold.cancellationdate %]
108
              <span>Cancelled</span>
109
                [% IF hold.cancellation_reason %]
110
                    ([% AuthorisedValues.GetByCode('HOLD_CANCELLATION', hold.cancellation_reason) | html %])
111
                [% END %]
112
          [% ELSIF hold.found == 'W' %]
113
              <span>Waiting</span>
114
          [% ELSIF hold.found == 'P' %]
115
              <span>Processing</span>
116
          [% ELSIF hold.found == 'T' %]
117
              <span>In transit</span>
118
          [% ELSE %]
119
              <span>Pending</span>
120
          [% END %]
121
          </td>
122
        </tr>
123
      [% END %]
124
      </tbody>
125
  </table>
126
</div>
127
81
82
        <h2>Historical holds</h2>
83
        [% IF patron.old_holds.count %]
84
            <table id="table_oldholdshistory">
85
                <thead>
86
                    <tr>
87
                        <th class="anti-the">Title</th>
88
                        <th>Author</th>
89
                        <th>Barcode</th>
90
                        <th>Call number</th>
91
                        <th>Library</th>
92
                        <th>Hold date</th>
93
                        <th>Expiration date</th>
94
                        <th>Waiting date</th>
95
                        <th>Cancellation date</th>
96
                        [% IF show_itemtype_column %]
97
                            <th>Requested item type</th>
98
                        [% END %]
99
                        <th>Status</th>
100
                    </tr>
101
                </thead>
102
            </table>
103
        [% ELSE %]
104
            <div class="dialog message">This patron has no historical holds.</div>
105
        [% END %]
106
    </div>
128
[% END %]
107
[% END %]
129
108
130
            </main>
109
            </main>
Lines 142-147 Link Here
142
    [% INCLUDE 'columns_settings.inc' %]
121
    [% INCLUDE 'columns_settings.inc' %]
143
    [% INCLUDE 'str/members-menu.inc' %]
122
    [% INCLUDE 'str/members-menu.inc' %]
144
    [% Asset.js("js/members-menu.js") | $raw %]
123
    [% Asset.js("js/members-menu.js") | $raw %]
124
    [% INCLUDE 'js-biblio-format.inc' %]
145
    <script>
125
    <script>
146
        $(document).ready(function() {
126
        $(document).ready(function() {
147
            var table_settings = [% TablesSettings.GetTableSettings('members', 'holdshistory', 'holdshistory-table', 'json') | $raw %];
127
            var table_settings = [% TablesSettings.GetTableSettings('members', 'holdshistory', 'holdshistory-table', 'json') | $raw %];
Lines 149-158 Link Here
149
              //Remove item type column settings
129
              //Remove item type column settings
150
              table_settings['columns'] = table_settings['columns'].filter(function(c){return c['columnname'] != 'itemtype';});
130
              table_settings['columns'] = table_settings['columns'].filter(function(c){return c['columnname'] != 'itemtype';});
151
            [% END %]
131
            [% END %]
152
            var table = KohaTable("table_holdshistory", {
132
            build_holds_table("#table_holdshistory");
153
                "pagingType": "full",
133
            build_holds_table("#table_oldholdshistory", 1);
154
                "order": [[4, 'desc']]
134
            function build_holds_table(table_id, old){
155
            }, table_settings);
135
                let table_url = '/api/v1/patrons/[% patron.borrowernumber | uri %]/holds';
136
                if (old){table_url += '?old=1'}
137
                $(table_id).kohaTable({
138
                    ajax: {
139
                        url: table_url,
140
                    },
141
                    order: [],
142
                    embed: ['biblio', 'item', 'pickup_library', 'pickup_library.branchname'],
143
                    columns: [
144
                        {
145
                            data: "biblio.title:biblio.subtitle:biblio.medium",
146
                            searchable: true,
147
                            orderable: true,
148
                            render: function (data, type, row, meta) {
149
                                return $biblio_to_html(row.biblio, { link: 1 });
150
                            }
151
                        },
152
                        {
153
                            data: "biblio.author",
154
                            searchable: true,
155
                            orderable: true,
156
                            render: function (data, type, row, meta) {
157
                                return row.biblio.author;
158
                            }
159
                        },
160
                        {
161
                            data: "item.external_id",
162
                            searchable: true,
163
                            orderable: true,
164
                            render: function (data, type, row, meta) {
165
                                return row.item ? row.item.external_id : "";
166
                            }
167
                        },
168
                        {
169
                            data: "item.callnumber",
170
                            searchable: true,
171
                            orderable: true,
172
                            render: function (data, type, row, meta) {
173
                                return row.item ? row.item.callnumber: "";
174
                            }
175
                        },
176
                        {
177
                            data: "pickup_library_id:pickup_library.branchname",
178
                            searchable: true,
179
                            orderable: true,
180
                            render: function (data, type, row, meta) {
181
                                return row.pickup_library.name;
182
                            }
183
                        },
184
                        {
185
                            data: "hold_date",
186
                            type: "date",
187
                            searchable: true,
188
                            orderable: true,
189
                            render: function (data, type, row, meta) {
190
                                return $date(row.hold_date);
191
                            }
192
                        },
193
                        {
194
                            data: "expiration_date",
195
                            type: "date",
196
                            searchable: true,
197
                            orderable: true,
198
                            render: function (data, type, row, meta) {
199
                                return $date(row.expiration_date)
200
                            }
201
                        },
202
                        {
203
                            data: "waiting_date",
204
                            type: "date",
205
                            searchable: true,
206
                            orderable: true,
207
                            render: function (data, type, row, meta) {
208
                                return $date(row.waiting_date)
209
                            }
210
                        },
211
                        {
212
                            data: "cancellation_date",
213
                            type: "date",
214
                            searchable: true,
215
                            orderable: true,
216
                            render: function (data, type, row, meta) {
217
                                return $date(row.cancellation_date)
218
                            }
219
                        },
220
                        [% IF show_itemtype_column %]
221
                        {
222
                            data: "item_type.item_type",
223
                            searchable: true,
224
                            orderable: true,
225
                            render: function (data, type, row, meta) {
226
                                if ( row.item_type ) {
227
                                    return row.item_type.item_type;
228
                                } else {
229
                                    return _("Any item type");
230
                                }
231
                            }
232
                        },
233
                        [% END %]
234
                        {
235
                            data: "found", // FIXME filter with dropdown list
236
                            searchable: true,
237
                            orderable: true,
238
                            render: function (data, type, row, meta) {
239
                                if ( row.status == 'F' ) {
240
                                    return _("Fulfilled");
241
                                } else if (row.cancellation_date) {
242
                                    let r = _("Cancelled");
243
                                    if (row.cancellation_reason){
244
                                        r += "(%s)".format("FIXME"); //FIXME Add HOLD_CANCELLATION description
245
                                    }
246
                                    return r;
247
                                } else if (row.status == 'W') {
248
                                    return _("Waiting");
249
                                } else if (row.status == 'P') {
250
                                    return _("Processing");
251
                                } else if (row.status == 'T') {
252
                                    return _("In transit");
253
                                }
254
255
                                return _("Pending");
256
                            }
257
                        },
258
                    ],
259
                }, table_settings);
260
            }
156
        });
261
        });
157
    </script>
262
    </script>
158
[% END %]
263
[% END %]
(-)a/members/holdshistory.pl (-35 / +11 lines)
Lines 26-81 use Koha::Patrons; Link Here
26
26
27
my $input = CGI->new;
27
my $input = CGI->new;
28
28
29
my $borrowernumber;
29
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
30
my $cardnumber;
30
    {
31
my @all_holds;
31
        template_name => "members/holdshistory.tt",
32
32
        query         => $input,
33
my ($template, $loggedinuser, $cookie)= get_template_and_user({template_name => "members/holdshistory.tt",
33
        type          => "intranet",
34
                query => $input,
34
        flagsrequired => { borrowers => 'edit_borrowers' },
35
                type => "intranet",
35
    }
36
                flagsrequired => {borrowers => 'edit_borrowers'},
36
);
37
                });
38
39
my $patron;
40
37
41
if ($input->param('cardnumber')) {
38
my $cardnumber     = $input->param('cardnumber');
42
    $cardnumber = $input->param('cardnumber');
39
my $borrowernumber = $input->param('borrowernumber');
43
    $patron = Koha::Patrons->find( { cardnumber => $cardnumber } );
40
my $patron         = Koha::Patrons->find( $cardnumber ? { cardnumber => $cardnumber } : $borrowernumber );
44
}
45
if ($input->param('borrowernumber')) {
46
    $borrowernumber = $input->param('borrowernumber');
47
    $patron = Koha::Patrons->find( $borrowernumber );
48
}
49
41
50
unless ( $patron ) {
42
unless ( $patron ) {
51
    print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
43
    print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
52
    exit;
44
    exit;
53
}
45
}
54
46
55
my $holds;
56
my $old_holds;
57
58
if ( $borrowernumber eq C4::Context->preference('AnonymousPatron') ){
47
if ( $borrowernumber eq C4::Context->preference('AnonymousPatron') ){
59
    # use of 'eq' in the above comparison is intentional -- the
48
    # use of 'eq' in the above comparison is intentional -- the
60
    # system preference value could be blank
49
    # system preference value could be blank
61
    $template->param( is_anonymous => 1 );
50
    $template->param( is_anonymous => 1 );
62
} else {
63
    $holds = $patron->holds;
64
    $old_holds = $patron->old_holds;
65
66
    while (my $hold = $holds->next) {
67
        push @all_holds, $hold;
68
    }
69
70
    while (my $hold = $old_holds->next) {
71
        push @all_holds, $hold;
72
    }
73
}
51
}
74
52
75
$template->param(
53
$template->param(
76
    holdshistoryview => 1,
54
    holdshistoryview => 1,
77
    patron           => $patron,
55
    patron           => $patron,
78
    holds            => \@all_holds,
79
);
56
);
80
57
81
output_html_with_http_headers $input, $cookie, $template->output;
58
output_html_with_http_headers $input, $cookie, $template->output;
82
- 

Return to bug 35560