MMCT TEAM
Server IP : 103.191.208.50  /  Your IP : 216.73.216.53
Web Server : LiteSpeed
System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64
User : celkcksm ( 1031)
PHP Version : 7.4.33
Disable Function : show_source, system, shell_exec, passthru, popen, exec
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/celkcksm/banking.ncriptech.com/application/controllers/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/celkcksm/banking.ncriptech.com/application/controllers/admin/Banking.php
<?php defined('BASEPATH') OR exit('No direct script access allowed');
date_default_timezone_set("Asia/Kolkata");
class Banking extends MY_Controller {

	public function __construct(){

		parent::__construct();
		auth_check(); // check login auth
		$this->rbac->check_module_access();

		$this->load->model('admin/admin_model', 'admin');
		$this->load->model('admin/user_model', 'user_model');
		$this->load->model('admin/activity_model', 'activity_model');
		$this->load->model('admin/banking_model', 'banking_model');
	}

	//-----------------------------------------------------------
	public function index(){
		$data = array();

		if(isset($_POST['submit'])){

			//echo 1 ; exit;
			$date_range = $this->input->post('date_range');
			$accno = $this->input->post('account_no');

			$date_rangeexplode = explode("-",$date_range) ;
			$formdate = strtotime($date_rangeexplode[0]);
			$todate = strtotime($date_rangeexplode[1]);

			$data['formdate'] = $formdate ;
			$data['todate'] = $todate ;
			$data['accid'] = $accno;
			$data['daterr'] = $date_range;
			$data['formdatee'] =date('d-m-Y',strtotime($date_rangeexplode[0]));
			$data['todateee'] = date('d-m-Y', strtotime($date_rangeexplode[1])) ; 


			$data['txnstate'] = $this->banking_model->get_all_statement($accno,$formdate, $todate);

			$this->load->view('admin/includes/_header');
			$this->load->view('admin/banking/statement',$data);
			$this->load->view('admin/includes/_footer');

		}else{
		     
			$this->load->view('admin/includes/_header');
			$this->load->view('admin/banking/statement', $data);
			$this->load->view('admin/includes/_footer');


		}



		
	}

    public function credit(){

		$data = array();
		
		if(isset($_POST['submit'])){


			$this->form_validation->set_rules('account_no', 'Account Number', 'required');
			$this->form_validation->set_rules('amount', 'Amount', 'trim|required');
			$this->form_validation->set_rules('particulars', 'Description', 'required');
			$this->form_validation->set_rules('chq_no', 'Ref No/Cheque No', 'required');

			if ($this->form_validation->run() == FALSE) {
				$data = array(
					'errors' => validation_errors()
				);
				$this->session->set_flashdata('errors', $data['errors']);
				redirect(base_url('admin/banking/credit'));
			}
			else{

				$accno = $this->input->post('account_no');
				$amunt = $this->input->post('amount');
				$particulars = $this->input->post('particulars');
				$chwno = $this->input->post('chq_no');
				

				$data_credit = array(
					"account_id"=>$accno,
					"amount" => $amunt,
					"particulars" => $particulars,
					"ref_no" => $chwno,
					"doe" => strtotime(date('Y-m-d')),
					"added_by" => $this->session->userdata('user_id'),
					"status" => 1,
					"created_at" => date('Y-m-d : h:m:s'),
					"updated_at" => date('Y-m-d : h:m:s'),
					

				);

				$data_transaction = array(
					"from_account_id"=>$accno,
					"description"=> $particulars,
					"credit"=> $amunt,
					"doe"=>strtotime(date('Y-m-d')),
					"refno_chq_no"=>$chwno,
					"status" => 1,
					"created_at" => date('Y-m-d : h:m:s'),
					"updated_at" => date('Y-m-d : h:m:s'),

				);


				$data = $this->security->xss_clean($data);
				$result = $this->banking_model->add_credit_transaction($data_credit,$data_transaction);
				
				if($result){

					// Activity Log 
					$this->activity_model->add_log(1);

					$this->session->set_flashdata('success', $amunt.'  has been created successfully!');
					redirect(base_url('admin/banking/credit'));
				}


			}
			

		}else{

			$this->load->view('admin/includes/_header');
			$this->load->view('admin/banking/credit', $data);
			$this->load->view('admin/includes/_footer');

		}

        

    }

    public function debit(){

		

		$data = array();
		
		if(isset($_POST['submit'])){


			$this->form_validation->set_rules('account_no', 'Account Number', 'required');
			$this->form_validation->set_rules('amount', 'Amount', 'trim|required');
			$this->form_validation->set_rules('particulars', 'Description', 'required');
			$this->form_validation->set_rules('chq_no', 'Ref No/Cheque No', 'required');

			if ($this->form_validation->run() == FALSE) {
				$data = array(
					'errors' => validation_errors()
				);
				$this->session->set_flashdata('errors', $data['errors']);
				redirect(base_url('admin/banking/debit'));
			}
			else{

				$accno = $this->input->post('account_no');
				$amunt = $this->input->post('amount');
				$particulars = $this->input->post('particulars');
				$chwno = $this->input->post('chq_no');
				

				$data_credit = array(
					"account_id"=>$accno,
					"amount" => $amunt,
					"particulars" => $particulars,
					"ref_no" => $chwno,
					"doe" => strtotime(date('Y-m-d')),
					"added_by" => $this->session->userdata('user_id'),
					"status" => 1,
					"created_at" => date('Y-m-d : h:m:s'),
					"updated_at" => date('Y-m-d : h:m:s'),
					

				);

				$data_transaction = array(
					"from_account_id"=>$accno,
					"description"=> $particulars,
					"debit"=> $amunt,
					"doe"=>strtotime(date('Y-m-d')),
					"refno_chq_no"=>$chwno,
					"status" => 1,
					"created_at" => date('Y-m-d : h:m:s'),
					"updated_at" => date('Y-m-d : h:m:s'),

				);


				$data = $this->security->xss_clean($data);
				$result = $this->banking_model->add_debit_transaction($data_credit,$data_transaction);
				if($result){

					// Activity Log 
					$this->activity_model->add_log(1);

					$this->session->set_flashdata('success', $amunt.'  has been created successfully!');
					redirect(base_url('admin/banking/debit'));
				}


			}
			

		}else{

			$this->load->view('admin/includes/_header');
			$this->load->view('admin/banking/debit', $data);
			$this->load->view('admin/includes/_footer');

		}

        

    }

    public function datatable_statement(){

        				   					   
		$records['data'] = $this->user_model->get_all_users();
		$data = array();

		$i=0;
		foreach ($records['data']   as $row) 
		{  
			$status = ($row['is_active'] == 1)? 'checked': '';
			$data[]= array(
				++$i,
				$row['username'],
				$row['email'],
				$row['mobile_no'],
				'<span class=\'btn btn-link\'>'.get_admin_name($row['added_by']).'</span>',
				date_time($row['created_at']),	
				'<input class="tgl_checkbox tgl-ios" 
				data-id="'.$row['user_id'].'" 
				id="cb_'.$row['user_id'].'"
				type="checkbox"  
				'.$status.'><label for="cb_'.$row['user_id'].'"></label>',		

				'<a title="View" class="view btn btn-xs btn-info" href="'.base_url('admin/users/edit/'.$row['user_id']).'"> <i class="fa fa-eye"></i></a>
				<a title="Edit" class="update btn btn-xs btn-warning" href="'.base_url('admin/users/edit/'.$row['user_id']).'"> <i class="fa fa-pencil-square-o"></i></a>
				<a title="Delete" class="delete btn btn-xs btn-danger" href='.base_url("admin/users/delete/".$row['user_id']).' title="Delete" onclick="return confirm(\'Do you want to delete ?\')"> <i class="fa fa-trash-o"></i></a>'
			);
		}
		$records['data']=$data;
		echo json_encode($records);	
    }



    public function view_account_list(){

        $this->load->view('admin/includes/_header');
		$this->load->view('admin/banking/list_account');
		$this->load->view('admin/includes/_footer');

    }


    public function datatable_account_list(){

        				   					   
		$records['data'] = $this->banking_model->get_all_account_list();
		$data = array();

		$i=0;
		foreach ($records['data']   as $row) 
		{  
			$status = ($row['status'] == 1)? 'checked': '';
			$data[]= array(
				++$i,
				$row['customer_name'],
				$row['account_type'],
				$row['address'],
				'<input class="tgl_checkbox tgl-ios" 
				data-id="'.$row['id'].'" 
				id="cb_'.$row['id'].'"
				type="checkbox"  
				'.$status.'><label for="cb_'.$row['id'].'"></label>',		

				'<a title="View" class="view btn btn-xs btn-info" href="'.base_url('admin/banking/view_account/'.$row['id']).'"> <i class="fa fa-eye"></i></a>
				<a title="Edit" class="update btn btn-xs btn-warning" href="'.base_url('admin/users/edit_account/'.$row['id']).'"> <i class="fa fa-pencil-square-o"></i></a>
				<a title="Delete" class="delete btn btn-xs btn-danger" href='.base_url("admin/users/delete_account/".$row['id']).' title="Delete" onclick="return confirm(\'Do you want to delete ?\')"> <i class="fa fa-trash-o"></i></a>'
			);
		}
		$records['data']=$data;
		echo json_encode($records);	

    }


