--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/vertrag_list12_csv.php Mon May 07 16:21:00 2012 +0200
@@ -0,0 +1,89 @@
+<?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_flist12(" . $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";
+
+ foreach ($result as $row)
+ {
+ $file .= $row->contract_ID . ";";
+ $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->yearkosten)
+ { // Form: yyyy:nnn.nn|yyyy:nnnnn|yyyy:nn.n usw.
+ $yka = explode('|',$row->yearkosten);
+ $first = true;
+ foreach ($yka as $yk)
+ {
+ if (!$first) $file .= "\r\n$row->contract_ID;;;;;;;;;;;;;";
+ list($year,$kost) = explode(':',$yk);
+ $file .= $year .";" .number_format($kost,2,",",".") . ";";
+ $first = false;
+ }
+ }
+ else $file .= ";;";
+ $file .= "\r\n";
+ }
+
+ 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