<?php

include ('../../inc/confNetisse.php');

$profilesJoin = ($GLOBALS["BO_CONF"]["CONSEILLER"]["multiple_profiles"])?'LEFT JOIN ca_conseiller_agence ca ON ca.id_conseiller = c.id_conseiller':'';
$lastActiveColumn = ($GLOBALS["BO_CONF"]["MOBILITY"])?", last_active":"";
$lastActiveSecColumn = ($GLOBALS["BO_CONF"]["MOBILITY"])?", TIME_TO_SEC(TIMEDIFF(now(),last_active)) last_active_sec":"";
$whereActivity = ($GLOBALS["BO_CONF"]["MOBILITY"])?' AND TIME_TO_SEC(TIMEDIFF(now(),last_active))<300':'';
$q = '
	SELECT count(c.id_conseiller) nb
	FROM ca_conseillers c
	'.$profilsJoin.'
	WHERE (c.id_agence= :id_agence1 OR ca.id_agence = :id_agence2)
		AND c.receive_notifications=1 AND c.supp=0 '.$whereActivity.' AND photo != "../photos/incognito.jpg"';
$values = array(':id_agence1' => intval($_REQUEST['id_agence']), ':id_agence2' => intval($_REQUEST['id_agence']));
$result = excuteQuery($qy, $values);
$r = $result['stmt'];
if ($r) {
	$o = $r->fetchObject();
	echo $o->nb;
}
else{
	echo "0";
}

?>