CAppUI::displayMsg($msg, "{$acte->_class}-msg-create");
        }
        // Actes CsARR
        foreach ($codes_csarrs as $_code) {
            $acte = new CActeCsARR();
            $acte->code = $_code;
            $acte->evenement_ssr_id = $evenement->_id;
            $msg = $acte->store();
            CAppUI::displayMsg($msg, "{$acte->_class}-msg-create");
        }
    }
} else {
    if (count($_days)) {
        $entree = CMbDT::date($sejour->entree);
        $sortie = CMbDT::date($sejour->sortie);
        $bilan = $sejour->loadRefBilanSSR();
        $referent = $bilan->loadRefKineReferent();
        $date = CValue::getOrSession("date", CMbDT::date());
        $monday = CMbDT::date("last monday", CMbDT::date("+1 day", $date));
        foreach ($_days as $_number) {
            $_day = CMbDT::date("+{$_number} DAYS", $monday);
            if (!CMbRange::in($_day, $entree, $sortie)) {
                CAppUI::setMsg("CEvenementSSR-msg-failed-bounds", UI_MSG_WARNING);
                continue;
            }
            if (!$_heure_deb || !$duree) {
                continue;
            }
            $evenement = new CEvenementSSR();
            $evenement->equipement_id = $equipement_id;
            $evenement->debut = "{$_day} {$_heure_deb}";
$sejour_id = CValue::post("sejour_id");
$original_sejour_id = CValue::post("original_sejour_id");
$sejour = new CSejour();
$sejour->load($sejour_id);
// Chargement de la prescription de sejour
$sejour->loadRefPrescriptionSejour();
// Verification que la prescription est vide
if ($sejour->_ref_prescription_sejour->countBackRefs("prescription_line_element")) {
    CAppUI::setMsg("Impossible de dupliquer l'ancien séjour car ce séjour possède déjà une prescription", UI_MSG_WARNING);
    CAppUI::redirect('m=ssr&tab=vw_aed_sejour_ssr&sejour_id=' . $sejour_id);
}
// Chargement du sejour à dupliquer
$original_sejour = new CSejour();
$original_sejour->load($original_sejour_id);
// Chargement des references: bilan, fiche d'autonomie, prescriptions, evenements
$bilan_ssr = $original_sejour->loadRefBilanSSR();
$fiche_autonomie = $original_sejour->loadRefFicheAutonomie();
$prescription_sejour = $original_sejour->loadRefPrescriptionSejour();
$lines_element = $prescription_sejour->loadRefsLinesElement();
// Chargement evenements de la derniere semaine complete
$original_last_friday = CMbDT::date("last friday", CMbDT::date("+ 1 DAY", $original_sejour->sortie));
$monday = CMbDT::date("last monday", $original_last_friday);
$next_monday = CMbDT::date("next monday", $monday);
// 1er vendredi du nouveau sejour
$next_friday = CMbDT::date("next friday", CMbDT::date("- 1 DAY", $sejour->entree));
// Calcul du nombre de decalage entre les 2 sejours
$nb_decalage = CMbDT::daysRelative($original_last_friday, $next_friday);
$evenement_ssr = new CEvenementSSR();
$where = array();
$where["sejour_id"] = " = '{$original_sejour->_id}'";
$where["debut"] = " BETWEEN '{$monday}' AND '{$next_monday}'";