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 / +74 lines)
Lines 22-27 Link Here
22
                    Process request
22
                    Process request
23
                </a>
23
                </a>
24
24
25
                [% IF id_arg && format=='SCAN' %]
26
                <a class="ar-edit-urls" href="#" onclick="HandleMulti( EditURLs, [% id_arg %], $(this) ); return false;">
27
                    <i class="fa fa-edit"></i>
28
                    Edit URLs
29
                </a>
30
                [% END %]
31
25
                <a class="ar-complete-request" href="#" onclick="HandleMulti( Complete, [% id_arg | html %], $(this) ); return false;">
32
                <a class="ar-complete-request" href="#" onclick="HandleMulti( Complete, [% id_arg | html %], $(this) ); return false;">
26
                    <i class="fa fa-check-circle"></i>
33
                    <i class="fa fa-check-circle"></i>
27
                    Complete request
34
                    Complete request
Lines 49-54 Link Here
49
    [% ELSIF myitem.notforloan < 0 %]<span>On order</span>
56
    [% ELSIF myitem.notforloan < 0 %]<span>On order</span>
50
    [% END %]
57
    [% END %]
51
[% END %]
58
[% END %]
59
[% BLOCK urls_modal %]
60
    <div id="myModal" class="modal fade modal-lg" role="dialog">
61
      <div class="modal-dialog">
62
        <div class="modal-content">
63
          <div class="modal-header">
64
             <h4 class="modal-title">Edit URL(s)</h4>
65
          </div>
66
          <div class="modal-body">
67
            <textarea id="urls" style="width:100%;"></textarea>
68
          </div>
69
          <div class="modal-footer">
70
            <button type="button" class="btn btn-default" data-dismiss="modal">Save</button>
71
          </div>
72
        </div>
73
      </div>
74
    </div>
75
[% END %]
52
76
53
<body id="circ_article-requests" class="circ">
77
<body id="circ_article-requests" class="circ">
54
    [% INCLUDE 'header.inc' %]
78
    [% INCLUDE 'header.inc' %]
Lines 67-72 Link Here
67
            <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
91
            <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
68
92
69
                <h1>Article requests</h1>
93
                <h1>Article requests</h1>
94
                [% PROCESS urls_modal %]
70
95
71
                <form id="ar-branchcode-form" method="post">
96
                <form id="ar-branchcode-form" method="post">
72
                    <select name="branchcode" id="branchcode">
97
                    <select name="branchcode" id="branchcode">
Lines 119-124 Link Here
119
                                    <th class="ar-enumchron">Enumeration</th>
144
                                    <th class="ar-enumchron">Enumeration</th>
120
                                    <th class="ar-barcode">Barcode</th>
145
                                    <th class="ar-barcode">Barcode</th>
121
                                    <th class="ar-format">Format</th>
146
                                    <th class="ar-format">Format</th>
147
                                    <th class="ar-urls">URLs</th>
122
                                    <th class="ar-patron">Patron</th>
148
                                    <th class="ar-patron">Patron</th>
123
                                    <th class="ar-date">Date</th>
149
                                    <th class="ar-date">Date</th>
124
                                    <th class="ar-actions">Actions</th>
150
                                    <th class="ar-actions">Actions</th>
Lines 190-195 Link Here
190
                                        <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
216
                                        <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
191
                                        <td class="ar-barcode">[% ar.item.barcode | html %]</td>
217
                                        <td class="ar-barcode">[% ar.item.barcode | html %]</td>
192
                                        <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
218
                                        <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
219
                                        <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>
193
                                        <td class="ar-patron">
220
                                        <td class="ar-patron">
194
                                            <p>
221
                                            <p>
195
                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
222
                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
Lines 201-207 Link Here
201
                                        </td>
228
                                        </td>
202
                                        <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
229
                                        <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
203
                                        <td class="ar-actions">
230
                                        <td class="ar-actions">
204
                                            [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %]
231
                                            [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %]
205
                                        </td>
232
                                        </td>
206
                                    </tr>
233
                                    </tr>
207
                                [% END %]
234
                                [% END %]
Lines 228-233 Link Here
228
                                    <th class="ar-enumchron">Enumeration</th>
255
                                    <th class="ar-enumchron">Enumeration</th>
229
                                    <th class="ar-barcode">Barcode</th>
256
                                    <th class="ar-barcode">Barcode</th>
