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

(-)a/acqui/invoice.pl (-27 / +40 lines)
Lines 187-229 foreach my $order (@$orders) { Link Here
187
187
188
push @foot_loop, map {$_} values %foot;
188
push @foot_loop, map {$_} values %foot;
189
189
190
my $budgets = GetBudgets();
191
my @budgets_loop;
192
my $shipmentcost_budgetid = $details->{shipmentcost_budgetid};
190
my $shipmentcost_budgetid = $details->{shipmentcost_budgetid};
193
foreach my $budget (@$budgets) {
191
194
    next unless CanUserUseBudget( $loggedinuser, $budget, $flags );
192
# build budget list
195
    my %line = %{$budget};
193
my $budget_loop = [];
196
    if (    $shipmentcost_budgetid
194
my $budgets     = GetBudgetHierarchy();
197
        and $budget->{budget_id} == $shipmentcost_budgetid )
195
foreach my $r ( @{$budgets} ) {
198
    {
196
    next unless ( CanUserUseBudget( $loggedinuser, $r, $flags ) );
199
        $line{selected} = 1;
197
198
    if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) {
199
        next;
200
    }
200
    }
201
    push @budgets_loop, \%line;
201
202
    my $selected = $shipmentcost_budgetid ? $r->{budget_id} eq $shipmentcost_budgetid : 0;
203
204
    push @{$budget_loop},
205
      {
206
        b_id     => $r->{budget_id},
207
        b_txt    => $r->{budget_name},
208
        b_active => $r->{budget_period_active},
209
        selected => $selected,
210
      };
202
}
211
}
203
212
213
@{$budget_loop} =
214
  sort { uc( $a->{b_txt} ) cmp uc( $b->{b_txt} ) } @{$budget_loop};
215
warn Data::Dumper::Dumper( $budget_loop );
216
204
my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({ invoiceid => $details->{'invoiceid'} });
217
my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({ invoiceid => $details->{'invoiceid'} });
205
if ( $adjustments ) { $template->param( adjustments => $adjustments ); }
218
if ( $adjustments ) { $template->param( adjustments => $adjustments ); }
206
219
207
$template->param(
220
$template->param(
208
    invoiceid        => $details->{'invoiceid'},
221
    invoiceid                   => $details->{'invoiceid'},
209
    invoicenumber    => $details->{'invoicenumber'},
222
    invoicenumber               => $details->{'invoicenumber'},
210
    suppliername     => $details->{'suppliername'},
223
    suppliername                => $details->{'suppliername'},
211
    booksellerid     => $details->{'booksellerid'},
224
    booksellerid                => $details->{'booksellerid'},
212
    shipmentdate     => $details->{'shipmentdate'},
225
    shipmentdate                => $details->{'shipmentdate'},
213
    billingdate      => $details->{'billingdate'},
226
    billingdate                 => $details->{'billingdate'},
214
    invoiceclosedate => $details->{'closedate'},
227
    invoiceclosedate            => $details->{'closedate'},
215
    shipmentcost     => $shipmentcost,
228
    shipmentcost                => $shipmentcost,
216
    orders_loop      => \@orders_loop,
229
    orders_loop                 => \@orders_loop,
217
    foot_loop        => \@foot_loop,
230
    foot_loop                   => \@foot_loop,
218
    total_quantity   => $total_quantity,
231
    total_quantity              => $total_quantity,
219
    total_tax_excluded => $total_tax_excluded,
232
    total_tax_excluded          => $total_tax_excluded,
220
    total_tax_included => $total_tax_included,
233
    total_tax_included          => $total_tax_included,
221
    total_tax_value  => $total_tax_value,
234
    total_tax_value             => $total_tax_value,
222
    total_tax_excluded_shipment => $total_tax_excluded + $shipmentcost,
235
    total_tax_excluded_shipment => $total_tax_excluded + $shipmentcost,
223
    total_tax_included_shipment => $total_tax_included + $shipmentcost,
236
    total_tax_included_shipment => $total_tax_included + $shipmentcost,
224
    invoiceincgst    => $bookseller->invoiceincgst,
237
    invoiceincgst               => $bookseller->invoiceincgst,
225
    currency         => Koha::Acquisition::Currencies->get_active,
238
    currency                    => Koha::Acquisition::Currencies->get_active,
226
    budgets_loop     => \@budgets_loop,
239
    budgets                     => $budget_loop,
227
);
240
);
228
241
229
defined( $invoice_files ) && $template->param( files => $invoice_files->GetFilesInfo() );
242
defined( $invoice_files ) && $template->param( files => $invoice_files->GetFilesInfo() );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt (-14 / +33 lines)
Lines 47-65 Link Here
47
47
48
            <li><label for="shipmentcost">Shipping cost:</label>
