86 lines
2.3 KiB
PHP
86 lines
2.3 KiB
PHP
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class department_model extends CI_Model
|
|
{
|
|
|
|
/**
|
|
* This function is used to get the user listing count
|
|
* @return array $result : result of the query(returns Department details)
|
|
*/
|
|
function departmentListing()
|
|
{
|
|
$this->db->select('BaseT.DepartmentName, BaseT.DEPCode, BaseT.HeadDept, BaseT.IsActive');
|
|
$this->db->from('T_DepartmentDetails as BaseT');
|
|
$this->db->order_by("BaseT.DEPCode", "asc");
|
|
$query = $this->db->get();
|
|
$result = $query->result();
|
|
return $result;
|
|
}
|
|
|
|
|
|
/**
|
|
* To get Department information by id
|
|
* @param array $department : This will have all the department datas
|
|
* @return array $result : result of the query (returns as count in numbers)
|
|
*/
|
|
function addNewdepartment($department)
|
|
{
|
|
|
|
$this->db->insert('T_DepartmentDetails', $department);
|
|
|
|
$SID = $this->db->affected_rows();
|
|
|
|
return $SID;
|
|
|
|
}
|
|
|
|
/**
|
|
* To get active department datas
|
|
* @return array $result : result of the query(returns DepartmentCode and DepartmentName)
|
|
*/
|
|
function getdepcode()
|
|
{
|
|
|
|
$this->db->distinct();
|
|
$this->db->select('DEPCode, DepartmentName');
|
|
$this->db->from('T_DepartmentDetails');
|
|
$this->db->where('IsActive =', 1);
|
|
|
|
$query = $this->db->get();
|
|
|
|
return $query->result();
|
|
}
|
|
|
|
/**
|
|
* To get department details
|
|
* @param number $DEPCode : Optional : this is department code
|
|
* @return array $result : result of the query
|
|
*/
|
|
function getDeptInfo($DEPCode='')
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('T_DepartmentDetails');
|
|
$this->db->where('DEPCode', $DEPCode);
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
|
|
/**
|
|
* To store edited department details repective depcode
|
|
* @param array $department : This will have all edited department datas
|
|
* @param number $DEPCode : This is department code
|
|
**/
|
|
function Updatedepartment($department, $DEPCode)
|
|
{
|
|
$this->db->where('DEPCode', $DEPCode);
|
|
$this->db->update('T_DepartmentDetails', $department);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
?>
|