1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| <!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test TreeView mySQL</title>
<script src="wsTreeCtrl.js"></script>
<body>
<label>
<input name="RadioGroup1" type="radio" id="Modifier" value="radio" onClick="modifier();"/>
Modifier</label>
<label>
<input name="RadioGroup1" type="radio" id="Supprimer" value="radio" />
Supprimer</label>
<input type="button" onClick="javascript:Expand();" value="Développer">
<input type="button" onClick="javascript:Recude();" value="Réduire">
<?php
mysql_connect("localhost", "root", "");
mysql_select_db("bd");
function ConsTableau($IDMission){
$Tab_php_IDMission = array();
$Tab_php_Libelle = array();
$Tab_php_IDParent = array();
$tableau=mysql_query("select * from missions where IDProjet=".$_SESSION['projet']." and IDParent=".$IDMission." order by Libelle");
$i=0;
while ( $datamenu = mysql_fetch_array ( $tableau ) )
{
$Tab_php_IDMission[$i] = $datamenu["IDMission"];
$Tab_php_Libelle[$i] = $datamenu["Libelle"];
$Tab_php_IDParent[$i] = $datamenu["IDParent"];
$i++;
}
for ( $j=0 ; $j < count($Tab_php_IDMission) ; $j++){
//////////////////// Script javascript /////////////////////
echo "<script type=\"text/javascript\">\n";
///// Fonction Modifier //////
echo "function modifier(){";
echo "if ( '$Tab_php_IDParent[$j]' == 0 )\n";
echo "window['v'+'$Tab_php_IDMission[$j]']=m_wsTreeCtrl.InsItem(null,'['+'$Tab_php_IDMission[$j]'+'] '+'$Tab_php_Libelle[$j]', '', '');\n";
echo "else\n";
echo "window['v'+'$Tab_php_IDMission[$j]']=m_wsTreeCtrl.InsItem(eval('v'+'$Tab_php_IDParent[$j]'), '['+'$Tab_php_IDMission[$j]'+'] '+'$Tab_php_Libelle[$j]', '', '');\n";
echo "m_wsTreeCtrl.InsItem(eval('v'+'$Tab_php_IDMission[$j]'), '$Tab_php_Libelle[$j]', 'trait_missions.php?action=Modifier&IDMission='+'$Tab_php_IDMission[$j]', 'mainFrame2');\n";
//echo "";*/
echo "}\n";
/////// Fonction Supprimer ///////
echo "function supprimer(){";
echo "if ( '$Tab_php_IDParent[$j]' == 0 )\n";
echo "window['v'+'$Tab_php_IDMission[$j]']=m_wsTreeCtrl.InsItem(null,'['+'$Tab_php_IDMission[$j]'+'] '+'$Tab_php_Libelle[$j]', '', '');\n";
echo "else\n";
echo "window['v'+'$Tab_php_IDMission[$j]']=m_wsTreeCtrl.InsItem(eval('v'+'$Tab_php_IDParent[$j]'), '['+'$Tab_php_IDMission[$j]'+'] '+'$Tab_php_Libelle[$j]', '', '');\n";
echo "m_wsTreeCtrl.InsItem(eval('v'+'$Tab_php_IDMission[$j]'), '$Tab_php_Libelle[$j]', 'trait_missions.php?action=Supprimerr&IDMission='+'$Tab_php_IDMission[$j]', 'mainFrame2');\n";
//echo "";*/
echo "}\n";
echo "</script>\n";
ConsTableau($Tab_php_IDMission[$j]);
}
}
echo "<script type=\"text/javascript\">\n";
echo "m_wsTreeCtrl = new wsTreeCtrl();\n";
echo "m_wsTreeCtrl.initializeDocument();\n";
echo "</script>\n";
ConsTableau(0);
echo "<script type=\"text/javascript\">\n";
echo "m_wsTreeCtrl.GenerateCode();\n";
echo "m_wsTreeCtrl.RecudeAllTree();\n";
echo "function Recude()\n";
echo "{\n";
echo " m_wsTreeCtrl.RecudeAllTree();\n";
echo "}\n";
echo "function Expand() \n";
echo "{\n";
echo " m_wsTreeCtrl.ExpandAllTree();\n";
echo "}\n";
echo "</script>\n";
?>
</body>
</html> |
Partager