diff --git a/application/config/routes.php b/application/config/routes.php index 9a3047f7..08bbb2d6 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -233,6 +233,8 @@ $route['Report_supplier'] = "report/purchase_supplier"; $route['Report_consolidate'] = "report/consolidate"; $route['Report_cumulative'] = "report/cumulative"; $route['cashbookreport']="report/cashbook"; +$route['cashbookcumulativereport']="report/cashbook_cumulative_report"; +$route['cashbookcumulativemonthreport']="report/cashbook_month_cumulative_report"; $route['cashbookmonthlyexpenses']="report/monthexpenses"; $route['cashbookyearlyexpenses']="report/yearexpenses"; $route['Report_purchase_inward'] = "report/ipurchase"; diff --git a/application/controllers/emergencypurchaseorder.php b/application/controllers/emergencypurchaseorder.php index 6f158255..a7a0fbf7 100644 --- a/application/controllers/emergencypurchaseorder.php +++ b/application/controllers/emergencypurchaseorder.php @@ -536,7 +536,10 @@ class emergencypurchaseorder extends BaseController $DeliveryChellanInvoiceNo=$this->input->post('ChallanInvNo'); $DeliveryChellan = $this->input->post('ChallanInvDate'); - $DeliveryChellanDate = $this->getDateformat($DeliveryChellan); + $DeliveryChellanDate = $this->getDateformat($DeliveryChellan); + + $MaterialReceive = $this->input->post('MRC'); + $MaterialReceivedate = $this->getDateformat($MaterialReceive); $Vehicle = $this->input->post('VehicleNo'); $Courier = $this->input->post('CourierNo'); @@ -551,8 +554,8 @@ class emergencypurchaseorder extends BaseController $IGRStatus = IGR_CREATED; $igr = array(); - $igr = array('PONO'=>$PONO,'VehicleNo'=>$Vehicle,'DeliveryChellanOrInvoiceNo'=>$DeliveryChellanInvoiceNo,'DeliveryChellanDate'=>$DeliveryChellanDate,'CourierNo'=>$Courier,'IGRStatus'=>$IGRStatus,'CreatedBy'=>$CreatedBy,'CreatedDate' =>$createddt); - $igrM = $this->inwardgateregister_model->addigrM($igr); + $igr = array('PONO'=>$PONO,'VehicleNo'=>$Vehicle,'DeliveryChellanOrInvoiceNo'=>$DeliveryChellanInvoiceNo,'DeliveryChellanDate'=>$DeliveryChellanDate,'CourierNo'=>$Courier,'IGRStatus'=>$IGRStatus,'CreatedBy'=>$CreatedBy,'CreatedDate' =>$createddt,'MaterialRcvdDate'=>$MaterialReceivedate); + $igrM = $this->inwardgateregister_model->addigrM($igr); $IGRNO = ''; if(count($igrM)>0) { diff --git a/application/controllers/inwardgateregister.php b/application/controllers/inwardgateregister.php index a1963037..e2975181 100644 --- a/application/controllers/inwardgateregister.php +++ b/application/controllers/inwardgateregister.php @@ -129,7 +129,12 @@ class inwardgateregister extends BaseController $DeliveryChellan = $this->input->post('InvoiceDate'); $DeliveryChellanDate = $this->getDateformat($DeliveryChellan); - + + + $Mat_Rcvd_Dt = $this->input->post('MaterialRcvdDate'); + $MaterialRcvdDt = $this->getDateformat($Mat_Rcvd_Dt); + + $VehicleNo = $this->input->post('VehicleNo'); $CourierNo = $this->input->post('CourierNo'); @@ -162,7 +167,7 @@ class inwardgateregister extends BaseController $igr = array(); - $igr = array('PONO'=>$PONO,'VehicleNo'=>$VehicleNo,'DeliveryChellanOrInvoiceNo'=>$DeliveryChellanOrInvoiceNo,'DeliveryChellanDate'=>$DeliveryChellanDate,'CourierNo'=>$CourierNo,'IGRStatus'=>$IGRStatus,'CreatedBy'=>$CreatedBy,'CreatedDate' =>$createddt,'file'=>$document); + $igr = array('PONO'=>$PONO,'VehicleNo'=>$VehicleNo,'DeliveryChellanOrInvoiceNo'=>$DeliveryChellanOrInvoiceNo,'DeliveryChellanDate'=>$DeliveryChellanDate,'MaterialRcvdDate'=>$MaterialRcvdDt,'CourierNo'=>$CourierNo,'IGRStatus'=>$IGRStatus,'CreatedBy'=>$CreatedBy,'CreatedDate' =>$createddt,'file'=>$document); $igrM = $this->inwardgateregister_model->addigrM($igr); @@ -240,6 +245,39 @@ class inwardgateregister extends BaseController echo json_encode($data); } + + /** + *To Update igr Datas form ajax + */ + function UpdateIGR() + { + + $IGRNo = $this->input->post('igr'); + + $DeliveryChellan = $this->input->post('invdate'); + $DeliveryChellanDate = $this->getDateformat($DeliveryChellan); + + $Mat_Rcvd_Dt = $this->input->post('mrc'); + $MaterialRcvdDt = $this->getDateformat($Mat_Rcvd_Dt); + + $updateby = $this->session->userdata('userId'); + + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $updatedon = $dt->format('Y-m-d H:i:s'); + + + $igrarr = array('DeliveryChellanDate'=>$DeliveryChellanDate,'MaterialRcvdDate'=>$MaterialRcvdDt,'UpdateBY'=>$updateby,'UpdatedOn'=>$updatedon); + + $data = $this->inwardgateregister_model->updateigr($igrarr,$IGRNo); + + if($data > 0){ + echo "Updated Succefully!"; + } + else{ + echo "Not Updated!"; + } + + } /** * To load pagenotfound view diff --git a/application/controllers/report.php b/application/controllers/report.php index 61bed12a..edbf81e8 100755 --- a/application/controllers/report.php +++ b/application/controllers/report.php @@ -518,7 +518,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['finyear']=$this->dahsboard_Model->ireport_finyear(); $this->loadviews("Report_purchase_inward",$this->global,$data, NULL); @@ -543,7 +543,7 @@ class report extends BaseController //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['finyear']=$this->dahsboard_Model->ireport_finyear(); $data['purchase']=$this->dahsboard_Model->ireport_purchase($cname,$prod,$fa,$aa,$m,$frm,$t,$sid,$mid,$d); @@ -566,7 +566,7 @@ class report extends BaseController $po = $this->input->get('po'); $data['material']=$this->dahsboard_Model->material_name(); $data['cust']=$this->dahsboard_Model->customer_name(); - $data['finyear']=$this->dahsboard_Model->report_finyear(); + $data['finyear']=$this->dahsboard_Model->ireport_finyear(); $data['purchase']=$this->dahsboard_Model->ireport_purchase_link($cname,$prod,$fa,$aa,$m,$frm,$t,$sid,$mid,$d,$cat,$da,$po); } @@ -588,12 +588,12 @@ class report extends BaseController //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['finyear']=$this->dahsboard_Model->ireport_finyear(); $data['purchase']=$this->dahsboard_Model->ireport_attachment($cname,$fa,$aa,$m,$frm,$t); } $data['cust']=$this->dahsboard_Model->customer_name(); - $data['finyear']=$this->dahsboard_Model->report_finyear(); + $data['finyear']=$this->dahsboard_Model->ireport_finyear(); // if($this->DEPCode == MANAGEMENT) // { $this->loadviews("Report_attach_inward",$this->global,$data, NULL); @@ -614,11 +614,11 @@ class report extends BaseController $a=substr($ab,0,-5); $b=substr($ab,5,5); $data['year']=$this->dahsboard_Model->ireport_year_wise($a,$b); - $data['finyear']=$this->dahsboard_Model->report_finyear(); + $data['finyear']=$this->dahsboard_Model->ireport_finyear(); //$this->loadviews("Report_year_wise",$this->global,$data, NULL); } - $data['finyear']=$this->dahsboard_Model->report_finyear(); + $data['finyear']=$this->dahsboard_Model->ireport_finyear(); @@ -671,12 +671,12 @@ class report extends BaseController //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['finyear']=$this->dahsboard_Model->ireport_finyear(); $data['spurchse']=$this->dahsboard_Model->ireport_supplier($cname,$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(); + $data['finyear']=$this->dahsboard_Model->ireport_finyear(); $this->loadviews("Report_supplier_inward",$this->global,$data, NULL); } public function iconsolidate() @@ -691,12 +691,12 @@ class report extends BaseController //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['finyear']=$this->dahsboard_Model->ireport_finyear(); $data['spurchse']=$this->dahsboard_Model->ireport_consolidate($cname,$fa,$aa); } $data['material']=$this->dahsboard_Model->material_name(); $data['cust']=$this->dahsboard_Model->customer_name(); - $data['finyear']=$this->dahsboard_Model->report_finyear(); + $data['finyear']=$this->dahsboard_Model->ireport_finyear(); $this->loadviews("Report_consolidate_inward",$this->global,$data, NULL); @@ -718,7 +718,7 @@ class report extends BaseController //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['finyear']=$this->dahsboard_Model->ireport_finyear(); $data['spurchse']=$this->dahsboard_Model->i_consolidate_month($m,$sid,$mid,$fa,$aa); // print_r( $data['spurchse']); @@ -742,7 +742,7 @@ class report extends BaseController //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['finyear']=$this->dahsboard_Model->ireport_finyear(); $data['spurchse']=$this->dahsboard_Model->i_consolidate_year($sid,$mid,$fa,$aa); // print_r( $data['spurchse']); @@ -872,12 +872,12 @@ class report extends BaseController //print_r($prod); $data['material']=$this->dahsboard_Model->category(); $data['cust']=$this->dahsboard_Model->customer_name(); - $data['finyear']=$this->dahsboard_Model->report_finyear(); + $data['finyear']=$this->dahsboard_Model->ireport_finyear(); $data['spurchse']=$this->dahsboard_Model->rawi_report_consolidate($cname,$fa,$aa); } $data['material']=$this->dahsboard_Model->category(); $data['cust']=$this->dahsboard_Model->customer_name(); - $data['finyear']=$this->dahsboard_Model->report_finyear(); + $data['finyear']=$this->dahsboard_Model->ireport_finyear(); $this->loadviews("Report_consolidate_raw",$this->global,$data, NULL); @@ -898,7 +898,7 @@ class report extends BaseController //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['finyear']=$this->dahsboard_Model->ireport_finyear(); $data['spurchse']=$this->dahsboard_Model->rawi_consolidate_month($m,$cat,$sup,$fa,$aa); // print_r( $data['spurchse']); @@ -920,7 +920,7 @@ class report extends BaseController //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['finyear']=$this->dahsboard_Model->ireport_finyear(); $data['spurchse']=$this->dahsboard_Model->rawi_consolidate_year($cat,$sup,$fa,$aa); // print_r( $data['spurchse']); @@ -1132,15 +1132,18 @@ class report extends BaseController public function cashbookdepartment() { //$this->global['pageTitle'] = 'Cashbook - department - '; - $sid=$_GET['sid']; - - $d=$_GET['d']; + if(!empty($_GET['sid'])){$sid=$_GET['sid'];}else{ $sid='';} + if(!empty($_GET['d'])){$d=$_GET['d'];}else{$d='';} $c=$_GET['c']; + $finyear=$_GET['finyear']; + $fy=substr( $finyear,0,-5); + $ty=substr( $finyear,5,5); + if ($c=='PAYMENT') { $this->global['pageTitle'] = $this->CompanyName.' : PaymentWise Reports'; - $data['departmentwise']=$this->dahsboard_Model->departmentwise($sid,$d,$c); + $data['departmentwise']=$this->dahsboard_Model->departmentwise($sid,$d,$c,$fy,$ty); $data['Indiancurrency']=$this->dahsboard_Model->INRSymbol(); $this->loadviews("cashbookmthlypaydep",$this->global,$data, NULL); @@ -1148,7 +1151,8 @@ class report extends BaseController } else{ $this->global['pageTitle'] = $this->CompanyName.' : ReceiptWise Reports'; - $data['departmentwise']=$this->dahsboard_Model->departmentwise($sid,$d,$c); + $data['departmentwise']=$this->dahsboard_Model->departmentwise($sid,$d,$c,$fy,$ty); + $data['Indiancurrency']=$this->dahsboard_Model->INRSymbol(); $this->loadviews("cashbookmthlyrecdep",$this->global,$data, NULL); //cashbookmonthlyexp=>cashbookmthlyrecdep @@ -1165,5 +1169,34 @@ class report extends BaseController $this->loadviews("cashbookyearmonthwise",$this->global,$data, NULL); } + + public function cashbook_cumulative_report() + { + $this->global['pageTitle'] = $this->CompanyName.' : Cashbook Cumulative Reports'; + $data['datas']=$this->dahsboard_Model->report_cumulative_cashbook(); + $this->loadviews("cashbook_cumulative_report",$this->global,$data, NULL); + } + + public function cashbook_month_cumulative_report() + { + + $this->global['pageTitle'] = $this->CompanyName.' : Cashbook Cumulative(Monthwise) Reports'; + if ($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); + + $data['accountname']=$this->dahsboard_Model->accountname(); + $data['finyear']=$this->dahsboard_Model->cashbook_finyear(); + // $data['spurchse']=$this->dahsboard_Model->rawi_report_consolidate($cname,$fa,$aa); + $data['datas'] = $this->dahsboard_Model->report_cumulative_month_cashbook($cname,$fa,$aa); + } + + $data['accountname']=$this->dahsboard_Model->accountname(); + $data['finyear']=$this->dahsboard_Model->cashbook_finyear(); + + $this->loadviews("cashbook_cumulative_month_report",$this->global,$data, NULL); + } } ?> \ No newline at end of file diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php index b3e1c24d..a2b8aa40 100755 --- a/application/models/dahsboard_model.php +++ b/application/models/dahsboard_model.php @@ -1070,6 +1070,42 @@ GROUP BY financial_year"; } + + function accountname() + { + $sql = "SELECT name from t_accountcode "; + $query = $this->db->query($sql); + return $query->result(); + } + + function cashbook_finyear(){ + + $sql="SELECT + CASE WHEN MONTH(date)>=4 THEN + concat(YEAR(date), '-',YEAR(date)+1) + ELSE concat(YEAR(date)-1,'-', YEAR(date)) END AS financial_year + FROM t_income_expense + GROUP BY financial_year"; + $query = $this->db->query($sql); + return $query->result(); + + } + + function ireport_finyear(){ + + $sql="SELECT + CASE WHEN MONTH(MaterialRcvdDate)>=4 + THEN concat(YEAR(MaterialRcvdDate), '-',YEAR(MaterialRcvdDate)+1) + ELSE concat(YEAR(MaterialRcvdDate)-1,'-', YEAR(MaterialRcvdDate)) + END AS financial_year + FROM T_IGR_Master + GROUP BY financial_year"; + $query = $this->db->query($sql); + return $query->result(); + + } + + function report_year_wise($a=null, $b=null){ @@ -1402,10 +1438,10 @@ group by supplier_name,material_name"; $query = $this->db->query($sql); return $query->result(); } - function ireport_purchase($cname,$prod,$fa,$aa,$m,$frm,$t,$cat){ + function ireport_purchase($cname,$prod,$fa,$aa,$m,$frm,$t,$cat){ - $sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as pono,date_format(im.CreatedDate,'%d-%m-%Y') as created_date,TIME_FORMAT(im.CreatedDate,'%l:%i %p') as created_time,mm.MaterialName as material_name,mm.Category as category,sd.SupplierName as supplier_name,mm.UOM as UOM, sum(id.QuantityAsPerInvoice) as quantity,pl.Rate as rate,round(sum(id.QuantityAsPerInvoice) * pl.Rate,2) as value,if(POType = 'IMPORT' or POType = 'CAPITAL',sum(pm.ExchangeRate),0) as exchange_rate, + $sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as pono,date_format(im.CreatedDate,'%d-%m-%Y') as created_date,TIME_FORMAT(im.CreatedDate,'%l:%i %p') as created_time,mm.MaterialName as material_name,mm.Category as category,sd.SupplierName as supplier_name,mm.UOM as UOM, sum(id.QuantityAsPerInvoice) as quantity,pl.Rate as rate,round(sum(id.QuantityAsPerInvoice) * pl.Rate,2) as value,if(POType = 'IMPORT' or POType = 'CAPITAL',sum(pm.ExchangeRate),0) as exchange_rate,date_format(im.MaterialRcvdDate,'%d-%m-%Y') as materialrcvddate, round(ifnull(if(POType = 'REVENUE', sum(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), sum(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) as sgst, @@ -1425,27 +1461,27 @@ round(ifnull(if(POType = 'REVENUE', sum(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) as Package, round(( - if(POType = 'IMPORT',sum(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +if(POType = 'IMPORT',sum(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), if(POType = 'CAPITAL' && CapitalRange = 0,sum(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0))) + round(ifnull(if(POType = 'REVENUE', - sum(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), - sum(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) + sum(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), + sum(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) + round(ifnull(if(POType = 'REVENUE', - sum(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity), - sum(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) + sum(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity), + sum(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) + round(ifnull(if(POType = 'REVENUE', - sum(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity), - sum(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) + sum(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity), + sum(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) + round(ifnull(if(POType = 'REVENUE', - sum(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity), - sum(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) + sum(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity), + sum(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) + round(ifnull(if(POType = 'REVENUE', - sum(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) + sum(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) - round(ifnull(if(POType = 'REVENUE', - sum(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), - sum(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total, - im.file as ifile,pb.FilePath as file + sum(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), + sum(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total, + im.file as ifile,pb.FilePath as file from T_IGR_Master im join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode @@ -1458,54 +1494,58 @@ left join T_PurchaseOrder_BillUpload pb on pb.IGRNO=im.IGRNO where pm.Status != 'ST030' "; if ($cname!= ''){ + + $sql.="and sd.SupplierName = '".$cname."'"; - $sql.="and sd.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ + } - $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - $sql.="and monthname(im.CreatedDate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - $sql.="and date(im.CreatedDate) >= '".$fromd."' - and date(im.CreatedDate) <= '".$tod."'"; - - } - if ($prod!= ''){ + if ($fa and $aa != ''){ + + //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + $sql.=" and (im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')"; - $sql.=" and mm.MaterialName = '".$prod."' "; - - } - if ($cat!= ''){ + } + if ($m!= ''){ + + //$sql.="and monthname(im.CreatedDate) = '".$m."'"; + $sql.="and monthname(im.MaterialRcvdDate) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromd= date("Y-m-d",strtotime($frm)); + $tod=date("Y-m-d",strtotime($t)); + + // $sql.="and date(im.CreatedDate) >= '".$fromd."' + // and date(im.CreatedDate) <= '".$tod."'"; + $sql.="and date(im.MaterialRcvdDate) >= '".$fromd."' + and date(im.MaterialRcvdDate) <= '".$tod."'"; + + } + if ($prod!= ''){ + + $sql.=" and mm.MaterialName = '".$prod."' "; + + } + if ($cat!= ''){ + + $sql.=" and mm.Category = '".$cat."' "; + + } - $sql.=" and mm.Category = '".$cat."' "; - - } - -$sql.="group by pono,material_name,category,supplier_name"; +$sql.="group by pono,material_name,category,supplier_name,id.IGRItemNo"; //echo $sql; - $query = $this->db->query($sql); - return $query->result(); - } - function ireport_purchase_link($cname,$prod,$fa,$aa,$m,$frm,$t,$sid,$mid,$d,$cat,$da,$po){ - - - $sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as pono,date_format(im.CreatedDate,'%d-%m-%Y') as created_date,TIME_FORMAT(im.CreatedDate,'%l:%i %p') as created_time,mm.MaterialName as material_name,mm.Category as category,sd.SupplierName as supplier_name,mm.UOM as UOM, sum(id.QuantityAsPerInvoice) as quantity,pl.Rate as rate,round(sum(id.QuantityAsPerInvoice) * pl.Rate,2) as value,if(POType = 'IMPORT' or POType = 'CAPITAL',sum(pm.ExchangeRate),0) as exchange_rate, + $query = $this->db->query($sql); + return $query->result(); + } + function ireport_purchase_link($cname,$prod,$fa,$aa,$m,$frm,$t,$sid,$mid,$d,$cat,$da,$po){ + + + $sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as pono,date_format(im.CreatedDate,'%d-%m-%Y') as created_date,TIME_FORMAT(im.CreatedDate,'%l:%i %p') as created_time,mm.MaterialName as material_name,mm.Category as category,sd.SupplierName as supplier_name,mm.UOM as UOM, sum(id.QuantityAsPerInvoice) as quantity,pl.Rate as rate,round(sum(id.QuantityAsPerInvoice) * pl.Rate,2) as value,if(POType = 'IMPORT' or POType = 'CAPITAL',sum(pm.ExchangeRate),0) as exchange_rate,date_format(im.MaterialRcvdDate,'%d-%m-%Y') as materialrcvddate, round(ifnull(if(POType = 'REVENUE', sum(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), sum(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) as sgst, @@ -1525,27 +1565,27 @@ round(ifnull(if(POType = 'REVENUE', sum(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) as Package, round(( - if(POType = 'IMPORT',sum(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +if(POType = 'IMPORT',sum(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), if(POType = 'CAPITAL' && CapitalRange = 0,sum(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0))) + round(ifnull(if(POType = 'REVENUE', - sum(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), - sum(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) + sum(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), + sum(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) + round(ifnull(if(POType = 'REVENUE', - sum(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity), - sum(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) + sum(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity), + sum(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) + round(ifnull(if(POType = 'REVENUE', - sum(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity), - sum(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) + sum(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity), + sum(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) + round(ifnull(if(POType = 'REVENUE', - sum(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity), - sum(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) + sum(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity), + sum(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) + round(ifnull(if(POType = 'REVENUE', - sum(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) + sum(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) - round(ifnull(if(POType = 'REVENUE', - sum(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), - sum(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total, - im.file as ifile,pb.FilePath as file + sum(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), + sum(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total, + im.file as ifile,pb.FilePath as file from T_IGR_Master im join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode @@ -1558,84 +1598,93 @@ left join T_PurchaseOrder_BillUpload pb on pb.IGRNO=im.IGRNO where pm.Status != 'ST030' "; if ($cname!= ''){ + + $sql.="and sd.SupplierName = '".$cname."'"; - $sql.="and sd.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ + } - $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - $sql.="and monthname(im.CreatedDate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - $sql.="and date(im.CreatedDate) >= '".$fromd."' - and date(im.CreatedDate) <= '".$tod."'"; - - } - if ($prod!= ''){ + if ($fa and $aa != ''){ + + //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + $sql.=" and (im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')"; - $sql.=" and mm.MaterialName = '".$prod."' "; - - } - if ($sid!= ''){ + } + if ($m!= ''){ + + //$sql.="and monthname(im.CreatedDate) = '".$m."'"; + $sql.="and monthname(im.MaterialRcvdDate) = '".$m."'"; - $sql.=" and sd.SupplierID = '".$sid."' "; - - } - if ($mid!= ''){ + } - $sql.=" and mm.MaterialCode = '".$mid."' "; - - } - if ($d!= ''){ + if ($frm and $t != ''){ + $fromd= date("Y-m-d",strtotime($frm)); + $tod=date("Y-m-d",strtotime($t)); + + // $sql.="and date(im.CreatedDate) >= '".$fromd."' + // and date(im.CreatedDate) <= '".$tod."'"; + + $sql.="and date(im.MaterialRcvdDate) >= '".$fromd."' + and date(im.MaterialRcvdDate) <= '".$tod."'"; - $sql.=" and date(im.CreatedDate) = '".$d."' "; - - } - if ($cat!= ''){ + } + if ($prod!= ''){ + + $sql.=" and mm.MaterialName = '".$prod."' "; - $sql.=" and mm.Category = '".$cat."' "; - - } - if ($da!= ''){ - $ddd= date("Y-m-d",strtotime($da)); - $sql.=" and date(im.CreatedDate) = '".$ddd."' "; - - } - if ($po!= ''){ + } + if ($sid!= ''){ + + $sql.=" and sd.SupplierID = '".$sid."' "; - $sql.=" and im.PONO = '".$po."' "; - - } + } + if ($mid!= ''){ + + $sql.=" and mm.MaterialCode = '".$mid."' "; + + } + if ($d!= ''){ + + //$sql.=" and date(im.CreatedDate) = '".$d."' "; + $sql.=" and date(im.MaterialRcvdDate) = '".$d."' "; + + } + if ($cat!= ''){ + + $sql.=" and mm.Category = '".$cat."' "; + + } + if ($da!= ''){ + $ddd= date("Y-m-d",strtotime($da)); + //$sql.=" and date(im.CreatedDate) = '".$ddd."' "; + $sql.=" and date(im.MaterialRcvdDate) = '".$ddd."' "; + + } + if ($po!= ''){ + + $sql.=" and im.PONO = '".$po."' "; + + } + -$sql.="group by pono,material_name,category,supplier_name"; +$sql.="group by pono,material_name,category,supplier_name,id.IGRItemNo"; // echo $m; // echo $sid; //echo $sql; - $query = $this->db->query($sql); - return $query->result(); - } - function ireport_attachment($cname,$fa,$aa,$m,$frm,$t){ + $query = $this->db->query($sql); + return $query->result(); + } + + function ireport_attachment($cname,$fa,$aa,$m,$frm,$t){ - $sql="select pono,potype,date_format(created_date,'%d-%m-%Y') as created_date,supplier_name, -sum(total) as total,file,ifile -from igr -where status != 'ST030' + $sql="select pono,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name, + sum(total) as total,file,ifile + from igr + where status != 'ST030' "; if ($cname!= ''){ @@ -1647,114 +1696,130 @@ if ($cname!= ''){ if ($fa and $aa != ''){ - - $sql.=" and (created_date >= '".$fa."-04-01' and created_date <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(created_date) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(created_date) >= '".$fromd."' - and date(created_date) <= '".$tod."'"; - - } - - $sql.="group by pono"; -// echo $m; -// echo $sid; -//echo $sql; - $query = $this->db->query($sql); - return $query->result(); - } - - function ireport_year_wise($a,$b){ - - - $sql="select dat as CreatedDate,sum(quantity)as quantity,sum(value) as value -from year_inward -where status != 'ST030' and date(dat) >= '$a-04-01' and date(dat) <= '$b-03-31' -group by month(CreatedDate) -"; -//echo $sql; - $query = $this->db->query($sql); - return $query->result(); - - - - } - - function ireport_month_wise($mont){ - $month= date("m",strtotime($mont)); - $year = date("Y",strtotime($mont)); - - $sql="select sid,mid,supplier_name,material_name,sum(quantity)as quantity,sum(value) as total -from year_inward -where status != 'ST030' and month(dat)= ? and year(dat) = ? -group by material_name,supplier_name"; - $query = $this->db->query($sql,array($month,$year)); - return $query->result(); - } - function ireport_year_wise_total($a,$b){ - - $sql="select sid,mid,supplier_name,material_name,sum(quantity)as quantity,sum(value) as total -from year_inward -where status != 'ST030' and date(dat) >= '$a-04-01' and date(dat) <= '$b-03-31' -group by material_name,supplier_name"; - $query = $this->db->query($sql,array()); - return $query->result(); - } - - function ireport_supplier($cname,$fa,$aa,$m,$frm,$t){ - - - $sql="SELECT sd.SupplierID as sid,sd.SupplierName as supplier_name,count(im.PONO) as counts,ifnull(sum(id.QuantityAsPerInvoice),0) as quantity,round(ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0),2) as value, -case pm.POType -when 'IMPORT' -then ifnull((sum((id.QuantityAsPerInvoice * pl.Rate) * pm.ExchangeRate) -+ ifnull(rt.Insurance,0) - -),0) -when 'CAPITAL' -then sum( if(pm.CapitalRange=0,(( id.QuantityAsPerInvoice * pl.Rate) * pm.ExchangeRate),( id.QuantityAsPerInvoice * pl.Rate) -- st.Afterdiscountval)) -+ ifnull(sum(st.After_SGST),0) -+ ifnull(sum(st.After_CGST),0) -+ ifnull(sum(st.After_IGST),0) -+ ifnull(sum(st.AfterFreightValue),0) -+ ifnull(rt.Insurance,0) - - -when 'SERVICE' -then ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0) -+ ifnull(sum(st.After_SGST),0) -+ ifnull(sum(st.After_CGST),0) -+ ifnull(sum(st.After_IGST),0) -+ ifnull(sum(st.AfterFreightValue),0) -+ ifnull(rt.Insurance,0) -- ifnull(sum(st.Afterdiscountval),0) - -when 'REVENUE' -then ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0) -- ifnull(sum(rt.AfterDiscount),0) -+ ifnull(sum(rt.AfterSGST),0) -+ ifnull(sum(rt.AfterCGST),0) -+ ifnull(sum(rt.AfterIGST),0) -+ ifnull(sum(rt.AfterFreightValue),0) -+ ifnull(sum(rt.AfterPackagingValue),0) -+ ifnull(rt.Insurance,0) - -end - as total -from T_IGR_Master im -join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO + //$sql.=" and (created_date >= '".$fa."-04-01' and created_date <= '".$aa."-03-31')"; + $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')"; + + } + if ($m!= ''){ + + //$sql.="and monthname(created_date) = '".$m."'"; + $sql.="and monthname(materialrcvddate) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromd= date("Y-m-d",strtotime($frm)); + $tod=date("Y-m-d",strtotime($t)); + + // $sql.="and date(created_date) >= '".$fromd."' + // and date(created_date) <= '".$tod."'"; + $sql.="and date(materialrcvddate) >= '".$fromd."' + and date(materialrcvddate) <= '".$tod."'"; + + } + + $sql.="group by pono,igrn"; + // echo $m; + // echo $sid; + //echo $sql; + $query = $this->db->query($sql); + return $query->result(); + } + + function ireport_year_wise($a,$b){ + + + // $sql="select dat as CreatedDate,sum(quantity)as quantity,sum(value) as value, materialrcvddate + // from year_inward + // where status != 'ST030' and date(dat) >= '$a-04-01' and date(dat) <= '$b-03-31' + // group by month(CreatedDate) + // "; + //echo $sql; + $sql="select dat as CreatedDate,materialrcvddate,sum(quantity)as quantity,sum(value) as value,materialrcvddate + from year_inward + where status != 'ST030' and date(materialrcvddate) >= '$a-04-01' and date(materialrcvddate) <= '$b-03-31' + group by month(materialrcvddate)"; + $query = $this->db->query($sql); + return $query->result(); + + + + } + + function ireport_month_wise($mont){ + $month= date("m",strtotime($mont)); + $year = date("Y",strtotime($mont)); + + // $sql="select sid,mid,supplier_name,material_name,sum(quantity)as quantity,sum(value) as total + // from year_inward + // where status != 'ST030' and month(dat)= ? and year(dat) = ? + // group by material_name,supplier_name"; + $sql="select sid,mid,supplier_name,material_name,sum(quantity)as quantity,sum(value) as total,materialrcvddate + from year_inward + where status != 'ST030' and month(materialrcvddate)= ? and year(materialrcvddate) = ? + group by material_name,supplier_name"; + $query = $this->db->query($sql,array($month,$year)); + return $query->result(); + } + function ireport_year_wise_total($a,$b){ + + // $sql="select sid,mid,supplier_name,material_name,sum(quantity)as quantity,sum(value) as total + // from year_inward + // where status != 'ST030' and date(dat) >= '$a-04-01' and date(dat) <= '$b-03-31' + // group by material_name,supplier_name"; + $sql="select sid,mid,supplier_name,material_name,sum(quantity)as quantity,sum(value) as total,materialrcvddate + from year_inward + where status != 'ST030' and date(materialrcvddate) >= '$a-04-01' and date(materialrcvddate) <= '$b-03-31' + group by material_name,supplier_name"; + $query = $this->db->query($sql,array()); + return $query->result(); + } + + function ireport_supplier($cname,$fa,$aa,$m,$frm,$t){ + + + $sql="SELECT sd.SupplierID as sid,sd.SupplierName as supplier_name,count(im.PONO) as counts,ifnull(sum(id.QuantityAsPerInvoice),0) as quantity,round(ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0),2) as value, + + case pm.POType + when 'IMPORT' + then ifnull((sum((id.QuantityAsPerInvoice * pl.Rate) * pm.ExchangeRate) + + ifnull(rt.Insurance,0) + + ),0) + when 'CAPITAL' + then sum( if(pm.CapitalRange=0,(( id.QuantityAsPerInvoice * pl.Rate) * pm.ExchangeRate),( id.QuantityAsPerInvoice * pl.Rate) + - st.Afterdiscountval)) + + ifnull(sum(st.After_SGST),0) + + ifnull(sum(st.After_CGST),0) + + ifnull(sum(st.After_IGST),0) + + ifnull(sum(st.AfterFreightValue),0) + + ifnull(rt.Insurance,0) + + + when 'SERVICE' + then ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0) + + ifnull(sum(st.After_SGST),0) + + ifnull(sum(st.After_CGST),0) + + ifnull(sum(st.After_IGST),0) + + ifnull(sum(st.AfterFreightValue),0) + + ifnull(rt.Insurance,0) + - ifnull(sum(st.Afterdiscountval),0) + + when 'REVENUE' + then ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0) + - ifnull(sum(rt.AfterDiscount),0) + + ifnull(sum(rt.AfterSGST),0) + + ifnull(sum(rt.AfterCGST),0) + + ifnull(sum(rt.AfterIGST),0) + + ifnull(sum(rt.AfterFreightValue),0) + + ifnull(sum(rt.AfterPackagingValue),0) + + ifnull(rt.Insurance,0) + + end + as total,im.MaterialRcvdDate + from T_IGR_Master im + join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode @@ -1763,359 +1828,367 @@ join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo left join T_PurchaseOrder_BillUpload pb on pb.IGRNO=im.IGRNO where pm.Status != 'ST030'"; - -if ($cname!= ''){ - - $sql.="and sd.SupplierName = '".$cname."'"; + + if ($cname!= ''){ + + $sql.="and sd.SupplierName = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + $sql.=" and (im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')"; + + } + if ($m!= ''){ + + //$sql.="and monthname(im.CreatedDate) = '".$m."'"; + $sql.="and monthname(im.MaterialRcvdDate) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromd= date("Y-m-d",strtotime($frm)); + $tod=date("Y-m-d",strtotime($t)); + + // $sql.="and date(im.CreatedDate) >= '".$fromd."' + // and date(im.CreatedDate) <= '".$tod."'"; + $sql.="and date(im.MaterialRcvdDate) >= '".$fromd."' + and date(im.MaterialRcvdDate) <= '".$tod."'"; + + } + $sql.= "group by supplier_name"; + //echo $sql; + $query = $this->db->query($sql); + return $query->result(); - } + } + function ireport_consolidate($cname,$fa,$aa){ + + + $sql="select sid,mid,supplier_name,material_name, + SUM(IF(month(dat) = 4, quantity, 0)) AS April, + SUM(IF(month(dat) = 5, quantity, 0)) AS May, + SUM(IF(month(dat) = 6, quantity, 0)) AS June, + SUM(IF(month(dat) = 7, quantity, 0)) AS July, + SUM(IF(month(dat) = 8, quantity, 0)) AS August, + SUM(IF(month(dat) = 9, quantity, 0)) AS September, + SUM(IF(month(dat) = 10, quantity, 0)) AS October, + SUM(IF(month(dat) = 11, quantity, 0)) AS November, + SUM(IF(month(dat) = 12, quantity, 0)) AS December, + SUM(IF(month(dat) = 1, quantity, 0)) AS January, + SUM(IF(month(dat) = 2, quantity, 0)) AS February, + SUM(IF(month(dat) = 3, quantity, 0)) AS March, + sum(quantity) as qtotal, + SUM(IF(month(dat) = 4, value, 0)) AS vApril, + SUM(IF(month(dat) = 5, value, 0)) AS vMay, + SUM(IF(month(dat) = 6, value, 0)) AS vJune, + SUM(IF(month(dat) = 7, value, 0)) AS vJuly, + SUM(IF(month(dat) = 8, value, 0)) AS vAugust, + SUM(IF(month(dat) = 9, value, 0)) AS vSeptember, + SUM(IF(month(dat) = 10, value, 0)) AS vOctober, + SUM(IF(month(dat) = 11, value, 0)) AS vNovember, + SUM(IF(month(dat) = 12, value, 0)) AS vDecember, + SUM(IF(month(dat) = 1, value, 0)) AS vJanuary, + SUM(IF(month(dat) = 2, value, 0)) AS vFebruary, + SUM(IF(month(dat) = 3, value, 0)) AS vMarch, + sum(value) as vtotal + FROM year_inward + where status != 'ST030' "; + + if ($cname!= ''){ + + $sql.="and supplier_name = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + // $sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; + $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')"; + + } + + $sql.= "group by supplier_name,material_name"; + // echo $sql; + $query = $this->db->query($sql); + return $query->result(); - - - if ($fa and $aa != ''){ - - $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(im.CreatedDate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(im.CreatedDate) >= '".$fromd."' - and date(im.CreatedDate) <= '".$tod."'"; - - } - $sql.= "group by supplier_name"; - //echo $sql; - $query = $this->db->query($sql); - return $query->result(); - + } + function i_consolidate_month($m=null,$sid=null,$mid=null,$fa=null,$aa=null){ + + $sql="select sid,mid,supplier_name,material_name,sum(quantity) as quantity,sum(value) as total + from year_inward + where status != 'ST030' and + monthname(dat) = '".$m."' and sid = '".$sid."' and mid = '".$mid."' "; + if ($fa and $aa != ''){ + + //$sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; + $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')"; + + } + $sql.= "group by supplier_name,material_name"; + $query = $this->db->query($sql); + //echo $sql; + return $query->result(); } - function ireport_consolidate($cname,$fa,$aa){ - - - $sql="select sid,mid,supplier_name,material_name, -SUM(IF(month(dat) = 4, quantity, 0)) AS April, -SUM(IF(month(dat) = 5, quantity, 0)) AS May, -SUM(IF(month(dat) = 6, quantity, 0)) AS June, -SUM(IF(month(dat) = 7, quantity, 0)) AS July, -SUM(IF(month(dat) = 8, quantity, 0)) AS August, -SUM(IF(month(dat) = 9, quantity, 0)) AS September, -SUM(IF(month(dat) = 10, quantity, 0)) AS October, -SUM(IF(month(dat) = 11, quantity, 0)) AS November, -SUM(IF(month(dat) = 12, quantity, 0)) AS December, -SUM(IF(month(dat) = 1, quantity, 0)) AS January, -SUM(IF(month(dat) = 2, quantity, 0)) AS February, -SUM(IF(month(dat) = 3, quantity, 0)) AS March, -sum(quantity) as qtotal, -SUM(IF(month(dat) = 4, value, 0)) AS vApril, -SUM(IF(month(dat) = 5, value, 0)) AS vMay, -SUM(IF(month(dat) = 6, value, 0)) AS vJune, -SUM(IF(month(dat) = 7, value, 0)) AS vJuly, -SUM(IF(month(dat) = 8, value, 0)) AS vAugust, -SUM(IF(month(dat) = 9, value, 0)) AS vSeptember, -SUM(IF(month(dat) = 10, value, 0)) AS vOctober, -SUM(IF(month(dat) = 11, value, 0)) AS vNovember, -SUM(IF(month(dat) = 12, value, 0)) AS vDecember, -SUM(IF(month(dat) = 1, value, 0)) AS vJanuary, -SUM(IF(month(dat) = 2, value, 0)) AS vFebruary, -SUM(IF(month(dat) = 3, value, 0)) AS vMarch, -sum(value) as vtotal -FROM year_inward -where status != 'ST030' "; - -if ($cname!= ''){ - - $sql.="and supplier_name = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - $sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; - - } - - $sql.= "group by supplier_name,material_name"; - // echo $sql; - $query = $this->db->query($sql); - return $query->result(); - + function i_consolidate_year($sid=null,$mid=null,$fa=null,$aa=null){ + + $sql="select sid,mid,supplier_name,material_name,sum(quantity) as quantity,sum(value) as total + from year_inward + where status != 'ST030' and sid = '".$sid."' and mid = '".$mid."' "; + if ($fa and $aa != ''){ + + //$sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; + $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')"; + + } + $sql.= "group by supplier_name,material_name"; + $query = $this->db->query($sql); + //echo $sql; + return $query->result(); } - function i_consolidate_month($m=null,$sid=null,$mid=null,$fa=null,$aa=null){ - - $sql="select sid,mid,supplier_name,material_name,sum(quantity) as quantity,sum(value) as total -from year_inward -where status != 'ST030' and -monthname(dat) = '".$m."' and sid = '".$sid."' and mid = '".$mid."' "; -if ($fa and $aa != ''){ - - $sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; - - } - $sql.= "group by supplier_name,material_name"; - $query = $this->db->query($sql); - //echo $sql; - return $query->result(); - } - function i_consolidate_year($sid=null,$mid=null,$fa=null,$aa=null){ - - $sql="select sid,mid,supplier_name,material_name,sum(quantity) as quantity,sum(value) as total -from year_inward -where status != 'ST030' and sid = '".$sid."' and mid = '".$mid."' "; -if ($fa and $aa != ''){ - - $sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; - - } - $sql.= "group by supplier_name,material_name"; - $query = $this->db->query($sql); - //echo $sql; - return $query->result(); - } - function ireport_cumulative(){ - 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 year.sid as sid,year.mid as mid,year.supplier_name as supplier_name,year.material_name as material_name,year.quantity as quantity,year.total as total,month.mquantity as mquantity,month.mtotal as mtotal,today.tquantity as tquantity,today.ttotal as ttotal -FROM (SELECT sid,mid,supplier_name,material_name,sum(Quantity) as quantity,sum(value) as total -FROM year_inward -where status != 'ST030' and -(dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31') -group by supplier_name,material_name -) as year left join -(SELECT sid,mid,supplier_name,material_name,sum(Quantity) as mquantity,sum(value) as mtotal -FROM year_inward -where status != 'ST030' and -month(dat) = month(current_date()) -group by supplier_name,material_name -) as month on month.supplier_name=year.supplier_name and month.material_name=year.material_name -left join -(SELECT sid,mid,supplier_name,material_name,sum(Quantity) as tquantity,sum(value) as ttotal -FROM year_inward -where status != 'ST030' and -date(dat) = current_date() -group by supplier_name,material_name -) as today on today.supplier_name=month.supplier_name and today.material_name=month.material_name -group by supplier_name,material_name -"; - $query = $this->db->query($sql); - return $query->result(); - } - function ireport_cum_month($sup=null,$mat=null){ - - $sql="SELECT sid,mid,supplier_name,material_name,sum(Quantity) as tquantity,sum(value) as ttotal -FROM year_inward -where status != 'ST030' and -month(dat) = month(current_date()) and sid = '".$sup."' and mid = '".$mat."' -group by supplier_name,material_name"; - $query = $this->db->query($sql); - return $query->result(); - } - function ireport_cum_year($sup=null,$mat=null){ - 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 sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal -FROM year_inward -where status != 'ST030' and -(dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31') - and sid = '".$sup."' and mid= '".$mat."' -group by supplier_name,material_name -"; - $query = $this->db->query($sql); - return $query->result(); - } - function ireport_cum_day($sup=null,$mat=null){ - - $sql="SELECT sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal -FROM year_inward -where status != 'ST030' and -date(dat) = current_date() and sid = '".$sup."' and mid = '".$mat."' -group by supplier_name,material_name"; - $query = $this->db->query($sql); - return $query->result(); - } - function rawi_report_cumulative(){ - 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 year.category as category,year.quantity as quantity,year.total as total,month.mquantity as mquantity,month.mtotal as mtotal,today.tquantity as tquantity,today.ttotal as ttotal -FROM (SELECT category,sum(Quantity) as quantity,sum(value) as total -FROM year_inward -where status != 'ST030' and -(dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31') -group by category -) as year left join -(SELECT category,sum(Quantity) as mquantity,sum(value) as mtotal -FROM year_inward -where status != 'ST030' and -month(dat) = month(current_date()) -group by category -) as month on month.category=year.category -left join -(SELECT category,sum(Quantity) as tquantity,sum(value) as ttotal -FROM year_inward -where status != 'ST030' and -date(dat) = current_date() -group by category -) as today on today.category=month.category -group by category "; - $query = $this->db->query($sql); - return $query->result(); - } - function rawi_report_cum_year($cat=null){ - 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 category,sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal -FROM year_inward -where status != 'ST030' and -(dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31') - and category = '".$cat."' -group by supplier_name,material_name"; - $query = $this->db->query($sql); - //echo $sql; - return $query->result(); - } - function rawi_report_cum_month($cat=null){ - - $sql="SELECT category,sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal -FROM year_inward -where status != 'ST030' and -month(dat) = month(current_date()) and category = '".$cat."' -group by supplier_name,material_name"; - $query = $this->db->query($sql); - return $query->result(); - } - function rawi_report_cum_day($cat=null){ - - $sql="SELECT category,sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal -FROM year_inward -where status != 'ST030' and -date(dat) = current_date() and category = '".$cat."' -group by supplier_name,material_name"; - $query = $this->db->query($sql); - //echo $sql; - return $query->result(); - } - function rawi_report_consolidate($cname,$fa,$aa){ - - - $sql="select sid,mid,category,supplier_name,material_name, -SUM(IF(month(dat) = 4, quantity, 0)) AS April, -SUM(IF(month(dat) = 5, quantity, 0)) AS May, -SUM(IF(month(dat) = 6, quantity, 0)) AS June, -SUM(IF(month(dat) = 7, quantity, 0)) AS July, -SUM(IF(month(dat) = 8, quantity, 0)) AS August, -SUM(IF(month(dat) = 9, quantity, 0)) AS September, -SUM(IF(month(dat) = 10, quantity, 0)) AS October, -SUM(IF(month(dat) = 11, quantity, 0)) AS November, -SUM(IF(month(dat) = 12, quantity, 0)) AS December, -SUM(IF(month(dat) = 1, quantity, 0)) AS January, -SUM(IF(month(dat) = 2, quantity, 0)) AS February, -SUM(IF(month(dat) = 3, quantity, 0)) AS March, -sum(quantity) as qtotal, -SUM(IF(month(dat) = 4, value, 0)) AS vApril, -SUM(IF(month(dat) = 5, value, 0)) AS vMay, -SUM(IF(month(dat) = 6, value, 0)) AS vJune, -SUM(IF(month(dat) = 7, value, 0)) AS vJuly, -SUM(IF(month(dat) = 8, value, 0)) AS vAugust, -SUM(IF(month(dat) = 9, value, 0)) AS vSeptember, -SUM(IF(month(dat) = 10, value, 0)) AS vOctober, -SUM(IF(month(dat) = 11, value, 0)) AS vNovember, -SUM(IF(month(dat) = 12, value, 0)) AS vDecember, -SUM(IF(month(dat) = 1, value, 0)) AS vJanuary, -SUM(IF(month(dat) = 2, value, 0)) AS vFebruary, -SUM(IF(month(dat) = 3, value, 0)) AS vMarch, -sum(value) as vtotal -FROM year_inward -where status != 'ST030' "; - -if ($cname!= ''){ - - $sql.="and Category = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - $sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; - - } - - $sql.= "group by category"; - //echo $sql; - $query = $this->db->query($sql); - return $query->result(); - + function ireport_cumulative(){ + 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 year.sid as sid,year.mid as mid,year.supplier_name as supplier_name,year.material_name as material_name,year.quantity as quantity,year.total as total,month.mquantity as mquantity,month.mtotal as mtotal,today.tquantity as tquantity,today.ttotal as ttotal + FROM (SELECT sid,mid,supplier_name,material_name,sum(Quantity) as quantity,sum(value) as total,materialrcvddate + FROM year_inward + where status != 'ST030' and + (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31') + group by supplier_name,material_name + ) as year left join + (SELECT sid,mid,supplier_name,material_name,sum(Quantity) as mquantity,sum(value) as mtotal + FROM year_inward + where status != 'ST030' and + month(materialrcvddate) = month(current_date()) + group by supplier_name,material_name + ) as month on month.supplier_name=year.supplier_name and month.material_name=year.material_name + left join + (SELECT sid,mid,supplier_name,material_name,sum(Quantity) as tquantity,sum(value) as ttotal + FROM year_inward + where status != 'ST030' and + date(materialrcvddate) = current_date() + group by supplier_name,material_name + ) as today on today.supplier_name=month.supplier_name and today.material_name=month.material_name + group by supplier_name,material_name + "; + $query = $this->db->query($sql); + return $query->result(); } - function rawi_consolidate_month($m=null,$cat=null,$sup=null,$fa=null,$aa=null){ + function ireport_cum_month($sup=null,$mat=null){ + + $sql="SELECT sid,mid,supplier_name,material_name,sum(Quantity) as tquantity,sum(value) as ttotal + FROM year_inward + where status != 'ST030' and + month(materialrcvddate) = month(current_date()) and sid = '".$sup."' and mid = '".$mat."' + group by supplier_name,material_name"; + $query = $this->db->query($sql); + return $query->result(); + } + function ireport_cum_year($sup=null,$mat=null){ + 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 sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal + FROM year_inward + where status != 'ST030' and + (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31') + and sid = '".$sup."' and mid= '".$mat."' + group by supplier_name,material_name + "; + $query = $this->db->query($sql); + return $query->result(); + } + function ireport_cum_day($sup=null,$mat=null){ + + $sql="SELECT sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal + FROM year_inward + where status != 'ST030' and + date(materialrcvddate) = current_date() and sid = '".$sup."' and mid = '".$mat."' + group by supplier_name,material_name"; + $query = $this->db->query($sql); + return $query->result(); + } + function rawi_report_cumulative(){ + 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 year.category as category,year.quantity as quantity,year.total as total,month.mquantity as mquantity,month.mtotal as mtotal,today.tquantity as tquantity,today.ttotal as ttotal + FROM (SELECT category,sum(Quantity) as quantity,sum(value) as total + FROM year_inward + where status != 'ST030' and + (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31') + group by category + ) as year left join + (SELECT category,sum(Quantity) as mquantity,sum(value) as mtotal + FROM year_inward + where status != 'ST030' and + month(materialrcvddate) = month(current_date()) + group by category + ) as month on month.category=year.category + left join + (SELECT category,sum(Quantity) as tquantity,sum(value) as ttotal + FROM year_inward + where status != 'ST030' and + date(materialrcvddate) = current_date() + group by category + ) as today on today.category=month.category + group by category "; + $query = $this->db->query($sql); + return $query->result(); + } + function rawi_report_cum_year($cat=null){ + 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 category,sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal + FROM year_inward + where status != 'ST030' and + (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31') + and category = '".$cat."' + group by supplier_name,material_name"; + $query = $this->db->query($sql); + //echo $sql; + return $query->result(); + } + function rawi_report_cum_month($cat=null){ + + $sql="SELECT category,sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal + FROM year_inward + where status != 'ST030' and + month(materialrcvddate) = month(current_date()) and category = '".$cat."' + group by supplier_name,material_name"; + $query = $this->db->query($sql); + return $query->result(); + } + function rawi_report_cum_day($cat=null){ + + $sql="SELECT category,sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal + FROM year_inward + where status != 'ST030' and + date(materialrcvddate) = current_date() and category = '".$cat."' + group by supplier_name,material_name"; + $query = $this->db->query($sql); + //echo $sql; + return $query->result(); + } + function rawi_report_consolidate($cname,$fa,$aa){ + + + $sql="select sid,mid,category,supplier_name,material_name, + SUM(IF(month(dat) = 4, quantity, 0)) AS April, + SUM(IF(month(dat) = 5, quantity, 0)) AS May, + SUM(IF(month(dat) = 6, quantity, 0)) AS June, + SUM(IF(month(dat) = 7, quantity, 0)) AS July, + SUM(IF(month(dat) = 8, quantity, 0)) AS August, + SUM(IF(month(dat) = 9, quantity, 0)) AS September, + SUM(IF(month(dat) = 10, quantity, 0)) AS October, + SUM(IF(month(dat) = 11, quantity, 0)) AS November, + SUM(IF(month(dat) = 12, quantity, 0)) AS December, + SUM(IF(month(dat) = 1, quantity, 0)) AS January, + SUM(IF(month(dat) = 2, quantity, 0)) AS February, + SUM(IF(month(dat) = 3, quantity, 0)) AS March, + sum(quantity) as qtotal, + SUM(IF(month(dat) = 4, value, 0)) AS vApril, + SUM(IF(month(dat) = 5, value, 0)) AS vMay, + SUM(IF(month(dat) = 6, value, 0)) AS vJune, + SUM(IF(month(dat) = 7, value, 0)) AS vJuly, + SUM(IF(month(dat) = 8, value, 0)) AS vAugust, + SUM(IF(month(dat) = 9, value, 0)) AS vSeptember, + SUM(IF(month(dat) = 10, value, 0)) AS vOctober, + SUM(IF(month(dat) = 11, value, 0)) AS vNovember, + SUM(IF(month(dat) = 12, value, 0)) AS vDecember, + SUM(IF(month(dat) = 1, value, 0)) AS vJanuary, + SUM(IF(month(dat) = 2, value, 0)) AS vFebruary, + SUM(IF(month(dat) = 3, value, 0)) AS vMarch, + sum(value) as vtotal + FROM year_inward + where status != 'ST030' "; + + if ($cname!= ''){ + + $sql.="and Category = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + //$sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; + $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')"; + + } + + $sql.= "group by category"; + //echo $sql; + $query = $this->db->query($sql); + return $query->result(); - $sql="select category,sid,supplier_name,mid,material_name, -sum(Quantity) as quantity, -sum(value) as total -FROM year_inward -where status != 'ST030' and -monthname(dat) = '".$m."' and category = '".$cat."' "; -if ($fa and $aa != ''){ - - $sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$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,$fa=null,$aa=null){ - - $sql="select category,sid,supplier_name,mid,material_name, -sum(Quantity) as quantity, -sum(value) as total -FROM year_inward -where status != 'ST030' and -category = '".$cat."' "; -if ($fa and $aa != ''){ - - $sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; - - } - $sql.= "group by category,supplier_name,material_name"; - $query = $this->db->query($sql); - //echo $sql; - return $query->result(); - } + } + function rawi_consolidate_month($m=null,$cat=null,$sup=null,$fa=null,$aa=null){ + + $sql="select category,sid,supplier_name,mid,material_name, + sum(Quantity) as quantity, + sum(value) as total + FROM year_inward + where status != 'ST030' and + monthname(materialrcvddate) = '".$m."' and category = '".$cat."' "; + if ($fa and $aa != ''){ + + $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$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,$fa=null,$aa=null){ + + $sql="select category,sid,supplier_name,mid,material_name, + sum(Quantity) as quantity, + sum(value) as total + FROM year_inward + where status != 'ST030' and + category = '".$cat."' "; + if ($fa and $aa != ''){ + + $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$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 @@ -2335,7 +2408,7 @@ function getDailyOpeningAmt($yesterday){ } - function departmentwise($sid='',$d='',$c='') + function departmentwise($sid,$d,$c='',$fy,$ty) { $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, ifnull(case @@ -2356,13 +2429,23 @@ function getDailyOpeningAmt($yesterday){ end, '-') as receiptname, 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'"; + WHERE tinc.type='$c'"; + if ($sid != ''){ + $sql.="and account_code = '".$sid."'"; + } + if ($d != ''){ + $sql.="and monthname(date)='".$d."'"; + } + if ($fy and $ty != ''){ + + $sql.=" and (tinc.date >= '".$fy."-04-01' and tinc.date <= '".$ty."-03-31')"; + + } + // -- WHERE account_code = '$sid' and monthname(date)='$d' and tinc.type='$c'"; $query = $this->db->query($sql); - //print_r($this->db->last_query()); - //echo $sql; return $query->result(); - } + } //yearwise/month// function yearmonthwise($sid='') { @@ -2580,5 +2663,118 @@ function INRSymbol() } + function report_cumulative_cashbook(){ + + 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 year.name as name,year.yearexpense as yexp,year.yearincome as yinc,month.monthexpense as mexp,month.monthincome as minc,today.todayexpense as texp,today.todayincome as tinc + FROM (select ac1.name, ifnull(case + when tinc1.type = 'PAYMENT' + then sum(tinc1.total) + end,'0') as yearexpense, + ifnull(case + when tinc1.type = 'RECEIPT' + then sum(tinc1.total) + end, '0') as yearincome + FROM t_income_expense tinc1 + join t_accountcode ac1 on ac1.code = tinc1.account_code + WHERE (tinc1.date >= '".$fa."-04-01' and tinc1.date <= '".$aa."-03-31') + group by ac1.name ) as year + left join + (select ac2.name ,ifnull(case + when tinc2.type = 'PAYMENT' + then sum(tinc2.total) + end,'0') as monthexpense, + ifnull(case + when tinc2.type = 'RECEIPT' + then sum(tinc2.total) + end, '0') as monthincome + FROM t_income_expense tinc2 + join t_accountcode ac2 on ac2.code = tinc2.account_code + where month(tinc2.date) = month(current_date()) + group by ac2.name) as month on month.name = year.name + left join + (select ac3.name ,ifnull(case + when tinc3.type = 'PAYMENT' + then sum(tinc3.total) + end,'0') as todayexpense, + ifnull(case + when tinc3.type = 'RECEIPT' + then sum(tinc3.total) + end, '0') as todayincome + FROM t_income_expense tinc3 + join t_accountcode ac3 on ac3.code = tinc3.account_code + where date(tinc3.date) = current_date() + group by ac3.name ) as today on today.name=month.name + group by name "; + $query = $this->db->query($sql); + return $query->result(); + } + + function report_cumulative_month_cashbook($cname,$yr1,$yr2){ + + if ($yr1 == '' && $yr2 == ''){ + 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); + } + else{ + $fa=$yr1; + $aa=$yr2; + } + + $sql = "select tinc.account_code,ac.name,tinc.type, + SUM(IF(month(tinc.date) = 4, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS AprilExpense, + SUM(IF(month(tinc.date) = 4, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS AprilIncome, + SUM(IF(month(tinc.date) = 5, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS MayExpense, + SUM(IF(month(tinc.date) = 5, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS MayIncome, + SUM(IF(month(tinc.date) = 6, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS JuneExpense, + SUM(IF(month(tinc.date) = 6, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS JuneIncome, + SUM(IF(month(tinc.date) = 7, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS JulyExpense, + SUM(IF(month(tinc.date) = 7, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS JulyIncome, + SUM(IF(month(tinc.date) = 8, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS AugustExpense, + SUM(IF(month(tinc.date) = 8, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS AugustIncome, + SUM(IF(month(tinc.date) = 9, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS SepExpense, + SUM(IF(month(tinc.date) = 9, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS SepIncome, + SUM(IF(month(tinc.date) = 10, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS OctExpense, + SUM(IF(month(tinc.date) = 10, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS OctIncome, + SUM(IF(month(tinc.date) = 11, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS NovExpense, + SUM(IF(month(tinc.date) = 11, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS NovIncome, + SUM(IF(month(tinc.date) = 12, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS DecExpense, + SUM(IF(month(tinc.date) = 12, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS DecIncome, + SUM(IF(month(tinc.date) = 1, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS JanExpense, + SUM(IF(month(tinc.date) = 1, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS JanIncome, + SUM(IF(month(tinc.date) = 2, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS FebExpense, + SUM(IF(month(tinc.date) = 2, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS FebIncome, + SUM(IF(month(tinc.date) = 3, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS MarExpense, + SUM(IF(month(tinc.date) = 3, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS MarIncome, + SUM(IF(tinc.type = 'RECEIPT', tinc.total, 0)) AS receiptoverall, + SUM(IF(tinc.type = 'PAYMENT', tinc.total, 0)) AS paymentoverall, + SUM(tinc.total) as overalltotal + from t_income_expense tinc + join t_accountcode ac on ac.code = tinc.account_code + where (tinc.date >='".$fa."-04-01' and tinc.date <= '".$aa."-03-31')"; + if ($cname!= ''){ + $sql.="and ac.name = '".$cname."'"; + } + $sql.= " group by tinc.account_code"; + $query = $this->db->query($sql); + return $query->result(); + + } + } ?> \ No newline at end of file diff --git a/application/models/inwardgateregister_model.php b/application/models/inwardgateregister_model.php index c0be934f..896c5990 100644 --- a/application/models/inwardgateregister_model.php +++ b/application/models/inwardgateregister_model.php @@ -199,4 +199,18 @@ class inwardgateregister_model extends CI_Model $result = $query->result(); return $result; } + + /** + * To Update IGR master details for material recieved data and delivery ch date + * @param number $IGRNo : This is igr no + * @return array $igrarr : Igr Array + */ + function updateigr($igrarr,$IGRNo){ + + //$this->db->where('PONO',$PONO); + $this->db->where('IGRNO',$IGRNo); + $this->db->update('T_IGR_Master',$igrarr); + $r = $this->db->affected_rows(); + return $r; + } } \ No newline at end of file diff --git a/application/views/Report_Material_Master_ReceiptValue.php b/application/views/Report_Material_Master_ReceiptValue.php index a42463e7..c78f90a5 100755 --- a/application/views/Report_Material_Master_ReceiptValue.php +++ b/application/views/Report_Material_Master_ReceiptValue.php @@ -1,12 +1,4 @@ - - - -
+ + + +

@@ -53,7 +45,7 @@ if(!empty($mms)) Supplier Name Material Name Quantity - Total Value  ( ) + Total Value  (₹) @@ -148,6 +140,9 @@ if(!empty($mms)) // Set up your table $(document).ready(function() { table = $('#cc').DataTable( { + "language": { + "emptyTable": "
Data Not Found !
" + }, "dom": "<'row'<'col-md-6'l><'col-md-6'Bf>>" + "<'row'<'col-md-6'><'col-md-6'>>" + "<'row'<'col-md-12't>><'row'<'col-md-4'i><'col-md-8'p>>", @@ -165,7 +160,36 @@ $(document).ready(function() { }, 'colvis' - ] + ], + "footerCallback": function ( row, data, start, end, display ) { + var api = this.api(), data; + + // Remove the formatting to get integer data for summation + var intVal = function ( i ) { + return typeof i === 'string' ? + parseFloat(i.replace(/[^0.00-9.00]+/g,"")*1) : + typeof i === 'number' ? + parseFloat(i) : 0; + }; + + TotalQTY = api + .column( 2, { search:'applied' } ) + .data() + .reduce( function (a, b) { + return intVal(a) + intVal(b); + }, 0 ); + + $( api.column( 2 ).footer() ).html( TotalQTY.toFixed().bold() ); + + TotalVALUE = api + .column( 3, { search:'applied' } ) + .data() + .reduce( function (a, b) { + return intVal(a) + intVal(b); + }, 0 ); + + $( api.column( 3 ).footer() ).html( TotalVALUE.toFixed(2).bold() ); + } } ); } ); $('#mySelect').on('change',function(){ diff --git a/application/views/Report_month_wise_inward.php b/application/views/Report_month_wise_inward.php index 88cfb412..7f42b136 100755 --- a/application/views/Report_month_wise_inward.php +++ b/application/views/Report_month_wise_inward.php @@ -1,12 +1,3 @@ - - - - + +
+
+
+
+
+
+

Cashbook - Cumulative Monthwise Report + + input->post('client_name')){ + $cl=$this->input->post('client_name'); + echo '('.$cl.')'; + } + if($this->input->post('financialyear')){ + $ab=$this->input->post('financialyear'); + echo '('.$ab.')'; + } + ?>

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

