
<div style="padding:10px 10px 10px 10px;">
           
<h2 style="text-align:center;">Byl připojen nový neasociovaný snímač!</h2>
<div style="text-align:center;">Prosím, vyberte ze seznamu spotřebič pro asociaci.</div>
<br/><br/>

<?php
     include("config.php");

     //$dotaz=mysql_query("SELECT id,mac FROM sensors WHERE id NOT IN (SELECT sensor FROM devices) AND active='1' ORDER BY mac ASC;");
     $dotaz=mysql_query("SELECT DISTINCT sensors.id,sensors.mac FROM temp,sensors WHERE sensors.id=temp.sensor ORDER BY sensors.mac ASC;");
     $seznams='<select name="sensor">';
     if (mysql_num_rows($dotaz)<1) {$nepridavat=true;} 
     for ($i=0;$i<mysql_num_rows($dotaz);$i++) 
      {$sens=mysql_fetch_row($dotaz); 
       if ($_GET['sens']==$sens[0]) {$vybrano="selected";} else {$vybrano="";}
       $seznams.='<option value="'.$sens[0].'" '.$vybrano.'>0x'.$sens[1].'</option>'; 
      };
     $seznams.='</select>';
    
     $dotaz1=mysql_query("SELECT devices.id,devices.name,devices.type,icons.picture,devices.person,devices.room FROM devices,icons WHERE icons.id=devices.icon AND devices.sensor=0;");
     $seznamz='<select name="device" id="dev">';
     for ($i=0;$i<mysql_num_rows($dotaz1);$i++) 
      {$dev=mysql_fetch_row($dotaz1); 
       if ($_GET['dev']==$dev[0]) {$vybrano="selected";} else {$vybrano="";}
       $seznamz.='<option value="'.$dev[0].'" title="'.$dev[3].'" '.$vybrano.'>'.$dev[1].' ('.$dev[5].', '.$dev[4].')</option>';  
      };
     $seznamz.='</select>';
     
     $tlacitko='<input type="submit" value="Uložit">';
     
                                                                                                                 
    echo ' 
     <form action="asociace.php?a=pridat&x=ajax" method="POST">
     <table>
     <tr><td style="text-align:right;font-weight:bold;">MAC snímače:</td><td><img src="icon/thumbnails/null.png" alt="" style="vertical-align:middle;width:18px;height:18px;"/>'.$seznams.'</td></tr>
     <tr><td style="text-align:right;font-weight:bold;">Zařízení:</td><td><img src="icon/thumbnails/null.png" alt="" style="vertical-align:middle;width:18px;height:18px;" id="thumb"/>'.$seznamz.'</td></tr>
     </table>
     <br/>
     <input type="hidden" name="odeslano" value="ano">
     '.$zprava.'
     '.$tlacitko.'
     </form>
    ';
    
?>    
     </div>
     

<script type="text/javascript">

 $(document).ready(function() {

  var ikona=$("#dev option:selected").attr("title"); 
 	 $("#thumb").attr("src","icon/thumbnails/"+ikona);
 	 
 $("#dev").change(function() {
   var ikona=$("#dev option:selected").attr("title"); 
 	 $("#thumb").attr("src","icon/thumbnails/"+ikona);
});

       
});


function hide(){  
   $("#shade").remove();
   $("#window").remove();
  }
  


</script>     