+Rechte Produktgruppe
authorBettina Schwarzer <schwarzer@fhi-berlin.mpg.de>
Tue, 11 Oct 2011 12:17:55 +0200
changeset 15 1ed6fbdf4237
parent 14 32203b8f40ee
child 16 3ebe66308a00
+Rechte Produktgruppe
fhiiqm/form/vertrag_report_form.inc.php
fhiiqm/inc/func_lib.inc.php
fhiiqm/inc/menu.inc.php
fhiiqm/inc/vertrag_list_ac.inc.php
fhiiqm/vertrag_flist1.php
fhiiqm/vertrag_flist2.php
--- a/fhiiqm/form/vertrag_report_form.inc.php	Fri Oct 07 11:37:29 2011 +0200
+++ b/fhiiqm/form/vertrag_report_form.inc.php	Tue Oct 11 12:17:55 2011 +0200
@@ -24,9 +24,20 @@
         <td>Produktgruppe</td>
         <td><select name="vr[prodg]" <?php  if ($rvnr == 1) echo "onchange=\"this.form.submit();\""; ?>>
             <?php 
-                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 (is_array($_SESSION["prodg"]))
+                {
+                        foreach ($_SESSION["prodg"] as $val)
+                            $listg .= ",'" .$val . "'";
+                        $listg = substr($listg,1);
+                }
+                else
+                {
+                    if ($vr["prodg"] == -1) $select = " selected "; else $select = "";
+                    echo "<option $select value=\"-1\"></option>\n";
+                }    
+                //Einschraenkung Produktgruppe
+                if (isset($listg) && $listg) $wher = " WHERE prod_group_ID IN ($listg) "; else $wher = "";
+                $sql = "SELECT prod_group_ID, prod_group_name FROM Produkt_Gruppe $wher ORDER BY 2";
                 if ($result = $dbc->queryObjectArray($sql))
                 {
                     $select = "";
--- a/fhiiqm/inc/func_lib.inc.php	Fri Oct 07 11:37:29 2011 +0200
+++ b/fhiiqm/inc/func_lib.inc.php	Tue Oct 11 12:17:55 2011 +0200
@@ -155,8 +155,23 @@
                         {
                             $_SESSION["recht"] = null;
 //                            echo "error_recht: " . $dbc->error . "<br />";
-                        }    
+                        }
 //                        print_r($arecht);
+
+                        // Recht Produkt-Gruppe
+                        $sql = "SELECT prod_group_ID FROM user_prodgroup WHERE userid = '$userid'";   
+                        if ($re = $dbc -> queryObjectArray($sql))
+                        {
+                            $pgrecht = array();
+                            foreach ($re as $row)
+                            {    $pgrecht[] = $row->prod_group_ID;}
+                            if (count($pgrecht)>0)
+                                $_SESSION["prodg"] = $pgrecht;
+                            else 
+                                $_SESSION["prodg"] = null;
+                        }
+                        else 
+                            $_SESSION["prodg"] = null;
                 		header("Location: $target");
                 		exit;
                     }
