*/ CCanDo::checkRead(); $praticien_id = CValue::getOrSession("praticien_id"); $function_id = CValue::getOrSession("function_id"); $filter = new COperation(); $filter->_date_min = CValue::getOrSession("_date_min", CMbDT::date("-7 day")); $filter->_date_max = CValue::getOrSession("_date_max", CMbDT::date()); $blocs = CGroups::loadCurrent()->loadBlocs(PERM_READ, null, "nom"); $bloc_id = CValue::getOrSession("bloc_id", reset($blocs)->_id); $bloc = new CBlocOperatoire(); $bloc->load($bloc_id); // Récupération des opérations $ljoin = array(); $ljoin["plagesop"] = "operations.plageop_id = plagesop.plageop_id"; $salles = $bloc->loadRefsSalles(); CStoredObject::filterByPerm($salles, PERM_READ); $in_salles = CSQLDataSource::prepareIn(array_keys($salles)); $where = array(); $where[] = "plagesop.salle_id {$in_salles} OR operations.salle_id {$in_salles}"; $where["materiel"] = "!= ''"; $where["operations.date"] = "BETWEEN '{$filter->_date_min}' AND '{$filter->_date_max}'"; if ($praticien_id) { $where["operations.chir_id"] = " = '{$praticien_id}'"; } elseif ($function_id) { $mediuser = new CMediusers(); $users = $mediuser->loadProfessionnelDeSante(PERM_READ, $function_id); $where["operations.chir_id"] = CSQLDataSource::prepareIn(array_keys($users)); } $order = "operations.date, rank"; $operation = new COperation(); $ops = $operation->loadList($where, $order, null, null, $ljoin);
} CValue::setSession("date_planning", $date_planning); //alerts $nbIntervHorsPlage = 0; $nbIntervNonPlacees = 0; $nbAlertesInterv = 0; $debut = $fin = $date_planning; $bloc = new CBlocOperatoire(); $where = array(); if ($bloc_id) { $where["bloc_operatoire_id"] = " = '{$bloc_id}'"; } $where["group_id"] = " = '{$group->_id}' "; /** @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();