<?php
$PageSecurity = 2;
include('includes/DefineSuppTransClass.php');
include('includes/DefinePOClass.php');
include('includes/SQL_CommonFunctions.inc');
include('includes/session.inc');
include('includes/function_lib.php');
include('includes/stockcalculation.php');
$function_filter[]=$_REQUEST['dealer'];
$function_filter[]=$_REQUEST['store'];
$function_filter[]=date('Y-m-d'); 
$function_filter[]=date('Y-m-d'); 


   $data1='';
	$data1.="<option value='0'>Select</option>";	
	$floor_sql=DB_query("SELECT  dbl_addmrn.MRNNo as mrnno,dbl_addmrn.MRNDate as date,dbl_addmrn.id AS id1 FROM dbl_addmrnqty 
	INNER JOIN dbl_addmrn ON dbl_addmrn.id=dbl_addmrnqty.issue_id  WHERE site='".$_REQUEST['dealer']."'
	 AND StoreCode ='".$_REQUEST['store']."'  AND mst_itemid ='".$_REQUEST['items']."' and dbl_addmrnqty.dispatch_status=0 ",$db);
	while($floor_row=DB_fetch_array($floor_sql))
	{
	
$data1.="<option value='".$floor_row['id1']."'>".$floor_row['mrnno'].'-'.$floor_row['date']."</option>";
		
	 } 
	
	
$op=openingBalance($function_filter,$_REQUEST['items']);
$in_1=receivedMRN($function_filter,$_REQUEST['items']);
$out_1=issueSlip($function_filter,$_REQUEST['items']);
$out_2=issueSiteToSite($function_filter,$_REQUEST['items']);		
$in_2=receivedSiteToSite($function_filter,$_REQUEST['items']);
$out_3=issueMatarialReturn($function_filter,$_REQUEST['items']);
$in_3=receivedReturn($function_filter,$_REQUEST['items']);	
$out_4=Rgpchallan($function_filter,$_REQUEST['items']);
$out_5=Nrgp($function_filter,$_REQUEST['items']);
$in_4=Rgpreturn($function_filter,$_REQUEST['items']);	 
$in_5=FinishedMR($function_filter,$_REQUEST['items']);
$in_6=dispatchreturnsaleorder($function_filter,$_REQUEST['items']);
$out_6=dispatchsaleorder($function_filter,$_REQUEST['items']);
$invalue=($op+$in_1+$in_2+$in_3+$in_4+$in_5+$in_6);
$outvalue=($out_1+$out_2+$out_3+$out_4+$out_5+$out_6);
$tot=$invalue-$outvalue;
$stockbalance=$tot;	
	
    
	
	echo $data=$data1."__".$stockbalance;
			
			
			
