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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt (-2 / +75 lines)
Lines 24-29 Link Here
24
                    Process request
24
                    Process request
25
                </a>
25
                </a>
26
26
27
                [% IF id_arg && format=='SCAN' %]
28
                <a class="ar-edit-urls" href="#" onclick="HandleMulti( EditURLs, [% id_arg %], $(this) ); return false;">
29
                    <i class="fa fa-edit"></i>
30
                    Edit URLs
31
                </a>
32
                [% END %]
33
27
                <a class="ar-complete-request" href="#" onclick="HandleMulti( Complete, [% id_arg | html %], $(this) ); return false;">
34
                <a class="ar-complete-request" href="#" onclick="HandleMulti( Complete, [% id_arg | html %], $(this) ); return false;">
28
                    <i class="fa fa-check-circle"></i>
35
                    <i class="fa fa-check-circle"></i>
29
                    Complete request
36
                    Complete request
Lines 51-56 Link Here
51
    [% ELSIF myitem.notforloan < 0 %]<span>On order</span>
58
    [% ELSIF myitem.notforloan < 0 %]<span>On order</span>
52
    [% END %]
59
    [% END %]
53
[% END %]
60
[% END %]
61
[% BLOCK urls_modal %]
62
    <div id="myModal" class="modal fade modal-lg" role="dialog">
63
      <div class="modal-dialog">
64
        <div class="modal-content">
65
          <div class="modal-header">
66
             <h4 class="modal-title">Edit URL(s)</h4>
67
          </div>
68
          <div class="modal-body">
69
            <textarea id="urls" style="width:100%;"></textarea>
70
          </div>
71
          <div class="modal-footer">
72
            <button type="button" class="btn btn-default" data-dismiss="modal">Save</button>
73
          </div>
74
        </div>
75
      </div>
76
    </div>
77
[% END %]
54
78
55
<body id="circ_article-requests" class="circ">
79
<body id="circ_article-requests" class="circ">
56
    [% INCLUDE 'header.inc' %]
80
    [% INCLUDE 'header.inc' %]
Lines 76-81 Link Here
76
            <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
100
            <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
77
101
78
                <h1>Article requests</h1>
102
                <h1>Article requests</h1>
103
                [% PROCESS urls_modal %]
79
104
80
                <form id="ar-branchcode-form" method="post">
105
                <form id="ar-branchcode-form" method="post">
81
                    <select name="branchcode" id="branchcode">
106
                    <select name="branchcode" id="branchcode">
Lines 128-133 Link Here
128
                                    <th class="ar-enumchron">Enumeration</th>
153
                                    <th class="ar-enumchron">Enumeration</th>
129
                                    <th class="ar-barcode">Barcode</th>
154
                                    <th class="ar-barcode">Barcode</th>
130
                                    <th class="ar-format">Format</th>
155
                                    <th class="ar-format">Format</th>
156
                                    <th class="ar-urls">URLs</th>
131
                                    <th class="ar-patron">Patron</th>
157
                                    <th class="ar-patron">Patron</th>
132
                                    <th class="ar-date">Date</th>
158
                                    <th class="ar-date">Date</th>
133
                                    <th class="ar-actions noExport">Actions</th>
159
                                    <th class="ar-actions noExport">Actions</th>
Lines 193-198 Link Here
193
                                        <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
219
                                        <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
194
                                        <td class="ar-barcode">[% ar.item.barcode | html %]</td>
220
                                        <td class="ar-barcode">[% ar.item.barcode | html %]</td>
195
                                        <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
221
                                        <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
222
                                        <td class="ar-urls">[% IF ar.format == 'SCAN' %]<span id="url_yesno_[% ar.id %]">[% IF ar.urls %]Yes[% ELSE %]No[% END%]</span><span id="url_[% ar.id%]" style="display:none;">[% ar.urls %]</span>[% END %]</td>
196
                                        <td class="ar-patron">
223
                                        <td class="ar-patron">
197
                                            <p>
224
                                            <p>
198
                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
225
                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
Lines 204-210 Link Here
204
                                        </td>
231
                                        </td>
205
                                        <td class="ar-date" data-order="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</td>
232
                                        <td class="ar-date" data-order="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</td>
206
                                        <td class="ar-actions">
233
                                        <td class="ar-actions">
207
                                            [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %]
234
                                            [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %]
208
                                        </td>
235
                                        </td>
209
                                    </tr>
236
                                    </tr>
210
                                [% END %]
237
                                [% END %]
Lines 231-236 Link Here
231
                                    <th class="ar-enumchron">Enumeration</th>
258
                                    <th class="ar-enumchron">Enumeration</th>
232
                                    <th class="ar-barcode">Barcode</th>
259
                                    <th class="ar-barcode">Barcode</th>
233
                                    <th class="ar-format">Format</th>
260
                                    <th class="ar-format">Format</th>
261
                                    <th class="ar-urls">URLs</th>
234
                                    <th class="ar-patron">Patron</th>
262
                                    <th class="ar-patron">Patron</th>
235
                                    <th class="ar-date">Date</th>
263
                                    <th class="ar-date">Date</th>
236
                                    <th class="ar-actions noExport">Actions</th>
