Formatting
[memberdb.git] / include / directdebit.php
index a00e79a..5243e37 100644 (file)
@@ -1,11 +1,9 @@
 <?php
 
-
 use MemberDB\Config\Config;
 
 function action_directdebit()
 {
-
     $config = Config::getInstance();
     $bank = $config['bank'];
 
@@ -61,7 +59,6 @@ function action_directdebit()
 
     js_modal_windows();
     js_get_master_key();
-
     ?>
     <noscript>
         <p class="error">
@@ -79,20 +76,20 @@ function action_directdebit()
         </tr>
         <?php foreach ($cash_payments as $payment) : ?>
             <tr>
-                <td><a href="<?= html_escape(link_to('fees',
-                        array('member_id' => $payment['member_id']))) ?>"><?= html_escape($payment['member_number']) ?></a>
+                <td><a href="<?php echo html_escape(link_to('fees',
+                        array('member_id' => $payment['member_id']))) ?>"><?php echo html_escape($payment['member_number']) ?></a>
                 </td>
-                <td><?= html_escape($payment['nickname']) ?></td>
-                <td style="text-align: right;"><?= html_escape(format_money($payment['amount'])) ?></td>
+                <td><?php echo html_escape($payment['nickname']) ?></td>
+                <td style="text-align: right;"><?php echo html_escape(format_money($payment['amount'])) ?></td>
                 <td>
-                    <form action="<?= link_to('create_earning') ?>" method="post" class="clearfix">
-                        <?= html_hidden_field('date', format_date(time())) ?>
-                        <?= html_hidden_field('type', 'fee') ?>
-                        <?= html_hidden_field('status', 'paid') ?>
-                        <?= html_hidden_field('value', format_money($payment['amount'])) ?>
-                        <?= html_hidden_field('member_id', $payment['member_id']) ?>
-                        <?= html_hidden_field('description', '') ?>
-                        <?= html_hidden_field('account', 'cash') ?>
+                    <form action="<?php echo link_to('create_earning') ?>" method="post" class="clearfix">
+                        <?php echo html_hidden_field('date', format_date(time())) ?>
+                        <?php echo html_hidden_field('type', 'fee') ?>
+                        <?php echo html_hidden_field('status', 'paid') ?>
+                        <?php echo html_hidden_field('value', format_money($payment['amount'])) ?>
+                        <?php echo html_hidden_field('member_id', $payment['member_id']) ?>
+                        <?php echo html_hidden_field('description', '') ?>
+                        <?php echo html_hidden_field('account', 'cash') ?>
                         <input class="submit" type="submit" name="submit" value="Einnahme verbuchen"/>
                     </form>
                 </td>
@@ -113,13 +110,13 @@ function action_directdebit()
         <?php $total = 0; ?>
         <?php foreach ($debits as $debit) : ?>
             <tr>
-                <td><a href="<?= html_escape(link_to('fees',
-                        array('member_id' => $debit['member_id']))) ?>"><?= html_escape($debit['member_number']) ?></a>
+                <td><a href="<?php echo html_escape(link_to('fees',
+                        array('member_id' => $debit['member_id']))) ?>"><?php echo html_escape($debit['member_number']) ?></a>
                 </td>
-                <td><?= html_escape($debit['nickname']) ?></td>
-                <td><?= html_escape($debit['purpose']) ?></td>
-                <td><?= html_escape($debit['debittype']) ?></td>
-                <td style="text-align: right;"><?= html_escape(format_money($debit['amount'])) ?></td>
+                <td><?php echo html_escape($debit['nickname']) ?></td>
+                <td><?php echo html_escape($debit['purpose']) ?></td>
+                <td><?php echo html_escape($debit['debittype']) ?></td>
+                <td style="text-align: right;"><?php echo html_escape(format_money($debit['amount'])) ?></td>
             </tr>
             <?php $total = bcadd($total, $debit['amount']); ?>
         <?php endforeach ?>
@@ -128,38 +125,37 @@ function action_directdebit()
             <td></td>
             <td></td>
             <td></td>
-            <td style="text-align: right;"><?= html_escape(format_money($total)) ?></td>
+            <td style="text-align: right;"><?php echo html_escape(format_money($total)) ?></td>
         </tr>
     </table>
 
-    <!-- ?=html_hidden_field('directdebittype', 'pain')? -->
-    <?= html_list_box('Dateiformat', 'directdebittype', array('dtaus' => 'DTAUS', 'pain' => 'PAIN'), 'pain'); ?>
+    <?php echo html_list_box('Dateiformat', 'directdebittype', array('dtaus' => 'DTAUS', 'pain' => 'PAIN'), 'pain'); ?>
     <input class="submit" type="button" name="btn_directdebit" value="Datei erzeugen" onclick="ask_for_password()"
            id="btn_directdebit"/>
     <br/>
     <br/>
