BBnepal-Accounts/application/models/Accountant_model.php
Sampanna Rimal 9cd05ef3cb commitall
2024-07-10 18:28:19 +05:45

92 lines
2.1 KiB
PHP

<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Accountant_model extends CI_Model
{
public function __construct()
{
$this->load->database();
}
public function login_accountant($uname, $pwd)
{
$pwd = md5($pwd);
$sql = "SELECT a.* FROM admin a
INNER JOIN admin_roles ar on ar.id = a.admin_role_ids
WHERE (a.email='$uname' AND a.password='$pwd') AND ar.role_name LIKE 'accountant%';";
$sql = $this->db->query($sql);
if ($sql->num_rows() > 0) {
return $sql->row_object();
} else {
return false;
}
}
public function checkEmailExist($email) {
$usernameCheck = "Select * from admin WHERE email = '".$email."'";
$unameCheck = $this->db->query($usernameCheck);
if ($unameCheck->num_rows() == 0) {
return false;
} else {
return true;
}
}
public function get_table_info($table_name, $where = '', $sqlQry = '', $order = 'DESC', $limit = FALSE, $offset = FALSE)
{
if ($limit)
$this->db->limit($limit, $offset);
if ($where != '')
$this->db->where($where);
$this->db->order_by($table_name . '.id', $order);
$query = $this->db->get($table_name);
if ($sqlQry != '')
$query = $this->db->query($sqlQry);
return $query->result_array();
}
public function get_table_info_row($table_name, $where = '', $sqlQry = '', $order = 'DESC', $limit = FALSE, $offset = FALSE)
{
if ($limit)
$this->db->limit($limit, $offset);
if ($where != '')
$this->db->where($where);
$this->db->order_by($table_name . '.id', $order);
$query = $this->db->get($table_name);
if ($sqlQry != '')
$query = $this->db->query($sqlQry);
return $query->row_array();
}
public function update_table($id, $data, $table) {
$this->db->trans_start();
$this->db->where('id', $id);
$this->db->update($table, $data);
$this->db->trans_complete();
if ($this->db->trans_status() === FALSE)
return 0;
return true;
}
public function insert_data($table, $data) {
$this->db->insert($table, $data);
if ($this->db->affected_rows() > 0)
return $insert_id = $this->db->insert_id();
else
return 0;
}
}