fhiiqm/test/tabs_dyn_content.php
author Bettina Schwarzer <schwarzer@fhi-berlin.mpg.de>
Fri, 16 Nov 2012 10:39:25 +0100
changeset 31 0a1eb975fbd9
parent 30 d02d02efc55a
permissions -rw-r--r--
+ Raumverantwortliche + Mitarbeiter - Telefon

<?php

/**
 * @author Bettina Schwarzer, Fritz-Haber-Institut
 * @copyright 08/2012
 * 
 * Test tabs jquery ui
 */

    error_reporting(E_ALL ^ E_NOTICE);
    header('Content-type: text/html; charset="iso-8859-1',true);    


    session_start();
    if (! isset($_SESSION["userid"]))
    { 
        include_once ($_SERVER["DOCUMENT_ROOT"]."/fhiiqm/inc/func_lib.inc.php");	
        login($_SERVER["PHP_SELF"]);
        exit;
    }
    
    if (is_null($_SESSION["recht"]) || (!is_null($_SESSION["recht"]) && !in_array("ir",$_SESSION["recht"]) && !in_array("ie",$_SESSION["recht"])))
    {
        header("Location: start.php");
        exit;
    }    

	include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
	if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
    $titel = "Test tabs"
?>
<!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"/>
    <link type="text/css" href="/fhiiqm/css/jquery/ui-lightness-1.8.21/jquery-ui-1.8.21.custom.css" rel="Stylesheet" />	
    <script type="text/javascript" src="/fhiiqm/js/jquery/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="/fhiiqm/js/jquery/jquery-ui-1.8.21.custom.min.js"></script>

	<?php echo "<title>$titel</title>\n"; ?>
</head>

<body>

    <?php     
        echo "<h3>&nbsp;&nbsp;&nbsp;$titel </h3>";
        echo "<table width='80%'><tr>
        <td class='bigger'>&nbsp;&nbsp;&nbsp;hier k&ouml;nnen Informationen erfasst, editiert, angelistet und daneben die Produkte eingesehen werden<br /><br /><br /></td><td>";
        
        $zeil = $_GET["z"];
        if (!$zeil) $zeil = $_POST["z"];
        if (!$zeil) $zeil = 9999; // Anzahl der gezeigten Zeilen
        $start = $_GET["st"];   // Start bei DS $start+1
        if (!$start) $start=0;
        
    	$sort   = $_GET["s"];   // Sortierung nach Spalte
        if (!isset($sort) && !$sort) $sort = $_POST["s"]; 
        if (!$sort) $sort=15;     
    
        $dir    = $_GET["d"];   // Sortierrichtung
        if (!isset($dir) && !$dir) $dir = $_POST["d"];
    
        $fnum   = $_GET["f"];   // Spaltennummer, nach der aktuell gefiltert wird
        if (!isset($fnum) && !$fnum) $fnum = $_POST["f"];
/*
        $infoid = $_POST['id']; // aus Feld 'id'
        if ($infoid == -1) $infoid=null;
        else*/if (!$infoid) $infoid=$_GET['i'] ; // aus tab_info_flist.php
//        print_r ($_GET); echo "<br /><br />";
//        print_r ($_POST); echo "<br /><br />";

//        $_GET['i'] = $infoid;   // fuer tab_info_ed.php, wenn klick aus info-liste
    ?>
    <form id="infol" method="POST" action="<?php $_SERVER['PHP_SELF'] ?>" enctype="application/x-www-form-urlencoded">
    <table>
        <tr><td>Infoliste sort nach</td>
            <td><select name="s">
                <?php
                $asort = array(15=>"Kennzeichen",2=>"Titel",3=>"Kurzinfo",4=>"Infotyp",5=>"Produkt",6=>"Adressat",
                        7=>"Verantwortlichen",8=>"Autor",9=>"erstellt am",10=>"gültig ab",11=>"gültig bis",12=>"Status"); 
                foreach ($asort as $key => $val)
                {
                    $select = ($sort == $key)? "selected" : "";
                    echo "<option $select value='$key'>$val</option>\n";
                }        
                ?>
            </select>
            </td>
        </tr>
        <tr><td>Sortierrichtung</td>
            <td><select name="d">
                <?php $select = ($dir == "ASC")? "selected" : "";
                echo "<option $select value='ASC'>aufsteigend</option>";
                $select = ($dir == "DESC")? "selected" : "";
                echo "<option $select value='DESC'>absteigend</option>"; ?>
            </select>
            &nbsp;&nbsp;&nbsp;<input type="submit" class="button" name="subil" id="subil" value="sortieren" /></td>
        </tr>
    
    </table>
    </form>
    <?php
        echo "</td></tr></table>";
        
    ?>
