示例#1
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())));
 }
示例#2
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']);
 }