siddharth_application/application/models/supplier_model.php
saravanakumar_kandasami 9a4c13b92a updated code for demo
2017-03-28 11:30:22 +05:30

137 lines
5.5 KiB
PHP

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class supplier_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 supplierListingCount($searchText = '')
{
$this->db->select('BaseT.SupplierID, BaseT.SupplierName, BaseT.Address, BaseT.ContactNumber, BaseT.AlternateContactNumber,BaseT.EmailAddress,BaseT.TIN,BaseT.PAN');
$this->db->from('T_SupplierDetailsN as BaseT');
//$this->db->join('tbl_users as users', 'users.userId = BaseT.userId','left');
//$this->db->join('T_SupplierDetails as ID', 'ID.SupplierID = BaseT.SupplierID','left');
if(!empty($searchText)) {
$likeCriteria = "(BaseT.SupplierID LIKE '%".$searchText."%'
OR BaseT.SupplierName LIKE '%".$searchText."%'
OR BaseT.Address LIKE '%".$searchText."%'
OR BaseT.ContactNumber LIKE '%".$searchText."%'
OR BaseT.AlternateContactNumber LIKE '%".$searchText."%'
OR BaseT.EmailAddress LIKE '%".$searchText."%'
OR BaseT.TIN LIKE '%".$searchText."%'
OR BaseT.PAN 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 supplierListing($searchText = '', $page, $segment)
{
$this->db->select('BaseT.SupplierID, BaseT.SupplierName, BaseT.Address, BaseT.ContactNumber, BaseT.AlternateContactNumber,BaseT.EmailAddress, BaseT.TIN, BaseT.PAN,BaseT.CreatedDate');
$this->db->from('T_SupplierDetailsN as BaseT');
//$this->db->join('tbl_users as users', 'users.userId = BaseT.userId','left');
//$this->db->join('T_SupplierDetails as ID', 'ID.SupplierID = BaseT.SupplierID','left');
if(!empty($searchText)) {
$likeCriteria = "(BaseT.SupplierID LIKE '%".$searchText."%'
OR BaseT.SupplierName LIKE '%".$searchText."%'
OR BaseT.Address LIKE '%".$searchText."%'
OR BaseT.ContactNumber LIKE '%".$searchText."%'
OR BaseT.AlternateContactNumber LIKE '%".$searchText."%'
OR BaseT.EmailAddress LIKE '%".$searchText."%'
OR BaseT.TIN LIKE '%".$searchText."%'
OR BaseT.CreatedDate LIKE '%".$searchText."%'
OR BaseT.PAN 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 used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function addNewsupplier($supplier)
{
$this->db->trans_start();
$this->db->insert('T_SupplierDetailsN', $supplier);
$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($supplierID)
{
$this->db->select('SupplierID, SupplierName,Address,ContactNumber,AlternateContactNumber,EmailAddress,TIN,PAN,CreatedDate');
$this->db->from('T_SupplierDetailsN');
//$this->db->where('isDeleted', 0);
//$this->db->where('roleId !=', 1);
$this->db->where('SupplierID', $supplierID);
$query = $this->db->get();
return $query->result();
}
/* This function to get the Supplier Address on respective Supplier ID */
function GetSupplierAddress($supplierID)
{
$this->db->select('Address');
$this->db->from('T_SupplierDetailsN');
$this->db->where('SupplierID', $supplierID);
$query = $this->db->get();
return $query->result_array();
}
function editsupplier($supplier, $supplierID)
{
$this->db->where('SupplierID', $supplierID);
$this->db->update('T_SupplierDetailsN', $supplier);
return TRUE;
}
function viewsupplier($supplier, $supplierID)
{
$this->db->where('SupplierID', $supplierID);
$this->db->update('T_SupplierDetailsN', $supplier);
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();
}*/
}
?>