    public function add_account(){

        
		
		$this->rbac->check_operation_access(); // check opration permission

		$data['admin_roles'] = $this->admin->get_admin_roles();


		if($this->input->post('submit')){
			$this->form_validation->set_rules('acc_name', 'Account Name', 'required');
			$this->form_validation->set_rules('accnumber', 'Account Number', 'trim|is_unique[ci_bank_account.account_number]|required');
			$this->form_validation->set_rules('address', 'Address', 'required');
			$this->form_validation->set_rules('pincode', 'Pincode', 'trim|numeric|required');
			$this->form_validation->set_rules('cifnum', 'CIF Number', 'required');
			$this->form_validation->set_rules('account_type', 'Account Type', 'required');
			$this->form_validation->set_rules('interest_rate', 'Interest Rate', 'required');
			$this->form_validation->set_rules('micr_Code', 'MICR Code', 'required');
			$this->form_validation->set_rules('email', 'Email', 'trim|valid_email|required');
			$this->form_validation->set_rules('mobile_no', 'Number', 'trim|required');
			$this->form_validation->set_rules('branch_name', 'Branch Name', 'trim|required');
			$this->form_validation->set_rules('ifsc_code', 'IFSC Code', 'trim|required');
			


			if ($this->form_validation->run() == FALSE) {
				$data = array(
					'errors' => validation_errors()
				);
				$this->session->set_flashdata('errors', $data['errors']);
				redirect(base_url('admin/banking/add_account'));
			}
			else{
				$data = array(
					'added_by' => $this->session->userdata('user_id'),
					'customer_name' => $this->input->post('acc_name'), 
					'address' => $this->input->post('address'),
					'cif' => $this->input->post('cifnum'),
					'state' => $this->input->post('state'),
					'email' => $this->input->post('email'),
					'mobile_no' => $this->input->post('mobile_no'),
					'pin' => $this->input->post('pincode'),
					'account_number' => $this->input->post('accnumber') ,
					'account_type' => $this->input->post('account_type') ,
					'branch' => $this->input->post('branch_name') ,
					'branch_code' => $this->input->post('branch_code'),
					'interest_rate' => $this->input->post('interest_rate') ,
					'mod_balance' => $this->input->post('mod_balance') ,
					'ifsc_code' => $this->input->post('ifsc_code') ,
					'micr_code' => $this->input->post('micr_Code') ,
					'nominee_regis' => $this->input->post('nominee_name') ,
					'status' => 1,
					'created_at' => date('Y-m-d : h:m:s'),
					'updated_at' => date('Y-m-d : h:m:s'),
				);
				$data = $this->security->xss_clean($data);
				$result = $this->banking_model->add_account($data);
				if($result){

					// Activity Log 
					$this->activity_model->add_log(1);

					$this->session->set_flashdata('success', 'User has been added successfully!');
					redirect(base_url('admin/banking/view_account_list'));
				}
			}
		}
		else{
			$this->load->view('admin/includes/_header');
			$this->load->view('admin/banking/add_account', $data);
			$this->load->view('admin/includes/_footer');
		}
		

    }

	public function view_account($id){


	}


	public function edit_account($id){


	}

	public function delete_account($id){

		$this->rbac->check_operation_access(); // check opration permission
		
		$this->db->delete('ci_bank_account', array('id' => $id));

		// Activity Log 
		$this->activity_model->add_log(3);

		$this->session->set_flashdata('success', 'Account has been deleted successfully!');
		redirect(base_url('admin/banking/view_benificary'));

	}

	public function view_benificary(){

		$this->load->view('admin/includes/_header');
		$this->load->view('admin/banking/list_benificiary');
		$this->load->view('admin/includes/_footer');
	}


	public function datatable_benificary_list(){

		 				   					   
		$records['data'] = $this->banking_model->get_all_benifici();
		$data = array();

		$i=0;
		foreach ($records['data']   as $row) 
		{  
			$get_account_holdr_name = $this->banking_model->get_account_holder_name($row['account_id']);
			$status = ($row['status'] == 1)? 'checked': '';
			$data[]= array(
				++$i,
				$get_account_holdr_name['customer_name'],
				$row['b_name'],
				$row['b_account'],
				$row['b_ifsc'],
				$row['b_branch_name'],					
				'<input class="tgl_checkbox tgl-ios" 
				data-id="'.$row['id'].'" 
				id="cb_'.$row['id'].'"
				type="checkbox"  
				'.$status.'><label for="cb_'.$row['id'].'"></label>',				
				'<a title="Edit" class="update btn btn-xs btn-warning" href="'.base_url('admin/banking/edit_benifi/'.$row['id']).'"> <i class="fa fa-pencil-square-o"></i></a>
				<a title="Delete" class="delete btn btn-xs btn-danger" href='.base_url("admin/banking/delete_benifi/".$row['id']).' title="Delete" onclick="return confirm(\'Do you want to delete ?\')"> <i class="fa fa-trash-o"></i></a>'
			);
		}
		$records['data']=$data;
		echo json_encode($records);	


	}


	public function add_beneficiary(){

		
		$this->rbac->check_operation_access(); // check opration permission

		$data['admin_roles'] = $this->admin->get_admin_roles();

		if($this->input->post('submit')){
			$this->form_validation->set_rules('accnumber', 'Account Number ', 'trim|is_unique[ci_account_benificiary.b_account]|required');
			$this->form_validation->set_rules('b_name', 'Benificiary Name', 'trim|required');
		//	$this->form_validation->set_rules('email', 'Email', 'trim|valid_email|required');
		//	$this->form_validation->set_rules('mobile_no', 'Number', 'trim|required');
			$this->form_validation->set_rules('b_branch_name', 'Branch Name', 'trim|required');
			$this->form_validation->set_rules('b_ifsc', 'IFSC Code', 'trim|required');
			$this->form_validation->set_rules('bank_name', 'Bank Name', 'trim|required');
			

			if ($this->form_validation->run() == FALSE) {
				$data = array(
					'errors' => validation_errors()
				);
				$this->session->set_flashdata('errors', $data['errors']);
				redirect(base_url('admin/banking/add_beneficiary'),'refresh');
			}
			else{
				$data = array(
					'added_by' => $this->session->userdata('user_id'),
					'account_id' => $this->input->post('acc_name'), 
					'b_email' => $this->input->post('email'),
					'b_mobile' => $this->input->post('mobile_no'),
					'b_name' => $this->input->post('b_name'),
					'b_branch_name' => $this->input->post('b_branch_name'),
					'b_account' => $this->input->post('accnumber'),
					'b_bank_name' => $this->input->post('bank_name'),
					'b_ifsc' => $this->input->post('b_ifsc'),
					'status' => 1,
					'created_at' => date('Y-m-d : h:m:s'),
					'updated_at' => date('Y-m-d : h:m:s'),
				);
				$data = $this->security->xss_clean($data);
				$result = $this->banking_model->add_benificiary($data);
				if($result){

					// Activity Log 
					$this->activity_model->add_log(1);

					$this->session->set_flashdata('success', 'Benificiary has been added successfully!');
					redirect(base_url('admin/banking/view_benificary'));
				}
			}
		}
		else{
			$this->load->view('admin/includes/_header');
			$this->load->view('admin/banking/add_benificiary', $data);
			$this->load->view('admin/includes/_footer');
		}
		

	}
	
	public function change_benificary_status(){
	    
	    $this->banking_model->change_benificary_status();
	}

	public function edit_benifi($id){

		$data['id'] = $id ;
		$data['befi_det'] = $this->banking_model->get_benifi_details_info($id);
		$this->rbac->check_operation_access(); // check opration permission

		$data['admin_roles'] = $this->admin->get_admin_roles();

		if($this->input->post('submit')){
			$this->form_validation->set_rules('accnumber', 'Account Number ', 'trim|required');
			$this->form_validation->set_rules('b_name', 'Benificiary Name', 'trim|required');
		//	$this->form_validation->set_rules('email', 'Email', 'trim|valid_email|required');
		//	$this->form_validation->set_rules('mobile_no', 'Number', 'trim|required');
			$this->form_validation->set_rules('b_branch_name', 'Branch Name', 'trim|required');
			$this->form_validation->set_rules('b_ifsc', 'IFSC Code', 'trim|required');
			$this->form_validation->set_rules('bank_name', 'Bank Name', 'trim|required');
			

			if ($this->form_validation->run() == FALSE) {
				$data = array(
					'errors' => validation_errors()
				);
				$this->session->set_flashdata('errors', $data['errors']);
				redirect(base_url('admin/banking/edit_beneficiary/'.$id),'refresh');
			}
			else{
				$data = array(
					'added_by' => $this->session->userdata('user_id'),
					'account_id' => $this->input->post('acc_name'), 
					'b_email' => $this->input->post('email'),
					'b_mobile' => $this->input->post('mobile_no'),
					'b_name' => $this->input->post('b_name'),
					'b_branch_name' => $this->input->post('b_branch_name'),
					'b_account' => $this->input->post('accnumber'),
					'b_bank_name' => $this->input->post('bank_name'),
					'b_ifsc' => $this->input->post('b_ifsc'),
					'status' => 1,
					'created_at' => date('Y-m-d : h:m:s'),
					'updated_at' => date('Y-m-d : h:m:s'),
				);
				$data = $this->security->xss_clean($data);
				$result = $this->banking_model->update_benificiary($data,$id);
				if($result){

					// Activity Log 
					$this->activity_model->add_log(1);

					$this->session->set_flashdata('success', 'Benificiary has been updated successfully!');
					redirect(base_url('admin/banking/view_benificary'));
				}
			}
		}
		else{
			$this->load->view('admin/includes/_header');
			$this->load->view('admin/banking/edit_benificiary', $data);
			$this->load->view('admin/includes/_footer');
		}
		



	}

	public function delete_benifi($id){

		$this->rbac->check_operation_access(); // check opration permission
		
		$this->db->delete('ci_account_benificiary', array('id' => $id));

		// Activity Log 
		$this->activity_model->add_log(3);

		$this->session->set_flashdata('success', 'Benificiary has been deleted successfully!');
		redirect(base_url('admin/banking/view_benificary'));

	}
	
