--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/test/vertrag_list_csv.php Mon May 07 16:21:00 2012 +0200
@@ -0,0 +1,84 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 04/2012
+ *
+ * Export Vertragsliste als csv-File
+ *
+ */
+
+ error_reporting(E_ALL ^ E_NOTICE);
+
+ include_once($_SERVER["DOCUMENT_ROOT"]."/fhiiqm/inc/dbconnect.inc.php");
+ if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
+
+ $sort = $_GET["s"]; // Sortierung nach Spalte
+ if (!$sort) $sort = 2;
+ $dir = $_GET["d"]; // Sortierrichtung
+ if (!$dir) $dir = '';
+ $fnum = $_GET["f"]; // Spaltennummer, nach der aktuell gefiltert wird
+ if (!$fnum) $fnum = 1;
+ $filter = $_GET["b"]; // Filterbegriff
+ if (!$filter) $filter = '';
+ $start = $_GET["st"]; // Start-DS - 1
+ if (!$start) $start = 0;
+ $zeil = $_GET["z"]; // Anzahl zu zeigender DS
+ if (!$zeil) $zeil = 9999;
+ $listg = $_GET["l"]; // Recht fuer ausgewaehlte Produktgruppen
+ if (!$listg) $listg = '';
+
+ $sql = "CALL fhiiqm.vertrag_flist2(" . $sort . ",'" . $dir . "', " . $fnum . ", '" . $filter . "', '" . $listg . "',$start,$zeil, @anz, @ganz)";
+
+ $result = $dbc ->queryObjectArray($sql);
+
+ if ($result)
+ {
+ $crlf = array("\r\n","\n\r","\r","\n"); // Zeilenumbrueche
+ $file ="Vertrag-ID;Bezeichnung;Beschreibung;Typ;zu Produkt;Partner;Bearbeiter;Beginn;Ende;Verlängerung;Künd.Frist(mon);Bemerkung;E-Mail?;Jahr;Kosten\r\n";
+ $cid=0;
+
+ foreach ($result as $row)
+ {
+ $file .= $row->contract_ID . ";";
+ if ($row->contract_ID != $cid)
+ { // Anzeigen der nur einmal relevanten Daten
+ $file .= $row->cname . ";";
+ $file .= str_replace($crlf,", ",$row->clong) . ";";
+ $file .= $row->typ . ";";
+ $file .= str_replace(";",":",$row->prod) . ";";
+ $file .= $row->partfirma . ";";
+ $file .= str_replace(";",":",$row->bearb) . ";";
+ if ($row->cbegin)
+ {
+ $cb = new DateTime($row->cbegin);
+ $file .= $cb->format('d.m.Y').";";
+ }
+ else $file .= ";";
+ if ($row->cend)
+ {
+ $cb = new DateTime($row->cend);
+ $file .= $cb->format('d.m.Y').";";
+ }
+ else $file .= ";";
+ if ($row->cautoend) $file .= "automatisch;"; else $file .= ";";
+ $file .= $row->kmon . ";";
+ $file .= str_replace(";",":",str_replace($crlf,", ",$row->bem)) . ";";
+ if ($row->email) $file .= "ja;"; else $file .= ";";
+ }
+ if ($row->kosten)
+ {
+ if ($cid == $row->contract_ID) $file .= ";;;;;;;;;;;;";
+ $file .= $row->kyear .";";
+ $file .= number_format($row->kosten,2,",",".") . ";";
+ }
+ $file .= "\r\n";
+ $cid = $row->contract_ID;
+ }
+ header( 'Content-Type: text/csv' );
+ header('Content-Disposition: attachment; filename="vertrag.csv"');
+ header("Content-Length: " . strlen($file));
+ echo $file;
+ }
+ else echo "kein Ergebnis!";
+?>
\ No newline at end of file