Added field for date of SEPA DD Mandate signature.
authorAndreas Schiermeier <andreas@schiermeier.name>
Sun, 12 Jan 2014 11:56:13 +0000 (12:56 +0100)
committerAndreas Schiermeier <andreas@schiermeier.name>
Sun, 12 Jan 2014 11:56:13 +0000 (12:56 +0100)
include/members.php

index 71d7cb0..05ad46a 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 
+// UPGRADE EXISTING DATABASE TABLE:
+// ALTER TABLE `memberdb_members` ADD `ddmandatesigdate` datetime NULL AFTER `directdebit`;
+
 $SQL_CREATE_MEMBERS = sprintf('
     CREATE TABLE IF NOT EXISTS `%1$s` (
       `id` int(10) unsigned NOT NULL auto_increment,
@@ -12,6 +15,7 @@ $SQL_CREATE_MEMBERS = sprintf('
       `bankcode` blob NOT NULL,
       `bankname` blob NOT NULL,
       `directdebit` tinyint(1) NOT NULL,
+      `ddmandatesigdate` datetime NULL,
       `street` varchar(255) NOT NULL,
       `housenumber` varchar(255) NOT NULL,
       `postcode` varchar(255) NOT NULL,
@@ -46,6 +50,7 @@ $DIRECTDEBIT_STATES = array(
 
 function db_create_member($member) {
     unset($member['id']);
+    $member['ddmandatesigdate'] = ($member['ddmandatesigdate'] == "") ? '0' : db_unixtime2datetime(ui_date2unixtime($member['ddmandatesigdate']));
     $member['created_at']   = db_unixtime2datetime(time());
     $member['modified_at']  = db_unixtime2datetime(time());
     if (!db_insert_single(DB_TABLE_MEMBERS, $member)) return false;
@@ -55,6 +60,7 @@ function db_create_member($member) {
 function db_change_member($member) {
     $id = $member['id'];
     unset($member['id']);
+    $member['ddmandatesigdate'] = ($member['ddmandatesigdate'] == "") ? '0' : db_unixtime2datetime(ui_date2unixtime($member['ddmandatesigdate']));
     $member['modified_at']  = db_unixtime2datetime(time());
     return db_update_single(DB_TABLE_MEMBERS, $member, sprintf('id=\'%1$d\'', db_escape($id)));
 }
@@ -98,32 +104,33 @@ function db_get_member_with_number($member_number) {
 
 function validate_member($userdata, &$dbdata, &$validation) {/*{{{*/
     $fields = array(
-        'id'            => 'number',
-        'number'        => 'number',
-        'firstname'     => 'string',
-        'lastname'      => 'string',
-        'nickname'      => 'string',
-        'accountholder' => 'string',
-        'accountnumber' => 'string',
-        'bankcode'      => 'string',
-        'bankname'      => 'string',
-        'directdebit'   => 'number',
-        'street'        => 'string',
-        'housenumber'   => 'string',
-        'postcode'      => 'string',
-        'city'          => 'string',
-        'country'       => 'string',
-        'email'         => 'string',
-        'phone'         => 'string',
-        'fax'           => 'string',
-        'mobile'        => 'string',
-        'jabber'        => 'string',
-        'icq'           => 'string',
-        'msn'           => 'string',
-        'aim'           => 'string',
-        'skype'         => 'string',
-        'url'           => 'string',
-        'twitter'       => 'string',
+        'id'               => 'number',
+        'number'           => 'number',
+        'firstname'        => 'string',
+        'lastname'         => 'string',
+        'nickname'         => 'string',
+        'accountholder'    => 'string',
+        'accountnumber'    => 'string',
+        'bankcode'         => 'string',
+        'bankname'         => 'string',
+        'directdebit'      => 'number',
+        'ddmandatesigdate' => 'string',
+        'street'           => 'string',
+        'housenumber'      => 'string',
+        'postcode'         => 'string',
+        'city'             => 'string',
+        'country'          => 'string',
+        'email'            => 'string',
+        'phone'            => 'string',
+        'fax'              => 'string',
+        'mobile'           => 'string',
+        'jabber'           => 'string',
+        'icq'              => 'string',
+        'msn'              => 'string',
+        'aim'              => 'string',
+        'skype'            => 'string',
+        'url'              => 'string',
+        'twitter'          => 'string',
     );
     $orig = $dbdata;
     foreach ($fields as $name => $type) {
@@ -320,7 +327,6 @@ function action_view_member() {/*{{{*/
     if (!isset($_REQUEST['id'])) redirect(link_to());
     $member = db_get_member_with_id($_REQUEST['id']);
     if (!isset($member)) redirect(link_to());
-
     form_member($member, true);
     action_list_events($member);
     action_create_event($member);
@@ -431,8 +437,6 @@ function form_member($member = array(), $readonly = false, $log_messages = array
             <?=html_text_field('Kontonummer', 'accountnumber', $member, true)?>
             <?=html_text_field('Bankleitzahl', 'bankcode', $member, true)?>
             <?=html_text_field('Name der Bank', 'bankname', $member, true)?>
-            <?=html_list_box('Lastschrifteinzug', 'directdebit', $DIRECTDEBIT_STATES, $member, $readonly)?>
-            
             <?php if (!isset($member['id'])) : ?>
                 <input class="submit" type="button" name="btn_bank_details" value="Bankverbindung erfassen" onclick="bank_details_ask_pass()" id="btn_bank_details"/>
             <?php elseif ($readonly) : ?>
@@ -440,6 +444,9 @@ function form_member($member = array(), $readonly = false, $log_messages = array
             <?php else : ?>
                 <input class="submit" type="button" name="btn_bank_details" value="Bankverbindung &auml;ndern" onclick="bank_details_ask_pass()" id="btn_bank_details"/>
             <?php endif ?>
+            <?=html_list_box('Beitragseinzug', 'directdebit', $DIRECTDEBIT_STATES, $member, $readonly)?>
+            <?php $member['ddmandatesigdate'] = ($member['ddmandatesigdate'] != 0) ? html_escape(format_date(db_date2unixtime($member['ddmandatesigdate']))) : "";  ?>
+            <?=html_text_field('Mandatsunterschrift', 'ddmandatesigdate', $member, $readonly)?>
         </fieldset>
         <fieldset style="clear: left;">
             <legend>Anschrift</legend>