From be50146e6a09f0d78708b6b92f0b37faa3c84616 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Thu, 28 Dec 2017 10:49:30 +0530 Subject: [PATCH] report changes --- application/config/routes.php | 1 + application/controllers/report.php | 58 ++- application/controllers/supplier.php | 11 +- application/models/dahsboard_model.php | 381 ++++++++------ application/models/requistion_model.php | 2 +- application/views/Report_POreleased.php | 11 +- application/views/Report_consolidate_raw.php | 7 +- application/views/Report_openorder.php | 2 +- application/views/Report_pending_purchase.php | 471 ++++++++++++++++++ application/views/Report_purchase_inward.php | 2 +- application/views/permission.php | 2 +- application/views/reportslink.php | 14 +- application/views/requisitionform.php | 9 +- application/views/supplierListing.php | 41 +- 14 files changed, 802 insertions(+), 210 deletions(-) create mode 100644 application/views/Report_pending_purchase.php diff --git a/application/config/routes.php b/application/config/routes.php index 2bfe408e..c23ad02f 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -234,6 +234,7 @@ $route['Report_consolidate_inward'] = "report/iconsolidate"; $route['Report_cumulative_inward'] = "report/icumulative"; $route['Report_cumulative_raw'] = "report/rawi_cumulative"; $route['Report_consolidate_category'] = "report/rawi_consolidate"; +$route['Report_pending_purchase'] = "report/pending_purchase"; // Company Information diff --git a/application/controllers/report.php b/application/controllers/report.php index 7dc2a722..affc18cb 100755 --- a/application/controllers/report.php +++ b/application/controllers/report.php @@ -1152,6 +1152,58 @@ class report extends BaseController } } + public function pending_purchase() + { + + $this->global['pageTitle'] = 'Resico : Reports'; + + if ($this->input->post('btn_submit')) { + + $cname = $this->input->post('client_name'); + + $prod = $this->input->post('item_name'); + + $ab=$this->input->post('financialyear'); + + $cat = $this->input->get('cat'); + + $fa=substr($ab,0,-5); + + $aa=substr($ab,5,5); + + $m=$this->input->post('month'); + + $frm = $this->input->post('from_date'); + + $t = $this->input->post('to_date'); + + $data['material']=$this->dahsboard_Model->material_name(); + + $data['cust']=$this->dahsboard_Model->customer_name(); + + $data['finyear']=$this->dahsboard_Model->report_finyear(); + + $data['ppurchse']=$this->dahsboard_Model->pending_purchase($cname,$prod,$fa,$aa,$m,$frm,$t); + + } + + $data['material']=$this->dahsboard_Model->material_name(); + + $data['cust']=$this->dahsboard_Model->customer_name(); + + $data['finyear']=$this->dahsboard_Model->report_finyear(); + + if($this->DEPCode == MANAGEMENT) + { + $this->loadviews("Report_pending_purchase",$this->global,$data, NULL); + } + else + { + $this->loadViews("access", $this->global, $data, NULL); + } + + } + public function cashbook() { @@ -1201,7 +1253,7 @@ class report extends BaseController $data['monthlyreport']=$this->dahsboard_Model->monthexpensereport(); - // $data['monthlyincreport']=$this->dahsboard_Model->monthincomereport(); + $data['Indiancurrency']=$this->dahsboard_Model->INRSymbol(); if($this->DEPCode == MANAGEMENT) @@ -1222,7 +1274,7 @@ class report extends BaseController $this->global['pageTitle'] = 'Cashbook - yearly expenses Reports - '; - //$data['yearlyincreport']=$this->dahsboard_Model->yearincomereport(); + $data['yearlyreport']=$this->dahsboard_Model->yearexpensereport(); $data['Indiancurrency']=$this->dahsboard_Model->INRSymbol(); @@ -1244,7 +1296,7 @@ class report extends BaseController $this->global['pageTitle'] = 'Cashbook - department - '; $data['departmentwise']=$this->dahsboard_Model->departmentwise($sid,$d); $data['Indiancurrency']=$this->dahsboard_Model->INRSymbol(); - //print_r($data['departmentwise']); + if($this->DEPCode == MANAGEMENT) { $this->loadviews("cashbookmonthlydep",$this->global,$data, NULL); diff --git a/application/controllers/supplier.php b/application/controllers/supplier.php index 22d0ae2b..ad460b9a 100644 --- a/application/controllers/supplier.php +++ b/application/controllers/supplier.php @@ -76,13 +76,12 @@ class supplier extends BaseController $this->global['pageTitle'] = 'Resico : Add New Supplier'; if($this->role == ROLE_ADMIN || $this->DEPCode == SALES || $this->DEPCode == FINANCE ||$this->DEPCode == HR) { - if($this->DEPCode != FINANCE && $this->DEPCode != HR) - { - //Load the view addsupplier.php - $this->loadViews("addsupplier", $this->global,$data, NULL); - - } + { + //Load the view addsupplier.php + $this->loadViews("addsupplier", $this->global,$data, NULL); + + } } else diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php index f7a19c5a..c8deeb3c 100755 --- a/application/models/dahsboard_model.php +++ b/application/models/dahsboard_model.php @@ -2,16 +2,7 @@ class dahsboard_Model extends CI_Model { - /*Admin Dashboard - To get User count */ - function getUserCount() - { - - $sql="select count(userId) as users FROM tbl_users where isDeleted ='0'"; - $query =$this->db->query($sql); - return $query->result(); - - } - + /* HR DASHBOART Model START*/ function totemp() @@ -22,7 +13,8 @@ class dahsboard_Model extends CI_Model return $query->result(); } - + + function totloan() { @@ -250,8 +242,8 @@ $sql= "select * FROM T_Emp_Pay_Data where EmpID = ?;"; } function reqdetail(){ - - $sql="SELECT count(Status) as TODAY_REQUESTS FROM T_Requestion_Master where date(ReqDate) = date(now());"; + $now= date('Y-m-d'); + $sql="SELECT count(Status) as TODAY_REQUESTS FROM T_Requestion_Master where date(ReqDate) = '".$now."' "; $query = $this->db->query($sql); @@ -509,6 +501,15 @@ function revenuebudgt () } function typebal () { + if (date('m') >= 4) + { + $yearl = date('Y').'-'.(date('Y')+1); + } else { + $yearl = (date('Y')-1).'-'.date('Y'); + } + $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, @@ -525,7 +526,7 @@ left JOIN T_PurchaseOrder_Master po on po.PONO=PO_Line_Item.PONO and po.Status ! 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) >= '2017-04-01' and date(po.PODate) <= '2018-03-31' +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 "; @@ -692,24 +693,36 @@ group by Dept_Name"; $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 ifnull((sum(distinct(PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate)),0) +then +sum(distinct if(Cost_Center_Budget.BudgetType='IMPORT', +(PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate,0)) when 'CAPITAL' -then ifnull(sum(distinct 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 ifnull((sum(distinct PO_Line_Item.Quantity * PO_Line_Item.Rate)),0) -when 'REVENUE' -then ifnull((sum(distinct PO_Line_Item.Quantity * PO_Line_Item.Rate) - sum(distinct T_Rev_Tax.AfterDiscount)),0) +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(PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate)),0)) +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(CapitalRange=0,(( PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate),( PO_Line_Item.Quantity * PO_Line_Item.Rate) - st.Afterdiscountval)),0)) +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 PO_Line_Item.Quantity * PO_Line_Item.Rate)),0)) +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 PO_Line_Item.Quantity * PO_Line_Item.Rate) - sum(distinct T_Rev_Tax.AfterDiscount)),0)) +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 @@ -1294,8 +1307,8 @@ group by supplier_name,material_name"; function ireport_purchase($cname,$prod,$fa,$aa,$m,$frm,$t,$cat){ - $sql="SELECT pm.PONO as pono,pm.POType as potype,date_format(pm.PODate,'%d-%m-%Y') as created_date, -TIME_FORMAT(pm.PODate,'%l:%i %p') as created_time, + $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(pl.Quantity),0) as quantity,mm.UOM as UOM,ifnull(sum(pl.Rate),0) as rate, round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as value, @@ -1317,13 +1330,14 @@ ifnull(sum(pl.Quantity * pl.Rate),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 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' and pm.PONO in (select PONO from T_IGR_Master) "; +where pm.Status != 'ST030' "; if ($cname!= ''){ @@ -1335,12 +1349,12 @@ if ($cname!= ''){ if ($fa and $aa != ''){ - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; } if ($m!= ''){ - $sql.="and monthname(pm.PODate) = '".$m."'"; + $sql.="and monthname(im.CreatedDate) = '".$m."'"; } @@ -1348,8 +1362,8 @@ if ($cname!= ''){ $fromd= date("Y-m-d",strtotime($frm)); $tod=date("Y-m-d",strtotime($t)); - $sql.="and date(pm.PODate) >= '".$fromd."' - and date(pm.PODate) <= '".$tod."'"; + $sql.="and date(im.CreatedDate) >= '".$fromd."' + and date(im.CreatedDate) <= '".$tod."'"; } if ($prod!= ''){ @@ -1373,8 +1387,8 @@ $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(pm.PODate,'%d-%m-%Y') as created_date, -TIME_FORMAT(pm.PODate,'%l:%i %p') as created_time, + $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(pl.Quantity),0) as quantity,mm.UOM as UOM,ifnull(sum(pl.Rate),0) as rate, round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as value, @@ -1396,14 +1410,14 @@ ifnull(sum(pl.Quantity * pl.Rate),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 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!= ''){ @@ -1415,12 +1429,12 @@ if ($cname!= ''){ if ($fa and $aa != ''){ - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; } if ($m!= ''){ - $sql.="and monthname(pm.PODate) = '".$m."'"; + $sql.="and monthname(im.CreatedDate) = '".$m."'"; } @@ -1428,8 +1442,8 @@ if ($cname!= ''){ $fromd= date("Y-m-d",strtotime($frm)); $tod=date("Y-m-d",strtotime($t)); - $sql.="and date(pm.PODate) >= '".$fromd."' - and date(pm.PODate) <= '".$tod."'"; + $sql.="and date(im.CreatedDate) >= '".$fromd."' + and date(im.CreatedDate) <= '".$tod."'"; } if ($prod!= ''){ @@ -1449,7 +1463,7 @@ if ($cname!= ''){ } if ($d!= ''){ - $sql.=" and date(pm.PODate) = '".$d."' "; + $sql.=" and date(im.CreatedDate) = '".$d."' "; } if ($cat!= ''){ @@ -1459,7 +1473,7 @@ if ($cname!= ''){ } -$sql.="and pm.PONO in (select PONO from T_IGR_Master) "; + $sql.="group by pono,material_name,category,supplier_name"; // echo $m; // echo $sid; @@ -1471,13 +1485,14 @@ $sql.="group by pono,material_name,category,supplier_name"; function ireport_year_wise(){ - $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,pm.PODate as created_date,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as total + $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,im.CreatedDate as created_date,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 left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and pm.PONO in (select PONO from T_IGR_Master) +where pm.Status != 'ST030' group by month(created_date)"; $query = $this->db->query($sql); return $query->result(); @@ -1492,11 +1507,12 @@ group by month(created_date)"; $sql="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 left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and pm.PONO in (select PONO from T_IGR_Master) and sd.SupplierName is not null and pm.PONO in (select PONO from T_IGR_Master) and month(pm.PODate)= ? and year(pm.PODate) = ? +where pm.Status != 'ST030' and sd.SupplierName is not null and month(im.CreatedDate)= ? and year(im.CreatedDate) = ? group by supplier_name,material_name"; $query = $this->db->query($sql,array($month,$year)); return $query->result(); @@ -1505,11 +1521,12 @@ group by supplier_name,material_name"; $sql="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 left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and pm.PONO in (select PONO from T_IGR_Master) and sd.SupplierName is not null and date(pm.PODate) >= '$a-04-01' and date(pm.PODate) <= '$b-03-31' +where pm.Status != 'ST030' and sd.SupplierName is not null and date(im.CreatedDate) >= '$a-04-01' and date(im.CreatedDate) <= '$b-03-31' group by supplier_name,material_name"; $query = $this->db->query($sql,array()); return $query->result(); @@ -1554,12 +1571,13 @@ 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 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' and pm.PONO in (select PONO from T_IGR_Master) "; +pm.Status != 'ST030' "; if ($cname!= ''){ @@ -1571,12 +1589,12 @@ if ($cname!= ''){ if ($fa and $aa != ''){ - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; } if ($m!= ''){ - $sql.="and monthname(pm.PODate) = '".$m."'"; + $sql.="and monthname(im.CreatedDate) = '".$m."'"; } @@ -1584,8 +1602,8 @@ if ($cname!= ''){ $fromd= date("Y-m-d",strtotime($frm)); $tod=date("Y-m-d",strtotime($t)); - $sql.="and date(pm.PODate) >= '".$fromd."' - and date(pm.PODate) <= '".$tod."'"; + $sql.="and date(im.CreatedDate) >= '".$fromd."' + and date(im.CreatedDate) <= '".$tod."'"; } $sql.= "group by supplier_name"; @@ -1598,39 +1616,40 @@ if ($cname!= ''){ $sql="select sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,mm.MaterialName as material_name, -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(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(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(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 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 pm.PONO in (select PONO from T_IGR_Master) "; +where pm.Status != 'ST030' "; if ($cname!= ''){ @@ -1642,7 +1661,7 @@ if ($cname!= ''){ if ($fa and $aa != ''){ - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; } @@ -1658,16 +1677,17 @@ if ($cname!= ''){ 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 pm.PONO in (select PONO from T_IGR_Master) and -monthname(pm.PODate) = '".$m."' and sd.SupplierName = '".$cname."' and mm.MaterialName = '".$prod."' "; +where pm.Status != 'ST030' and +monthname(im.CreatedDate) = '".$m."' and sd.SupplierName = '".$cname."' and mm.MaterialName = '".$prod."' "; if ($fa and $aa != ''){ - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; } $sql.= "group by supplier_name,material_name"; @@ -1681,15 +1701,16 @@ if ($fa and $aa != ''){ 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 pm.PONO in (select PONO from T_IGR_Master) and sd.SupplierName = '".$cname."' and mm.MaterialName = '".$prod."' "; +where pm.Status != 'ST030' and sd.SupplierName = '".$cname."' and mm.MaterialName = '".$prod."' "; if ($fa and $aa != ''){ - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; } $sql.= "group by supplier_name,material_name"; @@ -1702,35 +1723,38 @@ if ($fa and $aa != ''){ $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 pm.PONO in (select PONO from T_IGR_Master) and +where pm.Status != 'ST030' and case - 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 ) + when (month(im.CreatedDate) >=4) then + (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(im.CreatedDate) <= 3 ) else - (YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 ) + (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)-1 and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) <= 3 ) end 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 pm.PONO in (select PONO from T_IGR_Master) and -month(pm.PODate) = month(current_date()) +where pm.Status != 'ST030' and +month(im.CreatedDate) = 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 pm.PONO in (select PONO from T_IGR_Master) and -date(pm.PODate) = current_date() +where pm.Status != 'ST030' and +date(im.CreatedDate) = 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 @@ -1742,10 +1766,11 @@ group by supplier_name,material_name $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 pm.PONO in (select PONO from T_IGR_Master) and month(pm.PODate) = month(current_date()) and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' +where pm.Status != 'ST030' and month(im.CreatedDate) = month(current_date()) and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' group by supplier_name,material_name"; $query = $this->db->query($sql); return $query->result(); @@ -1754,15 +1779,16 @@ group by supplier_name,material_name"; $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 pm.PONO in (select PONO from T_IGR_Master) and +where pm.Status != 'ST030' and case - 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 ) + when (month(im.CreatedDate) >=4) then + (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(im.CreatedDate) <= 3 ) else - (YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 ) + (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)-1 and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) <= 3 ) end and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' group by supplier_name,material_name"; @@ -1773,11 +1799,12 @@ group by supplier_name,material_name"; $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 pm.PONO in (select PONO from T_IGR_Master) and -date(pm.PODate) = current_date() and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' +where pm.Status != 'ST030' and +date(im.CreatedDate) = current_date() and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' group by supplier_name,material_name"; $query = $this->db->query($sql); return $query->result(); @@ -1787,35 +1814,38 @@ group by supplier_name,material_name"; $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 pm.PONO in (select PONO from T_IGR_Master) and +where pm.Status != 'ST030' and case - 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 ) + when (month(im.CreatedDate) >=4) then + (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(im.CreatedDate) <= 3 ) else - (YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 ) + (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)-1 and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) <= 3 ) end 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 pm.PONO in (select PONO from T_IGR_Master) and -month(pm.PODate) = month(current_date()) +where pm.Status != 'ST030' and +month(im.CreatedDate) = 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 pm.PONO in (select PONO from T_IGR_Master) and -date(pm.PODate) = current_date() +where pm.Status != 'ST030' and +date(im.CreatedDate) = current_date() group by category ) as today on today.category=month.category group by category "; @@ -1826,15 +1856,16 @@ group by category "; $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 pm.PONO in (select PONO from T_IGR_Master) and +where pm.Status != 'ST030' and case - 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 ) + when (month(im.CreatedDate) >=4) then + (YEARim.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(im.CreatedDate) <= 3 ) else - (YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 ) + (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)-1 and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) <= 3 ) end and mm.Category = '".$cat."' group by supplier_name,material_name"; @@ -1846,11 +1877,12 @@ group by supplier_name,material_name"; $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 pm.PONO in (select PONO from T_IGR_Master) and -month(pm.PODate) = month(current_date()) and mm.Category = '".$cat."' +where pm.Status != 'ST030' and +month(im.CreatedDate) = month(current_date()) and mm.Category = '".$cat."' group by supplier_name,material_name"; $query = $this->db->query($sql); return $query->result(); @@ -1859,11 +1891,12 @@ group by supplier_name,material_name"; $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 pm.PONO in (select PONO from T_IGR_Master) and -date(pm.PODate) = current_date() and mm.Category = '".$cat."' +where pm.Status != 'ST030' and +date(im.CreatedDate) = current_date() and mm.Category = '".$cat."' group by supplier_name,material_name"; $query = $this->db->query($sql); echo $sql; @@ -1873,37 +1906,38 @@ group by supplier_name,material_name"; $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(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(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(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(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' and pm.PONO in (select PONO from T_IGR_Master) "; +where pm.Status != 'ST030' "; if ($cname!= ''){ @@ -1915,7 +1949,7 @@ if ($cname!= ''){ if ($fa and $aa != ''){ - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; } @@ -1931,14 +1965,15 @@ if ($cname!= ''){ 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 pm.PONO in (select PONO from T_IGR_Master) and -monthname(pm.PODate) = '".$m."' and mm.Category = '".$cat."' "; +where pm.Status != 'ST030' and +monthname(im.CreatedDate) = '".$m."' and mm.Category = '".$cat."' "; if ($fa and $aa != ''){ - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; } $sql.= "group by category,supplier_name,material_name"; @@ -1952,20 +1987,72 @@ if ($fa and $aa != ''){ 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 pm.PONO in (select PONO from T_IGR_Master) and +where pm.Status != 'ST030' and mm.Category = '".$cat."' "; if ($fa and $aa != ''){ - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; } $sql.= "group by category,supplier_name,material_name"; $query = $this->db->query($sql); //echo $sql; return $query->result(); + } + function pending_purchase($cname,$prod,$fa,$aa,$m,$frm,$t){ + + $sql="select po.PONO as po,date_format(po.PODate,'%d-%m-%Y') as pdate,sup.SupplierName as supplier,mm.MaterialName as material,mm.Category as category,pl.Quantity as quantity,pl.ReceivedQuantity as received, (pl.Quantity - pl.ReceivedQuantity) as pending +from T_PurchaseOrder_LineItem pl +join T_PurchaseOrder_Master po on po.PONO = pl.PONO +join T_SupplierDetailsN sup on sup.SupplierID=po.SupplierID +join T_MaterialMaster mm on mm.MaterialCode=pl.MaterialCode +where po.Status != 'ST030' and po.Status = 'ST026' + "; +if ($cname!= ''){ + + $sql.="and sup.SupplierName = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + $sql.=" and (po.PODate >= '".$fa."-04-01' and po.PODate <= '".$aa."-03-31')"; + + } + if ($m!= ''){ + + $sql.="and monthname(po.PODate) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromd= date("Y-m-d",strtotime($frm)); + $tod=date("Y-m-d",strtotime($t)); + + $sql.="and date(po.PODate) >= '".$fromd."' + and date(po.PODate) <= '".$tod."'"; + + } + if ($prod!= ''){ + + $sql.=" and mm.MaterialName = '".$prod."' "; + + } + // if ($cat!= ''){ + + // $sql.=" and mm.Category = '".$cat."' "; + + // } + $sql.="order by po.PONO"; + $query = $this->db->query($sql); + //echo $sql; + return $query->result(); } function cashbook() { @@ -2075,7 +2162,7 @@ if ($fa and $aa != ''){ when tinc.type = 'RECEIPT' then tinc.towhom end, '-') as receiptname, - date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.total,tinc.towhom,.tinc.description, ac.name FROM + date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.total,tinc.document,tinc.towhom,.tinc.description, ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code WHERE account_code = '$sid' and monthname(date)='$d' and tinc.type='$c'"; $query = $this->db->query($sql); @@ -2173,7 +2260,7 @@ function INRSymbol() when tinc.type = 'RECEIPT' then tinc.towhom end, '-') as receiptname, - tinc.total,tinc.towhom,tinc.description,tinc.type,tinc.account_code,ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code WHERE DATE(date) = CURRENT_DATE"; + tinc.total,tinc.towhom,tinc.description,tinc.document,tinc.type,tinc.account_code,ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code WHERE DATE(date) = CURRENT_DATE"; $query = $this->db->query($sql); return $query->result(); } @@ -2214,7 +2301,7 @@ function INRSymbol() when tinc.type = 'RECEIPT' then tinc.towhom end, '-') as receiptname, - tinc.total,tinc.towhom,tinc.description,tinc.type,tinc.account_code,ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code where tinc.date !=0 "; + tinc.total,tinc.towhom,tinc.description,tinc.type,tinc.document,tinc.account_code,ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code where tinc.date !=0 "; if ($fdate and $tdate != ''){ $fdate= date("Y-m-d",strtotime($fdate)); $tdate=date("Y-m-d",strtotime($tdate)); @@ -2238,7 +2325,7 @@ function INRSymbol() } function menudepartmentwise($sid='') { - $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.total,tinc.towhom,.tinc.description, ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code + $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.total,tinc.document,tinc.towhom,tinc.description, ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code WHERE account_code = '$sid'"; $query = $this->db->query($sql); //print_r($this->db->last_query()); diff --git a/application/models/requistion_model.php b/application/models/requistion_model.php index 07d8d7f6..13c8ee6c 100644 --- a/application/models/requistion_model.php +++ b/application/models/requistion_model.php @@ -176,7 +176,7 @@ ifnull(Po.Quantity,0) as POQTY,sta.StatusName { $this->db->select('MaterialCode, MaterialName,UOM'); $this->db->from('T_MaterialMaster'); - $this->db->where('MaterialType',$ReqType ); + //$this->db->where('MaterialType',$ReqType ); $query = $this->db->get(); if($NotArray == '') diff --git a/application/views/Report_POreleased.php b/application/views/Report_POreleased.php index 92b45cf5..414c4e66 100755 --- a/application/views/Report_POreleased.php +++ b/application/views/Report_POreleased.php @@ -305,7 +305,7 @@ if(!empty($rel_po)) - + @@ -492,14 +492,13 @@ $.fn.dataTable.ext.search.push( ); $(document).ready(function() { - //var table = $('#qdetails').DataTable(); // Event listener to the two range filtering inputs to redraw on input $('#min, #max').keyup( function() { table.draw(); } ); } ); -//for clear button + function Reset() { $('#min').val(''); @@ -508,11 +507,5 @@ function Reset() $('#max-date').val(''); } - - - - - - \ No newline at end of file diff --git a/application/views/Report_consolidate_raw.php b/application/views/Report_consolidate_raw.php index 9da6b689..ffea4758 100644 --- a/application/views/Report_consolidate_raw.php +++ b/application/views/Report_consolidate_raw.php @@ -36,6 +36,9 @@ +
+ +

