Rename generic export.php to less generic exportxls.php
authorAndreas Schiermeier <andreas@schiermeier.name>
Mon, 30 Dec 2013 19:49:47 +0000 (20:49 +0100)
committerAndreas Schiermeier <andreas@schiermeier.name>
Mon, 30 Dec 2013 19:49:47 +0000 (20:49 +0100)
include/export.php [deleted file]
include/xlsexport.php [new file with mode: 0644]

diff --git a/include/export.php b/include/export.php
deleted file mode 100644 (file)
index bc7e305..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php
-
-function action_export() {
-       global $EARNING_TYPES, $EXPENSE_TYPES;
-
-    error_reporting(error_reporting() & ~E_DEPRECATED);
-       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();
-}
-
-
-
diff --git a/include/xlsexport.php b/include/xlsexport.php
new file mode 100644 (file)
index 0000000..bc7e305
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+
+function action_export() {
+       global $EARNING_TYPES, $EXPENSE_TYPES;
+
+    error_reporting(error_reporting() & ~E_DEPRECATED);
+       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();
+}
+
+
+