diff --git a/composer.json b/composer.json index d94ecbe..78fa48b 100755 --- a/composer.json +++ b/composer.json @@ -5,6 +5,7 @@ "php": "^7.1.3", "ext-ctype": "*", "ext-iconv": "*", + "facebook/webdriver": "^1.7", "sensio/framework-extra-bundle": "^5.1", "symfony/asset": "4.2.*", "symfony/console": "4.2.*", @@ -77,5 +78,8 @@ "allow-contrib": false, "require": "4.2.*" } + }, + "require": { + "ext-curl": "^7.3" } } diff --git a/data/database.sqlite b/data/database.sqlite index 6804099..638496a 100755 Binary files a/data/database.sqlite and b/data/database.sqlite differ diff --git a/src/Controller/ImovelController.php b/src/Controller/ImovelController.php index 5cbf296..647f33f 100644 --- a/src/Controller/ImovelController.php +++ b/src/Controller/ImovelController.php @@ -6,6 +6,7 @@ use App\Entity\Imovel; use App\Forms\ImovelType; +use App\Service\ImovelService; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Routing\Annotation\Route; @@ -19,7 +20,7 @@ class ImovelController extends AbstractController * @param Request $request * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response */ - public function cadastroImovel(Request $request) + public function cadastroImovel(Request $request, ImovelService $imovelService) { $imovel = new Imovel(); @@ -28,9 +29,11 @@ public function cadastroImovel(Request $request) if ($form->isSubmitted()) { $imovel = $form->getData(); - $em = $this->getDoctrine()->getManager(); - $em->persist($imovel); - $em->flush(); + //$em = $this->getDoctrine()->getManager(); + //$em->persist($imovel); + //$em->flush(); + + $imovelService->salvar($imovel); return $this->redirectToRoute('index'); } @@ -41,6 +44,37 @@ public function cadastroImovel(Request $request) } + /** + * @Route("/editar/{id}", name="editar_imovel") + */ + public function editarImovel(int $id, Request $request, ImovelService $imovelService) + { + $imovel = $this->getDoctrine()->getManager()->getRepository(Imovel::class)->find($id); + //$imovel = $em->getRepository(Imovel::class)->find($id); + + if (!$imovel) { + throw new \Exception('Imovel não encontrado'); + } + + $form = $this->createForm(ImovelType::class, $imovel); + $form->handleRequest($request); + + if ($form->isSubmitted()) { + $imovel = $form->getData(); + $imovelService->editar($imovel); + //$em = $this->getDoctrine()->getManager(); + //$em->merge($imovel); + //$em->flush(); + + return $this->redirectToRoute('listar_imoveis'); + } + + return $this->render('imovel_cadastro.html.twig', [ + 'form' => $form->createView() + ]); + } + + /** * @Route("/imovel/listar", name="listar_imoveis") */ @@ -81,6 +115,21 @@ public function imovelVisualizar(Request $request) ]); } + /** + * @Route("/deletar/{id}", name="deletar_imovel") + */ + public function deletarImovel(int $id, Request $request, ImovelService $imovelService) + { + $imovel = $this->getDoctrine()->getManager()->getRepository(Imovel::class)->find($id); + + $imovelService->deletar($imovel); + //$em->remove($imovel); + //$em->flush(); + $this->addFlash('success', 'Imovel de id:'.$id.' deletado com sucesso!!!'); + + return $this->redirectToRoute('listar_imoveis'); + } + } \ No newline at end of file diff --git a/src/Controller/UsuarioController.php b/src/Controller/UsuarioController.php index f1facd9..94edc40 100644 --- a/src/Controller/UsuarioController.php +++ b/src/Controller/UsuarioController.php @@ -6,12 +6,10 @@ use App\Entity\Corretor; use App\Forms\UsuarioType; use App\Entity\Usuario; -use phpDocumentor\Reflection\DocBlock\Tags\Throws; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; -use Symfony\Component\Routing\Annotation\Route; +use App\Service\UsuarioService; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Annotation\Route; /** * Class UsuarioController @@ -21,24 +19,24 @@ class UsuarioController extends AbstractController { /** - *@IsGranted("ROLE_ADMIN") + * @Route("/usuario", name="usuario_novo") */ - public function cadastroUsuario(Request $request) + public function cadastroUsuario(Request $request, UsuarioService $usuarioService) { $usuario = new Usuario(); $form = $this->createForm(UsuarioType::class, $usuario); $form->handleRequest($request); - if ($form->isSubmitted()) { $usuario = $form->getData(); - $em = $this->getDoctrine()->getManager(); - $em->persist($usuario); - $em->flush(); +// $em = $this->getDoctrine()->getManager(); +// $em->persist($usuario); +// $em->flush(); + + $usuarioService->salvar($usuario); return $this->redirectToRoute('index'); } - return $this->render('usuario_cadastro.html.twig', [ 'form' => $form->createView() ]); @@ -71,24 +69,24 @@ public function listarUsuarios(Request $request) /** * @Route("/editar/{id}", name="editar_usuario") */ - public function editarUsuario(int $id, Request $request) + public function editarUsuario(int $id, Request $request, UsuarioService $usuarioService) { - $em = $this->getDoctrine()->getManager(); - $usuario = $em->getRepository(Usuario::class)->find($id); + $usuario = $this->getDoctrine()->getManager()->getRepository(Usuario::class)->find($id); + //$usuario = $em->getRepository(Usuario::class)->find($id); if (!$usuario) { throw new \Exception('Usuario não encontrado'); } $form = $this->createForm(UsuarioType::class, $usuario); - $form->handleRequest($request); if ($form->isSubmitted()) { $usuario = $form->getData(); - $em = $this->getDoctrine()->getManager(); - $em->merge($usuario); - $em->flush(); + $usuarioService->editar($usuario); + //$em = $this->getDoctrine()->getManager(); + //$em->merge($usuario); + //$em->flush(); return $this->redirectToRoute('listar_usuarios'); } @@ -101,12 +99,13 @@ public function editarUsuario(int $id, Request $request) /** * @Route("/deletar/{id}", name="deletar_usuario") */ - public function deletarUsuario(int $id, Request $request) + public function deletarUsuario(int $id, Request $request, UsuarioService $usuarioService) { - $em = $this->getDoctrine()->getManager(); - $usuario = $em->getRepository(Usuario::class)->find($id); - $em->remove($usuario); - $em->flush(); + $usuario = $this->getDoctrine()->getManager()->getRepository(Usuario::class)->find($id); + + $usuarioService->deletar($usuario); + //$em->remove($usuario); + //$em->flush(); $this->addFlash('success', 'Usuario de id:'.$id.' deletado com sucesso!!!'); return $this->redirectToRoute('listar_usuarios'); diff --git a/src/Entity/ContratoAdm.php b/src/Entity/ContratoAdm.php new file mode 100644 index 0000000..c5d56fc --- /dev/null +++ b/src/Entity/ContratoAdm.php @@ -0,0 +1,107 @@ +id; +}/** + * @param mixed $id + */ +public function setId($id): void +{ + $this->id = $id; +}/** + * @return mixed + */ +public function getDtCadastro() +{ + return $this->dt_cadastro; +}/** + * @param mixed $dt_cadastro + */ +public function setDtCadastro($dt_cadastro): void +{ + $this->dt_cadastro = $dt_cadastro; +}/** + * @return mixed + */ +public function getUsuarioId() +{ + return $this->usuario_id; +}/** + * @param mixed $usuario_id + */ +public function setUsuarioId($usuario_id): void +{ + $this->usuario_id = $usuario_id; +}/** + * @return mixed + */ +public function getImovelId() +{ + return $this->imovel_id; +}/** + * @param mixed $imovel_id + */ +public function setImovelId($imovel_id): void +{ + $this->imovel_id = $imovel_id; +}/** + * @return mixed + */ +public function getClausulaContratual() +{ + return $this->clausula_contratual; +}/** + * @param mixed $clausula_contratual + */ +public function setClausulaContratual($clausula_contratual): void +{ + $this->clausula_contratual = $clausula_contratual; +} +} \ No newline at end of file diff --git a/src/Entity/ContratoLocacao.php b/src/Entity/ContratoLocacao.php new file mode 100644 index 0000000..fc30c23 --- /dev/null +++ b/src/Entity/ContratoLocacao.php @@ -0,0 +1,57 @@ +setAction('../usuario') +// ->setAction('../cadastro_imovel') // ->setMethod('POST') ->add('status', ChoiceType::class, [ 'label' => 'Status', diff --git a/src/Repository/ImovelRepository.php b/src/Repository/ImovelRepository.php new file mode 100644 index 0000000..67f535c --- /dev/null +++ b/src/Repository/ImovelRepository.php @@ -0,0 +1,50 @@ +getEntityManager(); + $em->persist($imovel); + $em->flush(); + } + + /** + * @return EntityManager + */ + + public function editar (Imovel $imovel) + { + $em = $this->getEntityManager(); + $em->merge($imovel); + $em->flush(); + } + + /** + * @return EntityManager + */ + + public function deletar(Imovel $imovel) + { + $em = $this->getEntityManager(); + $em->remove($imovel); + $em->flush(); + } +} \ No newline at end of file diff --git a/src/Repository/UsuarioRepository.php b/src/Repository/UsuarioRepository.php new file mode 100644 index 0000000..330b728 --- /dev/null +++ b/src/Repository/UsuarioRepository.php @@ -0,0 +1,51 @@ +getEntityManager(); + $em->persist($usuario); + $em->flush(); + } + + /** + * @return EntityManager + */ + + public function editar (Usuario $usuario) + { + $em = $this->getEntityManager(); + $em->merge($usuario); + $em->flush(); + } + + /** + * @return EntityManager + */ + + public function deletar (Usuario $usuario) + { + $em = $this->getEntityManager(); + $em->remove($usuario); + $em->flush(); + } +} diff --git a/src/Service/ImovelService.php b/src/Service/ImovelService.php new file mode 100644 index 0000000..1e98173 --- /dev/null +++ b/src/Service/ImovelService.php @@ -0,0 +1,35 @@ +imovelRepository = $imovelRepository; + } + + public function salvar(Imovel $imovel) + { + $this->imovelRepository->salvar($imovel); + } + + public function editar (Imovel $imovel) + { + $this->imovelRepository->editar($imovel); + } + + public function deletar (Imovel $imovel) + { + $this->imovelRepository->deletar($imovel); + } +} \ No newline at end of file diff --git a/src/Service/UsuarioService.php b/src/Service/UsuarioService.php new file mode 100644 index 0000000..31ef151 --- /dev/null +++ b/src/Service/UsuarioService.php @@ -0,0 +1,41 @@ +usuarioRepository = $usuarioRepository; + } + + public function salvar(Usuario $usuario) + { + $this->usuarioRepository->salvar($usuario); + } + + public function editar (Usuario $imovel) + { + $this->usuarioRepository->editar($imovel); + } + + public function deletar (Usuario $imovel) + { + $this->usuarioRepository->deletar($imovel); + } + + + + +} \ No newline at end of file diff --git a/templates/listar_imoveis.html.twig b/templates/listar_imoveis.html.twig index 6af1973..3a6b141 100644 --- a/templates/listar_imoveis.html.twig +++ b/templates/listar_imoveis.html.twig @@ -20,6 +20,8 @@ Data Cadastro Bairro Rua + Ações + @@ -31,6 +33,7 @@ Data Cadastro Bairro Rua + Ações @@ -45,9 +48,15 @@ {{ imovel.dtCadastro|date("m/d/Y") }} {{ imovel.endereco.bairro }} {{ imovel.endereco.logradouro }} - + + - + + + + + + {% endfor %}