	public function download_report_new($frm,$tod,$acno){
	    
	    date_default_timezone_set("Asia/Kolkata");
	    
	    $frm = strtotime($frm);
	    
	    // echo "<br>";
	     
	    $tod = strtotime($tod);
	    
	    //echo "<br>";

		$this->load->library('fpdf_master');
		$imgpath = base_url().'assets/sbi_logo.png';
		//$this->fpdf->Image("$imgpath", 15, 25, 35, 0, 'PNG');

		//get all account info 
		$accinfo = $this->db->query("select * from ci_bank_account where id='".$acno."'")->result();

		//$this->fpdf->ln(30);
		
		$this->fpdf->SetFont('Helvetica','B',12);
		$this->fpdf->Cell(205,5,'STATEMENT OF ACCOUNT','0','0','C');
		
		$this->fpdf->SetFont('Arial','B',14);
		$this->fpdf->line(85,14,140,14);
		$this->fpdf->line(85,14,140,14);
		$this->fpdf->line(85,14,140,14);
		$this->fpdf->line(85,14,140,14);
		$this->fpdf->line(85,14,140,14);
		$this->fpdf->line(85,14,140,14);
		$this->fpdf->line(85,14,140,14);
		
		$this->fpdf->ln(5);
		$this->fpdf->cell(115);
		$this->fpdf->SetFont('Arial','',9);
		$this->fpdf->cell(120,3.5,'INDIAN BANK','0','1','L');
		
		
		$this->fpdf->cell(115);
		$this->fpdf->SetFont('Arial','',9);
		$this->fpdf->cell(120,3.5,'MOLLARPUR BRANCH','0','1','L');
		
		
		$this->fpdf->cell(115);
		$this->fpdf->SetFont('Arial','',9);
		$this->fpdf->cell(120,3.5,'PO.DIST. BURDWAN','0','1','L');
		
		$this->fpdf->cell(115);
		$this->fpdf->SetFont('Arial','',9);
		$this->fpdf->cell(120,3.5,'WEST BENGAL','0','1','L');
		
		$this->fpdf->cell(115);
		$this->fpdf->SetFont('Arial','',9);
		$this->fpdf->cell(120,3.5,'712201','0','1','L');
		
		$this->fpdf->cell(115);
		$this->fpdf->SetFont('Arial','',9);
		$this->fpdf->cell(120,3.5,'Branch Code: 4290 Ph No: 2531714','0','1','L');
		
		
		$this->fpdf->cell(5);
		$this->fpdf->SetFont('Helvetica','B',10);
		$this->fpdf->cell(180,3.5,'GLORIOUS COLLEGE OF EDUCATION (B.Ed)','0','1','L');
		
		
		
		$this->fpdf->cell(5);
		$this->fpdf->SetFont('Arial','',9);
		$this->fpdf->cell(115,3.5,'MOLLARPUR(B.R. ROAD)','0','0','L');
		$this->fpdf->SetFont('Arial','B',9);
		$this->fpdf->cell(20,3.5,'Account No.: ','0','0','L');
		$this->fpdf->SetFont('Arial','',9);
		$this->fpdf->cell(20,3.5,' 5036589656','0','1','L');
		
		
		$this->fpdf->cell(5);
		$this->fpdf->SetFont('Arial','',9);
		$this->fpdf->cell(115,3.5,'P.S- MOLLARPUR, BIRBHUM','0','0','L');
		$this->fpdf->SetFont('Arial','B',9);
		$this->fpdf->cell(13,3.5,'Product:','0','0','L');
		$this->fpdf->SetFont('Arial','',9);
		$this->fpdf->cell(20,3.5,' CA-GEN-PUB-METRO/URBAN-INR','0','1','L');
		
		
		
		$this->fpdf->cell(5);
		$this->fpdf->SetFont('Arial','',9);
		$this->fpdf->cell(115,3.5,'WEST BENGAL  731216','0','0','L');
		$this->fpdf->SetFont('Arial','B',9);
		$this->fpdf->cell(15,3.5,'Currency: ','0','0','L');
		$this->fpdf->SetFont('Arial','',9);
		$this->fpdf->cell(20,3.5,' INR','0','1','L');
		
		$this->fpdf->ln(2);
		
		$this->fpdf->cell(5);
		$this->fpdf->SetFont('Arial','B',7);
		$this->fpdf->cell(20,3.5,'Statement From: ','0','0','L');
		$this->fpdf->SetFont('Arial','',7);
		$this->fpdf->cell(30,3.5,date('d/m/Y',$frm).' to '. date('d/m/Y',$tod),'0','0','L');
		
		$this->fpdf->SetFont('Arial','B',7);
		$this->fpdf->cell(8,3.5,'Date:','0','0','L');
		$this->fpdf->SetFont('Arial','',7);
		$this->fpdf->cell(14,3.5,date('d/m/Y'),'0','0','L');
		
		$this->fpdf->SetFont('Arial','B',7);
		$this->fpdf->cell(8,3.5,'Time:','0','0','L');
		$this->fpdf->SetFont('Arial','',7);
		$this->fpdf->cell(10,3.5,date('H:i:s'),'0','1','L');
		
		$this->fpdf->ln(1);
		
		$this->fpdf->cell(5);
		$this->fpdf->SetFont('Arial','B',7);
		$this->fpdf->cell(20,3.5,'E-mail: ','0','0','L');
		$this->fpdf->SetFont('Arial','',7);
		$this->fpdf->cell(50,3.5,'','0','0','L');
		
		$this->fpdf->SetFont('Arial','B',7);
		$this->fpdf->cell(10,3.5,'Nominee name:','0','0','L');
		$this->fpdf->SetFont('Arial','',7);
		$this->fpdf->cell(20,3.5,'','0','1','L');
		
		
		
			$statementtnew = $this->db->query("select * from  ci_transaction where from_account_id='".$acno."' and (doe<'".$frm."') order by doe asc,credit asc")->result();
		//echo "select * from  ci_transaction where from_account_id='".$acno."' and (doe='".$frm."') order by id asc limit 1";
		$prevbalance = 0;
		if(isset($statementtnew) && !empty($statementtnew)){
		    
		    $prevbalance = 0 ;
		    
		    foreach($statementtnew as $trstt){
		        
		       // print_r($trstt);
		        //echo "<br>============<br>";
		        
		        if(isset($trstt->credit) && !empty($trstt->credit)){

					$precredit = $trstt->credit; 
				//	$precredit =  preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $precredit);

					 $prevbalance = floatval($prevbalance) + floatval($precredit) ;
					//echo "<br>";
					
				 }
			     
			     if(isset($trstt->debit) && !empty($trstt->debit)){

					$predebit = $trstt->debit; 
				//	$predebit =  preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $predebit);

				 	$prevbalance = floatval($prevbalance) - floatval($predebit) ;
				
					
				 }
		        
		        
		        
		        
		        
		    }
		    
		    	$currentball =  number_format((float)$prevbalance, 2, '.', '');
		    	
		    	$currentball = preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $currentball);
		    
		    
		    
		    
		    
		    
		    /*$bass = floatval($statementtnew[0]->balance);
		    $creditbb = floatval($statementtnew[0]->credit);
		    $debitbb = floatval($statementtnew[0]->debit);
		    
		    if($creditbb>0){
		    
		    $curtbb = $bass - $creditbb;
    		}else if($debitbb>0){
    		    
    		     $curtbb = $bass + $debitbb;
    		}
    		
    		$currentball =  number_format((float)$curtbb, 2, '.', '');*/
		    
		}else{
		    $currentball =  "0.00";
		}
		
		
		$this->fpdf->ln(1);
		
		$this->fpdf->cell(5);
		$this->fpdf->SetFont('Arial','B',7);
		$this->fpdf->cell(30,3.5,'Cleared Balance: ','0','0','L');
		$this->fpdf->SetFont('Arial','',7);
		$this->fpdf->cell(30,3.5,'2,36,456.00cr','0','0','L');
		
		$this->fpdf->SetFont('Arial','B',7);
		$this->fpdf->cell(30,3.5,'Uncleared Balance:','0','0','L');
		$this->fpdf->SetFont('Arial','',7);
		$this->fpdf->cell(10,3.5,'0.00','0','0','L');
		
		$this->fpdf->SetFont('Arial','B',7);
		$this->fpdf->cell(12,3.5,'Page No.:','0','0','L');
		$this->fpdf->SetFont('Arial','',7);
		$this->fpdf->cell(10,3.5,'1','0','1','L');
		
		
		
		//$this->fpdf->ln(1);
		
		$this->fpdf->cell(5);
		$this->fpdf->SetFont('Arial','B',7);
		$this->fpdf->cell(30,3.5,'Limit: ','0','0','L');
		$this->fpdf->SetFont('Arial','',7);
		$this->fpdf->cell(30,3.5,'0.00','0','0','L');
		
		$this->fpdf->SetFont('Arial','B',7);
		$this->fpdf->cell(20,3.5,'Drawing Power:','0','0','L');
		$this->fpdf->SetFont('Arial','',7);
		$this->fpdf->cell(20,3.5,'0.00','0','0','L');
		
		$this->fpdf->SetFont('Arial','B',7);
		$this->fpdf->cell(15,3.5,'Int. Rate :','0','0','L');
		$this->fpdf->SetFont('Arial','',7);
		$this->fpdf->cell(10,3.5,'14.75%','0','1','L');
		
		
		$this->fpdf->ln(2);
		//$this->fpdf->cell(5);
		
		$this->fpdf->line(12,75,195,75);
		
		$this->fpdf->SetFont('Arial','B',10);
		
		$this->fpdf->cell(20,4,'Post Dt','0','0','C');
		
		$this->fpdf->cell(20,4,'Val Dt','0','0','L');
		
		$this->fpdf->cell(45,4,'Details','0','0','L');
		
		$this->fpdf->cell(20,4,'Chq. No.','0','0','C');
		
		$this->fpdf->cell(25,4,'Debit','0','0','R');
		
		$this->fpdf->cell(25,4,'Credit','0','0','R');
		
		
		$this->fpdf->cell(30,4,'Balance','0','1','R');
		$this->fpdf->line(12,70,195,70);
		$this->fpdf->ln(1);
		$this->fpdf->SetFont('Arial','B',9);
		
		$this->fpdf->cell(25);
		$this->fpdf->cell(130,4,'BROUGHT FORWARD','0','0','L');
		
		$this->fpdf->SetFont('Arial','B',8);
		$this->fpdf->cell(30,4,'3,25,632.00Cr','0','1','R');
		
		$this->fpdf->ln();
		
	
		
		
		
        
		$statementt = $this->db->query("select * from  ci_transaction where from_account_id='".$acno."' and (doe>='".$frm."' and  doe<='".$tod."'  ) order by doe asc ")->result();
	  //	echo "select * from  ci_transaction where from_account_id='".$acno."' and (doe>='".$frm."' and doe<='".$tod."') order by doe asc";
	   //$prevbalance = 1010000;
	   //$currentball  = 
	   $currentbalance = floatval($prevbalance);
		if(isset($statementt) && !empty($statementt)){

			$balance = 0 ;
			//$currentbalance = $prevbalance ;
			$jjj = 1; 
			$ppppp = 2;
            for($i=0;$i<30;$i++){
			foreach($statementt as $txnn){
			    
			    
			    
			    //print_r($txnn);
			    //echo "<br>";
			    
			    $txt ="";

				//$this->fpdf->SetAligns(array('L','L','L','L','R','R','R','R'));
				//$this->fpdf->SetFont('Arial','',7);

				$dd = date('d/m/y',$txnn->doe);
				
				$cghh = $txnn->refno_chq_no ;

				if(floatval(($txnn->debit)>0)){

					$debit = floatval($txnn->debit); 
					$debitbalance =  floatval($txnn->debit); 
					$debit =  preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $debit);

					$balance = floatval($balance) - floatval($debit) ;
					$txt = "TO TRANSFER-".$part = $txnn->description;;
					
					$currentbalance = floatval($currentbalance) - floatval($debitbalance);

				  }else{

					$debit = "";
					$debitbalance = 0 ;
					
					$currentbalance = floatval($currentbalance) - floatval($debitbalance);
				

				  }

				if((floatval($txnn->credit))>0){
				    
				   
				    
				    //$precredit = $trstt->credit;
                    
					$credit = floatval($txnn->credit);
					$creditbalance =  floatval($txnn->credit); 
					$credit = preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $credit);
					
					$balance = floatval($balance) +  floatval($credit) ;
					$txt = "BY TRANSFER-".$part = $txnn->description;;
					
					$currentbalance = floatval($currentbalance) + floatval($creditbalance);

				  }else{

					$credit ="";
					$creditbalance= 0 ;
					$currentbalance = floatval($currentbalance) + floatval($creditbalance);
					

				  }

				  //$ball = number_format((float)$txnn->balance, 2, '.', '');
				  
				  $ball = number_format((float)$currentbalance, 2, '.', '');
				  
				 // $ball = "5230.25";
				  
				 // setlocale(LC_MONETARY, 'en_IN');
                  $amount = preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $ball);

