diff --git a/application/controllers/cashbook.php b/application/controllers/cashbook.php index df8d8e9f..970e4366 100644 --- a/application/controllers/cashbook.php +++ b/application/controllers/cashbook.php @@ -1002,11 +1002,11 @@ class cashbook extends BaseController //$data['bankid'] = $_GET['d']; $data['bankdepitpaid'] = $this->cashbook_model->debitbankstatemet($Supplierid,$fdate,$tdate); } - else - { - $data['bankdepitpaid'] = $this->cashbook_model->debitbankstatemet1(); - //print_r($data['bankdepit']); - } + // else + // { + // $data['bankdepitpaid'] = $this->cashbook_model->debitbankstatemet1(); + // //print_r($data['bankdepit']); + // } $data['getsupplier'] = $this->cashbook_model->getsupplier(); $this->loadViews("bankdebit",$this->global,$data,NULL); //die(); @@ -1021,6 +1021,8 @@ class cashbook extends BaseController $fdate = $this->input->post('from_date'); $tdate = $this->input->post('to_date'); $data['bankinvoicedata'] = $this->cashbook_model->bankinvoice($Customer,$fdate,$tdate); + // $data['bankreceivedamount']= $this->cashbook_model->receivedamount($Customer,$fdate,$tdate); + // print_r($data['bankreceivedamount']); //$data['supplier'] = $this->cashbook_model->getsupplier(); } $data['getcustomer'] = $this->cashbook_model->getcustomer(); @@ -1612,14 +1614,14 @@ class cashbook extends BaseController $data['bankdebitsupp'] = $this->cashbook_model->amountpaidsupplierwisefilter($fa,$aa,$m,$fdate,$tdate); $data['amountpaidcashbook']=$this->cashbook_model->amountpaidcashbookfilter($fa,$aa,$m,$fdate,$tdate); } - else - { + // else + // { - $data['bankdebitsupp'] = $this->cashbook_model->amountpaidsupplierwise(); + // $data['bankdebitsupp'] = $this->cashbook_model->amountpaidsupplierwise(); - $data['amountpaidcashbook']=$this->cashbook_model->amountpaidcashbook(); + // $data['amountpaidcashbook']=$this->cashbook_model->amountpaidcashbook(); - } + // } $data['finyear']=$this->cashbook_model->report_amountpaid(); $data['supplier'] = $this->cashbook_model->getsupplier(); $this->loadViews("bankpaidsupp", $this->global,$data, NULL); @@ -1890,14 +1892,20 @@ class cashbook extends BaseController $clearedbalance=$this->input->post('clearbalance'); $updateamount=$clearedbalance-$Amount; $updatebalancetoclear=$Amount+$balancetoclear; - $data['$bankmappingamount'] = $this->cashbook_model->gettotalbankmappingpo($igrno); + $data['$bankmappingamount'] = $this->cashbook_model->gettotalbankmappingpo($id); $amountpaid=$data['$bankmappingamount'][0]->Amountpaid; + $data['$bankmappingamountcount'] = $this->cashbook_model->gettotalbankmappingpocount($igrno); + $count= $data['$bankmappingamountcount'][0]->countAmountpaid; //$data['$totallineitemamount']=$this->cashbook_model->gettotallineitem($igrno); - if($amountpaid==$totalamount || $amountpaid!=$totalamount) + if($count==1) { $BankStatus=NO_PAIDIGR; } + else + { + $BankStatus=PARTIALLY_PAIDIGR; + } @@ -1910,54 +1918,81 @@ class cashbook extends BaseController //$updateamount=0; $IsActive=0; $result2= $this->cashbook_model->deleteBankmappingpo($id,$IsActive); - //for update mapping amount inT_Bankporeport table// - //die(); - $result3= $this->cashbook_model->updateBankporeportpo($igrno,$totalbalancetopay,$updatebankpoamount,$Bankid,$IsActive); + $data['$poreportamount'] = $this->cashbook_model->gettotalbankpoamount($igrno); + $amountpaidpo= $data['$poreportamount'][0]->Amountpaid; + $balancetopay= $data['$poreportamount'][0]->Balancetopay; + $amountpaidupdate=$amountpaidpo-$Amount; + $balancetopayupdate=$balancetopay+$Amount; + if($amountpaidupdate==0) + { + $IsAct=0; + } + else + { + $IsAct=1; + } + $result3= $this->cashbook_model->updateBankporeportpo($igrno,$balancetopayupdate,$amountpaidupdate,$Bankid,$IsAct); $this->loadViews("bankstatement", $this->global,$data, NULL); } - public function Deletemappingpo() +public function Deletemappingpo() { - $totalamount = $_GET['totalpoamount']; + $totalamount = $_GET['totalpoamount'];//totalpoamount $Bankid = $_GET['bankid']; - $Amount = $_GET['amount']; + $Amount = $_GET['amount'];//paid amount $igrno = $_GET['igrno']; $balancetoclear=$_GET['balancetoclear']; //for T_Bankreport IsActive// $bankdebit=$_GET['debit']; $mapped= $Amount+$balancetoclear; - - ///////////////// $id=$_GET['id']; - - $bankamount=$_GET['bankamount']; $updateamount=$bankamount-$Amount; $updatebalancetoclear=$Amount+$balancetoclear; - $data['$bankmappingamount'] = $this->cashbook_model->gettotalbankmappingpo($igrno); + $data['$bankmappingamount'] = $this->cashbook_model->gettotalbankmappingpo($id); $amountpaid=$data['$bankmappingamount'][0]->Amountpaid; - - + $data['$bankmappingamountcount'] = $this->cashbook_model->gettotalbankmappingpocount($igrno); + $count= $data['$bankmappingamountcount'][0]->countAmountpaid; + - if($amountpaid==$totalamount || $amountpaid!= $totalamount) + if($count==1) { $BankStatus=NO_PAIDIGR; } + else + { + $BankStatus=PARTIALLY_PAIDIGR; + } $result= $this->cashbook_model->IgrDetailsStatusUpdate($igrno,$BankStatus); $result1= $this->cashbook_model->deletemapping($Bankid,$updateamount,$updatebalancetoclear); - //for update mapping amount in t_bankmappingpo table// - $balancetopay=$_GET['balancetopay']; + //for update mapping amount in t_bankreport table// + $balancetopay=$_GET['balancetopay'];//balancetopay $totalbalancetopay=$Amount + $balancetopay; $IsActive=0; $updatebankpoamount=$totalamount-$totalbalancetopay; $result2= $this->cashbook_model->deleteBankmappingpo($id,$IsActive); - //for update mapping amount inT_Bankporeport table// - $result3= $this->cashbook_model->updateBankporeportpo($igrno,$totalbalancetopay,$updatebankpoamount,$Bankid,$IsActive); + //$result3= $this->cashbook_model->updatemappingamount($igrno,$amountpaid); + $data['$poreportamount'] = $this->cashbook_model->gettotalbankpoamount($igrno); + $amountpaidpo= $data['$poreportamount'][0]->Amountpaid; + $balancetopay= $data['$poreportamount'][0]->Balancetopay; + $amountpaidupdate=$amountpaidpo-$Amount; + $balancetopayupdate=$balancetopay+$Amount; + + //die(); + if($amountpaidupdate==0) + { + $IsAct=0; + } + else + { + $IsAct=1; + } + $result3= $this->cashbook_model->updateBankporeportpo($igrno,$balancetopayupdate,$amountpaidupdate,$Bankid,$IsAct); - if(count($result2)>0) + if(count($result3)>0) { redirect('Bankingstatement','refresh'); } @@ -1971,12 +2006,15 @@ class cashbook extends BaseController $invoiceno = $this->input->post('invoiceno'); $bankid = $this->input->post('bankid'); $mappingid=$this->input->post('mappingid'); + $amountreceived = $this->input->post('amountreceived'); $bankingclear = $this->input->post('bankingclear'); $bankingbalclear = $this->input->post('bankingbalclear'); $totinvoiceamount = $this->input->post('totinvoiceamount'); $balancetoreceived = $this->input->post('balancetoreceived'); + $updatebalancetoclear=$amountreceived+$bankingbalclear; + if($amountreceived<0) { $updateclearbalance=$bankingclear-($amountreceived);//450-(-250) @@ -2001,15 +2039,39 @@ class cashbook extends BaseController $bankstatement=array('cbalancetocleared'=>$updatebalancetoclear,'cclearbalance'=>$updateclearbalance,'IsActive'=>$active); $result1= $this->cashbook_model->updatebankreportiv($bankid,$bankstatement); - $receivedstatus=NO_RECEIVED; + - $IsActive=0; + + $data['$invoicereportamount'] = $this->cashbook_model->gettotalbankreceivedamount($invoiceno); + $amountreceivedinvoice= $data['$invoicereportamount'][0]->amountreceived; + $$balancetoreceived= $data['$invoicereportamount'][0]->balancetoreceived; + $amountreceivedupdate=$amountreceivedinvoice-$amountreceived; + $balancetoreceivedupdate=$balancetoreceived+$amountreceived; + if($amountreceivedupdate==0) + { + $IsAct=0; + } + else + { + $IsAct=1; + } - $updatebalancetoreceived=$balancetoreceived+$amountreceived; - $updateamountreceived=$totinvoiceamount-$updatebalancetoreceived; - $result3= $this->cashbook_model->updatebankinvoicereport($invoiceno,$bankid,$updatebalancetoreceived,$updateamountreceived,$IsActive); + // $updatebalancetoreceived=$balancetoreceived+$amountreceived; + // $updateamountreceived=$totinvoiceamount-$updatebalancetoreceived; + $result3= $this->cashbook_model->updatebankinvoicereport($invoiceno,$bankid,$balancetoreceivedupdate,$amountreceivedupdate,$IsAct); + $IsActive=0; if(count($result3)>0) { + $data['$bankreceivedamountcount'] = $this->cashbook_model->gettotalbankmappinginvoicecount($invoiceno); + $counting= $data['$bankreceivedamountcount'][0]->countamountreceived; + if($counting==1) + { + $receivedstatus=NO_RECEIVED; + } + else + { + $receivedstatus=PARTIALLY_RECEIVED; + } $result1=$this->cashbook_model->UpdateIpinvoiceStatus($invoiceno,$receivedstatus); $result2= $this->cashbook_model->deletemappinginvoice($mappingid,$IsActive); // if(count($result2)>0) diff --git a/application/models/cashbook_model.php b/application/models/cashbook_model.php index d3ffe397..5606a4a3 100644 --- a/application/models/cashbook_model.php +++ b/application/models/cashbook_model.php @@ -480,15 +480,16 @@ join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -left join T_Bankporeport br on br.IGRLineItemNo=id.IGRItemNo -where im.IGRStatus = 'ST027' and id.BankStatus!='ST070' "; +left join T_Bankporeport br on br.IGRLineItemNo=id.IGRItemNo and br.IsActive = 1 +where im.IGRStatus = 'ST027' and id.BankStatus!='ST070'"; -if ($Supplierid!= ''){ - +if ($Supplierid!= '') + { + $sql.="and sd.SupplierID = '".$Supplierid."'"; - } + } if ($fdate and $tdate != ''){ @@ -506,78 +507,78 @@ $sql.="group by id.IGRItemNo"; $query = $this->db->query($sql); return $query->result(); } - function debitbankstatemet1(){ + // function debitbankstatemet1(){ - $sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as PONO,im.IGRNO,id.IGRItemNo,im.MaterialRcvdDate as CreatedDate,br.Balancetopay,br.Amountpaid,sd.SupplierName as SupplierName,sd.SupplierID as SupplierID, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.SGST/100)), -(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.SGST /100))),0),2) as sgst, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.CGST/100)), -(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.CGST /100))),0),2) as cgst, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.IGST/100)), -(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.IGST /100))),0),2) as igst, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * pl.Rate)- (rt.AfterDiscount), -(id.QuantityAsPerInvoice * pl.Rate)- (st.Afterdiscountval)),0),2) as discount, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * pl.Rate) + (rt.AfterFreightValue), -(id.QuantityAsPerInvoice * pl.Rate) + (st.AfterFreightValue)),0),2) as freight, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * pl.Rate) +(rt.AfterPackagingValue),0),0),2) as Package, + // $sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as PONO,im.IGRNO,id.IGRItemNo,im.MaterialRcvdDate as CreatedDate,br.Balancetopay,br.Amountpaid,sd.SupplierName as SupplierName,sd.SupplierID as SupplierID, +// round(ifnull(if(POType = 'REVENUE', +// (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.SGST/100)), +// (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.SGST /100))),0),2) as sgst, +// round(ifnull(if(POType = 'REVENUE', +// (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.CGST/100)), +// (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.CGST /100))),0),2) as cgst, +// round(ifnull(if(POType = 'REVENUE', +// (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.IGST/100)), +// (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.IGST /100))),0),2) as igst, +// round(ifnull(if(POType = 'REVENUE', +// (id.QuantityAsPerInvoice * pl.Rate)- (rt.AfterDiscount), +// (id.QuantityAsPerInvoice * pl.Rate)- (st.Afterdiscountval)),0),2) as discount, +// round(ifnull(if(POType = 'REVENUE', +// (id.QuantityAsPerInvoice * pl.Rate) + (rt.AfterFreightValue), +// (id.QuantityAsPerInvoice * pl.Rate) + (st.AfterFreightValue)),0),2) as freight, +// round(ifnull(if(POType = 'REVENUE', +// (id.QuantityAsPerInvoice * pl.Rate) +(rt.AfterPackagingValue),0),0),2) as Package, -round(( -if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), -if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), -ifnull((id.QuantityAsPerInvoice * pl.Rate),0))) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), - (id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity), - (id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity), - (id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity), - (id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) -- round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), - (id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total -from T_IGR_Master im -left 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_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -left join T_Bankporeport br on br.IGRLineItemNo=id.IGRItemNo -where im.IGRStatus = 'ST027' and id.BankStatus !='ST070'"; +// round(( +// if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +// if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +// ifnull((id.QuantityAsPerInvoice * pl.Rate),0))) +// + round(ifnull(if(POType = 'REVENUE', + // (id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), + // (id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) +// + round(ifnull(if(POType = 'REVENUE', + // (id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity), + // (id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) +// + round(ifnull(if(POType = 'REVENUE', + // (id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity), + // (id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) +// + round(ifnull(if(POType = 'REVENUE', + // (id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity), + // (id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) +// + round(ifnull(if(POType = 'REVENUE', + // (id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) +// - round(ifnull(if(POType = 'REVENUE', + // (id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), + // (id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total +// from T_IGR_Master im +// left 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_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID +// left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo +// left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo +// left join T_Bankporeport br on br.IGRLineItemNo=id.IGRItemNo +// where im.IGRStatus = 'ST027' and id.BankStatus !='ST070'"; -$sql.=" group by id.IGRItemNo"; -//echo $sql; - $query = $this->db->query($sql); - return $query->result(); - } +// $sql.=" group by id.IGRItemNo"; +// //echo $sql; + // $query = $this->db->query($sql); + // return $query->result(); + // } - function bank_finyear(){ + // function bank_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(); + // $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 debitbankstatemet($Supplierid,$fdate,$tdate) // { @@ -687,7 +688,7 @@ if ($Supplierid!= ''){ } -$sql.="group by sd.SupplierName"; +$sql.="group by sd.SupplierID"; //echo $sql; $query = $this->db->query($sql); return $query->result(); @@ -948,16 +949,15 @@ $sql.="group by id.IGRItemNo"; } function bankinvoice($Customer,$fdate,$tdate) { - // $status='ST065'; - $this->db->distinct(); + $this->db->select('iva.invoice_id,iva.invoice_total,iv.invoice_date_created,iv.invoice_number,iva.invoice_paid,ic.client_name,ic.client_id,BI.balancetoreceived,BI.amountreceived'); $this->db->from ('ip_invoice_amounts iva'); $this->db->join ('ip_invoices iv','iva.invoice_id = iv.invoice_id'); $this->db->join ('ip_clients ic','iv.client_id = ic.client_id','left'); - $this->db->join ('T_Bankinvoicereport BI',' iv.invoice_number =BI.invoiceno','left'); - //$this->db->where('iva.receivedstatus !=','ST065'); + $this->db->join ('T_Bankinvoicereport BI','iv.invoice_number = BI.invoiceno and BI.IsActive= 1','left'); $this->db->where('iv.invoice_status_id','2'); $this->db->where('iv.receivedstatus !=','ST065'); + // $this->db->where('BI.IsActive',1); if ($fdate and $tdate != ''){ $fromdate= date("Y-m-d",strtotime($fdate)); $todate=date("Y-m-d",strtotime($tdate)); @@ -969,8 +969,34 @@ $sql.="group by id.IGRItemNo"; $this->db->where('ic.client_id',$Customer); } $this->db->group_by('iva.invoice_id'); + $query = $this->db->get(); + + return $query->result(); + + } + function receivedamount($Customer,$fdate,$tdate) + { + // $status='ST065'; + // $this->db->distinct(); + $this->db->select('BI.balancetoreceived,BI.amountreceived'); + $this->db->from ('T_Bankinvoicereport BI'); + //$this->db->where('BI.IsActive',1); + if ($fdate and $tdate != ''){ + $fromdate= date("Y-m-d",strtotime($fdate)); + $todate=date("Y-m-d",strtotime($tdate)); + $date = "date(BI.BankDate) >= '".$fromdate."' + and date(BI.BankDate) <= '".$todate."'"; + $this->db->where($date); + } + if ($Customer != ''){ + $this->db->where('BI.client_id',$Customer); + } + $this->db->group_by('BI.invoiceno'); //$this->db->where('inc.type','PAYMENT'); + //print_r($this->db->last_query()); + //die(); $query = $this->db->get(); + return $query->result(); } @@ -1761,6 +1787,7 @@ function receiptdata() $this->db->from ('t_income_expense tie'); $this->db->join('t_accountcode tac','tac.code=tie.account_code'); $this->db->where('tie.amounttype','DEBIT'); + $this->db->where('tie.cashtype','BANK'); $this->db->where('tie.IsActive',1); //$this->db->where('t_income_expense.account_code !=','ADV001'); if ($fa and $aa != ''){ @@ -1828,9 +1855,9 @@ function receiptdata() { $this->db->select('bm.id,bm.mid,bm.PONO,bm.Suppliername,bm.SupplierID,sum(bm.Totalpoamount)as Totalpoamount, - bm.Balancetopay,sum(bm.Amountpaid) as Amountpaid,bm.Podate,bm.BankDate,bm.IGRLineItemNo,bm.BankDate'); + bm.Balancetopay,sum(bm.Amountpaid) as Amountpaid,bm.Podate,bm.IGRLineItemNo,bm.BankDate'); $this->db->from ('T_Bankmappingpo bm'); - $this->db->join('T_bankreport br','br.ID=bm.mid'); + //$this->db->join('T_bankreport br','br.ID=bm.mid'); //$this->db->join('T_IGR_Details igr','igr.IGRItemNo=bm.IGRLineItemNo'); //$this->db->where('igr.BankStatus !=',ST072); $this->db->where('bm.IsActive',1); @@ -2151,6 +2178,22 @@ function receiptdata() $r = $this->db->affected_rows(); return $r; } + // function updatemappingamount($igrno,$amountpaid) + // { + + // $sql="update T_Bankmappingpo set Balancetopay=$amountpaid+Balancetopay where IGRLineItemNo='$igrno' and + // IsActive='1'"; + // $query = $this->db->query($sql); + // return $query->result(); + + // // $this->db->set('Balancetopay',$amountpaid+'Balancetopay'); + // // //$this->db->set('Balancetopay',$amountpaid); + // // $this->db->where('IGRLineItemNo',$igrno); + // // $this->db->where('IsActive',1); + // // $this->db->update('T_Bankmappingpo'); + // // $r = $this->db->affected_rows(); + // // return $r; + // } function UpdateIpinvoiceStatus($invoiceno,$receivedstatus) { $this->db->set('receivedstatus',$receivedstatus); @@ -2179,11 +2222,11 @@ function receiptdata() // $r = $this->db->affected_rows(); // return $r; // } - function updateBankporeportpo($igrno,$totalbalancetopay,$updatebankpoamount,$Bankid,$IsActive) + function updateBankporeportpo($igrno,$balancetopayupdate,$amountpaidupdate,$Bankid,$IsAct) { - $this->db->set('Balancetopay',$totalbalancetopay); - $this->db->set('Amountpaid',$updatebankpoamount); - $this->db->set('IsActive',$IsActive); + $this->db->set('Balancetopay',$balancetopayupdate); + $this->db->set('Amountpaid',$amountpaidupdate); + $this->db->set('IsActive',$IsAct); $this->db->where('IGRLineItemNo',$igrno); $this->db->where('mid',$Bankid); $this->db->update('T_Bankporeport'); @@ -2191,24 +2234,74 @@ function receiptdata() return $r; } - function updatebankinvoicereport($invoiceno,$bankid,$updatebalancetoreceived,$updateamountreceived,$IsActive) + function updatebankinvoicereport($invoiceno,$bankid,$balancetoreceivedupdate,$amountreceivedupdate,$IsAct) { - $this->db->set('balancetoreceived',$updatebalancetoreceived); - $this->db->set('amountreceived',$updateamountreceived); - $this->db->set('IsActive',$IsActive); + $this->db->set('balancetoreceived',$balancetoreceivedupdate); + $this->db->set('amountreceived',$amountreceivedupdate); + $this->db->set('IsActive',$IsAct); $this->db->where('invoiceno',$invoiceno); $this->db->where('bankid',$bankid); $this->db->update('T_Bankinvoicereport'); $r = $this->db->affected_rows(); return $r; } - function gettotalbankmappingpo($igrno) + function gettotalbankmappingpo($id) { $this->db->select('sum(Amountpaid)as Amountpaid'); + $this->db->from ('T_Bankmappingpo'); + $this->db->where('id',$id); + $this->db->where('IsActive',1); + //$this->db->group_by('T_Bankmappingpo.IGRLineItemNo'); + $query = $this->db->get(); + return $query->result(); + } + function gettotalbankmappingpocount($igrno) + { + $this->db->select('count(Amountpaid)as countAmountpaid'); $this->db->from ('T_Bankmappingpo'); $this->db->where('IGRLineItemNo',$igrno); $this->db->where('IsActive',1); - $this->db->group_by('T_Bankmappingpo.IGRLineItemNo'); + //$this->db->group_by('T_Bankmappingpo.IGRLineItemNo'); + $query = $this->db->get(); + return $query->result(); + } + function gettotalbankmappinginvoicecount($invoiceno) + { + $this->db->select('count(amountreceived)as countamountreceived'); + $this->db->from ('T_Bankmappingiv'); + $this->db->where('invoiceno',$invoiceno); + $this->db->where('IsActive',1); + //$this->db->group_by('T_Bankmappingpo.IGRLineItemNo'); + $query = $this->db->get(); + return $query->result(); + } + function gettotalbankpoamount($igrno) + { + $this->db->select('Amountpaid,Balancetopay'); + $this->db->from ('T_Bankporeport'); + $this->db->where('IGRLineItemNo',$igrno); + $this->db->where('IsActive',1); + //$this->db->group_by('T_Bankmappingpo.IGRLineItemNo'); + $query = $this->db->get(); + return $query->result(); + } + function gettotalbankreceivedamount($invoiceno) + { + $this->db->select('amountreceived,balancetoreceived'); + $this->db->from ('T_Bankinvoicereport'); + $this->db->where('invoiceno',$invoiceno); + $this->db->where('IsActive',1); + //$this->db->group_by('T_Bankmappingpo.IGRLineItemNo'); + $query = $this->db->get(); + return $query->result(); + } + function gettotalbankporeport($igrno) + { + $this->db->select('Amountpaid'); + $this->db->from ('T_Bankporeport'); + $this->db->where('IGRLineItemNo',$igrno); + $this->db->where('IsActive',1); + //$this->db->group_by('T_Bankmappingpo.IGRLineItemNo'); $query = $this->db->get(); return $query->result(); } diff --git a/application/views/bankamountpaid.php b/application/views/bankamountpaid.php index ed51cabf..598f5265 100644 --- a/application/views/bankamountpaid.php +++ b/application/views/bankamountpaid.php @@ -2,7 +2,7 @@ ">IGRLineItemNo?>