<?php 
$url_cancel= "index.php?route=ToolPlants/Transaction/asset_breakdown_assignment_add".$rurl;
//echo $url_cancel;
if(isset($_POST['Approve']))
{
 for($i=0;$i<count($_REQUEST['approveid']);$i++)
 {    
$update=DB_query("update tpl_breakdown_mgmt_assig set process_appv=1,
                   process_appv_by='".$_SESSION['UserID']."'
                  where id='".$_REQUEST['approveid'][$i]."'",$db); 
 } 
}
?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h1>Process Dept. Approval</h1>
<form action="" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="3" class="thborder">
<tr>
	<th width="8%">Branch</th>
	<th width="8%">Slip No.</th>
	<th width="8%">Job Card No.</th>
	<th width="10%">Break Down Location</th>
	<th width="8%">Received By</th>
    <th width="12%">Assigned To</th>
	<th width="80">Asset Code</th>
	<th width="150">Asset Name</th>
	<th>Asset Group</th>
    <th width="7%">Approve</th>	
</tr>
<?php 
//$record=$s->GetRecordById('tpl_asset_transfer_request',1);
$sql = "select * from tpl_breakdown_mgmt_assig where CompanyId='".$_SESSION['ACGCompanyId']."'
 and saft_appv=1 and dept_appv=1 and process_appv=0";		 
// echo $sql;		 
 $record=DB_query($sql,$db);
$i=0;
$numrow1=DB_num_rows($record);
if(DB_num_rows($record)>0){
while($row=DB_fetch_array($record))
{
$i++;
extract($row);
?>
<tr>
<td><?php  echo $s->GetFieldValue('locations',"loccode='".$site."'",'locationname');  //$site;?></td>
<td><?php echo  $slip_no;?></td>
<td><?php  echo $s->getField('tpl_breakdown_mgmt','id',$job_id,'tt_no'); ?></td>
<td><?php echo $s->getField('tpl_breakdown_mgmt','id',$job_id,'rec_from');?></td>
<td><?php  echo $s->getField('tpl_breakdown_mgmt','id',$job_id,'rec_by'); ?></td>
<td><?php 
$sql_row=DB_query("select distinct(technician) from tpl_breakdown_mgmt_details
                  where master_id='".$id."'",$db);
while($row1=DB_fetch_array($sql_row))
{
echo $s->getField('technicians','id',$row1['technician'],'technician');
} ?>
 </td>
<td colspan="3" valign="top" style="padding:0px;">
<div id="amc-tab">
	<table width="100%" border="0" cellpadding="3" cellspacing="0">
	<?php
   $sql_2=DB_query("select * from tpl_breakdown_mgmt_machine where master_id='".$job_id."'",$db);
   while($row1=DB_fetch_array($sql_2))
   {   
		$reqDet_sql = "SELECT * FROM machine_center WHERE ID= ".$row1['asset_id']."";
		$result = DB_query($reqDet_sql,$db);
		if(DB_num_rows($result)>0){
			while($assetRow = DB_fetch_array($result)){
			$reqDet_sql1 = "SELECT * FROM machine_group_master WHERE id= ".$assetRow['under_group']."";
		$result1 = DB_query($reqDet_sql1,$db);
		$assetRow1 = DB_fetch_array($result1);			
			?>
				<tr>
					<td width="80"><?php  echo $assetRow['code'];?></td>
					<td width="150"><?php  echo $assetRow['name'];?></td>
					<td><?php echo $assetRow1['machine_gp_location'];?></td>
				</tr>
   <?php	} 	} 	} ?>	
	</table>
	</div></td>
<td style="text-align:center;"><input type="checkbox" name="approveid[]" value="<?php echo $id; ?>"></td>
</tr><?php 
} 
}else{?>
<tr>
<td colspan="10" style="text-align:center;"><font color="#FF0000">No Record Found</font></td>
</tr>
<?php }?>
</table>
 <?php if($numrow1>0)
 { ?>
 <p align="center"><input type="submit" name="Approve" value="Approve" class="search"></p>
 <?php } ?>
</form>
</div>
</div>
