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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt (-108 / +26 lines)
Lines 2-7 Link Here
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE KohaDates %]
3
[% USE KohaDates %]
4
[% USE Branches %]
4
[% USE Branches %]
5
[% SET footerjs = 1 %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
6
<title>Koha &rsaquo; Acquisitions &rsaquo; Order staged MARC records
7
<title>Koha &rsaquo; Acquisitions &rsaquo; Order staged MARC records
7
[% IF ( batch_details ) %]
8
[% IF ( batch_details ) %]
Lines 12-119 Link Here
12
</title>
13
</title>
13
<style>#dataPreview { width : 80%; } @media (max-width: 767px) { #dataPreview { margin: 0; width : auto; } }</style>
14
<style>#dataPreview { width : 80%; } @media (max-width: 767px) { #dataPreview { margin: 0; width : auto; } }</style>
14
[% INCLUDE 'doc-head-close.inc' %]
15
[% INCLUDE 'doc-head-close.inc' %]
15
    [% Asset.js("js/acquisitions-menu.js") | $raw %]
16
    [% INCLUDE 'datatables.inc' %]
17
    [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
18
    [% Asset.js("js/acq.js") | $raw %]
19
    [% Asset.js("js/funds_sorts.js") | $raw %]
20
    <script>
21
        $(document).ready(function() {
22
            $("#files").dataTable($.extend(true, {}, dataTablesDefaults, {
23
                "aoColumnDefs": [
24
                    { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
25
                    { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
26
                    { "sType": "title-string", "aTargets" : [ "title-string" ] }
27
                ],
28
                "sPaginationType": "four_button",
29
                "aaSorting": []
30
            } ) );
31
32
            $("#records_to_import fieldset.rows div").hide();
33
            $('input:checkbox[name="import_record_id"]').change(function(){
34
                var container = $(this).parents("fieldset");
35
                if ( $(this).is(':checked') ) {
36
                    $(container).addClass("selected");
37
                    $(container).removeClass("unselected");
38
                    $(container).find("div").toggle(true);
39
                } else {
40
                    $(container).addClass("unselected");
41
                    $(container).removeClass("selected");
42
                    $(container).find("div").toggle(false);
43
                }
44
            } );
45
46
            $("input:checkbox").prop("checked", false);
47
            $("div.biblio.unselected select").prop('disabled', false);
48
            $("div.biblio.unselected input").prop('disabled', false);
49
50
            $("#checkAll").click(function(){
51
                $("#Aform").checkCheckboxes();
52
                $("input:checkbox[name='import_record_id']").change();
53
                return false;
54
            });
55
            $("#unCheckAll").click(function(){
56
                $("#Aform").unCheckCheckboxes();
57
                $("input:checkbox[name='import_record_id']").change();
58
                return false;
59
            });
60
61
            $("#Aform").on("submit", function(){
62
                if ( $("input:checkbox[name='import_record_id']:checked").length < 1 ) {
63
                    alert(_("There is no record selected"));
64
                    return false;
65
                }
66
67
                var error = 0;
68
                $("input:checkbox[name='import_record_id']:checked").parents('fieldset').find('input[name="quantity"]').each(function(){
69
                    if ( $(this).val().length < 1 || isNaN( $(this).val() ) ) {
70
                        error++;
71
                    }
72
                });
73
                if ( error > 0 ) {
74
                    alert(error + " " + _("quantity values are not filled in or are not numbers"));
75
                    return false;
76
77
                }
78
79
        if (! $("#all_budget_id").val() ) {
80
            // If there is no default fund
81
            var error = 0;
82
            $(".selected [name='budget_id']").each(function(){
83
            if (!$(this).val()) {
84
                error++;
85
            }
86
            });
87
            if ( error > 0 ) {
88
            alert(_("Some budgets are not defined in item records"));
89
            return false;
90
            }
91
        }
92
93
                return disableUnchecked($(this));
94
            });
95
            $('#tabs').tabs();
96
            $(".previewData").on("click", function(e){
97
                e.preventDefault();
98
                var ltitle = $(this).text();
99
                var page = $(this).attr("href");
100
                $("#dataPreviewLabel").text(ltitle);
101
                $("#dataPreview .modal-body").load(page + " div");
102
                $('#dataPreview').modal({show:true});
103
            });
104
            $("#dataPreview").on("hidden.bs.modal", function(){
105
                $("#dataPreviewLabel").html("");
106
                $("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
107
            });
108
        });
109
110
        function disableUnchecked(form){
111
            $("fieldset.biblio.unselected").each(function(){
112
                $(this).remove();
113
            });
114
            return 1;
115
        }
116
    </script>
117
</head>
16
</head>
118
17
119
<body id="acq_addorderiso2709" class="acq">
18
<body id="acq_addorderiso2709" class="acq">
Lines 211-217 Link Here
211
                            </li>
110
                            </li>
212
                            <li class="quantity">
111
                            <li class="quantity">
213
                                <label for="quantity_record_[% biblio.import_record_id | html %]" class="required">Quantity: </label>
112
                                <label for="quantity_record_[% biblio.import_record_id | html %]" class="required">Quantity: </label>
214
                                <input id="quantity_record_[% biblio.import_record_id | html %]" type="text" value="[% biblio.quantity.length ? biblio.quantity : 1 | html %]" name="quantity" />
113
                                <input id="quantity_record_[% biblio.import_record_id | html %]" type="text" pattern="[0-9]+" value="[% biblio.quantity.length ? biblio.quantity : 1 | html %]" name="quantity" />
114
                                <span class="required">Required</span>
215
                            </li>
115
                            </li>
216
                            <li class="price">
116
                            <li class="price">
217
                                <label for="price_record_[% biblio.import_record_id | html %]">Price: </label>
117
                                <label for="price_record_[% biblio.import_record_id | html %]">Price: </label>
Lines 220-233 Link Here
220
                            <li class="discount">
120
                            <li class="discount">
221
                                <label for="discount_record_[% biblio.import_record_id | html %]">Discount: </label>
121
                                <label for="discount_record_[% biblio.import_record_id | html %]">Discount: </label>
222
                                <input id="discount_record_[% biblio.import_record_id | html %]" type="text" value="[% biblio.discount | html %]" name="discount" size="6" /> %
122
                                <input id="discount_record_[% biblio.import_record_id | html %]" type="text" value="[% biblio.discount | html %]" name="discount" size="6" /> %
223
                                (If empty, discount rate from vendor will be used)
123
                                <div class="hint">If empty, discount rate from vendor will be used</div>
224
                            </li>
124
                            </li>
225
                            <li class="budget">
125
                            <li class="fund">
226
                                <label for="fund_record_[% biblio.import_record_id | html %]">Fund: </label>
227
                                [% IF ( close ) %]
126
                                [% IF ( close ) %]
228
                                  <input type="hidden" size="20" name="budget_id" value="[% budget_id | html %]" />[% Budget_name | html %]
127
                                    <label for="fund_record_[% biblio.import_record_id | html %]">Fund: </label>
128
                                    <input type="hidden" size="20" name="budget_id" value="[% budget_id | html %]" />[% Budget_name | html %]
229
                                [% ELSE %]
129
                                [% ELSE %]
230
                                  <select id="fund_record_[% biblio.import_record_id | html %]" size="1" name="budget_id">
130
                                    <label for="fund_record_[% biblio.import_record_id | html %]">Fund: </label>
131
                                    <select id="fund_record_[% biblio.import_record_id | html %]" size="1" name="budget_id">
231
                                    <option value="">Select a fund</option>
132
                                    <option value="">Select a fund</option>
232
                                    [% FOREACH budget IN budget_loop %]
133
                                    [% FOREACH budget IN budget_loop %]
233
                                        [% IF ( budget.b_id == biblio.budget_id ) %]
134
                                        [% IF ( budget.b_id == biblio.budget_id ) %]
Lines 243-248 Link Here
243
                                        [% END %]
144
                                        [% END %]
244
                                    [% END %]
145
                                    [% END %]
245
                                  </select>
146
                                  </select>
147
                                  <span class="required" style="display:none">Required</span>
246
                                [% END %]
148
                                [% END %]
247
                            </li>
149
                            </li>
248
                            <li class="sort1">
150
                            <li class="sort1">
Lines 525-528 Link Here
525
            </div> [% # /div.col-sm-6 %]
427
            </div> [% # /div.col-sm-6 %]
526
       </div> [% # /div.row %]
428
       </div> [% # /div.row %]
527
429
430
431
[% MACRO jsinclude BLOCK %]
432
    [% Asset.js("js/acquisitions-menu.js") | $raw %]
433
    [% INCLUDE 'datatables.inc' %]
434
    [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
435
    [% Asset.js("js/acq.js") | $raw %]
436
    [% Asset.js("js/funds_sorts.js") | $raw %]
437
    [% Asset.js("js/addorderiso2709.js") | $raw %]
438
    <script>
439
        var ERR_NO_RECORD_SELECTED = _("There is no record selected");
440
        var ERR_INVALID_QUANTITY = _("quantity values are not filled in or are not numbers");
441
        var ERR_FUNDS_MISSING = _("Some budgets are not defined in item records");
442
        var MSG_LOADING = _("Loading");
443
    </script>
444
[% END %]
445
528
[% INCLUDE 'intranet-bottom.inc' %]
446
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/addorderiso2709.js (-1 / +120 lines)
Line 0 Link Here
0
- 
1
/* global dataTablesDefaults ERR_NO_RECORD_SELECTED ERR_INVALID_QUANTITY ERR_FUNDS_MISSING MSG_LOADING */
2
3
$(document).ready(function() {
4
    $("#files").dataTable($.extend(true, {}, dataTablesDefaults, {
5
        "aoColumnDefs": [
6
            { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
7
            { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
8
            { "sType": "title-string", "aTargets" : [ "title-string" ] }
9
        ],
10
        "sPaginationType": "four_button",
11
        "aaSorting": []
12
    }) );
13
14
    var all_budget_id = $("#all_budget_id");
15
16
    if( !all_budget_id.val() ){
17
        $(".fund label, .fund select").addClass("required").prop("required", true);
18
        $(".fund span.required").show();
19
    }
20
21
    all_budget_id.on("change", function(){
22
        if( $(this).val() != "" ){
23
            $(".fund label, .fund select").removeClass("required").prop("required", false);
24
            $(".fund select").each(function(){
25
                if( $(this).val() == '' ){
26
                    $(this).val( all_budget_id.val() );
27
                }
28
            });
29
            $(".fund span.required").hide();
30
        } else {
31
            $(".fund label, .fund select").addClass("required").prop("required", true);
32
            $(".fund span.required").show();
33
        }
34
    });
35
36
    $("#records_to_import fieldset.rows div").hide();
37
    $('input:checkbox[name="import_record_id"]').change(function(){
38
        var container = $(this).parents("fieldset");
39
        if ( $(this).is(':checked') ) {
40
            $(container).addClass("selected");
41
            $(container).removeClass("unselected");
42
            $(container).find("div").toggle(true);
43
        } else {
44
            $(container).addClass("unselected");
45
            $(container).removeClass("selected");
46
            $(container).find("div").toggle(false);
47
        }
48
    } );
49
50
    $("input:checkbox").prop("checked", false);
51
    $("div.biblio.unselected select").prop('disabled', false);
52
    $("div.biblio.unselected input").prop('disabled', false);
53
54
    $("#checkAll").click(function(){
55
        $("#Aform").checkCheckboxes();
56
        $("input:checkbox[name='import_record_id']").change();
57
        return false;
58
    });
59
    $("#unCheckAll").click(function(){
60
        $("#Aform").unCheckCheckboxes();
61
        $("input:checkbox[name='import_record_id']").change();
62
        return false;
63
    });
64
65
    $("#Aform").on("submit", function(){
66
        if ( $("input:checkbox[name='import_record_id']:checked").length < 1 ) {
67
            alert( ERR_NO_RECORD_SELECTED );
68
            return false;
69
        }
70
71
        var error = 0;
72
        $("input:checkbox[name='import_record_id']:checked").parents('fieldset').find('input[name="quantity"]').each(function(){
73
            if ( $(this).val().length < 1 || isNaN( $(this).val() ) ) {
74
                error++;
75
            }
76
        });
77
        if ( error > 0 ) {
78
            alert( error + " " + ERR_INVALID_QUANTITY );
79
            return false;
80
81
        }
82
83
        if (! all_budget_id.val() ) {
84
            // If there is no default fund
85
            error = 0;
86
            $(".selected [name='budget_id']").each(function(){
87
                if (!$(this).val()) {
88
                    error++;
89
                }
90
            });
91
            if ( error > 0 ) {
92
                alert( ERR_FUNDS_MISSING );
93
                return false;
94
            }
95
        }
96
97
        return disableUnchecked($(this));
98
    });
99
100
    $('#tabs').tabs();
101
    $(".previewData").on("click", function(e){
102
        e.preventDefault();
103
        var ltitle = $(this).text();
104
        var page = $(this).attr("href");
105
        $("#dataPreviewLabel").text(ltitle);
106
        $("#dataPreview .modal-body").load(page + " div");
107
        $('#dataPreview').modal({show:true});
108
    });
109
    $("#dataPreview").on("hidden.bs.modal", function(){
110
        $("#dataPreviewLabel").html("");
111
        $("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> " + MSG_LOADING + "</div>");
112
    });
113
});
114
115
function disableUnchecked(){
116
    $("fieldset.biblio.unselected").each(function(){
117
        $(this).remove();
118
    });
119
    return 1;
120
}

Return to bug 22734