191 lines
5.3 KiB
PHP
191 lines
5.3 KiB
PHP
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class companydetailsmodel extends CI_Model
|
|
{
|
|
/**
|
|
* To Store the values
|
|
* @param number $Company : To get all the information of company
|
|
* @return $CompID : This will return how many value are inserted (return as number/count)
|
|
*/
|
|
function Companyadd($Company)
|
|
{
|
|
$this->db->insert('T_Company_Details', $Company);
|
|
$CompID = $this->db->affected_rows();
|
|
return $Company;
|
|
}
|
|
|
|
/**
|
|
* To Store the values
|
|
* @param number $myfile : To get all the information of company's file
|
|
* @return $CompID : This will return how many value are inserted (return as number/count)
|
|
*/
|
|
function filedetails($myfile)
|
|
{
|
|
$this->db->insert('file',$myfile);
|
|
$CompID = $this->db->affected_rows();
|
|
return $myfile;
|
|
}
|
|
|
|
|
|
/**
|
|
* To get the company files for listing
|
|
* @return array $query->result() : This is result of the query (company files's information)
|
|
*/
|
|
function filelist()
|
|
{
|
|
$sql=" select ID,filename,filedescription,createdDate from file where isDeleted IS NULL OR isDeleted=0";
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
}
|
|
|
|
|
|
/**
|
|
* To update the company files as inactive(if deleted means)
|
|
* @param number $ID :
|
|
* @param number $userInfo : To get all the information of company's files
|
|
* @return array $this->db->affected_rows() : This will return how many value are changed (return as number/count)
|
|
*/
|
|
function deletefile($ID,$userInfo)
|
|
{
|
|
$this->db->where('ID', $ID);
|
|
$this->db->update('file', $userInfo);
|
|
return $this->db->affected_rows();
|
|
}
|
|
|
|
|
|
/**
|
|
* To update the company related files information
|
|
* @param number $compID : To get the company ID
|
|
* @param number $Comp : To get all the modified information of company
|
|
* @return array $this->db->last_query() : this will return changes in last executed query
|
|
*/
|
|
function Updatecompany($Comp, $CompID)
|
|
{
|
|
$this->db->where('CompID', $CompID);
|
|
$this->db->update('T_Company_Details', $Comp);
|
|
$this->db->last_query();
|
|
return TRUE;
|
|
}
|
|
|
|
/**
|
|
* To Check the company images and files. if exists are not
|
|
* @param number $Pic: To get the images name from the controller
|
|
* @return array $query->result_array() : This is result of the query
|
|
*/
|
|
function checkPhotoExists($Pic)
|
|
{
|
|
$this->db->select('ProfilePic');
|
|
$this->db->from('T_Company_Details');
|
|
$this->db->where($Pic);
|
|
$query = $this->db->get();
|
|
if ($query->num_rows > 0) {
|
|
return $query->result_array();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* To get the Company Information for listing
|
|
* @return array $result : This is result of the query
|
|
*/
|
|
function companylisting()
|
|
{
|
|
$this->db->select('com.*,emp.firstname,pmt.PaymentTerms');
|
|
$this->db->from('T_Company_Details com');
|
|
$this->db->join('T_PaymentTerms pmt','com.paymentID = pmt.PaymentID','left');
|
|
$this->db->join('tbl_users as tbl',' com.createdby = tbl.userid','left');
|
|
$this->db->join('T_Employee_Details as emp', 'emp.empid=tbl.empid','left');
|
|
$query = $this->db->get();
|
|
$result = $query->result();
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* To get the paymentterms information for companydetails
|
|
* @return array $result : This is result of the query
|
|
*/
|
|
function getPaymentTerms()
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('T_PaymentTerms');
|
|
$query = $this->db->get();
|
|
$result = $query->result();
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* To get filedescription information by config value(dropdown for file description)
|
|
* @param number $Configvalue :Optional : To get config value
|
|
* @return $query->result() : This is result of the query (config information)
|
|
*/
|
|
function getfilename($Configvalue = '')
|
|
{
|
|
$ConfigID = 'C025';
|
|
$this->db->select('ConfigValue');
|
|
$this->db->from('T_ConfigDetails');
|
|
$this->db->where('Config_ID ',$ConfigID );
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
|
|
|
|
/**
|
|
* To get bank details for company.
|
|
* @return $result : This is result of the query (bank details)
|
|
*/
|
|
function getBankDetails()
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('T_Bank_Details');
|
|
$query = $this->db->get();
|
|
$result = $query->result();
|
|
return $result;
|
|
}
|
|
|
|
|
|
/**
|
|
* To store and modified bank details for company.
|
|
* @param array $Bank : To get bank details from the controller using array
|
|
* @return array $isExits->result_array() : This is result of the query (bank details)
|
|
*/
|
|
function BankDetails($Bank)
|
|
{
|
|
$bankname=$Bank['Bank_name'];
|
|
$bankifsc=$Bank['IFSC'];
|
|
$count=0;
|
|
|
|
$this->db->select('count(*) as count');
|
|
$this->db->from('T_Bank_Details');
|
|
$this->db->where('Bank_name',$bankname);
|
|
$this->db->where('IFSC',$bankifsc);
|
|
|
|
$isExits = $this->db->get();
|
|
$res = $isExits->result_array();
|
|
|
|
|
|
if(!empty($res))
|
|
{
|
|
|
|
$count = $res[0]['count'];
|
|
}
|
|
|
|
|
|
if($count == 0 )
|
|
{
|
|
$i = $this->db->insert('T_Bank_Details', $Bank);
|
|
return $i;
|
|
|
|
}
|
|
elseif($count == 1)
|
|
{
|
|
$this->db->where('Bank_name',$bankname);
|
|
$this->db->where('IFSC',$bankifsc);
|
|
$i = $this->db->update('T_Bank_Details',$Bank);
|
|
return $i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|