$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(); } // Récupération des opérations $operation = new COperation(); $where = array(); $ljoin = array(); $where["operations.date"] = "= '{$date_planning}'";
/** * Mine or remine the first availables salles * * @param int $limit * @param string $phase * * @return array Success/failure counts report */ function mineSome($limit = 100, $phase = "mine") { $date = CMbDT::date(); $report = array("success" => 0, "failure" => 0); $salle = new CSalle(); $ds = $salle->getDS(); $min_date = self::getMinDate(); $phases = array("mine" => array("mined", "remined", "postmined"), "remine" => array("remined", "postmined"), "postmine" => array("postmined")); $ref_dates = array("mine" => CMbDT::date(self::$mine_delay), "remine" => CMbDT::date(self::$remine_delay), "postmine" => CMbDT::date(self::$postmine_delay)); $sql = "SELECT sallesbloc.salle_id, MAX(date) as date FROM sallesbloc\n LEFT JOIN salle_daily_occupation ON salle_daily_occupation.salle_id = sallesbloc.salle_id\n WHERE (salle_daily_occupation.status " . $ds->prepareIn($phases[$phase]) . " OR salle_daily_occupation.status IS NULL)\n GROUP BY salle_id\n "; if (!($result = $ds->loadList($sql))) { return; } // cleanup foreach ($result as &$_result) { if (!$_result["date"]) { $_result["date"] = $min_date; } } // iteration $i = $limit; while ($i--) { // sort array_multisort(CMbArray::pluck($result, "date"), SORT_ASC, $result); // first $result[0]["date"] = CMbDT::date("+1 DAY", $result[0]["date"]); if ($result[0]["date"] > $ref_dates[$phase]) { break; } $this->mine($result[0]["salle_id"], $result[0]["date"]); if ($msg = $this->store()) { $report["failure"]++; } else { $report["success"]++; } } return $report; }