src/Controller/Finance/ProposalController.php line 70

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Finance;
  3. use App\Entity\Finance\Proposal;
  4. use App\Entity\Finance\ProposalElement;
  5. use App\Entity\HR\Employee;
  6. use App\Form\Finance\ContractType;
  7. use App\Entity\Finance\Contract;
  8. use App\Entity\Finance\ContractElement;
  9. use App\Form\Finance\ProposalType;
  10. use App\Form\Finance\ProposalInterviewType;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\HttpFoundation\Response;
  14. use Symfony\Contracts\Translation\TranslatorInterface;
  15. use Symfony\Component\Routing\Annotation\Route;
  16. use App\Service\Kernel\KernelService;
  17. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  18. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  19. /**
  20.  * @Route("/{_locale}/proposal")
  21.  */
  22. class ProposalController extends AbstractController
  23. {
  24.     /**
  25.      * @Route("/index/{state}/{open}/{my}/{user}/{interview}", name="proposal_index", methods={"GET"})
  26.      */
  27.     public function index(int $state=0int $open=0int $my=0int $user=0int $interview 0): Response
  28.     {
  29.         $classname =  explode("\\"get_class($this));
  30.         $arraysize count($classname);
  31.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  32.         $this->denyAccessUnlessGranted($attribute);
  33.         return $this->render('finance/proposal/index.html.twig',[
  34.            'state' => $state
  35.            'open' => $open,
  36.            'my' => $my,
  37.            'user' => $user,
  38.            'interview' => $interview,
  39.         ]);
  40.     }
  41.     /**
  42.      * @Route("/table/{state}/{open}/{my}/{leadId}/{user}/{interview}", name="proposal_table", methods={"GET"})
  43.      */
  44.     public function table(int $stateint $openint $my,int $leadIdint $user 0int $interview 0) :Response{
  45.         $classname =  explode("\\"get_class($this));
  46.         $arraysize count($classname);
  47.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  48.         $this->denyAccessUnlessGranted($attribute);
  49.         
  50.         $button $state 3*$open 9*$my 27*$interview;
  51.         return $this->render('finance/proposal/table.html.twig', [
  52.             'button' => $button'state' => $state'open' => $open'my' => $my'leadId' => $leadId,'user' => $user'interview'=>$interview
  53.         ]);
  54.     }
  55.     
  56.     /**
  57.      * @Route("/tabledetails/{state}/{open}/{my}/{leadId}/{user}/{interview}", name="proposal_tabledetails", methods={"GET","POST"})
  58.      */
  59.     public function tabledetails(Request $requestint $state,int $open,int $my,int $leadId,int $user=0,int $interview 0,TranslatorInterface $translatorKernelService $kernel_service) : Response {
  60.         $classname explode("\\"get_class($this));
  61.         $arraysize count($classname);
  62.         $attribute str_replace("Controller"""$classname[$arraysize -1]) . ":" str_replace("Action"""__FUNCTION__);
  63.         $this->denyAccessUnlessGranted($attribute);
  64.         $start $request->get('start');
  65.     $length $request->get('length');
  66.     
  67.         $em $this->getDoctrine()->getManager();
  68.         $organization =  $this->getUser()->getOrganization();
  69.         if ($organization == null)
  70.         {
  71.             $organizationid 0;
  72.         }
  73.         else
  74.         {
  75.             $organizationid $organization->getId();
  76.         }
  77.     $filter $request->get('search')['value'];
  78.         
  79.         //$openbasedondate = $kernel_service->getApplicationInfoValue('Kernel.OpenProposalBasedOnDate');
  80.        
  81.         $columns $request->get('columns');
  82.         $order $request->get('order');
  83.         $orderColumn $order[0]["column"];
  84.         $orderby $this->orderColumns($orderColumn$interview);
  85.         $direction strtoupper($order[0]["dir"]);
  86.         $queryString "SELECT s FROM App\Entity\Finance\Proposal s LEFT JOIN s.client t LEFT JOIN s.endClient u LEFT JOIN s.proposalElement v LEFT JOIN v.employee w WHERE ((s.state = ?1) ";
  87.         if($open == 1){
  88.             /*if ($openbasedondate == true)
  89.             {
  90.                 $queryString = $queryString . "AND (s.proposedOn >= ?3) ";
  91.             }
  92.             else
  93.             {*/
  94.                 $queryString $queryString "AND (s.open = ?3) ";
  95.             //}
  96.         }
  97.         if($my == 1){
  98.             $queryString $queryString "AND (s.owner = ?4 ) ";
  99.         }
  100.         if($user != 0){
  101.             $queryString $queryString "AND (s.owner = ?4 ) ";
  102.         }
  103.         if($leadId != -1){
  104.             $queryString $queryString "AND (s.lead = ?5) ";
  105.         }
  106.         if($interview != 0){
  107.             $queryString $queryString "AND (s.interview = ?6) ";
  108.         }
  109.         $queryString $queryString ."AND ((?2 = 0) or ((s.organization = ?2) or (s.organization is null)))) ";
  110.         if(!empty($filter) == true){
  111.             $queryString $queryString ."AND ((((s.subject LIKE '%".$filter."%') "
  112.                     "or (concat(w.firstname,' ', w.lastname) LIKE '%".$filter."%')"
  113.                     "or (t.company LIKE '%".$filter."%')) "
  114.                      "or (u.company LIKE '%".$filter."%')) "
  115.                     "or (s.proposedOn LIKE '%".$filter."%')) ";
  116.             
  117.         } 
  118.         $queryString $queryString ."ORDER BY ".$orderby." ".$direction;
  119.         $query $em->createQuery($queryString);
  120.         $count $query->setParameter(2$organizationid)
  121.                        ->setParameter(1$state); 
  122.         if($open == 1){
  123.             /*if ($openbasedondate == true)
  124.             {
  125.                 $dateInTwoWeeks = strtotime('-2 weeks');
  126.                 $count->setParameter(3, $dateInTwoWeeks);
  127.             }
  128.             else
  129.             {*/
  130.                 $count->setParameter(3$open);
  131.             //}
  132.             
  133.         }
  134.         if($my == 1){
  135.              $count->setParameter(4$this->getUser());
  136.         }
  137.         if($user != 0){
  138.              $count->setParameter(4$user);
  139.         }
  140.         if($leadId != -1){
  141.             $count->setParameter(5$leadId);
  142.         }
  143.         if($interview != 0){
  144.              $count->setParameter(6$interview);
  145.         }
  146.         $total count($count->getResult());
  147.         $query->setMaxResults($length)
  148.               ->setFirstResult($start);
  149.         $proposals $query->getResult();
  150.         $twig = clone $this->get('twig');
  151.         
  152.         $datawithlinks = array();
  153.         foreach($proposals as $row){
  154.             $i 0;
  155.             $newrow = array();
  156.             
  157.             $element null;
  158.             foreach ($row->getProposalElement() as $element2)
  159.             {
  160.                 if ($element2->getState() == 0)
  161.                 {
  162.                     $element =$element2;
  163.                 }
  164.             }
  165.             
  166.             $url $twig->createTemplate("{{ path('proposal_show', {'id': id })  }}")->render(array("id" => $row->getId()));
  167.             $newrow[$i] = $row->getId();
  168.             $i++;
  169.             $newrow[$i] = $url;
  170.             $i++;
  171.             //$newrow[$i] = $translator->trans("".$row->getType());
  172.             //$i++;
  173.             if ($element != null)
  174.             {
  175.                 $newrow[$i] = "".$element->getEmployee();
  176.                 $i++;
  177.                 $newrow[$i] = "".$element->getIntakePrice();
  178.                 $i++;
  179.                 $newrow[$i] = "".$element->getUnitPrice();
  180.                 $i++;
  181.             } else
  182.             {
  183.                 $newrow[$i] = "";
  184.                 $i++;
  185.                 $newrow[$i] = "";
  186.                 $i++;
  187.                 $newrow[$i] = "";
  188.                 $i++;
  189.             }
  190.             
  191.             $newrow[$i] = $row->getSubject();
  192.             $i++;
  193.             if ($interview == 1)
  194.             {
  195.                 if ($row->getInterviewDate() != null)
  196.                 {
  197.                     $newrow[$i] = "".$row->getInterviewDate()->format('d/m/Y');
  198.                 }
  199.                 else
  200.                 {
  201.                     $newrow[$i] = "";
  202.                 }
  203.             }
  204.             else
  205.             {
  206.                 if ($row->getProposedOn() != null)
  207.                 {
  208.                     $newrow[$i] = "".$row->getProposedOn()->format('d/m/Y');
  209.                 }
  210.                 else
  211.                 {
  212.                     $newrow[$i] = "";
  213.                 }
  214.             }
  215.             $i++;
  216.             $newrow[$i] = "".$row->getContactPerson();
  217.             $i++;
  218.             $newrow[$i] = "".$row->getClient();
  219.             $i++;
  220.             $newrow[$i] = "".$row->getEndClient();
  221.             $i++;
  222.             $newrow[$i] = "".$row->getOwner();
  223.             $i++;
  224.             if($row->getOpen()){
  225.                 $state "Open";
  226.             }else{
  227.                 $state "Closed";
  228.             }
  229.             $newrow[$i] = $translator->trans($state);
  230.             $i++;
  231.             $newrow[$i] = "".$row->getOrganization();
  232.             $i++;
  233.             $datawithlinks[] = $newrow;
  234.         }
  235.         $return = array(
  236.             "draw" => intval($request->get('draw')),
  237.             "recordsTotal" => $total,
  238.             "recordsFiltered" => $total,
  239.             "aaData" => $datawithlinks
  240.         );
  241.         $return json_encode($return);
  242.         return new Response($return,200,array('Content-type' => 'application/json')); 
  243.     }
  244.     
  245.         public function orderColumns($orderColumn$interview){
  246.         $orderby ""
  247.         switch($orderColumn){
  248.             case 0:
  249.                 $orderby "s.id"// i don't think this works
  250.                 break;
  251.             case 2:
  252.                 $orderby "s.id"// i don't think this works
  253.                 break;
  254.             case 3:
  255.                 $orderby "s.id"// i don't think this works
  256.                 break;
  257.             case 4:
  258.                 $orderby "s.id"// i don't think this works
  259.                 break;
  260.             case 5
  261.                 $orderby "s.subject";
  262.                 break;
  263.             case 6:
  264.                 if ($interview == 1)
  265.                 {
  266.                     $orderby "s.interviewDate";
  267.                 }
  268.                 else
  269.                 {
  270.                     $orderby "s.proposedOn";
  271.                 }
  272.                 break;
  273.             case 7:
  274.                 $orderby "s.contactPerson";
  275.                 break;
  276.             case 8:
  277.                 $orderby "s.client";
  278.                 break;
  279.             case 9:
  280.                 $orderby "s.endClient";
  281.                 break;
  282.             case 10
  283.                 $orderby "s.owner"// total amount don't work 
  284.                 break;
  285.             case 11
  286.                 $orderby "s.open"
  287.                 break;
  288.             case 12:
  289.                 $orderby "s.organization";
  290.                 break;
  291.                 
  292.         }
  293.         return $orderby;
  294.     }
  295.      /**
  296.      * @Route("/{id}/newcontract", name="proposal_newContract", methods={"GET","POST"})
  297.      */
  298.     public function newContract(Request $requestProposal $proposal): Response
  299.     {
  300.         $classname =  explode("\\"get_class($this));
  301.         $arraysize count($classname);
  302.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  303.         $this->denyAccessUnlessGranted($attribute);
  304.         
  305.         $entityManager $this->getDoctrine()->getManager();
  306.         
  307.         $contract = new Contract();
  308.         $date = new \DateTime();
  309.         $contract->setStartDate($date);
  310.         $contract->setEndDate($date);
  311.         $contract->setContractCreated($date);
  312.         $contract->setProposal($proposal);
  313.         $contract->setSubject($proposal->getSubject());
  314.         $contract->setType($proposal->getType());
  315.         $contract->setClient($proposal->getClient());
  316.         $contract->setEndClient($proposal->getEndClient());
  317.         $contract->setOwner($proposal->getOwner());
  318.         $contract->setOpen($proposal->getOpen());
  319.         $contract->setNoExtension(false);
  320.         $contract->setSend2signedCopies(false);
  321.         $contract->setReceivedCounterSigned(false);
  322.         $contract->setState(0);
  323.         $contract->setContactPerson($proposal->getContactPerson());
  324.         $contract->setOrganization($proposal->getOrganization());
  325.         $entityManager->persist($contract);
  326.         
  327.         $proposal->setOpen(false);
  328.         $entityManager->persist($proposal);
  329.         
  330.         
  331.         foreach($proposal->getProposalElement() as $element)
  332.         {
  333.             $contractelement = new ContractElement();
  334.             $contractelement->setContract($contract);
  335.             $contractelement->setEmployee($element->getEmployee());
  336.             $contractelement->setFrequency($element->getFrequency());
  337.             $contractelement->setIntakePrice($element->getIntakePrice());
  338.             $contractelement->setUnitPrice($element->getUnitPrice());
  339.             $contractelement->setProduct($element->getProduct());
  340.             $contractelement->setQuantity($element->getQuantity());
  341.             $contractelement->setReceivedBack(false);
  342.             $contractelement->setSendCounterSigned(false);
  343.             $contractelement->setContractSendToConsultant(false);
  344.             $contractelement->setState(0);
  345.             $entityManager->persist($contractelement);
  346.         }
  347.         
  348.         $entityManager->flush();
  349.         
  350.         
  351.         
  352.         return $this->redirectToRoute('contract_edit', array('id' => $contract->getId()));
  353.         
  354.     }
  355.     /**
  356.      * @Route("/new/{id?0}", name="proposal_new", methods={"GET","POST"})
  357.      */
  358.     public function new(Request $requestint $id 0KernelService $kernelservice): Response
  359.     {
  360.         $classname =  explode("\\"get_class($this));
  361.         $arraysize count($classname);
  362.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  363.         $this->denyAccessUnlessGranted($attribute);
  364.         
  365.         $entityManager $this->getDoctrine()->getManager();
  366.         
  367.         $proposal = new Proposal();
  368.         $date = new \DateTime();
  369.         $proposal->setProposedOn($date);
  370.         $proposal->setOpen(true);
  371.         $proposal->setOwner($this->getUser());
  372.         $organization $this->getUser()->getOrganization();
  373.         $simpleProposals $kernelservice->getApplicationInfoValue("Sales.SimpleProposals");
  374.         $form $this->createForm(ProposalType::class, $proposal
  375.                 ['organization' => $organization'action' => $this->generateUrl('proposal_new'), 'attr' => ['id' => $this->generateUrl('proposal_new')]]);     
  376.         if($simpleProposals)
  377.         {
  378.             $required true;
  379.             $employee null;
  380.             $employees = array();
  381.             if ($id != 0)
  382.             {
  383.                 $employeeentity $entityManager->getRepository(Employee::class)->findOneById($id);
  384.                 $employees["".$employeeentity
  385.                             = "SU".$employeeentity->getId();
  386.                 $employee "SU".$employeeentity->getId();
  387.             }
  388.             $form->add('employeeselect2',ChoiceType::class, array('priority' => 3'label' => 'Employee',
  389.                     'required' => true,
  390.                     'multiple' => false,
  391.                     'mapped' => false,
  392.                     'data' => $employee
  393.                     'choices' => $employees,
  394.                     'attr' => array('class' => 'selectemployee')
  395.                 ));
  396.             $form->add('intakePrice'NumberType::class, array('priority' => 2'mapped' => false'label' => 'IntakePrice','required' => $required));
  397.             $form->add('unitPrice'NumberType::class, array('priority' => 1'mapped' => false'label' => 'Proposal.UnitPrice','required' => $required));
  398.         }
  399.         if ($this->getUser()->getOrganization() == null) {
  400.         $form->add('organization'null, array('label' => 'Organization',
  401.                 'query_builder' => function ($repository) {
  402.                     return $repository->createQueryBuilder('s')->where("s.state = 0");
  403.                 },
  404.                 'attr' => ['class' => 'select2']));
  405.         }
  406.         $form->handleRequest($request);
  407.         if ($form->isSubmitted()) {// && $form->isValid()) {
  408.             
  409.             
  410.             
  411.             
  412.             $proposal->setState(0);
  413.             if ($this->getUser()->getOrganization() != null) {
  414.                 $proposal->setOrganization($this->getUser()->getOrganization());
  415.             }
  416.             $entityManager->persist($proposal);
  417.             $entityManager->flush();
  418.             
  419.             
  420.             $requestdata $request->request->all("proposal");
  421.             $unitprice 0;
  422.             if (isset($requestdata['unitPrice']) == true)
  423.             {
  424.                 
  425.                 $unitprice floatval(str_replace(',''.'$requestdata['unitPrice']));
  426.             }
  427.             $intakeprice 0;
  428.             if (isset($requestdata['intakePrice']) == true)
  429.             {
  430.                 $intakeprice floatval(str_replace(',''.'$requestdata['intakePrice']));
  431.             }
  432.             if (isset($requestdata['employeeselect2']) == true) {
  433.                 $employeeselect2 $requestdata['employeeselect2'];
  434.                 $employee null;
  435.                 $employeetype substr($employeeselect202);
  436.                 $employeeid substr($employeeselect22);
  437.                 if ($employeetype == "SU") {
  438.                     
  439.                     $proposalElement = new ProposalElement();
  440.                     $proposalElement->setProposal($proposal);
  441.                     $proposalElement
  442.                             ->setEmployee(
  443.                                $entityManager->getRepository(Employee::class)
  444.                                     ->findOneById($employeeid));
  445.                     $proposalElement->setIntakePrice($intakeprice);
  446.                     $proposalElement->setUnitPrice($unitprice);
  447.                     $proposalElement->setState(0);
  448.                     $proposalElement->setQuantity(0);
  449.                     $entityManager->persist($proposalElement);
  450.                     $entityManager->flush();
  451.                 }
  452.             }
  453.             
  454.             $this->denyAccessUnlessGranted($attribute$proposal);
  455.             //return $this->redirectToRoute('proposal_index');
  456.             return $this->redirectToRoute('proposal_show', array('id' => $proposal->getId()));
  457.         }
  458.         return $this->render('finance/proposal/new.html.twig', [
  459.             'proposal' => $proposal,
  460.             'form' => $form->createView(),
  461.         ]);
  462.     }
  463.     /**
  464.      * @Route("/{id}", name="proposal_show", methods={"GET"})
  465.      */
  466.     public function show(Proposal $proposalKernelService $kernelservice): Response
  467.     {
  468.         $classname =  explode("\\"get_class($this));
  469.         $arraysize count($classname);
  470.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  471.         $this->denyAccessUnlessGranted($attribute$proposal);  
  472.         
  473.         $simpleProposals $kernelservice->getApplicationInfoValue("Sales.SimpleProposals");
  474.         $interviewProposals $kernelservice->getApplicationInfoValue("Sales.InterviewProposals");
  475.         
  476.         return $this->render('finance/proposal/show.html.twig', [
  477.             'proposal' => $proposal,
  478.             'simpleProposals' => $simpleProposals,
  479.             'interviewProposals' => $interviewProposals
  480.         ]);
  481.     }
  482.     
  483.     /**
  484.      * @Route("/{id}/audit", name="proposal_showaudit", methods={"GET"})
  485.      */
  486.     public function showaudit(Proposal $proposal): Response
  487.     {
  488.         $classname =  explode("\\"get_class($this));
  489.         $arraysize count($classname);
  490.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  491.         $this->denyAccessUnlessGranted($attribute$proposal);  
  492.         
  493.         return $this->render('finance/proposal/showaudit.html.twig', [
  494.             'proposal' => $proposal,
  495.         ]);
  496.     }
  497.     
  498.     /**
  499.      * @Route("/{id}/archive", name="proposal_archive", methods={"GET"})
  500.      */
  501.     public function archive(Proposal $proposal): Response
  502.     {
  503.         $classname =  explode("\\"get_class($this));
  504.         $arraysize count($classname);
  505.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  506.         $this->denyAccessUnlessGranted($attribute$proposal); 
  507.         
  508.                 
  509.         $entityManager $this->getDoctrine()->getManager();
  510.         $proposal->setState(1);
  511.         $entityManager->persist($proposal);
  512.         $entityManager->flush();
  513.         
  514.         return $this->redirectToRoute('proposal_show', array('id' => $proposal->getId()));
  515.     }
  516.     
  517.     /**
  518.      * @Route("/{id}/restore", name="proposal_restore", methods={"GET"})
  519.      */
  520.     public function restore(Proposal $proposal): Response
  521.     {
  522.         $classname =  explode("\\"get_class($this));
  523.         $arraysize count($classname);
  524.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  525.         $this->denyAccessUnlessGranted($attribute$proposal); 
  526.         
  527.                 
  528.         $entityManager $this->getDoctrine()->getManager();
  529.         $proposal->setState(0);
  530.         $entityManager->persist($proposal);
  531.         $entityManager->flush();
  532.         
  533.         return $this->redirectToRoute('proposal_show', array('id' => $proposal->getId()));
  534.     }
  535.     
  536.     /**
  537.      * @Route("/{id}/delete", name="proposal_logicaldelete", methods={"GET"})
  538.      */
  539.     public function logicaldelete(Proposal $proposal): Response
  540.     {
  541.         $classname =  explode("\\"get_class($this));
  542.         $arraysize count($classname);
  543.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  544.         $this->denyAccessUnlessGranted($attribute$proposal); 
  545.         
  546.                 
  547.         $entityManager $this->getDoctrine()->getManager();
  548.         $proposal->setState(2);
  549.         $entityManager->persist($proposal);
  550.         $entityManager->flush();
  551.         
  552.         return $this->redirectToRoute('proposal_index');
  553.     }
  554.     /**
  555.      * @Route("/{id}/edit", name="proposal_edit", methods={"GET","POST"})
  556.      */
  557.     public function edit(Request $requestProposal $proposalKernelService $kernelservice): Response
  558.     {
  559.         $classname =  explode("\\"get_class($this));
  560.         $arraysize count($classname);
  561.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  562.         $this->denyAccessUnlessGranted($attribute$proposal); 
  563.     
  564.         $form $this->createForm(ProposalType::class, $proposal
  565.                 ['organization' => $proposal->getOrganization() , 'action' => $this->generateUrl('proposal_edit', array('id' => $proposal->getId())), 
  566.                  'attr' => ['id' => $this->generateUrl('proposal_edit', array('id' => $proposal->getId()))]]);
  567.         
  568.         $simpleProposals $kernelservice->getApplicationInfoValue("Sales.SimpleProposals");
  569.         if($simpleProposals)
  570.         {
  571.             $employees = array();
  572.             $employee "";
  573.             $unitPrice 0;
  574.             $intakePrice 0;
  575.             
  576.             if ($proposal->getProposalElement()->isEmpty() == false) {
  577.                 $element =  $proposal->getProposalElement()->first();
  578.                 $employee $element->getEmployee();
  579.                 $unitPrice $element->getUnitPrice();
  580.                 $intakePrice $element->getIntakePrice();
  581.                 
  582.                 if ($element->getEmployee() != null)
  583.                 {
  584.                     $employees["".$element->getEmployee()] 
  585.                             = "SU".$element->getEmployee()->getId();
  586.                     $employee "SU".$element->getEmployee()->getId();
  587.                 }
  588.             }
  589.             
  590.             $required true;
  591.             $form->add('employeeselect2',ChoiceType::class, array('priority' => 3'label' => 'Employee',
  592.                     'required' => true,
  593.                     'multiple' => false,
  594.                     'mapped' => false,
  595.                     'data' => $employee
  596.                     'choices' => $employees,
  597.                     'attr' => array('class' => 'selectemployee')
  598.                 ));
  599.             $form->add('intakePrice'NumberType::class, array('priority' => 2'data' => $intakePrice'mapped' => false'label' => 'IntakePrice','required' => $required));
  600.             $form->add('unitPrice'NumberType::class, array('priority' => 1'data' => $unitPrice'mapped' => false'label' => 'UnitPrice','required' => $required));
  601.         }
  602.         
  603.         $form->handleRequest($request);
  604.         if ($form->isSubmitted()) { // && $form->isValid()) {
  605.             $this->getDoctrine()->getManager()->flush();
  606.             
  607.             if($simpleProposals)
  608.             {
  609.                 if ($proposal->getProposalElement()->isEmpty() == false) {
  610.                     $element =  $proposal->getProposalElement()->first();
  611.                     $requestdata $request->request->all("proposal");
  612.                     
  613.                     if (isset($requestdata['unitPrice']) == true)
  614.                     {
  615.                         $element->setUnitPrice($requestdata['unitPrice']);
  616.                     }
  617.                     if (isset($requestdata['intakePrice']) == true)
  618.                     {
  619.                         $element->setIntakePrice($requestdata['intakePrice']);
  620.                     }
  621.                     if (isset($requestdata['employeeselect2']) == true) {
  622.                         $employeeselect2 $requestdata['employeeselect2'];
  623.                         $employee null;
  624.                         $entityManager $this->getDoctrine()->getManager();
  625.                         $employeetype substr($employeeselect202);
  626.                         $employeeid substr($employeeselect22);
  627.                         if ($employeetype == "SU") {
  628.                             $element
  629.                                     ->setEmployee(
  630.                                        $entityManager->getRepository(Employee::class)
  631.                                             ->findOneById($employeeid));
  632.                         }
  633.                     }
  634.                     $entityManager->persist($element);
  635.                     $entityManager->flush();
  636.                 }           
  637.             }
  638.             return $this->redirectToRoute('proposal_show', array('id' => $proposal->getId()));
  639.         }
  640.         return $this->render('finance/proposal/edit.html.twig', [
  641.             'proposal' => $proposal,
  642.             'form' => $form->createView(),
  643.         ]);
  644.     }
  645.     
  646.     /**
  647.      * @Route("/{id}/editinterview", name="proposal_editinterview", methods={"GET","POST"})
  648.      */
  649.     public function editinterview(Request $requestProposal $proposalKernelService $kernelservice): Response
  650.     {
  651.         $classname =  explode("\\"get_class($this));
  652.         $arraysize count($classname);
  653.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  654.         $this->denyAccessUnlessGranted($attribute$proposal); 
  655.     
  656.         $form $this->createForm(ProposalInterviewType::class, $proposal
  657.                 ['action' => $this->generateUrl('proposal_editinterview', array('id' => $proposal->getId())), 
  658.                  'attr' => ['id' => $this->generateUrl('proposal_editinterview', array('id' => $proposal->getId()))]]);
  659.         
  660.         
  661.         
  662.         $form->handleRequest($request);
  663.         if ($form->isSubmitted()) { // && $form->isValid()) {
  664.             $this->getDoctrine()->getManager()->flush();
  665.             return $this->redirectToRoute('proposal_show', array('id' => $proposal->getId()));
  666.         }
  667.         return $this->render('finance/proposal/editinterview.html.twig', [
  668.             'proposal' => $proposal,
  669.             'form' => $form->createView(),
  670.         ]);
  671.     }
  672.     /**
  673.      * @Route("/{id}", name="proposal_delete", methods={"DELETE"})
  674.      */
  675.     public function delete(Request $requestProposal $proposal): Response
  676.     {
  677.         $classname =  explode("\\"get_class($this));
  678.         $arraysize count($classname);
  679.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  680.         $this->denyAccessUnlessGranted($attribute$proposal); 
  681.     
  682.         if ($this->isCsrfTokenValid('delete'.$proposal->getId(), $request->request->get('_token'))) {
  683.             $entityManager $this->getDoctrine()->getManager();
  684.             $entityManager->remove($proposal);
  685.             $entityManager->flush();
  686.         }
  687.         return $this->redirectToRoute('proposal_index');
  688.     }
  689.     
  690. }