<?php include('header.php'); ?>
<?php include('session.php'); ?>
    <body>
		<?php include('navbar.php'); ?>
        <div class="container-fluid">
            <div class="row-fluid">
				<?php include('newdevice_slidebar.php'); ?>
			    
				  <div class="span9" id="content">
                     <div class="row-fluid">
				  
					 <h2 id="sc" align="center"><image src="images/sclogo.png" width="45%" height="45%"/></h2>
				<?php	
	             $count_item=mysqli_query($con,"select * from stdevice
				 LEFT JOIN device_name ON device_name.dev_id = stdevice.dev_id
		         where stdevice.dev_status='new' ORDER BY stdevice.id DESC");
	             $count = mysqli_num_rows($count_item);
                 ?>		                 					 
				   <div id="block_bg" class="block">
                        <div class="navbar navbar-inner block-header">
                             <div class="muted pull-left"><i class="icon-check"></i>&nbsp;New Device List</div>
							 <div class="muted pull-right">
								Number of New Device (s): <span class="badge badge-info"><?php  echo $count; ?></span>
							 </div>
                          </div>
						  
				<h4 id="sc">New Device (s) List
					<div align="right" id="sc">Date:
						<?php
                            $date = new DateTime();
                            echo $date->format('l, F jS, Y');
                         ?></div>
				 </h4>		  
						   	 
 <div class="container-fluid">
 <div class="row-fluid">						 
 <br/>
 <!-----------------------------------device categorized by their location details using nav pills------------------------------------>	
	<div class="pull-left">
			    <ul class="nav nav-pills">
			
				<?php
				$get_id='1';
	            $my_device = mysqli_query($con,"select * from stdevice    
	LEFT JOIN stlocation ON stdevice.stdev_id = stlocation.stdev_id
	LEFT JOIN device_name ON device_name.dev_id = device_name.dev_id
	WHERE stdevice.stdev_id  = '1' AND dev_status='new' AND device_name.dev_name='Desktop' ");
			    $count = mysqli_num_rows($my_device);
			    ?>
				<li class="active">
				<!--a href= 'mydevice.php<?php echo '?stdev_id='.$get_id; ?>')">PICC&nbsp;<span class="label label-default"> <?php echo $count;?></span></a-->
					
				</li>
				
			<?php	
	          $my_desktop = mysqli_query($con,"select * from stdevice    
	LEFT JOIN stlocation ON stdevice.stdev_id = stlocation.stdev_id
	LEFT JOIN device_name ON device_name.dev_id = stdevice.dev_id
	WHERE stdevice.stdev_id  = '1' AND dev_status='new' AND device_name.dev_name='Desktop'  ");
			  $count = mysqli_num_rows($my_desktop);
			  ?>
              					
				<li class="">			
				    <a href= 'mydesktop.php<?php echo '?stdev_id='.$get_id; ?>')">Desktop&nbsp;<span class="label label-default"> <?php echo $count;?></span></a>					
				</li>
				
				<?php	
	            $my_ultrabook = mysqli_query($con,"select * from stdevice    
	LEFT JOIN stlocation ON stdevice.stdev_id = stlocation.stdev_id
	LEFT JOIN device_name ON device_name.dev_id = stdevice.dev_id
	WHERE stdevice.stdev_id  = '1' AND dev_status='new' AND device_name.dev_name='Ultra Book'  
				");
			    $count = mysqli_num_rows($my_ultrabook);
               ?>
				<li class="">			
				    <a href= 'myultrabook.php<?php echo '?stdev_id='.$get_id; ?>')">Ultra Book&nbsp;<span class="label label-default"> <?php echo $count;?></span></a>					
				</li>				
				
			  <?php	
	            $my_laptop = mysqli_query($con,"select * from stdevice    
	LEFT JOIN stlocation ON stdevice.stdev_id = stlocation.stdev_id
	LEFT JOIN device_name ON device_name.dev_id = stdevice.dev_id
	WHERE stdevice.stdev_id  = '1' AND dev_status='new' AND device_name.dev_name='Laptop'");
			    $count = mysqli_num_rows($my_laptop);
               ?>
			   
				<li class="">			
				    <a href= 'mylaptop.php<?php echo '?stdev_id='.$get_id; ?>')">Laptop&nbsp;<span class="label label-default"> <?php echo $count;?></span></a>					
				</li>
				
				 <?php	
	            $my_server = mysqli_query($con,"select * from stdevice    
	LEFT JOIN stlocation ON stdevice.stdev_id = stlocation.stdev_id
	LEFT JOIN device_name ON device_name.dev_id = stdevice.dev_id
	WHERE stdevice.stdev_id  = '1' AND dev_status='new' AND device_name.dev_name='Server'  ");
			    $count = mysqli_num_rows($my_server);
               ?>
				<li class="">			
				    <a href= 'myserver.php<?php echo '?stdev_id='.$get_id; ?>')">Server&nbsp;<span class="label label-default"> <?php echo $count;?></span></a>					
				</li>
				
               <?php	
	            $my_vga = mysqli_query($con,"select * from stdevice    
	LEFT JOIN stlocation ON stdevice.stdev_id = stlocation.stdev_id
	LEFT JOIN device_name ON device_name.dev_id = stdevice.dev_id
	WHERE stdevice.stdev_id  = '1' AND dev_status='new' AND device_name.dev_name='Adapter Converter'  ");
			    $count = mysqli_num_rows($my_vga);
               ?>			
				<li class="">			
				    <a href='myvga.php<?php echo '?stdev_id='.$get_id; ?>')">Adapter Converter&nbsp;<span class="label label-default"> <?php echo $count;?></span></a>					
				</li>
				<?php	
	            $my_dvd= mysqli_query($con,"select * from stdevice    
	LEFT JOIN stlocation ON stdevice.stdev_id = stlocation.stdev_id
	LEFT JOIN device_name ON device_name.dev_id = stdevice.dev_id
	WHERE stdevice.stdev_id  = '1' AND dev_status='new' AND device_name.dev_name='DVD'  ");
			    $count = mysqli_num_rows($my_dvd);
               ?>			
				<li class="">			
				    <a href= 'mydvd.php<?php echo '?stdev_id='.$get_id; ?>')">DVD&nbsp;<span class="label label-default"> <?php echo $count;?></span></a>					
				</li>
				
			<?php	
	            $my_ea= mysqli_query($con,"select * from stdevice    
	LEFT JOIN stlocation ON stdevice.stdev_id = stlocation.stdev_id
	LEFT JOIN device_name ON device_name.dev_id = stdevice.dev_id
	WHERE stdevice.stdev_id  = '1' AND dev_status='new' AND device_name.dev_name='ETHERNET ADAPTER'  ");
			    $count = mysqli_num_rows($my_ea);
               ?>			
				<li class="">			
				    <a href= 'myea.php<?php echo '?stdev_id='.$get_id; ?>')">Ethernet Adapter&nbsp;<span class="label label-default"> <?php echo $count;?></span></a>					
				</li>
				<?php	
	            $my_pointer= mysqli_query($con,"select * from stdevice    
	LEFT JOIN stlocation ON stdevice.stdev_id = stlocation.stdev_id
	LEFT JOIN device_name ON device_name.dev_id = stdevice.dev_id
	WHERE stdevice.stdev_id  = '1' AND dev_status='new'AND device_name.dev_name='pointer'  ");
			    $count = mysqli_num_rows($my_pointer);
               ?>			
				<li class="">			
				    <a href= 'mypointer.php<?php echo '?stdev_id='.$get_id; ?>')">Pointer&nbsp;<span class="label label-default"> <?php echo $count;?></span></a>					
				</li>
				<?php	
	            $my_netgear= mysqli_query($con,"select * from stdevice    
	LEFT JOIN stlocation ON stdevice.stdev_id = stlocation.stdev_id
	LEFT JOIN device_name ON device_name.dev_id = stdevice.dev_id
	WHERE stdevice.stdev_id  = '1' AND dev_status='new' AND device_name.dev_name='NETGEAR WIFI ADAPTER'  ");
			    $count = mysqli_num_rows($my_netgear);
               ?>			
				<li class="">			
				    <a href= 'mynetgear.php<?php echo '?stdev_id='.$get_id; ?>')"> Netgear WIFI Adapter&nbsp;<span class="label label-default"> <?php echo $count;?></span></a>					
				</li>	
				
				<?php	
	            $my_spinetix= mysqli_query($con,"select * from stdevice    
	LEFT JOIN stlocation ON stdevice.stdev_id = stlocation.stdev_id
	LEFT JOIN device_name ON device_name.dev_id = stdevice.dev_id
	WHERE stdevice.stdev_id  = '1' AND dev_status='new' AND device_name.dev_name='SPINETIX HMP 130'  ");
			    $count = mysqli_num_rows($my_spinetix);
               ?>			
				<li class="">			
				    <a href= 'myspinetix.php<?php echo '?stdev_id='.$get_id; ?>')">SPINETIX HMP 130&nbsp;<span class="label label-default"> <?php echo $count;?></span></a>					
				</li>		
				
				<?php	
	            $my_lcd= mysqli_query($con,"select * from stdevice    
	LEFT JOIN stlocation ON stdevice.stdev_id = stlocation.stdev_id
	LEFT JOIN device_name ON device_name.dev_id = stdevice.dev_id
	WHERE stdevice.stdev_id  = '1' AND dev_status='new' AND device_name.dev_name='LCD MOBILE & TV'  ");
			    $count = mysqli_num_rows($my_lcd);
               ?>			
				<li class="">			
				    <a href= 'mylcd.php<?php echo '?stdev_id='.$get_id; ?>')">LCD TV&nbsp;<span class="label label-default"> <?php echo $count;?></span></a>					
				</li>
				<?php	
	            $my_led= mysqli_query($con,"select * from stdevice    
	LEFT JOIN stlocation ON stdevice.stdev_id = stlocation.stdev_id
	LEFT JOIN device_name ON device_name.dev_id = stdevice.dev_id
	WHERE stdevice.stdev_id  = '1' AND dev_status='new' AND device_name.dev_name='LED MOBILE & TV'  ");
               ?>			
				<li class="">			
				    <a href= 'myled.php<?php echo '?stdev_id='.$get_id; ?>')">LED TV &nbsp;<span class="label label-default"> <?php echo $count;?></span></a>					
				</li>	
				
				<?php	
	            $my_external= mysqli_query($con,"select * from stdevice    
	LEFT JOIN stlocation ON stdevice.stdev_id = stlocation.stdev_id
	LEFT JOIN device_name ON device_name.dev_id = stdevice.dev_id
	WHERE stdevice.stdev_id  = '1' AND dev_status='new' AND device_name.dev_name='External Hardisk'  ");
			    $count = mysqli_num_rows($my_external);
               ?>			
				<li class="">			
				    <a href= 'myexternal.php<?php echo '?stdev_id='.$get_id; ?>')">External Hardisk &nbsp;<span class="label label-default"> <?php echo $count;?></span></a>					
				</li>		
				
				</ul>
	 </div>
   </div>
</div>

<div class="block-content collapse in">
   <div class="span12">
	
<form id="send" method="post">	
<div class="empty">
	<div class="control-group">
		 <label class="control-label" for="inputEmail">Location Name</label>
			 <div class="controls">
				  <select name="stdev_id" class="chzn-select" required/>
				    <option></option>
			          <?php $result =  mysqli_query($con,"select * from stlocation")or die(mysql_error()); 
			          while ($row=mysqli_fetch_array($result)){ ?>
				   <option value="<?php echo $row['stdev_id']; ?>&nbspName&nbsp<?php echo $row['stdev_location_name']; ?>"><?php echo $row['stdev_location_name']; ?></option>
				    <?php } ?>
				   </select>
		    </div>
	</div>
			
	  <div class="control-group"> 
		<div class="controls">
		<button  class="btn btn-primary" id="snd" data-placement="right" title="Click to Assign"><i class="icon-share"> Assign Location</i></button>
         <script type="text/javascript">
	     $(document).ready(function(){
	     $('#snd').tooltip('show');
	     $('#snd').tooltip('hide');
	     });
	    </script>
			 		 
		 <div class="pull-right">
	      <a href="print_new.php" class="btn btn-info" id="print" data-placement="left" title="Click to Print"><i class="icon-print icon-large"></i> Print List</a> 
		       <script type="text/javascript">
		       $(document).ready(function(){
		       $('#print').tooltip('show');
		       $('#print').tooltip('hide');
		       });
		        </script> 	
         </div>
	  </div>
 </div>
</div>                      
  	<table cellpadding="0" cellspacing="0" border="0" class="table" id="example">
		<thead>		
		        <tr>
				<th class="empty"></th>
					<th>Device Name</th>
					<th>Device Description </th>
					<th>Device Serial Number  </th>
			        <th>Device Brand  </th>
					<th>Device Model  </th>
					<th>Device Status  </th>                   					              		  
		    </tr>
		</thead>
<tbody>
<!-----------------------------------Content------------------------------------>
	
		<?php
	    $device_query = mysqli_query($con,"select * from stdevice
	                    where stdevice.dev_status='new' ORDER BY stdevice.id DESC");
	    while ($row = mysqli_fetch_array($device_query)) {
		$id = $row['id'];
		$dev_name =isset($row['dev_name']) ? strtolower($_POST['dev_name']) : NULL;
		//$dev_name = $row['dev_name'];
		?>
										
		<tr>
		<td width="30" class="empty">
			<input id="" class="uniform_on" name="selector[]" type="checkbox" value="<?php echo $id; ?>&nbspName&nbsp<?php echo $dev_name; ?>" >
		</td>
			<td><?php echo $dev_name; ?></td>
			<td><?php echo $row['dev_desc']; ?></td>
			<td><?php echo $row['dev_serial']; ?></td>
			<td><?php echo $row['dev_brand']; ?></td>
			<td><?php echo $row['dev_model']; ?></td>
			<td><div class="alert alert-success"><i class="icon-check"></i><strong><?php echo $row['dev_status']; ?></strong></div></td>		
		</tr>
											
	<?php } ?>   

</tbody>
</table>
</form>	
<script>
		jQuery(document).ready(function(){
		jQuery("#send").submit(function(e){
			e.preventDefault();{												
			var formData = jQuery(this).serialize();
			$.ajax({
			type: "POST",
			url: "send.php",
			data: formData,
			success: function(html){
					
			$.jGrowl("Device Successfully Assign", { header: 'Device Assign' });
			var delay = 500;
			setTimeout(function(){ window.location = 'device_location.php'  }, delay);  
						
			}
												
		 });
			
	   }
	});
});
</script>
				  		
</div>
</div>

</div>
</div>
</div>

	
<?php include('footer.php'); ?>
</div>
<?php include('script.php'); ?>
 </body>
</html>