siddharth_application/application/models/Purchaseorder_model.php
saravanakumar_kandasami 749478c0e4 new code
2017-03-13 14:24:41 +05:30

193 lines
7.4 KiB
PHP

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class purchaseorder_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 purchaseorderListingCount($searchText = '')
{
$this->db->select('BaseT.PONO, BaseT.POType, BaseT.PODate, ID.SupplierID,BaseT.SpecialOrder, users.UserID,BaseT.RequesterEmail,BaseT.RequesterPh,BaseT.RequestedDate,BaseT.BudgetManager,BaseT.BudgetManagerDepartment,BaseT.PurchasingCategory');
$this->db->from('T_PurchaseOrderDetails 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.PONO LIKE '%".$searchText."%'
OR BaseT.POType LIKE '%".$searchText."%'
OR BaseT.PODate LIKE '%".$searchText."%'
OR BaseT.SupplierID LIKE '%".$searchText."%'
OR BaseT.UserID LIKE '%".$searchText."%'
OR BaseT.RequesterEmail LIKE '%".$searchText."%'
OR BaseT.RequesterPh LIKE '%".$searchText."%'
OR BaseT.RequestedDate LIKE '%".$searchText."%'
OR BaseT.BudgetManager LIKE '%".$searchText."%'
OR BaseT.BudgetManagerDepartment LIKE '%".$searchText."%'
OR BaseT.PurchasingCategory LIKE '%".$searchText."%'
OR BaseT.SpecialOrder 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 purchaseorderListing($searchText = '', $page, $segment)
{
$this->db->select('BaseT.PONO, BaseT.POType, BaseT.PODate, ID.SupplierID,BaseT.SpecialOrder, users.UserID,BaseT.RequesterEmail,BaseT.RequesterPh, BaseT.RequestedDate, BaseT.BudgetManager, BaseT.BudgetManagerDepartment, BaseT.PurchasingCategory');
$this->db->from('T_PurchaseOrderDetails 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.PONO LIKE '%".$searchfield."%'
OR BaseT.POType LIKE '%".$searchText."%'
OR BaseT.PODate LIKE '%".$searchText."%'
OR BaseT.SupplierID LIKE '%".$searchText."%'
OR BaseT.UserID LIKE '%".$searchText."%'
OR BaseT.RequesterEmail LIKE '%".$searchText."%'
OR BaseT.RequesterPh LIKE '%".$searchText."%'
OR BaseT.RequestedDate LIKE '%".$searchText."%'
OR BaseT.BudgetManager LIKE '%".$searchText."%'
OR BaseT.BudgetManagerDepartment LIKE '%".$searchText."%'
OR BaseT.PurchasingCategory LIKE '%".$searchText."%'
OR BaseT.SpecialOrder 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;
}
/**
* This function is used to get the SupplierID information
* @return array $result : This is result of the query
*/
function getSupplierName()
{
$this->db->select('SupplierID, SupplierName');
$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();
}
/**
* This function is used to check whether email id is already exist or not
* @param {string} $email : This is email id
* @param {number} $userId : This is user id
* @return {mixed} $result : This is searched result
function checkEmailExists($email, $userId = 0)
{
$this->db->select("email");
$this->db->from("tbl_users");
$this->db->where("email", $email);
$this->db->where("isDeleted", 0);
if($userId != 0){
$this->db->where("userId !=", $userId);
}
$query = $this->db->get();
return $query->result();
}*/
/**
* This function is used to add new user to system
* @return number $insert_id : This is last inserted id
*/
function addNewPO($POInfo)
{
$this->db->trans_start();
$this->db->insert('T_PurchaseOrderDetails', $POInfo);
$PO_id = $this->db->insert_id();
$this->db->trans_complete();
return $PO_id;
}
/**
* 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($PO)
{
$this->db->select('POType, PODate, SupplierID,SpecialOrder,UserID,RequestedDate,RequesterEmail,RequesterPh,PurchasingCategory,BudgetManager,BudgetManagerDepartment,');
$this->db->from('T_PurchaseOrderDetails');
//$this->db->where('isDeleted', 0);
//$this->db->where('roleId !=', 1);
$this->db->where('PONO', $PO);
$query = $this->db->get();
return $query->result();
}
/**
* This function is used to update the user information
* @param array $userInfo : This is users updated information
* @param number $userId : This is user id
*/
function editPO($POInfo, $PO)
{
$this->db->where('PONO', $PO);
$this->db->update('T_PurchaseOrderDetails', $PO);
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();
}*/
/**
* This function is used to match users password for change password
* @param number $userId : This is user id
*/
}