Added XLS export of members.
authorAndreas Schiermeier <andreas@schiermeier.name>
Mon, 30 Dec 2013 20:08:17 +0000 (21:08 +0100)
committerAndreas Schiermeier <andreas@schiermeier.name>
Mon, 30 Dec 2013 20:08:17 +0000 (21:08 +0100)
include/members.php
include/xlsexport.php
index.php

index 6fc8b14..272dbc1 100644 (file)
@@ -305,6 +305,7 @@ function action_list_members() {/*{{{*/
         <p>Derzeit gibt es <?=$count?> aktive Mitglieder.</p>
         <a href="<?=link_to('create_member')?>">Neues Mitglied</a>
         <a href="<?=link_to('export_email')?>">E-Mail-Adressen</a>
+        <a href="<?=link_to('export_members')?>">XLS Export</a>
     <?php
 }/*}}}*/
 
index 1c247c6..7944fa1 100644 (file)
@@ -1,5 +1,88 @@
 <?php
 
+function action_export_members() {
+       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('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');
+       $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']);
+               $col = 0;
+               $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;
 
@@ -66,4 +149,4 @@ function action_export_payments() {
 }
 
 
-
+?>
\ No newline at end of file
index b901e38..ee443a1 100644 (file)
--- a/index.php
+++ b/index.php
@@ -55,6 +55,7 @@ try {
         case 'dtaus'          : action_dtaus();           break;
         case 'finances'       : action_finances();        break;
         case 'export'         : action_export_payments(); break;
+        case 'export_members' : action_export_members(); break;
         default: action_404();
     }