Bug 11176: Add active switch on budgets select in suggestions
When creating a new purchase suggestion, all funds display and are available for selection. The behaviour of this drop-down menu should mirror that of those drop-down menus elsewhere in acquisitions, where only funds that are linked to active budgets display to the user. This patch add the active switch based on what exists in acqui/invoice.tt and acqui/invoice.pl. Looks like actually in suggestion.pl budgets list was fetches with GetBudgets(). But this is for the filter in 'Acquisition information'. Budgets selection on suggestion creation/edition must use GetBudgetHierarchy(), like in acqui/invoice.pl, in order to have the actif status. Test plan : 1) Create a budget periods active B1 with a fund F1 2) Create a budget periods inactive B2 with a fund F2 3) Go to suggestions module 4) Create a new suggestion 5) Check you see only active fund F1 6) Click on 'Show inactive' 7) Check you see also 'F2 (inactive)' 8) Choose fund F1 and save 9) Select the suggestion and edit 10) Check fund F1 is selected 11) Come back to suggestion table 12) Check filter 'Book fund' under 'Acquisition information' contains all funds Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
80993795dd
commit
8dca36661d
|
|
@ -447,10 +447,21 @@
|
|||
</li>
|
||||
<li><label for="budgetid">Fund:</label>
|
||||
<select name="budgetid" id="budgetid">
|
||||
<option value="">Any</option>[% FOREACH budgetsloo IN budgetsloop %]
|
||||
[% IF ( budgetsloo.selected ) %]<option value="[% budgetsloo.budget_id | html %]" selected="selected">[% budgetsloo.budget_name | html %]</option>[% ELSE %]<option value="[% budgetsloo.budget_id | html %]">[% budgetsloo.budget_name | html %]</option>[% END %][% END %]
|
||||
<option value="">Any</option>
|
||||
[% FOREACH budget IN sugg_budgets %]
|
||||
[% IF ( budget.selected ) %]
|
||||
<option value="[% budget.b_id | html %]" selected="selected">[% budget.b_txt | html %] [% IF ( !budget.b_active ) %](inactive)[% END %]</option>
|
||||
[% ELSIF ( budget.b_active ) %]
|
||||
<option value="[% budget.b_id | html %]">[% budget.b_txt | html %]</option>
|
||||
[% ELSE %]
|
||||
<option value="[% budget.b_id | html %]" class="b_inactive">[% budget.b_txt | html %] (inactive)</option>
|
||||
[% END %]
|
||||
[% END %]
|
||||
</select>
|
||||
</li><li><label for="quantity">Copies:</label>
|
||||
<label for="showallfunds" style="float:none;width:auto;"> Show inactive:</label>
|
||||
<input type="checkbox" id="showallfunds" />
|
||||
</li>
|
||||
<li><label for="quantity">Copies:</label>
|
||||
<input type="text" size="10" id="quantity" name="quantity" value="[% quantity | html %]" />
|
||||
</li>
|
||||
<li>
|
||||
|
|
@ -1186,6 +1197,20 @@
|
|||
$('#notify').prop('checked', false).prop('disabled', true);
|
||||
});
|
||||
|
||||
//keep a copy of all budgets before removing the inactives
|
||||
var budgetId = $("form#add_edit #budgetid");
|
||||
var disabledBudgetsCopy = budgetId.html();
|
||||
$('.b_inactive').remove();
|
||||
|
||||
$('#showallfunds').click(function() {
|
||||
if ($(this).is(":checked")) {
|
||||
budgetId.html(disabledBudgetsCopy); //Puts back all the funds
|
||||
}
|
||||
else {
|
||||
$('.b_inactive').remove();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
|
|
|||
|
|
@ -407,7 +407,7 @@ $template->param( returnsuggestedby => $returnsuggestedby );
|
|||
my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG");
|
||||
$template->param(patron_reason_loop=>$patron_reason_loop);
|
||||
|
||||
#Budgets management
|
||||
# Budgets for filtering
|
||||
my $budgets = GetBudgets;
|
||||
my @budgets_loop;
|
||||
foreach my $budget ( @{$budgets} ) {
|
||||
|
|
@ -420,8 +420,25 @@ foreach my $budget ( @{$budgets} ) {
|
|||
|
||||
push @budgets_loop, $budget;
|
||||
}
|
||||
|
||||
$template->param( budgetsloop => \@budgets_loop);
|
||||
|
||||
# Budgets for suggestion add or edition
|
||||
my $sugg_budget_loop = [];
|
||||
my $sugg_budgets = GetBudgetHierarchy();
|
||||
foreach my $r ( @{$sugg_budgets} ) {
|
||||
next unless ( CanUserUseBudget( $borrowernumber, $r, $userflags ) );
|
||||
my $selected = ( $$suggestion_ref{budgetid} && $r->{budget_id} eq $$suggestion_ref{budgetid} ) ? 1 : 0;
|
||||
push @{$sugg_budget_loop},
|
||||
{
|
||||
b_id => $r->{budget_id},
|
||||
b_txt => $r->{budget_name},
|
||||
b_active => $r->{budget_period_active},
|
||||
selected => $selected,
|
||||
};
|
||||
}
|
||||
@{$sugg_budget_loop} = sort { uc( $a->{b_txt} ) cmp uc( $b->{b_txt} ) } @{$sugg_budget_loop};
|
||||
$template->param( sugg_budgets => $sugg_budget_loop);
|
||||
|
||||
if( $suggestion_ref->{STATUS} ) {
|
||||
$template->param(
|
||||
"statusselected_".$suggestion_ref->{STATUS} => 1,
|
||||
|
|
|
|||
Loading…
Reference in New Issue