<?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) {
		$query = $this->conexion->query("SELECT * FROM se_evenement WHERE start LIKE '$q%' AND status != 'Finalizada'")or die($this->conexion->error);
		if (mysqli_num_rows($query)<=0){
			print '';			
		} else {
			print '<div id="alert4">&nbsp;&nbsp;&nbsp; Ya existen citas para ese día<br/>
			<table class="table table-hover" style="margin-bottom:1px">
					<thead>
					  <tr>
						<th style="padding:2px">Nombre</th>
						<th style="padding:2px">Servicios</th>
						<th style="padding:2px">Estado</th>
					  </tr>
					</thead><tbody>';
			while ($row = mysqli_fetch_assoc($query)) {
				print ' <tr>
						<td style="padding:2px">'.$row['name'].'</td>
						<td style="padding:2px">';
						if($row['SCH'] != ''){ print 'SCH ';};
		                if($row['ST'] != ''){print 'ST ';};
		                if($row['CMF'] != ''){print 'CMF ';};
		                if($row['CEL'] != ''){print 'CEL ';};
		                if($row['CM'] != ''){print 'CM ';};
		                if($row['SEF'] != ''){print 'SEF ';};
		                if($row['SEV'] != ''){print 'SEV ';};
		                if($row['SEH'] != ''){print 'SEH ';};
		                if($row['SETT'] != ''){print 'SETT ';};
		                if($row['SEG'] != ''){print 'SEG ';};
		                if($row['SEP'] != ''){print 'SEP ';};
		                if($row['SEC'] != ''){print 'SEC ';};
		                if($row['SEL'] != ''){print 'SEL ';};
		                if($row['CHC'] != ''){print 'CHC ';};
		                if($row['CMD'] != ''){print 'CMD ';};
		                if($row['CMT'] != ''){print 'CMT ';};
		                if($row['CTO'] != ''){print 'CTO ';};
		                if($row['CAT'] != ''){print 'CAT ';};
		                if($row['CPA'] != ''){print 'CPA ';};
		                if($row['CAF'] != ''){print 'CAF ';};
		                if($row['CMA'] != ''){print 'CMA ';};
		                if($row['LAB'] != ''){print 'LAB ';};
		                if($row['CMG'] != ''){print 'CMG ';};
		                if($row['MG'] != ''){print 'MG ';};
				print'</td>
						<td style="padding:2px">'.$row['status'].'</td>
						<td style="padding:2px"><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>';
		}
			
	}
}
?>