<?php 
$PageSecurity = 4;
include('includes/session.inc');
include('includes/DefineSuppTransClass.php');
include('includes/function_lib.php');
include('includes/stockcalculation.php');
//echo $_REQUEST['store'];
$function_filter[0]=$_REQUEST['site'];
$function_filter[1]=$_REQUEST['store'];
$function_filter[2]=date('Y-m-d');

?>


<table width="100%" border="1" cellspacing="0" cellpadding="3" >
      <tr class="row1">
        <td ><strong>Item Code</strong></td>
        <td><strong>Item Name</strong></td>
        <td><strong>Pkg description</strong></td>
        <td><strong>Batch no.</strong></td>
         <td><strong>MFG.</strong></td>
         <td><strong>Expiry.</strong></td>
         <td><strong>Stock Balance </strong></td>
        <td  colspan="5" style="text-align:center"><strong>Issue Qty<strong> </td> 
      </tr>
      <?php
    $i=0;
	  $sql=DB_query("select * from addmrnqty where issue_id='".$_REQUEST['id']."' ",$db);
	  while($row=DB_fetch_array($sql))
	  {
	    $itemcode=$s->getField('item_master','id',$row['mst_itemid'],'StockID');
	    $itemname=$s->getField('item_master','id',$row['mst_itemid'],'item_name');
      $unitid=$row['mst_unitid']; 
      $unitid1 = $s->getField('item_master','id',$row['mst_itemid'],'conv_unit');      


        
	   //$unitid=$s->getField('item_master','id',$row['mst_itemid'],'mst_unitid');
	   //$unit=$s->getField('unitsofmeasure','unitid',$unitid,'unitname');
	  
      $op=openingBalance($function_filter,$row['mst_itemid']);
        $in_1=receivedMRN($function_filter,$row['mst_itemid']);
        $out_1=issueSlip($function_filter,$row['mst_itemid']);
        $out_2=issueSiteToSite($function_filter,$row['mst_itemid']);    
        $in_2=receivedSiteToSite($function_filter,$row['mst_itemid']);
        $out_3=issueMatarialReturn($function_filter,$row['mst_itemid']);
        $in_3=receivedReturn($function_filter,$row['mst_itemid']);  
        $out_4=Rgpchallan($function_filter,$row['mst_itemid']);
        $out_5=Nrgp($function_filter,$row['mst_itemid']);
        $in_4=Rgpreturn($function_filter,$row['mst_itemid']);  
        $in_5=FinishedMR($function_filter,$row['mst_itemid']);
        $in_6=MaterialConReceived($function_filter,$row['mst_itemid']);
        $out_6=MaterialConIssue($function_filter,$row['mst_itemid']);
        $in_7=PhysicalStockPlus($function_filter,$row['mst_itemid']);
        $out_7=PhysicalStockMinus($function_filter,$row['mst_itemid']);
        $out_8=dispatchIssue($function_filter,$row['mst_itemid']);
        $out_9=jobWorkChallan57Issue($function_filter,$row['mst_itemid']);
        $in_8=jobWorkChallan57Received($function_filter,$row['mst_itemid']);
        $in_9=directPurchase($function_filter,$row['mst_itemid']);
        $in_10=saleReturn($function_filter,$row['mst_itemid']);
        $out_10=invoice($function_filter,$row['mst_itemid']);
        $invalue=($op+$in_1+$in_2+$in_3+$in_4+$in_5 + $in_6 + $in_7 + $in_8+$in_9 + $in_10);
        $outvalue=($out_1+$out_2+$out_3+$out_4+$out_5 + $out_6 + $out_7 + $out_8 + $out_9 + $out_10);
        $tot=$invalue-$outvalue;
        $stockallitems=$tot;
        $total_current=$tot;
		
	      if($total_current==0)
        {
          $primary_qty=0;
          $secondary_qty=0;
        }
        else
        {
          $primary_qty=$row['reciveqty'];
          $secondary_qty=$row['stock_qty2'];
        }
	   ?>
	  	  
    <tr bgcolor="#e7e7e7">
    <td>
      <input type="text" value="<?php echo $itemcode; ?>" tabindex="" readonly id="itemcode_<?php echo $i; ?>" name="delitem[]" style="width:150px;"
		    /><input type="hidden" readonly id="itemdataid_<?php echo $i; ?>" name="itemdataid[]" value="<?php echo $row['mst_itemid']; ?>"/>
    </td>
    <td><input type="text" name="itemname[]"  id="descriptions_<?php echo $i; ?>" readonly  value="<?php echo $itemname; ?>"/></td>
    <td><input type="text" name="desc[]"  id="desc_<?php echo $i; ?>"  value=""/></td>
    <td><input type="text" name="batchno[]" value="<?php echo $row['batch_no']; ?>" readonly></td>
    <td>
      <input type="text" name="dateofmfg[]" id="mfg_<?php echo $i; ?>" style="width:100px;"  value="<?php echo ConvertSQLDate($row['mfg']); ?>" readonly/>
    </td>
    <td>
      <input type="text" name="dateofexpiry[]" id="expiry_<?php echo $i; ?>" style="width:100px;"  value="<?php echo ConvertSQLDate($row['expiry']); ?>" readonly/>
    </td>
    <td>
      <input type="text" name="stock[]" id="Stockbalance_<?php echo $i; ?>" style="width:100px;"  value="<?php echo $total_current; ?>" readonly/>
    </td>
    <td>
      <input type="text" name="q1[]" id="q1_<?php echo $i; ?>" style="width:100px;" onkeyup="calamt1(<?php echo $i; ?>,this.value)"  value="<?php echo $primary_qty; ?>" readonly  />
    </td> 
     <td>
      <select name="unitnamea[]" id="uom_<?php echo $i; ?>" style="width:50px;">
       <?php
       $sql_unit=DB_query("select * from unitsofmeasure where unitid='".$unitid."'",$db);
       while($row1=DB_fetch_array($sql_unit))
       {
        $u='';
        if($row1['unitid']==$unitid)
          $u="selected";
       ?>
       <option value="<?php echo $row1['unitid']; ?>" <?php echo $u; ?> ><?php echo $row1['unitname']; ?></option>
       <?php } ?>
    </select>
    </td>    
    <td><input  type="hidden" name="confac[]" style="width:50px;"  id="confac_<?php echo $i; ?>" value="<?php echo $row['conv_fac']; ?>"   /></td>
    <td width="10%"><input  type="text" name="q2[]" style="width:100px;"  id="q2" value="<?php echo $secondary_qty; ?>"  readonly /></td> 
      <td>
      <select name="unitnamea2[]" id="uom_<?php echo $i; ?>" style="width:50px;">
       <?php
       $sql_unit=DB_query("select * from unitsofmeasure where unitid='".$unitid1."'",$db);
       while($row1=DB_fetch_array($sql_unit))
       {
        $u='';
        if($row1['unitid']==$unitid1)
          $u="selected";
       ?>
       <option value="<?php echo $row1['unitid']; ?>" <?php echo $u; ?> ><?php echo $row1['unitname']; ?></option>
       <?php } ?>
    </select>
    </td>    
  </tr>
		<?php $i++; } ?>     
    </table>
    <table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
  <tr>
    <td class="tabledata1"><strong>Remarks:</strong></td>
    <td><textarea name="remarks" id="remarks" cols="" rows="" style="width:100%; height:60px;"></textarea></td>
  </tr>
</table>
    <p align="center"><input type="submit" name="Save" value="Save" class="search" /></p>


	
	



