Ajout du système de popup sur reception d'un SMS
This commit is contained in:
parent
0b2fe3c989
commit
90e761e152
|
@ -0,0 +1 @@
|
||||||
|
0612423997:salut
|
|
@ -51,4 +51,12 @@
|
||||||
{
|
{
|
||||||
$this->render('internalIncs/footer');
|
$this->render('internalIncs/footer');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cette fonction retourne une page js avec des constantes php sous forme js
|
||||||
|
*/
|
||||||
|
public function phptojs()
|
||||||
|
{
|
||||||
|
$this->render('internalIncs/phptojs');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,4 +47,28 @@
|
||||||
'nbResults' => count($receiveds),
|
'nbResults' => count($receiveds),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cette fonction retourne tous les SMS reçus aujourd'hui pour la popup
|
||||||
|
* @return json : Un tableau des sms
|
||||||
|
*/
|
||||||
|
public function popup ()
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
$now = new DateTime();
|
||||||
|
$receiveds = $db->getReceivedsSince($now->format('Y-m-d'));
|
||||||
|
|
||||||
|
$nbReceiveds = count($receiveds);
|
||||||
|
|
||||||
|
if (!isset($_SESSION['popup_nb_receiveds']) || ($_SESSION['popup_nb_receiveds'] > $nbReceiveds))
|
||||||
|
{
|
||||||
|
$_SESSION['popup_nb_receiveds'] = $nbReceiveds;
|
||||||
|
}
|
||||||
|
|
||||||
|
$newlyReceiveds = array_slice($receiveds, $_SESSION['popup_nb_receiveds']);
|
||||||
|
|
||||||
|
echo json_encode($newlyReceiveds);
|
||||||
|
$_SESSION['popup_nb_receiveds'] = $nbReceiveds;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,19 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/** POPUPS ALERT **/
|
/** POPUPS ALERT **/
|
||||||
.popup-alert
|
.popup-alerts-container
|
||||||
{
|
{
|
||||||
position: fixed;
|
position: fixed;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
z-index: 9999;
|
z-index: 9998;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-alert
|
||||||
|
{
|
||||||
|
width: 50%;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** FOOTER **/
|
/** FOOTER **/
|
||||||
|
|
21
js/custom.js
21
js/custom.js
|
@ -17,5 +17,24 @@ function showMessage(message, type)
|
||||||
}
|
}
|
||||||
|
|
||||||
var alerthtml = '<div class="col-xs-10 col-xs-offset-1 col-md-6 col-md-offset-3 popup-alert alert ' + type + '"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>' + message + '</div>';
|
var alerthtml = '<div class="col-xs-10 col-xs-offset-1 col-md-6 col-md-offset-3 popup-alert alert ' + type + '"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>' + message + '</div>';
|
||||||
jQuery('body').prepend(alerthtml);
|
jQuery('body .popup-alerts-container').prepend(alerthtml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cette fonction vérifie si un message a été reçu
|
||||||
|
*/
|
||||||
|
function verifReceived()
|
||||||
|
{
|
||||||
|
jQuery('.popup-alert').fadeOut('slow');
|
||||||
|
jQuery.getJSON(HTTP_PWD + "/receiveds/popup", function( data ) {
|
||||||
|
$.each(data, function(key, val) {
|
||||||
|
showMessage('SMS reçu du ' + val.send_by.replace(/</g, "<").replace(/>/g, ">") + ' : ' + val.content.replace(/</g, "<").replace(/>/g, ">"), 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
jQuery(document).ready(function()
|
||||||
|
{
|
||||||
|
var verifReceivedInterval = setInterval(verifReceived, 10000);
|
||||||
|
});
|
||||||
|
|
|
@ -95,6 +95,26 @@
|
||||||
return $this->runQuery($query, $params);
|
return $this->runQuery($query, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Récupère les SMS reçus depuis une date
|
||||||
|
* @param $date : La date depuis laquelle on veux les SMS (au format 2014-10-25 20:10:05)
|
||||||
|
* @return array : Tableau avec tous les SMS depuis la date
|
||||||
|
*/
|
||||||
|
public function getReceivedsSince($date)
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
SELECT *
|
||||||
|
FROM receiveds
|
||||||
|
WHERE at > STR_TO_DATE(:date, '%Y-%m-%d %h:%i:%s')
|
||||||
|
";
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
'date' => $date,
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->runQuery($query, $params);
|
||||||
|
}
|
||||||
|
|
||||||
/********************************/
|
/********************************/
|
||||||
/* PARTIE DES REQUETES CONTACTS */
|
/* PARTIE DES REQUETES CONTACTS */
|
||||||
/********************************/
|
/********************************/
|
||||||
|
|
|
@ -15,6 +15,10 @@
|
||||||
<link href="<?php echo HTTP_PWD; ?>font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
|
<link href="<?php echo HTTP_PWD; ?>font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
|
||||||
<!-- Custom CSS site -->
|
<!-- Custom CSS site -->
|
||||||
<link href="<?php echo HTTP_PWD; ?>css/style.css" rel="stylesheet">
|
<link href="<?php echo HTTP_PWD; ?>css/style.css" rel="stylesheet">
|
||||||
|
<?php
|
||||||
|
$incs = new internalIncs();
|
||||||
|
$incs->phptojs();
|
||||||
|
?>
|
||||||
<script src="<?php echo HTTP_PWD; ?>js/jquery.js"></script>
|
<script src="<?php echo HTTP_PWD; ?>js/jquery.js"></script>
|
||||||
<script src="<?php echo HTTP_PWD; ?>js/bootstrap.min.js"></script>
|
<script src="<?php echo HTTP_PWD; ?>js/bootstrap.min.js"></script>
|
||||||
<script src="<?php echo HTTP_PWD; ?>js/plugins/morris/raphael.min.js"></script>
|
<script src="<?php echo HTTP_PWD; ?>js/plugins/morris/raphael.min.js"></script>
|
||||||
|
@ -58,3 +62,4 @@
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div class="popup-alerts-container"></div>
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
<script>
|
||||||
|
var HTTP_PWD = '<?php echo addslashes(HTTP_PWD); ?>';
|
||||||
|
</script>
|
Loading…
Reference in New Issue