| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/adeetie/application/models/ |
Upload File : |
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Mbank extends CI_Model{
protected $tableName = 'banking_users';
function usermodel() {
return array(
'name' => $this->input->post('name'),
'email_id' => $this->input->post('email_id'),
'user_type' => $this->input->post('user_type'),
'state_code' => $this->input->post('state_code')
);
}
function add_user(){
$arr = $this->usermodel();
if(!empty($this->input->post('password'))) {
$arr['password'] = password_hash($this->input->post('password'), PASSWORD_DEFAULT);
}
$arr['user_id'] = uniqid();
$arr['created_by'] = json_encode([
'email_id' => $this->session->userdata('email_id'),
'name' => $this->session->userdata('name'),
'user_type' => $this->session->userdata('user_type'),
'user_id' => $this->session->userdata('user_id')
]);
$this->db->insert($this->tableName, $arr);
if( $this->db->affected_rows() > 0 ) {
$id = $this->db->insert_id();
$this->session->set_flashdata('message','Successfully Updated');
redirect('console/users', 'refresh');
} else {
$this->session->set_flashdata('error','Unknown error');
redirect('console/users', 'refresh');
}
}
function update_user($id) {
$arr = $this->usermodel();
if(!empty($this->input->post('password'))) {
$arr['password'] = password_hash($this->input->post('password'), PASSWORD_DEFAULT);
}
$this->db->where('user_id', $id);
$this->db->update( $this->tableName, $arr );
if( $this->db->affected_rows() > 0 ) {
$this->session->set_flashdata( 'message','Successfully Updated' );
redirect('console/users', 'refresh');
} else {
$this->session->set_flashdata('error','Updation failed');
redirect('console/users', 'refresh');
}
}
function get_all_user() {
$query = $this->db->select('bee_users.*, states.state_name')
->distinct()
->from('bee_users')
->join('states', 'states.state_code = bee_users.state_code', 'left')
->get();
if( $query->num_rows() > 0 ) {
return $query->result_array();
}
}
function get_user_byid($id) {
$this->db->where('user_id', $id);
$sql = $this->db->get($this->tableName);
if ($sql->num_rows() > 0) {
return $sql->row_array();
}
}
function get_bank_detail() {
$this->db->order_by('bank_name', 'asc');
$this->db->where('status', 1);
$sql = $this->db->get('banks');
if ($sql->num_rows() > 0) {
return $sql->result_array();
}
}
function get_bank_all() {
$this->db->order_by('bank_name', 'asc');
$sql = $this->db->get('banks');
if ($sql->num_rows() > 0) {
return $sql->result_array();
}
}
}