Пример #1
0
 public function addMissionAction(Request $request)
 {
     $em = $this->getDoctrine()->getEntityManager();
     $mission = new Mission();
     $etablissement = $this->getDoctrine()->getRepository('GenericBundle:Etablissement')->find($request->get('_idetab'));
     $mission->setEtablissement($etablissement);
     $mission->setDescriptif($request->get('_Descriptif'));
     $mission->setProfil($request->get('_Profil'));
     $mission->setTypecontrat($request->get('_TypeContrat'));
     $mission->setDomaine($request->get('_Domaine'));
     $date = new \DateTime();
     $mission->setDate($date);
     $mission->setRemuneration($request->get('_Remuneration'));
     $mission->setHoraire($request->get('_Horaire'));
     $mission->setDatedebut(date_create($request->get('_Datedebut')));
     $mission->setDatefin(date_create($request->get('_Datefin')));
     $mission->setNomcontact($request->get('_NomContact'));
     $mission->setPrenomContact($request->get('_PrenomContact'));
     $mission->setFonctionContact($request->get('_FonctionContact'));
     $mission->setTelContact($request->get('_TelContact'));
     $mission->setEmailContact($request->get('_EmailContact'));
     $mission->setIntitule($request->get('_Intitule'));
     $mission->setEmploi($request->get('_Emploi'));
     $em->persist($mission);
     $em->flush();
     $mission->genererCode();
     $em->flush();
     if ($request->get('formation')) {
         $diffuser = new Diffusion();
         $formation = $this->getDoctrine()->getRepository('GenericBundle:Formation')->find($request->get('formation'));
         $diffuser->setFormation($formation);
         $diffuser->setMission($mission);
         $diffuser->setStatut(5);
         $em->persist($diffuser);
         $em->flush();
     }
     return $this->redirect($this->generateUrl('affiche_etab', array('id' => $etablissement->getId())));
 }
Пример #2
0
 private function ImportMissions($uploadedfile)
 {
     $file = new \SplFileObject($uploadedfile);
     $reader = new CsvReader($file);
     $jump = 0;
     $em = $this->getDoctrine()->getEntityManager();
     foreach ($reader as $row) {
         if ($jump++ < 1 || ('' == $row[1] and '' == $row[2] and '' == $row[3] and '' == $row[4])) {
             continue;
         } else {
             $siren = substr(mb_convert_encoding($row[1], 'UTF-8', 'auto'), 0, 9);
             $tier = $em->getRepository('GenericBundle:Tier')->findOneBy(array('siren' => $siren));
             if (!$tier) {
                 $newtier = new Tier();
                 $newtier->setSiren($siren);
                 $newtier->setRaisonsoc(mb_convert_encoding($row[3], 'UTF-8', 'auto'));
                 $newtier->setActivite(mb_convert_encoding($row[4], 'UTF-8', 'auto'));
                 $newtier->setEcole(false);
                 $em->persist($newtier);
                 $em->flush();
                 $tier = $newtier;
             }
             $siege = $em->getRepository('GenericBundle:Etablissement')->findOneBy(array('siret' => mb_convert_encoding($row[1], 'UTF-8', 'auto')));
             if (!$siege) {
                 $newsiege = new Etablissement();
                 $newsiege->setSiret(mb_convert_encoding($row[1], 'UTF-8', 'auto'));
                 $newsiege->setAdresse(mb_convert_encoding($row[5], 'UTF-8', 'auto'));
                 $newsiege->setCodepostal(mb_convert_encoding($row[6], 'UTF-8', 'auto'));
                 $newsiege->setVille(mb_convert_encoding($row[7], 'UTF-8', 'auto'));
                 $newsiege->setTier($tier);
                 $em->persist($newsiege);
                 $em->flush();
                 $siege = $newsiege;
             }
             $etab_mission = $em->getRepository('GenericBundle:Etablissement')->findOneBy(array('siret' => mb_convert_encoding($row[2], 'UTF-8', 'auto')));
             if (!$etab_mission) {
                 $newetab = new Etablissement();
                 $newetab->setSiret(mb_convert_encoding($row[2], 'UTF-8', 'auto'));
                 $newetab->setAdresse(mb_convert_encoding($row[8], 'UTF-8', 'auto'));
                 $newetab->setCodepostal(mb_convert_encoding($row[9], 'UTF-8', 'auto'));
                 $newetab->setVille(mb_convert_encoding($row[10], 'UTF-8', 'auto'));
                 $newetab->setTier($tier);
                 $em->persist($newetab);
                 $em->flush();
                 $etab_mission = $newetab;
             }
             $mission = new Mission();
             $mission->setEtat('À pourvoir');
             $mission->setTypecontrat(mb_convert_encoding($row[16], 'UTF-8', 'auto'));
             $mission->setIntitule(mb_convert_encoding($row[18], 'UTF-8', 'auto'));
             $mission->setDescriptif(mb_convert_encoding($row[19], 'UTF-8', 'auto'));
             $mission->setDomaine(mb_convert_encoding($row[20], 'UTF-8', 'auto'));
             $mission->setNomcontact(mb_convert_encoding($row[11], 'UTF-8', 'auto'));
             $mission->setPrenomcontact(mb_convert_encoding($row[12], 'UTF-8', 'auto'));
             $mission->setFonctioncontact(mb_convert_encoding($row[13], 'UTF-8', 'auto'));
             $mission->setTelcontact(mb_convert_encoding($row[14], 'UTF-8', 'auto'));
             $mission->setEmailcontact(mb_convert_encoding($row[15], 'UTF-8', 'auto'));
             $mission->setEtablissement($etab_mission);
             if (!$row[0] == '' and !mb_convert_encoding($row[0], 'UTF-8', 'auto') == 'jj/mm/aaaa') {
                 $date = date_create_from_format('dd/mm/YYYY', mb_convert_encoding($row[0], 'UTF-8', 'auto'));
                 $mission->setDate($date);
             }
             $em->persist($mission);
             $em->flush();
             if ($row[17] == '') {
                 $mission->genererCode();
             } else {
                 $mission->setCodemission(mb_convert_encoding($row[17], 'UTF-8', 'auto'));
             }
             $em->flush();
             $superadmins = $this->getDoctrine()->getRepository('GenericBundle:User')->findByRole('ROLE_SUPER_ADMIN');
             $usercon = $this->get('security.token_storage')->getToken()->getUser();
             $superadmins = array_merge($superadmins, $this->getDoctrine()->getRepository('GenericBundle:User')->findBy(array('tier' => $usercon->getTier())));
             foreach ($superadmins as $admin) {
                 if (!$this->getDoctrine()->getRepository('GenericBundle:Notification')->findOneBy(array('entite' => $mission->getId(), 'type' => 'Mission', 'user' => $admin))) {
                     $notif = new Notification();
                     $notif->setEntite($mission->getId());
                     $notif->setType('Mission');
                     $notif->setUser($admin);
                     $em->persist($notif);
                     $em->flush();
                 }
             }
         }
     }
 }