+ +
+
+
+ + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Account NameAprilMayJuneJulyAugustSeptemberOctoberNovemberDecemberJanuaryFebruaryMarchTotal
Receipt  (₹)Payment  (₹)Receipt  (₹)Payment  (₹)Recepit  (₹)Payment  (₹)Receipt  (₹)Payment  (₹)Receipt  (₹)Payment  (₹)Recepit  (₹)Payment  (₹)Receipt  (₹)Payment  (₹)Receipt  (₹)Payment  (₹)Recepit  (₹)Payment  (₹)Receipt  (₹)Payment  (₹)Receipt  (₹)Payment  (₹)Recepit  (₹)Payment  (₹)Recepit  (₹)Payment  (₹)
name; ?>AprilIncome,2,'.',''); echo number_format($d->AprilIncome,2,'.',''); ?>AprilExpense,2,'.',''); echo number_format($d->AprilExpense,2,'.',''); ?>MayIncome,2,'.',''); echo number_format($d->MayIncome,2,'.',''); ?>MayExpense,2,'.',''); echo number_format($d->MayExpense,2,'.',''); ?>JuneIncome,2,'.',''); echo number_format($d->JuneIncome,2,'.',''); ?>JuneExpense,2,'.',''); echo number_format($d->JuneExpense,2,'.',''); ?>JulyIncome,2,'.',''); echo number_format($d->JulyIncome,2,'.',''); ?>JulyExpense,2,'.',''); echo number_format($d->JulyExpense,2,'.',''); ?>AugustIncome,2,'.',''); echo number_format($d->AugustIncome,2,'.',''); ?>AugustExpense,2,'.',''); echo number_format($d->AugustExpense,2,'.',''); ?>SepIncome,2,'.',''); echo number_format($d->SepIncome,2,'.',''); ?>SepExpense,2,'.',''); echo number_format($d->SepExpense,2,'.',''); ?>OctIncome,2,'.',''); echo number_format($d->OctIncome,2,'.',''); ?>OctExpense,2,'.',''); echo number_format($d->OctExpense,2,'.',''); ?>NovIncome,2,'.',''); echo number_format($d->NovIncome,2,'.',''); ?>NovExpense,2,'.',''); echo number_format($d->NovExpense,2,'.',''); ?>DecIncome,2,'.',''); echo number_format($d->DecIncome,2,'.',''); ?>DecExpense,2,'.',''); echo number_format($d->DecExpense,2,'.',''); ?>JanIncome,2,'.',''); echo number_format($d->JanIncome,2,'.',''); ?>JanExpense,2,'.',''); echo number_format($d->JanExpense,2,'.',''); ?>FebIncome,2,'.',''); echo number_format($d->FebIncome,2,'.',''); ?>FebExpense,2,'.',''); echo number_format($d->FebExpense,2,'.',''); ?>MarIncome,2,'.',''); echo number_format($d->MarIncome,2,'.',''); ?>MarExpense,2,'.',''); echo number_format($d->MarExpense,2,'.',''); ?>receiptoverall,2,'.',''); echo number_format($d->receiptoverall,2,'.',''); ?>paymentoverall,2,'.',''); echo number_format($d->paymentoverall,2,'.',''); ?>
+
+
+
+
+
+
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/application/views/cashbook_cumulative_report.php b/application/views/cashbook_cumulative_report.php new file mode 100755 index 00000000..f2026e1e --- /dev/null +++ b/application/views/cashbook_cumulative_report.php @@ -0,0 +1,227 @@ += 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); +?> + + +
+
+
+ +
+ +
+
+

