diff --git a/application/controllers/cashbook.php b/application/controllers/cashbook.php index d0ca44c1..341e8a89 100755 --- a/application/controllers/cashbook.php +++ b/application/controllers/cashbook.php @@ -514,6 +514,7 @@ class cashbook extends BaseController $cashbookdatas = array('type'=>$acc_type,'code'=>$acc_code,'name'=>$acc_name,'accountname'=>$acc_pname,'categories'=>$acc_categories,'description'=>$acc_desc,'status'=>$acc_status,'created_on'=>$acc_createddt); // print_r($cashbookdatas); + $result = $this->cashbook_model->Cashbook($cashbookdatas); } } @@ -544,6 +545,7 @@ class cashbook extends BaseController $this->load->model('cashbook_model'); $data['DepDetails'] = $this->cashbook_model->viewdepartment($cash); + //$data['deletefile'] = $this->cashbook-model->deletefile($cash); $data['dropdownvalues'] = $this->cashbook_model->getAccounTypes(); //print_r( $data['DepDetails']);die(); @@ -603,6 +605,9 @@ class cashbook extends BaseController $description1 = $this->input->post('description'); $deleteflag = $this->input->post('deleteflag'); $oldfile = $this->input->post('oldfile'); + $amounttype = $this->input->post('amounttype'); + $bankid=$this->input->post('bankid'); + $normalid=$this->input->post('normalid'); $document =null; //$document1=$this->input->post('myfile'); @@ -632,9 +637,48 @@ class cashbook extends BaseController $document = null; } } + + $updateaccount = array('type'=>$option,'account_code'=>$accountcode1,'date'=>$date,'towhom'=>$towhome1,'invoice_no'=>$Invoiceno1,'merchant'=>$merchant1,'merchant_gst'=>$Merchantgst1,'HSN'=>$hsn1,'value_before_gst'=>$valuebeforegST1,'sgst'=>$SGST1,'cgst'=>$CGST1,'igst'=>$IGST1,'total'=>$totalamount1,'description'=>$description1,'document'=>$document); + $res = $this->cashbook_model->updatedepartment($updateaccount,$id1); //print_r($updateaccount);die(); - $res = $this->cashbook_model->updatedepartment($updateaccount,$id1); + $cashbookamount=$this->cashbook_model->cashbookamount($bankid); + $invoiceamount=$this->cashbook_model->invoiceamonut($bankid); + $poamount=$this->cashbook_model->poamonut($bankid); + foreach($invoiceamount as $ia) + { + $invam=$ia->amountreceived; + } + foreach($poamount as $pa) + { + $poamnt=$pa->amountpaid; + } + foreach($cashbookamount as $ca) + { + $cashamnt=$ca->total; + } + + //print_r($invoiceamount); + if($amounttype=='CREDIT') + { + $updatecredit=$invam+$cashamnt; + //print_r($updateamount); + $cashbookstatus1= array('cclearbalance'=>$updatecredit,'cstatus'=>$statu); + //print_r($cashbookstatus1); + //die(); + $res1 = $this->cashbook_model->cashcreditupdate($cashbookstatus1,$bankid); + } + + else + { + $updatedepit=$poamnt+$cashamnt; + $cashbookstatus = array('Clearbalance'=>$updatedepit,'Status'=>$stat); + print_r($cashbookstatus); + //die(); + $res = $this->cashbook_model->cashbankupdate($cashbookstatus,$bankid); + + } + //if( $res == 1 ){ echo ""; diff --git a/application/models/cashbook_model.php b/application/models/cashbook_model.php index 996afdc8..74f173c6 100755 --- a/application/models/cashbook_model.php +++ b/application/models/cashbook_model.php @@ -87,8 +87,9 @@ class cashbook_model extends CI_Model } function viewdepartment($sid='') { - $sql="SELECT ie.*,ac.name,date_format(ie.date,'%d-%m-%Y')as date FROM t_income_expense ie + $sql="SELECT ie.*,br.ID,ac.name,ie.id,date_format(ie.date,'%d-%m-%Y')as date FROM t_income_expense ie join t_accountcode ac on ac.code=ie.account_code + 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()); @@ -234,8 +235,39 @@ function debitpolist($bankid) balancetoreceived,amountreceived'); $this->db->from ('T_Bankinvoicereport'); $this->db->where('bankid',$bankid); - - $this->db->group_by('invoiceno'); + $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_Bankinvoicereport'); + $this->db->where('bankid',$bankid); + //$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_Bankporeport'); + $this->db->where('mid',$bankid); + //$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->group_by('invoiceno'); $query = $this->db->get(); return $query->result(); diff --git a/application/views/bankcashnew.php b/application/views/bankcashnew.php index a8c66e44..67c37153 100644 --- a/application/views/bankcashnew.php +++ b/application/views/bankcashnew.php @@ -15,9 +15,13 @@ $(function() { { $("#accode").append( $('').val(item.code).html(item.name)); } + else(item.type == 'PAYMENT') + { + $("#accode").append( $('').val(item.code).html(item.name)); + } }); - + $('#gst').click(function(){ $('#gstarea').toggle(); @@ -65,7 +69,7 @@ function isNumberKey(evt) return true; } - +//$(document).ready(function(id) function loadAccountType(id) { //alert('called'+id); @@ -337,6 +341,11 @@ if(!empty($cashbanking)) +