<?php
class Xpl_model extends CI_Model{
	public function __construct(){
		parent::__construct();
	}

	public function listar($texto=""){
		$query = "
			SELECT
				personal.pers_id,
				personal.pers_apenombres,
				personal.pers_usuario,
				personal.pers_clave
			FROM
				personal
			WHERE personal.pers_estado = 0 AND CONCAT(personal.pers_apenombres, personal.pers_usuario) LIKE '%{$texto}%' {$qwhere}
		";
		return $this->db->query($query);
	}

	public function validar($usuario){
		$this->db->select('personal.*')->from('personal');
		$this->db->where('personal.pers_usuario',$usuario);
		$this->db->where('personal.pers_estado', 0);
		$query = $this->db->get();
		return $query->row();
	}

	public function validar_usuario($usuario='',$clave=''){
		$this->db->select('*')->from('personal');
		$this->db->where('pers_usuario',$usuario);
		if($clave!=''){
			$this->db->where('pers_clave',$clave);
		}
		$this->db->where('personal.pers_estado', 0);
		$query = $this->db->get();
		return $query->row();
	}

	public function ver($id=""){
		$this->db->select('*');
		$this->db->from('personal');
		$this->db->where('personal.pers_id',$id);
		$query = $this->db->get();
		return $query->row();
	}

	public function insertar($data){
		$this->db->insert('personal',$data);
		return $this->db->insert_id();
	}

	public function editar($id,$data){
		$this->db->where('pers_id',$id);
		$this->db->update('personal',$data);
	}
}