264
                                    <th class="ar-actions noExport">Actions</th>
Lines 294-299 Link Here
294
                                        <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
322
                                        <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
295
                                        <td class="ar-barcode">[% ar.item.barcode | html %]</td>
323
                                        <td class="ar-barcode">[% ar.item.barcode | html %]</td>
296
                                        <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
324
                                        <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
325
                                        <td class="ar-urls">[% IF ar.format == 'SCAN' %]<span id="url_yesno_[% ar.id %]">[% IF ar.urls %]Yes[% ELSE %]No[% END%]</span><span id="url_[% ar.id%]" style="display:none;">[% ar.urls %]</span>[% END %]</td>
297
                                        <td class="ar-patron">
326
                                        <td class="ar-patron">
298
                                            <p>
327
                                            <p>
299
                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
328
                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
Lines 305-311 Link Here
305
                                        </td>
334
                                        </td>
306
                                        <td class="ar-date" data-order="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</td>
335
                                        <td class="ar-date" data-order="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</td>
307
                                        <td class="ar-actions">
336
                                        <td class="ar-actions">
308
                                            [% PROCESS actions menuid="table_" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %]
337
                                            [% PROCESS actions menuid="table_" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %]
309
                                        </td>
338
                                        </td>
310
                                    </tr>
339
                                    </tr>
311
                                [% END %]
340
                                [% END %]
Lines 356-361 Link Here
356
                else $('a.ar-process-request').show();
385
                else $('a.ar-process-request').show();
357
            });
386
            });
358
387
388
            $('#myModal').on("shown.bs.modal", function () {
389
                $('#myModal textarea').focus();
390
            });
391
            $('#myModal').on("hidden.bs.modal", function () {
392
                // Set focus back to dropdown
393
                var id = $('#myModal textarea').attr('ar_id');
394
                var link = $('span#url_'+ id).parent().parent().find('td.ar-actions').find('div.dropdown a');
395
                if( link.length > 0 ) link[0].focus();
396
            });
397
            $( '#myModal button' ).on("click", function () {
398
                SaveURLs( $('#myModal textarea').val() );
399
            });
400
359
            pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, {
401
            pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, {
360
                "aoColumnDefs": [
402
                "aoColumnDefs": [
361
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
403
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
Lines 451-456 Link Here
451
        }
493
        }
452
494
453
        function Complete( id, a ) {
495
        function Complete( id, a ) {
496
            // if it is a scan, check if urls field is filled
497
            var urlspan = $('span#url_'+id);
498
            if( urlspan.length>0 && urlspan.text() === '' ) {
499
                alert( _("Please fill URL before completing request.") );
500
                return;
501
            }
454
            a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide();
502
            a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide();
455
            $.ajax({
503
            $.ajax({
456
                type: "POST",
504
                type: "POST",
Lines 472-477 Link Here
472
            $("#ar_pending_count").html( pending_datatable.rows().count() );
520
            $("#ar_pending_count").html( pending_datatable.rows().count() );
473
            $("#ar_processing_count").html( processing_datatable.rows().count() );
521
            $("#ar_processing_count").html( processing_datatable.rows().count() );
474
        }
522
        }
523
524
        function EditURLs(id) {
525
            var urls = $('span#url_'+ id).text();
526
            $('#myModal textarea').val(urls);
527
            $('#myModal textarea').attr('ar_id', id);
528
            $('#myModal').modal('show');
529
        }
530
531
        function SaveURLs(newurl) {
532
            var id = $('#myModal textarea').attr('ar_id');
533
            $('span#url_'+ id).text(newurl);
534
            if(newurl)
535
                $('span#url_yesno_'+id).text(_("Yes"));
536
            else
537
                $('span#url_yesno_'+id).text(_("No"));
538
539
            $.ajax({
540
                type: "POST",
541
                url: '/cgi-bin/koha/svc/article_request',
542
                data: { action: 'update_urls', id: id, urls: newurl },
543
                dataType: 'json',
544
                error: function() { alert('Error: Saving URL failed!'); },
545
                success: function(data) { if(!data.success) alert('Saving URL failed!'); },
546
            });
547
        }
475
    </script>
548
    </script>
476
[% END %]
549
[% END %]
477
550
(-)a/svc/article_request (-2 / +6 lines)
Lines 20-26 Link Here
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
22
23
use CGI;
23
use CGI qw ( -utf8 );
24
use JSON qw(to_json);
24
use JSON qw(to_json);
25
25
26
use C4::Auth qw(check_cookie_auth);
26
use C4::Auth qw(check_cookie_auth);
Lines 58-63 if ($ar) { Link Here
58
        $ar->branchcode( $branchcode ) if $branchcode;
58
        $ar->branchcode( $branchcode ) if $branchcode;
59
        $ar = $ar->store();
59
        $ar = $ar->store();
60
    }
60
    }
61
    elsif( $action eq 'update_urls' ) {
62
        my $urls = $cgi->param('urls') // q{};
63
        $ar->urls( $urls );
64
        $ar = $ar->store();
65
    }
61
}
66
}
62
67
63
print to_json( { success => $ar ? 1 : 0 } );
68
print to_json( { success => $ar ? 1 : 0 } );
64
- 

Return to bug 20472