                	//$this->fpdf->SetWidths(array(20, 20, 35, 20,15,24,26,30));
				//$this->fpdf->Row(array("$dd","$dd","$txt","$cghh",$accinfo[0]->branch_code, "$debit","$credit","$amount"));
				
				
				
				if($jjj>17){
				    
				    $this->fpdf->addpage();
				    $this->fpdf->SetFont('Helvetica','B',12);
            		$this->fpdf->Cell(205,5,'STATEMENT OF ACCOUNT','0','0','C');
            		
            		$this->fpdf->SetFont('Arial','B',14);
            		$this->fpdf->line(85,14,140,14);
            		$this->fpdf->line(85,14,140,14);
            		$this->fpdf->line(85,14,140,14);
            		$this->fpdf->line(85,14,140,14);
            		$this->fpdf->line(85,14,140,14);
            		$this->fpdf->line(85,14,140,14);
            		$this->fpdf->line(85,14,140,14);
            		
            		$this->fpdf->ln(5);
            		$this->fpdf->cell(115);
            		$this->fpdf->SetFont('Arial','',9);
            		$this->fpdf->cell(120,3.5,'INDIAN BANK','0','1','L');
            		
            		
            		$this->fpdf->cell(115);
            		$this->fpdf->SetFont('Arial','',9);
            		$this->fpdf->cell(120,3.5,'MOLLARPUR BRANCH','0','1','L');
            		
            		
            		$this->fpdf->cell(115);
            		$this->fpdf->SetFont('Arial','',9);
            		$this->fpdf->cell(120,3.5,'PO.DIST. BURDWAN','0','1','L');
            		
            		$this->fpdf->cell(115);
            		$this->fpdf->SetFont('Arial','',9);
            		$this->fpdf->cell(120,3.5,'WEST BENGAL','0','1','L');
            		
            		$this->fpdf->cell(115);
            		$this->fpdf->SetFont('Arial','',9);
            		$this->fpdf->cell(120,3.5,'712201','0','1','L');
            		
            		$this->fpdf->cell(115);
            		$this->fpdf->SetFont('Arial','',9);
            		$this->fpdf->cell(120,3.5,'Branch Code: 4290 Ph No: 2531714','0','1','L');
            		
            		
            		$this->fpdf->cell(5);
            		$this->fpdf->SetFont('Helvetica','B',10);
            		$this->fpdf->cell(180,3.5,'GLORIOUS COLLEGE OF EDUCATION (B.Ed)','0','1','L');
            		
            		
            		
            		$this->fpdf->cell(5);
            		$this->fpdf->SetFont('Arial','',9);
            		$this->fpdf->cell(115,3.5,'MOLLARPUR(B.R. ROAD)','0','0','L');
            		$this->fpdf->SetFont('Arial','B',9);
            		$this->fpdf->cell(20,3.5,'Account No.: ','0','0','L');
            		$this->fpdf->SetFont('Arial','',9);
            		$this->fpdf->cell(20,3.5,' 5036589656','0','1','L');
            		
            		
            		$this->fpdf->cell(5);
            		$this->fpdf->SetFont('Arial','',9);
            		$this->fpdf->cell(115,3.5,'P.S- MOLLARPUR, BIRBHUM','0','0','L');
            		$this->fpdf->SetFont('Arial','B',9);
            		$this->fpdf->cell(13,3.5,'Product:','0','0','L');
            		$this->fpdf->SetFont('Arial','',9);
            		$this->fpdf->cell(20,3.5,' CA-GEN-PUB-METRO/URBAN-INR','0','1','L');
            		
            		
            		
            		$this->fpdf->cell(5);
            		$this->fpdf->SetFont('Arial','',9);
            		$this->fpdf->cell(115,3.5,'WEST BENGAL  731216','0','0','L');
            		$this->fpdf->SetFont('Arial','B',9);
            		$this->fpdf->cell(15,3.5,'Currency: ','0','0','L');
            		$this->fpdf->SetFont('Arial','',9);
            		$this->fpdf->cell(20,3.5,' INR','0','1','L');
            		
            		$this->fpdf->ln(2);
            		
            		$this->fpdf->cell(5);
            		$this->fpdf->SetFont('Arial','B',7);
            		$this->fpdf->cell(20,3.5,'Statement From: ','0','0','L');
            		$this->fpdf->SetFont('Arial','',7);
            		$this->fpdf->cell(30,3.5,date('d/m/Y',$frm).' to '. date('d/m/Y',$tod),'0','0','L');
            		
            		$this->fpdf->SetFont('Arial','B',7);
            		$this->fpdf->cell(8,3.5,'Date:','0','0','L');
            		$this->fpdf->SetFont('Arial','',7);
            		$this->fpdf->cell(14,3.5,date('d/m/Y'),'0','0','L');
            		
            		$this->fpdf->SetFont('Arial','B',7);
            		$this->fpdf->cell(8,3.5,'Time:','0','0','L');
            		$this->fpdf->SetFont('Arial','',7);
            		$this->fpdf->cell(10,3.5,date('H:i:s'),'0','1','L');
            		
            		$this->fpdf->ln(1);
            		
            		$this->fpdf->cell(5);
            		$this->fpdf->SetFont('Arial','B',7);
            		$this->fpdf->cell(20,3.5,'E-mail: ','0','0','L');
            		$this->fpdf->SetFont('Arial','',7);
            		$this->fpdf->cell(50,3.5,'','0','0','L');
            		
            		$this->fpdf->SetFont('Arial','B',7);
            		$this->fpdf->cell(10,3.5,'Nominee name:','0','0','L');
            		$this->fpdf->SetFont('Arial','',7);
            		$this->fpdf->cell(20,3.5,'','0','1','L');
            		
            		
            		
            		$this->fpdf->ln(1);
		
            		$this->fpdf->cell(5);
            		$this->fpdf->SetFont('Arial','B',7);
            		$this->fpdf->cell(30,3.5,'Cleared Balance: ','0','0','L');
            		$this->fpdf->SetFont('Arial','',7);
            		$this->fpdf->cell(30,3.5,'2,36,456.00cr','0','0','L');
            		
            		$this->fpdf->SetFont('Arial','B',7);
            		$this->fpdf->cell(30,3.5,'Uncleared Balance:','0','0','L');
            		$this->fpdf->SetFont('Arial','',7);
            		$this->fpdf->cell(10,3.5,'0.00','0','0','L');
            		
            		$this->fpdf->SetFont('Arial','B',7);
            		$this->fpdf->cell(12,3.5,'Page No.:','0','0','L');
            		$this->fpdf->SetFont('Arial','',7);
            		$this->fpdf->cell(10,3.5 ,"$ppppp",'0','1','L');
            		
            		
            		
            		//$this->fpdf->ln(1);
            		
            		$this->fpdf->cell(5);
            		$this->fpdf->SetFont('Arial','B',7);
            		$this->fpdf->cell(30,3.5,'Limit: ','0','0','L');
            		$this->fpdf->SetFont('Arial','',7);
            		$this->fpdf->cell(30,3.5,'0.00','0','0','L');
            		
            		$this->fpdf->SetFont('Arial','B',7);
            		$this->fpdf->cell(20,3.5,'Drawing Power:','0','0','L');
            		$this->fpdf->SetFont('Arial','',7);
            		$this->fpdf->cell(20,3.5,'0.00','0','0','L');
            		
            		$this->fpdf->SetFont('Arial','B',7);
            		$this->fpdf->cell(15,3.5,'Int. Rate :','0','0','L');
            		$this->fpdf->SetFont('Arial','',7);
            		$this->fpdf->cell(10,3.5,'14.75%','0','1','L');
            		
            		
            		$this->fpdf->ln(2);
            		//$this->fpdf->cell(5);
            		
            		$this->fpdf->line(12,75,195,75);
            		
            		$this->fpdf->SetFont('Arial','B',10);
            		
            		$this->fpdf->cell(20,4,'Post Dt','0','0','C');
            		
            		$this->fpdf->cell(20,4,'Val Dt','0','0','L');
            		
            		$this->fpdf->cell(45,4,'Details','0','0','L');
            		
            		$this->fpdf->cell(20,4,'Chq. No.','0','0','C');
            		
            		$this->fpdf->cell(25,4,'Debit','0','0','R');
            		
            		$this->fpdf->cell(25,4,'Credit','0','0','R');
            		
            		
            		$this->fpdf->cell(30,4,'Balance','0','1','R');
            		$this->fpdf->line(12,70,195,70);
            		$this->fpdf->ln(1);
            		$this->fpdf->SetFont('Arial','B',9);
            		
            		$this->fpdf->cell(25);
            		$this->fpdf->cell(130,4,'BROUGHT FORWARD','0','0','L');
            		
            		$this->fpdf->SetFont('Arial','B',8);
            		$this->fpdf->cell(30,4,'3,25,632.00Cr','0','1','R');
            		
            		$this->fpdf->ln();
            		
            		
            		$jjj  = 0;
            		
            		$ppppp++;
		
				    
				    
				    
				    
				    
				}
				
				
				
				
			    $this->fpdf->SetFont('Arial','B',8);
        		$this->fpdf->cell(20,3,"$dd",'0','0','C');
        		
        		$this->fpdf->cell(20,3,'','0','0','C');
        		
        		$this->fpdf->cell(12,3,"$dd",'0','0','L');
        		
        		$this->fpdf->cell(40,3,"BY TFR",'0','0','L');
        		
        		$this->fpdf->cell(20,3,'','0','0','C');
        		
        		
        		
        		$this->fpdf->cell(25,3,"$debit",'0','0','R');
        		
        		
        		$this->fpdf->SetFont('Arial','B',8);
        		
        		$this->fpdf->cell(25,3,"$credit",'0','0','R');
        		
        		
        		$this->fpdf->cell(30,3,"$amount"."Cr",'0','1','R');
        		
        		
        		////////////////////////////////////////////////////////////
        		$this->fpdf->SetFont('Arial','B',9);
        		$this->fpdf->cell(20,3,"",'0','0','C');
        		
        		$this->fpdf->cell(20,3,'','0','0','C');
        		
        		$this->fpdf->cell(45,3," trf",'0','0','L');
        		
        		$this->fpdf->cell(20,3,'','0','0','C');
        		
        		
        		
