category wise report issue fixed

This commit is contained in:
gandhimathi 2017-12-14 13:43:12 +05:30
parent 934326f76c
commit e4fb60c226

View File

@ -461,7 +461,7 @@ function reqdetail(){
function report_relpo(){
$sql="select Mast.PONO,Mast.POType,date_format(Mast.PODate,'%d-%m-%Y') as CreatedDate,date_format(Mast.ReleasedOn,'%d-%m-%Y') as ReleasedDate,Dept_Details.DepartmentName As Dept_Name,Mast.TotalOrderValue
$sql="select Mast.PONO,Mast.POType,date_format(Mast.PODate,'%d-%m-%Y') as PODate,date_format(Mast.ReleasedOn,'%d-%m-%Y') as ReleasedDate,Dept_Details.DepartmentName As Dept_Name,Mast.TotalOrderValue
from T_PurchaseOrder_Master Mast
JOIN T_PurchaseOrder_LineItem Det on Det.PONO=Mast.PONO
JOIN T_Requestion_Master as Req on Req.ReqNo=Det.ReqNo
@ -482,7 +482,7 @@ group by Mast.PONO";
function report_openpending(){
$sql="select Mast.PONO as PONO,Mast.POType as POType,date_format(Mast.PODate,'%d-%m-%Y') as CreatedDate,date_format(Mast.ApprovedOn,'%d-%m-%Y') as ApprovedDate,Dept_Details.DepartmentName As Dept_Name,Mast.TotalOrderValue
$sql="select Mast.PONO as PONO,Mast.POType as POType,date_format(Mast.PODate,'%d-%m-%Y') as PODate,date_format(Mast.ApprovedOn,'%d-%m-%Y') as ApprovedDate,Dept_Details.DepartmentName As Dept_Name,Mast.TotalOrderValue
from T_PurchaseOrder_Master Mast
JOIN T_PurchaseOrder_LineItem Det on Det.PONO=Mast.PONO
JOIN T_Requestion_Master as Req on Req.ReqNo=Det.ReqNo
@ -603,12 +603,12 @@ group by po.SupplierID,pl.MaterialCode";
$sql="select
DATE_FORMAT(IF(matv.CreatedDate = '0000-00-00', NOW(), matv.CreatedDate), '%b-%Y') AS Month,
DATE_FORMAT(IF(matv.PODate = '0000-00-00', NOW(), matv.PODate), '%b-%Y') AS Month,
matv.MaterialCode,mat.MaterialName,mat.UOM,ROUND(AVG(matv.Rate),2) as Average_Rate
from T_MaterialItem_PO matv
join T_MaterialMaster mat on matv.MaterialCode=mat.MaterialCode
group by matv.MaterialCode
order by monthname(matv.CreatedDate)";
order by monthname(matv.PODate)";
$query = $this->db->query($sql);
return $query->result();
@ -1524,10 +1524,10 @@ left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode
left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and
case
when (month(pm.CreatedDate) >=4) then
(YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(pm.CreatedDate) >= 4 ) or ( YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.CreatedDate) <= 3 )
when (month(pm.PODate) >=4) then
(YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.PODate) <= 3 )
else
(YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.CreatedDate) >= 4 ) or ( YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(pm.CreatedDate) <= 3 )
(YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 )
end
group by category
) as year left join
@ -1537,7 +1537,7 @@ left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO
left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode
left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and
month(pm.CreatedDate) = month(current_date())
month(pm.PODate) = month(current_date())
group by category
) as month on month.category=year.category
left join
@ -1547,7 +1547,7 @@ left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO
left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode
left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and
date(pm.CreatedDate) = current_date()
date(pm.PODate) = current_date()
group by category
) as today on today.category=month.category
group by category ";
@ -1563,10 +1563,10 @@ left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode
left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and
case
when (month(pm.CreatedDate) >=4) then
(YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(pm.CreatedDate) >= 4 ) or ( YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.CreatedDate) <= 3 )
when (month(pm.PODate) >=4) then
(YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.PODate) <= 3 )
else
(YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.CreatedDate) >= 4 ) or ( YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(pm.CreatedDate) <= 3 )
(YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 )
end
and mm.Category = '".$cat."'
group by supplier_name,material_name";
@ -1582,7 +1582,7 @@ left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO
left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode
left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and
month(pm.CreatedDate) = month(current_date()) and mm.Category = '".$cat."'
month(pm.PODate) = month(current_date()) and mm.Category = '".$cat."'
group by supplier_name,material_name";
$query = $this->db->query($sql);
return $query->result();
@ -1595,7 +1595,7 @@ left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO
left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode
left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and
date(pm.CreatedDate) = current_date() and mm.Category = '".$cat."'
date(pm.PODate) = current_date() and mm.Category = '".$cat."'
group by supplier_name,material_name";
$query = $this->db->query($sql);
echo $sql;
@ -1605,31 +1605,31 @@ group by supplier_name,material_name";
$sql="select mm.Category as category,
SUM(IF(month(pm.CreatedDate) = 4, pl.Quantity, 0)) AS April,
SUM(IF(month(pm.CreatedDate) = 5, pl.Quantity, 0)) AS May,
SUM(IF(month(pm.CreatedDate) = 6, pl.Quantity, 0)) AS June,
SUM(IF(month(pm.CreatedDate) = 7, pl.Quantity, 0)) AS July,
SUM(IF(month(pm.CreatedDate) = 8, pl.Quantity, 0)) AS August,
SUM(IF(month(pm.CreatedDate) = 9, pl.Quantity, 0)) AS September,
SUM(IF(month(pm.CreatedDate) = 10, pl.Quantity, 0)) AS October,
SUM(IF(month(pm.CreatedDate) = 11, pl.Quantity, 0)) AS November,
SUM(IF(month(pm.CreatedDate) = 12, pl.Quantity, 0)) AS December,
SUM(IF(month(pm.CreatedDate) = 1, pl.Quantity, 0)) AS January,
SUM(IF(month(pm.CreatedDate) = 2, pl.Quantity, 0)) AS February,
SUM(IF(month(pm.CreatedDate) = 3, pl.Quantity, 0)) AS March,
SUM(IF(month(pm.PODate) = 4, pl.Quantity, 0)) AS April,
SUM(IF(month(pm.PODate) = 5, pl.Quantity, 0)) AS May,
SUM(IF(month(pm.PODate) = 6, pl.Quantity, 0)) AS June,
SUM(IF(month(pm.PODate) = 7, pl.Quantity, 0)) AS July,
SUM(IF(month(pm.PODate) = 8, pl.Quantity, 0)) AS August,
SUM(IF(month(pm.PODate) = 9, pl.Quantity, 0)) AS September,
SUM(IF(month(pm.PODate) = 10, pl.Quantity, 0)) AS October,
SUM(IF(month(pm.PODate) = 11, pl.Quantity, 0)) AS November,
SUM(IF(month(pm.PODate) = 12, pl.Quantity, 0)) AS December,
SUM(IF(month(pm.PODate) = 1, pl.Quantity, 0)) AS January,
SUM(IF(month(pm.PODate) = 2, pl.Quantity, 0)) AS February,
SUM(IF(month(pm.PODate) = 3, pl.Quantity, 0)) AS March,
sum(pl.Quantity) as qtotal,
SUM(IF(month(pm.CreatedDate) = 4, pl.Quantity * pl.Rate, 0)) AS vApril,
SUM(IF(month(pm.CreatedDate) = 5, pl.Quantity * pl.Rate, 0)) AS vMay,
SUM(IF(month(pm.CreatedDate) = 6, pl.Quantity * pl.Rate, 0)) AS vJune,
SUM(IF(month(pm.CreatedDate) = 7, pl.Quantity * pl.Rate, 0)) AS vJuly,
SUM(IF(month(pm.CreatedDate) = 8, pl.Quantity * pl.Rate, 0)) AS vAugust,
SUM(IF(month(pm.CreatedDate) = 9, pl.Quantity * pl.Rate, 0)) AS vSeptember,
SUM(IF(month(pm.CreatedDate) = 10, pl.Quantity * pl.Rate, 0)) AS vOctober,
SUM(IF(month(pm.CreatedDate) = 11, pl.Quantity * pl.Rate, 0)) AS vNovember,
SUM(IF(month(pm.CreatedDate) = 12, pl.Quantity * pl.Rate, 0)) AS vDecember,
SUM(IF(month(pm.CreatedDate) = 1, pl.Quantity * pl.Rate, 0)) AS vJanuary,
SUM(IF(month(pm.CreatedDate) = 2, pl.Quantity * pl.Rate, 0)) AS vFebruary,
SUM(IF(month(pm.CreatedDate) = 3, pl.Quantity * pl.Rate, 0)) AS vMarch,
SUM(IF(month(pm.PODate) = 4, pl.Quantity * pl.Rate, 0)) AS vApril,
SUM(IF(month(pm.PODate) = 5, pl.Quantity * pl.Rate, 0)) AS vMay,
SUM(IF(month(pm.PODate) = 6, pl.Quantity * pl.Rate, 0)) AS vJune,
SUM(IF(month(pm.PODate) = 7, pl.Quantity * pl.Rate, 0)) AS vJuly,
SUM(IF(month(pm.PODate) = 8, pl.Quantity * pl.Rate, 0)) AS vAugust,
SUM(IF(month(pm.PODate) = 9, pl.Quantity * pl.Rate, 0)) AS vSeptember,
SUM(IF(month(pm.PODate) = 10, pl.Quantity * pl.Rate, 0)) AS vOctober,
SUM(IF(month(pm.PODate) = 11, pl.Quantity * pl.Rate, 0)) AS vNovember,
SUM(IF(month(pm.PODate) = 12, pl.Quantity * pl.Rate, 0)) AS vDecember,
SUM(IF(month(pm.PODate) = 1, pl.Quantity * pl.Rate, 0)) AS vJanuary,
SUM(IF(month(pm.PODate) = 2, pl.Quantity * pl.Rate, 0)) AS vFebruary,
SUM(IF(month(pm.PODate) = 3, pl.Quantity * pl.Rate, 0)) AS vMarch,
sum(pl.Quantity * pl.Rate) as vtotal
FROM T_PurchaseOrder_Master pm
join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO
@ -1647,7 +1647,7 @@ if ($cname!= ''){
if ($fa and $aa != ''){
$sql.=" and (pm.CreatedDate >= '".$fa."-04-01' and pm.CreatedDate <= '".$aa."-03-31')";
$sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')";
}
@ -1667,10 +1667,10 @@ join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO
join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode
join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and
monthname(pm.CreatedDate) = '".$m."' and mm.Category = '".$cat."' ";
monthname(pm.PODate) = '".$m."' and mm.Category = '".$cat."' ";
if ($fa and $aa != ''){
$sql.=" and (pm.CreatedDate >= '".$fa."-04-01' and pm.CreatedDate <= '".$aa."-03-31')";
$sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')";
}
$sql.= "group by category,supplier_name,material_name";
@ -1691,7 +1691,7 @@ where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO f
mm.Category = '".$cat."' ";
if ($fa and $aa != ''){
$sql.=" and (pm.CreatedDate >= '".$fa."-04-01' and pm.CreatedDate <= '".$aa."-03-31')";
$sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')";
}
$sql.= "group by category,supplier_name,material_name";