<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Datacek extends CI_Controller {

	function __construct(){
		parent::__construct();
			$this->load->library('session');
			$this->load->library('form_validation');
			$this->load->model('m_home');
			$this->load->model('m_datacek');
			if($this->session->userdata('username') =='' OR $this->session->userdata('token') !=md5('100%Madiun'.date('Ymd')) ){
				redirect(base_url("login"));
			}			
	}
	public function index()
	{	
	$data['alert']='';
	$data['pesan']='';
	$data['pesanok'] = $this->m_datacek->datapesan();	
	$data['pesandetail'] = $this->m_datacek->pesandetail();	
	$this->load->view('admin/datacek', $data);			
	}
	
	function hapuspesan1(){
	$idpesan=$this->security->xss_clean($this->input->post('idpesan'));
	//delete
	$where = array(
	'idpesan' => $idpesan
	);
	$this->m_home->hapus($where,'pesan');	
	$data['alert']='';
	$data['pesan']='';
	$data['pesanok'] = $this->m_datacek->datapesan();	
	$data['pesandetail'] = $this->m_datacek->pesandetail();	
	$this->load->view('admin/datacek', $data);				
	}	

	function hapuspesan2(){
	$idpesandetail =$this->security->xss_clean($this->input->post('idpesandetail'));
	//delete
	$where = array(
	'idpesandetail ' => $idpesandetail 
	);
	$this->m_home->hapus($where,'pesandetail');	
	$data['alert']='';
	$data['pesan']='';
	$data['pesanok'] = $this->m_datacek->datapesan();	
	$data['pesandetail'] = $this->m_datacek->pesandetail();	
	$this->load->view('admin/datacek', $data);				
	}
	
	

	function psok(){
	$namafield =$this->security->xss_clean($this->input->post('namafield'));
	$kondisi =$this->security->xss_clean($this->input->post('kondisi'));
	//delete
	$where = array(
	'namapemakai' => 'Sdwq'
	);
	$this->m_home->hapus($where,'pesan');	
	$data['alert']='';
	$data['pesan']='';
	$data['pesanok'] = $this->m_datacek->datapesan();	
	$data['pesandetail'] = $this->m_datacek->pesandetail();	
	$this->load->view('admin/datacek', $data);				
	}
	
	function pesanhapus1(){
	$namafield =$this->security->xss_clean($this->input->post('namafield'));
	$kondisi =$this->security->xss_clean($this->input->post('kondisi'));
	//delete
	$where = array(
	$namafield => $kondisi
	);
	$this->m_home->hapus($where,'pesan');	
	$data['alert']='';
	$data['pesan']='';
	$data['pesanok'] = $this->m_datacek->datapesan();	
	$data['pesandetail'] = $this->m_datacek->pesandetail();	
	$this->load->view('admin/datacek', $data);				
	}
	
	function pesanhapus2(){
	$namafield =$this->security->xss_clean($this->input->post('namafield'));
	$kondisi =$this->security->xss_clean($this->input->post('kondisi'));
	//delete
	$where = array(
	$namafield => $kondisi
	);
	$this->m_home->hapus($where,'pesandetail');	
	$data['alert']='';
	$data['pesan']='';
	$data['pesanok'] = $this->m_datacek->datapesan();	
	$data['pesandetail'] = $this->m_datacek->pesandetail();	
	$this->load->view('admin/datacek', $data);				
	}
	
}
