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

(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt (-94 / +121 lines)
Lines 17-35 Link Here
17
     return s.substring(index + 1);
17
     return s.substring(index + 1);
18
 }
18
 }
19
19
20
// Select the first item available
21
function select_first_available(id){
22
    var radios = $("input:radio[name='checkitem_" + id + "']");
23
    $(radios).first().attr("checked", "checked");
24
}
25
20
 $(document).ready(function() {
26
 $(document).ready(function() {
21
    $('#hold-request-form').preventDoubleFormSubmit();
27
    $('#hold-request-form').preventDoubleFormSubmit();
22
28
23
    var copiesRowId = null;
29
    var copiesRowId = null;
24
    var wasSpecific = false;
30
    var wasSpecific = false;
25
    var lastCopiesRowId = null;
31
    var lastCopiesRowId = null;
26
	$(".checkitem").parent().click(function(e){
32
    $(".checkitem").parent().click(function(e){
27
		if(e.target.tagName.toLowerCase() == 'td'){
33
        if(e.target.tagName.toLowerCase() == 'td'){
28
           $(this).find("input.checkitem").each( function() {
34
           $(this).find("input.checkitem").each( function() {
29
               $(this).attr('checked', !$(this).attr('checked'));
35
               $(this).attr('checked', 'checked');
30
			});
36
            });
31
		}
37
        }
32
	});
38
    });
39
40
    // click on a first td check the confirmjs checkbox
41
    $("td.hold").click(function(e){
42
      if(e.target.tagName.toLowerCase() == 'td'){
43
        $(this).find("input.confirmjs").each( function() {
44
           $(this).attr('checked', !$(this).attr('checked'));
45
           $(this).change();
46
        });
47
      }
48
    });
49
33
    // Hides all 'specific copy' table rows on load.
50
    // Hides all 'specific copy' table rows on load.
34
    $(".copiesrow").hide();
51
    $(".copiesrow").hide();
35
    $(".notesrow").hide();
52
    $(".notesrow").hide();
Lines 43-117 Link Here
43
        }
60
        }
44
    });
61
    });
45
62
46
    $("#place_on_hdr").show();
47
    $(".place_on_type").show();
48
49
    // Replace non-JS single-selection with multi-selection capability.
63
    // Replace non-JS single-selection with multi-selection capability.
50
    $(".reserve_mode").val("multi");
64
    $(".reserve_mode").val("multi");
51
    $(".confirm_nonjs").remove();
65
    $(".confirm_nonjs").remove();
52
    $(".confirmjs_hold").each(function(){
66
    $(".confirmjs_hold").each(function(){
53
        var bib = $(this).attr("title");
67
        var bib = $(this).attr("title");
54
        var html = "<input type =\"checkbox\" class=\"confirmjs\" checked=\"checked\"";
68
        var html = "<input type =\"checkbox\" class=\"confirmjs\" checked=\"checked\"";
55
        html += "value=\"" + bib + "\"/>";
69
        html += "value=\"" + bib + "\" id=\"" + bib + "\"/>";
56
        $(this).html(html);
57
    });
58
    $(".confirmjs_nohold").each(function(){
59
        var bib = $(this).attr("title");
60
        var html = "<input type =\"checkbox\" class=\"confirmjs\" disabled=\"disabled\"";
61
        html += "value=\"" + bib + "\"/>";
62
        $(this).html(html);
70
        $(this).html(html);
63
    });
71
    });
64
72
65
    // Make sure a specific item was selected where specified
73
    // expand or collapse the copiesrow tr
66
    // before moving on to a new item.
74
    function toggle_copiesrow(biblioNum) {
67
    function changeSelection (newCopiesRowId, isSpecific) {
75
        var checkbox = $("input:checkbox[value='"+biblioNum+"']");
68
        if (copiesRowId && ((copiesRowId != newCopiesRowId) || (wasSpecific != isSpecific))) {
69
            var biblioNum = suffixOf(copiesRowId, "_");
70
71
            // If the 'specific copy' radio button was checked
72
              if (wasSpecific && (copiesRowId != newCopiesRowId)) {
73
                // Find the selected copy
74
                var item = $(".checkitem_" + biblioNum + ":checked");
75
                if ($(item).size() == 0) {
76
                    alert(MSG_NO_COPY_SELECTED);
77
                    return false;
78
                }
79
            }
80
        }
81
        copiesRowId = newCopiesRowId;
82
        wasSpecific = isSpecific;
83
        return true;
84
    }
85
86
    // When 'specific copy' radio button is clicked
87
    $(".selectspecific").click(function() {
88
89
        // Make sure all other specific copy table rows are hidden
90
        biblioNum = suffixOf($(this).attr("id"), "_");
91
        newCopiesRowId = "#copiesrow_" + biblioNum;
76
        newCopiesRowId = "#copiesrow_" + biblioNum;
77
        var select_specific = $("#reqspecific_"+biblioNum).is(":checked");
92
78
93
        if (!changeSelection(newCopiesRowId, true)) {
79
        // If the checkbox is checked AND we want a specific item, we display the items block
94
            return false;
80
        if ( $(checkbox).is(":checked") && select_specific ) {
81
            $(newCopiesRowId).show();
82
        } else {
83
            $(newCopiesRowId).hide();
95
        }
84
        }
96
        $(".copiesrow:not(" + newCopiesRowId + ")").hide();
85
    };
97
86
98
        // Show the specific copy table for this radio button.
87
    $("#place_on_hdr").show();
99
        $(newCopiesRowId).show();
100
    });
