$affectations_enfant = $affectation->loadBackRefs("affectations_enfant");
    foreach ($affectations_enfant as $_affectation_enfant) {
        /** @var CAffectation $_affectation_enfant */
        if (CMbDT::addDateTime("00:{$tolerance}:00", $_affectation_enfant->entree) > $_date_cut) {
            $_affectation = $_affectation_enfant;
        } else {
            $_affectation = new CAffectation();
            $_affectation->entree = $_date_cut;
            $_affectation->sejour_id = $_affectation_enfant->sejour_id;
            $_affectation->sortie = $_affectation_enfant->sortie;
            $_affectation->uf_hebergement_id = $_affectation_enfant->uf_hebergement_id;
            $_affectation->uf_medicale_id = $_affectation_enfant->uf_medicale_id;
            $_affectation->uf_soins_id = $_affectation_enfant->uf_soins_id;
            $_affectation_enfant->sortie = $_date_cut;
        }
        $_affectation->lit_id = $lit_id ? $lit_id : $_affectation_enfant->lit_id;
        $_affectation->parent_affectation_id = $affectation_cut->_id;
        if ($msg = $_affectation_enfant->store()) {
            CAppUI::setMsg($msg, UI_MSG_ERROR);
        }
        if ($msg = $_affectation->store()) {
            CAppUI::setMsg($msg, UI_MSG_ERROR);
        }
    }
}
if ($callback) {
    $fields = $affectation_cut->getProperties();
    CAppUI::callbackAjax($callback, $affectation_cut->_id, $fields);
}
echo CAppUI::getMsg();
CApp::rip();