159 lines
4.8 KiB
PHP
Executable File
159 lines
4.8 KiB
PHP
Executable File
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class rawmaterialdetails_model extends CI_Model
|
|
{
|
|
/**
|
|
* This function is used to get the user listing count
|
|
* @param string $searchText : This is optional search text
|
|
* @return number $count : This is row count
|
|
*/
|
|
function rawmaterialListingCount($searchText = '')
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('T_MaterialMaster');
|
|
|
|
if(!empty($searchText)) {
|
|
$likeCriteria = "(MaterialCode LIKE '%".$searchText."%'
|
|
OR MaterialName LIKE '%".$searchText."%'
|
|
OR MaterialType LIKE '%".$searchText."%' OR UOM LIKE '%".$searchText."%')";
|
|
$this->db->where($likeCriteria);
|
|
}
|
|
//$this->db->where('BaseT.isDeleted', 0);
|
|
//$this->db->where('BaseT.userId !=', 1);
|
|
$query = $this->db->get();
|
|
|
|
return count($query->result());
|
|
}
|
|
/**
|
|
* This function is used to get the user listing count
|
|
* @param string $searchText : This is optional search text
|
|
* @param number $page : This is pagination offset
|
|
* @param number $segment : This is pagination limit
|
|
* @return array $result : This is result
|
|
*/
|
|
function rawmaterialListing($searchText = '', $page, $segment)
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('T_MaterialMaster');
|
|
|
|
if(!empty($searchText)) {
|
|
$likeCriteria = "(MaterialCode LIKE '%".$searchText."%'
|
|
OR MaterialName LIKE '%".$searchText."%'
|
|
OR MaterialType LIKE '%".$searchText."%' OR UOM LIKE '%".$searchText."%')";
|
|
|
|
$this->db->where($likeCriteria);
|
|
}
|
|
|
|
$this->db->limit($page, $segment);
|
|
$query = $this->db->get();
|
|
|
|
$result = $query->result();
|
|
return $result;
|
|
}
|
|
|
|
|
|
|
|
function getUOM($UOM = '')
|
|
{
|
|
$ConfigID = 'C001';
|
|
$this->db->select('ConfigValue');
|
|
$this->db->from('T_ConfigDetails');
|
|
$this->db->where('Config_id ',$ConfigID );
|
|
if($UOM != '')
|
|
{
|
|
$this->db->where('ConfigValue !=',$UOM );
|
|
}
|
|
$query = $this->db->get();
|
|
|
|
return $query->result();
|
|
}
|
|
|
|
function getmaterialType($MaterialType = '')
|
|
{
|
|
$Config_ID = 'C003';
|
|
|
|
$this->db->select('Config_ID,ConfigValue');
|
|
$this->db->from('T_ConfigDetails');
|
|
$this->db->where('Config_id',$Config_ID );
|
|
if($MaterialType != '')
|
|
{
|
|
$this->db->where('ConfigValue !=',$MaterialType );
|
|
}
|
|
$query = $this->db->get();
|
|
|
|
return $query->result();
|
|
}
|
|
/**
|
|
* This function used to get user information by id
|
|
* @param number $userId : This is user id
|
|
* @return array $result : This is user information
|
|
*/
|
|
|
|
function addNewRawMaterial($RawMaterial='')
|
|
{
|
|
|
|
$this->db->insert('T_MaterialMaster', $RawMaterial);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
/**
|
|
* This function used to get user information by id
|
|
* @param number $userId : This is user id
|
|
* @return array $result : This is user information
|
|
*/
|
|
function getMaterialDetails($MaterialCode)
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('T_MaterialMaster');
|
|
|
|
$this->db->where('MaterialCode', $MaterialCode);
|
|
$query = $this->db->get();
|
|
//sprint_r($this->db->last_query());
|
|
return $query->result();
|
|
}
|
|
function editRawmaterial($RawMaterial, $MaterialCode)
|
|
{
|
|
|
|
|
|
|
|
$this->db->where('MaterialCode', $MaterialCode);
|
|
$this->db->update('T_MaterialMaster', $RawMaterial);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
function viewrawmaterial($RawMaterial, $MaterialCode)
|
|
{
|
|
echo $MaterialCode; //."and".$RawMaterial ;
|
|
|
|
|
|
$this->db->where('MaterialCode', $MaterialCode);
|
|
$this->db->update('T_MaterialMaster', $RawMaterial);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
function export_excel(){
|
|
|
|
$this->db->select('det.MaterialCode,det.MaterialName,det.MaterialType,det.UOM,emp.firstname,emp1.firstname as Updated_By,det.IsActive');
|
|
$this->db->join('tbl_users as tbl',' det.createdby = tbl.userid','left');
|
|
$this->db->join('T_Employee_Details as emp', 'emp.empid=tbl.empid','left');
|
|
$this->db->join('tbl_users as tbl1',' det.UpdatedBy = tbl1.userid','left');
|
|
$this->db->join('T_Employee_Details as emp1', 'emp1.empid=tbl1.empid','left');
|
|
return $this->db->get('T_MaterialMaster as det')->result_array();
|
|
}
|
|
/**
|
|
* This function is used to delete the user information
|
|
* @param number $userId : This is user id
|
|
* @return boolean $result : TRUE / FALSE
|
|
|
|
function deletePO($PO, $POinfo)
|
|
{
|
|
$this->db->where('PO', $PO);
|
|
$this->db->update('T_PurchaseOrderDetails', $POInfo);
|
|
|
|
return $this->db->affected_rows();
|
|
}*/
|
|
}
|
|
?>
|