Bug 22786: Prevent fund creation for locked budgets

If a budget is locked, there is a "New fund for $budget" link that is
disabled but clickable.
We should ensure that the link is not clickable and prevent it at
controller level (do we need it at module level, ie.
Koha::Acquisition::Fund->store?)

Test plan:
- Create a budget, lock it
- Go to /cgi-bin/koha/admin/aqbudgetperiods.pl
- Click on the name of the budget you just created
=> The "New > New fund for $budget_name" button should be disabled
- Click it anyway
=> Without this patch the form to add a new fund is displayed
=> With this patch applied nothing happens
- Hit /cgi-bin/koha/admin/aqbudgets.pl?op=add_form&budget_period_id=XXX
With XXX the budget's id
=> Without this patch the form is displayed
=> With this patch applied you get a message:
  "The budget is locked, fund creation is not possible."
And you are not able to create a new fund

QA notes:
1. See description
2. The add_validate op can still be forced, let trust librarians with
administration permissions for now.

Signed-off-by: Hayley Mapley <hayleymapley@catalyst.net.nz>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 9215ca42d2)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 8d5a50384f)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2019-06-22 19:29:42 -05:00 committed by Lucas Gass
parent 371eb680ac
commit f8c8d6df0a
3 changed files with 8 additions and 1 deletions

View File

@ -115,6 +115,8 @@ if ($op eq 'add_form') {
}
$dropbox_disabled = BudgetHasChildren($budget_id);
$budget->{budget_owner} = Koha::Patrons->find( $budget->{budget_owner_id} );
} elsif ( $period->{budget_period_locked} ) {
output_and_exit( $input, $cookie, $template, 'budget_is_locked' );
}
# build budget hierarchy

View File

@ -13,6 +13,8 @@
<div class="dialog message">This basket does not exist.</div>
[% CASE 'wrong_csrf_token' %]
<div class="dialog message">The form submission failed (Wrong CSRF token). Try to come back, refresh the page, then try again.</div>
[% CASE 'budget_is_locked' %]
<div class="dialog message">The budget is locked, fund creation is not possible.</div>
[% CASE %][% blocking_error | html %]
[% END %]

View File

@ -7,10 +7,13 @@
<li><a href="/cgi-bin/koha/admin/aqbudgetperiods.pl?op=add_form">New budget</a></li>
[% IF ( budget_period_locked || !CAN_user_acquisition_budget_add_del ) %]
<li class="disabled">
<a data-toggle="tooltip" data-placement="left" title="The budget is locked" href="#">New fund for [% budget_period_description | html %]</a>
</li>
[% ELSE %]
<li>
<a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_period_id=[% budget_period_id | uri %]">New fund for [% budget_period_description | html %]</a>
</li>
[% END %]
<a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_period_id=[% budget_period_id | uri %]">New fund for [% budget_period_description | html %]</a></li>
</ul>
</div>