<?php
require_once('../../Connections/odonto_connection1.php');
//$q = intval($_GET['q']);
session_start();
$msj_orig = $_GET['msj'];
$info_orig = $_GET['info'];
$codigo = $_GET['codigo'];
$negocio = $_GET['negocio'];

$con = mysqli_connect($hostname_odonto_connection,$username_odonto_connection,$password_odonto_connection,$database_odonto_connection);
if (!$con) {die('Could not connect: ' . mysqli_error($con));}

$sql="SELECT mensaje FROM mesas WHERE codigo = '".$codigo."' AND mensaje != '' AND ver LIKE 'si' LIMIT 1";
$rs_ingreso = mysqli_query($con,$sql);
$row_rs_ingreso = mysqli_fetch_assoc($rs_ingreso);
//$cant_actual = mysqli_num_rows($rs_ingreso);
$msj_actual = $row_rs_ingreso['mensaje'];

$sql="SELECT informacion FROM informaciones WHERE negocio = '".$negocio."' AND informacion != '' AND ver LIKE 'si' LIMIT 1";
$rs_ingreso_info = mysqli_query($con,$sql);
$row_rs_ingreso_info = mysqli_fetch_assoc($rs_ingreso_info);
$info_actual = $row_rs_ingreso_info['informacion'];

if($info_actual != $info_orig || $msj_actual != $msj_orig) {
	echo "---";
	die();
}

$cuenta=$_SESSION['cuenta'];

if($cuenta == 1) {
	$envelope = "fas fa-envelope-open-text";
	$pointer = "fas fa-hand-point-right";
	$color_letra = "#FFF";
	$color_fondo = "#000";
	$cuenta = 0;
}
else {
	$envelope = "fas fa-envelope-open";
	$pointer = "far fa-hand-point-right";
	$color_letra = "#000";
	$color_fondo = "#FFF";
	$cuenta += 1;
}

$_SESSION['cuenta'] = $cuenta;

if($info_orig) echo "<div style='color:$color_letra;background-color:$color_fondo;font-size:1.3rem'><i class='$pointer'></i> ".$info_orig."</div><br>";//invertimos los colores
if($msj_orig) echo "<div style='color:$color_fondo;background-color:$color_letra;font-size:1.3rem'><i class='$envelope'></i> ".$msj_orig."</div>";

//$dif = $row_cnt - $cantidad_original;
//echo "<font style='color:white'>cant original ".$cant_original."</font><br>";
//echo "<font style='color:white'><br>cant actual ".$cant_actual."</font><br>";
//echo "<font style='color:white'>".$r."</font><br>";
//echo "<font style='color:white'>".$dif."</font><br>";
mysqli_close($con);
?>
