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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt (-4 / +5 lines)
Lines 129-135 Link Here
129
                                [% ELSE %]
129
                                [% ELSE %]
130
                                    <label for="fund_record_[% biblio.import_record_id | html %]">Fund: </label>
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">
131
                                    <select id="fund_record_[% biblio.import_record_id | html %]" size="1" name="budget_id">
132
                                    <option value="">Select a fund</option>
132
                                    <option value="">Select a fund (will use default if set)</option>
133
                                    [% FOREACH budget IN budget_loop %]
133
                                    [% FOREACH budget IN budget_loop %]
134
                                        [% IF ( budget.b_id == biblio.budget_id ) %]
134
                                        [% IF ( budget.b_id == biblio.budget_id ) %]
135
                                          [% IF budget.b_active %]
135
                                          [% IF budget.b_active %]
Lines 225-238 Link Here
225
                        </li>
225
                        </li>
226
                        <li><label for="uri_item_[% item.item_id | html %]">uri</label><input type="text" id="uri_item_[% item.item_id | html %]" name="uri_[% item.biblio_count | html %]" value="[% item.uri | html %]"></li>
226
                        <li><label for="uri_item_[% item.item_id | html %]">uri</label><input type="text" id="uri_item_[% item.item_id | html %]" name="uri_[% item.biblio_count | html %]" value="[% item.uri | html %]"></li>
227
                        <li><label for="copyno_item_[% item.item_id | html %]">copyno</label><input type="text" id="copyno_item_[% item.item_id | html %]" name="copyno_[% item.biblio_count | html %]" value="[% item.copyno | html %]"></li>
227
                        <li><label for="copyno_item_[% item.item_id | html %]">copyno</label><input type="text" id="copyno_item_[% item.item_id | html %]" name="copyno_[% item.biblio_count | html %]" value="[% item.copyno | html %]"></li>
228
                        <li><label for="budget_code_item_[% item.item_id | html %]">budget_code</label><select id="budget_code_item_[% item.item_id | html %]" name="budget_code_[% item.biblio_count | html %]">
228
                        <li><label for="budget_code_item_[% item.item_id | html %]">budget_code</label><select class="budget_code_item" id="budget_code_item_[% item.item_id | html %]" name="budget_code_[% item.biblio_count | html %]">
229
                        <option value="">Select a fund</option>
229
                        <option value="">Select a fund (will use default if set)</option>
230
                        [% FOREACH budget_loo IN budget_loop %]
230
                        [% FOREACH budget_loo IN budget_loop %]
231
                            [% IF ( budget_loo.b_id ) == ( item.budget_id ) %]<option value="[% budget_loo.b_id | html %]" selected="selected">[% budget_loo.b_txt | html %]</option>
231
                            [% IF ( budget_loo.b_id ) == ( item.budget_id ) %]<option value="[% budget_loo.b_id | html %]" selected="selected">[% budget_loo.b_txt | html %]</option>
232
                            [% ELSE %]<option value="[% budget_loo.b_id | html %]">[% budget_loo.b_txt | html %]</option>
232
                            [% ELSE %]<option value="[% budget_loo.b_id | html %]">[% budget_loo.b_txt | html %]</option>
233
                            [% END %]
233
                            [% END %]
234
                        [% END %]
234
                        [% END %]
235
                        </select>
235
                        </select>
236
                        <span class="item_fund required">Required</span>
236
                        </li>
237
                        </li>
237
                        <li><label for="price_item_[% item.item_id | html %]">price</label><input type="text" id="price_item_[% item.item_id | html %]" name="itemprice_[% item.biblio_count | html %]" value="[% item.itemprice | html %]"></li>
238
                        <li><label for="price_item_[% item.item_id | html %]">price</label><input type="text" id="price_item_[% item.item_id | html %]" name="itemprice_[% item.biblio_count | html %]" value="[% item.itemprice | html %]"></li>
238
                        <li><label for="replacementprice_item_[% item.item_id | html %]">replacement price</label><input type="text" id="replacementprice_item_[% item.item_id | html %]" name="replacementprice_[% item.biblio_count | html %]" value="[% item.replacementprice | html %]"></li>
239
                        <li><label for="replacementprice_item_[% item.item_id | html %]">replacement price</label><input type="text" id="replacementprice_item_[% item.item_id | html %]" name="replacementprice_[% item.biblio_count | html %]" value="[% item.replacementprice | html %]"></li>
Lines 339-345 Link Here
339
                                        <li>
340
                                        <li>
340
                                            <label for="all_budget_id">Fund: </label>
341
                                            <label for="all_budget_id">Fund: </label>
341
                                            <select id="all_budget_id" size="1" name="all_budget_id">
342
                                            <select id="all_budget_id" size="1" name="all_budget_id">
342
                                              <option value="">Select a fund</option>
