<div style="width:1246px; margin:auto; overflow:auto;">
<table width="2200" border="1" cellspacing="0" cellpadding="3">
<tr class="row1"><td colspan="18"><strong>Issued Transfer Request</strong></td></tr>
<tr bgcolor="#CCCCCC" height="25">
	<td width="2%"><strong>S. No.</strong></td>
	<td width="5%"><strong>Branch</strong></td>
	<td width="5%"><strong>ATN No.</strong></td>
	<td width="4%"><strong>ATN Date</strong></td>
	<td width="5%"><strong>ATR No.</strong></td>
	<td width="3%"><strong>ATR Date</strong></td>
	<td width="10%"><strong>Requested By</strong></td>
	<td width="5%"><strong>Approved By</strong></td>
	<td width="10%"><strong>Requested Branch</strong></td>
	<td width="150"><strong>Asset Code</strong></td>
	<td width="200"><strong>Asset Name </strong></td>
	<?php 
   $title1=DB_query("select * from tbl_title_master order by serial_no ASC limit 0,3",$db);
   while($r=DB_fetch_array($title1))
   { 
    ?>
    <td width="150"><strong><?php echo $r['title_name'];?></strong></td>
    <?php } ?>
	<td width="100"><strong>Status </strong></td>
	<td width="80"><strong>Received Status </strong></td>
	<td colspan="2"><strong>Action</strong></td>
</tr>
<?php 
 $SQL = "select I.*,T.*,I.id as ISSUEID, A.id as APRID, A.approved_site,A.approved_by, E.emp_name 
		FROM tpl_asset_transfer_issue I 
		LEFT JOIN tpl_asset_transfer_request_approval A ON I.approval_no=A.id
		LEFT JOIN tpl_asset_transfer_request_approval_details AD ON A.id=AD.approved_id
		INNER JOIN tpl_asset_transfer_request T ON T.id=A.request_id 
		INNER JOIN empmaster E ON E.id=T.requested_by
		WHERE T.company_to='".$_SESSION['ACGCompanyId']."'
		and T.request_date  BETWEEN '".$_SESSION['financialYrStart']."' 
		AND '".$_SESSION['financialYrEnd']."' AND AD.status='Issued'";
//and (T.status='Approved' or T.status='PartialApproved')
$record = DB_query($SQL,$db);
if(DB_num_rows($record)>0){
$i=0;
while($row=DB_fetch_array($record))
{
$i++;
extract($row);

?>
<tr>
<td><?php  echo $i;?></td>
<td><?php  echo $s->GetFieldValue('locations','loccode="'.$site.'"','loccode');?> </td>
<td><?php  echo $issue_no;?> </td>
<td><?php  if($issue_date!='') echo date('d/m/y',strtotime($issue_date)); else echo ""; ?> </td>
<td><?php  echo $request_no;?> </td>
<td><?php  if($request_date!='') echo date('d/m/y',strtotime($request_date)); else echo ""; ?> </td>
<td><?php  echo $emp_name;?></td>
<td><?php  echo $s->GetFieldValue('www_users','id="'.$approved_by.'"','realname');?></td>
<td><?php  echo $s->GetFieldValue('locations','loccode="'.$requested_site.'"','loccode');?></td>
<td colspan="6" valign="top" style="padding:0px;">
	<table width="100%" border="1" cellspacing="0" cellpadding="3">
	<?php
		$reqDet_sql = "SELECT RA.approved_qty, RA.status AS RS, A.* 
					   FROM tpl_asset_transfer_request_approval_details RA
					   INNER JOIN machine_center A ON A.id=RA.asset_id
					   WHERE RA.approved_id='".$APRID."' AND RA.status<>'Rejected'";
		$result = DB_query($reqDet_sql,$db);
		if(DB_num_rows($result)>0){
			while($assetRow = DB_fetch_array($result)){?>
				<tr>
					<td width="149" style="border-right:#808080 1px solid;"><?php  echo $assetRow['code'];?></td>
					<td  style="border-right:#808080 1px solid;" width="200"><?php  echo $assetRow['name'];?></td>
					<?php 
   $title1=DB_query("select * from tbl_title_master order by serial_no ASC limit 0,3",$db);
   while($r=DB_fetch_array($title1))
   { 
    ?>
    <td width="150" style="border-right:#808080 1px solid;"><?php echo $assetRow[$r['db_field_name']];?></td>
    <?php } ?>
				  <td width="99"><?php  echo $assetRow['RS'];?></td>
				</tr>
		<?php	}
		}
	?>
	
	</table>
</td>
<td><?php  echo $received_status;?> </td>

<td width="3%">
<?php if($ISSUEID !=''){?>
<a href="<?php echo $url_edit;?>&action=Edit&rid=<?php echo $id;?>&issueid=<?php echo $ISSUEID;?>&aprid=<?php echo $APRID;?>"><img src="images/icon_edit.gif" title="Edit Issue" /></a> 
<?php }?>
</td>
<td><a href="atn_print.php?rid=<?php echo $ISSUEID;?>" target="_blank"><img width="18" height="18" src="images/icon_print.jpg"></a> </td>
</tr><?php 
} 
}else{
?>
<tr>
<td colspan="14"><font color="#FF0000">No Record Found</font></td>
</tr>
<?php }?>
</table>
</div>