|
|
|
|
@ -1428,49 +1428,50 @@ group by supplier_name,material_name";
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
return $query->result();
|
|
|
|
|
}
|
|
|
|
|
function ireport_purchase($cname,$prod,$fa,$aa,$m,$frm,$t,$cat){
|
|
|
|
|
|
|
|
|
|
function ireport_purchase($cname,$prod,$fa,$aa,$m,$frm,$t,$cat){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as pono,date_format(im.CreatedDate,'%d-%m-%Y') as created_date,TIME_FORMAT(im.CreatedDate,'%l:%i %p') as created_time,mm.MaterialName as material_name,mm.Category as category,sd.SupplierName as supplier_name,mm.UOM as UOM, sum(id.QuantityAsPerInvoice) as quantity,pl.Rate as rate,round(sum(id.QuantityAsPerInvoice) * pl.Rate,2) as value,if(POType = 'IMPORT' or POType = 'CAPITAL',sum(pm.ExchangeRate),0) as exchange_rate,date_format(im.MaterialRcvdDate,'%d-%m-%Y') as materialrcvddate,
|
|
|
|
|
$sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as pono,date_format(im.CreatedDate,'%d-%m-%Y') as created_date,TIME_FORMAT(im.CreatedDate,'%l:%i %p') as created_time,mm.MaterialName as material_name,mm.Category as category,sd.SupplierName as supplier_name,mm.UOM as UOM, id.QuantityAsPerInvoice as quantity,pl.Rate as rate,round(id.QuantityAsPerInvoice * pl.Rate,2) as value,if(POType = 'IMPORT' or POType = 'CAPITAL',pm.ExchangeRate,0) as exchange_rate,date_format(im.MaterialRcvdDate,'%d-%m-%Y') as materialrcvddate,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
sum(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity),
|
|
|
|
|
sum(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) as sgst,
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) as sgst,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
sum(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity),
|
|
|
|
|
sum(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) as cgst,
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) as cgst,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
sum(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity),
|
|
|
|
|
sum(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) as igst,
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) as igst,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
sum(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity),
|
|
|
|
|
sum(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2) as discount,
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2) as discount,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
sum(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity),
|
|
|
|
|
sum(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) as freight,
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) as freight,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
sum(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) as Package,
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) as Package,
|
|
|
|
|
|
|
|
|
|
round((
|
|
|
|
|
if(POType = 'IMPORT',sum(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
|
|
|
if(POType = 'CAPITAL' && CapitalRange = 0,sum(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
|
|
|
ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0)))
|
|
|
|
|
if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
|
|
|
if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
|
|
|
ifnull((id.QuantityAsPerInvoice * pl.Rate),0)))
|
|
|
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
sum(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity),
|
|
|
|
|
sum(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2)
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2)
|
|
|
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
sum(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity),
|
|
|
|
|
sum(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2)
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2)
|
|
|
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
sum(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity),
|
|
|
|
|
sum(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2)
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2)
|
|
|
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
sum(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity),
|
|
|
|
|
sum(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2)
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2)
|
|
|
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
sum(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2)
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2)
|
|
|
|
|
- round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
sum(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity),
|
|
|
|
|
sum(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total,
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total,
|
|
|
|
|
im.file as ifile,pb.FilePath as file
|
|
|
|
|
from T_IGR_Master im
|
|
|
|
|
left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO
|
|
|
|
|
@ -1536,23 +1537,56 @@ $sql.="group by pono,material_name,category,supplier_name,id.IGRItemNo";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql ="select im.IGRNO as igrn,pm.POType as potype,im.PONO as pono,date_format(im.CreatedDate,'%d-%m-%Y') as created_date,TIME_FORMAT(im.CreatedDate,'%l:%i %p') as created_time,mm.MaterialName as material_name,mm.Category as category,sd.SupplierName as supplier_name,mm.UOM as UOM, id.QuantityAsPerInvoice as quantity,pl.Rate as rate,round(id.QuantityAsPerInvoice * pl.Rate,2) as value,if(POType = 'IMPORT' or POType = 'CAPITAL',pm.ExchangeRate,0) as exchange_rate,date_format(im.MaterialRcvdDate,'%d-%m-%Y') as materialrcvddate,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) as sgst, round(ifnull(if(POType = 'REVENUE', (id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) as cgst, round(ifnull(if(POType = 'REVENUE', (id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) as igst, round(ifnull(if(POType = 'REVENUE', (id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2) as discount,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE', (id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) as freight,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE', (id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) as Package,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) as sgst,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) as cgst,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) as igst,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2) as discount,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) as freight,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) as Package,
|
|
|
|
|
|
|
|
|
|
round(( if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
|
|
|
if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
|
|
|
ifnull((id.QuantityAsPerInvoice * pl.Rate),0))) + round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
round((
|
|
|
|
|
if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
|
|
|
if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
|
|
|
ifnull((id.QuantityAsPerInvoice * pl.Rate),0)))
|
|
|
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) + round(ifnull(if(POType = 'REVENUE', (id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity), (id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) + round(ifnull(if(POType = 'REVENUE', (id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity), (id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) + round(ifnull(if(POType = 'REVENUE', (id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity), (id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) + round(ifnull(if(POType = 'REVENUE', (id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) - round(ifnull(if(POType = 'REVENUE', (id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), (id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total, im.file as ifile,pb.FilePath as file from T_IGR_Master im join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo left join T_PurchaseOrder_BillUpload pb on pb.IGRNO=im.IGRNO
|
|
|
|
|
|
|
|
|
|
where pm.Status != 'ST030' ";
|
|
|
|
|
(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2)
|
|
|
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2)
|
|
|
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2)
|
|
|
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2)
|
|
|
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2)
|
|
|
|
|
- round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity),
|
|
|
|
|
(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total,
|
|
|
|
|
im.file as ifile,pb.FilePath as file
|
|
|
|
|
from T_IGR_Master im
|
|
|
|
|
left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO
|
|
|
|
|
join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode
|
|
|
|
|
join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO
|
|
|
|
|
left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode
|
|
|
|
|
left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
|
|
|
|
|
left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo
|
|
|
|
|
left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo
|
|
|
|
|
left join T_PurchaseOrder_BillUpload pb on pb.IGRNO=im.IGRNO
|
|
|
|
|
where pm.Status != 'ST030' ";
|
|
|
|
|
|
|
|
|
|
if ($cname!= ''){
|
|
|
|
|
|
|
|
|
|
@ -1634,38 +1668,19 @@ $sql.="group by pono,material_name,category,supplier_name,id.IGRItemNo";
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
return $query->result();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ireport_attachment($cname,$fa,$aa,$m,$frm,$t){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** $sql="select pono,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name,
|
|
|
|
|
sum(total) as total,file,ifile
|
|
|
|
|
from igr
|
|
|
|
|
where status != 'ST030'
|
|
|
|
|
$sql="select pono,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name,
|
|
|
|
|
sum(total) as total,file,ifile
|
|
|
|
|
from igr
|
|
|
|
|
where status != 'ST030'
|
|
|
|
|
";
|
|
|
|
|
|
|
|
|
|
if ($cname!= ''){
|
|
|
|
|
|
|
|
|
|
$sql.="and supplier_name = '".$cname."'";
|
|
|
|
|
|
|
|
|
|
}**/
|
|
|
|
|
|
|
|
|
|
$sql="select pm.Status AS status,sd.SupplierID AS sid,im.file AS ifile,pb.FilePath AS file,im.IGRNO AS igrn,pm.POType AS potype,im.PONO AS pono,date_format(im.CreatedDate,'%d-%m-%Y') AS created_date,time_format(im.CreatedDate,'%l:%i %p') AS created_time,mm.MaterialName AS material_name,
|
|
|
|
|
date_format(im.MaterialRcvdDate,'%d-%m-%Y') as materialrcvddate,sd.SupplierName AS supplier_name,sum(id.QuantityAsPerInvoice) AS quantity,
|
|
|
|
|
round(((((((if((pm.POType = 'IMPORT'),sum((pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate))),if(((pm.POType = 'CAPITAL') and (pm.CapitalRange = 0)),sum((pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate))),ifnull(sum((id.QuantityAsPerInvoice * pl.Rate)),0))) + round(ifnull(if((pm.POType = 'REVENUE'),sum(((id.QuantityAsPerInvoice * rt.AfterSGST) / pl.Quantity)),sum(((id.QuantityAsPerInvoice * st.After_SGST) / pl.Quantity))),0),2)) + round(ifnull(if((pm.POType = 'REVENUE'),sum(((id.QuantityAsPerInvoice * rt.AfterCGST) / pl.Quantity)),sum(((id.QuantityAsPerInvoice * st.After_CGST) / pl.Quantity))),0),2)) + round(ifnull(if((pm.POType = 'REVENUE'),sum(((id.QuantityAsPerInvoice * rt.AfterIGST) / pl.Quantity)),sum(((id.QuantityAsPerInvoice * st.After_IGST) / pl.Quantity))),0),2)) + round(ifnull(if((pm.POType = 'REVENUE'),sum(((id.QuantityAsPerInvoice * rt.AfterFreightValue) / pl.Quantity)),sum(((id.QuantityAsPerInvoice * st.AfterFreightValue) / pl.Quantity))),0),2)) + round(ifnull(if((pm.POType = 'REVENUE'),sum(((id.QuantityAsPerInvoice * rt.AfterPackagingValue) / pl.Quantity)),0),0),2)) - round(ifnull(if((pm.POType = 'REVENUE'),sum(((id.QuantityAsPerInvoice * rt.AfterDiscount) / pl.Quantity)),sum(((id.QuantityAsPerInvoice * st.Afterdiscountval) / pl.Quantity))),0),2)),2) AS total
|
|
|
|
|
from ((((((((T_IGR_Master im join T_PurchaseOrder_LineItem pl on((pl.PONO = im.PONO))) join T_IGR_Details id on(((id.IGRNO = im.IGRNO) and (id.MaterialCode = pl.MaterialCode)))) join T_PurchaseOrder_Master pm on((pm.PONO = pl.PONO)))
|
|
|
|
|
left join T_MaterialMaster mm on((mm.MaterialCode = pl.MaterialCode)))
|
|
|
|
|
left join T_SupplierDetailsN sd on((sd.SupplierID = pm.SupplierID)))
|
|
|
|
|
left join T_Service_Tax st on((st.LineItemNo = pl.LineItemNo)))
|
|
|
|
|
left join T_Revenue_Tax rt on((rt.LineItemNo = pl.LineItemNo)))
|
|
|
|
|
left join T_PurchaseOrder_BillUpload pb on((pb.PONO = im.PONO)))
|
|
|
|
|
where (pm.Status <> 'ST030') ";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($cname!= ''){
|
|
|
|
|
|
|
|
|
|
$sql.="and sd.SupplierName = '".$cname."'";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
|
@ -1693,24 +1708,24 @@ where (pm.Status <> 'ST030') ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$sql.="group by pono,igrn";
|
|
|
|
|
// echo $m;
|
|
|
|
|
// echo $sid;
|
|
|
|
|
//echo $sql;
|
|
|
|
|
// echo $m;
|
|
|
|
|
// echo $sid;
|
|
|
|
|
//echo $sql;
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
return $query->result();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ireport_year_wise($a,$b){
|
|
|
|
|
function ireport_year_wise($a,$b){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $sql="select dat as CreatedDate,sum(quantity)as quantity,sum(value) as value, materialrcvddate
|
|
|
|
|
// from year_inward
|
|
|
|
|
// where status != 'ST030' and date(dat) >= '$a-04-01' and date(dat) <= '$b-03-31'
|
|
|
|
|
// group by month(CreatedDate)
|
|
|
|
|
// ";
|
|
|
|
|
//echo $sql;
|
|
|
|
|
$sql="select materialrcvddate,sum(quantity)as quantity,sum(value) as value,materialrcvddate
|
|
|
|
|
from year_inward
|
|
|
|
|
// $sql="select dat as CreatedDate,sum(quantity)as quantity,sum(value) as value, materialrcvddate
|
|
|
|
|
// from year_inward
|
|
|
|
|
// where status != 'ST030' and date(dat) >= '$a-04-01' and date(dat) <= '$b-03-31'
|
|
|
|
|
// group by month(CreatedDate)
|
|
|
|
|
// ";
|
|
|
|
|
//echo $sql;
|
|
|
|
|
$sql="select materialrcvddate,sum(quantity)as quantity,sum(value) as value
|
|
|
|
|
from igr
|
|
|
|
|
where status != 'ST030' and date(materialrcvddate) >= '$a-04-01' and date(materialrcvddate) <= '$b-03-31'
|
|
|
|
|
group by month(materialrcvddate)";
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
@ -1729,7 +1744,7 @@ where (pm.Status <> 'ST030') ";
|
|
|
|
|
// where status != 'ST030' and month(dat)= ? and year(dat) = ?
|
|
|
|
|
// group by material_name,supplier_name";
|
|
|
|
|
$sql="select sid,mid,supplier_name,material_name,sum(quantity)as quantity,sum(value) as total,materialrcvddate
|
|
|
|
|
from year_inward
|
|
|
|
|
from igr
|
|
|
|
|
where status != 'ST030' and month(materialrcvddate)= ? and year(materialrcvddate) = ?
|
|
|
|
|
group by material_name,supplier_name";
|
|
|
|
|
$query = $this->db->query($sql,array($month,$year));
|
|
|
|
|
@ -1737,72 +1752,71 @@ where (pm.Status <> 'ST030') ";
|
|
|
|
|
}
|
|
|
|
|
function ireport_year_wise_total($a,$b){
|
|
|
|
|
|
|
|
|
|
// $sql="select sid,mid,supplier_name,material_name,sum(quantity)as quantity,sum(value) as total
|
|
|
|
|
// from year_inward
|
|
|
|
|
// where status != 'ST030' and date(dat) >= '$a-04-01' and date(dat) <= '$b-03-31'
|
|
|
|
|
// group by material_name,supplier_name";
|
|
|
|
|
// $sql="select sid,mid,supplier_name,material_name,sum(quantity)as quantity,sum(value) as total
|
|
|
|
|
// from year_inward
|
|
|
|
|
// where status != 'ST030' and date(dat) >= '$a-04-01' and date(dat) <= '$b-03-31'
|
|
|
|
|
// group by material_name,supplier_name";
|
|
|
|
|
$sql="select sid,mid,supplier_name,material_name,sum(quantity)as quantity,sum(value) as total,materialrcvddate
|
|
|
|
|
from year_inward
|
|
|
|
|
from igr
|
|
|
|
|
where status != 'ST030' and date(materialrcvddate) >= '$a-04-01' and date(materialrcvddate) <= '$b-03-31'
|
|
|
|
|
group by material_name,supplier_name";
|
|
|
|
|
$query = $this->db->query($sql,array());
|
|
|
|
|
return $query->result();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ireport_supplier($cname,$fa,$aa,$m,$frm,$t){
|
|
|
|
|
function ireport_supplier($cname,$fa,$aa,$m,$frm,$t){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql="SELECT sd.SupplierID as sid,sd.SupplierName as supplier_name,count(im.PONO) as counts,ifnull(sum(id.QuantityAsPerInvoice),0) as quantity,round(ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0),2) as value,
|
|
|
|
|
|
|
|
|
|
case pm.POType
|
|
|
|
|
when 'IMPORT'
|
|
|
|
|
then ifnull((sum((id.QuantityAsPerInvoice * pl.Rate) * pm.ExchangeRate)
|
|
|
|
|
+ ifnull(rt.Insurance,0)
|
|
|
|
|
case pm.POType
|
|
|
|
|
when 'IMPORT'
|
|
|
|
|
then ifnull((sum((id.QuantityAsPerInvoice * pl.Rate) * pm.ExchangeRate)
|
|
|
|
|
+ ifnull(rt.Insurance,0)
|
|
|
|
|
|
|
|
|
|
),0)
|
|
|
|
|
when 'CAPITAL'
|
|
|
|
|
then sum( if(pm.CapitalRange=0,(( id.QuantityAsPerInvoice * pl.Rate) * pm.ExchangeRate),( id.QuantityAsPerInvoice * pl.Rate)
|
|
|
|
|
- st.Afterdiscountval))
|
|
|
|
|
+ ifnull(sum(st.After_SGST),0)
|
|
|
|
|
+ ifnull(sum(st.After_CGST),0)
|
|
|
|
|
+ ifnull(sum(st.After_IGST),0)
|
|
|
|
|
+ ifnull(sum(st.AfterFreightValue),0)
|
|
|
|
|
+ ifnull(rt.Insurance,0)
|
|
|
|
|
),0)
|
|
|
|
|
when 'CAPITAL'
|
|
|
|
|
then sum( if(pm.CapitalRange=0,(( id.QuantityAsPerInvoice * pl.Rate) * pm.ExchangeRate),( id.QuantityAsPerInvoice * pl.Rate)
|
|
|
|
|
- st.Afterdiscountval))
|
|
|
|
|
+ ifnull(sum(st.After_SGST),0)
|
|
|
|
|
+ ifnull(sum(st.After_CGST),0)
|
|
|
|
|
+ ifnull(sum(st.After_IGST),0)
|
|
|
|
|
+ ifnull(sum(st.AfterFreightValue),0)
|
|
|
|
|
+ ifnull(rt.Insurance,0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
when 'SERVICE'
|
|
|
|
|
then ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0)
|
|
|
|
|
+ ifnull(sum(st.After_SGST),0)
|
|
|
|
|
+ ifnull(sum(st.After_CGST),0)
|
|
|
|
|
+ ifnull(sum(st.After_IGST),0)
|
|
|
|
|
+ ifnull(sum(st.AfterFreightValue),0)
|
|
|
|
|
+ ifnull(rt.Insurance,0)
|
|
|
|
|
- ifnull(sum(st.Afterdiscountval),0)
|
|
|
|
|
when 'SERVICE'
|
|
|
|
|
then ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0)
|
|
|
|
|
+ ifnull(sum(st.After_SGST),0)
|
|
|
|
|
+ ifnull(sum(st.After_CGST),0)
|
|
|
|
|
+ ifnull(sum(st.After_IGST),0)
|
|
|
|
|
+ ifnull(sum(st.AfterFreightValue),0)
|
|
|
|
|
+ ifnull(rt.Insurance,0)
|
|
|
|
|
- ifnull(sum(st.Afterdiscountval),0)
|
|
|
|
|
|
|
|
|
|
when 'REVENUE'
|
|
|
|
|
then ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0)
|
|
|
|
|
- ifnull(sum(rt.AfterDiscount),0)
|
|
|
|
|
+ ifnull(sum(rt.AfterSGST),0)
|
|
|
|
|
+ ifnull(sum(rt.AfterCGST),0)
|
|
|
|
|
+ ifnull(sum(rt.AfterIGST),0)
|
|
|
|
|
+ ifnull(sum(rt.AfterFreightValue),0)
|
|
|
|
|
+ ifnull(sum(rt.AfterPackagingValue),0)
|
|
|
|
|
+ ifnull(rt.Insurance,0)
|
|
|
|
|
when 'REVENUE'
|
|
|
|
|
then ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0)
|
|
|
|
|
- ifnull(sum(rt.AfterDiscount),0)
|
|
|
|
|
+ ifnull(sum(rt.AfterSGST),0)
|
|
|
|
|
+ ifnull(sum(rt.AfterCGST),0)
|
|
|
|
|
+ ifnull(sum(rt.AfterIGST),0)
|
|
|
|
|
+ ifnull(sum(rt.AfterFreightValue),0)
|
|
|
|
|
+ ifnull(sum(rt.AfterPackagingValue),0)
|
|
|
|
|
+ ifnull(rt.Insurance,0)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
as total,im.MaterialRcvdDate
|
|
|
|
|
from T_IGR_Master im
|
|
|
|
|
join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO
|
|
|
|
|
join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode
|
|
|
|
|
join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO
|
|
|
|
|
left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode
|
|
|
|
|
left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
|
|
|
|
|
left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo
|
|
|
|
|
left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo
|
|
|
|
|
left join T_PurchaseOrder_BillUpload pb on pb.IGRNO=im.IGRNO
|
|
|
|
|
where pm.Status != 'ST030'";
|
|
|
|
|
end
|
|
|
|
|
as total,im.MaterialRcvdDate
|
|
|
|
|
from T_IGR_Master im
|
|
|
|
|
left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO
|
|
|
|
|
join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode
|
|
|
|
|
join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO
|
|
|
|
|
left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode
|
|
|
|
|
left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
|
|
|
|
|
left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo
|
|
|
|
|
left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo
|
|
|
|
|
where pm.Status != 'ST030'";
|
|
|
|
|
|
|
|
|
|
if ($cname!= ''){
|
|
|
|
|
if ($cname!= ''){
|
|
|
|
|
|
|
|
|
|
$sql.="and sd.SupplierName = '".$cname."'";
|
|
|
|
|
|
|
|
|
|
@ -1839,40 +1853,40 @@ where (pm.Status <> 'ST030') ";
|
|
|
|
|
return $query->result();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
function ireport_consolidate($cname,$fa,$aa){
|
|
|
|
|
function ireport_consolidate($cname,$fa,$aa){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql="select sid,mid,supplier_name,material_name,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 4, quantity, 0)) AS April,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 5, quantity, 0)) AS May,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 6, quantity, 0)) AS June,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 7, quantity, 0)) AS July,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 8, quantity, 0)) AS August,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 9, quantity, 0)) AS September,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 10, quantity, 0)) AS October,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 11, quantity, 0)) AS November,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 12, quantity, 0)) AS December,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 1, quantity, 0)) AS January,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 2, quantity, 0)) AS February,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 3, quantity, 0)) AS March,
|
|
|
|
|
sum(quantity) as qtotal,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 4, value, 0)) AS vApril,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 5, value, 0)) AS vMay,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 6, value, 0)) AS vJune,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 7, value, 0)) AS vJuly,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 8, value, 0)) AS vAugust,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 9, value, 0)) AS vSeptember,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 10, value, 0)) AS vOctober,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 11, value, 0)) AS vNovember,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 12, value, 0)) AS vDecember,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 1, value, 0)) AS vJanuary,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 2, value, 0)) AS vFebruary,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 3, value, 0)) AS vMarch,
|
|
|
|
|
sum(value) as vtotal
|
|
|
|
|
FROM year_inward
|
|
|
|
|
where status != 'ST030' ";
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 4, quantity, 0)) AS April,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 5, quantity, 0)) AS May,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 6, quantity, 0)) AS June,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 7, quantity, 0)) AS July,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 8, quantity, 0)) AS August,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 9, quantity, 0)) AS September,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 10, quantity, 0)) AS October,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 11, quantity, 0)) AS November,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 12, quantity, 0)) AS December,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 1, quantity, 0)) AS January,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 2, quantity, 0)) AS February,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 3, quantity, 0)) AS March,
|
|
|
|
|
sum(quantity) as qtotal,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 4, value, 0)) AS vApril,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 5, value, 0)) AS vMay,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 6, value, 0)) AS vJune,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 7, value, 0)) AS vJuly,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 8, value, 0)) AS vAugust,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 9, value, 0)) AS vSeptember,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 10, value, 0)) AS vOctober,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 11, value, 0)) AS vNovember,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 12, value, 0)) AS vDecember,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 1, value, 0)) AS vJanuary,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 2, value, 0)) AS vFebruary,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 3, value, 0)) AS vMarch,
|
|
|
|
|
sum(value) as vtotal
|
|
|
|
|
FROM igr
|
|
|
|
|
where status != 'ST030' ";
|
|
|
|
|
|
|
|
|
|
if ($cname!= ''){
|
|
|
|
|
if ($cname!= ''){
|
|
|
|
|
|
|
|
|
|
$sql.="and supplier_name = '".$cname."'";
|
|
|
|
|
|
|
|
|
|
@ -1893,13 +1907,13 @@ where (pm.Status <> 'ST030') ";
|
|
|
|
|
return $query->result();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
function i_consolidate_month($m=null,$sid=null,$mid=null,$fa=null,$aa=null){
|
|
|
|
|
function i_consolidate_month($m=null,$sid=null,$mid=null,$fa=null,$aa=null){
|
|
|
|
|
|
|
|
|
|
$sql="select sid,mid,supplier_name,material_name,sum(quantity) as quantity,sum(value) as total
|
|
|
|
|
from year_inward
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
monthname(dat) = '".$m."' and sid = '".$sid."' and mid = '".$mid."' ";
|
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
|
from igr
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
monthname(materialrcvddate) = '".$m."' and sid = '".$sid."' and mid = '".$mid."' ";
|
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
|
|
|
|
|
|
//$sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')";
|
|
|
|
|
$sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')";
|
|
|
|
|
@ -1913,9 +1927,9 @@ where (pm.Status <> 'ST030') ";
|
|
|
|
|
function i_consolidate_year($sid=null,$mid=null,$fa=null,$aa=null){
|
|
|
|
|
|
|
|
|
|
$sql="select sid,mid,supplier_name,material_name,sum(quantity) as quantity,sum(value) as total
|
|
|
|
|
from year_inward
|
|
|
|
|
where status != 'ST030' and sid = '".$sid."' and mid = '".$mid."' ";
|
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
|
from igr
|
|
|
|
|
where status != 'ST030' and sid = '".$sid."' and mid = '".$mid."' ";
|
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
|
|
|
|
|
|
//$sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')";
|
|
|
|
|
$sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')";
|
|
|
|
|
@ -1936,37 +1950,37 @@ where (pm.Status <> 'ST030') ";
|
|
|
|
|
$fa=substr($ab,0,-5);
|
|
|
|
|
$aa=substr($ab,5,5);
|
|
|
|
|
$sql="SELECT year.sid as sid,year.mid as mid,year.supplier_name as supplier_name,year.material_name as material_name,year.quantity as quantity,year.total as total,month.mquantity as mquantity,month.mtotal as mtotal,today.tquantity as tquantity,today.ttotal as ttotal
|
|
|
|
|
FROM (SELECT sid,mid,supplier_name,material_name,sum(Quantity) as quantity,sum(value) as total,materialrcvddate
|
|
|
|
|
FROM year_inward
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
(materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')
|
|
|
|
|
group by supplier_name,material_name
|
|
|
|
|
) as year left join
|
|
|
|
|
(SELECT sid,mid,supplier_name,material_name,sum(Quantity) as mquantity,sum(value) as mtotal
|
|
|
|
|
FROM year_inward
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
month(materialrcvddate) = month(current_date())
|
|
|
|
|
group by supplier_name,material_name
|
|
|
|
|
) as month on month.supplier_name=year.supplier_name and month.material_name=year.material_name
|
|
|
|
|
left join
|
|
|
|
|
(SELECT sid,mid,supplier_name,material_name,sum(Quantity) as tquantity,sum(value) as ttotal
|
|
|
|
|
FROM year_inward
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
date(materialrcvddate) = current_date()
|
|
|
|
|
group by supplier_name,material_name
|
|
|
|
|
) as today on today.supplier_name=month.supplier_name and today.material_name=month.material_name
|
|
|
|
|
group by supplier_name,material_name
|
|
|
|
|
";
|
|
|
|
|
FROM (SELECT sid,mid,supplier_name,material_name,sum(Quantity) as quantity,sum(value) as total,materialrcvddate
|
|
|
|
|
FROM igr
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
(materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')
|
|
|
|
|
group by supplier_name,material_name
|
|
|
|
|
) as year left join
|
|
|
|
|
(SELECT sid,mid,supplier_name,material_name,sum(Quantity) as mquantity,sum(value) as mtotal
|
|
|
|
|
FROM igr
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
month(materialrcvddate) = month(current_date())
|
|
|
|
|
group by supplier_name,material_name
|
|
|
|
|
) as month on month.supplier_name=year.supplier_name and month.material_name=year.material_name
|
|
|
|
|
left join
|
|
|
|
|
(SELECT sid,mid,supplier_name,material_name,sum(Quantity) as tquantity,sum(value) as ttotal
|
|
|
|
|
FROM igr
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
date(materialrcvddate) = current_date()
|
|
|
|
|
group by supplier_name,material_name
|
|
|
|
|
) as today on today.supplier_name=month.supplier_name and today.material_name=month.material_name
|
|
|
|
|
group by supplier_name,material_name
|
|
|
|
|
";
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
return $query->result();
|
|
|
|
|
}
|
|
|
|
|
function ireport_cum_month($sup=null,$mat=null){
|
|
|
|
|
|
|
|
|
|
$sql="SELECT sid,mid,supplier_name,material_name,sum(Quantity) as tquantity,sum(value) as ttotal
|
|
|
|
|
FROM year_inward
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
month(materialrcvddate) = month(current_date()) and sid = '".$sup."' and mid = '".$mat."'
|
|
|
|
|
group by supplier_name,material_name";
|
|
|
|
|
FROM igr
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
month(materialrcvddate) = month(current_date()) and sid = '".$sup."' and mid = '".$mat."'
|
|
|
|
|
group by supplier_name,material_name";
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
return $query->result();
|
|
|
|
|
}
|
|
|
|
|
@ -1980,22 +1994,22 @@ where (pm.Status <> 'ST030') ";
|
|
|
|
|
$fa=substr($ab,0,-5);
|
|
|
|
|
$aa=substr($ab,5,5);
|
|
|
|
|
$sql="SELECT sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal
|
|
|
|
|
FROM year_inward
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
(materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')
|
|
|
|
|
and sid = '".$sup."' and mid= '".$mat."'
|
|
|
|
|
group by supplier_name,material_name
|
|
|
|
|
";
|
|
|
|
|
FROM igr
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
(materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')
|
|
|
|
|
and sid = '".$sup."' and mid= '".$mat."'
|
|
|
|
|
group by supplier_name,material_name
|
|
|
|
|
";
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
return $query->result();
|
|
|
|
|
}
|
|
|
|
|
function ireport_cum_day($sup=null,$mat=null){
|
|
|
|
|
|
|
|
|
|
$sql="SELECT sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal
|
|
|
|
|
FROM year_inward
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
date(materialrcvddate) = current_date() and sid = '".$sup."' and mid = '".$mat."'
|
|
|
|
|
group by supplier_name,material_name";
|
|
|
|
|
FROM igr
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
date(materialrcvddate) = current_date() and sid = '".$sup."' and mid = '".$mat."'
|
|
|
|
|
group by supplier_name,material_name";
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
return $query->result();
|
|
|
|
|
}
|
|
|
|
|
@ -2009,26 +2023,26 @@ where (pm.Status <> 'ST030') ";
|
|
|
|
|
$fa=substr($ab,0,-5);
|
|
|
|
|
$aa=substr($ab,5,5);
|
|
|
|
|
$sql="SELECT year.category as category,year.quantity as quantity,year.total as total,month.mquantity as mquantity,month.mtotal as mtotal,today.tquantity as tquantity,today.ttotal as ttotal
|
|
|
|
|
FROM (SELECT category,sum(Quantity) as quantity,sum(value) as total
|
|
|
|
|
FROM year_inward
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
(materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')
|
|
|
|
|
group by category
|
|
|
|
|
) as year left join
|
|
|
|
|
(SELECT category,sum(Quantity) as mquantity,sum(value) as mtotal
|
|
|
|
|
FROM year_inward
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
month(materialrcvddate) = month(current_date())
|
|
|
|
|
group by category
|
|
|
|
|
) as month on month.category=year.category
|
|
|
|
|
left join
|
|
|
|
|
(SELECT category,sum(Quantity) as tquantity,sum(value) as ttotal
|
|
|
|
|
FROM year_inward
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
date(materialrcvddate) = current_date()
|
|
|
|
|
group by category
|
|
|
|
|
) as today on today.category=month.category
|
|
|
|
|
group by category ";
|
|
|
|
|
FROM (SELECT category,sum(Quantity) as quantity,sum(value) as total
|
|
|
|
|
FROM igr
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
(materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')
|
|
|
|
|
group by category
|
|
|
|
|
) as year left join
|
|
|
|
|
(SELECT category,sum(Quantity) as mquantity,sum(value) as mtotal
|
|
|
|
|
FROM igr
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
month(materialrcvddate) = month(current_date())
|
|
|
|
|
group by category
|
|
|
|
|
) as month on month.category=year.category
|
|
|
|
|
left join
|
|
|
|
|
(SELECT category,sum(Quantity) as tquantity,sum(value) as ttotal
|
|
|
|
|
FROM igr
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
date(materialrcvddate) = current_date()
|
|
|
|
|
group by category
|
|
|
|
|
) as today on today.category=month.category
|
|
|
|
|
group by category ";
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
return $query->result();
|
|
|
|
|
}
|
|
|
|
|
@ -2042,11 +2056,11 @@ where (pm.Status <> 'ST030') ";
|
|
|
|
|
$fa=substr($ab,0,-5);
|
|
|
|
|
$aa=substr($ab,5,5);
|
|
|
|
|
$sql="SELECT category,sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal
|
|
|
|
|
FROM year_inward
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
(materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')
|
|
|
|
|
and category = '".$cat."'
|
|
|
|
|
group by supplier_name,material_name";
|
|
|
|
|
FROM igr
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
(materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')
|
|
|
|
|
and category = '".$cat."'
|
|
|
|
|
group by supplier_name,material_name";
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
//echo $sql;
|
|
|
|
|
return $query->result();
|
|
|
|
|
@ -2054,20 +2068,20 @@ where (pm.Status <> 'ST030') ";
|
|
|
|
|
function rawi_report_cum_month($cat=null){
|
|
|
|
|
|
|
|
|
|
$sql="SELECT category,sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal
|
|
|
|
|
FROM year_inward
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
month(materialrcvddate) = month(current_date()) and category = '".$cat."'
|
|
|
|
|
group by supplier_name,material_name";
|
|
|
|
|
FROM igr
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
month(materialrcvddate) = month(current_date()) and category = '".$cat."'
|
|
|
|
|
group by supplier_name,material_name";
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
return $query->result();
|
|
|
|
|
}
|
|
|
|
|
function rawi_report_cum_day($cat=null){
|
|
|
|
|
|
|
|
|
|
$sql="SELECT category,sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal
|
|
|
|
|
FROM year_inward
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
date(materialrcvddate) = current_date() and category = '".$cat."'
|
|
|
|
|
group by supplier_name,material_name";
|
|
|
|
|
FROM igr
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
date(materialrcvddate) = current_date() and category = '".$cat."'
|
|
|
|
|
group by supplier_name,material_name";
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
//echo $sql;
|
|
|
|
|
return $query->result();
|
|
|
|
|
@ -2076,36 +2090,36 @@ where (pm.Status <> 'ST030') ";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql="select sid,mid,category,supplier_name,material_name,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 4, quantity, 0)) AS April,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 5, quantity, 0)) AS May,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 6, quantity, 0)) AS June,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 7, quantity, 0)) AS July,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 8, quantity, 0)) AS August,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 9, quantity, 0)) AS September,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 10, quantity, 0)) AS October,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 11, quantity, 0)) AS November,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 12, quantity, 0)) AS December,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 1, quantity, 0)) AS January,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 2, quantity, 0)) AS February,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 3, quantity, 0)) AS March,
|
|
|
|
|
sum(quantity) as qtotal,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 4, value, 0)) AS vApril,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 5, value, 0)) AS vMay,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 6, value, 0)) AS vJune,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 7, value, 0)) AS vJuly,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 8, value, 0)) AS vAugust,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 9, value, 0)) AS vSeptember,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 10, value, 0)) AS vOctober,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 11, value, 0)) AS vNovember,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 12, value, 0)) AS vDecember,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 1, value, 0)) AS vJanuary,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 2, value, 0)) AS vFebruary,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 3, value, 0)) AS vMarch,
|
|
|
|
|
sum(value) as vtotal
|
|
|
|
|
FROM year_inward
|
|
|
|
|
where status != 'ST030' ";
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 4, quantity, 0)) AS April,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 5, quantity, 0)) AS May,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 6, quantity, 0)) AS June,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 7, quantity, 0)) AS July,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 8, quantity, 0)) AS August,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 9, quantity, 0)) AS September,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 10, quantity, 0)) AS October,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 11, quantity, 0)) AS November,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 12, quantity, 0)) AS December,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 1, quantity, 0)) AS January,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 2, quantity, 0)) AS February,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 3, quantity, 0)) AS March,
|
|
|
|
|
sum(quantity) as qtotal,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 4, value, 0)) AS vApril,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 5, value, 0)) AS vMay,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 6, value, 0)) AS vJune,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 7, value, 0)) AS vJuly,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 8, value, 0)) AS vAugust,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 9, value, 0)) AS vSeptember,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 10, value, 0)) AS vOctober,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 11, value, 0)) AS vNovember,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 12, value, 0)) AS vDecember,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 1, value, 0)) AS vJanuary,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 2, value, 0)) AS vFebruary,
|
|
|
|
|
SUM(IF(month(materialrcvddate) = 3, value, 0)) AS vMarch,
|
|
|
|
|
sum(value) as vtotal
|
|
|
|
|
FROM igr
|
|
|
|
|
where status != 'ST030' ";
|
|
|
|
|
|
|
|
|
|
if ($cname!= ''){
|
|
|
|
|
if ($cname!= ''){
|
|
|
|
|
|
|
|
|
|
$sql.="and Category = '".$cname."'";
|
|
|
|
|
|
|
|
|
|
@ -2126,15 +2140,15 @@ where (pm.Status <> 'ST030') ";
|
|
|
|
|
return $query->result();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
function rawi_consolidate_month($m=null,$cat=null,$sup=null,$fa=null,$aa=null){
|
|
|
|
|
function rawi_consolidate_month($m=null,$cat=null,$sup=null,$fa=null,$aa=null){
|
|
|
|
|
|
|
|
|
|
$sql="select category,sid,supplier_name,mid,material_name,
|
|
|
|
|
sum(Quantity) as quantity,
|
|
|
|
|
sum(value) as total
|
|
|
|
|
FROM year_inward
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
monthname(materialrcvddate) = '".$m."' and category = '".$cat."' ";
|
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
|
sum(Quantity) as quantity,
|
|
|
|
|
sum(value) as total
|
|
|
|
|
FROM igr
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
monthname(materialrcvddate) = '".$m."' and category = '".$cat."' ";
|
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
|
|
|
|
|
|
$sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')";
|
|
|
|
|
|
|
|
|
|
@ -2147,12 +2161,12 @@ where (pm.Status <> 'ST030') ";
|
|
|
|
|
function rawi_consolidate_year($cat=null,$sup=null,$fa=null,$aa=null){
|
|
|
|
|
|
|
|
|
|
$sql="select category,sid,supplier_name,mid,material_name,
|
|
|
|
|
sum(Quantity) as quantity,
|
|
|
|
|
sum(value) as total
|
|
|
|
|
FROM year_inward
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
category = '".$cat."' ";
|
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
|
sum(Quantity) as quantity,
|
|
|
|
|
sum(value) as total
|
|
|
|
|
FROM igr
|
|
|
|
|
where status != 'ST030' and
|
|
|
|
|
category = '".$cat."' ";
|
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
|
|
|
|
|
|
$sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')";
|
|
|
|
|
|
|
|
|
|
|