[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha members/memberentry.pl koha-tmpl/intranet-...
From: |
Pierrick LE GALL |
Subject: |
[Koha-cvs] koha members/memberentry.pl koha-tmpl/intranet-... |
Date: |
Fri, 21 Apr 2006 14:32:10 +0000 |
CVSROOT: /sources/koha
Module name: koha
Branch:
Changes by: Pierrick LE GALL <address@hidden> 06/04/21 14:32:09
Modified files:
members : memberentry.pl
koha-tmpl/intranet-tmpl/prog/en/members: memberentryA.tmpl
. : about.pl
Log message:
bug 659 fixed: borrower category age limitations are now taken into
account
during member registration.
Warning: new external module required, Date::Calc
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/koha/members/memberentry.pl.diff?tr1=1.19&tr2=1.20&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/koha/koha/koha-tmpl/intranet-tmpl/prog/en/members/memberentryA.tmpl.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/koha/koha/about.pl.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
Patches:
Index: koha/about.pl
diff -u koha/about.pl:1.7 koha/about.pl:1.8
--- koha/about.pl:1.7 Thu Mar 16 11:33:28 2006
+++ koha/about.pl Fri Apr 21 14:32:09 2006
@@ -28,6 +28,7 @@
my $apacheVersion = `httpd -v`;
$apacheVersion = `httpd2 -v` unless $apacheVersion;
my $zebraVersion = `zebraidx -V`;
+# $apacheVersion = (`/usr/sbin/apache2 -V`)[0];
$template->param(
kohaVersion => $kohaVersion,
@@ -44,8 +45,10 @@
Event Net::LDAP PDF::API2
Mail::Sendmail MARC::Record Digest::MD5
HTML::Template DBD::mysql Date::Manip
- DBI Smart::Comments ZOOM
+ DBI Smart::Comments Net::Z3950::ZOOM
+ Date::Calc
/;
+
my @components = ();
foreach my $component (sort @component_names) {
Index: koha/koha-tmpl/intranet-tmpl/prog/en/members/memberentryA.tmpl
diff -u koha/koha-tmpl/intranet-tmpl/prog/en/members/memberentryA.tmpl:1.1
koha/koha-tmpl/intranet-tmpl/prog/en/members/memberentryA.tmpl:1.2
--- koha/koha-tmpl/intranet-tmpl/prog/en/members/memberentryA.tmpl:1.1 Fri Apr
14 09:35:22 2006
+++ koha/koha-tmpl/intranet-tmpl/prog/en/members/memberentryA.tmpl Fri Apr
21 14:32:09 2006
@@ -42,6 +42,9 @@
<!-- TMPL_IF NAME="ERROR_login_exist" -->
<p>login/password already exist</p>
<!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="ERROR_age_limitations" -->
+ Member is too young or too old for this
category
+ <!-- /TMPL_IF -->
</div>
<!-- /TMPL_IF -->
Index: koha/members/memberentry.pl
diff -u koha/members/memberentry.pl:1.19 koha/members/memberentry.pl:1.20
--- koha/members/memberentry.pl:1.19 Fri Apr 14 09:32:34 2006
+++ koha/members/memberentry.pl Fri Apr 21 14:32:09 2006
@@ -1,5 +1,5 @@
#!/usr/bin/perl
-# $Id: memberentry.pl,v 1.19 2006/04/14 09:32:34 tipaul Exp $
+# $Id: memberentry.pl,v 1.20 2006/04/21 14:32:09 plg Exp $
# Copyright 2006 SAN OUEST PROVENCE et Paul POULAIN
#
@@ -18,21 +18,27 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
+# pragma
use strict;
+
+# external modules
+use Date::Calc qw/Today/;
+use CGI;
+use HTML::Template;
+use Date::Manip;
+use Digest::MD5 qw(md5_base64);
+
+# internal modules
use C4::Auth;
use C4::Context;
use C4::Output;
use C4::Interface::CGI::Output;
-use CGI;
use C4::Search;
use C4::Members;
use C4::Koha;
-use HTML::Template;
-use Date::Manip;
use C4::Date;
use C4::Input;
use C4::Log;
-use Digest::MD5 qw(md5_base64);
my $input = new CGI;
my %data;
@@ -65,6 +71,8 @@
my $select_city=$input->param('select_city');
my $nok=$input->param('nok');
+my @errors;
+
# $check_categorytype contains the value of duplicate borrowers category type
to redirect in good template in step =2
my $check_categorytype=$input->param('check_categorytype');
# NOTE: Alert for ethnicity and ethnotes fields, they are unvalided in all
borrowers form
@@ -87,7 +95,7 @@
$data{$key}=~ s/\'/\\\'/g;
$data{$key}=~ s/\"/\\\"/g;
}
- my @errors;
+
#############test for member being unique #############
if ($op eq 'add' && $step eq 2){
(my $category_type_send=$category_type ) if ($category_type eq
'I');
@@ -125,7 +133,29 @@
$data{'email'}=$guarantordata->{'email'};
$data{'emailpro'}=$guarantordata->{'emailpro'};
}
- }
+ }
+ if ($categorycode ne 'I') {
+ # is the age of the borrower compatible with age
limitations of
+ # the borrower category
+ my $query = '
+SELECT upperagelimit,
+ dateofbirthrequired
+ FROM categories
+ WHERE categorycode = ?
+';
+ my $sth=$dbh->prepare($query);
+ $sth->execute($categorycode);
+ my $category_info = $sth->fetchrow_hashref;
+
+ my $age = get_age(format_date_in_iso($data{dateofbirth}));
+
+ if ($age > $category_info->{upperagelimit}
+ or $age < $category_info->{dateofbirthrequired}
+ ) {
+ push @errors, 'ERROR_age_limitations';
+ $nok = 1;
+ }
+ }
}
# STEP 2
if ($step eq 2) {
@@ -174,14 +204,6 @@
logaction($loggedinuser,"MEMBERS","add member",
$borrowerid, "");
}
}
-
- if ($nok) {
- foreach my $error (@errors) {
- $template->param( $error => 1);
- }
- $template->param(nok => 1);
- $step--; # decrease step : go back to step 2, the
step++ just before showing the template will go again to 3
- }
unless ($nok) {
if($destination eq "circ"){
@@ -384,8 +406,18 @@
$data{'opacnotes'} =~ s/\\//g;
$data{'borrowernotes'} =~ s/\\//g;
+
# increase step to see next page
- $step++;
+ if ($nok) {
+ foreach my $error (@errors) {
+ $template->param( $error => 1);
+ }
+ $template->param(nok => 1);
+ }
+ else {
+ $step++;
+ }
+
warn "CITY".$data{city};
$template->param(
BorrowerMandatoryField =>
C4::Context->preference("BorrowerMandatoryField"),#field to test with javascript
@@ -462,6 +494,25 @@
#$template->param(Institution => 1) if ($categorycode eq "I");
output_html_with_http_headers $input, $cookie, $template->output;
}
+
+sub get_age {
+ my ($date, $date_ref) = @_;
+
+ if (not defined $date_ref) {
+ $date_ref = sprintf('%04d-%02d-%02d', Today());
+ }
+
+ my ($year1, $month1, $day1) = split /-/, $date;
+ my ($year2, $month2, $day2) = split /-/, $date_ref;
+
+ my $age = $year2 - $year1;
+ if ($month1.$day1 > $month2.$day2) {
+ $age--;
+ }
+
+ return $age;
+}
+
# Local Variables:
# tab-width: 8
# End:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] koha members/memberentry.pl koha-tmpl/intranet-...,
Pierrick LE GALL <=