• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI for Accounting

#10
This is my akun model:

<?php

if (!defined('BASEPATH'))
exit('No direct script access allowed');

class Akun_model extends CI_Model
{

public $table = 'akun';
public $id = 'id';
public $order = 'DESC';

function __construct()
{
parent::__construct();
}

// datatables
function json() {
$this->datatables->select('id,kode_akun,nama_akun,saldo_normal,saldo');
$this->datatables->from('akun');
//add this line for join
//$this->datatables->join('table2', 'akun.field = table2.field');
$this->datatables->add_column('action', anchor(site_url('akun/read/$1'),'<span data-toggle="tooltip" title="Lihat Details" class=\'glyphicon glyphicon-eye-open\' aria-hidden=\'true\'></span>')." | ".anchor(site_url('akun/update/$1'),'<span data-toggle="tooltip" title="Edit Data" class=\'glyphicon glyphicon-edit\' aria-hidden=\'true\'></span>')." | ".anchor(site_url('akun/delete/$1'),'<span data-toggle="tooltip" title="Hapus Data" class=\'glyphicon glyphicon-trash\' aria-hidden=\'true\'></span>','onclick="javasciprt: return confirm(\'Are You Sure ?\')"'), 'id');
return $this->datatables->generate();
}

// get all
function get_all()
{
$this->db->order_by($this->id, $this->order);
return $this->db->get($this->table)->result();
}

// get data by id
function get_by_id($id)
{
$this->db->where($this->id, $id);
return $this->db->get($this->table)->row();
}

// get total rows
function total_rows($q = NULL) {
$this->db->like('id', $q);
$this->db->or_like('kode_akun', $q);
$this->db->or_like('nama_akun', $q);
$this->db->or_like('saldo_normal', $q);
$this->db->or_like('saldo', $q);
$this->db->from($this->table);
return $this->db->count_all_results();
}

// get data with limit and search
function get_limit_data($limit, $start = 0, $q = NULL) {
$this->db->order_by($this->id, $this->order);
$this->db->like('id', $q);
$this->db->or_like('kode_akun', $q);
$this->db->or_like('nama_akun', $q);
$this->db->or_like('saldo_normal', $q);
$this->db->or_like('saldo', $q);
$this->db->limit($limit, $start);
return $this->db->get($this->table)->result();
}

// insert data
function insert($data)
{
$this->db->insert($this->table, $data);
}

// update data
function update($id, $data)
{
$this->db->where($this->id, $id);
$this->db->update($this->table, $data);
}

// delete data
function delete($id)
{
$this->db->where($this->id, $id);
$this->db->delete($this->table);
}

}
Reply


Messages In This Thread
CI for Accounting - by tamam - 09-29-2017, 02:17 AM
RE: CI for Accounting - by rtenny - 09-29-2017, 07:15 AM
RE: CI for Accounting - by tamam - 09-30-2017, 03:50 PM
RE: CI for Accounting - by krystian2160 - 09-30-2017, 01:31 AM
RE: CI for Accounting - by tamam - 09-30-2017, 03:54 PM
RE: CI for Accounting - by PaulD - 10-01-2017, 08:29 AM
RE: CI for Accounting - by tamam - 10-01-2017, 02:44 PM
RE: CI for Accounting - by tamam - 10-01-2017, 02:51 PM
RE: CI for Accounting - by tamam - 10-01-2017, 02:52 PM
RE: CI for Accounting - by tamam - 10-01-2017, 02:53 PM
RE: CI for Accounting - by tamam - 10-01-2017, 02:55 PM
RE: CI for Accounting - by tamam - 10-01-2017, 02:56 PM
RE: CI for Accounting - by tamam - 10-01-2017, 02:57 PM
RE: CI for Accounting - by PaulD - 10-01-2017, 04:44 PM
RE: CI for Accounting - by tamam - 10-01-2017, 06:56 PM
RE: CI for Accounting - by ciadmin - 10-01-2017, 07:00 PM
RE: CI for Accounting - by tamam - 10-01-2017, 09:38 PM
RE: CI for Accounting - by PaulD - 10-02-2017, 10:10 AM
RE: CI for Accounting - by tamam - 10-10-2017, 05:22 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.