From 786fb59f3c8047c09e908ed73018b173238809c7 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Thu, 20 Sep 2018 16:03:32 +0530 Subject: [PATCH] bankbook --- application/controllers/cashbook_model.php | 1094 -------------------- application/models/cashbook_model.php | 4 +- 2 files changed, 2 insertions(+), 1096 deletions(-) delete mode 100644 application/controllers/cashbook_model.php diff --git a/application/controllers/cashbook_model.php b/application/controllers/cashbook_model.php deleted file mode 100644 index 5cc5536d..00000000 --- a/application/controllers/cashbook_model.php +++ /dev/null @@ -1,1094 +0,0 @@ -db->where('status',1); - $r = $this->db->get('t_accountcode'); - return $r->result(); - - } - function getAccountpay() - { - $this->db->where('type',PAYMENT); - $r = $this->db->get('t_accountcode'); - return $r->result(); - - } - function getAccounTypes1() - { - $this->db->select('name,type'); - $r = $this->db->get('t_accountcode'); - return $r->result(); - - } - - function saveIncomeExpense($data) - { - $this->db->insert('t_income_expense',$data); - $r = $this->db->affected_rows(); - return $r; - } - // function addcashbook($bankcash1) - // { - // $this->db->insert('T_Bankmappingcashbook',$bankcash1); - // $r = $this->db->affected_rows(); - // return $r; - // } - - function getIncomeExpenseList($i="") - { - // echo $i; - $this->db->select('t_accountcode.name,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*'); - $this->db->from('t_income_expense'); - $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left'); - $this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left'); - $this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left'); - $this->db->where('t_income_expense.IsActive',1); - $this->db->where('t_income_expense.account_code !=','ADV001'); - $this->db->order_by("date","desc"); - if(!empty($i)) - { - $this->db->where('t_income_expense.id',$i); - - } - $r = $this->db->get(); - return $r->result(); - } - - function getIncomeExpense($firstyear,$secondyear,$frmdt,$todt) - { - $this->db->select('t_accountcode.name,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*'); - $this->db->from('t_income_expense'); - $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left'); - $this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left'); - $this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left'); - $this->db->where('t_income_expense.IsActive',1); - $this->db->where('t_income_expense.account_code !=','ADV001'); - $this->db->where('t_income_expense.account_code !=','0013'); - if ($firstyear and $secondyear != '') - { - $finyear = "t_income_expense.date >= '".$firstyear."-04-01' and t_income_expense.date <= '".$secondyear."-03-31'"; - $this->db->where($finyear); - } - if ($frmdt and $todt != ''){ - $fromdate= date("Y-m-d",strtotime($frmdt)); - $todate=date("Y-m-d",strtotime($todt)); - $date = "date(t_income_expense.date) >= '".$fromdate."' - and date(t_income_expense.date) <= '".$todate."'"; - $this->db->where($date); - } - $this->db->order_by("date","desc"); - $r = $this->db->get(); - return $r->result(); - } - - function getAdvanceList($i="") - { - // echo $i; - $this->db->select('t_accountcode.name,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*'); - $this->db->from('t_income_expense'); - $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left'); - $this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left'); - $this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left'); - $this->db->where('t_income_expense.IsActive',1); - $this->db->where('t_income_expense.account_code','ADV001'); - $this->db->or_where('t_income_expense.account_code','0013'); - $this->db->order_by("date","desc"); - if(!empty($i)) - { - $this->db->where('t_income_expense.id',$i); - - } - $r = $this->db->get(); - return $r->result(); - } - - function getAdvance($firstyear,$secondyear,$frmdt,$todt) - { - $this->db->select('t_accountcode.name,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*'); - $this->db->from('t_income_expense'); - $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left'); - $this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left'); - $this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left'); - $this->db->where('t_income_expense.IsActive',1); - $this->db->where('t_income_expense.account_code','ADV001'); - $this->db->or_where('t_income_expense.account_code','0013'); - if ($firstyear and $secondyear != ''){ - $finyear = "t_income_expense.date >= '".$firstyear."-04-01' and t_income_expense.date <= '".$secondyear."-03-31'"; - $this->db->where($finyear); - } - if ($frmdt and $todt != ''){ - $fromdate= date("Y-m-d",strtotime($frmdt)); - $todate=date("Y-m-d",strtotime($todt)); - $date = "date(t_income_expense.date) >= '".$fromdate."' - and date(t_income_expense.date) <= '".$todate."'"; - $this->db->where($date); - } - $this->db->order_by("date","desc"); - $r = $this->db->get(); - return $r->result(); - } - -function 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 getCompany() - { - $r = $this->db->get('T_Company_Details'); - return $r->result(); - - - } - - function getAccounutInfo($i) - { - $this->db->select('t_accountcode.name,t_income_expense.*'); - $this->db->from('t_income_expense'); - $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code'); - $this->db->order_by("date", "desc"); - //$this->db->where('t_income_expense.id') - $r = $this->db->get(); - return $r->result(); - - } - - function Selectcash() - { - $this->db->select('*'); - $this->db->from('t_accountcode'); - $query = $this->db->get(); - $result = $query->result(); - return $result; - - } - - - function Selectadvance($i="") - { - // echo $i; - $this->db->select('T_SupplierDetailsN.SupplierName,t_accountcode.name,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*'); - $this->db->from('t_income_expense'); - $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left'); - $this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left'); - $this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left'); - $this->db->join('T_SupplierDetailsN','T_SupplierDetailsN.SupplierID=t_income_expense.Supplier_id' ); - $this->db->order_by("date","desc"); - $this->db->where_in('t_accountcode.code',[AReceipt,Apayment]); - if(!empty($i)) - { - $this->db->where('t_income_expense.id',$i); - - } - $r = $this->db->get(); - return $r->result(); - } - - - function viewdepartment($sid='') - { - $sql="SELECT ie.*,br.*,br.ID,ie.totalbankamount,ac.name,ie.id,date_format(ie.date,'%d-%m-%Y')as date FROM t_income_expense ie - left join t_accountcode ac on ac.code=ie.account_code - left join T_bankreport br on br.ID=ie.bankid - WHERE ie.id = ?"; - $query = $this->db->query($sql,array($sid)); - //print_r($this->db->last_query()); - //echo $sql; - return $query->result(); - } - function deletefile($cashid) - { - - //echo $cashid; - $sql="UPDATE t_income_expense SET document = NULL - WHERE id = ?"; - $query = $this->db->query($sql,array($cashid)); - //print_r($this->db->last_query()); - //echo $sql; - $r = $this->db->affected_rows(); - return $r; - } - - - function updatedepartment($updateaccount,$id1) - { - $this->db->where('id', $id1); - $this->db->update('t_income_expense',$updateaccount); - $r = $this->db->affected_rows(); - return $r; - - } - function bankfile($FileDetails) - { - $this->db->insert('T_bankingfile',$FileDetails); - $r = $this->db->affected_rows(); - return $r; - } - function bankfiledata($filedataupload) - { - - - $this->db->select('reportdate,Narration,Balance'); - $this->db->from('T_bankreport'); - $this->db->where('reportdate',$filedataupload['reportdate']); - $this->db->where('Narration',$filedataupload['Narration']); - $this->db->where('Balance',$filedataupload['Balance']); - - $query = $this->db->get(); - if ($query->num_rows() > 0){ - return true; - - } - else{ - $this->db->insert('T_bankreport', $filedataupload); - $r = $this->db->affected_rows(); - //print_r($this->db->last_query()); - return $r; - } -} - -function balance($balance){ - - - $this ->db->insert('T_bankbalance',$balance); -} - -function getbalancedetails() -{ - -$subquery="SELECT openingbalance,closingbalance FROM T_bankbalance WHERE balance_keyid in (SELECT MAX(balance_keyid) FROM T_bankbalance)"; -$query = $this->db->query($subquery); -return $query->result(); - -} - - - -function report_finyear(){ - - - $sql="SELECT -CASE WHEN MONTH(reportdate)>=4 THEN - concat(YEAR(reportdate), '-',YEAR(reportdate)+1) -ELSE concat(YEAR(reportdate)-1,'-', YEAR(reportdate)) END AS financial_year -FROM T_bankreport -GROUP BY financial_year"; - $query = $this->db->query($sql); - return $query->result(); - - - -} - -function bankstatement($fdate,$tdate,$fa,$aa){ - - - - $sql="SELECT *,date_format(reportdate,'%d-%m-%Y')as date,tie.total,date_format(valuedate,'%d-%m-%Y')as valuedate from T_bankreport as br left join t_income_expense as tie on tie.bankid=br.ID where br.reportdate !=0 "; - - - if ($fa and $aa != ''){ - - $sql.=" and (reportdate >= '".$fa."-04-01' and reportdate<= '".$aa."-03-31')"; - - } - if ($fdate and $tdate != '') - { - - $fdate= date("Y-m-d",strtotime($fdate)); - $tdate=date("Y-m-d",strtotime($tdate)); - - $sql.= " and date(reportdate) >= '".$fdate."' - and date(reportdate) <= '".$tdate."'"; - } - - - - - $sql.=" group by(br.ID) "; - $sql.=" ORDER BY br.ID+0 DESC "; - - - $query = $this->db->query($sql); - return $query->result(); - - - -} -function cleareddebitbalance(){ - - $sql = "SELECT SUM(Balancetocleared) as debit FROM T_bankreport where Clearbalance >'0'"; - - $query = $this->db->query($sql); - return $query->result(); - - -} -function clearedcreditbalance(){ - - $sql = "SELECT SUM(cbalancetocleared) as credit FROM T_bankreport where cclearbalance >'0'"; - - $query = $this->db->query($sql); - return $query->result(); - - -} - - - function debitbankstatemet($Supplierid,$fdate,$tdate) - { - $status='ST057'; - //echo $tdate; - //die(); - // +rt.SGST/100+rt.IGST/100)) - //$Supplierid; - $this->db->distinct(); - $this->db->select('igr.PONO,igrli.IGRItemNo,igr.IGRNO,supp.SupplierName,igrli.CreatedDate,BR.Balancetopay,BR.Amountpaid,pom.Status,igrli.QuantityAsPerInvoice ,poli.Rate,(igrli.QuantityAsPerInvoice * poli.Rate) as total,(igrli.QuantityAsPerInvoice * poli.Rate)+(igrli.QuantityAsPerInvoice * poli.Rate)*(rt.CGST/100)+(igrli.QuantityAsPerInvoice * poli.Rate)*(rt.SGST/100)+(igrli.QuantityAsPerInvoice * poli.Rate)*(rt.IGST/100) as finalamount'); - $this->db->from ('T_IGR_Details igrli'); - $this->db->join('T_IGR_Master igr','igrli.IGRNO = igr.IGRNO','left'); - $this->db->join('T_PurchaseOrder_LineItem poli','igr.PONO= poli.PONO and igrli.MaterialCode=poli.MaterialCode'); - $this->db->join('T_PurchaseOrder_Master pom','poli.PONO =pom.PONO'); - $this->db->join('T_SupplierDetailsN supp','pom.SupplierID =supp.SupplierID'); - $this->db->join('T_Revenue_Tax rt','poli.LineItemNo=rt.LineItemNo'); - $this->db->join ('T_Bankporeport BR','igrli.IGRItemNo = BR.IGRLineItemNo','left'); - if ($fdate and $tdate != ''){ - $fromdate= date("Y-m-d",strtotime($fdate)); - $todate=date("Y-m-d",strtotime($tdate)); - $date = "date(igr.CreatedDate) >= '".$fromdate."' - and date(igr.CreatedDate) <= '".$todate."'"; - $this->db->where($date); - } - if ($Supplierid != ''){ - $this->db->where('supp.SupplierID',$Supplierid); - } - $this->db->where_in('igr.IGRStatus','ST027'); - //$this->db->where_in('pom.Status',[ST044,ST056]); - $this->db->where('igrli.BankStatus','ST072'); - $query = $this->db->get(); - return $query->result(); - - } - 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,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->where('iv.invoice_status_id','2'); - $this->db->where('iv.receivedstatus !=','ST065'); - if ($fdate and $tdate != ''){ - $fromdate= date("Y-m-d",strtotime($fdate)); - $todate=date("Y-m-d",strtotime($tdate)); - $date = "date(iv.invoice_date_created) >= '".$fromdate."' - and date(iv.invoice_date_created) <= '".$todate."'"; - $this->db->where($date); - } - if ($Customer != ''){ - $this->db->where('ic.client_id',$Customer); - } - $this->db->group_by('iva.invoice_id'); - //$this->db->where('inc.type','PAYMENT'); - $query = $this->db->get(); - return $query->result(); - - } - -function receiptdata() - { - - $this->db->distinct(); - $this->db->select('inc.type,inc.date,inc.account_code,inc.towhom,inc.total'); - $this->db->from ('t_income_expense inc'); - $this->db->where('inc.type','RECEIPT'); - $query = $this->db->get(); - return $query->result(); - - } - function paymentdata() - { - - $this->db->distinct(); - $this->db->select('inc.type,inc.date,inc.account_code,inc.towhom,inc.total'); - $this->db->from ('t_income_expense inc'); - //$this->db->group_by('inc.account_code'); - //$this->db->where('inc.type','PAYMENT'); - $query = $this->db->get(); - return $query->result(); - - } - - - - function debitimage($igrno,$pono) - { - - $this->db->select('*'); - $this->db->from ('T_PurchaseOrder_BillUpload'); - $this->db->where('IGRNO != "" '); - $this->db->where('IGRNO',$igrno); - $this->db->or_where('PONO',$pono); - $query = $this->db->get(); - $result = $query->result(); - // print_r($result);die; - return $result; - - } - - - - function debitpolistfilter($SupplierName,$fdate,$tdate) - { - $this->db->select('bm.id,bm.mid,igrm.MaterialRcvdDate,bm.PONO,bm.Suppliername,bm.Totalpoamount, - bm.Balancetopay,bm.Amountpaid,bm.IGRNO,igrm.file,bm.IGRLineItemNo,br.Clearbalance,br.Balancetocleared,bu.FilePath,bu.BillNo,inward.FilePath as Fpath'); - $this->db->from ('T_Bankporeport bm'); - $this->db->join ('T_IGR_Master igrm','igrm.PONO = bm.PONO or igrm.IGRNO = bm.IGRNO ','left'); - //$this->db->join ('T_IGR_Details igrde','igrde.IGRNO=igrm.IGRNO'); - $this->db->join ('T_SupplierDetailsN sd','sd.SupplierName = bm.Suppliername'); - $this->db->join ('T_bankreport br','br.ID=bm.mid'); - $this->db->join('T_Inwardgateregister_fileupload inward','inward.IGRNO =igrm.IGRNO','left'); - $this->db->join ('T_PurchaseOrder_BillUpload bu','bm.PONO=bu.PONO','left'); - if($fdate!='' && $tdate!='') - { - $this->db->where('bm.Podate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"'); - } - if($SupplierName!='') - { - $this->db->where('sd.SupplierID',$SupplierName); - } - - - $this->db->group_by('bm.id'); - $query = $this->db->get(); - return $query->result(); - - } - - - function igrmastersingle($igrno,$pono) - { - $this->db->distinct(); - $this->db->select('IGRNO,file,PONO as pono'); - $this->db->from('T_IGR_Master'); - if(!empty($igrno) && !empty($pono)){ - $this->db->where('PONO',$pono); - $this->db->where('IGRNO',$igrno); - }else if(!empty($pono)){ - $this->db->where('PONO',$pono); - $this->db->where('IGRNO != ""'); - }else{ - $this->db->where('IGRNO',$IGRNO); - } - - $query = $this->db->get(); - return $query->result(); - } - function igrmastermultiple($igrno,$pono) - { - $this->db->distinct(); - $this->db->select('BillNo,IGRNO,FilePath,PONO,Remarks'); - $this->db->from('T_Inwardgateregister_fileupload'); - if(!empty($igrno) && !empty($pono)){ - $this->db->where('PONO',$pono); - $this->db->where('IGRNO',$igrno); - }else if(!empty($pono)){ - $this->db->where('PONO',$pono); - $this->db->where('IGRNO != ""'); - }else{ - $this->db->where('IGRNO',$IGRNO); - } - $query = $this->db->get(); - return $query->result(); - - } - function debitpolist($bankid) - { - $this->db->select('bp.id,bp.mid,igrm.MaterialRcvdDate,bp.PONO,bp.Suppliername,bp.Totalpoamount,br.Debit,bp.Balancetopay,bp.Amountpaid,bp.IGRNO,bp.IGRLineItemNo,igrm.file,bu.FilePath,inward.FilePath as Fpath'); - $this->db->from ('T_Bankmappingpo bp'); - $this->db->join ('T_IGR_Master igrm','bp.IGRNO = igrm.IGRNO','left'); - $this->db->join ('T_PurchaseOrder_BillUpload bu','bu.PONO = bp.PONO','left'); - $this->db->join('T_Inwardgateregister_fileupload inward','inward.IGRNO =igrm.IGRNO','left'); - $this->db->join ('T_bankreport br','br.ID=bp.mid'); - $this->db->where('bp.IsActive',1); - $this->db->where('bp.mid',$bankid); - // $this->db->where('igrde.BankStatus !=','ST072'); - $this->db->group_by('bp.id'); - $query = $this->db->get(); - return $query->result(); - - } - - - function creditinvoicelist($bankid) - { - $this->db->select('bm.indate,bm.invoiceno,bm.customername,bm.totinvoiceamount,bm.bankid, - bm.balancetoreceived,bm.amountreceived,bm.ID,br.Credit'); - $this->db->from ('T_Bankmappingiv bm'); - $this->db->join('T_bankreport br','br.ID=bm.bankid'); - $this->db->where('bm.bankid',$bankid); - $this->db->where('bm.IsActive',1); - //$this->db->group_by('invoiceno'); - $query = $this->db->get(); - return $query->result(); - - } - function creditinvoicelistfilter($Customer,$fdate,$tdate) - { - $this->db->select('bm.ID,bm.indate,bm.invoiceno,bm.customername,bm.totinvoiceamount,bm.bankid, - bm.balancetoreceived,bm.amountreceived,br.cclearbalance,br.cbalancetocleared'); - $this->db->from ('T_Bankmappingiv bm'); - $this->db->where('bm.IsActive',1); - $this->db->join ('ip_clients ic','ic.client_name = bm.customername','left'); - $this->db->join('T_bankreport br','br.ID = bm.bankid'); - if($fdate!='' && $tdate!='') - { - $this->db->where('bm.indate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"'); - } - if($Customer!='') - { - $this->db->where('ic.client_id',$Customer); - } - //$this->db->group_by('invoiceno'); - - $query = $this->db->get(); - return $query->result(); - - } - //for cashbook edit screen and update bankreport// - function invoiceamonut($bankid) - { - $this->db->select('sum(amountreceived)as amountreceived'); - $this->db->from ('T_Bankmappingiv'); - $this->db->where('bankid',$bankid); - $this->db->where('IsActive',1); - //$this->db->group_by('invoiceno'); - $query = $this->db->get(); - return $query->result(); - - } - //for cashbook edit screen and update bankreport// - function poamonut($bankid) - { - $this->db->select('sum(Amountpaid)as amountpaid'); - $this->db->from ('T_Bankmappingpo'); - $this->db->where('mid',$bankid); - $this->db->where('IsActive',1); - //$this->db->group_by('invoiceno'); - $query = $this->db->get(); - return $query->result(); - - } - function cashbookamount($bankid) - { - $this->db->select('sum(total)as total'); - $this->db->from ('t_income_expense'); - $this->db->where('bankid',$bankid); - $this->db->where('IsActive',1); - //$this->db->group_by('invoiceno'); - $query = $this->db->get(); - return $query->result(); - - } - - function mappingcash($SupplierName,$fdate,$tdate,$bankid) - { - $this->db->select('ie.id,ie.date,ie.bankid,ie.cashtype,ie.amounttype,ie.total,ac.name,totalbankamount,ie.id'); - $this->db->from ('t_income_expense as ie'); - $this->db->join ('t_accountcode ac ','ac.code = ie.account_code','left'); - $this->db->where('bankid',$bankid); - $this->db->where('IsActive',1); - //$this->db->group_by('mid'); - $query = $this->db->get(); - return $query->result(); - - } - function newcashbook() - { - $this->db->select('cdate,mid,btype,amount,boption,mappingamount,totalamount,amounttype,alreadycreditpaid'); - $this->db->from ('T_Bankmappingcashbook'); - //$this->db->where('mid',$bankid); - - //$this->db->group_by('mid'); - $query = $this->db->get(); - return $query->result(); - - } - - function debitlistpo($pono) - { - $this->db->select('bmp.mid,bmp.PONO,bmp.IGRLineItemNo,bmp.Amountpaid'); - $this->db->from ('T_Bankmappingpo as bmp'); - // $this->db->join('T_bankreport br','br.ID = bmp.mid'); - $this->db->where('bmp.PONO',$pono); - $this->db->where('bmp.IsActive',1); - $query = $this->db->get(); - return $query->result(); - - } - - function creditlistinv($invno) - { - $this->db->select('bmp.bankid,bmp.invoiceno,bmp.amountreceived,br.Narration'); - $this->db->from ('T_Bankmappingiv as bmp'); - $this->db->join('T_bankreport br','br.ID = bmp.bankid'); - $this->db->where('invoiceno',$invno); - $this->db->where('bmp.IsActive',1); - //$this->db->group_by('invoiceno'); - $query = $this->db->get(); - return $query->result(); - - } - - function getsupplier() - { - $this->db->select('SupplierName,SupplierID'); - $this->db->from('T_SupplierDetailsN'); - //$this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code'); - //$this->db->where('t_income_expense.id') - $r = $this->db->get(); - return $r->result(); - - } - - function checkMerchant($mer){ - - $temp[] = '' ; - $this->db->distinct(); - $this->db->select('SupplierID,SupplierName'); - $this->db->from('T_SupplierDetailsN'); - $this->db->like('SupplierName',$mer); - $query = $this->db->get(); - - $temparr[] = '' ; - foreach($query->result() as $arr){ - $temparr[] = $arr->SupplierName; - } - $temp['suggestions'] = $temparr; - - return $temp; - } - - function getsupp_dtls($s){ - $this->db->select('GSTNO'); - $this->db->from('T_SupplierDetailsN'); - $this->db->where('SupplierName',$s); - $r = $this->db->get(); - return $r->result(); - } - - function getcustomer() - { - $this->db->select('client_name,client_id'); - $this->db->from('ip_clients'); - //$this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code'); - //$this->db->where('t_income_expense.id') - $r = $this->db->get(); - return $r->result(); - - } - function invoicedata($invoicedata) - { - $this->db->insert('T_Bankinvoicereport',$invoicedata); - // $this->db->where('PONO',$pono); - $r = $this->db->affected_rows(); - return $r; - } - function podata($podata) - { - $this->db->insert('T_Bankporeport',$podata); - // $this->db->where('PONO',$pono); - $r = $this->db->affected_rows(); - return $r; - } - // function invicedata($invoicedata) - // { - // $this->db->insert('T_Bankinvoicereport',$invoicedata); - // $r = $this->db->affected_rows(); - // return $r; - // } - function mappingpo($podata) - { - $this->db->insert('T_Bankmappingpo',$podata); - // $this->db->where('PONO',$pono); - $r = $this->db->affected_rows(); - return $r; - } - function mappinginvoice($invoicedata) - { - $this->db->insert('T_Bankmappingiv',$invoicedata); - // $this->db->where('PONO',$pono); - $r = $this->db->affected_rows(); - return $r; - } - - - public function getpono($igrlineitem) - { - $this->db->select('IGRLineItemNo'); - $this->db->from('T_Bankporeport'); - $this->db->where('IGRLineItemNo ',$igrlineitem); - $query = $this->db->get(); - // print_r( $this->db->last_query()); - return $query->result(); - - } - public function invoiceupdate($invid) - { - $this->db->select('invoiceno'); - $this->db->from('T_Bankinvoicereport'); - $this->db->where('invoiceno',$invid); - $query = $this->db->get(); - // print_r( $this->db->last_query()); - return $query->result(); - - } - public function bankid($pono) - { - $this->db->select('PONO'); - $this->db->from('T_Bankporeport'); - $this->db->where('PONO ',$pono); - $query = $this->db->get(); - // print_r( $this->db->last_query()); - return $query->result(); - - } - public function cashbankupdate($cashbookstatus,$bankid) - { - // echo $bankid; - $this->db->where('ID',$bankid); - $this->db->update('T_bankreport',$cashbookstatus); - return TRUE; - - } - function cashcreditupdate($cashbookstatus1,$bankid) - { - - $this->db->where('ID',$bankid); - $this->db->update('T_bankreport',$cashbookstatus1); - return TRUE; - } - public function bankupdate($bankdata,$bankid) - { - $this->db->where('ID ',$bankid); - $this->db->update('T_bankreport',$bankdata); - return TRUE; - - } - public function bankcreditupdate($bankcreditdata,$bankid) - { - - - $this->db->where('ID ',$bankid); - $this->db->update('T_bankreport',$bankcreditdata); - - // print_r( $this->db->last_query()); - return TRUE; - - } - public function getearlyamount($igrlineitem) - { - $this->db->select('Amountpaid'); - $this->db->from('T_Bankporeport'); - $this->db->where('IGRLineItemNo ',$igrlineitem); - $query = $this->db->get(); - // print_r( $this->db->last_query()); - return $query->result(); - - } - public function getearlyamountcredit($invid) - { - $this->db->select('amountreceived'); - $this->db->from('T_Bankinvoicereport'); - $this->db->where('invoiceno ',$invid); - $query = $this->db->get(); - // print_r( $this->db->last_query()); - return $query->result(); - - } - public function getalreadypaid($bankid) - { - $this->db->select('Clearbalance'); - $this->db->from('T_bankreport'); - $this->db->where('ID ',$bankid); - $query = $this->db->get(); - // print_r( $this->db->last_query()); - return $query->result(); - - } - public function getalreadyreceived($bankid) - { - $this->db->select('cclearbalance'); - $this->db->from('T_bankreport'); - $this->db->where('ID ',$bankid); - $query = $this->db->get(); - // print_r( $this->db->last_query()); - return $query->result(); - - } - - public function poupdate($podata,$igrlineitem) - { - - $this->db->where('IGRLineItemNo',$igrlineitem); - $this->db->update('T_Bankporeport',$podata); - - return TRUE; - } - public function invoiceupdate1($invoicedata,$invid) - { - //print_r($invoicedata); - //print_r($invid); - $this->db->where('invoiceno',$invid); - $this->db->update('T_Bankinvoicereport',$invoicedata); - - return TRUE; - } - function paided() - { - $this->db->select('*'); - $this->db->from('T_Bankmappingpo'); - $query = $this->db->get(); - $result = $query->result(); - return $result; - - } - // function unpaided() - // { - // // $this->db->select('igd.IGRNO,igd.IGRItemNo,pom.PONO,sm.SupplierName'); - // // $this->db->from('T_IGR_Details igd'); - // // $this->db->join('T_IGR_Master igm','igm.IGRNO=igd.IGRNO'); - // // $this->db->join('T_PurchaseOrder_LineItem poli','igm.PONO= poli.PONO and igd.MaterialCode=poli.MaterialCode'); - // // $this->db->join('T_PurchaseOrder_Master pom','pom.PONO=poli.PONO'); - // // $this->db->join('T_SupplierDetailsN sm','sm.SupplierID=pom.SupplierID'); - // // $this->db->where('igd.BankStatus','ST072'); - // // $query = $this->db->get(); - // // $result = $query->result(); - // // return $result; - - // } - function received() - { - $this->db->select('*'); - $this->db->from('T_Bankmappingiv'); - $query = $this->db->get(); - $result = $query->result(); - return $result; - - } - - - function igrdetailstatus($igrdetails,$igrlineitem) - { - $this->db->where('IGRItemNo',$igrlineitem); - $this->db->update('T_IGR_Details',$igrdetails); - $r = $this->db->affected_rows(); - return $r; - - } - function invoiceamountstatus($invoicemaster,$invid) - { - - $this->db->where('invoice_number',$invid); - $this->db->update('ip_invoices',$invoicemaster); - $r = $this->db->affected_rows(); - return $r; - - } - // function poamountstatus1($pomaster1,$pono) - // { - // $this->db->where('PONO', $pono); - // $this->db->update('T_PurchaseOrder_Master',$pomaster1); - // $r = $this->db->affected_rows(); - // return $r; - - // } - - function Cashbook($cashbookdatas) - { - $code=$cashbookdatas['code']; - $type=$cashbookdatas['type']; - - $count=0; - - $this->db->select('count(*) as count'); - $this->db->from('t_accountcode'); - $this->db->where('type',$type); - $this->db->where('code',$code); - - $isExits = $this->db->get(); - $res = $isExits->result_array(); - - - if(!empty($res)) - { - $count = $res[0]['count']; - } - - - if($count == 0 )//for cashbook_insert - { - $cbi = $this->db->insert('t_accountcode', $cashbookdatas); - return $cbi; - } - elseif($count == 1)//for cashbook_update - { - $this->db->where('code',$code); - $cbu = $this->db->update('t_accountcode',$cashbookdatas); - return $cbu; - } - - } - function deletemapping($Bankid,$updateamount,$updatebalancetoclear,$active) - { - $this->db->set('Clearbalance',$updateamount); - $this->db->set('Balancetocleared',$updatebalancetoclear); - $this->db->set('IsActive',$active); - $this->db->where('ID',$Bankid); - $this->db->update('T_bankreport'); - $r = $this->db->affected_rows(); - return $r; - } - function updatebankreportiv($bankid,$bankstatement) - { - $this->db->where('ID',$bankid); - $this->db->update('T_bankreport',$bankstatement); - $r = $this->db->affected_rows(); - return $r; - - } - function IgrDetailsStatusUpdate($igrno,$BankStatus) - { - - $this->db->set('BankStatus',$BankStatus); - $this->db->where('IGRItemNo',$igrno); - $this->db->update('T_IGR_Details'); - $r = $this->db->affected_rows(); - return $r; - } - function deleteBankmappingpo($id,$IsActive) - { - $this->db->set('IsActive',$IsActive); - $this->db->where('id',$id); - $this->db->update('T_Bankmappingpo'); - $r = $this->db->affected_rows(); - return $r; - } - function UpdateIpinvoiceStatus($invoiceno,$receivedstatus) - { - $this->db->set('receivedstatus',$receivedstatus); - $this->db->where('invoice_number',$invoiceno); - $this->db->update('ip_invoices'); - $r = $this->db->affected_rows(); - return $r; - } - - function deletemappinginvoice($mappingid,$IsActive) - { - $this->db->set('IsActive',$IsActive); - $this->db->where('ID',$mappingid); - $this->db->update('T_Bankmappingiv'); - $r = $this->db->affected_rows(); - return $r; - } - function updateBankporeportpo($igrno,$totalbalancetopay,$updatebankpoamount,$Bankid) - { - $this->db->set('Balancetopay',$totalbalancetopay); - $this->db->set('Amountpaid',$updatebankpoamount); - $this->db->where('IGRLineItemNo',$igrno); - $this->db->where('mid',$Bankid); - $this->db->update('T_Bankporeport'); - $r = $this->db->affected_rows(); - return $r; - - } - function updatebankinvoicereport($invoiceno,$bankid,$updatebalancetoreceived,$updateamountreceived) - { - $this->db->set('balancetoreceived',$updatebalancetoreceived); - $this->db->set('amountreceived',$updateamountreceived); - $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) - { - $this->db->select('sum(Amountpaid)as Amountpaid'); - $this->db->from ('T_Bankmappingpo'); - $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 getlatestamount($mappingid,$invoiceno) - { - $this->db->select('min(balancetoreceived)as balancetoreceived'); - $this->db->from ('T_Bankmappingiv'); - $this->db->where('ID',$mappingid); - $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 getlatest($invoiceno) - { - $sql="select ID,balancetoreceived from T_Bankmappingiv where invoiceno='$invoiceno' and - ID in(select max(ID) from T_Bankmappingiv group by invoiceno)"; - $query =$this->db->query($sql); - return $query->result(); - } - function deletecashbookdata($Bankid,$updatebankamount,$clearbalance) - { - $this->db->set('Clearbalance',$clearbalance); - $this->db->set('Balancetocleared',$updatebankamount); - $this->db->where('ID',$Bankid); - $this->db->update('T_bankreport'); - $r = $this->db->affected_rows(); - return $r; - } - function deletecashbookdatacredit($Bankid,$updateclearbalance,$updatebalancetoclear) - { - $this->db->set('cclearbalance',$updateclearbalance); - $this->db->set('cbalancetocleared',$updatebalancetoclear); - $this->db->where('ID',$Bankid); - $this->db->update('T_bankreport'); - $r = $this->db->affected_rows(); - return $r; - } - function getaccountcode($accountname) - { - $this->db->select('code'); - $this->db->from ('t_accountcode'); - $this->db->where('name',$accountname); - $query = $this->db->get(); - return $query->result(); - } - function StatusUpadateCashbook($id,$IsActive) - { - $this->db->set('IsActive',$IsActive); - $this->db->where('id',$id); - $this->db->update('t_income_expense'); - $r = $this->db->affected_rows(); - return $r; - } - -} - -?> \ No newline at end of file diff --git a/application/models/cashbook_model.php b/application/models/cashbook_model.php index c0ecbd2b..5cc5536d 100644 --- a/application/models/cashbook_model.php +++ b/application/models/cashbook_model.php @@ -631,9 +631,9 @@ function receiptdata() function debitlistpo($pono) { - $this->db->select('bmp.mid,bmp.PONO,bmp.IGRLineItemNo,bmp.Amountpaid,br.Narration'); + $this->db->select('bmp.mid,bmp.PONO,bmp.IGRLineItemNo,bmp.Amountpaid'); $this->db->from ('T_Bankmappingpo as bmp'); - $this->db->join('T_bankreport br','br.ID = bmp.mid'); + // $this->db->join('T_bankreport br','br.ID = bmp.mid'); $this->db->where('bmp.PONO',$pono); $this->db->where('bmp.IsActive',1); $query = $this->db->get();