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

class Kmpart_m extends CI_Model
{

    public function get($id = null)
    {

        if ($id != null) {
            $this->db->from('tb_katbrg');
            $this->db->order_by('id_katalogbrg', 'asc');
            $this->db->where('id_katalogbrg', $id);
        } elseif (isset($_GET['Cab'])) {
            $cab = $_GET['Cab'];
            $this->db->from('tb_katbrg');
            $this->db->where('id_cabang', $cab);
            $this->db->order_by('id_katalogbrg', 'asc');
        } else {
            $this->db->from('tb_katbrg');
            $this->db->order_by('id_katalogbrg', 'asc');
        }
        $query = $this->db->get();
        return $query;
    }

    public function getpart($id = null)
    {
        $this->db->from('tb_katbrgstok');
        if (isset($_GET['Part'])) {
            $Part = $_GET['Part'];
            $this->db->order_by('id_katbrgstok', 'asc');
            $this->db->where('id_katalogbrg', $Part);
        } else {
            $this->db->where('id_katalogbrg', 00);
        }
        $query = $this->db->get();
        return $query;
    }

    public function editharga($post)
    {
        $params['hargam_brg'] = $post['hargam_brg'];
        $params['persen_brg'] = $post['persen_brg'];
        $params['hargau_brg'] = $post['hargau_brg'];
        $params['hargac_brg'] = $post['hargac_brg'];

        $this->db->where('id_katbrgstok', $post['id_katbrgstok']);
        $this->db->update('tb_katbrgstok', $params);
    }
}
