$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";
    $where["operations.salle_id"] = CSQLDataSource::prepareIn($salles_ids);
    $where["sallesbloc.bloc_id"] = "= '{$bloc_id}'";
}
$praticien = new CMediusers();
$praticiens = $praticien->loadPraticiens();
$where["operations.chir_id"] = CSQLDataSource::prepareIn(array_keys($praticiens), $praticien_id);
/** @var COperation[] $operations */
$operations = $operation->loadListWithPerms(PERM_READ, $where, null, null, "operations.operation_id", $ljoin);
$nbIntervHorsPlage = CIntervHorsPlage::countForDates($date_planning, null, array($praticien_id));
$prats = CStoredObject::massLoadFwdRef($operations, "chir_id");
CStoredObject::massLoadFwdRef($prats, "function_id");
CStoredObject::massLoadFwdRef($operations, "plageop_id");
CStoredObject::massLoadFwdRef($operations, "salle_id");
CStoredObject::massLoadFwdRef($operations, "anesth_id");
CStoredObject::massLoadFwdRef($operations, "chir_2_id");
CStoredObject::massLoadFwdRef($operations, "chir_3_id");
CStoredObject::massLoadFwdRef($operations, "chir_4_id");
CStoredObject::massLoadBackRefs($operations, "workflow");
$sejours = CStoredObject::massLoadFwdRef($operations, "sejour_id");
$affectations = CStoredObject::massLoadBackRefs($sejours, "affectations");
CStoredObject::massLoadFwdRef($affectations, "lit_id");
$patients = CStoredObject::massLoadFwdRef($sejours, "patient_id");
$dossiers = CStoredObject::massLoadBackRefs($patients, "dossier_medical");