+ Report Vertrag
authorBettina Schwarzer <schwarzer@fhi-berlin.mpg.de>
Fri, 16 Sep 2011 16:15:15 +0200
changeset 11 245f994f8fa0
parent 10 f538f73ebc37
child 12 2d8be944f381
+ Report Vertrag
fhiiqm/css/db.css
fhiiqm/css/db_print.css
fhiiqm/form/vertrag_report_form.inc.php
fhiiqm/gefahr_ap_search.php
fhiiqm/img/printer.png
fhiiqm/inc/menu.inc.html
fhiiqm/report/vertrag_report_kost.php
fhiiqm/start.php
fhiiqm/vertrag_report.html
--- a/fhiiqm/css/db.css	Thu Sep 15 11:45:38 2011 +0200
+++ b/fhiiqm/css/db.css	Fri Sep 16 16:15:15 2011 +0200
@@ -40,14 +40,14 @@
     margin-right: 0.3em;
     vertical-align: text-top;
 }
-a:link {
+a:link, a:visited {
     font-family:  Verdana, Arial, Helvetica, Geneva, sans-serif;
     font-size: 11px;
     line-height: 12px;
     font-weight: bold;
     color: #07079E;
     text-decoration: none;}
-
+/*
 a:visited {
     font-family:  Verdana, Arial, Helvetica, Geneva, sans-serif;
     font-size: 11px;
@@ -55,7 +55,7 @@
     font-weight: normal;
     color: #07079E;
     text-decoration: none;}
-
+*/
 a:hover {
     font-family:  Verdana, Arial, Helvetica, Geneva, sans-serif;
     font-size: 11px;
@@ -135,7 +135,7 @@
 
 .bigger
 {
-    font-size: 111%;    
+    font-size: 1.1em;    
     text-align: left;
 }
 .left
@@ -146,6 +146,10 @@
 {
     text-align: right;
 }
+.center
+{
+    text-align: center;
+}
 .long20
 {
     width: 20em;
--- a/fhiiqm/css/db_print.css	Thu Sep 15 11:45:38 2011 +0200
+++ b/fhiiqm/css/db_print.css	Fri Sep 16 16:15:15 2011 +0200
@@ -1,7 +1,7 @@
 /* class="sc" verhindert Druck ueber Druckmenu*/
 .sc {display: none;}
 
-a:link {
+a:link, a:visited {
     font-family:  Verdana, Arial, Helvetica, Geneva, sans-serif;
     font-size: 11px;
     line-height: 12px;
@@ -9,14 +9,6 @@
     color: #07079E;
     text-decoration: none;}
 
-a:visited {
-    font-family:  Verdana, Arial, Helvetica, Geneva, sans-serif;
-    font-size: 11px;
-    line-height: 12px;
-    font-weight: normal;
-    color: #07079E;
-    text-decoration: none;}
-
 a:hover {
     font-family:  Verdana, Arial, Helvetica, Geneva, sans-serif;
     font-size: 11px;
@@ -96,13 +88,17 @@
 
 .bigger
 {
-    font-size: 110%;    
+    font-size: 1.1em;    
     text-align: left;
 }
 .left
 {
     text-align: left;
 }
+.center
+{
+    text-align: center;
+}
 .right
 {
     text-align: right;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/form/vertrag_report_form.inc.php	Fri Sep 16 16:15:15 2011 +0200
@@ -0,0 +1,133 @@
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 09/2011
+ * 
+ * Form Berichte Vertrag
+ */
+
+
+	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
+	if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
+    $okn = true;
+
+?>
+<div align="center">
+<h3><font face="Verdana, Arial, Helvetica, sans-serif"></font></h3>
+<p>Bitte Kriterien f&uuml;r den Vertragsbericht w&auml;hlen</p>
+</div>
+<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="application/x-www-form-urlencoded" name="form_rag" target="_self">	
+<div align="center">
+<table width="50%" border="0" cellspacing="3" cellpadding="3">
+    <tr>
+        <td>Produktgruppe</td>
+        <td><select name="vr[prodg]">
+            <?php 
+                $select = null;
+                if ($vr["prodg"] == -1) $select = " selected "; else $select = "";
+                echo "<option $select value=\"-1\"></option>\n";
+                $sql = "SELECT prod_group_ID, prod_group_name FROM Produkt_Gruppe ORDER BY 2";
+                if ($result = $dbc->queryObjectArray($sql))
+                {
+                    foreach ($result as $row)
+                    {
+                        if (is_array($vr["prodg"])) $select = in_array( $row->prod_group_ID, $vr["prodg"] ) ? ' selected' : null;
+    					   echo "<option $select value=\"$row->prod_group_ID\">$row->prod_group_name</option>\n";
+                    }
+                }
+            ?>
+            </select>
+        </td>
+    </tr>
+    <tr>
+        <td>Produkt</td>
+        <td><select name="vr[prod]">
+            <?php 
+                $select = null;
+                if ($vr["prod"] == -1) $select = " selected "; else $select = "";
+                echo "<option $select value=\"-1\"></option>\n";
+                $sql = "SELECT produkt_ID, prod_name FROM Produkt ORDER BY 2";
+                if ($result = $dbc->queryObjectArray($sql))
+                {
+                    foreach ($result as $row)
+                    {
+                        if (is_array($vr["prod"])) $select = in_array( $row->produkt_ID, $vr["prod"] ) ? ' selected' : null;
+    					   echo "<option $select value=\"$row->produkt_ID\">$row->prod_name</option>\n";
+                    }
+                }
+            ?>
+            </select>
+        </td>
+    </tr>
+    <tr>
+        <td>Vertrag-Typ</td>
+        <td><select name="vr[vtyp]">
+            <?php 
+                $select = null;
+                if ($vr['vtyp'] == -1) $select = " selected "; else $select = "";
+                echo "<option $select value=\"-1\"></option>\n";
+                $sql = "SELECT vtyp_ID, vtyp_bezeichnung FROM Vertrag_Typ ORDER BY 2";
+                if ($result = $dbc->queryObjectArray($sql))
+                {
+                    foreach ($result as $row)
+                    {
+                        if (is_array($vr["vtyp"])) $select = in_array( $row->vtyp_ID, $vr["vtyp"] ) ? ' selected' : null;
+	                       echo "<option $select value=\"$row->vtyp_ID\">$row->vtyp_bezeichnung</option>\n";
+                    }
+            }
+            ?>
+            </select>
+        </td>
+    </tr>
+    <tr>
+        <td>Jahr</td>
+        <td>
+             <select name="vr[jahr]" size="1">
+    		 <?php
+        		if (!$vr['jahr'] ) 
+        		 	echo "<option selected value=\"-1\"></option>\n";  
+        		else
+        		 	echo "<option value=\"-1\"></option>\n";  
+        		$ja = $vr['jahr'];
+        		for ($i=2000; $i<2031; $i++)
+        		 {	if ($i==intval($j1)) 
+        				echo "<option selected>$ja1</option>\n";
+        			else		
+        				echo "<option>$i</option>\n";
+        		  }
+    		 ?> 
+    		 </select>
+        </td>
+    </tr>    
+    <tr> 
+          <td>Verkn&uuml;pfung</td>
+          <td>UND&nbsp;&nbsp;&nbsp;
+            <input type="radio" name="vr[bind]" value="AND" <?php if (isset($vr["bind"]) && $vr["bind"]=="AND") echo "checked"; else  echo "checked";?>>
+          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ODER&nbsp;&nbsp;&nbsp;
+            <input type="radio" name="vr[bind]" value="OR" <?php if (isset($vr["bind"]) && $vr["bind"]=="OR") echo "checked"; ?>></td>
+    </tr>
+    <tr>
+        <td>Sortierung nach<br />(in dieser Reihenfolge)</td><td>
+    <?php
+        $sort = array("-1"=>"","2"=>"Vertragsbezeichnung","10"=>"Kosten","11"=>"Kostenjahr");
+        for ($i=1; $i<4; $i++)
+        { 
+          echo "$i.&nbsp;&nbsp;<select name='vr[sort$i]'>\n";
+          foreach ($sort as $key=>$val)
+          {
+            $rsort = $sort . $i;
+            if ($rag[$rsort] == $i) $select= " selected"; else $select = "";
+            echo "<option$select value='$key'>$val</option>\n";
+          }
+          echo "</select>&nbsp;&nbsp;&nbsp;&nbsp;\n";
+        } 
+        echo "</td></tr>\n";
+    ?>
+    <tr> 
+        <td>&nbsp;</td>
+        <td><input class="button" type="submit" name="create" value="Bericht erstellen"></td>
+    </tr>
+</table>
+</div>
+</form>
\ No newline at end of file
--- a/fhiiqm/gefahr_ap_search.php	Thu Sep 15 11:45:38 2011 +0200
+++ b/fhiiqm/gefahr_ap_search.php	Fri Sep 16 16:15:15 2011 +0200
@@ -22,7 +22,6 @@
 
     error_reporting(E_ALL ^ E_NOTICE);
     
-    $query = $_POST["query"]; // alle Filterfelder
     
     $zeil = $_GET["z"];
     if (!$zeil) $zeil = 25; // Anzahl der gezeigten Zeilen
Binary file fhiiqm/img/printer.png has changed
--- a/fhiiqm/inc/menu.inc.html	Thu Sep 15 11:45:38 2011 +0200
+++ b/fhiiqm/inc/menu.inc.html	Fri Sep 16 16:15:15 2011 +0200
@@ -9,7 +9,7 @@
         		<li><a href="vertrag_ins.php" target="_blank" title="Vertrag erfassen">Vertrag erfassen</a></li>
         		<li><a href="partner_flist.php" target="_blank" title="Partnerliste">Vertragspartner sortieren, filtern, bearbeiten</a></li>
                 <li><a href="partner_ins.php" target="_blank" title="Partner erfassen">Vertragspartner erfassen</a></li>
-                <li><a href="#">Berichte</a></li>
+                <li><a href="vertrag_report.html" target="_blank" title="Berichte">Berichte</a></li>
 
 			</ul>
         </li>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/report/vertrag_report_kost.php	Fri Sep 16 16:15:15 2011 +0200
@@ -0,0 +1,181 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
+   	<link href="/fhiiqm/css/db.css" rel="STYLESHEET" type="TEXT/CSS"  media="screen"/> 
+   	<link href="/fhiiqm/css/db_print.css" rel="STYLESHEET" type="TEXT/CSS"  media="print"/> 
+	<title>Bericht Vertrag-Kosten</title>
+</head>
+
+<body >
+    <div class="float-r"><img src="/fhiiqm/img/document_mark_as_final.png" border="0" alt="Bericht" title="Bericht"/></div>
+
+<?php
+
+/**
+ * @author Bettina Schwarzer, Fritz-Haber-Institut
+ * @copyright 08/2011
+ *
+ * Report Vertrag
+ * 
+ */ 
+
+
+    error_reporting(E_ALL ^ E_NOTICE);
+    
+    $vr    = $_POST["vr"];    // Parameter aus Form
+    $create = $_POST["create"];
+    
+//    print_r($vr); echo "<br /><br />";
+    
+    echo "<div align='center'><h3>Bericht: Vertrag - Kosten pro Jahr</h3></div>\n";
+    if (!isset($create) || !$create)
+    {
+        include($_SERVER["DOCUMENT_ROOT"]. "/fhiiqm/form/vertrag_report_form.inc.php");
+        echo "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>";
+        echo "<p>&nbsp;&nbsp;&nbsp;<a href=\"/fhiiqm/vertrag_report.html\" target=\"_self\" title=\"Berichte\">&laquo; zur Berichts&uuml;bersicht</a></p>\n";    
+    }    
+    else
+    {
+        // Kriterien sind klar
+        echo "<div align='center'>\n";
+
+    	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
+//        include ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
+    
+    	$dbc = new dbconnection();
+        
+        $sql1 = "SELECT v.contract_ID,contract_name,contract_l,contract_begin,contract_end,v.vtyp_ID,
+                        pv.produkt_ID,prod_name,prod_group_ID,kosten,k_year,vtyp_kurz 
+                    FROM fhiiqm.Vertrag v 
+                    INNER JOIN fhiiqm.Vertrag_Kosten k ON v.contract_ID=k.contract_ID
+                    INNER JOIN fhiiqm.Produkt_Vertrag pv ON v.contract_ID=pv.contract_ID
+                    INNER JOIN fhiiqm.Produkt p ON pv.produkt_ID=p.produkt_ID
+                    INNER JOIN fhiiqm.Vertrag_Typ t ON v.vtyp_ID=t.vtyp_ID
+                    WHERE (contract_end IS NULL OR YEAR(contract_end)>=YEAR(Current_Date()))";
+
+        $sql2 = "SELECT SUM(kosten) AS sumkosten, k_year
+                    FROM fhiiqm.Vertrag v 
+                    INNER JOIN fhiiqm.Vertrag_Kosten k ON v.contract_ID=k.contract_ID
+                    INNER JOIN fhiiqm.Produkt_Vertrag pv ON v.contract_ID=pv.contract_ID
+                    INNER JOIN fhiiqm.Produkt p ON pv.produkt_ID=p.produkt_ID
+                    WHERE (contract_end IS NULL OR YEAR(contract_end)>=YEAR(Current_Date()))";
+
+        if (!$vr["bind"]) $bind = " AND "; else $bind = $vr["bind"];
+        
+        if ($vr["prodg"]> -1)
+        { 
+            if ($where) $where .= " $bind prod_group_ID = $vr[prodg] "; else $where = " prod_group_ID = $vr[prodg] ";
+
+            if ($krit) $bd = " ".$bind; else $bd = "";
+            $sql = "SELECT prod_group_name FROM Produkt_Gruppe WHERE prod_group_ID = " . $vr["prodg"];
+            $res = $dbc -> querySingleItem($sql);
+            $krit .= $bd." [Produktgruppe = '$res']";
+        }   
+        if ($vr["prod"]> -1)
+        { 
+            if ($where) $where .= " $bind pv.produkt_ID= $vr[prod] "; else $where = " pv.produkt_ID= $vr[prod] ";
+
+            if ($krit) $bd = " ".$bind; else $bd = "";
+            $sql = "SELECT prod_name FROM Produkt WHERE produkt_ID = " . $vr["prod"];
+            $res = $dbc -> querySingleItem($sql);
+            $krit .= $bd. " [Produkt = '$res']";
+        }   
+        if ($vr["vtyp"]> -1)
+        { 
+            if ($where) $where .= " $bind v.vtyp_ID = $vr[vtyp] "; else $where = " v.vtyp_ID = $vr[vtyp] ";
+
+            if ($krit) $bd = " ".$bind; else $bd = "";
+            $sql = "SELECT vtyp_bezeichnung FROM Vertrag_Typ WHERE vtyp_ID = " . $vr["vtyp"];
+            $res = $dbc -> querySingleItem($sql);
+            $krit .= $bd." [Vertragtyp = '$res']";
+        }    
+        if ($vr["jahr"]> -1)
+        { 
+            if ($where) $where .= " $bind k_year = $vr[jahr] "; else $where = " k_year = $vr[jahr] ";
+//            $hav = " HAVING k_year = $vr[jahr]";
+
+            if ($krit) $bd = " ".$bind; else $bd = "";
+            $krit .= $bd." [Kostenjahr = '" . $vr["jahr"] ."']";
+        }
+        if ($where) $where = " AND $where";
+        
+        if ($vr["sort1"]>0 || $rag["sort2"]>0)
+        {
+            if ($vr["sort1"]>0) $ord  = " ORDER BY " . $vr["sort1"];
+            if ($vr["sort2"]>0) $ord .= ",".$vr["sort2"];
+        }
+        
+        $sql1 .= $where . $ord;
+//        echo "<br /><br />sql1 = $sql1<br /><br />\n";
+        $result = $dbc ->queryObjectArray($sql1);
+        if ($dbc->error) echo $dbc->error . "<br />";
+        if ($krit )echo "<p>Filter: $krit</p>";
+
+        if ($result)
+        {
+    		$bg1 = "#F8F8F8";
+    		$bg2 = "#DEDFE1";
+    		$bg = "#FFFFFF";
+            echo "<table border='1' cellspacing='0' cellpadding='2' width=65%>\n";
+            // Listenkopf
+            echo "<tr bgcolor='#68ACBF'>";
+            echo "<th width='25%'>Bezeichnung</th>";
+            echo "<th width='40%'>Beschreibung</th>";
+            echo "<th width='3%'>Typ</th>";
+            echo "<th width='15%'>zu Produkt</th>";
+            echo "<th width='12%'>Kosten (&euro;)</th>";
+            echo "<th width='5%'>Kosten-Jahr</th></tr>\n";
+
+            
+            foreach ($result as $row)
+            {
+        			if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
+                    echo "<tr bgcolor='" . $bg . "'>"; 
+                    echo "<td>$row->contract_name</td>";
+                    echo "<td>$row->contract_l</td>";
+                    echo "<td>$row->vtyp_kurz</td>";
+                    echo "<td>$row->prod_name</td>";
+                    echo "<td class='right'>". number_format($row->kosten,2,",",".") ."</td>";
+                    echo "<td class='center'>$row->k_year</td></tr>\n";
+            }   
+
+            // Summe Kosten
+            $sql2 .= $where . " GROUP BY k_year";
+//            echo "<br /><br />sql2 = $sql2<br /><br />\n";
+            $result = $dbc ->queryObjectArray($sql2);
+            if ($dbc->error) echo $dbc->error . "<br />";
+            if ($result)
+            {
+                foreach ($result as $row)
+                {
+        			if ($bg == $bg1) $bg = $bg2; else $bg = $bg1;
+                    echo "<tr bgcolor='" . $bg . "'>";
+                    echo "<td colspan='3'>&nbsp;</td>"; 
+                    echo "<td><b>&sum; Kosten</b></td>"; 
+                    echo "<td class='right'><b>". number_format($row->sumkosten,2,",",".") ."</b></td>";
+                    echo "<td class='center'><b>$row->k_year</b></td></tr>\n";
+                    
+                }
+            }
+
+            echo "</table>\n";
+
+            echo "<p></p><table width=65%><tr><td class='right'><a href=\"javascript:window.print()\" class='sc'>
+                <img src=\"/fhiiqm/img/printer.png\" alt=\"Bericht drucken\" border=\"0\" align=\"right\" title=\"Bericht drucken\"></a></td></tr></table>";
+            
+        }
+        else echo "<p class='red'>&nbsp;&nbsp;&nbsp;Leider gibt es kein Ergebnis für die von Ihnen gewählten Kriterien!</p>";
+        
+        echo "</div>\n";
+        echo "<br /><br />&nbsp;&nbsp;&nbsp;<a href=\"" . $_SERVER["PHP_SELF"] . "\" target=\"_self\" 
+                title=\"Report Vertrag-Kosten\" class=\"sc\">neuer Bericht Vertrag - Kosten</a></p>\n";
+        
+        echo "<p>&nbsp;&nbsp;&nbsp;<a href=\"/fhiiqm/vertrag_report.html\" target=\"_self\" title=\"Berichte\">&laquo; zur Berichts&uuml;bersicht</a></p>\n";    
+    }
+
+?>
+
+</body>
+</html>
\ No newline at end of file
--- a/fhiiqm/start.php	Thu Sep 15 11:45:38 2011 +0200
+++ b/fhiiqm/start.php	Fri Sep 16 16:15:15 2011 +0200
@@ -5,7 +5,7 @@
 	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    	<link href="css/db.css" rel="STYLESHEET" type="TEXT/CSS" /> 
    	<link href="css/navio.css" rel="STYLESHEET" type="TEXT/CSS" /> 
-	<meta name="author" content="Bettina Schwarzer" />
+	<meta name="author" content="Bettina Schwarzer, FHI" />
 
 	<title>FHI Administration</title>
 </head>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/vertrag_report.html	Fri Sep 16 16:15:15 2011 +0200
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
+   	<link href="css/db.css" rel="STYLESHEET" type="TEXT/CSS" /> 
+   	<link href="css/navio.css" rel="STYLESHEET" type="TEXT/CSS" /> 
+	<meta name="author" content="Bettina Schwarzer,FHI" />
+
+	<title>Reports Vertrag</title>
+</head>
+
+<body>
+    <div class="float-r"><img src="/fhiiqm/img/document_mark_as_final.png" border="0" alt="Bericht" title="Bericht"/></div>
+    <h3>&nbsp;&nbsp;&nbsp;Berichte zu Vertr&auml;gen</h3>
+    <p>&nbsp;</p>
+    <div align="center">
+    <table width="94%" cellspacing="4" cellpadding="4">
+        <tr>
+            <td class="bigger">
+                <a href="/fhiiqm/report/vertrag_report_kost.php" title="Vertr&auml;ge - Kosten">Vertr&auml;ge und Kosten pro Jahr</a>
+                <br />&nbsp;&nbsp;&nbsp;Auswahl: Produktgruppe, Produkt, Vertragstyp, Kostenjahr
+                <br />&nbsp;&nbsp;&nbsp;Ansicht: Vertragsbezeichnung, -beschreibung, Vertragstyp, Kosten, Kostenjahr
+            </td>
+        </tr>
+        <tr>
+            <td class="bigger">
+                <a href="#" title="Vertr&auml;ge - K&uuml;ndigungsfrist">Vertr&auml;ge - K&uuml;ndigungsfrist</a>
+                <br />&nbsp;&nbsp;&nbsp;Auswahl: Produktgruppe, Produkt, Vertragstyp
+            </td>
+        </tr>
+    </table>
+    </div>    
+
+
+</body>
+</html>
\ No newline at end of file