siddharth_application/application/models/supplier_model.php
venbatechnologies@gmail.com a262577714 link creation for supplier
2018-07-24 12:36:37 +05:30

207 lines
6.9 KiB
PHP
Executable File

<?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
* @param number $page : This is pagination offset
* @param number $segment : This is pagination limit
* @return array $result : This is result
*/
function supplierListing()
{
$this->db->select('BaseT.SupplierID, BaseT.SupplierName, BaseT.Address, BaseT.ContactNumber, BaseT.AlternateContactNumber,BaseT.EmailAddress,BaseT.Exiseregistration, BaseT.TIN, BaseT.PAN,,BaseT.GSTNO,BaseT.GSTRange,BaseT.CollectrateAddress,BaseT.UANumber,BaseT.CreatedOn,BaseT.PaymentID,pmt.PaymentTerms,BaseT.CSTDate');//,BaseT.PaymentTerms,BaseT.PaymentDays,BaseT.PayableAT,pmt.Details');
$this->db->from('T_SupplierDetailsN as BaseT');
$this->db->join('T_PaymentTerms as pmt', 'pmt.PaymentID = BaseT.PaymentID','left');
$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 getpayment($Configvalue = '')
{
$ConfigID = 'C009';
$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();
}
function getPaymentTerms($payment = '')
{
$this->db->select('*');
$this->db->from('T_PaymentTerms');
$query = $this->db->get();
$result = $query->result();
return $result;
}
function checkPAN($PAN,$SID = '')
{
$this->db->select('PAN');
$this->db->from('T_SupplierDetailsN');
$this->db->where('PAN',$PAN);
if ($SID != '')
{
$this->db->where('SupplierID !=',$SID);
}
$query = $this->db->get();
//print_r($this->db->last_query());
if ($query->num_rows > 0) {
//echo $result->num_rows;
return $query->result_array();
}
}
function checkGST($GST,$SID = '')
{
$this->db->select('GSTNO');
$this->db->from('T_SupplierDetailsN');
$this->db->where('GSTNO',$GST);
if ($SID != '')
{
$this->db->where('SupplierID !=',$SID);
}
$query = $this->db->get();
//print_r($this->db->last_query());
if ($query->num_rows > 0) {
// echo $query->num_rows;
return $query->result_array();
}
}
function addNewsupplier($supplier)
{
$this->db->insert('T_SupplierDetailsN', $supplier);
$SID = $this->db->affected_rows();
return $SID;
}
// function addNewsupplier($supplier)
// {
// $this->db->insert('T_SupplierDetailsN', $supplier);
// $SID = $this->db->affected_rows();
// // if($SID>0)
// // {
// // $subQuery = 'select max(SupplierID) as suppid from T_SupplierDetailsN';
// // $query = $this->db->query($subQuery);
// // return $query->result();
// // }
// return $SID;
// }
/**
* This function used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function getSupplierInfo($supplierID='')
{
$this->db->select('SD.*,PT.PaymentTerms');
//$this->db->select('SD.SupplierID, SD.SupplierName, SD.Address, SD.ContactNumber, SD.AlternateContactNumber, SD.EmailAddress, SD.Exiseregistration, SD.TIN, SD.PAN, SD.CSTNO, SD.CSTDate, SD.GSTNO, SD.GSTRange, SD.CollectrateAddress, SD.UANumber, SD.Cert_EMS, SD.Cert_TS, SD.Cert_IMS, SD.Cert_ISO, SD.Cert_OSHAS, SD.BankAcNumber, SD.IsService, SD.IsMaintanance, SD.IsRawMaterial, SD.IFSCCode, SD.BranchName, SD.BankAddress, SD.IsActive, SD.PaymentID,PT.PaymentTerms');
$this->db->from('T_SupplierDetailsN SD');
$this->db->join('T_PaymentTerms PT','PT.PaymentID = SD.PaymentID','left');
$this->db->where('SD.SupplierID', $supplierID);
$query = $this->db->get();
// print_r($this->db->last_query());
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 UpdateSupplier($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;
}
function SupplierCertification($cerificate)
{
$this->db->insert_id('T_Supplier_Certification',$cerificate);
$insert_id = $this->db->affected_rows();
return $insert_id;
}
function export_excel(){
$this->db->select('det.SupplierID,SupplierName,det.Address,det.ContactNumber,det.AlternateContactNumber,det.EmailAddress,det.Exiseregistration,det.TIN,
det.PAN,det.CSTNO,det.CSTDate,det.GSTNO,det.GSTRange,det.CollectrateAddress,det.UANumber,pmt.PaymentTerms,emp.firstname ,emp1.firstname as Update_by,det.IsActive,
det.Cert_EMS,det.Cert_TS,det.Cert_OSHAS,det.Cert_ISO,det.Cert_IMS,det.BankAcNumber,det.IFSCCode,det.BranchName,det.BankAddress,
det.IsService,det.IsMaintanance,det.IsRawMaterial');
$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');
$this->db->join('T_PaymentTerms as pmt', 'pmt.PaymentID = det.PaymentID','left');
return $this->db->get('T_SupplierDetailsN as det')->result_array();
}
function checkSupplierExists($supp_name)
{
$this->db->select('SupplierID,SupplierName,Address');
$this->db->from('T_SupplierDetailsN');
$this->db->like('REPLACE(SupplierName, " ", "")', $supp_name);
$query = $this->db->get();
return $query->result();
}
/*SUPPLIER */
/*SUPPLIER TYPE */
}
?>