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

class Inventory_Types_model extends CI_Model
{
    private $_table = "inventory_types";


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

    public function jumlah_type()
    {
        $query =  $this->db->query(" SELECT COUNT(inventory_types_id) AS JumlahType FROM inventory_types where inventory_types_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->inventory_types_nama = $post["inventory_types_nama"];
        $this->inventory_types_description = $post["inventory_types_description"];
        $this->inventory_types_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);
    }
}
