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 69-74 Link Here
69
            <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
93
            <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
70
94
71
                <h1>Article requests</h1>
95
                <h1>Article requests</h1>
96
                [% PROCESS urls_modal %]
72
97
73
                <form id="ar-branchcode-form" method="post">
98
                <form id="ar-branchcode-form" method="post">
74
                    <select name="branchcode" id="branchcode">
99
                    <select name="branchcode" id="branchcode">
Lines 121-126 Link Here
121
                                    <th class="ar-enumchron">Enumeration</th>
146
                                    <th class="ar-enumchron">Enumeration</th>
122
                                    <th class="ar-barcode">Barcode</th>
147
                                    <th class="ar-barcode">Barcode</th>
123
                                    <th class="ar-format">Format</th>
148
                                    <th class="ar-format">Format</th>
149
                                    <th class="ar-urls">URLs</th>
124
                                    <th class="ar-patron">Patron</th>
150
                                    <th class="ar-patron">Patron</th>
125
                                    <th class="ar-date">Date</th>
151
                                    <th class="ar-date">Date</th>
126
                                    <th class="ar-actions">Actions</th>
152
                                    <th class="ar-actions">Actions</th>
Lines 186-191 Link Here
186
                                        <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
212
                                        <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
187
                                        <td class="ar-barcode">[% ar.item.barcode | html %]</td>
213
                                        <td class="ar-barcode">[% ar.item.barcode | html %]</td>
188
                                        <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
214
                                        <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
215
                                        <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>
189
                                        <td class="ar-patron">
216
                                        <td class="ar-patron">
190
                                            <p>
217
                                            <p>
191
                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
218
                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
Lines 197-203 Link Here
197
                                        </td>
224
                                        </td>
198
                                        <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
225
                                        <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
199
                                        <td class="ar-actions">
226
                                        <td class="ar-actions">
200
                                            [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %]
227
                                            [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %]
201
                                        </td>
228
                                        </td>
202
                                    </tr>
229
                                    </tr>
203
                                [% END %]
230
                                [% END %]
Lines 224-229 Link Here
224
                                    <th class="ar-enumchron">Enumeration</th>
251
                                    <th class="ar-enumchron">Enumeration</th>
225
                                    <th class="ar-barcode">Barcode</th>
252
                                    <th class="ar-barcode">Barcode</th>
226
                                    <th class="ar-format">Format</th>
253
                                    <th class="ar-format">Format</th>
254
                                    <th class="ar-urls">URLs</th>
227
                                    <th class="ar-patron">Patron</th>
255
                                    <th class="ar-patron">Patron</th>
228
                                    <th class="ar-date">Date</th>
256
                                    <th class="ar-date">Date</th>
229
                                    <th class="ar-actions">Actions</th>
257
                                    <th class="ar-actions">Actions</th>
Lines 287-292 Link Here
287
                                        <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
315
                                        <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
288
                                        <td class="ar-barcode">[% ar.item.barcode | html %]</td>
316
                                        <td class="ar-barcode">[% ar.item.barcode | html %]</td>
289
                                        <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
317
                                        <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
318
                                        <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>
290
                                        <td class="ar-patron">
319
                                        <td class="ar-patron">
291
                                            <p>
320
                                            <p>
292
                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
321
                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
Lines 298-304 Link Here
298
                                        </td>
327
                                        </td>
299
                                        <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
328
                                        <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
300
                                        <td class="ar-actions">
329
                                        <td class="ar-actions">
301
                                            [% PROCESS actions menuid="table_" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %]
330
                                            [% PROCESS actions menuid="table_" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %]
302
                                        </td>
331
                                        </td>
303
                                    </tr>
332
                                    </tr>
304
                                [% END %]
333
                                [% END %]
Lines 349-354 Link Here
349
                else $('a.ar-process-request').show();
378
                else $('a.ar-process-request').show();
350
            });
379
            });
351
380
381
            $('#myModal').on("shown.bs.modal", function () {
382
                $('#myModal textarea').focus();
383
            });
384
            $('#myModal').on("hidden.bs.modal", function () {
385
                // Set focus back to dropdown
386
                var id = $('#myModal textarea').attr('ar_id');
387
                var link = $('span#url_'+ id).parent().parent().find('td.ar-actions').find('div.dropdown a');
388
                if( link.length > 0 ) link[0].focus();
389
            });
390
            $( '#myModal button' ).on("click", function () {
391
                SaveURLs( $('#myModal textarea').val() );
392
            });
393
352
            pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, {
394
            pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, {
353
                "aoColumnDefs": [
395
                "aoColumnDefs": [
354
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
396
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
Lines 444-449 Link Here
444
        }
486
        }
445
487
446
        function Complete( id, a ) {
488
        function Complete( id, a ) {
489
            // if it is a scan, check if urls field is filled
490
            var urlspan = $('span#url_'+id);
491
            if( urlspan.length>0 && urlspan.text() === '' ) {
492
                alert( _("Please fill URL before completing request.") );
493
                return;
494
            }
447
            a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide();
495
            a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide();
448
            $.ajax({
496
            $.ajax({
449
                type: "POST",
497
                type: "POST",
Lines 465-470 Link Here
465
            $("#ar_pending_count").html( pending_datatable.rows().count() );
513
            $("#ar_pending_count").html( pending_datatable.rows().count() );
466
            $("#ar_processing_count").html( processing_datatable.rows().count() );
514
            $("#ar_processing_count").html( processing_datatable.rows().count() );
467
        }
515
        }
516
517
        function EditURLs(id) {
518
            var urls = $('span#url_'+ id).text();
519
            $('#myModal textarea').val(urls);
520
            $('#myModal textarea').attr('ar_id', id);
521
            $('#myModal').modal('show');
522
        }
523
524
        function SaveURLs(newurl) {
525
            var id = $('#myModal textarea').attr('ar_id');
526
            $('span#url_'+ id).text(newurl);
527
            if(newurl)
528
                $('span#url_yesno_'+id).text(_("Yes"));
529
            else
530
                $('span#url_yesno_'+id).text(_("No"));
531
532
            $.ajax({
533
                type: "POST",
534
                url: '/cgi-bin/koha/svc/article_request',
535
                data: { action: 'update_urls', id: id, urls: newurl },
536
                dataType: 'json',
537
                error: function() { alert('Error: Saving URL failed!'); },
538
                success: function(data) { if(!data.success) alert('Saving URL failed!'); },
539
            });
540
        }
468
    </script>
541
    </script>
469
[% END %]
542
[% END %]
470
543
(-)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