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

(-)a/acqui/addorder.pl (-1 / +99 lines)
Lines 126-131 use C4::Auth; # get_template_and_user Link Here
126
use C4::Acquisition;	# NewOrder DelOrder ModOrder
126
use C4::Acquisition;	# NewOrder DelOrder ModOrder
127
use C4::Suggestions;	# ModStatus
127
use C4::Suggestions;	# ModStatus
128
use C4::Biblio;			# AddBiblio TransformKohaToMarc
128
use C4::Biblio;			# AddBiblio TransformKohaToMarc
129
use C4::Budgets;
129
use C4::Items;
130
use C4::Items;
130
use C4::Output;
131
use C4::Output;
131
132
Lines 135-141 use C4::Output; Link Here
135
# not just blindly call C4 functions and print a redirect.  
136
# not just blindly call C4 functions and print a redirect.  
136
137
137
my $input = new CGI;
138
my $input = new CGI;
138
### $input 
139
140
# Check if order total amount exceed allowed budget
141
my $confirm_budget_exceeding = $input->param('confirm_budget_exceeding');
142
unless($confirm_budget_exceeding) {
143
    my $budget_id = $input->param('budget_id');
144
    my $total = $input->param('total');
145
    my $budget = GetBudget($budget_id);
146
    my $budget_spent = GetBudgetSpent($budget_id);
147
    my $budget_ordered = GetBudgetOrdered($budget_id);
148
    my $budget_used = $budget_spent + $budget_ordered;
149
    my $budget_remaining = $budget->{budget_amount} - $budget_used;
150
    my $budget_encumbrance = $budget->{budget_amount} * $budget->{budget_encumb} / 100;
151
    my $budget_expenditure = $budget->{budget_expend};
152
153
    if ( $total > $budget_remaining
154
      || ( ($budget_encumbrance+0) && ($budget_used + $total) > $budget_encumbrance)
155
      || ( ($budget_expenditure+0) && ($budget_used + $total) > $budget_expenditure) )
156
    {
157
        my ($template, $loggedinuser, $cookie) = get_template_and_user({
158
            template_name   => "acqui/addorder.tmpl",
159
            query           => $input,
160
            type            => "intranet",
161
            authnotrequired => 0,
162
            flagsrequired   => {acquisition => 'order_manage'},
163
        });
164
165
        my $url = $input->referer();
166
        unless ( defined $url ) {
167
            my $basketno = $input->param('basketno');
168
            $url = "/cgi-bin/koha/acqui/basket.pl?basketno=$basketno";
169
        }
170
171
        my $vars = $input->Vars;
172
        my @vars_loop;
173
        foreach (keys %$vars) {
174
            unless($_ eq "field_value" || $_ eq "itemid" || $_ eq "kohafield" || $_ eq "tag" || $_ eq "subfield" || $_ eq "mandatory") {
175
                push @vars_loop, {
176
                    name => $_,
177
                    value => $vars->{$_},
178
                };
179
            }
180
        }
181
182
        my @field_value_loop;
183
        push @field_value_loop, {value => $_} for $input->param('field_value');
184
185
        my @itemid_loop;
186
        push @itemid_loop, {value => $_} for $input->param('itemid');
187
188
        my @kohafield_loop;
189
        push @kohafield_loop, {value => $_} for $input->param('kohafield');
190
191
        my @tag_loop;
192
        push @tag_loop, {value => $_} for $input->param('tag');
193
194
        my @subfield_loop;
195
        push @subfield_loop, {value => $_} for $input->param('subfield');
196
197
        my @mandatory_loop;
198
        push @mandatory_loop, {value => $_} for $input->param('mandatory');
199
200
        if( ($budget_encumbrance+0) && ($budget_used + $total) > $budget_encumbrance
201
          && $total <= $budget_remaining)
202
        {
203
            $template->param(
204
                encumbrance_exceeded => 1,
205
                encumbrance => sprintf("%.2f", $budget->{'budget_encumb'}),
206
            );
207
        }
208
        if( ($budget_expenditure+0) && ($budget_used + $total) > $budget_expenditure
209
          && $total <= $budget_remaining )
210
        {
211
            my $currency = GetCurrency;
212
            $template->param(
213
                expenditure_exceeded => 1,
214
                expenditure => sprintf("%.2f", $budget_expenditure),
215
                currency => ($currency) ? $currency->{'symbol'} : '',
216
            );
217
        }
218
        if($total > $budget_remaining){
219
            $template->param(budget_exceeded => 1);
220
        }
221
222
        $template->param(
223
            not_enough_budget => 1,
224
            referer => $url,
225
            vars_loop => \@vars_loop,
226
            field_value => \@field_value_loop,
227
            itemid => \@itemid_loop,
228
            kohafield => \@kohafield_loop,
229
            tag => \@tag_loop,
230
            subfield => \@subfield_loop,
231
            mandatory => \@mandatory_loop,
232
        );
233
        output_html_with_http_headers $input, $cookie, $template->output;
234
        exit;
235
    }
236
}
139
237
140
# get_template_and_user used only to check auth & get user id
238
# get_template_and_user used only to check auth & get user id
141
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
239
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
(-)a/admin/aqbudgets.pl (-1 / +1 lines)
Lines 137-143 if ($op eq 'add_form') { Link Here
137
        $dropbox_disabled = BudgetHasChildren($budget_id);
137
        $dropbox_disabled = BudgetHasChildren($budget_id);
138
        my $borrower = &GetMember( borrowernumber=>$budget->{budget_owner_id} );
138
        my $borrower = &GetMember( borrowernumber=>$budget->{budget_owner_id} );
139
        $budget->{budget_owner_name} = $borrower->{'firstname'} . ' ' . $borrower->{'surname'};
139
        $budget->{budget_owner_name} = $borrower->{'firstname'} . ' ' . $borrower->{'surname'};
140
        $$budget{$_}= sprintf("%.2f", $budget->{$_}) for grep{/amount/} keys %$budget;
140
        $$budget{$_}= sprintf("%.2f", $budget->{$_}) for grep{ /amount|encumb|expend/ } keys %$budget;
141
    }
