<?php
if($_REQUEST['Delete'])
{
	for($i=0;$i<count($_REQUEST['leadid']);$i++){
	
	$umgsql=DB_query("select add_file from machine_center where id='".$_REQUEST['leadid'][$i]."'",$db);
	$ImgName=DB_fetch_array($umgsql);
   if(!empty($ImgName['add_file']))
   {
	$dirre='Add_file/'.$ImgName['add_file'];
	unlink($dirre);
   }
	$del=DB_query("delete from machine_center where id='".$_REQUEST['leadid'][$i]."'",$db);
	}	
}

?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h1>Machine Center List</h1>
<form name="myform" method="post">
<p align="left">
	<a href="index.php?route=Machine_center&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>">
	<input type="button" name="Add" value="Add Machine Center" class="search" /></a>
	<input type="submit" name="Delete" value="Delete" class="search" onclick="return confirm('Are you sure you want to delete?')" />
</p>
<table width="100%" border="1" cellpadding="3" cellspacing="0">
<tr>
<td class="tabledata"><input name="leadid" type="checkbox"   id="leadid" onclick="LeadData()"    /></td>
<td class="tabledata">Code</td>
<td class="tabledata">Model No.</td>
<td class="tabledata">Under Group</td>
<td class="tabledata">SR_No </td>
<td class="tabledata">Chesis No</td>
</tr>
<?php
$sql=DB_query("Select * from machine_center where CompanyId='".$_SESSION['ACGCompanyId']."'",$db);	
$i=0;
$num=DB_num_rows($sql);
if($num>0)
{
while($myrow=DB_fetch_array($sql))
{
?>
<tr class="row1">
<td style="white-space:nowrap;"><input name="leadid[]" type="checkbox" id="leadid_<?php echo $i+1; ?>"   value="<?php  echo $myrow['id']?>" />
	
	<a href="index.php?route=Edit_Machine_center&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&action=Edit&Id=<?php echo $myrow['id'];?>"><img src="images/icon_edit.gif" width="12px"  height="12" /></a>
	
	<a href="index.php?route=view_machinecente&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&action=view&Id=<?php echo $myrow['id'];?>"><img src="images/search.gif" width="12px"  height="12" /></a>
	</td>
<td><?php  echo $myrow['code']  ?></td>
<td><?php echo $myrow['model_no'];?></td>
<td><?php echo $s->getField('machine_group_master','id',$myrow['under_group'],'machine_gp_location');?></td>
<td><?php echo $myrow['sr_no'];?></td>
<td><?php echo $myrow['chesis_no'];?></td>
</tr>
<?php $i++;}}
else { ?>
<tr class="row1">
<td style="color:#FF0000" colspan="9">No Records Find</td>
</tr>
<?php }   ?>
	
</table>
</form>
</div>
</div>
<script type="text/javascript" language="javascript">
function LeadData()
{	
	myCheckboxArray = document.myform.elements["leadid[]"];
	var t=myCheckboxArray.length;
	//alert(myCheckboxArray);
	if(document.getElementById('leadid').checked==true)
	{	
	if(t==undefined)
	document.getElementById('leadid_'+1).checked=true;		
	for (var i = 1; i <= t; i++)
	{
	document.getElementById('leadid_'+i).checked=true;	
	}	
	}
	else
	{
	if(t==undefined)		
	document.getElementById('leadid_'+1).checked=false;		
	for (var i = 1; i <= t; i++)
	{
	document.getElementById('leadid_'+i).checked=false;	
	}
	}
}		
</script>