48
            <li><label for="shipmentcost">Shipping cost:</label>
49
                    <input type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% shipmentcost | $Price on_editing => 1 %]" /></li>
49
                    <input type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% shipmentcost | $Price on_editing => 1 %]" /></li>
50
            <li><label for="shipment_budget_id">Shipping fund:</label>
50
51
                    <select id="shipment_budget_id" name="shipment_budget_id">
51
        <li>
52
                        <option value="">No fund</option>
52
            <label for="shipment_budget_id">Shipping fund: </label>
53
                      [% FOREACH budget IN budgets_loop %]
53
            <select id="shipment_budget_id" name="shipment_budget_id">
54
                        [% IF ( budget.selected ) %]
54
                <option value="">No fund</option>
55
                          <option selected="selected" value="[% budget.budget_id | html %]">
55
                [% FOREACH budget IN budgets %]
56
                        [% ELSE %]
56
                    [% IF ( budget.selected ) %]
57
                          <option value="[% budget.budget_id | html %]">
57
                        <option value="[% budget.b_id | html %]" selected="selected">[% budget.b_txt | html %] [% IF ( !budget.b_active ) %](inactive)[% END %]</option>
58
                        [% END %]
58
                    [% ELSIF ( budget.b_active ) %]
59
                          [% budget.budget_name | html %]
59
                        <option value="[% budget.b_id | html %]">[% budget.b_txt | html %]</option>
60
                        </option>
60
                    [% ELSE %]
61
                      [% END %]
61
                        <option value="[% budget.b_id | html %]" class="b_inactive">[% budget.b_txt | html %] (inactive)</option>
62
                    </select></li>
62
                    [% END %]
63
                [% END %]
64
            </select>
65
            <label for="showallfunds" style="float:none;width:auto;">&nbsp;Show inactive:</label>
66
            <input type="checkbox" id="showallfunds" />
67
68
        </li>
63
69
64
            [% IF ( invoiceclosedate ) %]
70
            [% IF ( invoiceclosedate ) %]
65
            <li><span class="label">Status:</span>
71
            <li><span class="label">Status:</span>
Lines 423-428 Link Here
423
            $("a.delete_adjustment").click(function(){
429
            $("a.delete_adjustment").click(function(){
424
                return ( confirm( _("Are you sure you want to delete this file ?") ) );
430
                return ( confirm( _("Are you sure you want to delete this file ?") ) );
425
            });
431
            });
432
433
            //keep a copy of all budgets before removing the inactives
434
            var budgetId = $("#shipment_budget_id");
435
            var disabledBudgetsCopy = budgetId.html();
436
            $('.b_inactive').remove();
437
438
            $('#showallfunds').click(function() {
439
                if ($(this).is(":checked")) {
440
                    budgetId.html(disabledBudgetsCopy); //Puts back all the funds
441
                }
442
                else {
443
                    $('.b_inactive').remove();
444
                }
445
            });
426
        });
446
        });
427
    </script>
447
    </script>
428
[% END %]
448
[% END %]
429
- 

Return to bug 14850