ria/application/models/cashbook_model.php
2017-12-21 19:36:31 +05:30

134 lines
3.6 KiB
PHP
Executable File

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class cashbook_model extends CI_Model
{
/**
* To get Account Type
* @return array $r->result() : result of the query (returns active account code)
*/
function getAccounTypes()
{
$this->db->where('status',1);
$r = $this->db->get('t_accountcode');
return $r->result();
}
/**
* To get Account status
* @param number $data : This will have all the income and expense information.
* @return array $r : This will return how many value are inserted (return as number/count)
*/
function saveIncomeExpense($data)
{
$this->db->insert('t_income_expense',$data);
$r = $this->db->affected_rows();
return $r;
}
/**
* To get Income and expense List
* @param number $i : Optional : This is incomeandexpense's id
* @return array $r->result() : result of the query (returns account information)
*/
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();
}
/**
* To get Company details
* @return array $r->result() : result of the query (returns company information)
*/
function getCompany()
{
$r = $this->db->get('T_Company_Details');
return $r->result();
}
/**
* To get Account Information
* @param number $i
* @return array $r->result() : result of the query (returns account name and incomeandexpense information)
*/
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');
$r = $this->db->get();
return $r->result();
}
/**
* To get Account Information
* @return array $result : result of the query (returns account information)
*/
function Selectcash()
{
$this->db->select('*');
$this->db->from('t_accountcode');
$query = $this->db->get();
$result = $query->result();
return $result;
}
/**
* To store cashbook Information (its insertion and updation operation)
* @param array $cashbookdatas : this will have all cashbook details
* @var number $res : gets count
* @return array $cbi : result of the query (for insertion)
* @return array $cbu : result of the query (for updation)
*/
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;
}
}
}
?>