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

class Uom_Categories_model extends CI_Model
{
    private $_table = "uom_categories";


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

    public function jumlah_type()
    {
        $query =  $this->db->query(" SELECT COUNT(uom_categories_id) AS JumlahType FROM uom_categories where uom_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->uom_categories_nama = $post["uom_categories_nama"];
        $this->uom_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);
    }
}
