Bugzilla – Attachment 169869 Details for
Bug 37096
Required fields in budget creation are ignored if left blank
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37096: Display error message for budget creation/modification if start/end date is left blank
Bug-37096-Display-error-message-for-budget-creatio.patch (text/plain), 5.76 KB, created by
Sam Lau
on 2024-07-30 16:51:11 UTC
(
hide
)
Description:
Bug 37096: Display error message for budget creation/modification if start/end date is left blank
Filename:
MIME Type:
Creator:
Sam Lau
Created:
2024-07-30 16:51:11 UTC
Size:
5.76 KB
patch
obsolete
>From cd4b824af8190bcd2ab59366b9ed120853844105 Mon Sep 17 00:00:00 2001 >From: Sam Lau <samalau@gmail.com> >Date: Tue, 30 Jul 2024 15:58:19 +0000 >Subject: [PATCH] Bug 37096: Display error message for budget > creation/modification if start/end date is left blank > >This patch adds an error message for a failed budget creation or modifcation due to the dates being empty. > >To test: >1) Go to the acquisitions tab, then on the side under 'Administration' select the 'Budgets' tab. >2) Click 'New budget', enter only a description and press save. >3) Note that the budget was not created, but no messages were displayed. >4) Apply patch, restart_all >5) Once again select 'New budget' and enter only a description. >6) This time when submitting, you will see an error message that says the process failed. >7) Edit an exisitng budget and remove the start date from this budget. >8) Attempt to save and note that the error message displays properly. >--- > admin/aqbudgetperiods.pl | 73 ++++++++++++------- > .../prog/en/modules/admin/aqbudgetperiods.tt | 4 + > 2 files changed, 50 insertions(+), 27 deletions(-) > >diff --git a/admin/aqbudgetperiods.pl b/admin/aqbudgetperiods.pl >index c66969a21c..8b6d4a0c7e 100755 >--- a/admin/aqbudgetperiods.pl >+++ b/admin/aqbudgetperiods.pl >@@ -110,38 +110,57 @@ if ( $op eq 'add_form' ) { > } > > elsif ( $op eq 'cud-add_validate' ) { >+EXIT_IF: { > ## add or modify a budget period (confirmation) > >- ## update budget period data >- if ( $budget_period_id ne '' ) { >- # Grab the previous values so we can log them >- my $budgetperiod_old=GetBudgetPeriod($budget_period_id); >- $$budget_period_hashref{$_}||=0 for qw(budget_period_active budget_period_locked); >- my $status=ModBudgetPeriod($budget_period_hashref); >- # Log the budget modification >- if (C4::Context->preference("AcquisitionLog")) { >- my $diff = 0 - ($budgetperiod_old->{budget_period_total} - $budget_period_hashref->{budget_period_total}); >- my $infos = { >- budget_period_startdate => $input->param('budget_period_startdate'), >- budget_period_enddate => $input->param('budget_period_enddate'), >- budget_period_total => $budget_period_hashref->{budget_period_total}, >- budget_period_startdate_old => $budgetperiod_old->{budget_period_startdate}, >- budget_period_enddate_old => $budgetperiod_old->{budget_period_enddate}, >- budget_period_total_old => $budgetperiod_old->{budget_period_total}, >- budget_period_total_change => $diff >- }; >- logaction( >- 'ACQUISITIONS', >- 'MODIFY_BUDGET', >- $budget_period_id, >- encode_json($infos) >+ my $budget_period_startdate = $input->param('budget_period_startdate'); >+ my $budget_period_enddate = $input->param('budget_period_enddate'); >+ my $action = $budget_period_id ne '' ? 'modify' : 'add'; >+ >+ if ( $budget_period_startdate eq '' || $budget_period_enddate eq '' ) { >+ >+ $template->param( >+ failed_add_validate => 1, >+ action => $action > ); >+ >+ $op = 'else'; >+ last EXIT_IF; > } >+ >+ ## update budget period data >+ if ( $action eq 'modify' ) { >+ >+ # Grab the previous values so we can log them >+ my $budgetperiod_old = GetBudgetPeriod($budget_period_id); >+ $$budget_period_hashref{$_} ||= 0 for qw(budget_period_active budget_period_locked); >+ my $status = ModBudgetPeriod($budget_period_hashref); >+ >+ # Log the budget modification >+ if ( C4::Context->preference("AcquisitionLog") ) { >+ my $diff = >+ 0 - ( $budgetperiod_old->{budget_period_total} - $budget_period_hashref->{budget_period_total} ); >+ my $infos = { >+ budget_period_startdate => $budget_period_startdate, >+ budget_period_enddate => $budget_period_enddate, >+ budget_period_total => $budget_period_hashref->{budget_period_total}, >+ budget_period_startdate_old => $budgetperiod_old->{budget_period_startdate}, >+ budget_period_enddate_old => $budgetperiod_old->{budget_period_enddate}, >+ budget_period_total_old => $budgetperiod_old->{budget_period_total}, >+ budget_period_total_change => $diff >+ }; >+ logaction( >+ 'ACQUISITIONS', >+ 'MODIFY_BUDGET', >+ $budget_period_id, >+ encode_json($infos) >+ ); >+ } >+ } else { # ELSE ITS AN ADD >+ my $budget_period_id = AddBudgetPeriod($budget_period_hashref); >+ } >+ $op = 'else'; > } >- else { # ELSE ITS AN ADD >- my $budget_period_id=AddBudgetPeriod($budget_period_hashref); >- } >- $op='else'; > } > > #-------------------------------------------------- >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt >index 9ed1b2a704..c7ad11c718 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt >@@ -456,6 +456,10 @@ > [% IF ( else ) %] > <h1>Budgets</h1> > >+ [% IF failed_add_validate %] >+ <div class="dialog message">Failed to [% action | html %] budget because start/end date was not provided.</div> >+ [% END %] >+ > [% IF ( failed_delete_funds_exist ) %] > <div class="dialog message">Failed to delete budget because funds exist.</div> > [% END %] >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37096
:
169869
|
169873