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

class Mekanikid_m extends CI_Model
{

    public function get($id = null)
    {

        if ($id != null) {
            $this->db->from('tb_user');
            $this->db->order_by('id_user', 'desc');
            $this->db->where('id_user', $id);
        } else {
            $this->db->from('tb_user');
            $this->db->order_by('id_user', 'desc');
        }
        $query = $this->db->get();
        return $query;
    }


    public function addmekanik($post)
    {
        $params['no_ktp'] = $post['no_ktp'];
        $params['nama'] = $post['nama'];
        $params['no_hp'] = $post['no_hp'];
        $params['alamat'] = $post['alamat'];
        $params['email'] = $post['email'];
        $params['sosial_media'] = $post['sosial_media'];
        $params['foto'] = $post['foto'];
        $params['pekerjaan'] = $post['pekerjaan'];
        $params['gaji'] = $post['gaji'];
        $params['nama_bank'] = $post['nama_bank'];
        $params['norek'] = $post['norek'];
        $params['injob'] = $post['injob'];
        $params['karyawan'] = $post['karyawan'];
        $params['is_active'] = 1;
        $params['status_cabang'] = 1;


        $this->db->insert('tb_user', $params);
    }

    public function editmekanik($post)
    {
        $params['no_ktp'] = $post['no_ktp'];
        $params['nama'] = $post['nama'];
        $params['no_hp'] = $post['no_hp'];
        $params['alamat'] = $post['alamat'];
        $params['email'] = $post['email'];
        $params['sosial_media'] = $post['sosial_media'];
        $params['pekerjaan'] = $post['pekerjaan'];
        $params['gaji'] = $post['gaji'];
        if ($post['foto'] != null) {
            $params['foto'] = $post['foto'];
        }
        $params['nama_bank'] = $post['nama_bank'];
        $params['norek'] = $post['norek'];
        $params['injob'] = $post['injob'];
        $params['karyawan'] = $post['karyawan'];


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

    public function editkeahlian($post)
    {
        $params['mmetik'] = $post['mmetik'];
        $params['mbebek'] = $post['mbebek'];
        $params['msport'] = $post['msport'];
        $params['mmodifikasi'] = $post['mmodifikasi'];

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

    public function editpribadi($post)
    {
        $params['kebkerja'] = $post['kebkerja'];
        $params['teamkerja'] = $post['teamkerja'];
        $params['konkerja'] = $post['konkerja'];

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

    public function delmekanikid($id)
    {
        $this->db->where('id_user', $id);
        $this->db->delete('tb_user');
    }
}