<!--
    <form id="infoi" method="POST" action="<?php $_SERVER['PHP_SELF'] ?>" enctype="application/x-www-form-urlencoded">
    <table>
        <tr><td>&nbsp;&nbsp;&nbsp;zu editierende Info wählen</td>
            <td><select name="id" onchange="this.form.submit();">
            <option value="-1">&nbsp;</option>
            <?php
            /*
                $sql = " SELECT info_ID,info_name_s FROM Info ORDER BY 2";
                if ($res = $dbc -> queryObjectArray($sql));
                    foreach ($res as $row)
                    {
                        $select = ($row->info_ID == $infoid) ? "selected" : "";
                        echo "<option $select value='$row->info_ID'>$row->info_ID - $row->info_name_s</option>\n";
                    }
             */                                
            ?>            
                </select>
            </td>
        <td>&nbsp;&nbsp;&nbsp;<a href="#tab_1" id="link_edit" class="link_edit">Edit Info</a></td></tr>
    </table>
    </form>
-->
    <script>
    <!--
        $(function() {
    		$( "#tabs" ).tabs({			
/*    		      cookie: {
				    // store cookie for a day, without, it would be a session cookie
				    expires: 1, name: "tabindex"},
                            
             // Objects available in the function context:
            alert(ui.tab);     // anchor element of the selected (clicked) tab
            alert(ui.panel);   // element, that contains the selected/clicked tab contents
            alert(ui.index);   // zero-based index of the selected (clicked) tab
                select: function( event, ui ) {
                        //var $select = $( ".selector" ).tabs( "option", "selected" );
                     alert ("selected tab: " + ui.index);},
                //this is the bit that makes all a link with the class of 'thisPane' stay within the tab
                //a href tags that are not of the class 'thisPane' will open outside the tab
                load: function(event, ui) {
                $(ui.panel).delegate('a.thisPane', 'click', function(event) {
                    $(ui.panel).load(this.href + "<?php echo "?s=$sort&d=$dir"; ?>");
                    alert (this.href + "<?php echo "?s=$sort&d=$dir"; ?>");
                    event.preventDefault();
                });
                },
*/
                ajaxOptions: {
                            error: function( xhr, status, index, anchor ) {
                                $( anchor.hash ).html(
                                    "Couldn't load this tab. We'll try to fix this as soon as possible. " +
                                    "If this wouldn't be a demo." );
                            }
                        },
                remote: true,
                select: function(event, ui){
                            window.location = ui.tab.href;
                        }
            });
             $('.link_edit').click(function() { 
                $('#tabs').tabs('select',0);
                $('#tabs').tabs("url", 0, '/fhiiqm/test/tab_info_ed.php?i=<?php echo $infoid; ?>');
                $('#tabs').tabs("load",0);
//                window.location = $('#tabs').tabs( "option", "selected",0);
//                alert ("url:" + $('#tabs').( "option", "selected" ));
//                $('#tabs').bind('tabsshow', function(event, ui){document.location = $(document).attr('location').pathname + '#' + ui.panel.id +"?i=123";});                 alert ("url = "+ui.tab.href);
                return false;
                })
/*
             $('.info_edit').click(function() { 
                $('#tabs').tabs('select',0);
                $('#tabs').tabs("url", 0, '/fhiiqm/test/tab_info_ed.php?i=<?php echo $_GET["i"]; ?>');
                $('#tabs').tabs("load",0);
                return false;
                })
*/
             $('#subil').click(function() { 
                $('#tabs').tabs('select',1);
                return true;
                })
        });
    -->
	</script>

    <p>&nbsp;</p>
    <div id="tabs">
    	<ul>
            <li><a href="#tab_1">Info neu/editieren</a></li>
<!--            <li><a href="#tab_2">Infoliste</a></li>   -->
    		<li><a href="/fhiiqm/test/tab_info_flist.php<?php echo "?f=$fnum&s=$sort&d=$dir&st=$start&z=$zeil";?>" class="thisPane">Infoliste</a></li>
    		<li><a href="/fhiiqm/test/tab_prod_hier.php?b=0&g=0&s=1">Produkte</a></li>
    	</ul>
        <div id="tab_1">
            <?php include ($_SERVER["DOCUMENT_ROOT"]."/fhiiqm/test/tab_info_ed.php"); ?>
        </div>            
    </div> <!-- tabs -->
 </body>
 </html>