} $document = $documents[0]; if ($document == null) { echo "Erreur enregistrement de compte rendu : document non trouvé."; die; } $document->setTitre(corriger_caracteres($doc_name_modif)); $document->save(); } //traitement de la copie de fichier joint if (isset($_REQUEST['ct_a_importer_class']) && isset($_REQUEST['id_ct_a_importer'])) { $classname = $_REQUEST["ct_a_importer_class"] . 'Query'; if (class_exists($classname)) { $notice = call_user_func($classname . '::create')->findOneByPrimaryKey($_REQUEST["id_ct_a_importer"]); if ($notice != null && $ctCompteRendu != null && $notice != $ctCompteRendu) { //pour la dernière condition, on évite de copier les fichiers joints d'une notice sur elle même $method = 'get' . $_REQUEST["ct_a_importer_class"] . 'FichierJoints'; foreach ($notice->{$method}() as $fichier_joint_modele) { $fj = new CahierTexteCompteRenduFichierJoint(); $fj->setEmplacement($fichier_joint_modele->getEmplacement()); $fj->setTitre($fichier_joint_modele->getTitre()); $fj->setTaille($fichier_joint_modele->getTaille()); $fj->save(); $ctCompteRendu->addCahierTexteCompteRenduFichierJoint($fj); } $ctCompteRendu->save(); } } } echo $ctCompteRendu->getIdCt(); $utilisateur->clearAllReferences();