From 0d28edf40121fbec168662126246805f8d7bb939 Mon Sep 17 00:00:00 2001 From: Sanjeev Date: Tue, 22 Jun 2021 14:43:17 +0530 Subject: [PATCH] Bank Upload Issues Fixes : ps --- application/config/database.php | 2 +- application/controllers/cashbook.php | 39 +++++++++++++++++---------- application/models/cashbook_model.php | 18 ++++++++++--- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/application/config/database.php b/application/config/database.php index 42fde493..e6e6d301 100644 --- a/application/config/database.php +++ b/application/config/database.php @@ -48,7 +48,7 @@ $active_group = 'default'; $active_record = TRUE; -$db['default']['hostname'] = 'sidharthindustries.com'; +$db['default']['hostname'] = '35.213.153.5'; // $db['default']['username'] = 'kasiram9_prod'; // $db['default']['password'] = 'sia!1234'; // $db['default']['database'] = 'kasiram9_SIAPROD'; diff --git a/application/controllers/cashbook.php b/application/controllers/cashbook.php index 7da72d6d..75e0ba8d 100644 --- a/application/controllers/cashbook.php +++ b/application/controllers/cashbook.php @@ -227,21 +227,26 @@ class cashbook extends BaseController } function bankfileupload() { - $document = null; - + //document => default NULL + $document = null; + // fs => File Name default 0 $fs = 0; if(!empty($_FILES['userfile']['name'])) - { + { //echo "FILE AVAILABLE"; - $config['file_name'] = $_FILES['userfile']['name']; - $myFIle = $config['file_name']; - + $config['file_name'] = $_FILES['userfile']['name']; // This Also FileName with format. + $myFIle = $config['file_name']; // This Also FileName with format. + // xls File destination folder Given Below. $config['upload_path'] = 'uploads/banking/'; $path = $config['upload_path']; - //$filename = $config['file_name']; + //Destionation Path => uploads/banking. + $filename = $config['file_name'];// This Also FileName with format. $document = $path.$filename; - //echo $document; + + $fs = $this->uploadFile1(); + // $this->function_alert($fs); + // echo "uploadFile1()".$fs;die(); $document = $path.$fs; $created_by = $this->session->userdata('userId'); @@ -335,11 +340,12 @@ class cashbook extends BaseController // $IsActive=0; $filedataupload= array('reportdate'=>$Date1,'valuedate'=>$Date2,'chequeNo'=>$cod,'Narration'=>$narration,'Cod'=> $chqno,'Debit'=>$debit,'Credit'=>$credit,'cbalancetocleared'=>$credit,'Balance'=>$balance,'Bankname'=>$bank,'Status'=>$Status,'cstatus'=>$cstatus); - - + // print_r($filedataupload); $res = $this->cashbook_model->bankfiledata($filedataupload); + // echo "response ".$res; } + // die(); $balance= array('filename'=>$config['file_name'],'created_by'=>$created_by,'openingbalance'=>$openingbalance,'closingbalance'=>$closingbalance); $bal = $this->cashbook_model->balance($balance); @@ -349,7 +355,7 @@ class cashbook extends BaseController } else { - echo ""; + echo ""; } } } @@ -598,14 +604,16 @@ class cashbook extends BaseController function uploadFile1() { - //echo "INSIDE UPLOAFD"; + // echo "I am Here INSIDE UPLOAD"; + // die(); //$this->load->library('upload') $pathinfo = pathinfo($_FILES['userfile']['name']); $config['upload_path'] = 'uploads/banking/'; - $config['allowed_types'] = 'png|jpg|jpeg|xlsx'; + // $config['allowed_types'] = 'png|jpg|jpeg|xlsx'; + $config['allowed_types'] = 'xlsx|csv|xls'; $config['file_name'] = $_FILES['userfile']['name']; - // $config['overwrite'] = true; + $config['overwrite'] = true; //Load upload library and initialize configuration $this->load->library('upload',$config); @@ -2345,4 +2353,7 @@ $amountInWords = "Rupees " . $result ." Paise ". $points." Only"; } } +function function_alert($msg) { + echo ""; +} ?> \ No newline at end of file diff --git a/application/models/cashbook_model.php b/application/models/cashbook_model.php index d22906c9..6c8b1fb3 100644 --- a/application/models/cashbook_model.php +++ b/application/models/cashbook_model.php @@ -255,7 +255,7 @@ function finyear(){ { - $this->db->select('reportdate,Narration,Balance'); + $this->db->select('reportdate,Narration,Balance,ID,IsActive'); $this->db->from('T_bankreport'); $this->db->where('reportdate',$filedataupload['reportdate']); $this->db->where('Narration',$filedataupload['Narration']); @@ -263,12 +263,22 @@ function finyear(){ $query = $this->db->get(); if ($query->num_rows() > 0){ - return true; - + $data = array_shift($query->result_array()); + // return true; + // echo "Data Available so Update Functionality"; + // echo($data['ID']); + // echo"
"; + $this->db->where('ID',$data['ID']); + // $this->db->where('IsActive',NULL); + $this->db->update('T_bankreport',$filedataupload); + $r = $this->db->affected_rows(); + // print_r($this->db->last_query()); + return $r; } else{ + // echo "Data not Available so insert"; $this->db->insert('T_bankreport', $filedataupload); - $r = $this->db->affected_rows(); + $r = $this->db->affected_rows(); //print_r($this->db->last_query()); return $r; }