Bugzilla – Attachment 45591 Details for
Bug 15206
Show patron's age when filling date of birth in memberentry.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15206 - CalculateAge in memberentry use C4::Members::GetAge()
Bug-15206---CalculateAge-in-memberentry-use-C4Memb.patch (text/plain), 4.21 KB, created by
Alex Arnaud
on 2015-12-11 10:00:36 UTC
(
hide
)
Description:
Bug 15206 - CalculateAge in memberentry use C4::Members::GetAge()
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2015-12-11 10:00:36 UTC
Size:
4.21 KB
patch
obsolete
>From 16a6eb56748d29b61712888ca81f2a9870479b4b Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Thu, 10 Dec 2015 16:33:53 +0100 >Subject: [PATCH] Bug 15206 - CalculateAge in memberentry use > C4::Members::GetAge() > >--- > .../prog/en/modules/members/memberentrygen.tt | 44 +++++++++--------- > svc/members/age | 49 ++++++++++++++++++++ > 2 files changed, 70 insertions(+), 23 deletions(-) > create mode 100755 svc/members/age > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >index 290bebe..6ca7570 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -145,36 +145,34 @@ > return 0; > } > >- function CalculateAge(dateofbirth) { >- var today = new Date(); >- var dob = new Date($("#dateofbirth").datepicker( 'getDate' )); >- >- var nowyear = today.getFullYear(); >- var nowmonth = today.getMonth(); >- var nowday = today.getDate(); >+ function CalculateAge() { >+ if (!$("#dateofbirth").datepicker( 'getDate' )) { >+ var elem = $("#dateofbirth").siblings(".hint").first().html(''); >+ return 1; >+ } > >- var birthyear = dob.getFullYear(); >- var birthmonth = dob.getMonth(); >- var birthday = dob.getDate(); >+ var dob = new Date($("#dateofbirth").datepicker( 'getDate' )); > >- var year = nowyear - birthyear; >- var month = nowmonth - birthmonth; >- var day = nowday - birthday; >+ var year = dob.getFullYear(); >+ var month = dob.getMonth(); >+ var day = dob.getDate(); > >- if(day < 0) { >- month = parseInt(month) -1; >- } >+ $.ajax({ >+ url : '/cgi-bin/koha/svc/members/age', >+ type : 'GET', >+ data: 'dateofbirth=' + year + '-' + month + '-' + day, >+ dataType: 'json', >+ success : function(json, statut){ >+ var age_string = "Age: "; >+ if (json.years) { age_string += json.years + " year(s) "; } >+ if (json.months) { age_string += json.months + " month(s) "; } >+ var elem = $("#dateofbirth").siblings(".hint").first().html(age_string); >+ }, >+ }); > >- if(month < 0) { >- year = parseInt(year) -1; >- month = 12 + month; >- } > > var age_string = "Age: "; >- if (year) { age_string += year + " year(s) "; } >- if (month) { age_string += month + " month(s) "; } > >- var elem = $("#dateofbirth").siblings(".hint").first().html(age_string); > } > > >diff --git a/svc/members/age b/svc/members/age >new file mode 100755 >index 0000000..fb50baa >--- /dev/null >+++ b/svc/members/age >@@ -0,0 +1,49 @@ >+#!/usr/bin/perl >+ >+# Copyright 2012 BibLibre >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use CGI qw ( -utf8 ); >+ >+use C4::Auth qw( check_cookie_auth ); >+use JSON qw( to_json ); >+use C4::Members qw( GetAge ); >+binmode STDOUT, ":encoding(UTF-8)"; >+ >+my $query = new CGI; >+ >+my ( $status, $sessionID ) = check_cookie_auth( >+ $query->cookie('CGISESSID'), >+ { borrowers => '*' }, >+); >+ >+unless ($status eq "ok") { >+ print $query->header(-type => 'application/json', -status => '403 Forbidden'); >+ exit 0; >+} >+ >+my $dateofbirth = $query->param('dateofbirth'); >+my ($age_year, $age_month) = GetAge($dateofbirth); >+ >+print $query->header(-type => 'application/json'); >+ >+print to_json({ >+ years => $age_year, >+ months => $age_month >+}); >+ >-- >1.7.10.4
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 15206
:
44953
|
44978
|
45579
|
45580
|
45581
|
45589
|
45590
|
45591
|
45592
|
45593
|
45597
|
45598
|
45599
|
45600
|
45601
|
46228
|
46245
|
46396
|
47301
|
47505
|
47506
|
47540
|
47541
|
47542
|
49032
|
49033
|
49034