230
                                    <th class="ar-format">Format</th>
257
                                    <th class="ar-format">Format</th>
258
                                    <th class="ar-urls">URLs</th>
231
                                    <th class="ar-patron">Patron</th>
259
                                    <th class="ar-patron">Patron</th>
232
                                    <th class="ar-date">Date</th>
260
                                    <th class="ar-date">Date</th>
233
                                    <th class="ar-actions">Actions</th>
261
                                    <th class="ar-actions">Actions</th>
Lines 299-304 Link Here
299
                                        <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
327
                                        <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
300
                                        <td class="ar-barcode">[% ar.item.barcode | html %]</td>
328
                                        <td class="ar-barcode">[% ar.item.barcode | html %]</td>
301
                                        <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
329
                                        <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
330
                                        <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>
302
                                        <td class="ar-patron">
331
                                        <td class="ar-patron">
303
                                            <p>
332
                                            <p>
304
                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
333
                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
Lines 310-316 Link Here
310
                                        </td>
339
                                        </td>
311
                                        <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
340
                                        <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
312
                                        <td class="ar-actions">
341
                                        <td class="ar-actions">
313
                                            [% PROCESS actions menuid="table_" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %]
342
                                            [% PROCESS actions menuid="table_" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %]
314
                                        </td>
343
                                        </td>
315
                                    </tr>
344
                                    </tr>
316
                                [% END %]
345
                                [% END %]
Lines 368-373 Link Here
368
                    $('a.ar-process-request').hide();
397
                    $('a.ar-process-request').hide();
369
                else $('a.ar-process-request').show();
398
                else $('a.ar-process-request').show();
370
            });
399
            });
400
            $('#myModal').on("shown.bs.modal", function () {
401
                $('#myModal textarea').focus();
402
            });
403
            $('#myModal').on("hidden.bs.modal", function () {
404
                // Set focus back to dropdown
405
                var id = $('#myModal textarea').attr('ar_id');
406
                var link = $('span#url_'+ id).parent().parent().find('td.ar-actions').find('div.dropdown a');
407
                if( link.length > 0 ) link[0].focus();
408
            });
409
            $( '#myModal button' ).on("click", function () {
410
                SaveURLs( $('#myModal textarea').val() );
411
            });
371
        });
412
        });
372
413
373
        function activateBatchActions( active_table ){
414
        function activateBatchActions( active_table ){
Lines 450-455 Link Here
450
        }
491
        }
451
492
452
        function Complete( id, a ) {
493
        function Complete( id, a ) {
494
            // if it is a scan, check if urls field is filled
495
            var urlspan = $('span#url_'+id);
496
            if( urlspan.length>0 && urlspan.text() === '' ) {
497
                alert( _("Please fill URL before completing request.") );
498
                return;
499
            }
453
            a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide();
500
            a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide();
454
            $.ajax({
501
            $.ajax({
455
                type: "POST",
502
                type: "POST",
Lines 476-481 Link Here
476
            $("#ar_processing_count").html( processing_count );
523
            $("#ar_processing_count").html( processing_count );
477
            if ( processing_count == 0 ) $(".ar-processing-none").show();
524
            if ( processing_count == 0 ) $(".ar-processing-none").show();
478
        }
525
        }
526
527
        function EditURLs(id) {
528
            var urls = $('span#url_'+ id).text();
529
            $('#myModal textarea').val(urls);
530
            $('#myModal textarea').attr('ar_id', id);
531
            $('#myModal').modal('show');
532
        }
533
534
        function SaveURLs(newurl) {
535
            var id = $('#myModal textarea').attr('ar_id');
536
            $('span#url_'+ id).text(newurl);
537
            if(newurl)
538
                $('span#url_yesno_'+id).text(_("Yes"));
539
            else
540
                $('span#url_yesno_'+id).text(_("No"));
541
542
            $.ajax({
543
                type: "POST",
544
                url: '/cgi-bin/koha/svc/article_request',
545
                data: { action: 'update_urls', id: id, urls: newurl },
546
                dataType: 'json',
547
                error: function() { alert('Error: Saving URL failed!'); },
548
                success: function(data) { if(!data.success) alert('Saving URL failed!'); },
549
            });
550
        }
479
    </script>
551
    </script>
480
[% END %]
552
[% END %]
481
553
(-)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