src/Controller/AccueilController.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use App\Entity\Expertise;
  7. use App\Form\ExpertiseType;
  8. use Symfony\Component\HttpFoundation\Request;
  9. class AccueilController extends AbstractController
  10. {
  11. /**
  12. * @Route("/", name="accueil")
  13. */
  14. public function index(Request $request): Response
  15. {
  16. // just setup a fresh $task object (remove the example data)
  17. $expertise = new Expertise();
  18. $form = $this->createForm(ExpertiseType::class, $expertise);
  19. $form->handleRequest($request);
  20. if ($form->isSubmitted() && $form->isValid()) {
  21. // $form->getData() holds the submitted values
  22. // but, the original `$task` variable has also been updated
  23. $expertise = $form->getData();
  24. $revenuLocatif = $expertise->getRevenuLocatif();
  25. $tauxImposition = $expertise->getTauxImposition();
  26. $type = $expertise->getType();
  27. $baseTaxable1 = $revenuLocatif * 0.5;
  28. $baseTaxable2 = $revenuLocatif * 0.7;
  29. if ($type == "France")
  30. {
  31. $csg1 = $baseTaxable1 * 0.186;
  32. $csg2 = $baseTaxable2 * 0.186;
  33. $economie1an = $csg2 - $csg1;
  34. $economie5an = $economie1an * 5;
  35. //dd($csg2);
  36. if ($tauxImposition != 0)
  37. {
  38. $ir1 = $baseTaxable1 * ($tauxImposition/100);
  39. $ir2 = $baseTaxable2 * ($tauxImposition/100);
  40. $economie1anIr = $ir2 - $ir1;
  41. $resultat1an = $economie1anIr + $economie1an;
  42. $resultat5an = $resultat1an * 5;
  43. }else{
  44. $resultat1an = $csg2 - $csg1;
  45. $ir1 = 0;
  46. }
  47. return $this->render('accueil/resultat.html.twig', [
  48. 'resultat1an' => $resultat1an,
  49. 'revenuLocatif' => $revenuLocatif,
  50. 'tauxImposition' => $tauxImposition,
  51. 'csg1' => $csg1,
  52. 'ir1' => $ir1,
  53. 'type' => $type,
  54. ]);
  55. }else{
  56. $csg1 = $baseTaxable1 * 0.075;
  57. $csg2 = $baseTaxable2 * 0.075;
  58. $economie1an = $csg2 - $csg1;
  59. $economie5an = $economie1an * 5;
  60. if ($tauxImposition != 0)
  61. {
  62. $ir1 = $baseTaxable1 * (20/100);
  63. $ir2 = $baseTaxable2 * (20/100);
  64. $economie1anIr = $ir2 - $ir1;
  65. $resultat1an = $economie1anIr + $economie1an;
  66. $resultat5an = $resultat1an * 5;
  67. }else{
  68. $resultat1an = $csg2 - $csg1;
  69. $ir1 = 0;
  70. }
  71. return $this->render('accueil/resultat.html.twig', [
  72. 'resultat1an' => $resultat1an,
  73. 'revenuLocatif' => $revenuLocatif,
  74. 'tauxImposition' => 20,
  75. 'csg1' => $csg1,
  76. 'ir1' => $ir1,
  77. 'type' => $type,
  78. ]);
  79. }
  80. //dd($resultat2an);
  81. // ... perform some action, such as saving the task to the database
  82. // for example, if Task is a Doctrine entity, save it!
  83. // $entityManager = $this->getDoctrine()->getManager();
  84. // $entityManager->persist($task);
  85. // $entityManager->flush();
  86. //return $this->redirectToRoute('task_success');
  87. }
  88. return $this->render('accueil/index.html.twig', [
  89. 'form' => $form->createView(),
  90. ]);
  91. }
  92. }