@@ -664,7 +667,9 @@
-
+
+ + diff --git a/application/views/Report_openorder.php b/application/views/Report_openorder.php index a9cc50e2..a17f1a2e 100755 --- a/application/views/Report_openorder.php +++ b/application/views/Report_openorder.php @@ -268,7 +268,7 @@ if(!empty($open_po))
PO NOPO No PO Type PO Date Released Date
- + diff --git a/application/views/Report_pending_purchase.php b/application/views/Report_pending_purchase.php new file mode 100644 index 00000000..40dba709 --- /dev/null +++ b/application/views/Report_pending_purchase.php @@ -0,0 +1,471 @@ + + + + + + + +
+

+
+ +
+ +
+
+

Report - Pending Purchase Order +

+ input->post('client_name')){ + $cl=$this->input->post('client_name'); + echo $cl; + echo ' '.' '; + } + if($this->input->post('item_name')){ + $it=$this->input->post('item_name'); + echo $it; + echo ' '.' '; + } + + if($this->input->post('financialyear')){ + $ab=$this->input->post('financialyear'); + echo '('.$ab.')'; + echo ' '; + + } + if($this->input->post('month')){ + $m=$this->input->post('month'); + echo '('.$m.')'; + echo ' '; + } + if($this->input->post('from_date') && $this->input->post('to_date')){ + $frm = $this->input->post('from_date'); + $t = $this->input->post('to_date'); + echo $frm.'-to-'.$t; + } + + ?> +

