<link rel="stylesheet" href="css/new_mxerp.css">
<?php
$modid=$_REQUEST['modid'];
$frmid=$_REQUEST['frmid'];
$rurl="&modid=".$modid."&frmid=".$frmid;
if($_REQUEST['action']=='delete' and $_REQUEST['Id']!='')
{
$del1=DB_query("delete from material_slip_against_job_card where id='".$_REQUEST['Id']."'",$db);
$del1=DB_query("delete from material_job_item where material_slip_id='".$_REQUEST['Id']."'",$db);
$del1=DB_query("delete from material_ink_details where material_slip_id='".$_REQUEST['Id']."'",$db);
$s->pageLocation('index.php?route=material_job_cardlist&modid='.$_REQUEST['modid'].'&frmid='.$_REQUEST['frmid'].$rurl);
}
?>

<div class="body_contain">
<div class="tab_div">

<h1><?php echo $s->getField('modules_form','id',$_REQUEST['frmid'],'frm_name'); ?></h1>
<?php if($_SESSION['frmAdd']==1) { ?>
<p align="left"><a href="index.php?route=material_job_card&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&action=addNew"><input type="button" value="Add Material Requirement Slip" class="search"></a></p>
<?php  } ?>

<table width="100%" border="0" cellpadding="3" cellspacing="0" class="thborder">
<tr>
	<th width="10%">Material Slip No.</th>
	<th width="10%">Req. Slip Date</th>
	<th width="20%">Prepared By</th>
	<th>Remarks</th>
	<!--<th width="7%">Job Card No.</th>
	<th width="7%">Job Card Date</th>
	<th width="7%">WO No.</th> -->
	<!--<th>Item Name</th>
	<th width="100">Order Qty.</th> -->
	<!-- <th width="100">Batch No.</th> -->
	<th width="4%" style="text-align:center;">View</th>
	<th width="4%" style="text-align:center;">Edit</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 material_slip_against_job_card where branch_id in('".$_SESSION['AssignedBranch']."') order by id",$db);	
$i=0;
$num=DB_num_rows($sql);
if($num>0)
{
    while($myrow=DB_fetch_array($sql))
   {

   	 $sql_check_issue="select id from addissue where mrs_id='".$myrow['id']."' ";
   	 $result_check_issue=DB_query($sql_check_issue,$db);
   	 $issue_count=DB_num_rows($result_check_issue);


	  //$jobcard=$s->getField('job_route_card','id',$myrow['job_card_id'],'job_card_no');
?>
<tr>
<td><?php echo $myrow['mat_slip_no']; ?></td>
<td><?php echo ConvertSQLDate($myrow['date']);  ?></td>
<td><?php echo $s->getField('www_users','id',$myrow['created_by'],'realname') ?></td>
<td><?php echo $myrow['remarks'];  ?></td>
<!--<td><?php echo $s->getField('job_card','id',$myrow['job_card_id'],'job_card_no'); ?></td>
<td><?php echo $myrow['job_card_data'];?></td>
<td><?php echo $s->getField('prd_wo','id',$myrow['wo_id'],'wo_no'); ?></td> -->
<!-- <td colspan="2" valign="top" style="padding:0;">
<div id="amc-tab">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
  <?php
      $sql_details=DB_query("select * from material_job_item where material_slip_id='".$myrow['id']."'",$db); 
       while($result_details=DB_fetch_array($sql_details))
       {
    
       	  $itemname=$s->getField('item_master','id',$result_details['mst_itemid'],'item_name');
	     
  ?>

<tr>
<td><?php echo $itemname;?></td>
<td width="100" style="text-align:right"><?php echo number_format((float)$result_details['primary_qty'],2);?></td>
<?php echo $myrow['batch_no'];?></td> 
</tr>
<?php } ?>
</table>
</div>
</td> -->
<td style="text-align:center;"><?php if($_SESSION['frmView']==1) { ?><a href="index.php?route=material_job_card_edit&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&action=view&Id=<?php echo $myrow['id'];?>"><img src="images/search.gif" height="15" width="15" title="View" /></a><?php } else { ?><img src="images/search.gif" height="15" width="15" title="No Permission" style="opacity:0.5;" /><?php } ?></td>
<td style="text-align:center;">
<?php 
	
		if($_SESSION['frmEdit']==1 & $issue_count=='0') { ?><a href="index.php?route=material_job_card_edit&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&action=edit&Id=<?php echo $myrow['id'];?>"><img src="images/icon-edit.png" height="15" width="15" title="Edit" /></a><?php } else { ?><img src="images/icon-edit.png" height="15" width="15" title="No Permission" style="opacity:0.5;" /><?php }
	
	?></td>
<td style="text-align:center;">
<?php 
	
		if($issue_count=='0') { ?><div align="center"> <a href="" onclick="javascript:delete_reason(<?php echo $myrow['id'] ?>,<?php echo $_REQUEST['frmid'] ?>,<?php echo $_REQUEST['modid'] ?>)"><img src="images/Icon_Delete.png" height="15" width="15" title="Delete" /></a></div><?php } else { ?><img src="images/Icon_Delete.png" height="15" width="15" title="Delete" style="opacity:0.5;" /><?php  }
	
	?></td>
<td style="text-align:center;"><a href="material_requirement_slip.php?printid=<?php echo $myrow['id'];  ?>" target="_blank" ><img src="images/icon_print.jpg"  height="18" width="18" title="Print" ></a></td>
</tr>
<?php $i++;}}
else { ?>
<tr>
<td colspan="12">No Records Found</td>
</tr>
<?php }   ?>
	
</table>
</div></div>

<script  type="text/javascript">
function  delete_reason(id,frmid,modid)
{
window.open("delete_reason.php?del_id="+id+"&frm="+frmid+"&modid="+modid,"profiles_popup_window","height=425,width=800,toolbar=no,menubar=no,dependent=yes,resizable=yes");

}
</script>