        		$this->fpdf->cell(25,3,"",'0','0','R');
        		
        		
        		$this->fpdf->SetFont('Arial','B',8);
        		
        		$this->fpdf->cell(25,3,"",'0','0','R');
        		
        		
        		$this->fpdf->cell(30,3,"",'0','1','R');
        		
        		
        		//========================================================
        		
        		$this->fpdf->SetFont('Arial','B',9);
        		$this->fpdf->cell(20,3,"",'0','0','C');
        		
        		$this->fpdf->cell(20,3,'','0','0','C');
        		
        		$this->fpdf->cell(90,3," TRANSFER TO 3065296896/ RAJ KUMAR DAS",'0','0','L');
        		
        		//$this->fpdf->cell(20,4,'','0','0','C');
        		
        		
        		
        		//$this->fpdf->cell(25,4,"",'0','0','R');
        		
        		
        		$this->fpdf->SetFont('Arial','B',8);
        		
        		$this->fpdf->cell(25,3,"",'0','0','R');
        		
        		
        		$this->fpdf->cell(30,3,"",'0','1','R');
        		
        		
        		
        		
        		if($jjj==17){
        		    
        		    $y = $this->fpdf->GetX();
        		    $this->fpdf->ln(6);
		
            		$this->fpdf->SetFont('Arial','B',9);
            		
            		$this->fpdf->cell(10);
            		$this->fpdf->cell(145,4,'CARRIED FORWARD:','0','0','L');
            		
            		$this->fpdf->SetFont('Arial','B',8);
            		$this->fpdf->cell(30,4,'3,25,632.00Cr','0','1','R');
            		
            		
            		
            		
            		$this->fpdf->ln(6);
            		
            		//$this->fpdf->line(12,261,195,261);
            		$this->fpdf->ln(2);
            		$this->fpdf->SetFont('Arial','B',8);
            		
            		$this->fpdf->cell(105,4,'Statement  Summary    Dr. Count  17   Cr. Count 01','T','0','L');
            		
            		
            		$this->fpdf->cell(30,4,'3,26,300.00','T','0','R');
            		
            		$this->fpdf->cell(30,4,'2,25,450.00','T','0','R');
            		
            		
            		$this->fpdf->cell(20,4,'','T','1','R');
            		
            		
            		$this->fpdf->ln(2);
            		
            		$this->fpdf->SetFont('Times','',8);
            		$this->fpdf->multicell(195,5,'In Case Your Account Is Operated By A Letter of Authority/Power of Attorney Holder. Please Check the Transaction With Extra Care');	
            
                    		    
        		    
        		    
        		    
        		}
        		
        		
        		
        		
        		
        		
        		$jjj++;
        		
        		
        		
        		
				
				
				
				
				


			}
		}

		}
		
		$this->fpdf->ln(6);
		
		$this->fpdf->SetFont('Arial','B',9);
		
		$this->fpdf->cell(10);
		$this->fpdf->cell(145,4,'CARRIED FORWARD:','0','0','L');
		
		$this->fpdf->SetFont('Arial','B',8);
		$this->fpdf->cell(30,4,'3,25,632.00Cr','0','1','R');
		
		
		
		
		$this->fpdf->ln(6);
		
		//$this->fpdf->line(12,262,195,262);
		$this->fpdf->ln(2);
		$this->fpdf->SetFont('Arial','B',8);
		
		$this->fpdf->cell(105,4,'Statement  Summary    Dr. Count  17   Cr. Count 01','T','0','L');
		
		
		$this->fpdf->cell(30,4,'3,26,300.00','T','0','R');
		
		$this->fpdf->cell(30,4,'2,25,450.00','T','0','R');
		
		
		$this->fpdf->cell(20,4,'','T','1','R');
		
		
		$this->fpdf->ln(2);
		
		$this->fpdf->SetFont('Times','',8);
		$this->fpdf->multicell(195,5,'In Case Your Account Is Operated By A Letter of Authority/Power of Attorney Holder. Please Check the Transaction With Extra Care');	

		



		//All text which have to print should be goes here
		//also you can go for calling view over here and put the same type of code inside the view
		
		//echo $this->fpdf->Output("Statement_".$accinfo[0]->account_number."XXXXX0256.pdf",'D');
        echo $this->fpdf->Output();
	}

	public function download_report($frm,$tod,$acno){
	    
	    $frm = strtotime($frm);
	    
	    // echo "<br>";
	     
	    $tod = strtotime($tod);
	    
	    //echo "<br>";

		$this->load->library('fpdf_master');
		$imgpath = base_url().'assets/sbi_logo.png';
		$this->fpdf->Image("$imgpath", 15, 25, 35, 0, 'PNG');

		//get all account info 
		$accinfo = $this->db->query("select * from ci_bank_account where id='".$acno."'")->result();

		$this->fpdf->ln(30);
		
		$this->fpdf->SetFont('Arial','',9);
		
		$this->fpdf->Cell(50,5,'Account Name');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,ucwords($accinfo[0]->customer_name),0,1,'L');

		$this->fpdf->Cell(50,5,'Address');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->multicell(60,4,strtoupper($accinfo[0]->address). ', '.strtoupper($accinfo[0]->state).', '.strtoupper($accinfo[0]->pin));

		$this->fpdf->Cell(50,5,'Date');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,date('d F Y'),0,1,'L');

		$this->fpdf->Cell(50,5,'Account Number');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,$accinfo[0]->account_number,0,1,'L');


		$this->fpdf->Cell(50,5,'Account Description');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,$accinfo[0]->account_type,0,1,'L');

		$this->fpdf->Cell(50,5,'Branch');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,strtoupper($accinfo[0]->branch),0,1,'L');

		$this->fpdf->Cell(50,5,'Drawing Power');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,'0.00',0,1,'L');

		$this->fpdf->Cell(50,5,'Interest Rate(% p.a.)');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,$accinfo[0]->interest_rate,0,1,'L');

		$this->fpdf->Cell(50,5,'MOD Balance');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,'0.00',0,1,'L');


		$this->fpdf->Cell(50,5,'CIF No.');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,$accinfo[0]->cif,0,1,'L');

		$this->fpdf->Cell(50,5,'IFS Code');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,$accinfo[0]->ifsc_code,0,1,'L');

		$this->fpdf->Cell(50,5,'(Indian Financial System)',0,1,'L');
		
		$this->fpdf->Cell(50,5,'MICR Code');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,$accinfo[0]->micr_code,0,1,'L');

		$this->fpdf->Cell(50,5,'(Magnetic Ink Character Recognition)',0,1,'L');

		$this->fpdf->Cell(50,5,'Nomination Registered');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,'No',0,1,'L');
		$statementtnew = $this->db->query("select * from  ci_transaction where from_account_id='".$acno."' and (doe<'".$frm."') order by doe asc,credit asc")->result();
		//echo "select * from  ci_transaction where from_account_id='".$acno."' and (doe='".$frm."') order by id asc limit 1";
		$prevbalance = 0;
		if(isset($statementtnew) && !empty($statementtnew)){
		    
		    $prevbalance = 0 ;
		    
		    foreach($statementtnew as $trstt){
		        
		       // print_r($trstt);
		        //echo "<br>============<br>";
		        
		        if(isset($trstt->credit) && !empty($trstt->credit)){

					$precredit = $trstt->credit; 
				//	$precredit =  preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $precredit);

					 $prevbalance = floatval($prevbalance) + floatval($precredit) ;
					//echo "<br>";
					
				 }
			     
			     if(isset($trstt->debit) && !empty($trstt->debit)){

					$predebit = $trstt->debit; 
				//	$predebit =  preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $predebit);

				 	$prevbalance = floatval($prevbalance) - floatval($predebit) ;
				
					
				 }
		        
		        
		        
		        
		        
		    }
		    
		    	$currentball =  number_format((float)$prevbalance, 2, '.', '');
		    	
		    	$currentball = preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $currentball);
		    
		    
		    
		    
		    
		    
		    /*$bass = floatval($statementtnew[0]->balance);
		    $creditbb = floatval($statementtnew[0]->credit);
		    $debitbb = floatval($statementtnew[0]->debit);
		    
		    if($creditbb>0){
		    
		    $curtbb = $bass - $creditbb;
    		}else if($debitbb>0){
    		    
    		     $curtbb = $bass + $debitbb;
    		}
    		
    		$currentball =  number_format((float)$curtbb, 2, '.', '');*/
		    
		}else{
		    $currentball =  "0.00";
		}
		
		
		
		
        $this->fpdf->Cell(50,5,'Balance as on '.date('d F Y',$frm));
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,"$currentball",0,1,'L');

		$this->fpdf->ln(10);

		$this->fpdf->SetFont('Arial','',12);
		$this->fpdf->Cell(50,5,'Account Statement from '. date('d F Y',$frm).' to '. date('d F Y',$tod),0,1,'L');
        
		$this->fpdf->ln(5);

		$this->fpdf->SetWidths(array(20, 20, 35, 20,15,24,26,30));

		$this->fpdf->SetAligns(array('L','L','L','L','R','R','R','R'));
		$this->fpdf->SetFont('Arial','B',8);
		$this->fpdf->Row(array("Txn Date","Value Date","Description","Ref No./Cheque No.","Branch Code", "Debit","Credit","Balance"));
        
        //echo date('d-m-y',$frm);
        
		$statementt = $this->db->query("select * from  ci_transaction where from_account_id='".$acno."' and (doe>='".$frm."' and  doe<='".$tod."'  ) order by doe asc ")->result();
	  //	echo "select * from  ci_transaction where from_account_id='".$acno."' and (doe>='".$frm."' and doe<='".$tod."') order by doe asc";
	   //$prevbalance = 1010000;
	   //$currentball  = 
	   $currentbalance = floatval($prevbalance);
		if(isset($statementt) && !empty($statementt)){

			$balance = 0 ;
			//$currentbalance = $prevbalance ;
			

			foreach($statementt as $txnn){
			    
			    
			    
			    //print_r($txnn);
			    //echo "<br>";
			    
			    $txt ="";

				$this->fpdf->SetAligns(array('L','L','L','L','R','R','R','R'));
				$this->fpdf->SetFont('Arial','',7);

				$dd = date('d F Y',$txnn->doe);
				
				$cghh = $txnn->refno_chq_no ;

				if(floatval(($txnn->debit)>0)){

					$debit = floatval($txnn->debit); 
					$debitbalance =  floatval($txnn->debit); 
					$debit =  preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $debit);

					$balance = floatval($balance) - floatval($debit) ;
					$txt = "TO TRANSFER-".$part = $txnn->description;;
					
					$currentbalance = floatval($currentbalance) - floatval($debitbalance);

				  }else{

					$debit = "";
					$debitbalance = 0 ;
					
					$currentbalance = floatval($currentbalance) - floatval($debitbalance);
				

				  }

				if((floatval($txnn->credit))>0){
				    
				   
				    
				    //$precredit = $trstt->credit;
                    
					$credit = floatval($txnn->credit);
					$creditbalance =  floatval($txnn->credit); 
					$credit = preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $credit);
					
					$balance = floatval($balance) +  floatval($credit) ;
					$txt = "BY TRANSFER-".$part = $txnn->description;;
					
					$currentbalance = floatval($currentbalance) + floatval($creditbalance);

				  }else{

					$credit ="";
					$creditbalance= 0 ;
					$currentbalance = floatval($currentbalance) + floatval($creditbalance);
					

				  }

				  //$ball = number_format((float)$txnn->balance, 2, '.', '');
				  
				  $ball = number_format((float)$currentbalance, 2, '.', '');
				  
				 // $ball = "5230.25";
				  
				 // setlocale(LC_MONETARY, 'en_IN');
                  $amount = preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $ball);

                	$this->fpdf->SetWidths(array(20, 20, 35, 20,15,24,26,30));
				$this->fpdf->Row(array("$dd","$dd","$txt","$cghh",$accinfo[0]->branch_code, "$debit","$credit","$amount"));


			}

		}
		$this->fpdf->ln(2);
		$this->fpdf->SetFont('Arial','',8);
		$this->fpdf->multicell(195,5,' Please do not share your ATM, Debit/Credit card number, PIN (Personal Identification Number) and OTP (One Time Password)	with anyone over mail, SMS, phone call or any other media. Bank never asks for such information.');	

		$this->fpdf->ln(5);
		$this->fpdf->cell(5);
		$this->fpdf->multicell(190,5,'**This is a computer generated statement and does not require a signature.');
		



		//All text which have to print should be goes here
		//also you can go for calling view over here and put the same type of code inside the view
		
		//echo $this->fpdf->Output("Statement_".$accinfo[0]->account_number."XXXXX0256.pdf",'D');
        echo $this->fpdf->Output();
	}
	
	public function download_report_axis($frm,$tod,$acno){
	    
	    $frm = strtotime($frm);
	    
	    // echo "<br>";
	     
	    $tod = strtotime($tod);
	    
	    //echo "<br>";

		$this->load->library('fpdf_master');
		$imgpath = base_url().'assets/sbi_logo.png';
		$this->fpdf->Image("$imgpath", 15, 25, 35, 0, 'PNG');

		//get all account info 
		$accinfo = $this->db->query("select * from ci_bank_account where id='".$acno."'")->result();

		$this->fpdf->ln(30);
		
		$this->fpdf->SetFont('Arial','',9);
		
		$this->fpdf->Cell(50,5,'Account Name');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,ucwords($accinfo[0]->customer_name),0,1,'L');

		$this->fpdf->Cell(50,5,'Address');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->multicell(60,4,strtoupper($accinfo[0]->address). ', '.strtoupper($accinfo[0]->state).', '.strtoupper($accinfo[0]->pin));

		$this->fpdf->Cell(50,5,'Date');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,date('d F Y'),0,1,'L');

		$this->fpdf->Cell(50,5,'Account Number');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,$accinfo[0]->account_number,0,1,'L');


		$this->fpdf->Cell(50,5,'Account Description');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,$accinfo[0]->account_type,0,1,'L');

		$this->fpdf->Cell(50,5,'Branch');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,strtoupper($accinfo[0]->branch),0,1,'L');

		$this->fpdf->Cell(50,5,'Drawing Power');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,'0.00',0,1,'L');

		$this->fpdf->Cell(50,5,'Interest Rate(% p.a.)');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,$accinfo[0]->interest_rate,0,1,'L');

		$this->fpdf->Cell(50,5,'MOD Balance');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,'0.00',0,1,'L');


		$this->fpdf->Cell(50,5,'CIF No.');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,$accinfo[0]->cif,0,1,'L');

		$this->fpdf->Cell(50,5,'IFS Code');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,$accinfo[0]->ifsc_code,0,1,'L');

		$this->fpdf->Cell(50,5,'(Indian Financial System)',0,1,'L');
		
		$this->fpdf->Cell(50,5,'MICR Code');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,$accinfo[0]->micr_code,0,1,'L');

		$this->fpdf->Cell(50,5,'(Magnetic Ink Character Recognition)',0,1,'L');

		$this->fpdf->Cell(50,5,'Nomination Registered');
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,'No',0,1,'L');
		$statementtnew = $this->db->query("select * from  ci_transaction where from_account_id='".$acno."' and (doe<'".$frm."') order by doe asc,credit asc")->result();
		//echo "select * from  ci_transaction where from_account_id='".$acno."' and (doe='".$frm."') order by id asc limit 1";
		$prevbalance = 0;
		if(isset($statementtnew) && !empty($statementtnew)){
		    
		    $prevbalance = 0 ;
		    
		    foreach($statementtnew as $trstt){
		        
		       // print_r($trstt);
		        //echo "<br>============<br>";
		        
		        if(isset($trstt->credit) && !empty($trstt->credit)){

					$precredit = $trstt->credit; 
				//	$precredit =  preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $precredit);

					 $prevbalance = floatval($prevbalance) + floatval($precredit) ;
					//echo "<br>";
					
				 }
			     
			     if(isset($trstt->debit) && !empty($trstt->debit)){

					$predebit = $trstt->debit; 
				//	$predebit =  preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $predebit);

				 	$prevbalance = floatval($prevbalance) - floatval($predebit) ;
				
					
				 }
		        
		        
		        
		        
		        
		    }
		    
		    	$currentball =  number_format((float)$prevbalance, 2, '.', '');
		    	
		    	$currentball = preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $currentball);
		    
		    
		    
		    
		    
		    
		    /*$bass = floatval($statementtnew[0]->balance);
		    $creditbb = floatval($statementtnew[0]->credit);
		    $debitbb = floatval($statementtnew[0]->debit);
		    
		    if($creditbb>0){
		    
		    $curtbb = $bass - $creditbb;
    		}else if($debitbb>0){
    		    
    		     $curtbb = $bass + $debitbb;
    		}
    		
    		$currentball =  number_format((float)$curtbb, 2, '.', '');*/
		    
		}else{
		    $currentball =  "0.00";
		}
		
		
		
		
        $this->fpdf->Cell(50,5,'Balance as on '.date('d F Y',$frm));
		$this->fpdf->Cell(2,5,':');
		$this->fpdf->Cell(50,5,"$currentball",0,1,'L');

		$this->fpdf->ln(10);

		$this->fpdf->SetFont('Arial','',12);
		$this->fpdf->Cell(50,5,'Account Statement from '. date('d F Y',$frm).' to '. date('d F Y',$tod),0,1,'L');
        
		$this->fpdf->ln(5);

		$this->fpdf->SetWidths(array(20, 20, 35, 20,15,24,26,30));

		$this->fpdf->SetAligns(array('L','L','L','L','R','R','R','R'));
		$this->fpdf->SetFont('Arial','B',8);
		$this->fpdf->Row(array("Txn Date","Value Date","Description","Ref No./Cheque No.","Branch Code", "Debit","Credit","Balance"));
        
        //echo date('d-m-y',$frm);
        
		$statementt = $this->db->query("select * from  ci_transaction where from_account_id='".$acno."' and (doe>='".$frm."' and  doe<='".$tod."'  ) order by doe asc ")->result();
	  //	echo "select * from  ci_transaction where from_account_id='".$acno."' and (doe>='".$frm."' and doe<='".$tod."') order by doe asc";
	   //$prevbalance = 1010000;
	   //$currentball  = 
	   $currentbalance = floatval($prevbalance);
		if(isset($statementt) && !empty($statementt)){

			$balance = 0 ;
			//$currentbalance = $prevbalance ;
			

			foreach($statementt as $txnn){
			    
			    
			    
			    //print_r($txnn);
			    //echo "<br>";
			    
			    $txt ="";

				$this->fpdf->SetAligns(array('L','L','L','L','R','R','R','R'));
				$this->fpdf->SetFont('Arial','',7);

				$dd = date('d F Y',$txnn->doe);
				
				$cghh = $txnn->refno_chq_no ;

				if(floatval(($txnn->debit)>0)){

					$debit = floatval($txnn->debit); 
					$debitbalance =  floatval($txnn->debit); 
					$debit =  preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $debit);

					$balance = floatval($balance) - floatval($debit) ;
					$txt = "TO TRANSFER-".$part = $txnn->description;;
					
					$currentbalance = floatval($currentbalance) - floatval($debitbalance);

				  }else{

					$debit = "";
					$debitbalance = 0 ;
					
					$currentbalance = floatval($currentbalance) - floatval($debitbalance);
				

				  }

				if((floatval($txnn->credit))>0){
				    
				   
				    
				    //$precredit = $trstt->credit;
                    
					$credit = floatval($txnn->credit);
					$creditbalance =  floatval($txnn->credit); 
					$credit = preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $credit);
					
					$balance = floatval($balance) +  floatval($credit) ;
					$txt = "BY TRANSFER-".$part = $txnn->description;;
					
					$currentbalance = floatval($currentbalance) + floatval($creditbalance);

				  }else{

					$credit ="";
					$creditbalance= 0 ;
					$currentbalance = floatval($currentbalance) + floatval($creditbalance);
					

				  }

				  //$ball = number_format((float)$txnn->balance, 2, '.', '');
				  
				  $ball = number_format((float)$currentbalance, 2, '.', '');
				  
				 // $ball = "5230.25";
				  
				 // setlocale(LC_MONETARY, 'en_IN');
                  $amount = preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $ball);

                	$this->fpdf->SetWidths(array(20, 20, 35, 20,15,24,26,30));
				$this->fpdf->Row(array("$dd","$dd","$txt","$cghh",$accinfo[0]->branch_code, "$debit","$credit","$amount"));


			}

		}
		$this->fpdf->ln(2);
		$this->fpdf->SetFont('Arial','',8);
		$this->fpdf->multicell(195,5,' Please do not share your ATM, Debit/Credit card number, PIN (Personal Identification Number) and OTP (One Time Password)	with anyone over mail, SMS, phone call or any other media. Bank never asks for such information.');	

		$this->fpdf->ln(5);
		$this->fpdf->cell(5);
		$this->fpdf->multicell(190,5,'**This is a computer generated statement and does not require a signature.');
		



		//All text which have to print should be goes here
		//also you can go for calling view over here and put the same type of code inside the view
		
		//echo $this->fpdf->Output("Statement_".$accinfo[0]->account_number."XXXXX0256.pdf",'D');
        echo $this->fpdf->Output();
	}
	
	public function download_report_icici($frm,$tod,$acno){
	    
	    $frm = strtotime($frm);
	    
	    // echo "<br>";
	     
	    $tod = strtotime($tod);
	    
	    //echo "<br>";

		$this->load->library('fpdf_master');
		$imgpath = base_url().'assets/icic_bank_nn.png';
		$this->fpdf->Image("$imgpath", 15, 25, 35, 0, 'PNG');

		//get all account info 
		$accinfo = $this->db->query("select * from ci_bank_account where id='".$acno."'")->result();

		$this->fpdf->ln(30);
		
		$this->fpdf->SetFont('Times','',9);
		
		$this->fpdf->Cell(30,5,'Name:');
		$this->fpdf->Cell(2,5,'');
		$this->fpdf->Cell(50,5,ucwords($accinfo[0]->customer_name),0,0,'L');
		$this->fpdf->Cell(25,5,'');
		$this->fpdf->Cell(30,5,'A/C Branch:');
		$this->fpdf->Cell(2,5,'');
		$this->fpdf->Cell(50,5,strtoupper($accinfo[0]->branch),0,1,'L');

		$this->fpdf->Cell(30,5,'Address:');
		$this->fpdf->Cell(2,5,'');
		$this->fpdf->multicell(60,4,strtoupper($accinfo[0]->address). ', '.strtoupper($accinfo[0]->state).', '.strtoupper($accinfo[0]->pin));

// 		$this->fpdf->Cell(50,5,'Date');
// 		$this->fpdf->Cell(2,5,':');
// 		$this->fpdf->Cell(50,5,date('d F Y'),0,1,'L');

		$this->fpdf->Cell(30,5,'A/C No.:');
		$this->fpdf->Cell(2,5,'');
		$this->fpdf->Cell(50,5,$accinfo[0]->account_number,0,0,'L');
        $this->fpdf->Cell(25,5,'');
        $this->fpdf->Cell(30,5,'A/C type:');
		$this->fpdf->Cell(2,5,'');
		$this->fpdf->Cell(50,5,$accinfo[0]->account_type,0,1,'L');
		
		$this->fpdf->Cell(30,5,'Jt. Holder:');
		$this->fpdf->Cell(2,5,'');
		$this->fpdf->Cell(50,5,'',0,0,'L');
        $this->fpdf->Cell(25,5,'');
        $this->fpdf->Cell(30,5,'Csut ID:');
		$this->fpdf->Cell(2,5,'');
		$this->fpdf->Cell(50,5,rand(7643567,23456712),0,1,'L');
		
		$this->fpdf->Cell(30,5,'Transaction Date Form:');
		$this->fpdf->Cell(2,5,'');
		$this->fpdf->Cell(50,5,'01/06/2023',0,0,'L');
        $this->fpdf->Cell(25,5,'');
        $this->fpdf->Cell(30,5,'Branch Code:');
		$this->fpdf->Cell(2,5,'');
		$this->fpdf->Cell(50,5,'5347',0,1,'L');
		
		$this->fpdf->Cell(30,5,'Transaction Period:');
		$this->fpdf->Cell(2,5,'');
		$this->fpdf->Cell(50,5,'Form '.date('d F Y',$frm).' to '. date('d F Y',$tod),0,0,'L');
        $this->fpdf->Cell(25,5,'');
        $this->fpdf->Cell(30,5,'IFSC Code:');
		$this->fpdf->Cell(2,5,'');
		$this->fpdf->Cell(50,5,'ICIC002523',0,1,'L');

		$this->fpdf->Cell(50,5,'Statement Request/Download Date:');
		$this->fpdf->Cell(2,5,'');
		$this->fpdf->Cell(50,5,date('d/m/Y'),0,1,'L');

// 		$this->fpdf->Cell(50,5,'Drawing Power');
// 		$this->fpdf->Cell(2,5,':');
// 		$this->fpdf->Cell(50,5,'0.00',0,1,'L');

// 		$this->fpdf->Cell(50,5,'Interest Rate(% p.a.)');
// 		$this->fpdf->Cell(2,5,':');
// 		$this->fpdf->Cell(50,5,$accinfo[0]->interest_rate,0,1,'L');

// 		$this->fpdf->Cell(50,5,'MOD Balance');
// 		$this->fpdf->Cell(2,5,':');
// 		$this->fpdf->Cell(50,5,'0.00',0,1,'L');


// 		$this->fpdf->Cell(50,5,'CIF No.');
// 		$this->fpdf->Cell(2,5,':');
// 		$this->fpdf->Cell(50,5,$accinfo[0]->cif,0,1,'L');

// 		$this->fpdf->Cell(50,5,'IFS Code');
// 		$this->fpdf->Cell(2,5,':');
// 		$this->fpdf->Cell(50,5,$accinfo[0]->ifsc_code,0,1,'L');

// 		$this->fpdf->Cell(50,5,'(Indian Financial System)',0,1,'L');
		
// 		$this->fpdf->Cell(50,5,'MICR Code');
// 		$this->fpdf->Cell(2,5,':');
// 		$this->fpdf->Cell(50,5,$accinfo[0]->micr_code,0,1,'L');

// 		$this->fpdf->Cell(50,5,'(Magnetic Ink Character Recognition)',0,1,'L');

// 		$this->fpdf->Cell(50,5,'Nomination Registered');
// 		$this->fpdf->Cell(2,5,':');
// 		$this->fpdf->Cell(50,5,'No',0,1,'L');
		$statementtnew = $this->db->query("select * from  ci_transaction where from_account_id='".$acno."' and (doe<'".$frm."') order by doe asc,credit asc")->result();
		//echo "select * from  ci_transaction where from_account_id='".$acno."' and (doe='".$frm."') order by id asc limit 1";
		$prevbalance = 0;
		if(isset($statementtnew) && !empty($statementtnew)){
		    
		    $prevbalance = 0 ;
		    
		    foreach($statementtnew as $trstt){
		        
		       // print_r($trstt);
		        //echo "<br>============<br>";
		        
		        if(isset($trstt->credit) && !empty($trstt->credit)){

					$precredit = $trstt->credit; 
				//	$precredit =  preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $precredit);

					 $prevbalance = floatval($prevbalance) + floatval($precredit) ;
					//echo "<br>";
					
				 }
			     
			     if(isset($trstt->debit) && !empty($trstt->debit)){

					$predebit = $trstt->debit; 
				//	$predebit =  preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $predebit);

				 	$prevbalance = floatval($prevbalance) - floatval($predebit) ;
				
					
				 }
		        
		        
		        
		        
		        
		    }
		    
		    	$currentball =  number_format((float)$prevbalance, 2, '.', '');
		    	
		    	$currentball = preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $currentball);
		    
		    
		    
		    
		    
		    
		    /*$bass = floatval($statementtnew[0]->balance);
		    $creditbb = floatval($statementtnew[0]->credit);
		    $debitbb = floatval($statementtnew[0]->debit);
		    
		    if($creditbb>0){
		    
		    $curtbb = $bass - $creditbb;
    		}else if($debitbb>0){
    		    
    		     $curtbb = $bass + $debitbb;
    		}
    		
    		$currentball =  number_format((float)$curtbb, 2, '.', '');*/
		    
		}else{
		    $currentball =  "0.00";
		}
		
		
		
		
        //$this->fpdf->Cell(30,5,'Balance as on '.date('d F Y',$frm).':');
		//$this->fpdf->Cell(2,5,'');
		//$this->fpdf->Cell(50,5,"$currentball",0,1,'L');

		$this->fpdf->ln(10);

