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

class Kmjasa_m extends CI_Model
{

    public function get($id = null)
    {

        if ($id != null) {
            $this->db->from('tb_katjasa');
            $this->db->order_by('id_katalogjasa', 'desc');
            $this->db->where('id_katalogjasa', $id);
        } elseif (isset($_GET['Jasa'])) {
            $cab = $_GET['Jasa'];
            $this->db->from('tb_katjasa');
            $this->db->where('id_katalogjasa', $cab);
            $this->db->order_by('id_katalogjasa', 'DESC');
        } else {
            $this->db->from('tb_katjasa');
            $this->db->order_by('id_katalogjasa', 'desc');
        }
        $query = $this->db->get();
        return $query;
    }

    public function getjasa($id = null)
    {
        $this->db->from('tb_katjasastok');
        if (isset($_GET['Jasa'])) {
            $Jasa = $_GET['Jasa'];
            $this->db->order_by('id_katjasastok', 'desc');
            $this->db->where('id_katalogjasa', $Jasa);
        } else {
            $this->db->where('id_katalogjasa', 00);
        }
        $query = $this->db->get();
        return $query;
    }

    public function editharga($post)
    {
        $params['nama_jasa'] = $post['nama_jasa'];
        $params['jasaperbaikan'] = $post['jasaperbaikan'];
        $params['hargam_jasa'] = $post['hargam_jasa'];
        $params['hargac_jasa'] = $post['hargac_jasa'];
        $params['datetime'] = $post['datetime'];
        $this->db->where('id_katjasastok', $post['id_katjasastok']);
        $this->db->update('tb_katjasastok', $params);
    }
}
