Browse Source

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 <pianohacker@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
3.22.x
Marc Véron 9 years ago
committed by Tomas Cohen Arazi
parent
commit
f461de794b
  1. 22
      admin/aqcontract.pl
  2. 9
      koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt

22
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

9
koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt

@ -1,3 +1,4 @@
[% USE KohaDates %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Acquisitions &rsaquo; Contracts &rsaquo;
[% 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> &nbsp;
<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> &nbsp;
<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">

Loading…
Cancel
Save