-    <form action="<?= link_to('create_earnings') ?>" method="post" class="clearfix">
+    <form action="<?php echo link_to('create_earnings') ?>" method="post" class="clearfix">
         <?php $count = 0; ?>
         <?php foreach ($debits as $debit) : ?>
-            <?= html_hidden_field(sprintf('earnings[%d][date]', $count), format_date(time())) ?>
-            <?= html_hidden_field(sprintf('earnings[%d][type]', $count), 'fee') ?>
-            <?= html_hidden_field(sprintf('earnings[%d][status]', $count), 'paid') ?>
-            <?= html_hidden_field(sprintf('earnings[%d][value]', $count), $debit['amount']) ?>
-            <?= html_hidden_field(sprintf('earnings[%d][member_id]', $count), $debit['member_id']) ?>
-            <?= html_hidden_field(sprintf('earnings[%d][description]', $count), $debit['purpose']) ?>
+            <?php echo html_hidden_field(sprintf('earnings[%d][date]', $count), format_date(time())) ?>
+            <?php echo html_hidden_field(sprintf('earnings[%d][type]', $count), 'fee') ?>
+            <?php echo html_hidden_field(sprintf('earnings[%d][status]', $count), 'paid') ?>
+            <?php echo html_hidden_field(sprintf('earnings[%d][value]', $count), $debit['amount']) ?>
+            <?php echo html_hidden_field(sprintf('earnings[%d][member_id]', $count), $debit['member_id']) ?>
+            <?php echo html_hidden_field(sprintf('earnings[%d][description]', $count), $debit['purpose']) ?>
             <?php $count++; ?>
         <?php endforeach ?>
         <input class="submit" type="submit" name="btn_create_earnings" value="Einnahmen verbuchen"/>
     </form>
     <hr/>
-    <form action="<?= link_to('export_ibanhin') ?>" method="POST" class="clearfix">
+    <form action="<?php echo link_to('export_ibanhin') ?>" method="POST" class="clearfix">
         <input class="submit" type="submit" name="btn_export_ibanhin" value="IBAN-hin Export"/>
     </form>
 
     <div id="password_popup" class="modal_window">
         <fieldset>
             <legend>Passwortabfrage</legend>
-            <?= html_password_field('Passwort', 'password') ?>
+            <?php echo html_password_field('Passwort', 'password') ?>
             <input class="submit" type="button" name="btn_generate_directdebit" value="Datei erzeugen"
                    onclick="generate_directdebit()"/>
             <input class="submit" type="button" name="btn_cancel" value="Abbrechen"
@@ -178,12 +174,10 @@ function action_directdebit()
     </div>
 
     <script type="text/javascript">
-
         var debits = new Array(
-            <?=join(",\n", array_map('json_encode', $debits)) ?>
+            <?php echo join(",\n", array_map('json_encode', $debits)) ?>
         );
 
