118 lines
4.7 KiB
PHP
118 lines
4.7 KiB
PHP
<?php
|
|
class M_masteruser extends CI_Model {
|
|
function index() {
|
|
$this->db->select('user.*,tipeuser.Nama_TipeUser');
|
|
$this->db->from('user')->join('tipeuser', 'user.FK_TipeUser = tipeuser.ID_TipeUser', 'left');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
|
|
function insert() {
|
|
$insert_masteruser = array(
|
|
'FK_TipeUser' => $this->input->post('tipeuser'),
|
|
'NamaUser_User' => $this->input->post('namauser'),
|
|
'Password_User' => "simkoprasiBMB",
|
|
'NamaLengkap_User' => $this->input->post('namalengkapuser'),
|
|
'Telepon_User' => $this->input->post('teleponuser'),
|
|
'Email_User' => $this->input->post('emailuser'),
|
|
'TanggalLahir_User' => $this->input->post('tanggallahiruser'),
|
|
'TempatLahir_User' => $this->input->post('tempatlahiruser'),
|
|
'Alamat_User' => $this->input->post('alamatuser'),
|
|
'JenisKelamin_User' => $this->input->post('jeniskelaminuser'),
|
|
'Agama_User' => $this->input->post('agamauser'),
|
|
'TanggalBuat_User' => date('Y-m-d H:i:s'),
|
|
'TanggalEdit_User' => date('Y-m-d H:i:s'),
|
|
'Provinsi_ID' => $this->input->post('provinsi'),
|
|
'Kabupaten_ID' => $this->input->post('kabupaten'),
|
|
'Kecamatan_ID' => $this->input->post('kecamatan'),
|
|
'Desa_ID' => $this->input->post('desa'),
|
|
|
|
);
|
|
|
|
$insert = $this->db->insert('user', $insert_masteruser);
|
|
return $insert;
|
|
}
|
|
|
|
function edit($id) {
|
|
$this->db->where('ID_User', $id);
|
|
$query = $this->db->get('user');
|
|
return $query;
|
|
}
|
|
|
|
function prosesedit() {
|
|
$update_masteruser = array(
|
|
'FK_TipeUser' => $this->input->post('tipeuser'),
|
|
'NamaUser_User' => $this->input->post('namauser'),
|
|
//'Password_User' => $this->input->post('passworduser'),
|
|
'NamaLengkap_User' => $this->input->post('namalengkapuser'),
|
|
'Telepon_User' => $this->input->post('teleponuser'),
|
|
'Email_User' => $this->input->post('emailuser'),
|
|
'TanggalLahir_User' => $this->input->post('tanggallahiruser'),
|
|
'TempatLahir_User' => $this->input->post('tempatlahiruser'),
|
|
'Alamat_User' => $this->input->post('alamatuser'),
|
|
'JenisKelamin_User' => $this->input->post('jeniskelaminuser'),
|
|
'Agama_User' => $this->input->post('agamauser'),
|
|
'TanggalEdit_User' => date('Y-m-d H:i:s'),
|
|
'Provinsi_ID' => $this->input->post('provinsi'),
|
|
'Kabupaten_ID' => $this->input->post('kabupaten'),
|
|
'Kecamatan_ID' => $this->input->post('kecamatan'),
|
|
'Desa_ID' => $this->input->post('desa'),
|
|
);
|
|
$id = $this->input->post('id');
|
|
$this->db->where('ID_User', $id);
|
|
$this->db->update('user', $update_masteruser);
|
|
}
|
|
|
|
function view($id) {
|
|
$this->db->where('ID_User', $id);
|
|
$query = $this->db->get('user');
|
|
return $query;
|
|
}
|
|
|
|
function delete($id) {
|
|
$this->db->where('ID_User', $id);
|
|
$this->db->delete('user');
|
|
}
|
|
|
|
function editfoto() {
|
|
$config = array(
|
|
'upload_path' => "./img/",
|
|
'allowed_types' => "jpg|jpeg",
|
|
'overwrite' => TRUE,
|
|
'max_size' => "2048000", // Can be set to particular file size , here it is 2 MB(2048 Kb)
|
|
'max_height' => "768",
|
|
'max_width' => "1024"
|
|
);
|
|
$this->load->library('upload', $config);
|
|
$upload_data = $this->upload->data();
|
|
$file_name = $upload_data['file_name'];
|
|
|
|
$update_user = array(
|
|
'Foto_User' => $file_name,
|
|
'TanggalEdit_User' => date('Y-m-d H:i:s'),
|
|
);
|
|
$id = $this->session->userdata('s_ID_User');
|
|
$this->db->where('ID_User', $id);
|
|
$this->db->update('user', $update_user);
|
|
}
|
|
|
|
function resetpass($id) {
|
|
$update_user = array(
|
|
'Password_User' => "simkoprasiBMB",
|
|
'TanggalEdit_User' => date('Y-m-d H:i:s'),
|
|
);
|
|
$this->db->where('ID_User', $id);
|
|
$this->db->update('user', $update_user);
|
|
}
|
|
|
|
function editpass($id) {
|
|
$update_user = array(
|
|
'Password_User' => $this->input->post('renewpass'),
|
|
'TanggalEdit_User' => date('Y-m-d H:i:s'),
|
|
);
|
|
$this->db->where('ID_User', $id);
|
|
$this->db->update('user', $update_user);
|
|
}
|
|
|
|
}
|
|
?>
|