101
102
103
    // When 'first available' radion button is clicked
104
    $(".selectany").click(function() {
105
        // Make sure all other specific copy table rows are hidden
106
        biblioNum = suffixOf($(this).attr("id"), "_");
107
        newCopiesRowId = "#copiesrow_" + biblioNum;
108
88
109
        if (!changeSelection(newCopiesRowId, false)) {
89
    [% IF OPACItemHolds == '1' %]
110
            return false;
90
        $(".place_on_type").show();
91
        // onload, selectany is checked
92
        $(".selectany").attr("checked", "checked");
93
    [% END %]
94
95
    // If we can choose a specific item, we preselect the first one
96
    [% IF OPACItemHolds =="1" or OPACItemHolds == 'force' %]
97
        $("tr.hold").each(function(){
98
            var id = suffixOf($(this).attr("id"), "_");
99
            select_first_available(id);
100
        });
101
    [% END %]
102
103
    // On confirmsjs change
104
    $(".confirmjs").change(function(){
105
        var id = suffixOf($(this).attr("id"), "_");
106
        // If I m checked, I enable radio buttons
107
        if ( $(this).is(":checked") ) {
108
            $("#reqspecific_" + id).attr("disabled", false);
109
            $("#reqany_" + id).attr("disabled", false);
111
        }
110
        }
112
111
        // Else its are disabled
113
        // Hide the copies table row
112
        else {
114
        $(".copiesrow").hide();
113
            $("#reqspecific_" + id).attr("disabled", "disabled");
114
            $("#reqany_" + id).attr("disabled", "disabled");
115
        }
116
        // expand or collaspe the items block
117
        toggle_copiesrow(id);
118
   });
119
120
    // When 'specific copy' or 'first available' radio button is clicked
121
    $(".selectspecific, .selectany").click(function() {
122
        var id = suffixOf($(this).attr("id"), "_");
123
        toggle_copiesrow(id);
115
    });
124
    });
116
125
117
    // Show or hide holds notes
126
    // Show or hide holds notes
Lines 171-177 Link Here
171
180
172
        $("#selections").val(selections);
181
        $("#selections").val(selections);
173
        $("#biblionumbers").val(biblionumbers);
182
        $("#biblionumbers").val(biblionumbers);
174
175
        return true;
183
        return true;
176
    });
184
    });
177
185
Lines 260-265 Link Here
260
            <input type="hidden" name="selecteditems" id="selections"/>
268
            <input type="hidden" name="selecteditems" id="selections"/>
261
            <div id="bigloop">
269
            <div id="bigloop">
262
              <table id="bibitemloop">
270
              <table id="bibitemloop">
271
                <thead>
263
                [% UNLESS ( none_available ) %]<tr>
272
                [% UNLESS ( none_available ) %]<tr>
264
                  <th>Hold</th>
273
                  <th>Hold</th>
265
                  <th>Title</th>
274
                  <th>Title</th>
Lines 278-297 Link Here
278
		  [% END %]
287
		  [% END %]
279
        <th>Hold not needed after</th>
288
        <th>Hold not needed after</th>
280
        [% IF ( OPACShowHoldNotes ) %]<th>Notes</th>[% END %]
289
        [% IF ( OPACShowHoldNotes ) %]<th>Notes</th>[% END %]
281
                  [% IF OPACItemHolds == 'yes' %]
290
                  [% IF OPACItemHolds == '1' %]
282
                    <th id="place_on_hdr" style="display:none">Place On</th>
291
                    <th id="place_on_hdr" style="display:none">Place On</th>
283
                  [% END %]
292
                  [% END %]
284
                  [% UNLESS ( singleBranchMode ) %]