Cashbook - Cumulative Report ( )

+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Account Name
Receipt  (₹)Payment  (₹)Receipt  (₹)Payment  (₹)Recepit  (₹)Payment  (₹)
name; ?>tinc)){ echo '0';}else{$incdayttl = $incdayttl + round($d->tinc); echo number_format($d->tinc,2,'.','');} ?>texp)){ echo '0';}else{$expdayttl = $expdayttl + round($d->texp); echo number_format($d->texp,2,'.','');} ?>minc); echo number_format($d->minc,2,'.',''); ?>mexp); echo number_format($d->mexp,2,'.',''); ?>yinc); echo number_format($d->yinc,2,'.',''); ?>yexp); echo number_format($d->yexp,2,'.',''); ?>
+
+
+ +
+ +
+
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/application/views/cashbookmthlypaydep.php b/application/views/cashbookmthlypaydep.php index d3b40383..a8a2841c 100755 --- a/application/views/cashbookmthlypaydep.php +++ b/application/views/cashbookmthlypaydep.php @@ -48,7 +48,7 @@ if(!empty($departmentwise))
-

Report (DEP:)

+

Report (DEP:)

@@ -135,6 +135,7 @@ if(!empty($departmentwise)) + - + \ No newline at end of file diff --git a/application/views/report_emp.php b/application/views/report_emp.php index 3522a731..b485e2e5 100755 --- a/application/views/report_emp.php +++ b/application/views/report_emp.php @@ -1,8 +1,5 @@ - +

- -

+

@@ -56,8 +49,6 @@ Supplier Name Invoice No Date of Invoice - Material Name - Advice Quantity Vechicle No Courier No Action @@ -76,22 +67,18 @@ ?> - IGRItemNo ?>" > IGRNO ?> PONO ?> SupplierName ?> DeliveryChellanOrInvoiceNo ?> DeliveryChellanDate); - echo $date->format('d-m-Y'); ?> - MaterialName ?> - QuantityAsPerInvoice ?> - + echo $date->format('d-m-Y'); ?> VehicleNo ?> CourierNo ?> + -
@@ -223,6 +215,7 @@
@@ -230,31 +223,13 @@
- - - - - - - - - + - + + +$('#update').click(function(){ + //alert('updated function entered'); + $('#content').loader('show'); + var igrno = $("#IGRNO1").val(); + var materialrcv_date = $("#MaterialRcvdDate").val(); + var inv_date = $("#Invoice_Date").val(); + + $.ajax({ + data:{igr:igrno,mrc:materialrcv_date,invdate:inv_date}, + type:"POST", + url:"inwardgateregister/UpdateIGR", + success:function(data) { + $('#content').loader('hide'); + alert(data); + } + }); +}); + \ No newline at end of file