Formatting
[memberdb.git] / include / xlsexport.php
index e32252d..2f98536 100644 (file)
 <?php
 
-function action_export_members() {
-       global $EARNING_TYPES, $EXPENSE_TYPES;
-
+function action_export_members()
+{
     error_reporting(error_reporting() & ~E_DEPRECATED & ~E_STRICT);
-       require_once 'vendor/autoload.php';
-
-       // Creating a workbook
-       $workbook = new Spreadsheet_Excel_Writer();
-       $workbook->setVersion(8);
-
-       // sending HTTP headers
-       $workbook->send('Mitglieder.xls');
-
-       // Creating a worksheet
-
-       $members = db_get_members();
-
-
-       $row = 0;
-       $col = 0;
-
-       $worksheet =& $workbook->addWorksheet('Mitglieder');
-       $worksheet->setInputEncoding('UTF-8');
-       $row = 0;
-       $worksheet->write($row, $col++, 'Mitgliedsnummer');
-       $worksheet->write($row, $col++, 'Nickname');
-       $worksheet->write($row, $col++, 'E-Mail');
-       $worksheet->write($row, $col++, 'Vorname');
-       $worksheet->write($row, $col++, 'Nachname');
-       $worksheet->write($row, $col++, 'Straße');
-       $worksheet->write($row, $col++, 'Hausnummer');
-       $worksheet->write($row, $col++, 'PLZ');
-       $worksheet->write($row, $col++, 'Ort');
-       $worksheet->write($row, $col++, 'Land');
-       $worksheet->write($row, $col++, 'Telefon');
-       $worksheet->write($row, $col++, 'Fax');
-       $worksheet->write($row, $col++, 'Handy');
-       $worksheet->write($row, $col++, 'Jabber');
-       $worksheet->write($row, $col++, 'ICQ');
-       $worksheet->write($row, $col++, 'MSN');
-       $worksheet->write($row, $col++, 'AIM');
-       $worksheet->write($row, $col++, 'Skype');
-       $worksheet->write($row, $col++, 'Website');
-       $worksheet->write($row, $col++, 'Twitter');
-       $worksheet->write($row, $col++, 'Lastschrifteinzug');
-       $worksheet->write($row, $col++, 'Status');
-       $row++;
-       
-       foreach ($members as $member) {
-               $col = 0;
-               $worksheet->write($row, $col++, $member['number']);    
-               $worksheet->write($row, $col++, $member['nickname']);    
-               $worksheet->write($row, $col++, $member['email']);     
-               $worksheet->write($row, $col++, $member['firstname']);    
-               $worksheet->write($row, $col++, $member['lastname']);    
-               $worksheet->write($row, $col++, $member['street']);    
-               $worksheet->write($row, $col++, $member['housenumber']);
-               $worksheet->write($row, $col++, $member['postcode']);      
-               $worksheet->write($row, $col++, $member['city']);         
-               $worksheet->write($row, $col++, $member['country']); 
-               $worksheet->write($row, $col++, $member['phone']);         
-               $worksheet->write($row, $col++, $member['fax']);         
-               $worksheet->write($row, $col++, $member['mobile']);         
-               $worksheet->write($row, $col++, $member['jabber']);         
-               $worksheet->write($row, $col++, $member['icq']);         
-               $worksheet->write($row, $col++, $member['msn']);         
-               $worksheet->write($row, $col++, $member['aim']);         
-               $worksheet->write($row, $col++, $member['skype']);         
-               $worksheet->write($row, $col++, $member['url']);    
-               $worksheet->write($row, $col++, $member['twitter']);
-               $worksheet->write($row, $col++, $member['directdebit']);
-               $membership_info = fees_info_for_member($member['id'], time());
-               $worksheet->write($row, $col++, $membership_info['is_member']);
-               $col = 0;
-               $row++;
-       }
-
-       // Let's send the file
-       $workbook->close();
-
-       $content = ob_get_contents();
-       ob_end_clean();
-       echo $content;
-       exit();
+
+    // Creating a workbook
+    $workbook = new Spreadsheet_Excel_Writer();
+    $workbook->setVersion(8);
+
+    // sending HTTP headers
+    $workbook->send('Mitglieder.xls');
+
+    // Creating a worksheet
+    $members = db_get_members();
+
+    $row = 0;
+    $col = 0;
+
+    $worksheet =& $workbook->addWorksheet('Mitglieder');
+    $worksheet->setInputEncoding('UTF-8');
+    $worksheet->write($row, $col++, 'Mitgliedsnummer');
+    $worksheet->write($row, $col++, 'Nickname');
+    $worksheet->write($row, $col++, 'E-Mail');
+    $worksheet->write($row, $col++, 'Vorname');
+    $worksheet->write($row, $col++, 'Nachname');
+    $worksheet->write($row, $col++, 'Straße');
+    $worksheet->write($row, $col++, 'Hausnummer');
+    $worksheet->write($row, $col++, 'PLZ');
+    $worksheet->write($row, $col++, 'Ort');
+    $worksheet->write($row, $col++, 'Land');
+    $worksheet->write($row, $col++, 'Telefon');
+    $worksheet->write($row, $col++, 'Fax');
+    $worksheet->write($row, $col++, 'Handy');
+    $worksheet->write($row, $col++, 'Jabber');
+    $worksheet->write($row, $col++, 'ICQ');
+    $worksheet->write($row, $col++, 'MSN');
+    $worksheet->write($row, $col++, 'AIM');
+    $worksheet->write($row, $col++, 'Skype');
+    $worksheet->write($row, $col++, 'Website');
+    $worksheet->write($row, $col++, 'Twitter');
+    $worksheet->write($row, $col++, 'Lastschrifteinzug');
+    $worksheet->write($row, $col++, 'Mandatunterschriftsdatum');
+    $worksheet->write($row, $col, 'Status');
+    $row++;
+
+    foreach ($members as $member) {
+        $col = 0;
+        $worksheet->write($row, $col++, $member['number']);
+        $worksheet->write($row, $col++, $member['nickname']);
+        $worksheet->write($row, $col++, $member['email']);
+        $worksheet->write($row, $col++, $member['firstname']);
+        $worksheet->write($row, $col++, $member['lastname']);
+        $worksheet->write($row, $col++, $member['street']);
+        $worksheet->write($row, $col++, $member['housenumber']);
+        $worksheet->write($row, $col++, $member['postcode']);
+        $worksheet->write($row, $col++, $member['city']);
+        $worksheet->write($row, $col++, $member['country']);
+        $worksheet->write($row, $col++, $member['phone']);
+        $worksheet->write($row, $col++, $member['fax']);
+        $worksheet->write($row, $col++, $member['mobile']);
+        $worksheet->write($row, $col++, $member['jabber']);
+        $worksheet->write($row, $col++, $member['icq']);
+        $worksheet->write($row, $col++, $member['msn']);
+        $worksheet->write($row, $col++, $member['aim']);
+        $worksheet->write($row, $col++, $member['skype']);
+        $worksheet->write($row, $col++, $member['url']);
+        $worksheet->write($row, $col++, $member['twitter']);
+        $worksheet->write($row, $col++, $member['directdebit']);
+        $worksheet->write($row, $col++, $member['ddmandatesigdate']);
+        $membership_info = fees_info_for_member($member['id'], time());
+        $worksheet->write($row, $col, $membership_info['is_member']);
+        $row++;
+    }
+
+    // Let's send the file
+    $workbook->close();
+
+    $content = ob_get_contents();
+    ob_end_clean();
+    echo $content;
+    exit();
 }
 
-function action_export_payments() {
-       global $EARNING_TYPES, $EXPENSE_TYPES;
+function action_export_payments()
+{
+    global $EARNING_TYPES, $EXPENSE_TYPES;
 
     error_reporting(error_reporting() & ~E_DEPRECATED & ~E_STRICT);
-       require_once 'vendor/autoload.php';
-
-       // Creating a workbook
-       $workbook = new Spreadsheet_Excel_Writer();
-       $workbook->setVersion(8);
-
-       // sending HTTP headers
-       $workbook->send('Finanzen.xls');
-
-       // Creating a worksheet
-
-       $payments = db_get_finished_payments(0, 1000000000);
-
-
-       $row = 0;
-       $col = 0;
-       $current_year = '';
-
-       foreach ($payments as $payment) {
-               $year = substr($payment['date'], 0, 4);
-               if ($year != $current_year) {
-                       $current_year = $year;
-                       $worksheet =& $workbook->addWorksheet($year);
-                       $worksheet->setInputEncoding('UTF-8');
-                       $row = 0;
-
-                       $worksheet->write($row, $col++, 'Id');
-                       $worksheet->write($row, $col++, 'Datum');
-                       $worksheet->write($row, $col++, 'Kategorie');
-                       $worksheet->write($row, $col++, 'Betrag');
-                       $worksheet->write($row, $col++, 'Beschreibung');
-                       $worksheet->write($row, $col++, 'Mitglied');
-                       $worksheet->write($row, $col++, 'Kontostand');
-                       $worksheet->write($row, $col++, 'Kassenstand');
-                       $worksheet->write($row, $col++, 'Gesamt');
-                       $row++;
-                       $col = 0;
-               }
-               $worksheet->write($row, $col++, $payment['id']);
-               $worksheet->write($row, $col++, $payment['date']);
-               $worksheet->write($row, $col++, $payment['ptype'] == 'earning'? $EARNING_TYPES[$payment['type']] : $EXPENSE_TYPES[$payment['type']]);
-               $worksheet->write($row, $col++, ($payment['ptype'] == 'earning' ? 1 : -1)  * $payment['value']);
-               $worksheet->write($row, $col++, $payment['description']);
-               $worksheet->write($row, $col++, $payment['nickname']);
-               $worksheet->write($row, $col++, $payment['bank']);
-               $worksheet->write($row, $col++, $payment['cash']);
-               $worksheet->write($row, $col++, $payment['total']);
-
-               $col = 0;
-               $row++;
-       }
-
-       // Let's send the file
-       $workbook->close();
-
-       $content = ob_get_contents();
-       ob_end_clean();
-       echo $content;
-       exit();
-}
 
-
-?>
\ No newline at end of file
+    // Creating a workbook
+    $workbook = new Spreadsheet_Excel_Writer();
+    $workbook->setVersion(8);
+
+    // sending HTTP headers
+    $workbook->send('Finanzen.xls');
+
+    // Creating a worksheet
+    $payments = db_get_finished_payments(0, 1000000000);
+
+
+    $row = 0;
+    $col = 0;
+    $current_year = '';
+    foreach ($payments as $payment) {
+        $year = substr($payment['date'], 0, 4);
+        if ($year != $current_year) {
+            $current_year = $year;
+            $worksheet =& $workbook->addWorksheet($year);
+            $worksheet->setInputEncoding('UTF-8');
+            $row = 0;
+
+            $worksheet->write($row, $col++, 'Id');
+            $worksheet->write($row, $col++, 'Datum');
+            $worksheet->write($row, $col++, 'Kategorie');
+            $worksheet->write($row, $col++, 'Betrag');
+            $worksheet->write($row, $col++, 'Beschreibung');
+            $worksheet->write($row, $col++, 'Mitglied');
+            $worksheet->write($row, $col++, 'Kontostand');
+            $worksheet->write($row, $col++, 'Kassenstand');
+            $worksheet->write($row, $col, 'Gesamt');
+            $row++;
+            $col = 0;
+        }
+        $worksheet->write($row, $col++, $payment['id']);
+        $worksheet->write($row, $col++, $payment['date']);
+        $worksheet->write($row, $col++,
+            $payment['ptype'] == 'earning' ? $EARNING_TYPES[$payment['type']] : $EXPENSE_TYPES[$payment['type']]);
+        $worksheet->write($row, $col++, ($payment['ptype'] == 'earning' ? 1 : -1) * $payment['value']);
+        $worksheet->write($row, $col++, $payment['description']);
+        $worksheet->write($row, $col++, $payment['nickname']);
+        $worksheet->write($row, $col++, $payment['bank']);
+        $worksheet->write($row, $col++, $payment['cash']);
+        $worksheet->write($row, $col, $payment['total']);
+
+        $col = 0;
+        $row++;
+    }
+
+    // Let's send the file
+    $workbook->close();
+
+    $content = ob_get_contents();
+    ob_end_clean();
+    echo $content;
+    exit();
+}