Bugzilla – Attachment 89791 Details for
Bug 22802
When ordering from a staged file, if funds are populated per item order level fund should not be required
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22802: Check item funds, order funds, and default funds when ordering from a file
Bug-22802-Check-item-funds-order-funds-and-default.patch (text/plain), 10.15 KB, created by
Liz Rea
on 2019-05-15 17:47:14 UTC
(
hide
)
Description:
Bug 22802: Check item funds, order funds, and default funds when ordering from a file
Filename:
MIME Type:
Creator:
Liz Rea
Created:
2019-05-15 17:47:14 UTC
Size:
10.15 KB
patch
obsolete
>From ec9a7c09256ae74d7ad067673d439f969d0545f1 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 14 May 2019 13:17:34 +0000 >Subject: [PATCH] Bug 22802: Check item funds, order funds, and default funds > when ordering from a file > >This patch tries to centralise the logic of order funds requirements into a single routine. >If propogates defaults down into items/order as necessary, it also prevents unsetting lower values if >a default is set. > >To test: >1 - Populate 'MarcItemFieldsToOrder' >2 - Add to a basket from a file >3 - Use a file containing some item records with funds defined or not >4 - Confirm if all items have funds defined, you can order >5 - Confirm that setting the default for an order populates items and you can order >6 - Confirm that setting the default for all orders populates items if present/ order if not >7 - Confirm that if defaults are set the lower levels cannot be unset >8 - Try various settings and confirm all work as expected > >Signed-off-by: Liz Rea <wizzyrea@gmail.com> >--- > .../prog/en/modules/acqui/addorderiso2709.tt | 9 ++- > koha-tmpl/intranet-tmpl/prog/js/addorderiso2709.js | 94 +++++++++++++++------- > 2 files changed, 68 insertions(+), 35 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt >index 9947df5704..ebf19684b0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt >@@ -129,7 +129,7 @@ > [% ELSE %] > <label for="fund_record_[% biblio.import_record_id | html %]">Fund: </label> > <select id="fund_record_[% biblio.import_record_id | html %]" size="1" name="budget_id"> >- <option value="">Select a fund</option> >+ <option value="">Select a fund (will use default if set)</option> > [% FOREACH budget IN budget_loop %] > [% IF ( budget.b_id == biblio.budget_id ) %] > [% IF budget.b_active %] >@@ -225,14 +225,15 @@ > </li> > <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> > <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> >- <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 %]"> >- <option value="">Select a fund</option> >+ <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 %]"> >+ <option value="">Select a fund (will use default if set)</option> > [% FOREACH budget_loo IN budget_loop %] > [% IF ( budget_loo.b_id ) == ( item.budget_id ) %]<option value="[% budget_loo.b_id | html %]" selected="selected">[% budget_loo.b_txt | html %]</option> > [% ELSE %]<option value="[% budget_loo.b_id | html %]">[% budget_loo.b_txt | html %]</option> > [% END %] > [% END %] > </select> >+ <span class="item_fund required">Required</span> > </li> > <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> > <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> >@@ -339,7 +340,7 @@ > <li> > <label for="all_budget_id">Fund: </label> > <select id="all_budget_id" size="1" name="all_budget_id"> >- <option value="">Select a fund</option> >+ <option value="">Select a fund (will populate orders/items if set)</option> > [% FOREACH budget_loo IN budget_loop %] > [% 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> > [% 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> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/addorderiso2709.js b/koha-tmpl/intranet-tmpl/prog/js/addorderiso2709.js >index 721d79fd56..36ce185bb6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/addorderiso2709.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/addorderiso2709.js >@@ -11,26 +11,11 @@ $(document).ready(function() { > "aaSorting": [] > }) ); > >+ checkOrderBudgets(); > var all_budget_id = $("#all_budget_id"); > >- if( !all_budget_id.val() ){ >- $(".fund label, .fund select").addClass("required").prop("required", true); >- $(".fund span.required").show(); >- } >- >- all_budget_id.on("change", function(){ >- if( $(this).val() != "" ){ >- $(".fund label, .fund select").removeClass("required").prop("required", false); >- $(".fund select").each(function(){ >- if( $(this).val() == '' ){ >- $(this).val( all_budget_id.val() ); >- } >- }); >- $(".fund span.required").hide(); >- } else { >- $(".fund label, .fund select").addClass("required").prop("required", true); >- $(".fund span.required").show(); >- } >+ $("#all_budget_id,[name='budget_id'],.budget_code_item,[name='import_record_id']").on("change", function(){ >+ checkOrderBudgets(); > }); > > $("#records_to_import fieldset.rows div").hide(); >@@ -80,18 +65,10 @@ $(document).ready(function() { > > } > >- if (! all_budget_id.val() ) { >- // If there is no default fund >- error = 0; >- $(".selected [name='budget_id']").each(function(){ >- if (!$(this).val()) { >- error++; >- } >- }); >- if ( error > 0 ) { >- alert( ERR_FUNDS_MISSING ); >- return false; >- } >+ error = checkOrderBudgets(); >+ if ( error > 0 ) { >+ alert( ERR_FUNDS_MISSING ); >+ return false; > } > > return disableUnchecked($(this)); >@@ -117,4 +94,59 @@ function disableUnchecked(){ > $(this).remove(); > }); > return 1; >-} >\ No newline at end of file >+} >+ >+function checkOrderBudgets(){ >+ var unset_funds = 0; >+ var all_budget_id = $("#all_budget_id"); >+ // If we don't have an overarching default set we need to check each selected order >+ if ( !all_budget_id.val() ) { >+ $("fieldset.biblio.rows.selected").each(function(){ >+ var default_order_fund = $(this).find("[name='budget_id']"); >+ // For each order we see if budget is set for order >+ if( !default_order_fund.val() ){ >+ $(this).find(".item_fund.required").show(); >+ //If not we need to check each item on the order >+ var item_funds = $(this).find(".budget_code_item"); >+ if( item_funds.length ){ >+ item_funds.each(function(){ >+ if( !$(this).val() ){ >+ $(this).addClass('required').prop("required", true); >+ unset_funds++; >+ } else { >+ $(this).removeClass('required').prop("required", false); >+ } >+ }); >+ } else { >+ //If the order has no items defined then the order level fund is required >+ default_order_fund.addClass('required').prop("required", true); >+ $(this).find(".fund span.required").show(); >+ $(this).find(".item_fund.required").hide(); >+ unset_funds++; >+ } >+ } else { >+ $(this).find(".fund span.required").hide(); >+ // If fund is set for order then none of the others are required >+ $(this).find(".budget_code_item").each(function(){ >+ if( !$(this).val() ){ >+ $(this).val( default_order_fund.val() ); >+ $(this).removeClass('required').prop("required", false); >+ } >+ }); >+ $(this).removeClass('required').prop("required", false); >+ } >+ }); >+ } else { >+ // Default is set overall, we just need to populate it through >+ // to each order/item >+ $("[name='budget_id'],.budget_code_item").each(function(){ >+ if( !$(this).val() ){ >+ $(this).val( all_budget_id.val() ); >+ $(this).removeClass('required').prop("required", false); >+ $(".item_fund.required").hide(); >+ $(".fund span.required").hide(); >+ } >+ }); >+ } >+ return unset_funds; >+} >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22802
:
89744
|
89745
|
89791
|
90035