From 2530d3e017c1ca754dbfcc15d9f760bb067676e3 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Sat, 28 Apr 2018 13:35:36 +0530 Subject: [PATCH] changes in bank statement upload anddeleted login id not allow --- application/controllers/cashbook.php | 96 +++++++++++++++++------- application/models/cashbook_model.php | 20 ++++- application/models/login_model.php | 8 +- application/views/BatchcardMaintAdd.php | 2 +- application/views/BatchcardMaintEdit.php | 2 +- 5 files changed, 92 insertions(+), 36 deletions(-) diff --git a/application/controllers/cashbook.php b/application/controllers/cashbook.php index 58960b93..0eacfe15 100755 --- a/application/controllers/cashbook.php +++ b/application/controllers/cashbook.php @@ -161,35 +161,74 @@ class cashbook extends BaseController $inputFileName = $_FILES['userfile']['tmp_name']; require_once APPPATH .'third_party/PHPExcel/IOFactory.php'; $objTpl = PHPExcel_IOFactory::load($inputFileName); - $sheet = $objTpl->getActiveSheet(0) ;//->toArray(null, NULL, True, True); - $highestRow = $sheet->getHighestRow(); - $highestColumn = $sheet->getHighestColumn(); + $sheet = $objTpl->getActiveSheet();//->toArray(null, true,true,true); - - $bank = $this->input->post('bankbranchname'); - $fileupload= array('Bankname'=>$bank,'document'=>$document); - - $res = $this->cashbook_model->bankfile($fileupload); - for($x=2;$x<=$highestRow;$x++){ - - $date = date('Y-m-d', PHPExcel_Shared_Date::ExcelToPHP( $sheet->getCell('A'.$x)->getValue())); - //echo $val; die(); - $valuedate = date('Y-m-d', PHPExcel_Shared_Date::ExcelToPHP( $sheet->getCell('B'.$x)->getValue())); - //PHPExcel_Shared_Date::ExcelToPHP($valuedate); - //echo date('Y-m-d',strtotime($valuedate));die; - $chqno = $sheet->getCell('C'.$x)->getValue(); - $narration = $sheet->getCell('D'.$x)->getValue(); - $cod =$sheet->getCell('E'.$x)->getValue(); - $debit =$sheet->getCell('F'.$x)->getValue(); - $credit=$sheet->getCell('G'.$x)->getValue(); - $balance=$sheet->getCell('H'.$x)->getValue(); - - - $filedataupload= array('reportdate'=>$date,'valuedate'=>$valuedate,'chequeNo'=>$chqno,'Narration'=>$narration,'Cod'=>$cod,'Debit'=>$debit,'Credit'=>$credit,'Balance'=>$balance,'Bankname'=>$bank,); - //print_r($filedataupload); + $highestRow = $sheet->getHighestRow(); + $highestColumn = $sheet->getHighestColumn(); + + + $highestRow4=$highestRow-4; + + + $bank = $this->input->post('bankbranchname'); + $fileupload= array('Bankname'=>$bank,'document'=>$document); + + $res = $this->cashbook_model->bankfile($fileupload); + for($x=22;$x<=$highestRow4;$x++){ + + + + + + $t=$sheet->getCell('A'.$x)->getValue(); + $dat= str_replace('/','-',$t); + + if (empty($dat)) + { + $Date1 = NULL; + } + else + { + $Date1 = strtotime( $dat); + $Date1 = date("Y-m-d ", $Date1); + } + + + + $s=$sheet->getCell('B'.$x)->getValue(); + $dat1= str_replace('/','-',$s); + + + + if (empty($dat1)) + { + $Date2 = NULL; + } + else + { + + $Date2 = date('Y-m-d',strtotime($dat1)); + + } + + + $chqno = $sheet->getCell('C'.$x)->getValue(); + $narration = $sheet->getCell('D'.$x)->getValue(); + $cod =$sheet->getCell('E'.$x)->getValue(); + $debit =$sheet->getCell('F'.$x)->getValue(); + + $credit=$sheet->getCell('G'.$x)->getValue(); + $balance=$sheet->getCell('H'.$x)->getValue(); + + + $filedataupload= array('reportdate'=>$Date1,'valuedate'=>$Date2,'chequeNo'=>$cod,'Narration'=>$narration,'Cod'=> $chqno,'Debit'=>$debit,'Credit'=>$credit,'Balance'=>$balance,'Bankname'=>$bank); + + + $res = $this->cashbook_model->bankfiledata($filedataupload); } - if( $res == 1 ){ + + if( $res == 1 ){ echo ""; } else @@ -198,7 +237,8 @@ class cashbook extends BaseController } } } - + + function addIncomeExpense() { @@ -439,7 +479,7 @@ class cashbook extends BaseController { $error = array('error' => $this->upload->display_errors()); $uploadfilename = ''; - print_r($error); + // print_r($error); return 0; } diff --git a/application/models/cashbook_model.php b/application/models/cashbook_model.php index 45ed2e9f..57f62392 100755 --- a/application/models/cashbook_model.php +++ b/application/models/cashbook_model.php @@ -125,13 +125,27 @@ class cashbook_model extends CI_Model return $r; } function bankfiledata($filedataupload) - { - $this->db->insert('T_bankreport', $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 bankstatement($fdate,$tdate){ diff --git a/application/models/login_model.php b/application/models/login_model.php index 9e7916d3..65e28863 100755 --- a/application/models/login_model.php +++ b/application/models/login_model.php @@ -15,9 +15,11 @@ class Login_model extends CI_Model $this->db->join('tbl_roles as Roles','Roles.roleId = BaseTbl.roleId'); $this->db->join('T_Employee_Details as Emp','BaseTbl.EmpID = Emp.EmpID'); $this->db->join('T_DepartmentDetails as DEPT','Emp.Departmentcode = DEPT.DEPCode'); - $this->db->where('BaseTbl.email', $email); - $this->db->or_where('Emp.ContactNumber', $email); - $this->db->where('BaseTbl.isDeleted', 0); + $this->db->where('BaseTbl.isDeleted !=',1); + $this->db->where('BaseTbl.email', $email); + $this->db->or_where('Emp.ContactNumber', $email); + $this->db->where('BaseTbl.isDeleted !=',1); + $query = $this->db->get(); diff --git a/application/views/BatchcardMaintAdd.php b/application/views/BatchcardMaintAdd.php index 099b5799..010bf454 100755 --- a/application/views/BatchcardMaintAdd.php +++ b/application/views/BatchcardMaintAdd.php @@ -48,7 +48,7 @@
-
+
Maintenance         Breakdown
diff --git a/application/views/BatchcardMaintEdit.php b/application/views/BatchcardMaintEdit.php index 55ab08f9..0c6006a8 100755 --- a/application/views/BatchcardMaintEdit.php +++ b/application/views/BatchcardMaintEdit.php @@ -100,7 +100,7 @@ if(!empty($MaintEdit))
-
+
Maintenance         Breakdown