104 lines
2.4 KiB
PHP
Executable File
104 lines
2.4 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 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;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|