diff --git a/application/config/routes.php b/application/config/routes.php index 4d0c1a1c..c0e5d593 100755 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -229,6 +229,8 @@ $route['Report_year_wise_inward'] = "report/iyear_wise"; $route['Report_supplier_inward'] = "report/ipurchase_supplier"; $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['cashbookreport']="report/cashbook"; $route['cashbookmonthlyexpenses']="report/monthexpenses"; $route['cashbookyearlyexpenses']="report/yearexpenses"; diff --git a/application/controllers/report.php b/application/controllers/report.php index 383b52f3..38a24c9c 100755 --- a/application/controllers/report.php +++ b/application/controllers/report.php @@ -503,6 +503,7 @@ class report extends BaseController $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'); @@ -512,7 +513,7 @@ class report extends BaseController $data['material']=$this->dahsboard_Model->material_name(); $data['cust']=$this->dahsboard_Model->customer_name(); $data['finyear']=$this->dahsboard_Model->report_finyear(); - $data['purchase']=$this->dahsboard_Model->ireport_purchase($cname,$prod,$fa,$aa,$m,$frm,$t); + $data['purchase']=$this->dahsboard_Model->ireport_purchase($cname,$prod,$fa,$aa,$m,$frm,$t,$cat); if($this->DEPCode == MANAGEMENT) { @@ -552,6 +553,7 @@ class report extends BaseController $this->global['pageTitle'] = 'Siddharth : Reports'; //$this->input->post('btn_submit'); $cname = $this->input->get('cname'); + $cat = $this->input->get('cat'); $prod = $this->input->get('prod'); $ab=$this->input->get('ab'); $fa=substr($ab,0,-5); @@ -567,7 +569,7 @@ class report extends BaseController $data['material']=$this->dahsboard_Model->material_name(); $data['cust']=$this->dahsboard_Model->customer_name(); $data['finyear']=$this->dahsboard_Model->report_finyear(); - $data['purchase']=$this->dahsboard_Model->ireport_purchase_link($cname,$prod,$fa,$aa,$m,$frm,$t,$sid,$mid,$d); + $data['purchase']=$this->dahsboard_Model->ireport_purchase_link($cname,$prod,$fa,$aa,$m,$frm,$t,$sid,$mid,$d,$cat); } $this->loadviews("Report_purchase_inward",$this->global,$data, NULL); @@ -751,6 +753,144 @@ class report extends BaseController $data['cum_day']=$this->dahsboard_Model->ireport_cum_day($sup,$mat); $this->loadviews("Report_cumulative_day_inward",$this->global,$data, NULL); + } + public function rawi_cumulative() + { + + $this->global['pageTitle'] = 'Siddharth : Reports'; + + //print_r($prod); + + $data['cum']=$this->dahsboard_Model->rawi_report_cumulative(); + + if($this->DEPCode == MANAGEMENT) + { + $this->loadviews("Report_cumulative_raw",$this->global,$data, NULL); + } + + else + { + $this->loadViews("access", $this->global, $data, NULL); + } + + + } + public function rawi_cum_year() + { + + $this->global['pageTitle'] = 'Siddharth : Reports'; + $mat=$this->input->get('mid'); + $cat=$this->input->get('cat'); + //print_r($sup); + + $data['cum_year']=$this->dahsboard_Model->rawi_report_cum_year($mat,$cat); + $this->loadviews("Report_cumulative_year_raw",$this->global,$data, NULL); + + } + public function rawi_cum_month() + { + + $this->global['pageTitle'] = 'Siddharth : Reports'; + $mat=$this->input->get('mid'); + $cat=$this->input->get('cat'); + + //print_r($prod); + + $data['cum_month']=$this->dahsboard_Model->rawi_report_cum_month($mat,$cat); + $this->loadviews("Report_cumulative_month_raw",$this->global,$data, NULL); + + } + public function rawi_cum_day() + { + + $this->global['pageTitle'] = 'Siddharth : Reports'; + $mat=$this->input->get('mid'); + $cat=$this->input->get('cat'); + //print_r($prod); + + $data['cum_day']=$this->dahsboard_Model->rawi_report_cum_day($mat,$cat); + $this->loadviews("Report_cumulative_day_raw",$this->global,$data, NULL); + + } + public function rawi_consolidate() + { + + $this->global['pageTitle'] = 'Siddharth : Reports'; + //$this->input->post('btn_submit'); + $cname = $this->input->post('client_name'); + $ab=$this->input->post('financialyear'); + $fa=substr($ab,0,-5); + $aa=substr($ab,5,5); + //print_r($prod); + $data['material']=$this->dahsboard_Model->material_name(); + $data['cust']=$this->dahsboard_Model->customer_name(); + $data['finyear']=$this->dahsboard_Model->report_finyear(); + $data['spurchse']=$this->dahsboard_Model->rawi_report_consolidate($cname,$fa,$aa); + + if($this->DEPCode == MANAGEMENT) + { + $this->loadviews("Report_consolidate_raw",$this->global,$data, NULL); + } + else + { + $this->loadViews("access", $this->global, $data, NULL); + } + + } + public function rawi_consolidate_month() + { + + $this->global['pageTitle'] = 'Siddharth : Reports'; + //$this->input->post('btn_submit'); + $cat = $this->input->get('cat'); + $sup = $this->input->get('sup'); + $mat = $this->input->get('mid'); + $m = $this->input->get('m'); + $ab=$this->input->get('ab'); + $fa=substr($ab,0,-5); + $aa=substr($ab,5,5); + //print_r($prod); + $data['material']=$this->dahsboard_Model->material_name(); + $data['cust']=$this->dahsboard_Model->customer_name(); + $data['finyear']=$this->dahsboard_Model->report_finyear(); + $data['spurchse']=$this->dahsboard_Model->rawi_consolidate_month($m,$cat,$sup,$mat,$fa,$aa); + // print_r( $data['spurchse']); + if($this->DEPCode == MANAGEMENT) + { + $this->loadviews("Report_consolidate_month",$this->global,$data, NULL); + } + else + { + $this->loadViews("access", $this->global, $data, NULL); + } + + } + public function rawi_consolidate_year() + { + + $this->global['pageTitle'] = 'Siddharth : Reports'; + //$this->input->post('btn_submit'); + $cat = $this->input->get('cat'); + $sup = $this->input->get('sup'); + $mat = $this->input->get('mid'); + $ab=$this->input->get('ab'); + $fa=substr($ab,0,-5); + $aa=substr($ab,5,5); + //print_r($prod); + $data['material']=$this->dahsboard_Model->material_name(); + $data['cust']=$this->dahsboard_Model->customer_name(); + $data['finyear']=$this->dahsboard_Model->report_finyear(); + $data['spurchse']=$this->dahsboard_Model->rawi_consolidate_year($cat,$sup,$mat,$fa,$aa); + // print_r( $data['spurchse']); + if($this->DEPCode == MANAGEMENT) + { + $this->loadviews("Report_consolidate_year",$this->global,$data, NULL); + } + else + { + $this->loadViews("access", $this->global, $data, NULL); + } + } public function cashbook() { diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php index 21e5aae1..12744c2e 100755 --- a/application/models/dahsboard_model.php +++ b/application/models/dahsboard_model.php @@ -639,7 +639,7 @@ 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' "; +pm.Status != 'ST030' and pm.Status != 'ST056' "; if ($cname!= ''){ @@ -713,7 +713,7 @@ 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' "; +pm.Status != 'ST030' and pm.Status != 'ST056' "; if ($cname!= ''){ @@ -794,7 +794,7 @@ left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' +where pm.Status != 'ST030' and pm.Status != 'ST056' group by month(created_date)"; $query = $this->db->query($sql); return $query->result(); @@ -822,7 +822,7 @@ left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and sd.SupplierName is not null and month(pm.CreatedDate)= ? and year(pm.CreatedDate) = ? +where pm.Status != 'ST030' and pm.Status != 'ST056' and sd.SupplierName is not null and month(pm.CreatedDate)= ? and year(pm.CreatedDate) = ? group by supplier_name,material_name"; $query = $this->db->query($sql,array($month,$year)); return $query->result(); @@ -835,7 +835,7 @@ left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and sd.SupplierName is not null and date(pm.CreatedDate) >= '$a-04-01' and date(pm.CreatedDate) <= '$b-03-31' +where pm.Status != 'ST030' and pm.Status != 'ST056' and sd.SupplierName is not null and date(pm.CreatedDate) >= '$a-04-01' and date(pm.CreatedDate) <= '$b-03-31' group by supplier_name,material_name"; $query = $this->db->query($sql,array()); return $query->result(); @@ -885,7 +885,7 @@ 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' "; +pm.Status != 'ST030' and pm.Status != 'ST056' "; if ($cname!= ''){ @@ -954,7 +954,7 @@ FROM T_PurchaseOrder_Master pm 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' "; +where pm.Status != 'ST030' and pm.Status != 'ST056' "; if ($cname!= ''){ @@ -984,7 +984,7 @@ FROM T_PurchaseOrder_Master pm 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 sd.SupplierName is not null and +where pm.Status != 'ST030' and pm.Status != 'ST056' and sd.SupplierName is not null and case when (month(pm.CreatedDate) >=4) then (YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(pm.CreatedDate) >= 4 ) or ( YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.CreatedDate) <= 3 ) @@ -998,7 +998,7 @@ FROM T_PurchaseOrder_Master pm 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 sd.SupplierName is not null and +where pm.Status != 'ST030' and pm.Status != 'ST056' and sd.SupplierName is not null and month(pm.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 @@ -1008,7 +1008,7 @@ FROM T_PurchaseOrder_Master pm 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 sd.SupplierName is not null and +where pm.Status != 'ST030' and pm.Status != 'ST056' and sd.SupplierName is not null and date(pm.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 @@ -1024,7 +1024,7 @@ FROM T_PurchaseOrder_Master pm 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 sd.SupplierName is not null and month(pm.CreatedDate) = month(current_date()) and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' +where pm.Status != 'ST030' and pm.Status != 'ST056' and sd.SupplierName is not null and month(pm.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(); @@ -1036,7 +1036,7 @@ FROM T_PurchaseOrder_Master pm 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 sd.SupplierName is not null and +where pm.Status != 'ST030' and pm.Status != 'ST056' and sd.SupplierName is not null and case when (month(pm.CreatedDate) >=4) then (YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(pm.CreatedDate) >= 4 ) or ( YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.CreatedDate) <= 3 ) @@ -1055,18 +1055,18 @@ FROM T_PurchaseOrder_Master pm 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 sd.SupplierName is not null and +where pm.Status != 'ST030' and pm.Status != 'ST056' and sd.SupplierName is not null and date(pm.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(); } - function ireport_purchase($cname,$prod,$fa,$aa,$m,$frm,$t){ + function ireport_purchase($cname,$prod,$fa,$aa,$m,$frm,$t,$cat){ $sql="SELECT pm.PONO as pono,date_format(pm.CreatedDate,'%d-%m-%Y') as created_date, TIME_FORMAT(pm.CreatedDate,'%l:%i %p') as created_time, -mm.MaterialName as material_name,sd.SupplierName as supplier_name, +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, if(POType = 'IMPORT' or POType = 'CAPITAL',sum(pm.ExchangeRate),0) as exchange_rate, @@ -1092,8 +1092,7 @@ 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' and pm.Status = 'ST056' "; +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) "; if ($cname!= ''){ @@ -1127,20 +1126,25 @@ if ($cname!= ''){ $sql.=" and mm.MaterialName = '".$prod."' "; } + if ($cat!= ''){ + + $sql.=" and mm.Category = '".$cat."' "; + + } -$sql.="group by pono,material_name,supplier_name"; +$sql.="group by pono,material_name,category,supplier_name"; //echo $sql; $query = $this->db->query($sql); return $query->result(); } - function ireport_purchase_link($cname,$prod,$fa,$aa,$m,$frm,$t,$sid,$mid,$d){ + function ireport_purchase_link($cname,$prod,$fa,$aa,$m,$frm,$t,$sid,$mid,$d,$cat){ $sql="SELECT pm.PONO as pono,date_format(pm.CreatedDate,'%d-%m-%Y') as created_date, TIME_FORMAT(pm.CreatedDate,'%l:%i %p') as created_time, -mm.MaterialName as material_name,sd.SupplierName as supplier_name, +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, if(POType = 'IMPORT' or POType = 'CAPITAL',sum(pm.ExchangeRate),0) as exchange_rate, @@ -1167,7 +1171,7 @@ 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.Status = 'ST056' "; +pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) "; if ($cname!= ''){ @@ -1216,11 +1220,16 @@ if ($cname!= ''){ $sql.=" and date(pm.CreatedDate) = '".$d."' "; } + if ($cat!= ''){ + + $sql.=" and mm.Category = '".$cat."' "; + + } -$sql.="group by pono,material_name,supplier_name"; -//echo $sql; +$sql.="group by pono,material_name,category,supplier_name"; +//ho $sql; $query = $this->db->query($sql); return $query->result(); } @@ -1234,7 +1243,7 @@ left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and pm.Status = 'ST056' +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) group by month(created_date)"; $query = $this->db->query($sql); return $query->result(); @@ -1253,7 +1262,7 @@ left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and pm.Status = 'ST056' and sd.SupplierName is not null and month(pm.CreatedDate)= ? and year(pm.CreatedDate) = ? +where pm.Status != 'ST030' and pm.Status = 'ST056' 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.CreatedDate)= ? and year(pm.CreatedDate) = ? group by supplier_name,material_name"; $query = $this->db->query($sql,array($month,$year)); return $query->result(); @@ -1266,7 +1275,7 @@ left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and pm.Status = 'ST056' and sd.SupplierName is not null and date(pm.CreatedDate) >= '$a-04-01' and date(pm.CreatedDate) <= '$b-03-31' +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and sd.SupplierName is not null and date(pm.CreatedDate) >= '$a-04-01' and date(pm.CreatedDate) <= '$b-03-31' group by supplier_name,material_name"; $query = $this->db->query($sql,array()); return $query->result(); @@ -1316,7 +1325,7 @@ 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.Status = 'ST056' "; +pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) "; if ($cname!= ''){ @@ -1385,7 +1394,7 @@ FROM T_PurchaseOrder_Master pm join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and pm.Status = 'ST056' "; +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) "; if ($cname!= ''){ @@ -1415,7 +1424,7 @@ FROM T_PurchaseOrder_Master pm left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and pm.Status = 'ST056' and sd.SupplierName is not null and +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and case when (month(pm.CreatedDate) >=4) then (YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(pm.CreatedDate) >= 4 ) or ( YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.CreatedDate) <= 3 ) @@ -1429,7 +1438,7 @@ FROM T_PurchaseOrder_Master pm left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and pm.Status = 'ST056' and sd.SupplierName is not null and +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and month(pm.CreatedDate) = month(current_date()) group by supplier_name,material_name ) as month on month.supplier_name=year.supplier_name and month.material_name=year.material_name @@ -1439,7 +1448,7 @@ FROM T_PurchaseOrder_Master pm left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and pm.Status = 'ST056' and sd.SupplierName is not null and +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and date(pm.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 @@ -1455,7 +1464,7 @@ FROM T_PurchaseOrder_Master pm left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and pm.Status = 'ST056' and sd.SupplierName is not null and month(pm.CreatedDate) = month(current_date()) and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and month(pm.CreatedDate) = month(current_date()) and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' group by supplier_name,material_name"; $query = $this->db->query($sql); return $query->result(); @@ -1467,7 +1476,7 @@ FROM T_PurchaseOrder_Master pm left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and pm.Status = 'ST056' and sd.SupplierName is not null and +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and case when (month(pm.CreatedDate) >=4) then (YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(pm.CreatedDate) >= 4 ) or ( YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.CreatedDate) <= 3 ) @@ -1486,11 +1495,195 @@ FROM T_PurchaseOrder_Master pm left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and pm.Status = 'ST056' and sd.SupplierName is not null and +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and date(pm.CreatedDate) = current_date() and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' group by supplier_name,material_name"; $query = $this->db->query($sql); return $query->result(); + } + function rawi_report_cumulative(){ + + $sql="SELECT year.mid as mid,year.category as category,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 mm.Category as category,mm.MaterialCode as mid,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 +left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode +left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and +case + when (month(pm.CreatedDate) >=4) then + (YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(pm.CreatedDate) >= 4 ) or ( YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.CreatedDate) <= 3 ) + else + (YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.CreatedDate) >= 4 ) or ( YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(pm.CreatedDate) <= 3 ) + end +group by category,material_name +) as year left join +(SELECT mm.Category as category,mm.MaterialCode as mid,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 +left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode +left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and +month(pm.CreatedDate) = month(current_date()) +group by category,material_name +) as month on month.material_name=year.material_name and month.category=year.category +left join +(SELECT mm.Category as category,mm.MaterialCode as mid,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 +left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode +left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and +date(pm.CreatedDate) = current_date() +group by category,material_name +) as today on today.material_name=month.material_name and today.category=month.category +group by category,material_name "; + $query = $this->db->query($sql); + return $query->result(); + } + function rawi_report_cum_year($mat=null,$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 +left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode +left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and +case + when (month(pm.CreatedDate) >=4) then + (YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(pm.CreatedDate) >= 4 ) or ( YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.CreatedDate) <= 3 ) + else + (YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.CreatedDate) >= 4 ) or ( YEAR(pm.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(pm.CreatedDate) <= 3 ) + end + and mm.MaterialCode = '".$mat."' and mm.Category = '".$cat."' +group by supplier_name,material_name"; + $query = $this->db->query($sql); + //echo $sql; + return $query->result(); + } + function rawi_report_cum_month($mat=null,$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 +left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode +left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and +month(pm.CreatedDate) = month(current_date()) and mm.MaterialCode = '".$mat."' and mm.Category = '".$cat."' +group by supplier_name,material_name"; + $query = $this->db->query($sql); + return $query->result(); + } + function rawi_report_cum_day($mat=null,$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 +left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode +left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and +date(pm.CreatedDate) = current_date() and mm.MaterialCode = '".$mat."'and mm.Category = '".$cat."' +group by supplier_name,material_name"; + $query = $this->db->query($sql); + return $query->result(); + } + function rawi_report_consolidate($cname,$fa,$aa){ + + + $sql="select mm.Category as category,mm.MaterialCode as mid,mm.MaterialName as material_name, +SUM(IF(month(pm.CreatedDate) = 4, pl.Quantity, 0)) AS April, +SUM(IF(month(pm.CreatedDate) = 5, pl.Quantity, 0)) AS May, +SUM(IF(month(pm.CreatedDate) = 6, pl.Quantity, 0)) AS June, +SUM(IF(month(pm.CreatedDate) = 7, pl.Quantity, 0)) AS July, +SUM(IF(month(pm.CreatedDate) = 8, pl.Quantity, 0)) AS August, +SUM(IF(month(pm.CreatedDate) = 9, pl.Quantity, 0)) AS September, +SUM(IF(month(pm.CreatedDate) = 10, pl.Quantity, 0)) AS October, +SUM(IF(month(pm.CreatedDate) = 11, pl.Quantity, 0)) AS November, +SUM(IF(month(pm.CreatedDate) = 12, pl.Quantity, 0)) AS December, +SUM(IF(month(pm.CreatedDate) = 1, pl.Quantity, 0)) AS January, +SUM(IF(month(pm.CreatedDate) = 2, pl.Quantity, 0)) AS February, +SUM(IF(month(pm.CreatedDate) = 3, pl.Quantity, 0)) AS March, +sum(pl.Quantity) as qtotal, +SUM(IF(month(pm.CreatedDate) = 4, pl.Quantity * pl.Rate, 0)) AS vApril, +SUM(IF(month(pm.CreatedDate) = 5, pl.Quantity * pl.Rate, 0)) AS vMay, +SUM(IF(month(pm.CreatedDate) = 6, pl.Quantity * pl.Rate, 0)) AS vJune, +SUM(IF(month(pm.CreatedDate) = 7, pl.Quantity * pl.Rate, 0)) AS vJuly, +SUM(IF(month(pm.CreatedDate) = 8, pl.Quantity * pl.Rate, 0)) AS vAugust, +SUM(IF(month(pm.CreatedDate) = 9, pl.Quantity * pl.Rate, 0)) AS vSeptember, +SUM(IF(month(pm.CreatedDate) = 10, pl.Quantity * pl.Rate, 0)) AS vOctober, +SUM(IF(month(pm.CreatedDate) = 11, pl.Quantity * pl.Rate, 0)) AS vNovember, +SUM(IF(month(pm.CreatedDate) = 12, pl.Quantity * pl.Rate, 0)) AS vDecember, +SUM(IF(month(pm.CreatedDate) = 1, pl.Quantity * pl.Rate, 0)) AS vJanuary, +SUM(IF(month(pm.CreatedDate) = 2, pl.Quantity * pl.Rate, 0)) AS vFebruary, +SUM(IF(month(pm.CreatedDate) = 3, pl.Quantity * pl.Rate, 0)) AS vMarch, +sum(pl.Quantity * pl.Rate) as vtotal +FROM T_PurchaseOrder_Master pm +join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode +join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) "; + +if ($cname!= ''){ + + $sql.="and mm.MaterialName = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + $sql.=" and (pm.CreatedDate >= '".$fa."-04-01' and pm.CreatedDate <= '".$aa."-03-31')"; + + } + + $sql.= "group by category,material_name"; + //echo $sql; + $query = $this->db->query($sql); + return $query->result(); + + } + function rawi_consolidate_month($m=null,$cat=null,$sup=null,$mat=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_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode +join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and +monthname(pm.CreatedDate) = '".$m."' and mm.Category = '".$cat."' and mm.MaterialCode = '".$mat."' "; +if ($fa and $aa != ''){ + + $sql.=" and (pm.CreatedDate >= '".$fa."-04-01' and pm.CreatedDate <= '".$aa."-03-31')"; + + } + $sql.= "group by category,supplier_name,material_name"; + $query = $this->db->query($sql); + //echo $sql; + return $query->result(); + } + function rawi_consolidate_year($cat=null,$sup=null,$mat=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_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode +join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID +where pm.Status != 'ST030' and pm.Status = 'ST056' and pm.PONO in (select PONO from T_IGR_Master) and +mm.Category = '".$cat."' and mm.MaterialCode = '".$mat."' "; +if ($fa and $aa != ''){ + + $sql.=" and (pm.CreatedDate >= '".$fa."-04-01' and pm.CreatedDate <= '".$aa."-03-31')"; + + } + $sql.= "group by category,supplier_name,material_name"; + $query = $this->db->query($sql); + //echo $sql; + return $query->result(); } function cashbook() { diff --git a/application/views/Report_consolidate_inward.php b/application/views/Report_consolidate_inward.php index 8e48d02a..7fe457af 100644 --- a/application/views/Report_consolidate_inward.php +++ b/application/views/Report_consolidate_inward.php @@ -157,7 +157,7 @@ foreach ($spurchse as $result) { ?>
Report - Consolidate Month(input->get('m'); + echo $m; + ?>)
| Category | +Supplier Name | +Material Name | ++ | |
|---|---|---|---|---|
| Quantity | +Value () | + + +|||
| + category;?> + | +supplier_name;?> + | +material_name;?> | +quantity); + echo round($rel->quantity);?> | +total,2,'.',''); + echo number_format($rel->total,2,'.','');?> | + + +
| Total | + ++ + + | ++ + + | ++ + + + | ++ + + + | + + + +
Report - Consolidate (Category-Wise)
| Category | +Material Name | +Apr | +May | +Jun | +Jul | +Aug | +Sep | +Oct | +Nov | +Dec | +Jan | +Feb | +Mar | +Total | + +
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| + category;?> + | +material_name)) { echo $result->material_name ; } else {echo "-";} + ?> | ++ April); + ?> + April);?> + | ++ May); + ?> + May);?> + | ++ June); + ?> + June);?> + | ++ July); + ?> + July);?> + | ++ August); + ?> + August);?> + | ++ September; + ?> + September);?> + | ++ October); + ?> + October);?> + | ++ November); + ?> + November);?> + | ++ December); + ?> + December);?> + | ++ January); + ?> + January);?> + | ++ February); + ?> + February);?> + | ++ March); + ?> + March);?> + | ++ qtotal); + ?> + qtotal);?> + | +
| Total | ++ | ++ | ++ + | ++ + | ++ + | ++ + | ++ + + | ++ + + | ++ + + + | ++ + + + | ++ + + + | ++ + + + | ++ + + | ++ + + | + + + +
Report - Consolidate Month(input->get('ab'); + echo $m; + ?>)
| Category | +Supplier Name | +Material Name | ++ | |
|---|---|---|---|---|
| Quantity | +Value () | + + +|||
| + category;?> + | +supplier_name;?> + | +material_name;?> | +quantity); + echo round($rel->quantity);?> | +total,2,'.',''); + echo number_format($rel->total,2,'.','');?> | + + +
| Total | + ++ + + | ++ + + | ++ + + + | ++ + + + | + + + +
Report - Cumulative Today
Report - Cumulative Today - Inward
Report - Cumulative Today (Category-Wise)
| Category | +Supplier Name | +Material Name | ++ | |
|---|---|---|---|---|
| Quantity | +Value () | + + +|||
| category;?> | ++ supplier_name;?> + | +material_name;?> | +tquantity); + echo round($rel->tquantity);?> | +ttotal,2,'.',''); + echo number_format($rel->ttotal,2,'.','');?> | + + +
| Total | + ++ + + | ++ + + + | ++ + + + | ++ + + + | + + + +
Report - Cumulative
Report - Cumulative - Inward
Report - Cumulative Month
Report - Cumulative Month - Inward
Report - Cumulative Month (Category-Wise)
| Category | +Supplier Name | +Material Name | ++ | |
|---|---|---|---|---|
| Quantity | +Value () | + + +|||
| category;?> | ++ supplier_name;?> + | +material_name;?> | +tquantity); + echo round($rel->tquantity);?> | +ttotal,2,'.',''); + echo number_format($rel->ttotal,2,'.','');?> | + + +
| Total | + ++ + + | ++ + + + | + ++ + + + | ++ + + + | + + + +
Report - Cumulative (Category-Wise)
| Category | +Material Name | ++ | + | + | |||
|---|---|---|---|---|---|---|---|
| Quantity | +Value () | +Quantity | +Value () | +Quantity | +Value () | + +||
| + category;?> + | +material_name;?> | ++ tquantity); + ?> + tquantity);?> + | +ttotal,2,'.',''); + ?> + ttotal,2,'.','');?> + | +mquantity); + ?> + mquantity);?> + | +mtotal,2,'.',''); + ?> + mtotal,2,'.','');?> + | +quantity); + ?> + quantity);?> + | +total,2,'.',''); + ?> + total,2,'.','');?> + | + + + +
| Total | + ++ + + + | + ++ + + + | ++ + + + | ++ + + + | ++ + + + | ++ + + + | ++ + + + | + + +
Report - Cumulative Year
Report - Cumulative Year - Inward
Report - Cumulative Year (Category-Wise)
| Category | +Supplier Name | +Material Name | ++ | |
|---|---|---|---|---|
| Quantity | +Value ( ) | + + +|||
| category;?> | ++ supplier_name;?> + | +material_name;?> | +tquantity); + echo round($rel->tquantity);?> | +ttotal,2,'.',''); + echo number_format($rel->ttotal,2,'.','');?> | + + +
| Total | + ++ + + | ++ + + + | ++ + + + | ++ + + + | + + + +