From f461de794b2538319f67b266e2c90228f46eb3ad Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc=20V=C3=A9ron?= Date: Thu, 15 Oct 2015 13:01:50 +0200 Subject: [PATCH] Bug 14931: (Follow-up) Validate date entry in contracts Go to Home > Acquisitions, search for an active vendor and view the vendor - Click on 'Contracts' at the left (admin/aqcontract.pl) - Create and edit contracts and verify that it works OK. (Note: there is no help for this page, see Bug 14929) Amended for comment #7 25.10.2015 / mv Signed-off-by: Jesse Weaver Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi --- admin/aqcontract.pl | 22 ++++++++++++------- .../prog/en/modules/admin/aqcontract.tt | 9 ++++---- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/admin/aqcontract.pl b/admin/aqcontract.pl index 6deec5be9c..8f6bf3063e 100755 --- a/admin/aqcontract.pl +++ b/admin/aqcontract.pl @@ -71,8 +71,8 @@ if ( $op eq 'add_form' ) { contractnumber => $contract->{contractnumber}, contractname => $contract->{contractname}, contractdescription => $contract->{contractdescription}, - contractstartdate => output_pref({ dt => dt_from_string( $contract->{contractstartdate} ), dateonly => 1 }), - contractenddate => output_pref({ dt => dt_from_string( $contract->{contractenddate} ), dateonly => 1 }), + contractstartdate => $contract->{contractstartdate}, + contractenddate => $contract->{contractenddate}, ); } else { $template->param( @@ -93,10 +93,16 @@ elsif ( $op eq 'add_validate' ) { my $is_a_modif = $input->param("is_a_modif"); + my $contractstart_dt = eval { dt_from_string( $input->param('contractstartdate') ); }; + $contractstart_dt = dt_from_string if ( ! $contractstart_dt ); + + my $contractend_dt = eval { dt_from_string( $input->param('contractenddate') ); }; + $contractend_dt = dt_from_string if ( ! $contractend_dt ); + if ( $is_a_modif ) { ModContract({ - contractstartdate => output_pref({ dt => dt_from_string( $input->param('contractstartdate') ), dateformat => 'iso', dateonly => 1 }), - contractenddate => output_pref({ dt => dt_from_string( $input->param('contractenddate') ), dateformat => 'iso', dateonly => 1 }), + contractstartdate => eval { output_pref({ dt => dt_from_string( $contractstart_dt ), dateformat => 'iso', dateonly => 1 } ); }, + contractenddate => eval { output_pref({ dt => dt_from_string( $contractend_dt ), dateformat => 'iso', dateonly => 1 } ); }, contractname => $input->param('contractname'), contractdescription => $input->param('contractdescription'), booksellerid => $input->param('booksellerid'), @@ -107,8 +113,8 @@ elsif ( $op eq 'add_validate' ) { contractname => $input->param('contractname'), contractdescription => $input->param('contractdescription'), booksellerid => $input->param('booksellerid'), - contractstartdate => output_pref({ dt => dt_from_string( $input->param('contractstartdate') ), dateformat => 'iso', dateonly => 1 }), - contractenddate => output_pref({ dt => dt_from_string( $input->param('contractenddate') ), dateformat => 'iso', dateonly => 1 }), + contractstartdate => eval { output_pref({ dt => dt_from_string( $input->param('contractstartdate') ), dateformat => 'iso', dateonly => 1 } ); }, + contractenddate => eval { output_pref({ dt => dt_from_string( $input->param('contractenddate') ), dateformat => 'iso', dateonly => 1 } ); }, }); } @@ -127,8 +133,8 @@ elsif ( $op eq 'delete_confirm' ) { contractnumber => $$contract{contractnumber}, contractname => $$contract{contractname}, contractdescription => $$contract{contractdescription}, - contractstartdate => output_pref({ dt => dt_from_string( $$contract{contractstartdate} ), dateonly => 1 }), - contractenddate => output_pref({ dt => dt_from_string( $$contract{contractenddate} ), dateonly => 1 }), + contractstartdate => $$contract{contractstartdate}, + contractenddate => $$contract{contractenddate}, ); # END $OP eq DELETE_CONFIRM diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt index 6c48aa2043..684d69fb99 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt @@ -1,3 +1,4 @@ +[% USE KohaDates %] [% INCLUDE 'doc-head-open.inc' %] Koha › Acquisitions › Contracts › [% IF ( add_form ) %] @@ -120,11 +121,11 @@ function Check(ff) { <input type="text" name="contractdescription" id="contractdescription" size="40" maxlength="80" value="[% contractdescription %]" /> </li> <li><label for="from" class="required">Start date: *</label>   - <input type="text" name="contractstartdate" id="from" value="[% contractstartdate %]" maxlength="10" size="10" class="datepickerfrom" /> + <input type="text" name="contractstartdate" id="from" value="[% contractstartdate | $KohaDates %]" maxlength="10" size="10" class="datepickerfrom" /> <div class="hint">[% INCLUDE 'date-format.inc' %]</div> </li> <li><label for="to" class="required">End date: *</label>   - <input type="text" name="contractenddate" id="to" value="[% contractenddate %]" maxlength="10" size="10" class="datepickerto" /> + <input type="text" name="contractenddate" id="to" value="[% contractenddate | $KohaDates %]" maxlength="10" size="10" class="datepickerto" /> <div class="hint">[% INCLUDE 'date-format.inc' %]</div> </li> </ol> @@ -148,8 +149,8 @@ function Check(ff) { <tr><th scope="row">Contract number:</th><td>[% contractnumber %]</td></tr> <tr><th scope="row">Contract name:</th><td>[% contractname %]</td></tr> <tr><th scope="row">Contract description:</th><td>[% contractdescription %]</td></tr> - <tr><th scope="row">Contract start date:</th><td>[% contractstartdate %]</td></tr> - <tr><th scope="row">Contract end date:</th><td>[% contractenddate %]</td></tr> + <tr><th scope="row">Contract start date:</th><td>[% contractstartdate | $KohaDates %]</td></tr> + <tr><th scope="row">Contract end date:</th><td>[% contractenddate | $KohaDates %]</td></tr> <tr><th scope="row">Vendor:</th><td>[% booksellername %]</td></tr> </table> <fieldset class="action"> -- 2.39.5