diff --git a/application/logs/log-2018-01-11.php b/application/logs/log-2018-01-11.php index 8d682b7a..57e272dd 100644 --- a/application/logs/log-2018-01-11.php +++ b/application/logs/log-2018-01-11.php @@ -581,3 +581,4 @@ ERROR - 2018-01-11 07:45:20 --> Severity: Notice --> Undefined index: BankBranc ERROR - 2018-01-11 07:45:20 --> Severity: Notice --> Undefined index: BankBranchName C:\xampp\htdocs\siddharth_application\application\views\editEmployee.php 1002 ERROR - 2018-01-11 07:45:20 --> Severity: Notice --> Undefined index: BankBranchName C:\xampp\htdocs\siddharth_application\application\views\editEmployee.php 1002 ERROR - 2018-01-11 07:45:20 --> Severity: Notice --> Undefined variable: uano C:\xampp\htdocs\siddharth_application\application\views\editEmployee.php 1082 +ERROR - 2018-01-11 15:06:20 --> Query error: Table 'kasiram9_SIADEV.cost_center' doesn't exist diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php index 167ca9e5..200611fe 100755 --- a/application/models/dahsboard_model.php +++ b/application/models/dahsboard_model.php @@ -625,27 +625,19 @@ function typebal () $ab=$yearl; $fa=substr($ab,0,-5); $aa=substr($ab,5,5); - $sql="SELECT Cost_Center_Budget.BudgetYear as BudgetYear, -sum(if(Cost_Center_Budget.BudgetType='IMPORT', -(PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate,0)) as im, -sum(if(Cost_Center_Budget.BudgetType='CAPITAL', -if(CapitalRange=0,(( PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate),( PO_Line_Item.Quantity * PO_Line_Item.Rate) - st.Afterdiscountval),0)) as ca, -sum(if(Cost_Center_Budget.BudgetType='SERVICE', -PO_Line_Item.Quantity * PO_Line_Item.Rate,0)) as sr, -sum(if(Cost_Center_Budget.BudgetType='REVENUE', -(PO_Line_Item.Quantity * PO_Line_Item.Rate)-T_Rev_Tax.AfterDiscount,0)) as rv - -from T_CostCenter_Budget Cost_Center_Budget -left join T_PurchaseOrder_LineItem PO_Line_Item on Cost_Center_Budget.CostCenterCode=PO_Line_Item.CostCenterCode -left JOIN T_PurchaseOrder_Master po on po.PONO=PO_Line_Item.PONO and po.Status !='ST030' -left JOIN T_Revenue_Tax T_Rev_Tax on PO_Line_Item.LineItemNo=T_Rev_Tax.LineItemNo -JOIN T_CostCenter_Master Cost_Mast on Cost_Center_Budget.CostCenterCode=Cost_Mast.CostCenterCode -left JOIN T_Service_Tax st on st.LineItemNo = PO_Line_Item.LineItemNo -WHERE Cost_Center_Budget.BudgetType = po.POType and date(po.PODate) >= '".$fa."-04-01' and date(po.PODate) <= '".$aa."-03-31' -group by -Cost_Center_Budget.BudgetYear + $sql="SELECT BudgetYear, +sum(if(BudgetType = 'SERVICE', +Util_Amount,0)) as sr, +sum(if(BudgetType = 'REVENUE', +Util_Amount,0)) as rv, +sum(if(BudgetType = 'IMPORT', +Util_Amount,0)) as im, +sum(if(BudgetType = 'CAPITAL', +Util_Amount,0)) as ca +FROM cost_center where Status !='ST030' and date(PODate) >= '".$fa."-04-01' and date(PODate) <= '".$aa."-03-31'; "; $query = $this->db->query($sql); + //echo $sql; return $query->result(); } @@ -803,58 +795,15 @@ group by Dept_Name"; function report_ccr($fa,$aa){ - $sql="SELECT Cost_Center_Budget.CostCenterCode as Cost_Center_Code, CostCenterName as Cost_Center_Name,group_concat(distinct Dept_Details.DepartmentName) as Dept_Name,Cost_Center_Budget.BudgetType as BudgetType,Cost_Center_Budget.BudgetYear as BudgetYear, -case Cost_Center_Budget.BudgetType -when 'IMPORT' -then -sum(distinct if(Cost_Center_Budget.BudgetType='IMPORT', -(PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate,0)) -when 'CAPITAL' -then -sum(distinct if(Cost_Center_Budget.BudgetType='CAPITAL', -if(CapitalRange=0,(( PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate),( PO_Line_Item.Quantity * PO_Line_Item.Rate) - st.Afterdiscountval),0)) -when 'SERVICE' -then -sum(distinct if(Cost_Center_Budget.BudgetType='SERVICE', -PO_Line_Item.Quantity * PO_Line_Item.Rate,0)) -when 'REVENUE' -then -sum(distinct if(Cost_Center_Budget.BudgetType='REVENUE', -(PO_Line_Item.Quantity * PO_Line_Item.Rate)-T_Rev_Tax.AfterDiscount,0)) -end -as Util_Amount, -case Cost_Center_Budget.BudgetType -when 'IMPORT' -then (Cost_Center_Budget.BudgetAmount - ifnull((sum(distinct if(Cost_Center_Budget.BudgetType='IMPORT', -(PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate,0))),0)) -when 'CAPITAL' -then (Cost_Center_Budget.BudgetAmount - ifnull(sum(distinct if(Cost_Center_Budget.BudgetType='CAPITAL', -if(CapitalRange=0,(( PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate),( PO_Line_Item.Quantity * PO_Line_Item.Rate) - st.Afterdiscountval),0)),0)) -when 'SERVICE' -then (Cost_Center_Budget.BudgetAmount - ifnull((sum(distinct if(Cost_Center_Budget.BudgetType='SERVICE', -PO_Line_Item.Quantity * PO_Line_Item.Rate,0))),0)) -when 'REVENUE' -then (Cost_Center_Budget.BudgetAmount - ifnull((sum(distinct if(Cost_Center_Budget.BudgetType='REVENUE', -(PO_Line_Item.Quantity * PO_Line_Item.Rate)-T_Rev_Tax.AfterDiscount,0))),0)) -end -as Avlbl_Amt -from T_CostCenter_Budget Cost_Center_Budget -left join T_PurchaseOrder_LineItem PO_Line_Item on Cost_Center_Budget.CostCenterCode=PO_Line_Item.CostCenterCode -left JOIN T_PurchaseOrder_Master po on po.PONO=PO_Line_Item.PONO and po.Status !='ST030' -left JOIN T_Revenue_Tax T_Rev_Tax on PO_Line_Item.LineItemNo=T_Rev_Tax.LineItemNo -JOIN T_CostCenter_Master Cost_Mast on Cost_Center_Budget.CostCenterCode=Cost_Mast.CostCenterCode -JOIN T_CostCenter_Departments CostCentDept on CostCentDept.CostCenterCode=Cost_Mast.CostCenterCode -JOIN T_DepartmentDetails Dept_Details on Dept_Details.DEPCode= CostCentDept.DEPCode -left JOIN T_Service_Tax st on st.LineItemNo = PO_Line_Item.LineItemNo -WHERE Cost_Center_Budget.BudgetType = po.POType and date(po.PODate) >= '".$fa."-04-01' and date(po.PODate) <= '".$aa."-03-31' -group by -Cost_Center_Budget.CostCenterCode,Cost_Center_Budget.BudgetYear,Cost_Center_Budget.BudgetType -order by Cost_Center_Budget.CostCenterCode"; + $sql="SELECT Cost_Center_Code,Cost_Center_Name,Dept_Name,BudgetType,BudgetYear,sum(Util_Amount) as Util_Amount, +budget - sum(Util_Amount) as Avlbl_Amt +FROM cost_center +where Status !='ST030' and date(PODate) >= '".$fa."-04-01' and date(PODate) <= '".$aa."-03-31' +group by Cost_Center_Code,BudgetYear,BudgetType"; $query = $this->db->query($sql); + //echo $sql; return $query->result(); - - - + } @@ -1425,12 +1374,7 @@ group by supplier_name,material_name"; function ireport_purchase($cname,$prod,$fa,$aa,$m,$frm,$t,$cat){ - $sql="SELECT im.PONO as pono,pm.POType as potype,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, -ifnull(sum(distinct pl.Quantity),0) as quantity,mm.UOM as UOM,ifnull(sum(distinct pl.Rate),0) as rate, -round(ifnull(sum(distinct pl.Quantity * pl.Rate),0),2) as value, -if(POType = 'IMPORT' or POType = 'CAPITAL',sum(distinct pm.ExchangeRate),0) as exchange_rate, + $sql="select im.IGRNO as igrn,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(distinct id.QuantityAsPerInvoice) as quantity,pl.Rate as rate,sum(distinct id.QuantityAsPerInvoice) * pl.Rate as value,if(POType = 'IMPORT' or POType = 'CAPITAL',sum(distinct pm.ExchangeRate),0) as exchange_rate, ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) as sgst, ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) as cgst, ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) as igst, @@ -1438,18 +1382,19 @@ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afte ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) as freight, ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) as Package, round(( - if(POType = 'IMPORT',sum(distinct pm.ExchangeRate * (pl.Quantity * pl.Rate)), -if(POType = 'CAPITAL' && CapitalRange = 0,sum(distinct pm.ExchangeRate * (pl.Quantity * pl.Rate)), -ifnull(sum(distinct pl.Quantity * pl.Rate),0))) + if(POType = 'IMPORT',sum(distinct pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +if(POType = 'CAPITAL' && CapitalRange = 0,sum(distinct pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +ifnull(sum(distinct id.QuantityAsPerInvoice * pl.Rate),0))) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) - ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0)),2) as total,pb.FilePath as file - FROM T_PurchaseOrder_Master pm - join T_IGR_Master im on im.PONO = pm.PONO -left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +from T_IGR_Master im +join T_IGR_Details id on id.IGRNO = im.IGRNO +join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO +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 @@ -1505,12 +1450,7 @@ $sql.="group by pono,material_name,category,supplier_name"; function ireport_purchase_link($cname,$prod,$fa,$aa,$m,$frm,$t,$sid,$mid,$d,$cat){ - $sql="SELECT pm.PONO as pono,pm.POType as potype,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, -ifnull(sum(distinct pl.Quantity),0) as quantity,mm.UOM as UOM,ifnull(sum(distinct pl.Rate),0) as rate, -round(ifnull(sum(distinct pl.Quantity * pl.Rate),0),2) as value, -if(POType = 'IMPORT' or POType = 'CAPITAL',sum(distinct pm.ExchangeRate),0) as exchange_rate, + $sql="select im.IGRNO as igrn,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(distinct id.QuantityAsPerInvoice) as quantity,pl.Rate as rate,sum(distinct id.QuantityAsPerInvoice) * pl.Rate as value,if(POType = 'IMPORT' or POType = 'CAPITAL',sum(distinct pm.ExchangeRate),0) as exchange_rate, ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) as sgst, ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) as cgst, ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) as igst, @@ -1518,24 +1458,25 @@ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afte ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) as freight, ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) as Package, round(( - if(POType = 'IMPORT',sum(distinct pm.ExchangeRate * (pl.Quantity * pl.Rate)), -if(POType = 'CAPITAL' && CapitalRange = 0,sum(distinct pm.ExchangeRate * (pl.Quantity * pl.Rate)), -ifnull(sum(distinct pl.Quantity * pl.Rate),0))) + if(POType = 'IMPORT',sum(distinct pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +if(POType = 'CAPITAL' && CapitalRange = 0,sum(distinct pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +ifnull(sum(distinct id.QuantityAsPerInvoice * pl.Rate),0))) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) - ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0)),2) as total,pb.FilePath as file - FROM T_PurchaseOrder_Master pm - join T_IGR_Master im on im.PONO = pm.PONO -left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +from T_IGR_Master im +join T_IGR_Details id on id.IGRNO = im.IGRNO +join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO +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=pm.PONO -where pm.Status != 'ST030' "; +where pm.Status != 'ST030' "; if ($cname!= ''){ @@ -1604,7 +1545,7 @@ $sql.="group by pono,material_name,category,supplier_name"; $sql="select dat as CreatedDate,sum(quantity)as quantity,sum(value) as value -from year_wise_inward +from year_inward where status != 'ST030' and date(dat) >= '$a-04-01' and date(dat) <= '$b-03-31' group by month(CreatedDate) "; @@ -1621,7 +1562,7 @@ group by month(CreatedDate) $year = date("Y",strtotime($mont)); $sql="select sid,mid,supplier_name,material_name,sum(quantity)as quantity,sum(value) as total -from year_wise_inward +from year_inward where status != 'ST030' and month(dat)= ? and year(dat) = ? group by material_name,supplier_name"; $query = $this->db->query($sql,array($month,$year)); @@ -1630,7 +1571,7 @@ group by material_name,supplier_name"; 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_wise_inward +from year_inward where status != 'ST030' and date(dat) >= '$a-04-01' and date(dat) <= '$b-03-31' group by material_name,supplier_name"; $query = $this->db->query($sql,array()); @@ -1640,15 +1581,15 @@ group by material_name,supplier_name"; function ireport_supplier($cname,$fa,$aa,$m,$frm,$t){ - $sql="SELECT sd.SupplierID as sid,sd.SupplierName as supplier_name,count(pm.PONO) as counts,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as value, + $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(distinct(pl.Quantity * pl.Rate) * pm.ExchangeRate) +then ifnull((sum(distinct(id.QuantityAsPerInvoice * pl.Rate) * pm.ExchangeRate) ),0) when 'CAPITAL' -then sum(distinct if(pm.CapitalRange=0,(( pl.Quantity * pl.Rate) * pm.ExchangeRate),( pl.Quantity * pl.Rate) +then sum(distinct if(pm.CapitalRange=0,(( id.QuantityAsPerInvoice * pl.Rate) * pm.ExchangeRate),( id.QuantityAsPerInvoice * pl.Rate) - st.Afterdiscountval)) + ifnull(sum(distinct st.After_SGST),0) + ifnull(sum(distinct st.After_CGST),0) @@ -1657,7 +1598,7 @@ then sum(distinct if(pm.CapitalRange=0,(( pl.Quantity * pl.Rate) * pm.ExchangeR when 'SERVICE' -then ifnull(sum(distinct pl.Quantity * pl.Rate),0) +then ifnull(sum(distinct id.QuantityAsPerInvoice * pl.Rate),0) + ifnull(sum(distinct st.After_SGST),0) + ifnull(sum(distinct st.After_CGST),0) + ifnull(sum(distinct st.After_IGST),0) @@ -1665,7 +1606,7 @@ then ifnull(sum(distinct pl.Quantity * pl.Rate),0) - ifnull(sum(distinct st.Afterdiscountval),0) when 'REVENUE' -then ifnull(sum(distinct pl.Quantity * pl.Rate),0) +then ifnull(sum(distinct id.QuantityAsPerInvoice * pl.Rate),0) - ifnull(sum(distinct rt.AfterDiscount),0) + ifnull(sum(distinct rt.AfterSGST),0) + ifnull(sum(distinct rt.AfterCGST),0) @@ -1675,14 +1616,16 @@ then ifnull(sum(distinct pl.Quantity * pl.Rate),0) end as total -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +from T_IGR_Master im +join T_IGR_Details id on id.IGRNO = im.IGRNO +join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO +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' "; +left join T_PurchaseOrder_BillUpload pb on pb.PONO=pm.PONO +where pm.Status != 'ST030' "; if ($cname!= ''){ @@ -1747,7 +1690,7 @@ SUM(IF(month(dat) = 1, value, 0)) AS vJanuary, SUM(IF(month(dat) = 2, value, 0)) AS vFebruary, SUM(IF(month(dat) = 3, value, 0)) AS vMarch, sum(value) as vtotal -FROM year_wise_inward +FROM year_inward where status != 'ST030' "; if ($cname!= ''){ @@ -1772,21 +1715,13 @@ if ($cname!= ''){ } function i_consolidate_month($m=null,$sid=null,$mid=null,$fa=null,$aa=null){ - $sql="select mm.Category as category,sd.SupplierID as sid,sd.SupplierName as supplier_name,mm.MaterialCode as mid,mm.MaterialName as material_name, -sum(pl.Quantity) as quantity, -sum(pl.Quantity * pl.Rate) as total -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -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 -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' and -monthname(im.CreatedDate) = '".$m."' and sd.SupplierID = '".$sid."' and mm.MaterialCode = '".$mid."' "; + $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 != ''){ - $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + $sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; } $sql.= "group by supplier_name,material_name"; @@ -1796,20 +1731,12 @@ if ($fa and $aa != ''){ } function i_consolidate_year($sid=null,$mid=null,$fa=null,$aa=null){ - $sql="select mm.Category as category,sd.SupplierID as sid,sd.SupplierName as supplier_name,mm.MaterialCode as mid,mm.MaterialName as material_name, -sum(pl.Quantity) as quantity, -sum(pl.Quantity * pl.Rate) as total -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -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 -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' and sd.SupplierID = '".$sid."' and mm.MaterialCode = '".$mid."' "; + $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 != ''){ - $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + $sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; } $sql.= "group by supplier_name,material_name"; @@ -1827,35 +1754,23 @@ if ($fa and $aa != ''){ $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 sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as total -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -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 -(im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31') +FROM (SELECT sid,mid,supplier_name,material_name,sum(Quantity) as quantity,sum(value) as total +FROM year_inward +where status != 'ST030' and +(dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31') group by supplier_name,material_name ) as year left join -(SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,ifnull(sum(pl.Quantity),0) as mquantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as mtotal -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -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 -month(im.CreatedDate) = month(current_date()) +(SELECT sid,mid,supplier_name,material_name,sum(Quantity) as mquantity,sum(value) as mtotal +FROM year_inward +where status != 'ST030' and +month(dat) = 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 sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -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 -date(im.CreatedDate) = current_date() +(SELECT sid,mid,supplier_name,material_name,sum(Quantity) as tquantity,sum(value) as ttotal +FROM year_inward +where status != 'ST030' and +date(dat) = 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 @@ -1865,13 +1780,10 @@ group by supplier_name,material_name } function ireport_cum_month($sup=null,$mat=null){ - $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -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 month(im.CreatedDate) = month(current_date()) and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' + $sql="SELECT sid,mid,supplier_name,material_name,sum(Quantity) as tquantity,sum(value) as ttotal +FROM year_inward +where status != 'ST030' and +month(dat) = month(current_date()) and sid = '".$sup."' and mid = '".$mat."' group by supplier_name,material_name"; $query = $this->db->query($sql); return $query->result(); @@ -1885,29 +1797,22 @@ group by supplier_name,material_name"; $ab=$yearl; $fa=substr($ab,0,-5); $aa=substr($ab,5,5); - $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -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 -(im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31') - and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' -group by supplier_name,material_name"; + $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 +(dat >= '".$fa."-04-01' and dat <= '".$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 sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -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 -date(im.CreatedDate) = current_date() and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' + $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(dat) = current_date() and sid = '".$sup."' and mid = '".$mat."' group by supplier_name,material_name"; $query = $this->db->query($sql); return $query->result(); @@ -1922,35 +1827,23 @@ group by supplier_name,material_name"; $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 mm.Category as category,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as total -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -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 -(im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31') +FROM (SELECT category,sum(Quantity) as quantity,sum(value) as total +FROM year_inward +where status != 'ST030' and +(dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31') group by category ) as year left join -(SELECT mm.Category as category,ifnull(sum(pl.Quantity),0) as mquantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as mtotal -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -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 -month(im.CreatedDate) = month(current_date()) +(SELECT category,sum(Quantity) as mquantity,sum(value) as mtotal +FROM year_inward +where status != 'ST030' and +month(dat) = month(current_date()) group by category ) as month on month.category=year.category left join -(SELECT mm.Category as category,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -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 -date(im.CreatedDate) = current_date() +(SELECT category,sum(Quantity) as tquantity,sum(value) as ttotal +FROM year_inward +where status != 'ST030' and +date(dat) = current_date() group by category ) as today on today.category=month.category group by category "; @@ -1966,15 +1859,11 @@ group by category "; $ab=$yearl; $fa=substr($ab,0,-5); $aa=substr($ab,5,5); - $sql="SELECT mm.Category as category,sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -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 -(im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31') - and mm.Category = '".$cat."' + $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 +(dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31') + and category = '".$cat."' group by supplier_name,material_name"; $query = $this->db->query($sql); //echo $sql; @@ -1982,28 +1871,20 @@ group by supplier_name,material_name"; } function rawi_report_cum_month($cat=null){ - $sql="SELECT mm.Category as category,sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -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 -month(im.CreatedDate) = month(current_date()) and mm.Category = '".$cat."' + $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(dat) = 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 mm.Category as category,sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -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 -date(im.CreatedDate) = current_date() and mm.Category = '".$cat."' + $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(dat) = current_date() and category = '".$cat."' group by supplier_name,material_name"; $query = $this->db->query($sql); //echo $sql; @@ -2012,43 +1893,39 @@ group by supplier_name,material_name"; function rawi_report_consolidate($cname,$fa,$aa){ - $sql="select sd.SupplierID as sid,mm.MaterialCode as mid,mm.Category as category,sd.SupplierName as supplier_name,mm.MaterialName as material_name, -SUM(IF(month(im.CreatedDate) = 4, pl.Quantity, 0)) AS April, -SUM(IF(month(im.CreatedDate) = 5, pl.Quantity, 0)) AS May, -SUM(IF(month(im.CreatedDate) = 6, pl.Quantity, 0)) AS June, -SUM(IF(month(im.CreatedDate) = 7, pl.Quantity, 0)) AS July, -SUM(IF(month(im.CreatedDate) = 8, pl.Quantity, 0)) AS August, -SUM(IF(month(im.CreatedDate) = 9, pl.Quantity, 0)) AS September, -SUM(IF(month(im.CreatedDate) = 10, pl.Quantity, 0)) AS October, -SUM(IF(month(im.CreatedDate) = 11, pl.Quantity, 0)) AS November, -SUM(IF(month(im.CreatedDate) = 12, pl.Quantity, 0)) AS December, -SUM(IF(month(im.CreatedDate) = 1, pl.Quantity, 0)) AS January, -SUM(IF(month(im.CreatedDate) = 2, pl.Quantity, 0)) AS February, -SUM(IF(month(im.CreatedDate) = 3, pl.Quantity, 0)) AS March, -sum(pl.Quantity) as qtotal, -SUM(IF(month(im.CreatedDate) = 4, pl.Quantity * pl.Rate, 0)) AS vApril, -SUM(IF(month(im.CreatedDate) = 5, pl.Quantity * pl.Rate, 0)) AS vMay, -SUM(IF(month(im.CreatedDate) = 6, pl.Quantity * pl.Rate, 0)) AS vJune, -SUM(IF(month(im.CreatedDate) = 7, pl.Quantity * pl.Rate, 0)) AS vJuly, -SUM(IF(month(im.CreatedDate) = 8, pl.Quantity * pl.Rate, 0)) AS vAugust, -SUM(IF(month(im.CreatedDate) = 9, pl.Quantity * pl.Rate, 0)) AS vSeptember, -SUM(IF(month(im.CreatedDate) = 10, pl.Quantity * pl.Rate, 0)) AS vOctober, -SUM(IF(month(im.CreatedDate) = 11, pl.Quantity * pl.Rate, 0)) AS vNovember, -SUM(IF(month(im.CreatedDate) = 12, pl.Quantity * pl.Rate, 0)) AS vDecember, -SUM(IF(month(im.CreatedDate) = 1, pl.Quantity * pl.Rate, 0)) AS vJanuary, -SUM(IF(month(im.CreatedDate) = 2, pl.Quantity * pl.Rate, 0)) AS vFebruary, -SUM(IF(month(im.CreatedDate) = 3, pl.Quantity * pl.Rate, 0)) AS vMarch, -sum(pl.Quantity * pl.Rate) as vtotal -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -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' "; + $sql="select sid,mid,category,supplier_name,material_name, +SUM(IF(month(dat) = 4, quantity, 0)) AS April, +SUM(IF(month(dat) = 5, quantity, 0)) AS May, +SUM(IF(month(dat) = 6, quantity, 0)) AS June, +SUM(IF(month(dat) = 7, quantity, 0)) AS July, +SUM(IF(month(dat) = 8, quantity, 0)) AS August, +SUM(IF(month(dat) = 9, quantity, 0)) AS September, +SUM(IF(month(dat) = 10, quantity, 0)) AS October, +SUM(IF(month(dat) = 11, quantity, 0)) AS November, +SUM(IF(month(dat) = 12, quantity, 0)) AS December, +SUM(IF(month(dat) = 1, quantity, 0)) AS January, +SUM(IF(month(dat) = 2, quantity, 0)) AS February, +SUM(IF(month(dat) = 3, quantity, 0)) AS March, +sum(quantity) as qtotal, +SUM(IF(month(dat) = 4, value, 0)) AS vApril, +SUM(IF(month(dat) = 5, value, 0)) AS vMay, +SUM(IF(month(dat) = 6, value, 0)) AS vJune, +SUM(IF(month(dat) = 7, value, 0)) AS vJuly, +SUM(IF(month(dat) = 8, value, 0)) AS vAugust, +SUM(IF(month(dat) = 9, value, 0)) AS vSeptember, +SUM(IF(month(dat) = 10, value, 0)) AS vOctober, +SUM(IF(month(dat) = 11, value, 0)) AS vNovember, +SUM(IF(month(dat) = 12, value, 0)) AS vDecember, +SUM(IF(month(dat) = 1, value, 0)) AS vJanuary, +SUM(IF(month(dat) = 2, value, 0)) AS vFebruary, +SUM(IF(month(dat) = 3, value, 0)) AS vMarch, +sum(value) as vtotal +FROM year_inward +where status != 'ST030' "; if ($cname!= ''){ - $sql.="and mm.Category = '".$cname."'"; + $sql.="and Category = '".$cname."'"; } @@ -2056,7 +1933,7 @@ if ($cname!= ''){ if ($fa and $aa != ''){ - $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + $sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; } @@ -2068,19 +1945,15 @@ if ($cname!= ''){ } function rawi_consolidate_month($m=null,$cat=null,$sup=null,$fa=null,$aa=null){ - $sql="select mm.Category as category,sd.SupplierID as sid,sd.SupplierName as supplier_name,mm.MaterialCode as mid,mm.MaterialName as material_name, -sum(pl.Quantity) as quantity, -sum(pl.Quantity * pl.Rate) as total -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -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 -monthname(im.CreatedDate) = '".$m."' and mm.Category = '".$cat."' "; + $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(dat) = '".$m."' and category = '".$cat."' "; if ($fa and $aa != ''){ - $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + $sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; } $sql.= "group by category,supplier_name,material_name"; @@ -2090,19 +1963,15 @@ if ($fa and $aa != ''){ } function rawi_consolidate_year($cat=null,$sup=null,$fa=null,$aa=null){ - $sql="select mm.Category as category,sd.SupplierID as sid,sd.SupplierName as supplier_name,mm.MaterialCode as mid,mm.MaterialName as material_name, -sum(pl.Quantity) as quantity, -sum(pl.Quantity * pl.Rate) as total -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -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 -mm.Category = '".$cat."' "; + $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 != ''){ - $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + $sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; } $sql.= "group by category,supplier_name,material_name"; diff --git a/application/views/report_emp.php b/application/views/report_emp.php index 1872a603..53e51b94 100644 --- a/application/views/report_emp.php +++ b/application/views/report_emp.php @@ -165,7 +165,7 @@