293
                  [% UNLESS ( singleBranchMode ) %]
285
		    [% IF ( choose_branch ) %]
294
                    [% IF ( choose_branch ) %]
286
                        <th>Pickup location</th>
295
                        <th>Pickup location</th>
287
		    [% END %]
296
                    [% END %]
288
                  [% END %]
297
                  [% END %]
289
                </tr>[% ELSE %]<tr><th colspan="[% itemtable_colspan + 1 %]">Title</th></tr>[% END %]
298
                </tr>[% ELSE %]<tr><th colspan="[% itemtable_colspan + 1 %]">Title</th></tr>[% END %]
290
291
                [% FOREACH bibitemloo IN bibitemloop %]
299
                [% FOREACH bibitemloo IN bibitemloop %]
292
                  <tr>
300
                  <tr id="hold_[% bibitemloo.biblionumber %]" class="hold">
293
                      [% IF ( bibitemloo.holdable ) %]
301
                    [% IF ( bibitemloo.holdable ) %]
294
                                    <td class="hold">
302
                    <td class="hold">
295
                      <input class="reserve_mode" name="reserve_mode" type="hidden" value="single"/>
303
                      <input class="reserve_mode" name="reserve_mode" type="hidden" value="single"/>
296
                      <input class="single_bib" name="single_bib" type="hidden" value="[% bibitemloo.biblionumber %]"/>
304
                      <input class="single_bib" name="single_bib" type="hidden" value="[% bibitemloo.biblionumber %]"/>
297
                        <span class="confirmjs_hold" title="[% bibitemloo.biblionumber %]"></span>
305
                        <span class="confirmjs_hold" title="[% bibitemloo.biblionumber %]"></span>
Lines 302-311 Link Here
302
                                 value="any" />
310
                                 value="any" />
303
                          <label class="confirm_label" for="[% bibitemloo.checkitem_bib %]">Next available copy</label>
311
                          <label class="confirm_label" for="[% bibitemloo.checkitem_bib %]">Next available copy</label>
304
                        </span>
312
                        </span>
305
					</td>
313
                    </td>
306
                      [% ELSE %]
314
                    [% ELSE %]
307
                                      [% UNLESS ( none_available ) %]<td class="hold">&nbsp;</td>[% END %]
315
                      [% UNLESS ( none_available ) %]<td class="hold">&nbsp;</td>[% END %]
308
                      [% END %]
316
                    [% END %]
309
                    [% IF ( bibitemloo.holdable ) %]<td class="title">[% ELSE %]<td class="title" colspan="[% itemtable_colspan + 1 %]">[% END %]
317
                    [% IF ( bibitemloo.holdable ) %]<td class="title">[% ELSE %]<td class="title" colspan="[% itemtable_colspan + 1 %]">[% END %]
310
                      <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% bibitemloo.biblionumber %]">[% bibitemloo.title |html %][% IF ( bibitemloo.subtitle ) %] [% FOREACH subtitl IN bibitemloo.subtitle %][% subtitl.subfield %][% END %][% END %]</a>
318
                      <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% bibitemloo.biblionumber %]">[% bibitemloo.title |html %][% IF ( bibitemloo.subtitle ) %] [% FOREACH subtitl IN bibitemloo.subtitle %][% subtitl.subfield %][% END %][% END %]</a>
311
                      [% IF ( bibitemloo.author ) %],  by [% bibitemloo.author %][% END %]
319
                      [% IF ( bibitemloo.author ) %],  by [% bibitemloo.author %][% END %]
Lines 367-403 Link Here
367
    [% IF ( OPACShowHoldNotes ) %][% IF ( bibitemloo.holdable ) %]<td><input type="button" id="shownotes_[% bibitemloo.biblionumber %]" class="shownotes" value="Edit notes"/></td>[% END %][% END %]
375
    [% IF ( OPACShowHoldNotes ) %][% IF ( bibitemloo.holdable ) %]<td><input type="button" id="shownotes_[% bibitemloo.biblionumber %]" class="shownotes" value="Edit notes"/></td>[% END %][% END %]
368
376
369
                    [% IF ( bibitemloo.holdable ) %]
377
                    [% IF ( bibitemloo.holdable ) %]
370
		    <!-- HOLDABLE -->
378
                        <!-- HOLDABLE -->
371
		        [% IF OPACItemHolds == 'yes' %]
379
                        [% IF OPACItemHolds == '1' or OPACItemHolds == 'force' %]
372
		        <!-- ITEM HOLDS -->
380
                        <!-- ITEM HOLDS -->
