/** @var CBlocOperatoire[] $blocs */
$blocs = $bloc->loadList($where);
CStoredObject::filterByPerm($blocs, PERM_READ);
if (count($blocs) == 1) {
    $current_bloc = reset($blocs);
}
// optimisation du chargement des salles (one shot) + alertes
$salle = new CSalle();
$ds = $salle->getDS();
$where = array();
$where["bloc_id"] = $ds->prepareIn(array_keys($blocs));
$ljoin["bloc_operatoire"] = "bloc_operatoire.bloc_operatoire_id = sallesbloc.bloc_id";
$order = "bloc_operatoire.nom, sallesbloc.nom";
$salles = $salle->loadList($where, $order, null, null, $ljoin);
$salles_ids = array_keys($salles);
$nbAlertesInterv = CBlocOperatoire::countAlertesIntervsForSalles(array_keys($salles));
foreach ($blocs as $_bloc) {
    $_bloc->canDo();
}
// Récupération des opérations
$operation = new COperation();
$where = array();
$ljoin = array();
$where["operations.date"] = "= '{$date_planning}'";
if (!$show_cancelled) {
    $where["operations.annulee"] = " != '1'";
}
//$where["operations.plageop_id"] = "IS NULL";
if ($bloc_id) {
    $ljoin["sallesbloc"] = "sallesbloc.salle_id = operations.salle_id";
    $ljoin["bloc_operatoire"] = "bloc_operatoire.bloc_operatoire_id = sallesbloc.bloc_id";