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

class Divisi_Categories_model extends CI_Model 
{
    private $_table = "divisi_categories";


    function getAll(){
        $query = $this->db->query("SELECT * from divisi_categories where divisi_categories_status=1");
        return $query->result();
    }
   

    public function jumlah_type()
    {
        $query =  $this->db->query(" SELECT COUNT(divisi_categories_id) AS JumlahType FROM divisi_categories where divisi_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->crew_id = $post["crew_id"];
        $this->divisi_categories_nama = $post["divisi_categories_nama"];
        $this->divisi_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);
    }
}
