DoB
authorjeff <jeff>
Wed, 4 Oct 2006 21:22:08 +0000 (21:22 +0000)
committerjeff <jeff>
Wed, 4 Oct 2006 21:22:08 +0000 (21:22 +0000)
FS/FS/Conf.pm
FS/FS/Record.pm
FS/FS/Schema.pm
FS/FS/cust_main.pm
httemplate/edit/cust_main.cgi
httemplate/elements/tr-input-date-field.html [new file with mode: 0644]
httemplate/view/cust_main/misc.html

index 384ff52..7f77e00 100644 (file)
@@ -413,6 +413,13 @@ httemplate/docs/config.html
   },
 
   {
+    'key'         => 'date_format',
+    'section'     => 'UI',
+    'description' => 'format code for displaying dates with Date::Format::time2str',
+    'type'        => 'text',
+  },
+
+  {
     'key'         => 'cyrus',
     'section'     => 'deprecated',
     'description' => '<b>DEPRECATED</b>, add a <i>cyrus</i> <a href="../browse/part_export.cgi">export</a> instead.  This option used to integrate with <a href="http://asg.web.cmu.edu/cyrus/imapd/">Cyrus IMAP Server</a>, three lines: IMAP server, admin username, and admin password.  Cyrus::IMAP::Admin should be installed locally and the connection to the server secured.',
index 114b1d6..bd5dd27 100644 (file)
@@ -83,6 +83,8 @@ FS::Record - Database record objects
     $error = $record->ut_float('column');
     $error = $record->ut_number('column');
     $error = $record->ut_numbern('column');
+    $error = $record->ut_snumber('column');
+    $error = $record->ut_snumbern('column');
     $error = $record->ut_money('column');
     $error = $record->ut_text('column');
     $error = $record->ut_textn('column');
@@ -1288,6 +1290,25 @@ sub ut_snumber {
   '';
 }
 
+=item ut_snumbern COLUMN
+
+Check/untaint signed numeric data (whole numbers).  If there is an error,
+returns the error, otherwise returns false.
+
+=cut
+
+sub ut_snumbern {
+  my($self, $field) = @_;
+  $self->getfield($field) =~ /^(-?)\s*(\d*)$/
+    or return "Illegal (numeric) $field: ". $self->getfield($field);
+  if ($1) {
+    return "Illegal (numeric) $field: ". $self->getfield($field)
+      unless $2;
+  }
+  $self->setfield($field, "$1$2");
+  '';
+}
+
 =item ut_number COLUMN
 
 Check/untaint simple numeric data (whole numbers).  May not be null.  If there
index 3d4fcc5..ea02dfe 100644 (file)
@@ -407,6 +407,7 @@ sub tables_hashref {
 #        'middle',   'varchar', 'NULL', $char_d, '', '', 
         'first',    'varchar', '',     $char_d, '', '', 
         'ss',       'varchar', 'NULL', 11, '', '', 
+        'birthdate',@date_type, '', '', 
         'company',  'varchar', 'NULL', $char_d, '', '', 
         'address1', 'varchar', '',     $char_d, '', '', 
         'address2', 'varchar', 'NULL', $char_d, '', '', 
index 4841387..cb44ba6 100644 (file)
@@ -1209,6 +1209,7 @@ sub check {
     || $self->ut_number('refnum')
     || $self->ut_name('last')
     || $self->ut_name('first')
+    || $self->ut_snumbern('birthdate')
     || $self->ut_textn('company')
     || $self->ut_text('address1')
     || $self->ut_textn('address2')
@@ -4619,6 +4620,8 @@ No multiple currency support (probably a larger project than just this module).
 
 payinfo_masked false laziness with cust_pay.pm and cust_refund.pm
 
+Birthdates rely on negative epoch values.
+
 =head1 SEE ALSO
 
 L<FS::Record>, L<FS::cust_pkg>, L<FS::cust_bill>, L<FS::cust_credit>
index 99f849f..e0dd3c8 100755 (executable)
 
 </TABLE>
 
+<!-- birthdate -->
+
+<BR>
+<% ntable("#cccccc", 2) %>
+<% include ('/elements/tr-input-date-field.html',
+            'birthdate',
+            $cust_main->birthdate,
+            'Date of Birth',
+            $conf->config('date_format') || "%m/%d/%Y")
+%>
+
+</TABLE>
+
 <!-- contact info -->
 
 <BR><BR>
@@ -247,6 +260,8 @@ Service address
 function bottomfixup(what) {
 
   var topvars = new Array(
+    'birthdate',
+
     'custnum', 'agentnum', 'refnum', 'referral_custnum',
 
     'last', 'first', 'ss', 'company',
@@ -329,6 +344,8 @@ function copyelement(from, to) {
 
 <FORM ACTION="<% popurl(1) %>process/cust_main.cgi" METHOD=POST NAME="bottomform" onSubmit="document.bottomform.submit.disabled=true; bottomfixup(this.form);" STYLE="margin-top: 0; margin-bottom: 0">
 % foreach my $hidden (
+%     'birthdate',
+%
 %     'custnum', 'agentnum', 'refnum', 'referral_custnum',
 %     'last', 'first', 'ss', 'company',
 %     'address1', 'address2', 'city',
diff --git a/httemplate/elements/tr-input-date-field.html b/httemplate/elements/tr-input-date-field.html
new file mode 100644 (file)
index 0000000..eb8eee4
--- /dev/null
@@ -0,0 +1,32 @@
+
+<LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2">
+<SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT>
+
+<TR>
+  <TD ALIGN="right"><% $label %></TD>
+  <TD>
+    <INPUT TYPE="text" NAME="<% $name %>" ID="<% $name %>_text" VALUE="<% time2str($format, $value) %>">
+    <IMG SRC="../images/calendar.png" ID="<% $name  %>_button" STYLE="cursor: pointer" TITLE="Select date">
+  </TD>
+</TR>
+
+<SCRIPT TYPE="text/javascript">
+  Calendar.setup({
+    inputField: "<% $name %>_text",
+    ifFormat:   "<% $format %>",
+    button:     "<% $name %>_button",
+    align:      "BR"
+  });
+</SCRIPT>
+
+
+<%init>
+my($name, $value, $label, $format) = @_;
+
+$format = "%m/%d/%Y" unless $format;
+$label = $name unless $label;
+
+</%init>
+
index fc033b9..b0fab03 100644 (file)
@@ -1,6 +1,7 @@
 %
 %  my( $cust_main ) = @_;
 %  my $conf = new FS::Conf;
+%  my $date_format = ($conf->config('date_format') || "%m/%d/%Y");
 %
 
 
   <TD BGCOLOR="#ffffff"><% $cust_main->otaker %></TD>
 </TR>
 
+<TR>
+  <TD ALIGN="right">Date of Birth</TD>
+  <TD BGCOLOR="#ffffff"><% $cust_main->birthdate ? time2str($date_format, $cust_main->birthdate) : '' %></TD>
+</TR>
+
 </TABLE></TD></TR></TABLE>