예제 #1
0
 public function tieraddedAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $tier = $em->getRepository('GenericBundle:Tier')->findOneBy(array('siren' => $request->get('_SIREN')));
     if (!$tier) {
         $newtier = new Tier();
         $newtier->setSiren($request->get('_SIREN'));
         $newtier->setRaisonsoc($request->get('_RaisonSoc'));
         $newtier->setEcole(intval($request->get('_Ecole')));
         if ($_FILES && $_FILES['_Logo']['size'] > 0) {
             $newtier->setLogo(file_get_contents($_FILES['_Logo']['tmp_name']));
         }
         if ($_FILES && $_FILES['_image']['size'] > 0) {
             $newtier->setFondecran(file_get_contents($_FILES['_image']['tmp_name']));
         }
         $em->persist($newtier);
         $em->flush();
         $tier = $newtier;
     }
     for ($i = 0; $i < count($request->get('_SIRET')); $i++) {
         $etablissement = new Etablissement();
         $etablissement->setSiret($request->get('_SIRET')[$i]);
         $etablissement->setAdresse($request->get('_Adresse')[$i]);
         $etablissement->setGeocode($request->get('_Geocode')[$i]);
         $etablissement->setCodepostal($request->get('_CodeP')[$i]);
         $etablissement->setTelephone($request->get('_Tel')[$i]);
         $etablissement->setFax($request->get('_Fax')[$i]);
         $etablissement->setVille($request->get('_Ville')[$i]);
         $etablissement->setResponsable($request->get('_Resp')[$i]);
         $etablissement->setTelResponsable($request->get('_TelResp')[$i]);
         $etablissement->setMailResponsable($request->get('_MailResp')[$i]);
         $etablissement->setSite($request->get('_Site')[$i]);
         $etablissement->addUser($this->get('security.token_storage')->getToken()->getUser());
         $etablissement->setTier($tier);
         $em->persist($etablissement);
         $em->flush();
     }
     $em->flush();
     return $this->redirect($_SERVER['HTTP_REFERER']);
 }
예제 #2
0
 public function tieraddedAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $tier = new Tier();
     $tier->setSiren($request->get('_SIREN'));
     $tier->setRaisonsoc($request->get('_RaisonSoc'));
     $tier->setEcole(intval($request->get('_Ecole')));
     if ($_FILES && $_FILES['_Logo']['size'] > 0) {
         $tier->setLogo(file_get_contents($_FILES['_Logo']['tmp_name']));
     }
     if ($_FILES && $_FILES['_image']['size'] > 0) {
         $tier->setFondecran(file_get_contents($_FILES['_image']['tmp_name']));
     }
     $em->persist($tier);
     for ($i = 0; $i < count($request->get('_SIRET')); $i++) {
         $etablissement = new Etablissement();
         $etablissement->setSiret($request->get('_SIRET')[$i]);
         $etablissement->setAdresse($request->get('_Adresse')[$i]);
         $etablissement->setGeocode($request->get('_Geocode')[$i]);
         $etablissement->setCodepostal($request->get('_CodeP')[$i]);
         $etablissement->setTelephone($request->get('_Tel')[$i]);
         $etablissement->setFax($request->get('_Fax')[$i]);
         $etablissement->setVille($request->get('_Ville')[$i]);
         $etablissement->setResponsable($request->get('_Resp')[$i]);
         $etablissement->setTelResponsable($request->get('_TelResp')[$i]);
         $etablissement->setMailResponsable($request->get('_MailResp')[$i]);
         $etablissement->setSite($request->get('_Site')[$i]);
         $etablissement->setTier($tier);
         $em->persist($etablissement);
         $em->flush();
         $admins = $this->getDoctrine()->getRepository('GenericBundle:User')->findByRoles(array('ROLE_SUPER_ADMIN', 'ROLE_ADMINECOLE', 'ROLE_ADMINSOC'));
         foreach ($admins as $admin) {
             $notif = new Notification();
             $notif->setEntite($etablissement->getId());
             if ($etablissement->getTier()->getEcole() && $admin . $this->isGranted('ROLE_ADMINSOC')) {
                 $notif->setType('Ecole');
                 $notif->setUser($admin);
                 $em->persist($notif);
                 $em->flush();
             }
             if (!$etablissement->getTier()->getEcole() && $admin . $this->isGranted('ROLE_ADMINECOLE')) {
                 $notif->setType('Societe');
                 $notif->setUser($admin);
                 $em->persist($notif);
                 $em->flush();
             }
         }
     }
     $em->flush();
     return $this->redirect($this->generateUrl('societe_admin', array('societe' => $this->get('security.token_storage')->getToken()->getUser()->getTier()->getRaisonsoc())));
 }
예제 #3
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();
                 }
             }
         }
     }
 }