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

(-)a/admin/aqbudgetperiods.pl (-8 / +22 lines)
Lines 127-147 elsif ( $op eq 'add_validate' ) { Link Here
127
#--------------------------------------------------
127
#--------------------------------------------------
128
elsif ( $op eq 'delete_confirm' ) {
128
elsif ( $op eq 'delete_confirm' ) {
129
## delete a budget period (preparation)
129
## delete a budget period (preparation)
130
    my $dbh = C4::Context->dbh;
130
    my $funds = GetBudgets({ budget_period_id => $budget_period_id });
131
    ## $total = number of records linked to the record that must be deleted
131
    my $fund_count = scalar @$funds;
132
    if ( $fund_count > 0 ) {
133
        $template->param( funds_exist => 1 );
134
    }
135
136
    #$total = number of records linked to the record that must be deleted
132
    my $total = 0;
137
    my $total = 0;
133
    my $data = GetBudgetPeriod( $budget_period_id);
138
    my $data = GetBudgetPeriod( $budget_period_id);
134
135
    $template->param(
139
    $template->param(
136
		%$data
140
        %$data
137
    );
141
    );
138
}
142
}
139
143
140
elsif ( $op eq 'delete_confirmed' ) {
144
elsif ( $op eq 'delete_confirmed' ) {
141
## delete the budget period record
145
    ## confirm no funds have been added to budget
142
146
    my $funds = GetBudgets({ budget_period_id => $budget_period_id });
143
    my $data = GetBudgetPeriod( $budget_period_id);
147
    my $fund_count = scalar @$funds;
144
    DelBudgetPeriod($budget_period_id);
148
    if ( $fund_count > 0 ) {
149
        $template->param( failed_delete_funds_exist => 1 );
150
    } else {
151
        ## delete the budget period record
152
        my $data = GetBudgetPeriod( $budget_period_id);
153
        DelBudgetPeriod($budget_period_id);
154
    }
145
	$op='else';
155
	$op='else';
146
}
156
}
147
157
Lines 263-268 my @period_active_loop; Link Here
263
foreach my $result ( @{$results} ) {
273
foreach my $result ( @{$results} ) {
264
    my $budgetperiod = $result;
274
    my $budgetperiod = $result;
265
    $budgetperiod->{budget_active} = 1;
275
    $budgetperiod->{budget_active} = 1;
276
    my $funds = GetBudgets({ budget_period_id => $budgetperiod->{budget_period_id} });
277
    $budgetperiod->{count} = scalar @$funds;
266
    push( @period_active_loop, $budgetperiod );
278
    push( @period_active_loop, $budgetperiod );
267
}
279
}
268
280
Lines 276-281 my @period_inactive_loop; Link Here
276
foreach my $result ( @{$results} ) {
288
foreach my $result ( @{$results} ) {
277
    my $budgetperiod = $result;
289
    my $budgetperiod = $result;
278
    $budgetperiod->{budget_active} = 1;
290
    $budgetperiod->{budget_active} = 1;
291
    my $funds = GetBudgets({ budget_period_id => $budgetperiod->{budget_period_id} });
292
    $budgetperiod->{count} = scalar @$funds;
279
    push( @period_inactive_loop, $budgetperiod );
293
    push( @period_inactive_loop, $budgetperiod );
280
}
294
}
281
295
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt (-14 / +27 lines)
Lines 3-26 Link Here
3
3
4
[%- BLOCK action_menu %]
4
[%- BLOCK action_menu %]
5
    <div class="dropdown">
5
    <div class="dropdown">
6
        <a class="btn btn-default btn-xs dropdown-toggle" id="budgetmenu_[% block_budget_id %]" role="button" data-toggle="dropdown" href="#">
6
        <a class="btn btn-default btn-xs dropdown-toggle" id="budgetmenu_[% block_budget.budget_period_id %]" role="button" data-toggle="dropdown" href="#">
7
           Actions <b class="caret"></b>
7
           Actions <b class="caret"></b>
8
        </a>
8
        </a>
9
        <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetmenu_[% block_budget_id %]">
9
        <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetmenu_[% block_budget.budget_period_id %]">
10
              <li>
10
              <li>
11
                  <a href="[% script_name %]?op=add_form&amp;budget_period_id=[% block_budget_id |html %]"><i class="fa fa-pencil"></i> Edit</a>
11
                  <a href="[% script_name %]?op=add_form&amp;budget_period_id=[% block_budget.budget_period_id |html %]"><i class="fa fa-pencil"></i> Edit</a>
12
              </li>
13
              <li>
14
                  <a href="[% script_name %]?op=delete_confirm&amp;budget_period_id=[% block_budget_id %]"><i class="fa fa-trash"></i> Delete</a>
15
              </li>
12
              </li>
13
              [% IF block_budget.count %]
14
                  <li class="disabled">
15
                      <a data-toggle="tooltip" data-placement="left" title="[% block_budget.count %] fund(s) are attached to this budget. You must delete all attached funds before deleting this budget." href="#"><i class="fa fa-trash"></i> Delete</a>
16
                  </li>
17
              [% ELSE %]
18
                  <li>
19
                      <a href="[% script_name %]?op=delete_confirm&amp;budget_period_id=[% block_budget.budget_period_id %]"><i class="fa fa-trash"></i> Delete</a>
20
                  </li>
21
              [% END %]
16
              <li>
22
              <li>
17
                  <a href="[% script_name %]?op=duplicate_form&amp;budget_period_id=[% block_budget_id %]"><i class="fa fa-copy"></i> Duplicate</a>
23
                  <a href="[% script_name %]?op=duplicate_form&amp;budget_period_id=[% block_budget.budget_period_id %]"><i class="fa fa-copy"></i> Duplicate</a>
18
              </li>
24
              </li>
19
              <li>
25
              <li>
20
                  <a href="[% script_name %]?op=close_form&amp;budget_period_id=[% block_budget_id %]"><i class="fa fa-times-circle"></i> Close</a>
26
                  <a href="[% script_name %]?op=close_form&amp;budget_period_id=[% block_budget.budget_period_id %]"><i class="fa fa-times-circle"></i> Close</a>
21
              </li>
27
              </li>
22
              <li>
28
              <li>
23
                  <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_period_id=[% block_budget_id %]"><i class="fa fa-plus"></i> Add fund</a>
29
                  <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_period_id=[% block_budget.budget_period_id %]"><i class="fa fa-plus"></i> Add fund</a>
24
              </li>
30
              </li>
25
        </ul>
31
        </ul>
26
    </div>
32
    </div>
Lines 225-231 Link Here
225
    [% END %]
231
    [% END %]
226
    [% IF ( delete_confirm ) %]
232
    [% IF ( delete_confirm ) %]
227
        <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a> &rsaquo;
233
        <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a> &rsaquo;
228
        [% IF ( total ) %]
234
        [% IF ( total || funds_exist ) %]
229
            <span>Cannot delete budget '[% budget_period_description %]'</span>
235
            <span>Cannot delete budget '[% budget_period_description %]'</span>
230
        [% ELSE %]
236
        [% ELSE %]
231
            <span>Delete budget '[% budget_period_description %]'?</span>
237
            <span>Delete budget '[% budget_period_description %]'?</span>
Lines 401-410 Link Here
401
        <h3>Cannot delete budget</h3>
407
        <h3>Cannot delete budget</h3>
402
        <p><strong>This record is used [% total %] times</strong>
408
        <p><strong>This record is used [% total %] times</strong>
403
        . Deletion is not possible.</p>
409
        . Deletion is not possible.</p>
410
    [% ELSIF ( funds_exist ) %]
411
        <div class="dialog message">
412
        <h3>Cannot delete budget</h3>
413
        <p>This budget has funds attached. You must delete all attached funds before you can delete this budget.</p>
404
    [% ELSE %]
414
    [% ELSE %]
405
        <div class="dialog alert">
415
        <div class="dialog alert">
406
        <h3>Delete budget '[% budget_period_description %]'?</h3>
416
        <h3>Delete budget '[% budget_period_description %]'?</h3>
407
    [% END %]
408
417
409
    <!-- ############################################################# -->
418
    <!-- ############################################################# -->
410
    <!-- "delete" and "cancel" buttons    -->
419
    <!-- "delete" and "cancel" buttons    -->
Lines 418-423 Link Here
418
    <form action="[% script_name %]" method="post">
427
    <form action="[% script_name %]" method="post">
419
        <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
428
        <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
420
    </form>
429
    </form>
430
    [% END %]
421
431
422
    </div>
432
    </div>
423
[% END %]
433
[% END %]
Lines 532-537 Link Here
532
[% IF ( else ) %]
542
[% IF ( else ) %]
533
  <h2>Budgets administration</h2>
543
  <h2>Budgets administration</h2>
534
544
545
    [% IF ( failed_delete_funds_exist ) %]
546
        <div class="dialog message">Failed to delete budget because funds exist.</div>
547
    [% END %]
548
535
  [% INCLUDE 'budgets-active-currency.inc' %]
549
  [% INCLUDE 'budgets-active-currency.inc' %]
536
550
537
  <div id="budgetsTabs" class="toptabs">
551
  <div id="budgetsTabs" class="toptabs">
Lines 566-572 Link Here
566
                </td>
580
                </td>
567
                <td class="data">[% period_active.budget_period_total | $Price %]</td>
581
                <td class="data">[% period_active.budget_period_total | $Price %]</td>
568
                <td>
582
                <td>
569
                    [% PROCESS action_menu block_budget_id=period_active.budget_period_id %]
583
                    [% PROCESS action_menu block_budget=period_active %]
570
                </td>
584
                </td>
571
                </tr>
585
                </tr>
572
              [% END %]
586
              [% END %]
Lines 598-604 Link Here
598
                  <td> [% IF ( period_loo.budget_period_locked ) %]<span style="color:green;">Locked</span>&nbsp;[% ELSE %][% END %] </td>
612
                  <td> [% IF ( period_loo.budget_period_locked ) %]<span style="color:green;">Locked</span>&nbsp;[% ELSE %][% END %] </td>
599
                  <td class="data">[% period_loo.budget_period_total | $Price %]</td>
613
                  <td class="data">[% period_loo.budget_period_total | $Price %]</td>
600
                  <td>
614
                  <td>
601
                        [% PROCESS action_menu block_budget_id=period_loo.budget_period_id %]
615
                        [% PROCESS action_menu block_budget=period_loo %]
602
                  </td>
616
                  </td>
603
                  </tr>
617
                  </tr>
604
              [% END %]
618
              [% END %]
605
- 

Return to bug 18351