<?php $PageSecurity = 4;
global  $db;
include('includes/session.inc');
include('includes/SQL_CommonFunctions.inc');
include('includes/function_lib.php');
?>
<link href="css/professional/default.css" rel="stylesheet" type="text/css" />
<?php 
if($_REQUEST['submit_tech']!='')
{


	$key = key($_REQUEST['submit_tech']);
	$sql1="Insert into trouble_ticket_creation_assignment set
			ttid='".$_REQUEST['ttid']."', 
			technician_id='".$_REQUEST['tech_id'][$key]."'";
		
	$result1=DB_query($sql1,$db);
	
	$sql2="UPDATE trouble_ticket_creation set
			is_assign='1' WHERE id='".$_REQUEST['ttid']."'";
		
	$result2=DB_query($sql2,$db);
	
	$_SESSION['session_msg']="Assigned Sucessfully";
?>
<script>
opener.window.location="index.php?route=service/view_trouble_ticket_assignment&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>";self.close();
</script>
<?php 
}
?>
<script language="javascript" type="text/javascript">
function open_technician_detail(str)
{
	var techid=str;
	window.open("open_technician_detail.php?modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'] ?>&action=<?php echo $_REQUEST['action']?>&techaid="+techid,"itempopup_window","height=500,width=600,toolbar=no,menubar=no,dependent=yes,resizable =yes, scrollbars=yes");
}

function confirm_func(str)
{
var tect=str;
var con=confirm("Are you want to assigned this job to "+tect);
	if(con)
	{ return true;
	}else{
		return false;
	}
}


</script>


<h2 align="center">Technician List</h2>
<form name="form1" action="" method="post">
  <table width="100%" border="0" cellspacing="3" cellpadding="2" align="center">
    <tr>
		<th width="23%"><strong>S.No.</strong></th>
      <th width="23%"><strong>Technician Name</strong></th>
      <th width="39%">&nbsp;</th>
      <th width="26%">&nbsp;</th>
    </tr>
  </table>
  <?php
 	$sql=DB_query("SELECT * FROM technicians where location='".$_REQUEST['braid']."'",$db); 
	?>
  <div style="overflow: scroll; height: 300px" id="sub_id">
    <table width="100%" border="0" cellspacing="3" cellpadding="2" align="center">
      <?php	
	
	$i=0;
	$j = 1;
	if(DB_num_rows($sql)>0)
	{
		while($myrow=DB_fetch_array($sql))
	  	{ 
		$j = $j +$i;	
		 
  ?>
      <tr bgcolor="#CCCCCC">
	  <td width="24%"><?php echo  $j;?></td>
        <td width="24%"><?php echo  $myrow['technician'];?><input type="hidden" name="tech_id[<?php echo $i;?>]" id="tech_id_<?php echo $i;?>" value="<?php echo  $myrow['id'];?>" /></td>
        <td width="40%"><input type="button" name="profile_popup" value="View Detail" id="profile_popup"  onclick="open_technician_detail(<?php echo $myrow['id']; ?>)" class="search" /></td>
        <td width="24%"><input type="submit" name="submit_tech[<?php echo $i;?>]" value="Assign" id="submit_tech_<?php echo $i;?>" class="search" onclick="return confirm_func('<?php echo $myrow['technician']; ?>')" /><input type="hidden" name="ttid" value="<?php echo $_REQUEST['ttaid'];?>" /></td>
      </tr>
      <?php $i++;} }?>
    </table>
  </div>
</form>
<div style="text-align:center"><input type="button" name="back" value="Close" onclick="window.close()" class="search" /></div>