343
                                              <option value="">Select a fund (will populate orders/items if set)</option>
343
                                            [% FOREACH budget_loo IN budget_loop %]
344
                                            [% FOREACH budget_loo IN budget_loop %]
344
                                                [% IF ( budget_loo.b_active ) %]<option value="[% budget_loo.b_id | html %]" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]">[% budget_loo.b_txt | html %]</option>
345
                                                [% IF ( budget_loo.b_active ) %]<option value="[% budget_loo.b_id | html %]" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]">[% budget_loo.b_txt | html %]</option>
345
                                                [% ELSE %]<option value="[% budget_loo.b_id | html %]" class="b_inactive" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]">[% budget_loo.b_txt | html %] (inactive)</option>
346
                                                [% ELSE %]<option value="[% budget_loo.b_id | html %]" class="b_inactive" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]">[% budget_loo.b_txt | html %] (inactive)</option>
(-)a/koha-tmpl/intranet-tmpl/prog/js/addorderiso2709.js (-33 / +67 lines)
Lines 11-36 $(document).ready(function() { Link Here
11
        "aaSorting": []
11
        "aaSorting": []
12
    }) );
12
    }) );
13
13
14
    checkOrderBudgets();
14
    var all_budget_id = $("#all_budget_id");
15
    var all_budget_id = $("#all_budget_id");
15
16
    
16
    if( !all_budget_id.val() ){
17
    $("#all_budget_id,[name='budget_id'],.budget_code_item,[name='import_record_id']").on("change", function(){
17
        $(".fund label, .fund select").addClass("required").prop("required", true);
18
        checkOrderBudgets();
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
    });
19
    });
35
20
36
    $("#records_to_import fieldset.rows div").hide();
21
    $("#records_to_import fieldset.rows div").hide();
Lines 80-97 $(document).ready(function() { Link Here
80
65
81
        }
66
        }
82
67
83
        if (! all_budget_id.val() ) {
68
        error = checkOrderBudgets();
84
            // If there is no default fund
69
        if ( error > 0 ) {
85
            error = 0;
70
            alert( ERR_FUNDS_MISSING );
86
            $(".selected [name='budget_id']").each(function(){
71
            return false;
87
                if (!$(this).val()) {
88
                    error++;
89
                }
90
            });
91
            if ( error > 0 ) {
92
                alert( ERR_FUNDS_MISSING );
93
                return false;
94
            }
95
        }
72
        }
96
73
97
        return disableUnchecked($(this));
74
        return disableUnchecked($(this));
Lines 117-120 function disableUnchecked(){ Link Here
117
        $(this).remove();
94
        $(this).remove();
118
    });
95
    });
119
    return 1;
96
    return 1;
120
}
97
}
98
99
function checkOrderBudgets(){
100
    var unset_funds = 0;
101
    var all_budget_id = $("#all_budget_id");
102
    // If we don't have an overarching default set we need to check each selected order
103
    if ( !all_budget_id.val() ) {
104
        $("fieldset.biblio.rows.selected").each(function(){
105
            var default_order_fund = $(this).find("[name='budget_id']");
106
            // For each order we see if budget is set for order
107
            if( !default_order_fund.val() ){
108
                $(this).find(".item_fund.required").show();
109
                //If not we need to check each item on the order
110
                var item_funds = $(this).find(".budget_code_item");
111
                if( item_funds.length ){
112
                    item_funds.each(function(){
113
                        if( !$(this).val() ){
114
                            $(this).addClass('required').prop("required", true);
115
                            unset_funds++;
116
                        } else {
117
                            $(this).removeClass('required').prop("required", false);
118
                        }
119
                    });
120
                } else {
121
                    //If the order has no items defined then the order level fund is required
122
                    default_order_fund.addClass('required').prop("required", true);
123
                    $(this).find(".fund span.required").show();
124
                    $(this).find(".item_fund.required").hide();
125
                    unset_funds++;
126
                }
127
            } else {
128
                $(this).find(".fund span.required").hide();
129
                // If fund is set for order then none of the others are required
130
                $(this).find(".budget_code_item").each(function(){
131
                    if( !$(this).val() ){
132
                        $(this).val( default_order_fund.val() );
133
                        $(this).removeClass('required').prop("required", false);
134
                    }
135
                });
136
                $(this).removeClass('required').prop("required", false);
137
            }
138
        });
139
    } else {
140
        // Default is set overall, we just need to populate it through
141
        // to each order/item
142
        $("[name='budget_id'],.budget_code_item").each(function(){
143
            if( !$(this).val() ){
144
                $(this).val( all_budget_id.val() );
145
                $(this).removeClass('required').prop("required", false);
146
                $(".item_fund.required").hide();
147
                $(".fund span.required").hide();
148
            }
149
        });
150
    }
151
    return unset_funds;
152
}
153
        
154
155
121
- 

Return to bug 22802