141
    }
142
142
143
    # build budget hierarchy
143
    # build budget hierarchy
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorder.tt (+57 lines)
Line 0 Link Here
1
[% INCLUDE "doc-head-open.inc" %]
2
<title>Koha &rsaquo; Acquisition &rsaquo; Add order</title>
3
[% INCLUDE "doc-head-close.inc" %]
4
</head>
5
6
<body>
7
[% INCLUDE "header.inc" %]
8
9
<div id="doc3" class="yui-t7">
10
11
<div id="bd">
12
  <div id="yui-main">
13
    <div class="yui-b">
14
      [% IF (not_enough_budget) %]
15
        <form action="/cgi-bin/koha/acqui/addorder.pl" method="post">
16
          [% FOREACH var IN vars_loop %]
17
            <input type="hidden" name="[% var.name %]" value="[% var.value |html %]" />
18
          [% END %]
19
          [% FOREACH f IN field_value %]
20
            <input type="hidden" name="field_value" value="[% f.value %]" />
21
          [% END %]
22
          [% FOREACH i IN itemid %]
23
            <input type="hidden" name="itemid" value="[% i.value %]" />
24
          [% END %]
25
          [% FOREACH f IN kohafield %]
26
            <input type="hidden" name="kohafield" value="[% f.value %]" />
27
          [% END %]
28
          [% FOREACH t IN tag %]
29
            <input type="hidden" name="tag" value="[% value %]" />
30
          [% END %]
31
          [% FOREACH s IN subfield %]
32
            <input type="hidden" name="subfield" value="[% s.value %]" />
33
          [% END %]
34
          [% FOREACH m IN mandatory %]
35
            <input type="hidden" name="mandatory" value="[% m.value %]" />
36
          [% END %]
37
          <input type="hidden" name="confirm_budget_exceeding" value="1" />
38
          <div class="dialog">
39
            [% IF (budget_exceeded) %]
40
              <p>Warning! Order total amount exceeds allowed budget.</p>
41
            [% END %]
42
            [% IF (encumbrance_exceeded) %]
43
              <p>Warning! You will exceed [% encumbrance %]% of your fund.</p>
44
            [% END %]
45
            [% IF (expenditure_exceeded) %]
46
              <p>Warning! You will exceed maximum limit ([% expenditure %][% IF (currency) %] [% currency %][% END %]) for your fund.</p>
47
            [% END %]
48
            <p>Do you want to confirm this order?</p>
49
            <input type="submit" class="approve" value="Yes, I confirm" />
50
            <input type="button" class="deny" value="No, I don't confirm" onclick="window.location.href = '[% referer %]'" />
51
          </div>
52
        </form>
53
      [% END %]
54
    </div>
55
  </div>
56
</div>
57
[% INCLUDE "intranet-bottom.inc" %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt (-7 / +8 lines)
Lines 341-354 Link Here
341
    <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount %]" size="8" />
341
    <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount %]" size="8" />
342
    </li>
342
    </li>
343
343
344
    <li style="display:none;">
344
    <li>
345
    <label for="budget_encumb">Encumbrance: </label>
345
      <label for="budget_encumb">Warning at (%): </label>
346
    <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb %]" size="8" />
346
      <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb %]" size="10" />
347
      <span style="color:grey">0 to disable</span>
347
    </li>
348
    </li>
348
349
349
    <li style="display:none;">
350
    <li>
350
    <label for="budget_expend">Expenditure: </label>
351
      <label for="budget_expend">Warning at (amount): </label>
351
    <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend %]" size="8" />
352
      <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend %]" size="10" /><input type="hidden" name="budget_owner_id" id="budget_owner_id" value="[% budget_owner_id %]" />
353
      <span style="color:grey">0 to disable</span>
352
    </li>
354
    </li>
353
355
354
    <li>
356
    <li>
355
- 

Return to bug 9822