373
                                          <td class="place_on_type" style="display:none">
381
                                          <td class="place_on_type" style="display:none">
374
                                            <ul>
382
                                            <ul>
375
                                                <li>
383
                                                <li>
376
                                                    <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
384
                                                    [% IF OPACItemHolds == "1" %]
377
                                                           id="reqany_[% bibitemloo.biblionumber %]"
385
                                                        <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
378
                                                           class="selectany"
386
                                                               id="reqany_[% bibitemloo.biblionumber %]"
379
                                                           value="Any"
387
                                                               class="selectany"
380
                                                           checked="checked"
388
                                                               value="Any"
381
                                                    />
389
                                                               checked="checked"
390
                                                        />
391
                                                    [% ELSE %]
392
                                                        <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
393
                                                               id="reqany_[% bibitemloo.biblionumber %]"
394
                                                               class="selectany"
395
                                                               value="Any"
396
                                                        />
397
                                                    [% END %]
382
                                                    <label for="reqany_[% bibitemloo.biblionumber %]">Next available copy</label>
398
                                                    <label for="reqany_[% bibitemloo.biblionumber %]">Next available copy</label>
383
                                                </li>
399
                                                </li>
384
                                                <li>
400
                                                <li>
385
                                                    <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
401
                                                    [% IF OPACItemHolds == "force" %]
386
                                                           id="reqspecific_[% bibitemloo.biblionumber %]"
402
                                                        <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
387
                                                           class="selectspecific"
403
                                                               id="reqspecific_[% bibitemloo.biblionumber %]"
388
                                                           value="Specific"
404
                                                               class="selectspecific"
389
                                                    />
405
                                                               value="Specific"
406
                                                               checked="checked"
407
                                                        />
408
                                                    [% ELSE %]
409
                                                        <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
410
                                                               id="reqspecific_[% bibitemloo.biblionumber %]"
411
                                                               class="selectspecific"
412
                                                               value="Specific"
413
                                                        />
414
                                                    [% END %]
390
                                                    <label for="reqspecific_[% bibitemloo.biblionumber %]">A specific copy</label>
415
                                                    <label for="reqspecific_[% bibitemloo.biblionumber %]">A specific copy</label>
391
                                                </li>
416
                                                </li>
392
                                            </ul>
417
                                            </ul>
393
                                          </td>
418
                                          </td>
394
		        [% ELSIF OPACItemHolds == 'force' %]
419
                        [% IF OPACItemHolds == 'force' %]
395
<script type="text/javascript">
420
                            <script type="text/javascript">
396
    $(document).ready(function() {
421
                                $(document).ready(function() {
397
        $("#copiesrow_[% bibitemloo.biblionumber %]").show();
422
                                    $("#copiesrow_[% bibitemloo.biblionumber %]").show();
398
    });
423
                                });
399
</script>
424
                            </script>
400
                        [% END %]
425
                        [% END %]
426
                    [% END %]
427
401
                    [% END  # holdable%]
428
                    [% END  # holdable%]
402
                    [% UNLESS ( singleBranchMode ) %]
429
                    [% UNLESS ( singleBranchMode ) %]
403
                        [% IF ( bibitemloo.holdable ) %]
430
                        [% IF ( bibitemloo.holdable ) %]
Lines 444-450 Link Here
444
                  [% END %]
471
                  [% END %]
445
                  [% END %]
472
                  [% END %]
446
473
447
                  [% IF OPACItemHolds == 'yes' || OPACItemHolds == 'force' %]
474
                  [% IF OPACItemHolds == '1' || OPACItemHolds == 'force' %]
448
                  [% IF ( bibitemloo.holdable ) %]
475
                  [% IF ( bibitemloo.holdable ) %]
449
                    <tr class="copiesrow" id="copiesrow_[% bibitemloo.biblionumber %]">
476
                    <tr class="copiesrow" id="copiesrow_[% bibitemloo.biblionumber %]">
450
                      <td>&nbsp;</td>
477
                      <td>&nbsp;</td>
Lines 527-532 Link Here
527
                  [% END %]<!-- bib_available -->
554
                  [% END %]<!-- bib_available -->
528
                  [% END %]<!-- OPACItemHolds -->
555
                  [% END %]<!-- OPACItemHolds -->
529
                [% END %]
556
                [% END %]
557
                </tbody>
530
              </table><!-- bibitemloop -->
558
              </table><!-- bibitemloop -->
531
              [% END %] <!-- if message -->
559
              [% END %] <!-- if message -->
532
            </div><!-- bigloop -->
560
            </div><!-- bigloop -->
533
- 

Return to bug 7825