<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Atk_Categories_model extends CI_Model{

    private $table = "atk_Categories";

    public function get_all(){
    return $this->db->get('Atk_Categories_model')->result();
    }

 public function getAll(){
        return $this->db
                    ->where('Atk_categories_status', 1)
                    ->get($this->table )
                    ->result();
    }


    public function jumlah_type()
    {
        $query =  $this->db->query(" SELECT COUNT(Atk_Categories_id) AS JumlahType FROM Atk_Categories where Atk_Categories_status = '1'");
        return $query->result();
      
    }
   
  
    public function save()
    {
        date_default_timezone_set("Asia/Jakarta");
        $tanggal = date("Y-m-d H:i:s");

        $post = $this->input->post();
       
        $this->atk_categories_nama = $post["atk_categories_nama"];
        $this->atk_categories_status = "1";
        $this->created_at =  $tanggal;
        $this->created_by = $post["created_by"];  
        return $this->db->insert($this->table, $this);
    }
    public function view_update($where, $table){
        return $this->db->get_where($table, $where);
    }

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

    public function delete($where, $table){
        $this->db->where($where);
        $this->db->delete($table);
    }
}
