<?php
class Crudd extends CI_Controller{
  function __construct(){
    parent::__construct();
      $this->load->library('datatables'); //load library ignited-dataTable
      $this->load->model('crud_model_stok'); //load model crud_model
  }
  function index(){
      $x['category']=$this->crud_model_stok->get_category();
      $this->load->view('crud_view',$x);
  }

  function get_product_json() { //get product data and encode to be JSON object
      header('Content-Type: application/json');
      echo $this->crud_model_stok->get_all_product();
  }

  function save(){ //insert record method
      $this->crud_model_stok->insert_product();
      redirect('crud');
  }

  function update(){ //update record method
      $this->crud_model_stok->update_product();
      redirect('kantor/tampil_stok');
  }
  function update_satuan(){ //update record method
      $this->crud_model_stok->update_product_satuan();
      redirect('kantor/tampil_stok_satuan');
  }
  function delete(){ //delete record method
      $this->crud_model_stok->delete_product();
      redirect('crud');
  }

}
