This commit is contained in:
venbatechnologies@gmail.com 2018-11-28 17:09:32 +05:30
parent 43acff29e6
commit 4d90965c8e

View File

@ -1358,7 +1358,7 @@ where MaterialCode = ? and SupplierID=?';
$currentyr = date("Y"); $currentyr = date("Y");
//echo $todate;die();
$finyear = $search['year']; $finyear = $search['year'];
@ -1367,11 +1367,13 @@ $pieces = explode("-", $finyear);///fin year
$startyr = $pieces['0']; $startyr = $pieces['0'];
$endyr = $pieces['1']; $endyr = $pieces['1'];
//echo $search['month'].'-'.$startyr.'-'. $endyr;die();
//echo $endyr;die(); //echo $endyr;die();
$subquery="SELECT $subquery="SELECT
DISTINCT(p.MaterialCode) AS ProductID,Ref_No,Date(CreatedOn),mm.MaterialName,stock,MaterialType,Category,stockdate,OpeningStock,mm.Category,ip.product_name,ip.product_id, DISTINCT(p.MaterialCode) AS ProductID,Ref_No,Date(CreatedOn),mm.MaterialName,stock,MaterialType,Category,stockdate,mm.Category,ip.product_name,ip.product_id,
SUM(IF(p.Transaction_type='Add',Quantity,0)) AS Addition, SUM(IF(p.Transaction_type='Add',Quantity,0)) AS Addition,
SUM(IF(p.Transaction_type='Reduce',Quantity,0)) AS Reduce, SUM(IF(p.Transaction_type='Reduce',Quantity,0)) AS Reduce,
SUM((IF(p.Transaction_type='Add',Quantity,0))-(IF(p.Transaction_type='Reduce',Quantity,0))) AS AvailableStock SUM((IF(p.Transaction_type='Add',Quantity,0))-(IF(p.Transaction_type='Reduce',Quantity,0))) AS AvailableStock
@ -1383,8 +1385,9 @@ left join ip_products ip on ip.product_id=p.MaterialCode
"; ";
if($search['month']=='' && $startyr =='' && $endyr =='') if($search['month']=='' && $startyr =='')
{ {
if($search['from_date'] != '') if($search['from_date'] != '')
{ {
@ -1402,9 +1405,11 @@ GROUP BY pp.MaterialCode
} }
else if($search['month']!='' && $startyr !='' && $endyr !='' ) else if($search['month']!='' && $startyr !='')
{ {
if($search['month']!='') if($search['month']!='')
{ {
$subquery.=" left join (select StockId,pq.MaterialCode mc, $subquery.=" left join (select StockId,pq.MaterialCode mc,
@ -1419,10 +1424,11 @@ GROUP BY pq.MaterialCode
} }
else if($search['month']!='' && $startyr =='' && $endyr =='') else if($search['month']!='' && $startyr =='')
{ {
$subquery.=" left join (select StockId,pq.MaterialCode mc, $subquery.=" left join (select StockId,pq.MaterialCode mc,
SUM((IF(pq.Transaction_type='Add',Quantity,0))-(IF(pq.Transaction_type='Reduce',Quantity,0))) SUM((IF(pq.Transaction_type='Add',Quantity,0))-(IF(pq.Transaction_type='Reduce',Quantity,0)))
AS OpeningStock AS OpeningStock
@ -1434,7 +1440,7 @@ GROUP BY pq.MaterialCode
} }
else if($search['month']=='' && $startyr !='' && $endyr !='' ) else if($search['month']=='' && $startyr !='' )
{ {
// if($search['month']!='') // if($search['month']!='')
@ -1456,7 +1462,7 @@ GROUP BY pq.MaterialCode
//$subquery.=" where mm.IsActive='1'"; //$subquery.=" where mm.IsActive='1'";
if($search['month']=='' && $startyr =='' && $endyr =='') if($search['month']=='' && $startyr =='')
{ {
if($search['from_date'] != '') if($search['from_date'] != '')
@ -1477,7 +1483,7 @@ if($search['month']=='' && $startyr =='' && $endyr =='')
else else
{ {
if($search['month']!='' && $startyr =='' && $endyr =='') if($search['month']!='' && $startyr =='')
{ {
$subquery.=" where date(p.CreatedOn)>= '".$currentyr.'-'.$search['month']."-01' and $subquery.=" where date(p.CreatedOn)>= '".$currentyr.'-'.$search['month']."-01' and
@ -1485,12 +1491,12 @@ else
} }
if($search['month']!='' && $startyr !='' && $endyr !='') if($search['month']!='' && $startyr !='')
{ {
$subquery.=" where month(p.CreatedOn)= '".$search['month']."' and date(p.CreatedOn)>= '".$startyr."-04-01' and date(p.CreatedOn)<= '".$endyr."-03-31'"; $subquery.=" where month(p.CreatedOn)= '".$search['month']."' and date(p.CreatedOn)>= '".$startyr."-04-01' and date(p.CreatedOn)<= '".$endyr."-03-31'";
} }
if($startyr !='' && $endyr !='' && $search['month']=='') if($startyr !='' && $search['month']=='')
{ {
$subquery.=" where date(p.CreatedOn)>= '".$startyr."-04-01' and date(p.CreatedOn)<= '".$endyr."-03-31'"; $subquery.=" where date(p.CreatedOn)>= '".$startyr."-04-01' and date(p.CreatedOn)<= '".$endyr."-03-31'";
} }