<?php
require('../45789417/ref4780.php');
date_default_timezone_set('America/Bogota');
class Buscador {
	var $host=DB_SERVER,$user=DB_USER,$pass=DB_PASS,$db=DB_NAME,$c_Servidor='Se conecto con el servidor correctamente',$i_Servidor='No se conecto con el Servidor',$c_DB='Se selecciono correctamente la DB',$i_DB='No se selecciono la DB';
	public function Conectar() {	
    		$this->conexion = new mysqli($this->host, $this->user, $this->pass,$this->db) or die(mysql_error());
      		$this->conexion->set_charset("utf8");
	}
	public function Buscar($q) {
  		$monthx = date('Y');
  /*		$query = $this->conexion->query('SELECT id, name, title, start, status FROM se_evenement WHERE start LIKE "%'.$monthx.'%"  AND name LIKE "%'.$q.'%" or title LIKE "%'.$q.'%" ORDER BY id DESC') or die ($this->conexion->error); */
  		$query = $this->conexion->query('SELECT id, name, title, start, status FROM se_evenement WHERE  name LIKE "%'.$q.'%" or title LIKE "%'.$q.'%" ORDER BY id DESC') or die ($this->conexion->error);		
		if (mysqli_num_rows($query)<=0){
			print '<div id="alert3" style="margin-right:10px"><a HREF="javascript:history.go(0)"><span style="color: black;" class="glyphicon glyphicon-remove-circle"></span> </a>No se encontro ningun resultado para el año actual</div>';			
		} else {
			print '<div id="alert3">
			<div align="right">
			<a HREF="javascript:history.go(0)"><span style="color: black;" class="glyphicon glyphicon-remove-circle"></span></a>
			</div><table class="table table-hover">
					<thead>
					  <tr>
						<th>Nombre</th>
						<th>Cedula</th>
						<th>Fecha</th>
						<th>Estado</th>
					  </tr>
					</thead><tbody>';
			while ($row = mysqli_fetch_assoc($query)) {
				print ' <tr>
						<td>'.$row['name'].'</td>
						<td>'.$row['title'].'</td>
						<td>'.$row['start'].'</td>
						<td>'.$row['status'].'</td>
						<td><a class="btn btn-default btn-xs" href="view_event.php?id='.$row['id'].'"><span class="glyphicon glyphicon-search"> Ver</span></td>
					  </tr>';
			}
			print '</tbody></table></div>';
			
		}
			
	}
}
?>