Skip to content
Snippets Groups Projects
Commit a9eeb823 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix browser notif

parent 60951cf3
No related branches found
No related tags found
No related merge requests found
......@@ -144,7 +144,7 @@ print '<input type="hidden" name="action" value="save">';
$head=agenda_prepare_head();
dol_fiche_head($head, 'autoactions', $langs->trans("Agenda"), 0, 'action');
dol_fiche_head($head, 'autoactions', $langs->trans("Agenda"), -1, 'action');
print $langs->trans("AgendaAutoActionDesc")."<br>\n";
print $langs->trans("OnlyActiveElementsAreShown").'<br>';
......
......@@ -75,7 +75,7 @@ print "<br>\n";
$head=agenda_prepare_head();
dol_fiche_head($head, 'attributes', $langs->trans("Agenda"), 0, 'action');
dol_fiche_head($head, 'attributes', $langs->trans("Agenda"), -1, 'action');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
......
......@@ -137,7 +137,7 @@ print '<input type="hidden" name="action" value="save">';
$head=agenda_prepare_head();
dol_fiche_head($head, 'extsites', $langs->trans("Agenda"), 0, 'action');
dol_fiche_head($head, 'extsites', $langs->trans("Agenda"), -1, 'action');
print $langs->trans("AgendaExtSitesDesc")."<br>\n";
print "<br>\n";
......
......@@ -196,7 +196,7 @@ print "<br>\n";
$head=agenda_prepare_head();
dol_fiche_head($head, 'other', $langs->trans("Agenda"), 0, 'action');
dol_fiche_head($head, 'other', $langs->trans("Agenda"), -1, 'action');
/*
......
......@@ -83,7 +83,7 @@ print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$head=agenda_prepare_head();
dol_fiche_head($head, 'xcal', $langs->trans("Agenda"), 0, 'action');
dol_fiche_head($head, 'xcal', $langs->trans("Agenda"), -1, 'action');
print $langs->trans("AgendaSetupOtherDesc")."<br>\n";
print "<br>\n";
......
......@@ -21,7 +21,6 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
require '../../main.inc.php';
......@@ -88,9 +87,11 @@ if ($time >= $_SESSION['auto_check_events_not_before'])
while ($obj = $db->fetch_object($resql))
{
$langs->load("agenda");
$langs->load("commercial");
$actionmod->fetch($obj->id);
// Message must be formated and translated to be used with javascript directly
$event = array();
$event['type'] = 'agenda';
$event['id'] = $actionmod->id;
......@@ -101,6 +102,10 @@ if ($time >= $_SESSION['auto_check_events_not_before'])
$eventfound[] = $event;
}
}
else
{
dol_syslog("Error sql = ".$db->lasterror(), LOG_ERR);
}
}
......
......@@ -65,7 +65,7 @@ if (! ($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/' || $_SERVER['H
// We set a delay before launching first test so next check will arrive after the time_auto_update compared to previous one.
var time_first_execution = (time_auto_update - (nowtime - time_js_next_test)) * 1000; //need milliseconds
if (login != '') {
console.log("Launch browser notif check: setTimeout to wait time_first_execution="+time_first_execution+" before first check - nowtime = "+nowtime+" auto_check_events_not_before = "+auto_check_events_not_before+" time_js_next_test = "+time_js_next_test+" time_auto_update="+time_auto_update);
console.log("Launch browser notif check: setTimeout is set to launch 'first_execution' function after a wait of time_first_execution="+time_first_execution+". nowtime (time php page generation) = "+nowtime+" auto_check_events_not_before (val in session)= "+auto_check_events_not_before+" time_js_next_test (max now,auto_check_events_not_before) = "+time_js_next_test+" time_auto_update="+time_auto_update);
setTimeout(first_execution, time_first_execution);
} //first run auto check
......@@ -79,17 +79,18 @@ if (! ($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/' || $_SERVER['H
function check_events() {
if (Notification.permission === "granted")
{
console.log("Call check_events time_js_next_test="+time_js_next_test);
$.ajax("<?php print dol_buildpath('/core/ajax/check_notifications.php', 1); ?>", {
type: "post", // Usually post o get
console.log("Call check_events time_js_next_test = date we are looking for event after ="+time_js_next_test);
$.ajax("<?php print DOL_URL_ROOT.'/core/ajax/check_notifications.php'; ?>", {
type: "post", // Usually post or get
async: true,
data: {time: time_js_next_test},
success: function (result) {
var arr = JSON.parse(result);
if (arr.length > 0) {
var audio = null;
<?php
if (! empty($conf->global->AGENDA_NOTIFICATION_SOUND)) {
print 'var audio = new Audio(\''.DOL_URL_ROOT.'/theme/common/sound/notification_agenda.wav'.'\');';
print 'audio = new Audio(\''.DOL_URL_ROOT.'/theme/common/sound/notification_agenda.wav'.'\');';
}
?>
......@@ -136,6 +137,7 @@ if (! ($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/' || $_SERVER['H
}
time_js_next_test += time_auto_update;
console.log('Updated time_js_next_test. New value is '+time_js_next_test);
}
<?php
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment