diff --git a/application/controllers/cashbook.php b/application/controllers/cashbook.php index c69ed519..a4c3b27a 100644 --- a/application/controllers/cashbook.php +++ b/application/controllers/cashbook.php @@ -1001,6 +1001,7 @@ class cashbook extends BaseController //$data['cash'] = $_GET['sid']; //$data['bankid'] = $_GET['d']; $data['bankdepitpaid'] = $this->cashbook_model->debitbankstatemet($Supplierid,$fdate,$tdate); + // print_r($data['bankdepitpaid']); } $data['getsupplier'] = $this->cashbook_model->getsupplier(); @@ -1264,10 +1265,10 @@ class cashbook extends BaseController $postatus=PARTIALLY_PAIDIGR; } - $podetails=array('Paymentstatus'=>$postatus,'StatusUpdatedDate'=>$now); + $igrdetails=array('Paymentstatus'=>$postatus,'StatusUpdatedDate'=>$now); //$podetails=array('Paymentstatus'=>$postatus); //$result1 = $this->cashbook_model->igrdetailstatus($podetails,$pono); - $result1 = $this->cashbook_model->poamountstatus($podetails,$pono); + $result1 = $this->cashbook_model->poamountstatus($igrdetails,$igrno); $this->loadViews("bankstatement", $this->global,$data, NULL); } public function invoiceamount1() @@ -1882,7 +1883,7 @@ class cashbook extends BaseController $id=$this->input->post('mappingid'); - $igrno = $this->input->post('IGRItemNo'); + $igrno = $this->input->post('igrno'); $pono = $this->input->post('pono'); $Bankid = $this->input->post('bankid'); $balancetoclear=$this->input->post('balancetobankingclear'); @@ -1891,7 +1892,7 @@ class cashbook extends BaseController $updatebalancetoclear=$Amount+$balancetoclear; $data['$bankmappingamount'] = $this->cashbook_model->gettotalbankmappingpo($id); $amountpaid=$data['$bankmappingamount'][0]->Amountpaid; - $data['$bankmappingamountcount'] = $this->cashbook_model->gettotalbankmappingpocount($pono); + $data['$bankmappingamountcount'] = $this->cashbook_model->gettotalbankmappingpocount($igrno); $count= $data['$bankmappingamountcount'][0]->countAmountpaid; //$data['$totallineitemamount']=$this->cashbook_model->gettotallineitem($igrno); @@ -1906,7 +1907,7 @@ class cashbook extends BaseController - $result= $this->cashbook_model->PoStatusUpdate($pono,$PaymentStatus); + $result= $this->cashbook_model->IGRStatusUpdate($igrno,$PaymentStatus); $result1= $this->cashbook_model->deletemapping($Bankid,$updateamount,$updatebalancetoclear); //for update mapping amount in t_bankmappingpo table// $balancetopay=$this->input->post('balancetopay'); @@ -1915,7 +1916,7 @@ class cashbook extends BaseController //$updateamount=0; $IsActive=0; $result2= $this->cashbook_model->deleteBankmappingpo($id,$IsActive); - $data['$poreportamount'] = $this->cashbook_model->gettotalbankpoamount($pono); + $data['$poreportamount'] = $this->cashbook_model->gettotalbankpoamount($igrno); $amountpaidpo= $data['$poreportamount'][0]->Amountpaid; $balancetopaypo= $data['$poreportamount'][0]->Balancetopay; $amountpaidupdate=($amountpaidpo) - ($Amount); @@ -1928,7 +1929,7 @@ class cashbook extends BaseController { $IsAct=1; } - $result3= $this->cashbook_model->updateBankporeport($pono,$balancetopayupdate,$amountpaidupdate,$IsAct); + $result3= $this->cashbook_model->updateBankporeport($igrno,$balancetopayupdate,$amountpaidupdate,$IsAct); $this->loadViews("bankstatement", $this->global,$data, NULL); } public function Deletemappingpo() @@ -1936,7 +1937,7 @@ public function Deletemappingpo() $totalamount = $_GET['totalpoamount'];//totalpoamount $Bankid = $_GET['bankid']; $Amount = $_GET['amount'];//paid amount - $pono = $_GET['pono']; + $igrno = $_GET['igrno']; $balancetoclear=$_GET['balancetoclear']; //for T_Bankreport IsActive// $bankdebit=$_GET['debit']; @@ -1949,7 +1950,7 @@ public function Deletemappingpo() $updatebalancetoclear=$Amount+$balancetoclear; $data['$bankmappingamount'] = $this->cashbook_model->gettotalbankmappingpo($id); $amountpaid=$data['$bankmappingamount'][0]->Amountpaid; - $data['$bankmappingamountcount'] = $this->cashbook_model->gettotalbankmappingpocount($pono); + $data['$bankmappingamountcount'] = $this->cashbook_model->gettotalbankmappingpocount($igrno); $count= $data['$bankmappingamountcount'][0]->countAmountpaid; @@ -1963,7 +1964,7 @@ public function Deletemappingpo() } - $result= $this->cashbook_model->PoStatusUpdate($pono,$PaymentStatus); + $result= $this->cashbook_model->IGRStatusUpdate($igrno,$PaymentStatus); $result1= $this->cashbook_model->deletemapping($Bankid,$updateamount,$updatebalancetoclear); //for update mapping amount in t_bankreport table// $balancetopay=$_GET['balancetopay'];//balancetopay @@ -1972,7 +1973,7 @@ public function Deletemappingpo() $updatebankpoamount=$totalamount-$totalbalancetopay; $result2= $this->cashbook_model->deleteBankmappingpo($id,$IsActive); //$result3= $this->cashbook_model->updatemappingamount($igrno,$amountpaid); - $data['$poreportamount'] = $this->cashbook_model->gettotalbankpoamount($pono); + $data['$poreportamount'] = $this->cashbook_model->gettotalbankpoamount($igrno); $amountpaidpo= $data['$poreportamount'][0]->Amountpaid; $balancetopay= $data['$poreportamount'][0]->Balancetopay; $amountpaidupdate=$amountpaidpo-$Amount; @@ -1987,7 +1988,7 @@ public function Deletemappingpo() { $IsAct=1; } - $result3= $this->cashbook_model->updateBankporeport($pono,$balancetopayupdate,$amountpaidupdate,$IsAct); + $result3= $this->cashbook_model->updateBankporeport($igrno,$balancetopayupdate,$amountpaidupdate,$IsAct); if(count($result3)>0) { diff --git a/application/models/cashbook_model.php b/application/models/cashbook_model.php index 4db2fac2..d9511a23 100644 --- a/application/models/cashbook_model.php +++ b/application/models/cashbook_model.php @@ -433,124 +433,162 @@ function clearedcreditbalance(){ - - - function suppliertotalfilter($fa,$aa,$m,$fdate,$tdate) { + - - $status= array('ST027','ST056'); - $this->db->select('pom.PONO,sum(pom.TotalOrderValue) as TotalOrderValue,sd.SupplierName,sd.SupplierID,im.MaterialRcvdDate,im.CreatedDate'); - $this->db->from ('T_PurchaseOrder_Master pom'); - $this->db->join('T_IGR_Master im','pom.PONO=im.PONO','left'); - $this->db->join('T_SupplierDetailsN sd','pom.SupplierID=sd.SupplierID','left'); - $this->db->or_where_in('pom.Status',$status); - $this->db->where('pom.Paymentstatus',NO_PAIDIGR); - - if ($fa and $aa != ''){ - $year="(im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')"; - $this->db->where($year); + $sql="select pono,igrn,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name,sid, + sum(total) as total,file,ifile + from igr + where Status ='ST027' or Status='ST056' and PaymentStatus ='ST072'"; + + + + if ($fa and $aa != ''){ + + //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + $sql.=" and (MaterialRcvdDate >= '".$fa."-04-01' and MaterialRcvdDate <= '".$aa."-03-31')"; + } if ($m!= ''){ - $month="monthname(im.MaterialRcvdDate) = '".$m."'"; - $this->db->where($month); + //$sql.="and monthname(im.CreatedDate) = '".$m."'"; + $sql.="and monthname(MaterialRcvdDate) = '".$m."'"; } - if($fdate!='' && $tdate!='') - { - $this->db->where('im.MaterialRcvdDate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"'); - } - // $this->db->group_by(array("sd.SupplierID", "pom.PONO")); - $this->db->group_by('sd.SupplierID','pom.PONO'); - //$this->db->group_by('pom.PONO'); - $query = $this->db->get(); - - return $query->result(); - + + + if ($fdate and $tdate != ''){ + $fromd= date("Y-m-d",strtotime($fdate)); + $tod=date("Y-m-d",strtotime($tdate)); + + $sql.="and date(MaterialRcvdDate) >= '".$fromd."' + and date(MaterialRcvdDate) <= '".$tod."'"; + + } + + + $sql.="group by sid"; + $query = $this->db->query($sql); + return $query->result(); } + + // function suppliertotalfooilter($fa,$aa,$m,$fdate,$tdate) + // { + + + + // $status= array('ST027','ST056'); + // $this->db->select('pom.PONO,sum(pom.TotalOrderValue) as TotalOrderValue,sd.SupplierName,sd.SupplierID as SupplierID,im.MaterialRcvdDate,im.CreatedDate'); + // $this->db->from ('T_PurchaseOrder_Master pom'); + // $this->db->join('T_IGR_Master im','pom.PONO=im.PONO','left'); + // $this->db->join('T_SupplierDetailsN sd','pom.SupplierID=sd.SupplierID','left'); + // // $this->db->or_where_in('pom.Status',$status); + // $this->db->where('pom.Status','ST027'); + // $this->db->where('pom.Paymentstatus',NO_PAIDIGR); + + // if ($fa and $aa != ''){ + // $year="(im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')"; + // $this->db->where($year); + // } + // if ($m!= ''){ + + // $month="monthname(im.MaterialRcvdDate) = '".$m."'"; + // $this->db->where($month); + + // } + // if($fdate!='' && $tdate!='') + // { + // $this->db->where('im.MaterialRcvdDate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"'); + // } + // // $this->db->group_by(array("sd.SupplierID", "pom.PONO")); + // // $this->db->group_by(['pom.SupplierID', 'pom.PONO']); + // $this->db->group_by('sd.SupplierID','pom.PONO'); + // //$this->db->group_by('pom.PONO'); + // $query = $this->db->get(); + + // return $query->result(); + + + // } function amountunpaid($supplierid1,$fa,$aa,$m,$fdate,$tdate) { - $status= array('ST027','ST056'); - $this->db->select('pom.PONO,pom.TotalOrderValue,sd.SupplierName,sd.SupplierID,im.MaterialRcvdDate,im.CreatedDate, - im.IGRNO'); - $this->db->from('T_PurchaseOrder_Master pom'); - //$this->db->join('T_PurchaseOrder_BillUpload bu','pom.PONO=bu.PONO','left');,inward.FilePath as iwFpath,bu.FilePath as poFilePath - $this->db->join('T_IGR_Master im','im.PONO = pom.PONO','left'); - $this->db->join('T_SupplierDetailsN sd','sd.SupplierID=pom.SupplierID','left'); - // $this->db->join('T_Bankporeport bm','bm.PONO=pom.PONO and bm.IsActive = 1','left'); - - //$this->db->join('T_Inwardgateregister_fileupload inward','inward.IGRNO =im.IGRNO','left'); - - - $this->db->or_where_in('pom.Status',$status); - $this->db->where('pom.Paymentstatus ',NO_PAIDIGR); - $this->db->where('sd.SupplierID',$supplierid1); + $sql="select pono,igrn,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name,sid, + sum(total) as total,file,ifile + from igr + where Status ='ST027' or Status='ST056' and PaymentStatus ='ST072' and sid='".$supplierid1."'"; - if ($fa and $aa != ''){ - $year="(im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')"; - $this->db->where($year); + + + if ($fa and $aa != ''){ + + //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + $sql.=" and (MaterialRcvdDate >= '".$fa."-04-01' and MaterialRcvdDate <= '".$aa."-03-31')"; + } if ($m!= ''){ - $month="monthname(im.MaterialRcvdDate) = '".$m."'"; - $this->db->where($month); + //$sql.="and monthname(im.CreatedDate) = '".$m."'"; + $sql.="and monthname(MaterialRcvdDate) = '".$m."'"; } - if($fdate!='' && $tdate!='') - { - $this->db->where('im.MaterialRcvdDate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"'); - } - //$this->db->group_by('pom.PONO'); - $query = $this->db->get(); - return $query->result(); + if ($fdate and $tdate != ''){ + $fromd= date("Y-m-d",strtotime($fdate)); + $tod=date("Y-m-d",strtotime($tdate)); + + $sql.="and date(MaterialRcvdDate) >= '".$fromd."' + and date(MaterialRcvdDate) <= '".$tod."'"; + + } + + $sql.="group by pono,igrn"; + $query = $this->db->query($sql); + return $query->result(); } function amountunpaidfilter($sd,$fa,$aa,$m,$fdate,$tdate) { - $status= array('ST027','ST056'); - $this->db->select('pom.PONO,pom.TotalOrderValue,sd.SupplierName,sd.SupplierID,im.MaterialRcvdDate,im.CreatedDate, - im.IGRNO'); - $this->db->from ('T_PurchaseOrder_Master pom'); - //$this->db->join('T_PurchaseOrder_BillUpload bu','pom.PONO=bu.PONO','left'); - $this->db->join('T_IGR_Master im','im.PONO=pom.PONO','left'); - $this->db->join('T_SupplierDetailsN sd','sd.SupplierID=pom.SupplierID','left'); - //$this->db->join('T_Bankporeport bm','bm.PONO=pom.PONO and bm.IsActive = 1','left'); - - //$this->db->join('T_Inwardgateregister_fileupload inward','inward.IGRNO =im.IGRNO','left'); inward.FilePath as iwFpath,bu.FilePath as poFilePath,im.IGRNO - $this->db->or_where_in('pom.Status',$status); - $this->db->where('pom.Paymentstatus',NO_PAIDIGR); - $this->db->where('sd.SupplierID',$sd); + $sql="select pono,igrn,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name,sid, + sum(total) as total,file,ifile + from igr + where Status ='ST027' or Status='ST056' and PaymentStatus ='ST072' and sid='".$sd."'"; - if ($fa and $aa != ''){ - $year="(im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')"; - $this->db->where($year); + + + if ($fa and $aa != ''){ + + //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + $sql.=" and (MaterialRcvdDate >= '".$fa."-04-01' and MaterialRcvdDate <= '".$aa."-03-31')"; + } if ($m!= ''){ - $month="monthname(im.MaterialRcvdDate) = '".$m."'"; - $this->db->where($month); + //$sql.="and monthname(im.CreatedDate) = '".$m."'"; + $sql.="and monthname(MaterialRcvdDate) = '".$m."'"; } - if($fdate!='' && $tdate!='') - { - $this->db->where('im.MaterialRcvdDate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"'); - } - // $this->db->group_by('pom.PONO'); - $query = $this->db->get(); - - return $query->result(); + if ($fdate and $tdate != ''){ + $fromd= date("Y-m-d",strtotime($fdate)); + $tod=date("Y-m-d",strtotime($tdate)); + + $sql.="and date(MaterialRcvdDate) >= '".$fromd."' + and date(MaterialRcvdDate) <= '".$tod."'"; } + $sql.="group by pono,igrn"; + $query = $this->db->query($sql); + return $query->result(); + } + + function bankinvoice($Customer,$fdate,$tdate) { $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'); @@ -578,32 +616,34 @@ function amountunpaid($supplierid1,$fa,$aa,$m,$fdate,$tdate) } function debitbankstatemet($Supplierid,$fdate,$tdate) - { + { - $status= array('ST027','ST056'); - $this->db->select('pom.PONO,pom.TotalOrderValue,sd.SupplierName,sd.SupplierID,im.MaterialRcvdDate,im.CreatedDate, - bm.Balancetopay,bm.Amountpaid,im.IGRNO'); - $this->db->from ('T_PurchaseOrder_Master pom'); - $this->db->join('T_IGR_Master im','im.PONO=pom.PONO','left'); - $this->db->join('T_SupplierDetailsN sd','sd.SupplierID=pom.SupplierID','left'); - $this->db->join('T_Bankporeport bm','bm.PONO=pom.PONO and bm.IsActive = 1','left'); - $this->db->or_where_in('pom.Status',$status); - $this->db->where('pom.Paymentstatus !=','ST070'); - if ($Supplierid != ''){ - $this->db->where('sd.SupplierID',$Supplierid); - } - if($fdate and $tdate != ''){ - $fromdate= date("Y-m-d",strtotime($fdate)); - $todate=date("Y-m-d",strtotime($tdate)); - $date = "date(im.CreatedDate) >= '".$fromdate."' - and date(im.CreatedDate) <= '".$todate."'"; - $this->db->WHERE($date); - } + $sql="select pono,igrn,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name,sid,Balancetopay,Amountpaid, + sum(total) as total,file,ifile + from bankdebit + where Status ='ST027' and PaymentStatus !='ST070'"; + + + + if ($Supplierid!= ''){ + + $sql.="and sid = '".$Supplierid."'"; - $this->db->group_by('pom.PONO'); - $query = $this->db->get(); - - return $query->result(); + } + + + if ($fdate and $tdate != ''){ + $fromd= date("Y-m-d",strtotime($fdate)); + $tod=date("Y-m-d",strtotime($tdate)); + + $sql.="and date(MaterialRcvdDate) >= '".$fromd."' + and date(MaterialRcvdDate) <= '".$tod."'"; + + } + + $sql.="group by pono,igrn"; + $query = $this->db->query($sql); + return $query->result(); } @@ -1729,10 +1769,10 @@ function receiptdata() return $r; } - function poamountstatus($podetails,$pono) + function poamountstatus($igrdetails,$igrno) { - $this->db->where('PONO',$pono); - $this->db->update('T_PurchaseOrder_Master',$podetails); + $this->db->where('IGRNO',$igrno); + $this->db->update('T_IGR_Master',$igrdetails); $r = $this->db->affected_rows(); return $r; @@ -1790,12 +1830,12 @@ function receiptdata() return $r; } - function PoStatusUpdate($pono,$PaymentStatus) + function IGRStatusUpdate($igrno,$PaymentStatus) { $this->db->set('Paymentstatus',$PaymentStatus); - $this->db->where('PONO',$pono); - $this->db->update('T_PurchaseOrder_Master'); + $this->db->where('IGRNO',$igrno); + $this->db->update('T_IGR_Master'); $r = $this->db->affected_rows(); return $r; } @@ -1852,12 +1892,12 @@ function receiptdata() // return $r; // } - function updateBankporeport($pono,$balancetopayupdate,$amountpaidupdate,$IsAct) + function updateBankporeport($igrno,$balancetopayupdate,$amountpaidupdate,$IsAct) { $this->db->set('Balancetopay',$balancetopayupdate); $this->db->set('Amountpaid',$amountpaidupdate); $this->db->set('IsActive',$IsAct); - $this->db->where('PONO',$pono); + $this->db->where('IGRNO',$igrno); //$this->db->where('mid',$Bankid); $this->db->update('T_Bankporeport'); $r = $this->db->affected_rows(); @@ -1886,11 +1926,11 @@ function receiptdata() $query = $this->db->get(); return $query->result(); } - function gettotalbankmappingpocount($pono) + function gettotalbankmappingpocount($igrno) { $this->db->select('count(Amountpaid)as countAmountpaid'); $this->db->from ('T_Bankmappingpo'); - $this->db->where('PONO',$pono); + $this->db->where('IGRNO',$igrno); $this->db->where('IsActive',1); //$this->db->group_by('T_Bankmappingpo.IGRLineItemNo'); $query = $this->db->get(); @@ -1906,11 +1946,11 @@ function receiptdata() $query = $this->db->get(); return $query->result(); } - function gettotalbankpoamount($pono) + function gettotalbankpoamount($igrno) { $this->db->select('Amountpaid,Balancetopay'); $this->db->from ('T_Bankporeport'); - $this->db->where('PONO',$pono); + $this->db->where('IGRNO',$igrno); $this->db->where('IsActive',1); //$this->db->group_by('T_Bankmappingpo.IGRLineItemNo'); $query = $this->db->get(); diff --git a/application/views/bankamountpaid.php b/application/views/bankamountpaid.php index bcafae25..da277cae 100644 --- a/application/views/bankamountpaid.php +++ b/application/views/bankamountpaid.php @@ -390,7 +390,8 @@ var paidamount=$('#ap'+i).text();//amountpaid var balancetopay=$('#btp'+i).text();//balancetopay -var Igritemno=$('#igritemno'+i).text();//igritemno +var igrno=$('#igrno'+i).text();//igritemno + var pono=$('#pono'+i).text();//pono var bankid=$('#bankingid'+i).val();//bankid @@ -404,7 +405,7 @@ var bankingclear=$('#bankingbalclear'+i).val(); var clearedbalance=$('#clearbal'+i).val(); $.ajax({ - data:{mappingid:mappingid,Totalpoamount:totalamount,paidamount:paidamount,balancetopay:balancetopay,pono:pono,IGRItemNo:Igritemno,bankid:bankid,balancetobankingclear:bankingclear,clearbalance:clearedbalance}, + data:{mappingid:mappingid,Totalpoamount:totalamount,paidamount:paidamount,balancetopay:balancetopay,pono:pono,igrno:igrno,bankid:bankid,balancetobankingclear:bankingclear,clearbalance:clearedbalance}, type:"POST", url:"DeletePo", success:function(data) diff --git a/application/views/bankamountunpaid.php b/application/views/bankamountunpaid.php index 54ca5a19..053bb46e 100644 --- a/application/views/bankamountunpaid.php +++ b/application/views/bankamountunpaid.php @@ -108,7 +108,7 @@ foreach($financialyear as $item) { } ?> -