<?php
class M_sertifikat extends CI_Model{

function simpan_ubah($id_tamu,$id_acara)
	{
		
		$nip=$this->input->post('nip');
		$nip_nospasi = str_replace(' ', '', $nip); 
		
		{
			$data = array(
            'nama'   						=>$this->input->post('nama'),
			'nip'   						=>$nip_nospasi,
			'unit_kerja'   					=>$this->input->post('unit_kerja'),
			'jabatan'   					=>$this->input->post('jabatan'),
			'kategori'   					=>$this->input->post('kategori'),
			'judul'   						=>$this->input->post('judul'),
			'no_hp'   						=>$this->input->post('no_hp'),
			'email'   						=>$this->input->post('email'),
			'sts_sertifikat'   				=>$this->input->post('sts_sertifikat')
			);
		}
		$this->db->where('id_tamu',$id_tamu);
		$this->db->where('id_acara',$id_acara);
        $this->db->update('tbl_registrasi',$data);
	}
	
	function simpan_ubah_file($id_tamu,$id_acara,$userfile)
	{
		
		$nip=$this->input->post('nip');
		$nip_nospasi = str_replace(' ', '', $nip); 
		
		{
			$data = array(
            'nama'   						=>$this->input->post('nama'),
			'nip'   						=>$nip_nospasi,
			'unit_kerja'   					=>$this->input->post('unit_kerja'),
			'jabatan'   					=>$this->input->post('jabatan'),
			'kategori'   					=>$this->input->post('kategori'),
			'judul'   						=>$this->input->post('judul'),
			'no_hp'   						=>$this->input->post('no_hp'),
			'email'   						=>$this->input->post('email'),
			'sts_sertifikat'   				=>$this->input->post('sts_sertifikat'),
			'nama_file'						=>$userfile
			);
		}
		$this->db->where('id_tamu',$id_tamu);
		$this->db->where('id_acara',$id_acara);
        $this->db->update('tbl_registrasi',$data);
	}
	
	function hapus_peserta($id_acara,$id_tamu)
	{
		$this->db->where('id_acara', $id_acara);
		$this->db->where('id_tamu', $id_tamu);
		$this->db->delete('tbl_registrasi');
		
	}

	function cari()
	{   
		$cari = $this->input->post ('cari');
		$id_acara = $this->input->post ('id_acara');
		
		$this->db->select('*');
		$this->db->where('id_acara',$id_acara);
		$this->db->where('tbl_registrasi.sts',1);
		
		$this->db->like('nama',$cari);
		$this->db->or_like('NIP',$cari);
		$this->db->or_like('unit_kerja',$cari);
		$this->db->or_like('no_hp',$cari);
		$this->db->or_like('email',$cari);
		$query = $this->db->get('tbl_registrasi');
		
		return $query->result();
		
		
	}
	
}