-
         $(document).ready(function () {
             $('#password').keypress(function (event) {
                 if (event.keyCode == '13') {
@@ -193,26 +187,19 @@ function action_directdebit()
             $('#btn_directdebit').focus();
         });
 
-
-        function ask_for_password() {/*{{{*/
+        function ask_for_password() {
             modal_window_show($("#password_popup"));
             $("#password").focus();
             return;
         }
 
-        /*}}}*/
-
-        function cancel_ask_for_password() {/*{{{*/
+        function cancel_ask_for_password() {
             modal_window_hide();
             $("#btn_directdebit").focus();
             return;
         }
 
-        /*}}}*/
-
-
-        function generate_directdebit() {/*{{{*/
-
+        function generate_directdebit() {
             var password = $('#password').val();
             var directdebitcontent = "";
             var directdebitcontent2 = "Wird nur bei SEPA verwendet.";
@@ -256,7 +243,6 @@ function action_directdebit()
                         break;
 
                     case "pain":
-
                         // datejs.com MAGIC
                         var jetzt = new Date.today();
                         var collectiondate = new Date.parse('<?php echo $config->get('direct_debit')['day']; ?>');
@@ -265,64 +251,58 @@ function action_directdebit()
                         }
 
                         if (!SEPACORE.init(collectiondate, '<?php echo $bank['creditor_id']; ?>', '<?php echo $bank['holder']; ?>', '<?php echo $bank['iban']; ?>', '<?php echo $bank['bic']; ?>'')) {
-                            $('#directdebit_content').val(DTAUS.errormsg);
-                            return;
-                        }
+                        $('#directdebit_content').val(DTAUS.errormsg);
+                        return;
+                }
 
-                        for (var i = 0; i < debits.length; i++) {
+                for (var i = 0; i < debits.length; i++) {
 
-                            if (debits[i]['debittype'] != 'FRST' && debits[i]['debittype'] != 'RCUR') {
-                                continue;
-                            }
+                    if (debits[i]['debittype'] != 'FRST' && debits[i]['debittype'] != 'RCUR') {
+                        continue;
+                    }
 
-                            var accountholder = debits[i]['accountholder'];
-                            var accountnumber = debits[i]['accountnumber'];
-                            var bankcode = debits[i]['bankcode'];
+                    var accountholder = debits[i]['accountholder'];
+                    var accountnumber = debits[i]['accountnumber'];
+                    var bankcode = debits[i]['bankcode'];
 
-                            // Encrypt/Decrypt data using AES with masterkey
-                            if (accountholder != "") accountholder = Crypto.charenc.UTF8.bytesToString(Crypto.AES.decrypt(accountholder, masterkey));
-                            if (accountnumber != "") accountnumber = Crypto.charenc.UTF8.bytesToString(Crypto.AES.decrypt(accountnumber, masterkey));
-                            if (bankcode != "") bankcode = Crypto.charenc.UTF8.bytesToString(Crypto.AES.decrypt(bankcode, masterkey));
+                    // Encrypt/Decrypt data using AES with masterkey
+                    if (accountholder != "") accountholder = Crypto.charenc.UTF8.bytesToString(Crypto.AES.decrypt(accountholder, masterkey));
+                    if (accountnumber != "") accountnumber = Crypto.charenc.UTF8.bytesToString(Crypto.AES.decrypt(accountnumber, masterkey));
+                    if (bankcode != "") bankcode = Crypto.charenc.UTF8.bytesToString(Crypto.AES.decrypt(bankcode, masterkey));
 
-                            // Mandatsreferenz '/V1/M:n/'; z.B. /V:1/M:2/
-                            var mandateref = '/V:1/M:' + debits[i]['member_number'] + '/';
-                            var e2eid = '/V:1/E2E:' + parseInt(SEPACORE.creationdate.getTime() / 1000) + '/S:' + debits[i]['debittype'][0] + '/I:' + i + '/';
-                            if (!SEPACORE.addDDTx(debits[i]['debittype'], accountholder, accountnumber, bankcode, mandateref, debits[i]['ddmandatesigdate'].substring(0, 10), debits[i]['amountcent'], debits[i]['purpose'], e2eid)) {
-                                $('#directdebit_content').val('Mitglied ' + debits[i]['member_number'] + ' ' + accountholder + '\n' + SEPACORE.errormsg);
-                                return;
-                            }
-                        }
+                    // Mandatsreferenz '/V1/M:n/'; z.B. /V:1/M:2/
+                    var mandateref = '/V:1/M:' + debits[i]['member_number'] + '/';
+                    var e2eid = '/V:1/E2E:' + parseInt(SEPACORE.creationdate.getTime() / 1000) + '/S:' + debits[i]['debittype'][0] + '/I:' + i + '/';
+                    if (!SEPACORE.addDDTx(debits[i]['debittype'], accountholder, accountnumber, bankcode, mandateref, debits[i]['ddmandatesigdate'].substring(0, 10), debits[i]['amountcent'], debits[i]['purpose'], e2eid)) {
+                        $('#directdebit_content').val('Mitglied ' + debits[i]['member_number'] + ' ' + accountholder + '\n' + SEPACORE.errormsg);
+                        return;
+                    }
+                }
 
-                        directdebitcontent = SEPACORE.getXMLContent('FRST');
-                        directdebitcontent2 = SEPACORE.getXMLContent('RCUR');
+                directdebitcontent = SEPACORE.getXMLContent('FRST');
+                directdebitcontent2 = SEPACORE.getXMLContent('RCUR');
 
-                        if (SEPACORE.errormsg.lenght > 0) {
-                            $('#directdebit_content').val(SEPACORE.errormsg);
-                            return;
-                        }
-                        break;
+                if (SEPACORE.errormsg.lenght > 0) {
+                    $('#directdebit_content').val(SEPACORE.errormsg);
+                    return;
                 }
-                $('#directdebit_content').val(directdebitcontent);
-                $('#directdebit_content2').val(directdebitcontent2);
-                $('#directdebit_content').focus();
-                $('#directdebit_content').select();
-            });
-
+            };
+            $('#directdebit_content').val(directdebitcontent);
+            $('#directdebit_content2').val(directdebitcontent2);
+            $('#directdebit_content').focus();
+            $('#directdebit_content').select();
         }
 
-        /*}}}*/
+        )
+        }
 
-        function directdebit_close() {/*{{{*/
+        function directdebit_close() {
             modal_window_hide();
             $("#directdebit_content").val('');
             $("#directdebit_content2").val('');
         }
-
-        /*}}}*/
-
-
     </script>
-    <?
+    <?php
 }
 
 // borrowed from PEARs Payment_DTA
@@ -541,7 +521,6 @@ function dtaus_string($string)
         'Ž' => 'Z',
     );
 
-
     $result = strtr($string, $special_chars);   // replace known special chars
     $result = strtoupper($result);                  // upper case
     // make sure every special char is replaced by one space, not two or three