push @foot_loop, map {$_} values %foot;
-my $budgets = GetBudgets();
-my @budgets_loop;
my $shipmentcost_budgetid = $details->{shipmentcost_budgetid};
-foreach my $budget (@$budgets) {
- next unless CanUserUseBudget( $loggedinuser, $budget, $flags );
- my %line = %{$budget};
- if ( $shipmentcost_budgetid
- and $budget->{budget_id} == $shipmentcost_budgetid )
- {
- $line{selected} = 1;
+
+# build budget list
+my $budget_loop = [];
+my $budgets = GetBudgetHierarchy();
+foreach my $r ( @{$budgets} ) {
+ next unless ( CanUserUseBudget( $loggedinuser, $r, $flags ) );
+
+ if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) {
+ next;
}
- push @budgets_loop, \%line;
+
+ my $selected = $shipmentcost_budgetid ? $r->{budget_id} eq $shipmentcost_budgetid : 0;
+
+ push @{$budget_loop},
+ {
+ b_id => $r->{budget_id},
+ b_txt => $r->{budget_name},
+ b_active => $r->{budget_period_active},
+ selected => $selected,
+ };
}
+@{$budget_loop} =
+ sort { uc( $a->{b_txt} ) cmp uc( $b->{b_txt} ) } @{$budget_loop};
+warn Data::Dumper::Dumper( $budget_loop );
+
my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({ invoiceid => $details->{'invoiceid'} });
if ( $adjustments ) { $template->param( adjustments => $adjustments ); }
$template->param(
- invoiceid => $details->{'invoiceid'},
- invoicenumber => $details->{'invoicenumber'},
- suppliername => $details->{'suppliername'},
- booksellerid => $details->{'booksellerid'},
- shipmentdate => $details->{'shipmentdate'},
- billingdate => $details->{'billingdate'},
- invoiceclosedate => $details->{'closedate'},
- shipmentcost => $shipmentcost,
- orders_loop => \@orders_loop,
- foot_loop => \@foot_loop,
- total_quantity => $total_quantity,
- total_tax_excluded => $total_tax_excluded,
- total_tax_included => $total_tax_included,
- total_tax_value => $total_tax_value,
+ invoiceid => $details->{'invoiceid'},
+ invoicenumber => $details->{'invoicenumber'},
+ suppliername => $details->{'suppliername'},
+ booksellerid => $details->{'booksellerid'},
+ shipmentdate => $details->{'shipmentdate'},
+ billingdate => $details->{'billingdate'},
+ invoiceclosedate => $details->{'closedate'},
+ shipmentcost => $shipmentcost,
+ orders_loop => \@orders_loop,
+ foot_loop => \@foot_loop,
+ total_quantity => $total_quantity,
+ total_tax_excluded => $total_tax_excluded,
+ total_tax_included => $total_tax_included,
+ total_tax_value => $total_tax_value,
total_tax_excluded_shipment => $total_tax_excluded + $shipmentcost,
total_tax_included_shipment => $total_tax_included + $shipmentcost,
- invoiceincgst => $bookseller->invoiceincgst,
- currency => Koha::Acquisition::Currencies->get_active,
- budgets_loop => \@budgets_loop,
+ invoiceincgst => $bookseller->invoiceincgst,
+ currency => Koha::Acquisition::Currencies->get_active,
+ budgets => $budget_loop,
);
defined( $invoice_files ) && $template->param( files => $invoice_files->GetFilesInfo() );
<li><label for="shipmentcost">Shipping cost:</label>
<input type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% shipmentcost | $Price on_editing => 1 %]" /></li>
- <li><label for="shipment_budget_id">Shipping fund:</label>
- <select id="shipment_budget_id" name="shipment_budget_id">
- <option value="">No fund</option>
- [% FOREACH budget IN budgets_loop %]
- [% IF ( budget.selected ) %]
- <option selected="selected" value="[% budget.budget_id | html %]">
- [% ELSE %]
- <option value="[% budget.budget_id | html %]">
- [% END %]
- [% budget.budget_name | html %]
- </option>
- [% END %]
- </select></li>
+
+ <li>
+ <label for="shipment_budget_id">Shipping fund: </label>
+ <select id="shipment_budget_id" name="shipment_budget_id">
+ <option value="">No fund</option>
+ [% FOREACH budget IN 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>
+ <label for="showallfunds" style="float:none;width:auto;"> Show inactive:</label>
+ <input type="checkbox" id="showallfunds" />
+
+ </li>
[% IF ( invoiceclosedate ) %]
<li><span class="label">Status:</span>
$("a.delete_adjustment").click(function(){
return ( confirm( _("Are you sure you want to delete this file ?") ) );
});
+
+ //keep a copy of all budgets before removing the inactives
+ var budgetId = $("#shipment_budget_id");
+ 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 %]