</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>
$('#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 %]
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} ) {
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,