src/Controller/NavigationController.php line 28
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
use Doctrine\Persistence\ManagerRegistry;
use App\Entity\User;
use App\Entity\UserGroup;
use App\Entity\CompanyType;
use App\Entity\CompanyLead;
use App\Repository\CompanyRepository;
use App\Repository\ContactRepository;
use App\Repository\UserGroupRepository;
use App\Repository\CompanyTypeRepository;
use App\Repository\CompanyLeadRepository;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
class NavigationController extends AbstractController
{
#[Route('/', name: 'dashboard')]
public function index(CompanyRepository $companyRepository, ContactRepository $contactRepository): Response
{
$companies = $companyRepository->findBy(
['userGroup' => $this->getUser()->getUserGroup()],
);
$contacts = $contactRepository->findAll();
return $this->render('dashboard.html.twig', ["companies" => $companies, "contacts" => $contacts]);
}
#[Route('/management', name: 'management')]
public function management(): Response
{
return $this->render('management.html.twig');
}
#[Route('/subscribe', name: 'subscribe')]
public function subscribe(): Response
{
return $this->render('subscribe.html.twig');
}
#[Route('/addUser', name: 'add_user')]
public function addUser(Request $request, UserGroupRepository $userGroupRepository, UserPasswordHasherInterface $hasher, ManagerRegistry $doctrine ): Response
{
$em = $doctrine->getManager();
$user = new User();
if( $request->get('userUserGroupId') ){
$userGroup = $userGroupRepository->find( $request->get('userUserGroupId') );
$user->setUserGroup( $userGroup );
}else{
$user->setUserGroup( $this->getUser()->getUserGroup() );
}
if( $request->get('role') == 1 ){
$user->setRoles([ "MANAGER" ]);
}else{
$user->setRoles([ "USER" ]);
}
$password = $hasher->hashPassword($user, $request->get('password') );
$user->setPassword($password);
$user->setEmail( $request->get('email') );
$existingUser = $em->getRepository(User::class)->findOneBy(['email' => $user->getEmail()]);
if ($existingUser) {
$this->addFlash("warning", "Cet e-mail n'est pas disponible.");
}else{
$em->persist($user);
$em->flush();
}
if ( in_array("ADMIN", $this->getUser()->getRoles() ) ) {
return $this->redirectToRoute('userGroups');
}else{
return $this->redirectToRoute('management');
}
}
#[Route('/userGroups', name: 'userGroups')]
public function userGroups( UserGroupRepository $userGroupRepository ): Response
{
$userGroups = $userGroupRepository->findAll();
return $this->render('userGroups.html.twig', ["userGroups" => $userGroups ]);
}
#[Route('/addUserGroup', name: 'add_userGroup')]
public function addUserGroup(Request $request, ManagerRegistry $doctrine ): Response
{
$userGroup = new UserGroup();
$em = $doctrine->getManager();
$userGroup->setName( $request->get('nameUserGroup') );
$em->persist($userGroup);
$companyLead = new CompanyLead();
$companyLead->setName( "LEAD" );
$companyLead->setUserGroup( $userGroup );
$em->persist($companyLead);
$companyLead = new CompanyLead();
$companyLead->setName( "QUALIF" );
$companyLead->setUserGroup( $userGroup );
$em->persist($companyLead);
$companyType = new CompanyType();
$companyType->setName( "IMMOBILIER" );
$companyType->setUserGroup( $userGroup );
$em->persist($companyType);
$companyType = new CompanyType();
$companyType->setName( "RESTAURANT" );
$companyType->setUserGroup( $userGroup );
$em->persist($companyType);
$em->flush();
return $this->redirectToRoute('userGroups');
}
#[Route('/settings', name: 'settings')]
public function settings( ): Response
{
return $this->render('settings.html.twig');
}
#[Route('/createLines', name: 'createLines')]
public function createLines(): Response
{
$var = "Actimmo Conseil,144 Bis avenue Gén Leclerc,91800,Brunoy,0169438400],[Agence De La Gare,8 rue Gare,91800,Brunoy,0169064707],[Agence Etude de la Poste,6 place Mairie,91800,Brunoy,0169395657],[Agence Guy Hoquet Immobilier,1 place St Médard,91800,Brunoy,0160487909],[AGENCE LANGLOIS-Syndic De Copropriété,79 avenue Gén Leclerc,91800,Brunoy,0169001750],[Agence Mariette,5 place Mairie,91800,Brunoy,0160461047],[Century 21 Ougier,21 rue Gare,91800,Brunoy,0160461031],[Iad France Karine Chabane Mandataire,7 rue Donjon,91800,Brunoy,0170581781],[Immotex,36 Bis rue Vallées,91800,Brunoy,0160470000],[J.P.B,1 4 3 Bis rue Pont Perronet,91800,Brunoy,0169839480],[Laforêt Immobilier,7 place St Médard,91800,Brunoy,0169001925],[L\'Agence du Centre,3 rue Pont Perronet,91800,Brunoy,0160465000],[Orpi Agence De La Mairie,10 place Mairie,91800,Brunoy,0169391515],[Stephane Plaza Immobilier Brunoy,4 rue Pont Perronet,91800,Brunoy,0186909646],[Timpan Gestion,14 rue Donjon,91800,Brunoy,0169430505],[Agence De La Mairie,210 boulevard Henri Barbusse,91210,Draveil,0169401313],[Agence Des Fleurs,214 boulevard Henri Barbusse,91210,Draveil,0169051313],[Ariane Gallet De St Aurin,87 boulevard Henri Barbusse,91210,Draveil,0950359721],[Arthurimmo.com,218 boulevard Henri Barbusse,91210,Draveil,0169569677],[Century 21 Avantage Immo Draveil,150 boulevard Henri Barbusse,91210,Draveil,0169404040],[Era Mainville,3 rue Mainville,91210,Draveil,0169422222],[Foncia Transaction,212 boulevard Henri Barbusse,91210,Draveil,0169037342],[Foncia Val D\'Essonne,5 place République,91210,Draveil,0169037342],[Immobiliere D.A,34 place République,91210,Draveil,0169007642],[L\'Adresse,128 boulevard Gén de Gaulle,91210,Draveil,0169408408],[Laforêt immobilier MCH immo services Franchisé Indépendant,202 boulevard Henri Barbusse,91210,Draveil,0169030000],[O.G.C.M,38 place République,91210,Draveil,0169521900],[Orpi Draveil - Gestion Optimmo,232 boulevard Henri Barbusse,91210,Draveil,0169401212],[RMS Immobilier,214 boulevard Henri Barbusse,91210,Draveil,0169732029],[Stephane Plaza Immobilier,64 boulevard Gén de Gaulle,91210,Draveil,0181860807],[Agence Abp SARL,61 avenue République,91230,Montgeron,0169402058],[Agence Immobiliere Crousse Et Compagnie,100 avenue République,91230,Montgeron,0169033960],[Agence Immobilière Orpi Anma,170 avenue République,91230,Montgeron,0169038775],[Agence Immobilière Renaud Dubuisson,100 avenue République,91230,Montgeron,0169033960],[Ageval Immo,97 Bis avenue République,91230,Montgeron,0169492623],[B . S Immobilier,97 avenue République,91230,Montgeron,0169401818],[Century 21 Bellimmo,91 avenue République,91230,Montgeron,0169832121],[Era Réveil Immo,101 Bis avenue République,91230,Montgeron,0169524580],[Immo Wurtz,95 avenue République,91230,Montgeron,0169406052],[Laforêt AMCT Franchisé indépendant,ENT 2 88 Bis avenue République,91230,Montgeron,0169737373],[Nathalie Roquard,31 avenue République,91230,Montgeron,0169400291],[Stephane Plaza Immobilier Montgeron,93 avenue République,91230,Montgeron,0169035249],[A2C Immo,29 rue Molière,91270,Vigneux sur Seine,0169400316],[Century 21 Optimmo Vigneux,32 avenue Henri Barbusse,91270,Vigneux sur Seine,0169394040],[Keres,57 avenue Paul Vaillant Couturier,91270,Vigneux sur Seine,0169402402],[Laforêt Immobilier,4 place Anatole France,91270,Vigneux sur Seine,0160461841],[Orpi Agence de l\'Hotel de ville,51 1 0 53 avenue Henri Barbusse,91270,Vigneux sur Seine,0169030526],[PRO INVEST,23 rue Fosse Montalbot,91270,Vigneux sur Seine,0169033972],[CENTURY 21 BOISSY GESTION,L\'orangerie 23 rue Cerçay,94440,Villecresnes,0156731100],[Guy Hoquet Villecresnes,76 rue Lieut Dagorno,94440,Villecresnes,0143827969],[La Brie Immobiliere Sarl,1 rue Cerçay,94440,Villecresnes,0145991137],[La Brie Immobilière SARL,41 avenue Mar de Lattre de Tassigny,94440,Villecresnes,0145991137],[Orpi Agence De La Mairie,63 - 65 rue Lieut Dagorno,94440,Villecresnes,0145950006],[Agence Immobiliere Crousse Et Compagnie,1 avenue Fusillés,94190,Villeneuve Saint Georges,0148136926],[Agence Vernay,19 rue Henri Janin,94190,Villeneuve Saint Georges,0143896655],[Carnot Immobilier,4 avenue Carnot,94190,Villeneuve Saint Georges,0143899292],[CBRD investimmo,2 rue Henri Janin,94190,Villeneuve Saint Georges,0143826934],[CECIL IMMO,2 rue Henri Leduc,94190,Villeneuve Saint Georges,0156871555],[Côté Particuliers VSG,27 avenue Carnot,94190,Villeneuve Saint Georges,0156871520],[Etude De La Gare,8 place Pierre Sémard,94190,Villeneuve Saint Georges,0143890004],[Foncia Pasquinelli,12 place Pierre Sémard,94190,Villeneuve Saint Georges,0143825110],[Agence De La Mairie Orpi,67 rue Charles de Gaulle,91330,Yerres,0169498383],[Agence Etude De La Poste,75 rue Charles de Gaulle,91330,Yerres,0169833030],[Bourgeoisat Immobilier,5 rue Charles de Gaulle,91330,Yerres,0169395767],[Contact Immo,64 rue Concy,91330,Yerres,0169523929],[Guy Hoquet L\'immobilier Gerimmobilier Franchisé indépendant,16 rue Charles de Gaulle,91330,Yerres,0169496479],[Immobilier Jean Chapuis,17 rue Marc Sangnier,91330,Yerres,0169409339],[Laforêt AMCT Franchisé indépendant,2 rue Eglise,91330,Yerres,0169520909],[Le Conseil Immobilier,2 rue Clos des Abbesses,91330,Yerres,0169563435],[Yerres Immo,2 rue Pierre de Coubertin,91330,Yerres,0169838883";
$array = explode("],[", $var);
$result = "";
foreach($array as $line){
$client = explode(",", $line);
$result .= "INSERT INTO `company` VALUES (NULL, 1, 1, 1, '$client[0]', '$client[4]', '$client[1]', '$client[2]','$client[3]', '2023-04-05 13:03:51.000000', NULL, NULL, NULL); <br>";
}
return new Response( $result);
}
}