Added IBAN-hin export
authorAndreas Schiermeier <andreas@schiermeier.name>
Mon, 30 Dec 2013 19:42:57 +0000 (20:42 +0100)
committerAndreas Schiermeier <andreas@schiermeier.name>
Mon, 30 Dec 2013 19:42:57 +0000 (20:42 +0100)
include/members.php
index.php

index ddeaf13..6fc8b14 100644 (file)
@@ -156,6 +156,124 @@ function validate_member_number($member_number, $member_id = NULL) {/*{{{*/
     return false;
 }/*}}}*/
 
+function action_export_ibanhin() {/*{{{*/
+    $members = db_get_members();
+    if (empty($members)) return;
+    js_modal_windows();
+    js_get_master_key();
+?>
+    <noscript>
+        <p class="error">
+            <strong>Achtung:</strong> Ohne JavaScript geht hier gar nichts. Bitte aktivieren!
+        </p>
+    </noscript>
+
+    <h2>IBAN-hin</h2>
+<input class="submit" type="button" name="btn_ibanhin" value="IBAN-hin erzeugen" onclick="ask_for_password()" id="btn_export_iban_hin"/>
+<br/>
+<br/>
+
+
+<div id="password_popup" class="modal_window">
+    <fieldset>
+        <legend>Passwortabfrage</legend>
+        <?=html_password_field('Passwort', 'password')?>
+        <input class="submit" type="button" name="btn_export_ibanhin" value="IBAN-hin erzeugen" onclick="export_ibanhin()"/>
+        <input class="submit" type="button" name="btn_cancel" value="Abbrechen" onclick="cancel_ask_for_password()"/>
+    </fieldset>
+</div>
+<div id="ibanhin_popup" class="modal_window">
+    <fieldset>
+        <legend>IBAN-hin</legend>
+            <textarea id="ibanhin_content" style="width: 100%" rows="30" readonly="readonly"></textarea>
+            <input class="submit" type="button" name="btn_ibanhin_close" value="Schlie├čen" onclick="ibanhin_close()"/>
+    </fieldset>
+</div>
+
+<script type="text/javascript">
+
+  var members = new Array(<?=join(",\n", array_map('json_encode', $members)) ?>);
+
+
+
+$(document).ready(function(){  
+    $('#password').keypress( function(event) { if (event.keyCode == '13') { export_ibanhin(); } });
+    $('#btn_ibanhin').focus();
+});  
+
+
+function ask_for_password() {/*{{{*/
+    modal_window_show($("#password_popup"));
+    $("#password").focus();
+    return;
+}/*}}}*/
+
+function cancel_ask_for_password() {/*{{{*/
+    modal_window_hide();
+    $("#btn_ibanhin").focus();
+    return;
+}/*}}}*/
+
+
+function export_ibanhin() {/*{{{*/
+    
+    var ibanhin_content = "";
+
+    var password = $('#password').val();
+    $("#password").val('');
+
+    // We pass a closure so that get_master_key may defer execution
+    get_master_key(password, function(masterkey) {
+
+    modal_window_replace($("#ibanhin_popup"));
+
+    for (var i = 0; i < members.length; i++) {
+      if (members[i]['directdebit'] = "1") {
+       var accountnumber = members[i]['accountnumber'];
+       var bankcode      = members[i]['bankcode'];
+       if (accountnumber != "") accountnumber = Crypto.charenc.UTF8.bytesToString(Crypto.AES.decrypt(accountnumber, masterkey));
+       if (bankcode      != "") bankcode      = Crypto.charenc.UTF8.bytesToString(Crypto.AES.decrypt(bankcode,      masterkey));
+        if (accountnumber != "" && bankcode != "") {
+          /* ZKA-Spezifikation-IBAN-hin-IBAN-rueck
+             01. Satzart
+             02. Anwender
+             03. Internes Kennzeichen des Anwenders
+             04. BIC-ALT
+             IBAN-ALT
+             05. LK/PZ-ALT
+             06. BLZ-ALT
+             07. KTONR-ALT
+             IBAN-NEU
+             08. LK/PZ-NEU
+             09. BLZ-NEU
+             10. KTONR-NEU
+             11. UMST-KZ
+           */
+          ibanhin_content += '"DE";;"' + members[i]['number'] + '";;;"' + bankcode + '";"' + accountnumber + '";;;;;' + "\n";
+        }
+      }
+    }
+
+    $('#ibanhin_content').val(ibanhin_content);
+    $('#ibanhin_content').focus();
+    $('#ibanhin_content').select();
+    
+    });
+
+}/*}}}*/
+
+function ibanhin_close() {/*{{{*/
+    modal_window_hide();
+    $("#ibanhin_content").val('');
+}/*}}}*/
+
+
+</script>
+
+<?php
+
+}/*}}}*/
+
 
 function action_list_members() {/*{{{*/
     $members = db_get_members();
index 2fc1cd8..c032593 100644 (file)
--- a/index.php
+++ b/index.php
@@ -39,6 +39,7 @@ try {
         case 'export_email'   : action_export_email();    break;
         case 'create_member'  : action_create_member();   break;
         case 'change_member'  : action_change_member();   break;
+        case 'export_ibanhin' : action_export_ibanhin();  break;
         case 'create_event'   : action_create_event();    break;
         case 'change_event'   : action_change_event();    break;
         case 'delete_event'   : action_delete_event();    break;
@@ -155,4 +156,4 @@ try {
 }
 catch (Exception $e) {
     echo 'Caught exception: ',  $e->getMessage(), "\n";
-}
\ No newline at end of file
+}