I have a help desk which I want when I send a "ticket" I get a notification in the browser, but I have not found something to do it I have tried it with push.js but I can not even install it income if they need it where you enter the ticket thanks
<?php
include('is_logged.php');//Archivo verifica que el usario que intenta acceder a la URL esta logueado
// checking for minimum PHP version
if (version_compare(PHP_VERSION, '5.3.7', '<')) {
exit("Sorry, Simple PHP Login does not run on a PHP version smaller than 5.3.7 !");
} else if (version_compare(PHP_VERSION, '5.5.0', '<')) {
// if you are using PHP 5.3 or PHP 5.4 you have to include the password_api_compatibility_library.php
// (this library adds the PHP 5.5 password hashing functions to older versions of PHP)
}
if (empty($_POST['incidencia'])){
$errors[] = "Por favor seleccione una incidencia";
} elseif (empty($_POST['tema'])){
$errors[] = "Tema vacío";
} elseif (empty($_POST['detalle'])) {
$errors[] = "detalle vacío";
} elseif (empty($_FILES['imagen']['name'])) {
$errors[] = "imagen vacía";
} elseif (
!empty($_POST['incidencia'])
&& !empty($_POST['tema'])
&& !empty($_POST['detalle'])
&& !empty($_FILES['imagen'])
) {
require_once ("../config/db.php");
require_once ("../config/conexion.php");
$incidencia = mysqli_real_escape_string($con,(strip_tags($_POST["incidencia"],ENT_QUOTES)));
$tema = mysqli_real_escape_string($con,(strip_tags($_POST["tema"],ENT_QUOTES)));
$detalle = mysqli_real_escape_string($con,(strip_tags($_POST["detalle"],ENT_QUOTES)));
$imagen = ($_FILES['imagen']);
$firstname = mysqli_real_escape_string($con,(strip_tags($_POST["firstname"],ENT_QUOTES)));
$sql = "SELECT * FROM ticket WHERE incidencia = '" . $incidencia . "' OR tema = '" . $tema . "';";
$query_check_incidencia = mysqli_query($con,$sql);
$sql = "INSERT INTO ticket (incidencia, tema, detalle, firstname, imagen)
VALUES('".$incidencia."','".$tema."','" . $detalle . "','".$_SESSION['firstname']."','" . $_FILES['imagen']['name'] . "');";
$query_new_incidencia_insert = mysqli_query($con,$sql);
$imagen = $_FILES['imagen']['name'];
$ruta_tmp = $_FILES['imagen']['tmp_name'];
$ruta_final = '../img/' . $imagen;
if (!file_exists($ruta_final)) {
move_uploaded_file($ruta_tmp, $ruta_final);
}
}
else {
$errors[] = "Un error desconocido ocurrió.";
}
if (isset($errors)){
?>
<div class="alert alert-danger" role="alert">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Error!</strong>
<?php
foreach ($errors as $error) {
echo $error;
}
?>
</div>
<?php
}
if (isset($messages)){
?>
<div class="alert alert-success" role="alert">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>¡Bien hecho!</strong>
<?php
foreach ($messages as $message) {
echo $message;
}
?>
</div>
<?php
}
?>
PS: it's done in ajax
code attempt
<script type="text/javascript" src="push.js-master/src/push/Push.js">
</script>
<script>
Push.create("Hello world!", {
body: "How's it hangin'?",
icon: '/icon.png',
timeout: 4000,
onClick: function () {
window.focus();
this.close();
}
});
</script>