+
+ +
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + + +
+
+ + +
+ +
+ + + + +
+ +
+

+ + +
+
+ + + + +
+
+
+
PO NOPO No PO Type Created Date Approved Date
+ + + + + + + + + + + + + + + + category; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PO NoPO DateSupplier NameMaterial NameCategoryOrdered QuantityReceived QuantityPending Quantity
+ po;?> + + pdate;?> + + + supplier;?> + + material;?> + + category;?> + quantity); + ?> + quantity);?> + received); + ?> + received);?> + pending); + ?> + pending);?> +
Total + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/application/views/Report_purchase_inward.php b/application/views/Report_purchase_inward.php index 89c92e64..f51a930d 100644 --- a/application/views/Report_purchase_inward.php +++ b/application/views/Report_purchase_inward.php @@ -240,7 +240,7 @@ if(!empty($mms)) - + diff --git a/application/views/permission.php b/application/views/permission.php index 04f8921a..78dff87b 100644 --- a/application/views/permission.php +++ b/application/views/permission.php @@ -1375,7 +1375,7 @@ function calculateTime() { min1 = Math.round(min1); if (minites< 0) { - swal('Please enter a invalid time'); + swal('Please enter a valid time'); $("#Pretime").val(0); } else{ $("#Pretime").val(hrs+':'+min1); diff --git a/application/views/reportslink.php b/application/views/reportslink.php index f1cb6ef3..f6b51c97 100644 --- a/application/views/reportslink.php +++ b/application/views/reportslink.php @@ -1,11 +1,12 @@ @@ -34,16 +35,17 @@ Purchase Supplier - Wise

Consolidate Report

Cumulative Report

+ Purchase Order Pending

-

  Material Master

+

  Material Master

Material Master - supplier wise

Material Master - Item wise

Material Master - Receipt Value

-

  Inward

+

  Inward

Purchase

Year Wise

Purchase Supplier - Wise

diff --git a/application/views/requisitionform.php b/application/views/requisitionform.php index be0e7be7..e57a4b28 100644 --- a/application/views/requisitionform.php +++ b/application/views/requisitionform.php @@ -109,7 +109,7 @@ if(!empty($Emp)) $Costs[$SID->CostCenterCode] = $SID->CostCenterCode .'-'. $SID->CostCenterName ; endforeach; - + } echo form_dropdown('CostCenter', $Costs,set_value('CostCenter'),'id="CostCenter"' ,'class = "form-control"'); @@ -362,8 +362,8 @@ if(!empty($Emp))   Save - - + +

@@ -373,7 +373,8 @@ if(!empty($Emp)) -
PO NOPO No Date Time Material Name