siddharth_application/application/models/requistion_model.php
gandhimathi Bharathirajan 1796a805e0 Requistion Flow
2017-05-10 10:52:52 +05:30

159 lines
4.4 KiB
PHP

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class requistion_model extends CI_Model
{
/**
* This function is used to get the SupplierID and SupplierName information
* @return array $result : This is result of the query
*/
function getSupplierName()
{
$this->db->select('SupplierID, SupplierName,Address');
$this->db->from('T_SupplierDetailsN');
//$this->db->where('roleId !=', 1);
$query = $this->db->get();
return $query->result();
}
/**
* This function is used to get the userId information
* @return array $result : This is result of the query
*/
function getusers()
{
$this->db->select('userId, name');
$this->db->from('tbl_users');
//$this->db->where('roleId !=', 1);
$query = $this->db->get();
return $query->result();
}
function GetEmployeeDetails($EmpID)
{
$this->db->select(' EMP.EmpID,EMP.Designation,DEPT.DEPCode,DEPT.DepartmentName');
$this->db->from('T_Employee_Details EMP');
$this->db->join('T_DepartmentDetails DEPT', 'EMP.Departmentcode = DEPT.DEPCode');
$this->db->where('EMP.EmpID ',$EmpID );
$query = $this->db->get();
return $query->result_array();
}
function GetCostCenterByDept($DeptId)
{
$this->db->select('Mast.CostCenterCode,Mast.CostCenterName');
$this->db->from('T_CostCenter_Master Mast ');
$this->db->join('T_CostCenter_Departments COST', 'COST.CostCenterCode = Mast.CostCenterCode');
$this->db->where('COST.DEPCode ',$DeptId );
$query = $this->db->get();
// print_r( $this->db->last_query());
return $query->result_array();
}
function GetAvailableBudgetAmount($CostCode,$Year,$BudgetType)
{
$this->db->select('BudgetAmount');
$this->db->from('T_CostCenter_Budget');
$this->db->where('CostCenterCode',$CostCode );
$this->db->where('BudgetYear',$Year );
$this->db->where('BudgetType',$BudgetType );
$query = $this->db->get();
return $query->result_array();
}
function GetMaterialCode($ReqType)
{
$this->db->select('MaterialCode, MaterialName,UOM');
$this->db->from('T_MaterialMaster');
$this->db->where('MaterialType',$ReqType );
$query = $this->db->get();
return $query->result_array();
}
/**
* This function is used to get the Raw Material information
* @return array $result : This is result of the query
*/
function getRawMaterialList($MaterialCode)
{
$this->db->select('MaterialName,UOM');
$this->db->from('T_MaterialMaster');
$this->db->where('MaterialCode',$MaterialCode );
$query = $this->db->get();
return $query->result_array();
}
/**
* This function is used to get the Config value from configuration table
* @return array $result : This is result of the query
*/
function getConfigValue($ConfigID ,$ConfigValue = '')
{
$this->db->select('ConfigValue');
$this->db->from('T_ConfigDetails');
$this->db->where('Config_id ',$ConfigID );
if($ConfigValue != '')
{
$this->db->where('ConfigValue != ',$ConfigValue );
}
$query = $this->db->get();
return $query->result();
}
/**
* This function is used to get the Purchase order Type
* @return array $result : This is result of the query
*/
function getAllEmployees()
{
$this->db->select('EmpID,FirstName,LastName');
$this->db->from('T_Employee_Details');
$query = $this->db->get();
return $query->result();
}
function addRequistion($Requistion)
{
$this->db->trans_start();
$this->db->insert('T_Requestion_Master', $Requistion);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
if($insert_id>0)
{
$subQuery = 'select max(ReqNo) as ReqNo from T_Requestion_Master';
$query = $this->db->query($subQuery);
return $query->result_array();
}
}
function addRequistionDetails($Requistion)
{
$this->db->trans_start();
$this->db->insert('T_Requestion_Details', $Requistion);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
print_r($this->db->last_query());
return $insert_id;
}
}