150 lines
5.0 KiB
PHP
150 lines
5.0 KiB
PHP
<?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('BaseT.MaterialCode, BaseT.MaterialName, BaseT.MaterialType, BaseT.UOM, BaseT.CreatedDate');
|
|
$this->db->from('T_MaterialMaster as BaseT');
|
|
//$this->db->join('tbl_users as users', 'users.userId = BaseT.userId','left');
|
|
//$this->db->join('T_SupplierDetailsN as ID', 'ID.SupplierID = BaseT.SupplierID','left');
|
|
if(!empty($searchText)) {
|
|
$likeCriteria = "(BaseT.MaterialCode LIKE '%".$searchText."%'
|
|
OR BaseT.MaterialName LIKE '%".$searchText."%'
|
|
OR BaseT.MaterialType LIKE '%".$searchText."%'
|
|
OR BaseT.SupplierID 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('BaseT.MaterialCode, BaseT.MaterialName, BaseT.MaterialType, BaseT.UOM ,BaseT.CreatedDate');
|
|
$this->db->from('T_MaterialMaster as BaseT');
|
|
|
|
//$this->db->join('T_SupplierDetailsN as ID', 'ID.SupplierID = BaseT.SupplierID','left');
|
|
if(!empty($searchText)) {
|
|
$likeCriteria = "(BaseT.MaterialCode LIKE '%".$searchText."%'
|
|
OR BaseT.MaterialName LIKE '%".$searchText."%'
|
|
OR BaseT.MaterialType LIKE '%".$searchText."%'
|
|
OR BaseT.SupplierID LIKE '%".$searchText."%')";
|
|
$this->db->where($likeCriteria);
|
|
}
|
|
//$this->db->where('BaseT.isDeleted', 0);
|
|
//$this->db->where('BaseT.userId !=', 1);
|
|
$this->db->limit($page, $segment);
|
|
$query = $this->db->get();
|
|
|
|
$result = $query->result();
|
|
return $result;
|
|
}
|
|
|
|
|
|
|
|
function getUOM()
|
|
{
|
|
$ConfigID = 'C001';
|
|
$this->db->select('ConfigValue');
|
|
$this->db->from('T_ConfigDetails');
|
|
$this->db->where('Config_id ',$ConfigID );
|
|
$query = $this->db->get();
|
|
|
|
return $query->result();
|
|
}
|
|
|
|
function getmaterial()
|
|
{
|
|
$Config_ID = 'C003';
|
|
|
|
$this->db->select('Config_ID,ConfigValue');
|
|
$this->db->from('T_ConfigDetails');
|
|
$this->db->where('Config_id',$Config_ID );
|
|
$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->trans_start();
|
|
$this->db->insert('T_MaterialMaster', $RawMaterial);
|
|
|
|
$MaterialCode = $this->db->insert_id();
|
|
|
|
$this->db->trans_complete();
|
|
|
|
return $MaterialCode;
|
|
}
|
|
|
|
/**
|
|
* This function used to get user information by id
|
|
* @param number $userId : This is user id
|
|
* @return array $result : This is user information
|
|
*/
|
|
function getuserInfo($MaterialCode)
|
|
{
|
|
$this->db->select('MaterialCode, MaterialName,MaterialType,UOM,CreatedBy,UpdatedBy,CreatedDate');
|
|
$this->db->from('T_MaterialMaster');
|
|
//$this->db->where('isDeleted', 0);
|
|
//$this->db->where('roleId !=', 1);
|
|
$this->db->where('MaterialCode', $MaterialCode);
|
|
$query = $this->db->get();
|
|
|
|
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;
|
|
}
|
|
/**
|
|
* 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();
|
|
}*/
|
|
}
|
|
?>
|