diff --git a/application/config/routes.php b/application/config/routes.php index 3a232b29..04035ce4 100755 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -219,6 +219,9 @@ $route['Report_costcenter'] = "report/ccr"; $route['Report_Material_Supplier'] = "report/MM_Supplier"; $route['Report_Material_Item'] = "report/MM_Item"; $route['Report_Material_ReceiptValue'] = "report/MM_ReceiptValue"; +$route['Report_purchase'] = "report/purchase"; +$route['Report_year_wise'] = "report/year_wise"; +$route['Report_supplier'] = "report/purchase_supplier"; // Company Information diff --git a/application/controllers/report.php b/application/controllers/report.php index e1395829..714064bc 100755 --- a/application/controllers/report.php +++ b/application/controllers/report.php @@ -126,7 +126,98 @@ class report extends BaseController } + public function purchase() + { + + $this->global['pageTitle'] = 'Siddharth : Reports'; + //$this->input->post('btn_submit'); + $cname = $this->input->post('client_name'); + $prod = $this->input->post('item_name'); + $ab=$this->input->post('financialyear'); + $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'); + //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['purchase']=$this->dahsboard_Model->report_purchase($cname,$prod,$fa,$aa,$m,$frm,$t); + + + $this->loadviews("Report_purchase",$this->global,$data, NULL); + + } + public function year_wise() + { + $this->global['pageTitle'] = 'Siddharth : Reports'; + + + if ($this->input->post('financialyear')) { + + $data['year']=$this->dahsboard_Model->report_year_wise(); + $data['finyear']=$this->dahsboard_Model->report_finyear(); + + //$this->loadviews("Report_year_wise",$this->global,$data, NULL); + } + $data['finyear']=$this->dahsboard_Model->report_finyear(); + + $this->loadviews("Report_year_wise",$this->global,$data, NULL); + } + public function month_wise() + { + + $this->global['pageTitle'] = 'Siddharth : Reports'; + + $last = $this->uri->total_segments(); + $month=$this->uri->segment($last); + $mon= date("F",strtotime($month)); + //print_r($month); + $data['mont']=$mon; + $data['month']=$this->dahsboard_Model->report_month_wise($month); + $this->loadviews("Report_month_wise",$this->global,$data, NULL); + + } + public function year_wise_total() + { + + $this->global['pageTitle'] = 'Siddharth : Reports'; + + $last = $this->uri->total_segments(); + $month=$this->uri->segment($last); + $a=substr($month,0,-5); + $b=substr($month,5,5); + //print_r($month); + $data['year']=$month; + $data['ytotal']=$this->dahsboard_Model->report_year_wise_total($a,$b); + $this->loadviews("Report_year_wise_total",$this->global,$data, NULL); + + } + + public function purchase_supplier() + { + + $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); + $m=$this->input->post('month'); + $frm = $this->input->post('from_date'); + $t = $this->input->post('to_date'); + //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->report_supplier($cname,$fa,$aa,$m,$frm,$t); + + + $this->loadviews("Report_supplier",$this->global,$data, NULL); + + } diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php index d194a6f5..6eb448f0 100755 --- a/application/models/dahsboard_model.php +++ b/application/models/dahsboard_model.php @@ -427,7 +427,175 @@ order by monthname(matv.CreatedDate)"; } + function report_purchase($cname,$prod,$fa,$aa,$m,$frm,$t){ + + + $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,ifnull(pl.Quantity,0) as quantity,ifnull(pl.Rate,0) as rate,round(ifnull((pl.Quantity * pl.Rate),0),2) as value,ifnull(st.After_SGST,0) as sgst,ifnull(st.After_CGST,0) as cgst,ifnull(st.After_IGST,0) as igst,round((ifnull((pl.Quantity * pl.Rate),0) + ifnull(st.After_SGST,0) + ifnull(st.After_CGST,0) + ifnull(st.After_IGST,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 +left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo +where +pm.PONO>'0' "; + +if ($cname!= ''){ + + $sql.="and sd.SupplierName = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + $sql.=" and (pm.CreatedDate >= '".$fa."-04-01' and pm.CreatedDate <= '".$aa."-03-31')"; + + } + if ($m!= ''){ + + $sql.="and monthname(pm.CreatedDate) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromd= date("Y-m-d",strtotime($frm)); + $tod=date("Y-m-d",strtotime($t)); + + $sql.="and date(pm.CreatedDate) >= '".$fromd."' + and date(pm.CreatedDate) <= '".$tod."'"; + + } + if ($prod!= ''){ + + $sql.=" and mm.MaterialName = '".$prod."' "; + + } + + + +$sql.="order by pono"; +//echo $sql; + $query = $this->db->query($sql); + return $query->result(); + + + + } + function report_finyear(){ + + + $sql="SELECT + CASE WHEN MONTH(CreatedDate)>=4 THEN + concat(YEAR(CreatedDate), '-',YEAR(CreatedDate)+1) + ELSE concat(YEAR(CreatedDate)-1,'-', YEAR(CreatedDate)) END AS financial_year + FROM T_PurchaseOrder_Master +GROUP BY financial_year"; + $query = $this->db->query($sql); + return $query->result(); + + + + } + function report_year_wise(){ + + + $sql="SELECT pm.CreatedDate as created_date,ifnull(sum(pl.Quantity),0) as quantity,round((ifnull(sum(pl.Quantity * pl.Rate),0) + ifnull(sum(st.After_SGST),0) + ifnull(sum(st.After_CGST),0) + ifnull(sum(st.After_IGST),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 +left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo +group by month(created_date)"; + $query = $this->db->query($sql); + return $query->result(); + + + + } + function customer_name(){ + $sql="SELECT distinct SupplierName FROM T_SupplierDetailsN;"; + $query = $this->db->query($sql); + return $query->result(); + } + function material_name(){ + $sql="SELECT distinct MaterialName FROM T_MaterialMaster;"; + $query = $this->db->query($sql); + return $query->result(); + } + function report_month_wise($mont){ + $month= date("m",strtotime($mont)); + $year = date("Y",strtotime($mont)); + + $sql="SELECT sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,pl.Quantity as quantity,round((ifnull((pl.Quantity * pl.Rate),0) + ifnull(st.After_SGST,0) + ifnull(st.After_CGST,0) + ifnull(st.After_IGST,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 +left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo +where 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(); + } + function report_year_wise_total($a,$b){ + + $sql="SELECT sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,pl.Quantity as quantity,round((ifnull((pl.Quantity * pl.Rate),0) + ifnull(st.After_SGST,0) + ifnull(st.After_CGST,0) + ifnull(st.After_IGST,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 +left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo +where 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(); + } + function report_supplier($cname,$fa,$aa,$m,$frm,$t){ + + + $sql="SELECT 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,round(sum(ifnull((pl.Quantity * pl.Rate),0) + ifnull(st.After_SGST,0) + ifnull(st.After_CGST,0) + ifnull(st.After_IGST,0)),2) as total +FROM T_PurchaseOrder_Master pm +join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID +left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo +where +pm.PONO>'0' "; + +if ($cname!= ''){ + + $sql.="and sd.SupplierName = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + $sql.=" and (pm.CreatedDate >= '".$fa."-04-01' and pm.CreatedDate <= '".$aa."-03-31')"; + + } + if ($m!= ''){ + + $sql.="and monthname(pm.CreatedDate) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromd= date("Y-m-d",strtotime($frm)); + $tod=date("Y-m-d",strtotime($t)); + + $sql.="and date(pm.CreatedDate) >= '".$fromd."' + and date(pm.CreatedDate) <= '".$tod."'"; + + } + $sql.= "group by supplier_name"; + //echo $sql; + $query = $this->db->query($sql); + return $query->result(); + + } diff --git a/application/views/Report_month_wise.php b/application/views/Report_month_wise.php new file mode 100644 index 00000000..c408fbae --- /dev/null +++ b/application/views/Report_month_wise.php @@ -0,0 +1,206 @@ + + + + + +
Report - Month-wise()
| Supplier | +Product | +Quantity | +Total Value | + + +
|---|---|---|---|
| supplier_name;?> | +material_name;?> | +quantity); + echo $rel->quantity;?> | +total; + echo $rel->total;?> | +
| + + | ++ + | + ++ + + + | ++ + + + | + + + +
Report - Purchase
| PO NO | +Date | +Time | +Material | +Supplier | +Quantity | +Rate | +Value | +SGST | +CGST | +IGST | +Total | + +
|---|---|---|---|---|---|---|---|---|---|---|---|
| pono;?> | +created_date;?> | +created_time;?> | +material_name;?> | +supplier_name;?> | +quantity); + echo round($rel->quantity);?> | +rate); + echo round($rel->rate);?> | +value); + echo round($rel->value);?> | +sgst); + echo round($rel->sgst);?> | +cgst); + echo round($rel->cgst);?> | +igst); + echo round($rel->igst);?> | +total); + echo round($rel->total);?> | + + + +
| Total | +  | +  | +  | +  | + ++ + + | ++ + + | ++ + + + | ++ + + + | ++ + + + | ++ + + + | ++ + + | + + + +
Report - Purchase
| Supplier | +Count | +Quantity | +Value | + <Total | + +
|---|---|---|---|---|
| supplier_name;?> | +counts); + echo round($rel->counts);?> | +quantity); + echo round($rel->quantity);?> | +value); + echo round($rel->value);?> | +total); + echo round($rel->total);?> | + + + +
| Total | + ++ + + | + ++ + + + | ++ + + + | ++ + + + | + + +
Report - Year-Wise
| Month-Year | +Quantity | +Total Value | + + +
|---|---|---|
| + created_date); + $new = date('M-y', $date); + $pass = date('Y-m-d',$date) + //echo $new; + ?> + "> + | +quantity; + echo round($rel->quantity);?> | +total; + echo $rel->total;?> | + + + +
| input->post('financialyear'); + $Total="Total"; + echo anchor('report/year_wise_total/' . $ab,$Total); ?> + + | + + ++ + + + | ++ + + + | + + + +
Report - Year-wise-Total()
| Supplier | +Product | +Quantity | +Total Value | + + +
|---|---|---|---|
| supplier_name;?> | +material_name;?> | +quantity); + echo round($rel->quantity);?> | +total; + echo $rel->total;?> | +
| + + | ++ + | + ++ + + + | ++ + + + | + + + +