$bloc_id = CValue::getOrSession("bloc_id", 0);
$date_suivi = CValue::getOrSession("date_suivi", CMbDT::date());
$listOps = array();
// Liste des services
$service = new CService();
$where = array();
$where["group_id"] = "= '{$group->_id}'";
$where["cancelled"] = "= '0'";
$order = "nom";
$services = $service->loadListWithPerms(PERM_READ, $where, $order);
// Liste des blocs
$bloc = new CBlocOperatoire();
$where = array();
$where["group_id"] = "= '{$group->_id}'";
$order = "nom";
$blocs = $bloc->loadListWithPerms(PERM_READ, $where, $order);
// Listes des interventions
$operation = new COperation();
$ljoin = array("plagesop" => "`operations`.`plageop_id` = `plagesop`.`plageop_id`", "sallesbloc" => "`operations`.`salle_id` = `sallesbloc`.`salle_id`", "sejour" => "`operations`.`sejour_id` = `sejour`.`sejour_id`");
$where = array();
$where[] = "`plagesop`.`date` = '{$date_suivi}' OR `operations`.`date` = '{$date_suivi}'";
if ($bloc_id) {
    $where["sallesbloc.bloc_id"] = "= '{$bloc_id}'";
}
$where["operations.annulee"] = "= '0'";
$where["sejour.group_id"] = "= '{$group->_id}'";
$order = "operations.time_operation";
/** @var COperation[] $listOps */
$listOps = $operation->loadList($where, $order, null, null, $ljoin);
$listServices = array();
// Chargement des infos des interventions
$month_deb = CMbDT::date("-{$rectif} DAYS", $now);
$month_fin = CMbDT::date("+1 month", $month_deb);
$month_fin = CMbDT::date("-1 day", $month_fin);
$next_month_deb = CMbDT::date("+1 day", $month_fin);
$next_month_fin = CMbDT::date("+1 month", $month_fin);
$next_month_fin = CMbDT::date("-1 day", $next_month_fin);
$listPrat = new CMediusers();
$listPrat = $listPrat->loadPraticiens(PERM_READ);
$listSpec = new CFunctions();
$listSpec = $listSpec->loadSpecialites(PERM_READ, 1);
$bloc = new CBlocOperatoire();
$group = CGroups::loadCurrent();
$where = array();
$where["group_id"] = "= '{$group->_id}'";
/** @var CBlocOperatoire[] $listBlocs */
$listBlocs = $bloc->loadListWithPerms(PERM_READ, $where, "nom");
foreach ($listBlocs as &$bloc) {
    $bloc->loadRefsSalles();
}
$praticien = CMediusers::get();
// Création du template
$smarty = new CSmartyDP("modules/dPbloc");
$smarty->assign("praticien", $praticien);
$smarty->assign("chir", $praticien->user_id);
$smarty->assign("filter", $filter);
$smarty->assign("filterSejour", $filterSejour);
$smarty->assign("now", $now);
$smarty->assign("tomorrow", $tomorrow);
$smarty->assign("j2", $j2);
$smarty->assign("j3", $j3);
$smarty->assign("next_week_deb", $next_week_deb);
 /**
  * Load blocs operatoires with given permission
  *
  * @param int    $permType    Permission level
  * @param bool   $load_salles Load salles
  * @param string $order       Ordre de chargmeent SQL
  * @param array  $where       SQL WHERE parameters
  *
  * @return CBlocOperatoire[]
  */
 function loadBlocs($permType = PERM_READ, $load_salles = true, $order = "nom", $where = array())
 {
     $bloc = new CBlocOperatoire();
     $whereGroup = array('group_id' => "= '{$this->_id}'");
     $where = array_merge($where, $whereGroup);
     /** @var CBlocOperatoire[] $blocs */
     $blocs = $bloc->loadListWithPerms($permType, $where, $order);
     if ($load_salles) {
         CStoredObject::massLoadBackRefs($blocs, "salles", "nom");
         foreach ($blocs as $_bloc) {
             $_bloc->loadRefsSalles();
         }
     }
     return $this->_ref_blocs = $blocs;
 }