<?php
$PageSecurity = 2;
$title = _('Material Return Slip');
$_SESSION['modid']=$_REQUEST['modid'];
$_SESSION['frmid']=$_REQUEST['frmid'];
$frmpermission= $px->GetFileAccess($_SESSION['modid'],$_SESSION['frmid'],$_SESSION['ACGRoleId']);
$_SESSION['frmAdd']=$frmpermission[0];
$_SESSION['frmEdit']=$frmpermission[1];
$_SESSION['frmDelete']=$frmpermission[2];
$_SESSION['frmView']=$frmpermission[3];
date_default_timezone_set('Asia/Calcutta');

?>
<?php 
if($_REQUEST['action']=="Delete" && $_REQUEST['id']!='')
{
      $asset_issue_id=$s->getField('asset_return','id',$_REQUEST['id'],'asset_issue_no');
    
      $issue_status_update="update asset_issue set full_returning_status='0' where id='".$asset_issue_id."'"; 
     $result_status_update=DB_query($issue_status_update,$db);
 
       $sql_item="select asset_issue_detail_id from asset_return_details where parentId='".$_REQUEST['id']."'";
      $result_item=DB_query($sql_item,$db);
      while($rs_item=DB_fetch_array($result_item))
      {
         $asset_returning_status="update asset_issue_details set returning_status='0' where id='".$rs_item[0]."'";
         $result_asset_returning_status=DB_query($asset_returning_status,$db);
      } 
   

    //  DB_query("update ")

    DB_query("delete from asset_return where id='".$_REQUEST['id']."'",$db);
    DB_query("delete from asset_return_details where parentId='".$_REQUEST['id']."'",$db);

  echo "<script>location.href='index.php?route=asset_return_index&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
}
?>
<style>
#slidingDiv {
    display: none;
	height:100px;
	background-color: #D9D6DA;
	padding:20px;
}
</style>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h1>Asset Return Slip</h1>
<?php if($_SESSION['frmAdd']=='1') {?>

<p align="left"><a href="index.php?route=add_asset_return&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>"><input type="button" class="search" value="Asset Return Slip"></a></p>

<?php }?>

<table width="100%" border="0" cellspacing="0" cellpadding="3" class="thborder">
  <tr>
  	<th>Branch</th>
    <th width="16%">Return Slip No.</th>
    <th width="8%">Return Date</th>
    <th width="10%">Against Issue Slip</th>
    <th width="4%" style="text-align:center;">Delete</th>
    <th width="4%" style="text-align:center;">Print</th>
  </tr>
  <?php

  $sql=DB_query("Select * from asset_return where CompanyId='".$_SESSION['ACGCompanyId']."' and
               returndate BETWEEN '".$_SESSION['financialYrStart']."'   AND '".$_SESSION['financialYrEnd']."'
			   order by id desc",$db);
  $i=0;
  if(DB_num_rows($sql)>0)
  {
  while($myrow=DB_fetch_array($sql))
  {
 if($myrow['receiveissue']=='0')
 {
	$productionFloor1=$s->getField('contractor_master','id',$myrow['receiveissue'],'contractor_name');
 }
 else
 {
 	$productionFloor2=$s->getField('empmaster','id',$myrow['receiveemp'],'emp_name');
 }
   	 $productionFloor1=$s->getField('contractor_master','id',$myrow['receiveissue'],'contractor_name');
	 $productionFloor2=$s->getField('empmaster','id',$myrow['receiveemp'],'emp_name');
			  if(empty($productionFloor1))
			  {	$productionFloor=$productionFloor2;  } else {$productionFloor=$productionFloor1;	  }
  ?>
  <tr onmouseover="this.style.backgroundColor='#fffeb3'; this.style.color='#00f';" onmouseout="this.style.backgroundColor='#FFF'; this.style.color='#000000';">
  	<td><?php 
	$sitename=$s->getField('locations','loccode',$myrow['site'],'locationname');
	echo $sitename;?></td>
    <td><?php echo $myrow['return_slipno'];?></td>
    <td><?php echo ConvertSQLDate($myrow['returndate']);?></td>  
    <td><?php echo $productionFloor1=$s->getField('asset_issue','id',$myrow['asset_issue_no'],'issue_slipno'); ?></td>
    <td style="text-align:center;"><a href="index.php?route=asset_return_index&modid=<?php echo $_REQUEST['modid'] ?>&frmid=<?php echo $_REQUEST['frmid'] ?>&action=Delete&id=<?php echo $myrow['id'] ?>" onclick="return confirm('Are you sure you want to delete?')" ><img title="Delete" src="images/Icon_Delete.png" height="15" width="15" /></a></td>
    <td style="text-align:center;"><a href="print_asset_return_slip.php?rid=<?php echo $myrow['id'] ?>" target="_blank"><img title="Print" src="images/icon_print.jpg" height="18" width="18" /><!--<input type="button" name="print" value="Print" style="cursor: pointer;" class="search">--></a></td>
</tr>
  <?php $i++;} }
  else
  {?>
  <tr>
    <td colspan="6" align="center"><strong>No Record Found</strong></td>
  </tr>
  <?php 	
  }
  ?>
</table>
</div>
</div>