// 		$this->fpdf->SetFont('Arial','',12);
// 		$this->fpdf->Cell(50,5,'Account Statement from '. date('d F Y',$frm).' to '. date('d F Y',$tod),0,1,'L');
        
		$this->fpdf->ln(5);

		$this->fpdf->SetWidths(array(10,20,20,20,20,45,10,25,25));

		$this->fpdf->SetAligns(array('C','C','C','C','L','C','R','R','R'));
		$this->fpdf->SetFont('Arial','B',7);
		$this->fpdf->Row(array("No.","Transaction ID","Value Date","Txn Poste Date","Cheque No.","Description","Cr/Dr","Transaction Amount(INR)", "Available Balance(INR)"));
        
        //echo date('d-m-y',$frm);
        
		$statementt = $this->db->query("select * from  ci_transaction where from_account_id='".$acno."' and (doe>='".$frm."' and  doe<='".$tod."'  ) order by doe asc ")->result();
	  //	echo "select * from  ci_transaction where from_account_id='".$acno."' and (doe>='".$frm."' and doe<='".$tod."') order by doe asc";
	   //$prevbalance = 1010000;
	   //$currentball  = 
	   $currentbalance = floatval($prevbalance);
		if(isset($statementt) && !empty($statementt)){

			$balance = 0 ;
			//$currentbalance = $prevbalance ;
			
            $sl=1;
			foreach($statementt as $txnn){
			    
			    $transid = rand(43278659,23898608);
			    
			    //print_r($txnn);
			    //echo "<br>";
			    
			    $txtdd ="S".$transid;
			    
			    

			    $this->fpdf->SetAligns(array('C','C','C','C','L','C','R','R','R'));
				$this->fpdf->SetFont('Arial','',7);

				$dd = date('d F Y',$txnn->doe);
				
				$valuedate = date('d/m/Y',$txnn->doe);
				
				//$hrs = rand(1,12);
				
				$valuedate_2 = date('d/m/Y H:i:s A',$txnn->doe);
				
				$cghh = $txnn->refno_chq_no ;
				
				$trnfg = "";

				if(floatval(($txnn->debit)>0)){

					$debit = floatval($txnn->debit); 
					$debitbalance =  floatval($txnn->debit); 
					$debit =  preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $debit);

					$balance = floatval($balance) - floatval($debit) ;
					$txt = $part = $txnn->description;
					
					$trnfg = $debit;
					
					$currentbalance = floatval($currentbalance) - floatval($debitbalance);

				  }else{

					$debit = "";
					$debitbalance = 0 ;
					$trnfg = $debit;
					
					$currentbalance = floatval($currentbalance) - floatval($debitbalance);
				

				  }

				if((floatval($txnn->credit))>0){
				    
				   
				    
				    //$precredit = $trstt->credit;
                    
					$credit = floatval($txnn->credit);
					$creditbalance =  floatval($txnn->credit); 
					$credit = preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $credit);
					
					$balance = floatval($balance) +  floatval($credit) ;
					$txt = $part = $txnn->description;;
					
					$trnfg = $credit;
					
					$currentbalance = floatval($currentbalance) + floatval($creditbalance);

				  }else{

					$credit ="";
					$creditbalance= 0 ;
					$currentbalance = floatval($currentbalance) + floatval($creditbalance);
					
					$trnfg = $credit;
					

				  }
				  
				  

				  //$ball = number_format((float)$txnn->balance, 2, '.', '');
				  
				  $ball = number_format((float)$currentbalance, 2, '.', '');
				  
				 // $ball = "5230.25";
				  
				 // setlocale(LC_MONETARY, 'en_IN');
                  $amount = preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $ball);
                  
                  //$this->fpdf->Row(array("No.","Transaction ID","Value Date","Txn Poste Date","Cheque No.","Description","Cr/Dr","Transaction Amount(INR)", "Available Balance(INR)"));

                //	$this->fpdf->SetWidths(array(20, 20, 35, 20,15,24,26,30));
                $this->fpdf->SetWidths(array(10,20,20,20,20,45,10,25,25));
                if(floatval($debit)>0){
                    $ffgg = "DR";
                    $trnfg = $debit ;
                    $cghh = "";
                }else{
                    $ffgg = "CR";
                }
				$this->fpdf->Row(array("$sl","$txtdd","$valuedate","$valuedate_2","$cghh","$txt","$ffgg","$trnfg","$amount"));
				
				$sl++;


			}

		}
		$this->fpdf->ln(2);
		$this->fpdf->SetFont('Arial','',8);
		$this->fpdf->multicell(195,5,' Please do not share your ATM, Debit/Credit card number, PIN (Personal Identification Number) and OTP (One Time Password)	with anyone over mail, SMS, phone call or any other media. Bank never asks for such information.');	

		$this->fpdf->ln(5);
		$this->fpdf->cell(5);
		$this->fpdf->multicell(190,5,'**This is a computer generated statement and does not require a signature.');
		



		//All text which have to print should be goes here
		//also you can go for calling view over here and put the same type of code inside the view
		
		//echo $this->fpdf->Output("Statement_".$accinfo[0]->account_number."XXXXX0256.pdf",'D');
        echo $this->fpdf->Output();
	}
	
	public function transfer(){
	    
	    
		$data = array();
		
		if(isset($_POST['submit'])){


			$this->form_validation->set_rules('account_no', 'Account Number', 'required');
			$this->form_validation->set_rules('amount', 'Amount', 'trim|required');
			//$this->form_validation->set_rules('particulars', 'Description', 'required');
			$this->form_validation->set_rules('date_of_entry', 'Date', 'required');

			if ($this->form_validation->run() == FALSE) {
				$data = array(
					'errors' => validation_errors()
				);
				$this->session->set_flashdata('errors', $data['errors']);
				redirect(base_url('admin/banking/transfer'));
			}
			else{

				$accno = $this->input->post('account_no');
				$amunt = $this->input->post('amount');
				$particulars = strtoupper($this->input->post('particulars'));
				$chwno = $this->input->post('chq_no');
				$totransfer = $this->input->post('transfer_form');
				$acnum = $this->input->post('upi');
				$owner = strtoupper($this->input->post('owner'));
				$bankshort = strtoupper($this->input->post('bank_name'));
				
				$utir = rand(123456789085,999999999999);
				
				$date_of_debit = date('Y-m-d',strtotime($this->input->post('date_of_entry')));
				
				$particu = "$totransfer$acnum/$utir/$owner/$bankshort/$particulars";
				
				
				$newbalancet = number_format((float)$amunt, 2, '.', '');
				// $last_baance = $this->db->query("select * from ci_transaction order by id desc limit 1")->result();
				// $balancenew = floatval($last_baance[0]->balance);
				// if(isset($balancenew) && !empty($balancenew)){
				//     if($balancenew>=floatval($amunt)){
    // 				    $newbalance = floatval($balancenew) - floatval($amunt);
    // 				    $newbalancet = number_format((float)$newbalance, 2, '.', '');
				//     }else{
				        
				//       $data = array(
    // 					'errors' => "insufficient balance."
    //     				);
    //     				$this->session->set_flashdata('errors', $data['errors']);
    //     				redirect(base_url('admin/banking/transfer')); 
				        
				//     }
				    
				// }else{
				   
				//     $data = array(
				// 	'errors' => "insufficient balance."
    // 				);
    // 				$this->session->set_flashdata('errors', $data['errors']);
    // 				redirect(base_url('admin/banking/transfer'));
				    
				// }
				

				$data_credit = array(
					"account_id"=>$accno,
					"amount" => $amunt,
					"particulars" => $particu,
					"ref_no" => $chwno,
					"doe" => strtotime($this->input->post('date_of_entry')),
					"added_by" => $this->session->userdata('user_id'),
					"status" => 1,
					"created_at" => date('Y-m-d : h:m:s'),
					"updated_at" => date('Y-m-d : h:m:s'),
					

				);
				
				
				
				
				//get last balance = 
				
				
				
				
				

				$data_transaction = array(
					"from_account_id"=>$accno,
					"description"=> $particu,
					"debit"=> $amunt,
					"balance"=>$newbalancet,
					"doe"=> strtotime($this->input->post('date_of_entry')),
					"refno_chq_no"=>$chwno,
					"status" => 1,
					"created_at" => date('Y-m-d : h:m:s'),
					"updated_at" => date('Y-m-d : h:m:s'),

				);


				$data = $this->security->xss_clean($data);
				$result = $this->banking_model->add_debit_transaction($data_credit,$data_transaction);
				if($result){

					// Activity Log 
					$this->activity_model->add_log(1);

					$this->session->set_flashdata('success', $amunt.'  has been created successfully!');
					redirect(base_url('admin/banking/transfer'));
				}


			}
			

		}else{

			$this->load->view('admin/includes/_header');
			$this->load->view('admin/banking/transfer', $data);
			$this->load->view('admin/includes/_footer');

		}

        

   

	}
	
	public function receive(){
	    
	    
		$data = array();
		
		if(isset($_POST['submit'])){


			$this->form_validation->set_rules('account_no', 'Account Number', 'required');
			$this->form_validation->set_rules('amount', 'Amount', 'trim|required');
			$this->form_validation->set_rules('particulars', 'Description', 'required');
			$this->form_validation->set_rules('date_of_entry', 'Date', 'required');


			if ($this->form_validation->run() == FALSE) {
				$data = array(
					'errors' => validation_errors()
				);
				$this->session->set_flashdata('errors', $data['errors']);
				redirect(base_url('admin/banking/receive'));
			}
			else{

				$accno = $this->input->post('account_no');
				$amunt = $this->input->post('amount');
				$particulars = strtoupper($this->input->post('particulars'));
				$chwno = $this->input->post('chq_no');
				$totransfer = $this->input->post('transfer_form');
				$acnum = $this->input->post('upi');
				$owner = strtoupper($this->input->post('owner'));
				$bankshort = strtoupper($this->input->post('bank_name'));
				$utir = rand(123456710050,999999999999);
				
				$particu = $totransfer.$acnum."/".$utir.'/'.$owner."/".$bankshort."/".$particulars;
				

				$data_credit = array(
					"account_id"=>$accno,
					"amount" => $amunt,
					"particulars" => $particu,
					"ref_no" => $chwno,
					"doe" => strtotime($this->input->post('date_of_entry')),
					"added_by" => $this->session->userdata('user_id'),
					"status" => 1,
					"created_at" => date('Y-m-d : h:m:s'),
					"updated_at" => date('Y-m-d : h:m:s'),
					

				);
				
				
				
				
				//get last balance = 
				
				$last_baance = $this->db->query("select * from ci_transaction order by id desc limit 1")->result();
				$balancenew = floatval($last_baance[0]->balance);
				if(isset($balancenew) && !empty($balancenew)){
				    $newbalance = $balancenew + floatval($amunt);
				    
				}else{
				    $newbalance = floatval($amunt);
				    
				}
				
				$newbalancet = number_format((float)$newbalance, 2, '.', '');
				

				$data_transaction = array(
					"from_account_id"=>$accno,
					"description"=> $particu,
					"credit"=> $amunt,
					"balance" => $newbalancet,
					"doe"=>strtotime($this->input->post('date_of_entry')),
					"refno_chq_no"=>$chwno,
					"status" => 1,
					"created_at" => date('Y-m-d : h:m:s'),
					"updated_at" => date('Y-m-d : h:m:s'),

				);


				$data = $this->security->xss_clean($data);
				$result = $this->banking_model->add_credit_transaction($data_credit,$data_transaction);
				
				if($result){

					// Activity Log 
					$this->activity_model->add_log(1);

					$this->session->set_flashdata('success', $amunt.'  has been created successfully!');
					redirect(base_url('admin/banking/receive'));
				}


			}
			

		}else{

			$this->load->view('admin/includes/_header');
			$this->load->view('admin/banking/receive', $data);
			$this->load->view('admin/includes/_footer');

		}

        

	    
	}
	public  function IND_money_format($number){    	
            $decimal = (string)($number - floor($number));
            $money = floor($number);
            $length = strlen($money);
            $delimiter = '';
            $money = strrev($money);
 
            for($i=0;$i<$length;$i++){
                if(( $i==3 || ($i>3 && ($i-1)%2==0) )&& $i!=$length){
                    $delimiter .=',';
                }
                $delimiter .=$money[$i];
            }
 
            $result = strrev($delimiter);
            $decimal = preg_replace("/0\./i", ".", $decimal);
            $decimal = substr($decimal, 0, 3);
 
            if( $decimal != '0'){
                $result = $result.$decimal;
            }
 
            return $result;
        }
        
    public function get_benificia_acc_details(){
        
        $idd = $this->input->post('id');
        
        //get account holder name 
        
        $resy = $this->db->query("select * from ci_account_benificiary where id='".$idd."'")->result();
        
        $accnumber = $resy[0]->b_account;
        $accname = $resy[0]->b_name;
        $bank_name = $resy[0]->b_bank_name;
        
        $msg = array('accno'=>$accnumber,'accname'=>$accname,'bankname'=>$bank_name);
        
        echo json_encode($msg);
        
        
        
        
        //echo $idd.'hello';
    }
    
    public function credit_delete($id){
        
        $this->db->where(array('transaction_id'=>$id));
        $this->db->delete('ci_credit');
        
        $this->db->where(array('id'=>$id));
        $this->db->delete('ci_transaction');
        
        $this->session->set_flashdata('success', 'Data deleted successfully');
		redirect(base_url('admin/banking/receive'));
        
    }
    
    public function debit_delete($id){
        
        $this->db->where(array('transaction_id'=>$id));
        $this->db->delete('ci_debit');
        
        $this->db->where(array('id'=>$id));
        $this->db->delete('ci_transaction');
        
        $this->session->set_flashdata('success', 'Data deleted successfully');
		redirect(base_url('admin/banking/transfer'));
        
    }

}

MMCT - 2023