136 lines
3.2 KiB
PHP
Executable File
136 lines
3.2 KiB
PHP
Executable File
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class cashbook_model extends CI_Model
|
|
{
|
|
|
|
function getAccounTypes()
|
|
{
|
|
$this->db->where('status',1);
|
|
$r = $this->db->get('t_accountcode');
|
|
return $r->result();
|
|
|
|
}
|
|
|
|
function saveIncomeExpense($data)
|
|
{
|
|
$this->db->insert('t_income_expense',$data);
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
|
|
function getIncomeExpenseList($i="")
|
|
{
|
|
$this->db->select('t_accountcode.name,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*');
|
|
$this->db->from('t_income_expense');
|
|
$this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code');
|
|
$this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId');
|
|
$this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID');
|
|
|
|
if(!empty($i))
|
|
{
|
|
$this->db->where('t_income_expense.id',$i);
|
|
}
|
|
$r = $this->db->get();
|
|
return $r->result();
|
|
}
|
|
|
|
function getCompany()
|
|
{
|
|
$r = $this->db->get('T_Company_Details');
|
|
return $r->result();
|
|
|
|
|
|
}
|
|
|
|
function getAccounutInfo($i)
|
|
{
|
|
$this->db->select('t_accountcode.name,t_income_expense.*');
|
|
$this->db->from('t_income_expense');
|
|
$this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code');
|
|
//$this->db->where('t_income_expense.id')
|
|
$r = $this->db->get();
|
|
return $r->result();
|
|
|
|
}
|
|
|
|
function Selectcash()
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('t_accountcode');
|
|
$query = $this->db->get();
|
|
$result = $query->result();
|
|
return $result;
|
|
|
|
}
|
|
function viewdepartment($sid='')
|
|
{
|
|
$sql="SELECT ie.*,ac.name,date_format(ie.date,'%d-%m-%Y')as date FROM t_income_expense ie
|
|
join t_accountcode ac on ac.code=ie.account_code
|
|
WHERE ie.id = ?";
|
|
$query = $this->db->query($sql,array($sid));
|
|
//print_r($this->db->last_query());
|
|
//echo $sql;
|
|
return $query->result();
|
|
}
|
|
function deletefile($cashid)
|
|
{
|
|
|
|
//echo $cashid;
|
|
$sql="UPDATE t_income_expense SET document = NULL
|
|
WHERE id = ?";
|
|
$query = $this->db->query($sql,array($cashid));
|
|
//print_r($this->db->last_query());
|
|
//echo $sql;
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
|
|
|
|
function updatedepartment($updateaccount,$id1)
|
|
{
|
|
$this->db->where('id', $id1);
|
|
$this->db->update('t_income_expense',$updateaccount);
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
|
|
}
|
|
|
|
function Cashbook($cashbookdatas)
|
|
{
|
|
$code=$cashbookdatas['code'];
|
|
$type=$cashbookdatas['type'];
|
|
|
|
$count=0;
|
|
|
|
$this->db->select('count(*) as count');
|
|
$this->db->from('t_accountcode');
|
|
$this->db->where('type',$type);
|
|
$this->db->where('code',$code);
|
|
|
|
$isExits = $this->db->get();
|
|
$res = $isExits->result_array();
|
|
|
|
|
|
if(!empty($res))
|
|
{
|
|
$count = $res[0]['count'];
|
|
}
|
|
|
|
|
|
if($count == 0 )//for cashbook_insert
|
|
{
|
|
$cbi = $this->db->insert('t_accountcode', $cashbookdatas);
|
|
return $cbi;
|
|
}
|
|
elseif($count == 1)//for cashbook_update
|
|
{
|
|
$this->db->where('code',$code);
|
|
$cbu = $this->db->update('t_accountcode',$cashbookdatas);
|
|
return $cbu;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|