<?php	require_once('../preheader1.php'); // <-- this include file MUST go first before any HTML/output
$user=$_SESSION['MM_Username'];
if(!isset($user)) header("Location:" . "../../index.php?deslogeo");
require_once('../../Connections/odonto_connection1.php'); 

$query_rs_todos = "SELECT negocio,categ FROM `ingreso` WHERE user LIKE '$user'";
$rs_ingreso0 = mysqli_query($odonto_connection,$query_rs_todos) or die(mysqli_error());
$row_rs_ingreso0 = mysqli_fetch_assoc($rs_ingreso0);
$categ=$row_rs_ingreso0['categ'];
$negocio=$row_rs_ingreso0['negocio'];

if(isset($_GET['id_avi'])){$id_avi=$_GET['id_avi'];
$query_rs_todos = "UPDATE `avisos` SET `avisado` = '1' WHERE `avisos`.`id_avi` = $id_avi";
$rs_ingreso2 = mysqli_query($odonto_connection,$query_rs_todos) or die(mysqli_error());
}

$query_rs_todos = "SELECT * FROM `clientes`";
$rs_ingreso = mysqli_query($odonto_connection,$query_rs_todos) or die(mysqli_error());
$row_rs_ingreso = mysqli_fetch_assoc($rs_ingreso);

$hora=$row_rs_ingreso['hora'];


	#the code for the class
	include ('../ajaxCRUD.class.php'); // <-- this include file MUST go first before any HTML/output

    #this one line of code is how you implement the class
    ########################################################
    
		
$tabla2 = new ajaxCRUD("AVISOS", "avisos", "id_avi", "../");
	$tabla2->omitPrimaryKey();
	$tabla2->displayAs("aviso", "Aviso");
	$tabla2->displayAs("descrip", "Descripcion");
	$tabla2->displayAs("hora_avisado", "Hora Atendido");
	$tabla2->displayAs("mozo", "Zona");
	//$tabla2->omitField("cod_pre");
	$tabla2->omitField("negocio");
	$tabla2->omitField("sucursal");
	$tabla2->omitField("latitud");
	$tabla2->omitField("longitud");
	$tabla2->omitField("puntaje");
	$tabla2->omitField("avisado");
	$tabla2->omitField("limpiado");
	$tabla2->omitField("codigo");
	$tabla2->omitField("id_delivery");
	//$tabla2->disableTableHeaders();
	$tabla2->emptyTableMessage = "nada para mostrar";
	$tabla2-> addWhereClause("WHERE (negocio = '$negocio')");
	//$tabla2->turnOffAjaxEditing();
	//$tabla2->addButtonToRow("OK", "index_precios.php?veamos", "id_pre");
	$tabla2->addOrderBy("ORDER BY id_avi DESC");
	$tabla2->disallowDelete();
	$tabla2->setLimit(200);
	$tabla2->disallowAdd();
	//$tabla2->disallowEdit('menu'); 
	//$tabla2->disallowEdit('precio'); 
	$tabla2->turnOffAjaxEditing();
	$tabla2->setCSSFile('greysuit.css');
	
	$tabla2->formatFieldWithFunction('hora', 'format_fecha');

	function format_fecha($data){
		$trozos0 = explode (" ", $data);
		$vemos0=array();
		$vemos0[0] = $trozos0[0];
		$segundos = $trozos0[1];
		
		$trozos = explode ("-", $vemos0[0]);
		$vemos=array();
		$vemos['0']=$trozos['2'];
		$vemos['1']=$trozos['1'];
		$vemos['2']=$trozos['0'];
		$data_c = implode('-', $vemos);
		return $data_c." ".$segundos;
	}	


?>
<!DOCTYPE HTML>
<html>
<head>
<!--<meta http-equiv="refresh" content="7" charset="UTF-8"> -->
<meta charset="UTF-8">
<title>PonderZone</title>
<link rel="icon" href="../../pondercode.jpg">

	<link rel="stylesheet" href="../../alertify/themes/alertify.core.css" />
	<link rel="stylesheet" href="../../alertify/themes/alertify.default.css" id="toggleCSS" />

<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0" />

<?php require_once('../../inc/bootstrap.php');?>

</head>
<body style="background-color:#0D1749" />	
	<?php	 require_once('menu.php');
	?>
	<br>
	<?php
			 require_once('botones.php');
	?>
		<!-- <div class="row" ><b>
<span style="border-image: initial; border: 2px solid white;">MESAS Y MOZOS</span>
</b><p>
		</div> -->

	<div class="container-fluid text-center">
		<div class="row">
			<div class="col">
				<h3>Historial de los avisos de los clientes</h3>
				
			</div>
		</div>
		<div class="row">
			<div class="col">
			<?php $tabla2->showTable();?>
			</div>
		</div>
	</div>
