<?php
$PageSecurity = 1;
include('config.php');
include('includes/ConnectDB.inc');
include('includes/function_lib.php');
include('includes/LanguageSetup.php');
include('includes/DateFunctions.inc');

$sql    = "SELECT * FROM asset_return WHERE id='".$_REQUEST['rid']."'";
$result = DB_query($sql,$db);
$row    = DB_fetch_array($result);
function convertDate($Dt)
{
	$dateBRK=explode('-',$Dt);
	$newFormat=$dateBRK[2]."/".$dateBRK[1]."/".$dateBRK[0];
	return $newFormat;
}
?>
<title>:: Asset Return Slip Request ::</title>
<link href="css/purchses1.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.f12{font-size:12px; color:#000000; font-weight:bold; font-family:Arial, Helvetica, sans-serif;}
.f11{font-size:12px; color:#000000; font-family:Arial, Helvetica, sans-serif;}
</style>
<div id="page" style="width:980px; margin:auto;">
<div style="width:100%;">
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td align='left'><img src='Setup/CompanyLogo/mx-erp.png' /></td>
<!-- <td align='right'><img src='images/right_img.jpg' /></td> -->
</tr>
<tr>
<td colspan='2' align="center"><h1 style="color:#006699; font-size:16px; font-weight:900; padding:10px; text-align:center;">Asset Return Slip Request</h1></td>
</tr>
</table>
</div>
<div id="foo" style="text-align:center;"><input type="button" onclick="javascript:toggle_visibility('foo');" value="Print" /></div>
<br />

<div>
<table width="100%" border="1" cellpadding="3" cellspacing="0" bordercolor="#000000" style="border-collapse:collapse;">
<tr>
	<td width="15%" class="f12">Branch</td>
	<td width="35%" class="f11"><?php echo $s->getField('locations','loccode',$row['site'],'locationname');?></td>
	<td width="15%" class="f12">Return Slip No.</td>
	<td class="f11"><?php echo $row['return_slipno'];?></td>
</tr>
<tr>
	<td class="f12">Return Date</td>
	<td class="f11"><?php echo date('d/m/Y',strtotime($row['returndate'])); ?></td>
	<td class="f12">From To</td>
	<td class="f11">
		<?php if($row['issueto']==''){ echo $a=$s->getField('empmaster','id',$row['received_by'],'emp_name'); } 
	    else{ echo $b= $s->getField('contractor_master','id',$row['issueto'],'contractor_name'); } ?>
	</td>
</tr>
<!--<tr class="row1">
	
	<td class="jjrs_tablehead" ><strong>Returnable</strong></td>
	<td class="jjrs_tablehead"><?php echo $row['returnable'];?></td>
</tr>-->
<tr>
	<td class="f12">Remarks</td>
	<td colspan="3" class="f11"><?php echo $row['remarks']; ?></td>
</tr>
</table>
<br />
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse;" bordercolor="#000000">
		<tr class="row1">
			<td width="5%" class="f12">Sr. No.</td>
			<td width="13%" class="f12">Asset Code</td>
			<td width="22%" class="f12">Asset Name</td>
			<td width="8%" class="f12">Return Qty</td>
			<td width="8%" class="f12">Unit</td>
			<td width="10%" class="f12" >Return Date</td>
			<td class="f12">Remarks</td>
		</tr>   
<?php 
$result2=DB_query("SELECT a.*,b.* FROM  asset_return a,asset_return_details b,asset_issue_details c WHERE b.parentId='".$_REQUEST['rid']."' and b.asset_issue_detail_id=c.id",$db);
//echo "SELECT a.*,b.* FROM  asset_return a,asset_return_details b,asset_issue_details c WHERE b.parentId='".$_REQUEST['rid']."' and b.asset_issue_detail_id=c.id";
$i=1;
while($myrow2=DB_fetch_array($result2))
{
$det1=DB_fetch_assoc(DB_query("select * from asset_issue_details where id='".$myrow2['asset_issue_detail_id']."'",$db));
$asset_detail=DB_fetch_assoc(DB_query("select * from machine_center where id='".$det1['mst_itemid']."'",$db));
$unit=DB_fetch_assoc(DB_query("select * from unitsofmeasure where unitid='".$asset_detail['unit']."'",$db));
?>
<tr>
	<td class="f11"><?php echo $i;?></td>
	<td class="f11"><?php echo  $asset_detail['code'];?></td>
	<td class="f11"><?php echo  $asset_detail['name'];?></td>
	<td class="f11"><?php echo "1";?></td>
	<td class="f11"><?php echo $unit['unitname']; ?></td>
	<td class="f11"><?php echo convertDate($myrow2['returndate']);?></td>
	<td class="f11"><?php echo $myrow2['remarks'];?></td>
</tr>
<?php $i++; } ?>
</table>
<br />
<table width="100%" cellpadding="3" cellspacing="0">
<tr>
<td class="f12">Created By </td>
<td align="right" class="f12">Approved By </td>
</tr>
<tr>
<td class="f11"><?php echo $s->GetFieldValue('www_users','id="'.$row['createdBy'].'"','realname');?></td>
<td align="right" class="f11">&nbsp; </td>
</tr>
</table>
</div>
</div>
<script type="text/javascript" language="javascript">
  function toggle_visibility(id) {
  var msg=confirm("Please Use Mozilla Firefox And Print In Landscape Mode");
  if(msg){
       var e = document.getElementById(id);
	      e.style.display = 'none';
		       //alert(e.style.display);
			   window.print();
    }
	}
</script>