--- a/fhiiqm/inc/menu.inc.php	Fri Oct 07 11:37:29 2011 +0200
+++ b/fhiiqm/inc/menu.inc.php	Tue Oct 11 12:17:55 2011 +0200
@@ -40,16 +40,16 @@
         {
           echo "<li>Vertragscontrolling\n
             	   <ul>\n";
-          if (in_array("vr",$_SESSION["recht"]))
+          if (in_array("vr",$_SESSION["recht"]) || in_array("ve",$_SESSION["recht"]))
             		echo "<li><a href=\"/fhiiqm/vertrag_flist1.php\" target=\"_blank\" title=\"Vertragsliste\">Vertr&auml;ge sortieren, filtern, bearbeiten</a></li>\n
             		<li><a href=\"/fhiiqm/vertrag_search.php\" target=\"_blank\" title=\"Vertrag suchen\">Vertrag suchen, bearbeiten</a></li>\n";
           if (in_array("ve",$_SESSION["recht"]))
             		echo "<li><a href=\"/fhiiqm/vertrag_ins.php\" target=\"_blank\" title=\"Vertrag erfassen\">Vertrag erfassen</a></li>\n";
-          if (in_array("vpr",$_SESSION["recht"]))
+          if (in_array("vpr",$_SESSION["recht"]) || in_array("vpe",$_SESSION["recht"]))
             		echo "<li><a href=\"/fhiiqm/partner_flist.php\" target=\"_blank\" title=\"Partnerliste\">Vertragspartner sortieren, filtern, bearbeiten</a></li>\n";
           if (in_array("vpe",$_SESSION["recht"]))
             		echo "<li><a href=\"/fhiiqm/partner_ins.php\" target=\"_blank\" title=\"Partner erfassen\">Vertragspartner erfassen</a></li>\n";
-          if (in_array("vr",$_SESSION["recht"]))
+          if (in_array("vr",$_SESSION["recht"]) || in_array("ve",$_SESSION["recht"]))
             		echo "<li><a href=\"/fhiiqm/vertrag_report.php\" target=\"_blank\" title=\"Berichte\">Berichte</a></li>\n";
     
     	  echo "	</ul>\n
@@ -59,7 +59,7 @@
         {
           echo "<li>Informationen zu FHI-Leistungen und Produkten\n
             	   <ul>\n";
-          if (in_array("ir",$_SESSION["recht"]))
+          if (in_array("ir",$_SESSION["recht"]) || in_array("ie",$_SESSION["recht"]))
             		echo "<li><a href=\"/fhiiqm/info_flist.php\" target=\"_blank\" title=\"Infoliste\">Informationen sortieren, filtern, bearbeiten</a></li>\n";
           if (in_array("ie",$_SESSION["recht"]))
             		echo "<li><a href=\"/fhiiqm/info_ins.php\" target=\"_blank\" title=\"Info erfassen\">Information erfassen</a></li>\n";
@@ -71,15 +71,15 @@
         {
           echo "<li>Stammdaten\n
             	   <ul>\n";
-          if (in_array("pr",$_SESSION["recht"]))
+          if (in_array("pr",$_SESSION["recht"]) || in_array("pe",$_SESSION["recht"]))
             		echo "<li><a href=\"/fhiiqm/prod_hier.php\" target=\"_blank\" title=\"Produkthierarchie\">Produkthierarchie</a></li>\n";
           if (in_array("pe",$_SESSION["recht"]))
             		echo "<li><a href=\"/fhiiqm/produkt_ins.php\" target=\"_blank\" title=\"Produkt erfassen\">Produkt erfassen</a></li>\n";
-          if (in_array("rr",$_SESSION["recht"]))
+          if (in_array("rr",$_SESSION["recht"]) || in_array("re",$_SESSION["recht"]))
             		echo "<li><a href=\"/fhiiqm/raum_flist.php\" target=\"_blank\" title=\"Raumliste\">R&auml;ume sortieren, filtern, bearbeiten</a></li>\n";
           if (in_array("re",$_SESSION["recht"]))
             		echo "<li><a href=\"/fhiiqm/raum_ins.php\" target=\"_blank\" title=\"Raum erfassen\">Raum erfassen</a></li>\n";
-          if (in_array("fmr",$_SESSION["recht"]))
+          if (in_array("fmr",$_SESSION["recht"]) || in_array("fme",$_SESSION["recht"]))
             		echo "<li><a href=\"/fhiiqm/ma_fkt_flist.php\" target=\"_blank\" title=\"MA-Funktionen-Liste\">Mitarbeiter - Funktion sort., filtern, bearbeiten</a></li>\n";
           if (in_array("fme",$_SESSION["recht"]))
             		echo "<li><a href=\"/fhiiqm/ma_fkt_ed.php\" target=\"_blank\" title=\"MA-Funktionen\">Mitarbeiter - Funktion erfassen</a></li>\n";
--- a/fhiiqm/inc/vertrag_list_ac.inc.php	Fri Oct 07 11:37:29 2011 +0200
+++ b/fhiiqm/inc/vertrag_list_ac.inc.php	Tue Oct 11 12:17:55 2011 +0200
@@ -10,6 +10,16 @@
     header('Content-type: text/html; charset="iso-8859-1',true); //wg. jquery ui autocomplete
     error_reporting(E_ALL ^ E_NOTICE);
     
+    // Recht Produktgruppe beruecksichtigen
+    session_start();
+    if (is_array($_SESSION["prodg"]))
+    {
+            foreach ($_SESSION["prodg"] as $val)
+                $listg .= "," .$val;
+            $listg = substr($listg,1);
+    }
+    else $listg = "";
+    
     $q = strtolower($_GET["term"]); // wird in jquery in 'term' uebergeben
 
     $su = array("ä","ö","ü","ß","Ä","Ö","Ü");
@@ -19,10 +29,18 @@
 	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
 	$dbc = new dbconnection();
 
-    $sql = "SELECT contract_ID,contract_name,t.vtyp_bezeichnung,contract_begin
-            FROM fhiiqm.Vertrag v LEFT OUTER JOIN fhiiqm.Vertrag_Typ t ON v.vtyp_ID=t.vtyp_ID 
-            WHERE contract_name LIKE '%".$q."%' COLLATE latin1_general_ci 
+    $sql = "SELECT v.contract_ID,contract_name,t.vtyp_bezeichnung,contract_begin
+            FROM fhiiqm.Vertrag v LEFT OUTER JOIN fhiiqm.Vertrag_Typ t ON v.vtyp_ID=t.vtyp_ID ";
+    if ($listg > "")
+        $sql .= " LEFT OUTER JOIN fhiiqm.Produkt_Vertrag pv ON v.contract_ID=pv.contract_ID
+            LEFT JOIN fhiiqm.Produkt p ON pv.produkt_ID=p.produkt_ID 
+            WHERE prod_group_ID IN ($listg) ";
+    else
+        $sql .= " WHERE 1=1 ";
+    
+    $sql .= " AND contract_name LIKE '%".$q."%' COLLATE latin1_general_ci 
             ORDER BY contract_name";
+
     $result = $dbc ->queryObjectArray($sql);
     if ($result)
     {
--- a/fhiiqm/vertrag_flist1.php	Fri Oct 07 11:37:29 2011 +0200
+++ b/fhiiqm/vertrag_flist1.php	Tue Oct 11 12:17:55 2011 +0200
@@ -78,6 +78,15 @@
     if (!isset($sort) && !$sort) $sort = 2;
     if (!isset($dir) && !$dir)  $dir = "";
     
+    // Recht Produktgruppe beruecksichtigen
+    if (is_array($_SESSION["prodg"]))
+    {
+            foreach ($_SESSION["prodg"] as $val)
+                $listg .= "," .$val;
+            $listg = substr($listg,1);
+    }
+    else $listg = "";
+
 //    echo "sort=$sort, fnum=$fnum, filter=$filter <br />";
     include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
     include_once ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
@@ -86,7 +95,7 @@
     echo "<div align='center'>\n";
 //echo "$sort, $dir, $fnum, $filter<br><br>\n";    
 //    $sql = "CALL fhiiqm.vertrag_flist1(" . $sort . ",'" . $dir . "', " . $fnum . ", '" . $filter . "',$start,$zeil, @anz)";
-    $sql = "CALL fhiiqm.vertrag_flist1_1(" . $sort . ",'" . $dir . "', " . $fnum . ", '" . $filter . "',$start,$zeil, @anz)";
+    $sql = "CALL fhiiqm.vertrag_flist1_1(" . $sort . ",'" . $dir . "', " . $fnum . ", '" . $filter . "', '" . $listg . "', $start,$zeil, @anz)";
     // Parameter: Nr. Sortfelf, Sortierrichtung, Nr. Filterfeld, Filterbegriff, Start bei DS $start+1, Anzahl DS/Seite, Anzahl gefundener Vertraege
     // liefert Felder: contract_ID,cname,clong,bearb,doc,typ,prod
     $result = $dbc -> queryObjectArray($sql);
--- a/fhiiqm/vertrag_flist2.php	Fri Oct 07 11:37:29 2011 +0200
+++ b/fhiiqm/vertrag_flist2.php	Tue Oct 11 12:17:55 2011 +0200
@@ -61,35 +61,21 @@
     $fnum   = $_GET["f"];   // Spaltennummer, nach der aktuell gefiltert wird
     $filter = $_GET["b"];
     if (!isset($fnum) && !$fnum) $fnum = 0;
-/*        
-    function tab_column($colnum=2,$bez,$sort,$dir)
+    
+    // Recht Produktgruppe beruecksichtigen
+    if (is_array($_SESSION["prodg"]))
     {
-        if ($colnum == $sort)
-            if ($dir == 'DESC')
-            {
-                $auf = "auf";
-                $ab = "ab_activ";
-            }
-            else
-            {
-                $auf = "auf_activ";
-                $ab = "ab";
-            }
-        else
-        {
-                $auf = "auf";
-                $ab = "ab";
-        }
-        echo "<th>$bez&nbsp;<a href='".$_SERVER['PHP_SELF']."?s=$colnum'><img src='img/$auf.gif' border='0' width='9' hight='9' alt='sort aufsteigend' title='sort aufsteigend'></a>            
-                  <a href='".$_SERVER['PHP_SELF']."?s=$colnum&d=DESC'><img src='img/$ab.gif' border='0' width='9' hight='9' alt='sort absteigend' title='sort absteigend'></a></th>\n";
-       
+            foreach ($_SESSION["prodg"] as $val)
+                $listg .= "," .$val;
+            $listg = substr($listg,1);
     }
-*/    
+    else $listg = "";
+
     include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
     include_once ($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/func_lib.inc.php");
 	$dbc = new dbconnection();
 
-    $sql = "CALL fhiiqm.vertrag_flist2(" . $sort . ",'" . $dir . "', " . $fnum . ", '" . $filter . "',$start,$zeil, @anz, @ganz)";
+    $sql = "CALL fhiiqm.vertrag_flist2(" . $sort . ",'" . $dir . "', " . $fnum . ", '" . $filter . "', '" . $listg . "',$start,$zeil, @anz, @ganz)";
     // Parameter: Nr. Sortfelf, Sortierrichtung, Nr. Filterfeld, Filterbegriff, Start bei DS $start+1, Anzahl DS/Seite, Anzahl gefundener Vertraege, Anzahl DS gesamt
     // liefert Felder: contract_ID,cname,clong,bearb,doc,typ,prod,cbegin,cend,kmon,partfirmar,kyear,kosten,bem
     $result = $dbc -> queryObjectArray($sql);