[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 /* $Id: visu_rapport.php 6411 2011-06-19 09:50:22Z crob $ 3 =========================================== 4 Projet SE3 5 Dispositif SE3+TFTP+Sauvegarde/Restauration/Clonage 6 Stephane Boireau 7 Distribué selon les termes de la licence GPL 8 ============================================= 9 */ 10 11 // loading libs and init 12 include "entete.inc.php"; 13 include "ldap.inc.php"; 14 include "ihm.inc.php"; 15 //require_once "../dhcp/dhcpd.inc.php"; 16 include "printers.inc.php"; 17 18 require ("lib_action_tftp.php"); 19 20 //aide 21 $_SESSION["pageaide"]="Le_module_Clonage_des_stations#Programmer_un_rapport"; 22 23 // CSS pour mes tableaux: 24 echo "<link type='text/css' rel='stylesheet' href='tftp.css' />\n"; 25 26 if((is_admin("system_is_admin",$login)!="Y")&&(ldap_get_right("parc_can_clone",$login)!="Y")) { 27 echo "<p style='color:red'>Action non autorisee.</p>"; 28 include ("pdp.inc.php"); 29 die(); 30 } 31 else { 32 $id_machine=isset($_POST['id_machine']) ? $_POST['id_machine'] : (isset($_GET['id_machine']) ? $_GET['id_machine'] : NULL); 33 $suppr=isset($_POST['suppr']) ? $_POST['suppr'] : NULL; 34 35 if(!isset($id_machine)) { 36 echo "<p style='color:red'>Aucune machine n'est choisie.</p>"; 37 include ("pdp.inc.php"); 38 die(); 39 } 40 41 $restriction_parcs="n"; 42 if(is_admin("system_is_admin",$login)!="Y") { 43 $restriction_parcs="y"; 44 $tab_delegated_parcs=list_delegated_parcs($login); 45 if(count($tab_delegated_parcs)==0) { 46 echo "<p style='color:red'>Aucun parc ne vous a été délégué.</p>\n"; 47 include ("pdp.inc.php"); 48 die(); 49 } 50 51 $temoin_erreur="y"; 52 $nom=""; 53 54 $sql="SELECT name FROM se3_dhcp WHERE id='$id_machine';"; 55 $res=mysql_query($sql); 56 if(mysql_num_rows($res)>0) { 57 $lig=mysql_fetch_object($res); 58 $nom=$lig->name; 59 60 for($loop=0;$loop<count($tab_delegated_parcs);$loop++) { 61 // La machine est-elle dans un des parcs délégués? 62 if(is_machine_in_parc($nom,$tab_delegated_parcs[$loop])) { 63 $temoin_erreur='n'; 64 break; 65 } 66 } 67 } 68 if($temoin_erreur=="y") { 69 echo "<p style='color:red'>La machine $nom n'est pas dans un de vos parcs delegues.</p>\n"; 70 include ("pdp.inc.php"); 71 die(); 72 } 73 74 } 75 76 77 if(isset($suppr)) { 78 $chaine=""; 79 for($i=0;$i<count($suppr);$i++) { 80 $sql="DELETE FROM se3_tftp_rapports WHERE id='$id_machine' AND identifiant='$suppr[$i]';"; 81 $res=mysql_query($sql); 82 if(!$res) { 83 $chaine.="<span style='color:red;'>Erreur lors de la suppression du rapport n°$suppr[$i].</span><br />\n"; 84 } 85 } 86 echo $chaine; 87 } 88 89 //$sql="SELECT * FROM se3_tftp_action WHERE id='".$id_machine."';"; 90 $sql="SELECT * FROM se3_dhcp WHERE id='".$id_machine."';"; 91 $res=mysql_query($sql); 92 if(mysql_num_rows($res)>0) { 93 $lig=mysql_fetch_object($res); 94 $mac_machine=$lig->mac; 95 $nom_machine=$lig->name; 96 echo "<h1>Rapport(s) sur $nom_machine</h1>\n"; 97 98 $sql="SELECT * FROM se3_tftp_rapports WHERE id='$id_machine' ORDER BY date DESC;"; 99 $res2=mysql_query($sql); 100 if(mysql_num_rows($res2)==0) { 101 echo "<p>Aucun rapport trouvé.</p>\n"; 102 } 103 else { 104 echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>\n"; 105 echo "<table class='crob'>\n"; 106 echo "<tr>\n"; 107 echo "<th>Nom</th>\n"; 108 echo "<th>Date</th>\n"; 109 echo "<th>Tâche</th>\n"; 110 echo "<th>Statut</th>\n"; 111 echo "<th>Descriptif</th>\n"; 112 //echo "<th>Supprimer</th>\n"; 113 echo "<th><input type='submit' name='supprimer' value='Supprimer' /><br />\n"; 114 echo "<a href='#' onclick='check_suppr(\"check\");return false'><img src=\"../elements/images/enabled.gif\" border='0' alt=\"Tout cocher\" title=\"Tout cocher\" /></a>\n"; 115 echo " / <a href='#' onclick='check_suppr(\"uncheck\");return false'><img src=\"../elements/images/disabled.gif\" border='0' alt=\"Tout décocher\" title=\"Tout décocher\" /></a>\n"; 116 echo "</th>\n"; 117 echo "</tr>\n"; 118 //$nb_rapports=mysql_num_rows($res2); 119 $cpt=0; 120 while($lig2=mysql_fetch_object($res2)) { 121 echo "<tr>\n"; 122 echo "<td>$lig2->name</td>\n"; 123 echo "<td>".mysql_date_to_fr_date($lig2->date)."</td>\n"; 124 echo "<td>".ucfirst(strtolower($lig2->tache))."</td>\n"; 125 echo "<td>\n"; 126 $tmp=ucfirst(strtolower($lig2->statut)); 127 if($tmp=="Succes") { 128 echo "<span style='color:green;'>Succès</span>"; 129 } 130 elseif($tmp=="Echec") { 131 echo "<span style='color:red;'>Echec</span>"; 132 } 133 elseif($tmp=="Valide") { 134 echo "<span style='color:blue;'>Valide</span>"; 135 } 136 else{ 137 echo $tmp; 138 } 139 echo "</td>\n"; 140 141 echo "<td>\n"; 142 echo nl2br(htmlentities($lig2->descriptif)); 143 echo "</td>\n"; 144 145 echo "<td>\n"; 146 echo "<input type='checkbox' name='suppr[]' id='suppr_$cpt' value='$lig2->identifiant' />\n"; 147 //echo $lig2->identifiant; 148 echo "</td>\n"; 149 echo "</tr>\n"; 150 $cpt++; 151 } 152 echo "</table>\n"; 153 echo "<input type='hidden' name='id_machine' value='$id_machine' />\n"; 154 //echo "<input type='submit' name='supprimer' value='Supprimer' />\n"; 155 echo "</form>\n"; 156 157 echo "<script type='text/javascript'> 158 function check_suppr(mode) { 159 for(i=0;i<$cpt;i++){ 160 if(document.getElementById('suppr_'+i)){ 161 if(mode=='check'){ 162 document.getElementById('suppr_'+i).checked=true; 163 } 164 else{ 165 document.getElementById('suppr_'+i).checked=false; 166 } 167 } 168 } 169 } 170 </script>\n"; 171 } 172 173 //echo "<p><i>NOTE:</i> Ajouter la possibilité de supprimer des rapports.</p>\n"; 174 } 175 else { 176 echo "<h1>Visualisation de rapport</h1>\n"; 177 echo "<p>ERREUR: Machine $id_machine inconnue dans la table 'se3_dhcp'.</p>\n"; 178 } 179 } 180 181 // Footer 182 include ("pdp.inc.php"); 183 184 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |