src/MDS/EventsBundle/Controller/ProposalSupplierServicesCostsController.php line 40

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by Mediterranean Develup Solutions
  4.  * User: jorge.defreitas@develup.solutions
  5.  * Date: 14/08/2017
  6.  * Time: 12:15
  7.  */
  8. namespace App\MDS\EventsBundle\Controller;
  9. use App\Entity\Configuration;
  10. use App\Entity\SettingsCompany;
  11. use App\Entity\Supplier;
  12. use App\MDS\EventsBundle\Entity\Proposal;
  13. use App\MDS\EventsBundle\Entity\ProposalSupplierServices;
  14. use App\MDS\EventsBundle\Entity\ProposalSupplierServicesCosts;
  15. use App\Service\ProposalSupplierServicesService;
  16. use Doctrine\ORM\EntityManagerInterface;
  17. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  18. use Symfony\Component\Routing\Annotation\Route;
  19. use Symfony\Component\HttpFoundation\Request;
  20. use Symfony\Contracts\Translation\TranslatorInterface;
  21. class ProposalSupplierServicesCostsController extends AbstractController
  22. {
  23.     private $translator;
  24.     public function __construct(TranslatorInterface $translator) {
  25.         $this->translator $translator;
  26.     }
  27.     
  28.     /*
  29.     * ATENCION LAS RAIZ DE @Route POR DEFECTO DEL BUNDLE: EventsBundle ES  /events/, NO PONERLO EN LA @Route("")
  30.     *
  31.     * */
  32.     /**
  33.      * @Route("/proposal/costs/supplier/view/{id}",  name="proposal_supplier_services_costs")
  34.      */
  35.     public function costsSupplierAction($idRequest $request)
  36.     {
  37.         $em $this->getDoctrine()->getManager();
  38.         $proposal $em->getRepository(Proposal::class)->findOneById($id);
  39.         /* Obtengo usuario logueado */
  40.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  41.         $user_id $user_logueado->getId();
  42. //        $services_id= $em->getRepository(SupplierIdServices::class)->findAll();
  43.         /* INSERTAMOS Y ACTUALIZAMOS LA BASE DE DATOS ProposalSupplierServicesCosts*/
  44.         /*  Sacamos los proveedores dentro de la proposal*/
  45. //        $supplier_control = $em->getRepository(ProposalSupplierControl::class)->findByProposalId($id);
  46.         $services_supplier $em->getRepository(ProposalSupplierServices::class)->findBy(
  47.             array(
  48.                 'proposalId' => $id,
  49.                 'isFather' => '',
  50.                 'status' => 'Confirmed',
  51.             ),
  52.             array(
  53.                 'id' => 'ASC'
  54.             )
  55.         );
  56.         $supplier_control = array();
  57.         foreach($services_supplier as $servicessupplier){
  58.             if (!is_null($servicessupplier->getsupplierId()) && $servicessupplier->getsupplierId() != '0'){
  59. //            if (!is_null($servicessupplier->getsupplierId())){
  60.                 $supplier_control[$servicessupplier->getSupplierId()] = $servicessupplier->getSupplierId();
  61.             }
  62.         }
  63.         $data_supplier = array();
  64.         $idcostsfuera = array();
  65.         foreach($supplier_control as $supplierControl){
  66.             $services_hay $em->getRepository(ProposalSupplierServices::class)->findBy(
  67.                 array(
  68.                     'proposalId' => $id,
  69.                     'supplierId' => $supplierControl,
  70.                     'isFather' => '0',
  71.                     'status' => 'Confirmed',
  72.                 ),
  73.                 array(
  74.                     'id' => 'ASC'
  75.                 )
  76.             );
  77.             $total_neto 0;
  78.             $total_iva 0;
  79.         if (!empty($services_hay)){
  80.             $datos = array();
  81.             foreach($services_hay as $serviceshay){
  82.                 if (!is_null($serviceshay->getsupplierId())){
  83.                     if ($serviceshay->getDirectPayment() == true){
  84.                         $symbol_pago " PD-YES";
  85.                     }else{
  86.                         $symbol_pago " PD-NO";
  87.                     }
  88.                     $datos[$serviceshay->getServiceCatId().' I'.$serviceshay->getIva().$symbol_pago][] = $serviceshay;
  89.                 }
  90.             }
  91.                 foreach ($datos as $datos1){
  92.                     $totales "0";
  93.                     $totales_direct "0";
  94.                     $dentroServiceIds "";
  95.                     $ids = array();
  96.                     $contando_costs="0";
  97.                     foreach ($datos1 as $datos2){
  98.                         //COLOR POR SERVICIO
  99.                         $contcolor ="";
  100.                         switch ($datos2->getServiceCatName()) {
  101.                             case "Accommodation":
  102.                                 $contcolor 'teal';
  103.                                 break;
  104.                             case "Menu" :
  105.                                 $contcolor 'purple';
  106.                                 break;
  107.                             case "Lounge":
  108.                                 $contcolor 'warning';
  109.                                 break;
  110.                             case "Activities":
  111.                                 $contcolor 'blue';
  112.                                 break;
  113.                             case "Itineraries":
  114.                                 $contcolor 'indigo';
  115.                                 break;
  116.                             case "Cruise":
  117.                                 $contcolor 'brown';
  118.                                 break;
  119.                             case "Transport":
  120.                                 $contcolor 'grey';
  121.                                 break;
  122.                             case "Av":
  123.                                 $contcolor 'slate';
  124.                                 break;
  125.                             case "Creative":
  126.                                 $contcolor 'orange';
  127.                                 break;
  128.                             case "Gifts":
  129.                                 $contcolor 'pink';
  130.                                 break;
  131.                             case "Entertainment":
  132.                                 $contcolor 'green';
  133.                                 break;
  134.                             case "Guide":
  135.                                 $contcolor 'orange';
  136.                                 break;
  137.                             case "Others":
  138.                                 $contcolor 'danger';
  139.                                 break;
  140.                             case "Technology":
  141.                                 $contcolor 'slate-800';
  142.                                 break;
  143.                             case "Assistant":
  144.                                 $contcolor 'indigo-800';
  145.                                 break;
  146.                             case "DDR":
  147.                                 $contcolor 'green-300';
  148.                                 break;
  149.                         }
  150.                         $directPayment $datos2->getDirectPayment();
  151.                         $ids[] = $datos2->getId();
  152. //                        $opcommission = $datos2->getOpCommission();
  153.                         //  $comision = $datos2->getCommission();
  154.                             if (is_null($datos2->getCommission()) or empty($datos2->getCommission())){
  155.                                 $comision 0;
  156.                             }else{
  157.                                 $comision $datos2->getCommission();
  158.                             }
  159.                         $opiva $datos2->getOpIva();
  160.                         //  $iva = $datos2->getIva();
  161.                             if (is_null($datos2->getIva()) or empty($datos2->getIva())){
  162.                                 $iva 0;
  163.                             }else{
  164.                                 $iva $datos2->getIva();
  165.                             }
  166.                         $supplierId $datos2->getSupplierId();
  167.                         $dateInAt $datos2->getDateInAt();
  168.                         $dateOutAt $datos2->getDateOutAt();
  169.                             if (!is_null($dateInAt) and !is_null($dateOutAt)){
  170.                                 $days $dateInAt->diff($dateOutAt);
  171.                                 $day $days->days;
  172.                             }else{
  173.                                 $day "0";
  174.                             }
  175.                         //  $price = $datos2->getPrice();
  176.                             if (is_null($datos2->getPrice()) or empty($datos2->getPrice())){
  177.                                 $price 0;
  178.                             }else{
  179.                                 $price $datos2->getPrice();
  180.                             }
  181.                         $units $datos2->getUnits();
  182.                         $pax $datos2->getPax();
  183.                         $idcat $datos2->getServiceCatId();
  184.                         $idcatName $datos2->getServiceCatName();
  185.                         $total $this->CalculoTotalCosts($price$units$pax$day$idcat$opiva$iva);
  186.                         if ($directPayment == true){
  187.                             if($opiva =='0'){
  188.                                 $iva $iva 100;
  189.                                 $total $total / ($iva 1);
  190.                             }
  191.                             $comision_direct = ($comision 100);
  192.                             $total_direct $total $comision_direct;
  193.                             $totales_direct += $total_direct;
  194.                         }else{
  195.                             $totales += $total;
  196.                         }
  197.                         /* CONSULTAMOS PARA SUMAR  */
  198.                         $parameters = array(
  199.                             'servicesId' => '%'.$datos2->getId().'%',
  200.                             'proposalId' => $id,
  201.                             'serviceCatId' => $idcat,
  202.                             'supplierId' => $supplierId,
  203.                         );
  204.                         $dql 'SELECT p
  205.                         FROM EventsBundle:ProposalSupplierServicesCosts p
  206.                         WHERE p.servicesId LIKE :servicesId
  207.                         and p.proposalId = :proposalId
  208.                         and p.serviceCatId = :serviceCatId
  209.                         and p.supplierId = :supplierId
  210.                         ORDER BY p.serviceCatId, p.id ASC ';
  211.                         $query $em->createQuery($dql)->setParameters($parameters);
  212.                         $costs_count $query->getResult();
  213.                         if (!empty($costs_count)){
  214.                             $dentroServiceIds $costs_count['0']->getServicesId();
  215.                             $idcosts $costs_count['0']->getId();
  216.                             $contando_costs += 1;
  217.                             $idcostsfuera[$idcosts] = $idcosts;
  218.                         }
  219.                     }
  220.                     $Adentroidservices explode(","$dentroServiceIds);
  221.                     $idservices implode(","$ids);
  222.                     if ($contando_costs == "0"){
  223.                         /* Para dentro de ProposalSupplierServicesCosts */
  224.                         $costs = new ProposalSupplierServicesCosts();
  225.                         $costs->setProposalId($id);
  226.                         $costs->setServicesId($idservices);
  227.                         $costs->setSupplierId($supplierId);
  228.                         if ($directPayment == true){
  229.                             $costs->setTotalServices(-$totales_direct);
  230.                             $costs->setCommission('0');
  231.                             $costs->setOpIva('1');
  232.                             $costs->setIvaServices('21');
  233.                         }else{
  234.                             $costs->setTotalServices($totales);
  235.                             $costs->setCommission($comision);
  236.                             $costs->setOpIva($opiva);
  237.                             // Se detecta un error con IVA que vienen en con opIva en negativo, el totalservices se clacula para ponerse antes de impuestos, pero el opIva se pone como si no se hiciera este calculo
  238.                             $costs->setOpIva(1);
  239.                             $costs->setIvaServices($iva);
  240.                         }
  241. //                            $costs->setTotalServices($totales);
  242. //                            $costs->setCommission($comision);
  243. //                            $costs->setOpIva($opiva);
  244. //                            $costs->setIvaServices($iva);
  245.                         $costs->setServiceCatId($idcat);
  246.                         $costs->setServiceCatName($idcatName);
  247.                         $costs->setCreatedId($user_id);
  248.                         $costs->setUpdatedId($user_id);
  249.                         $costs->setContcolor($contcolor);
  250.                         $costs->setEdited('0');
  251.                         $em->persist($costs);
  252.                         $em->flush();
  253.                         $idcostsfuera[$costs->getId()] = $costs->getId();
  254.                     }else{
  255.                         if(count($ids) != $contando_costs or count($ids) != count($Adentroidservices)){
  256.                             $costs$em->getRepository(ProposalSupplierServicesCosts::class)->findOneById($idcosts);
  257.                             $costs->setServicesId($idservices);
  258.                             if ($directPayment == true){
  259.                                 $costs->setTotalServices(-$totales_direct);
  260.                             }else{
  261.                                 $costs->setTotalServices($totales);
  262.                             }
  263.                             $costs->setUpdatedId($user_id);
  264.                             $costs->setEdited('1');
  265.                             $em->persist($costs);
  266.                             $em->flush();
  267.                         }else{
  268. //                            d('test', $idcosts);
  269.                         }
  270.                     }
  271.                 }
  272.             }
  273.         }
  274.         $supplierexistentesquery $em->getRepository(ProposalSupplierServicesCosts::class)->findByProposalId($id);
  275.         $supplierexistecontrolbase = [];
  276.         foreach($supplierexistentesquery as $supplierexistentes){
  277.             if ($supplierexistentes->getsupplierId() != '0'){
  278.                 $supplierexistecontrolbase[$supplierexistentes->getSupplierId()] = $supplierexistentes->getSupplierId();
  279.             }
  280.         }
  281.         foreach($supplierexistecontrolbase as $supplierexistecontrol){
  282.             //            d($supplier_existentes->getSupplierId());
  283.             $costs_supplier $em->getRepository(ProposalSupplierServicesCosts::class)->findBy(
  284.                 array(
  285.                     'proposalId' => $id,
  286.                     'supplierId' => $supplierexistecontrol,
  287.                     //                'supplierId' => $supplierControl
  288.                 )
  289.             );
  290.             $total_neto 0;
  291.             $total_iva 0;
  292.             $data_costs = array();
  293.             foreach ($costs_supplier as $costssupplier){
  294.                 if (empty($costssupplier->getCommission()) OR is_null($costssupplier->getCommission() OR $costssupplier->getCommission() == " ")){
  295.                     $comisionEmpty 0;
  296.                 }else{
  297.                     $comisionEmpty $costssupplier->getCommission();
  298.                 }
  299.                 if (empty($costssupplier->getTotalServices()) OR is_null($costssupplier->getTotalServices() OR $costssupplier->getTotalServices() == " ")){
  300.                     $TotalServicesEmpty 0;
  301.                 }else{
  302.                     $TotalServicesEmpty $costssupplier->getTotalServices();
  303.                 }
  304.                 if (empty($costssupplier->getIvaServices()) OR is_null($costssupplier->getIvaServices() OR $costssupplier->getIvaServices() == " ")){
  305.                     $IvaServicesEmpty 0;
  306.                 }else{
  307.                     $IvaServicesEmpty $costssupplier->getIvaServices();
  308.                 }
  309.                 //                $totales_neto = $costssupplier->getTotalServices() /  ($costssupplier->getCommission() /100 + 1);
  310.                 $totales_neto = (float)$TotalServicesEmpty *  ( ( 100 - (float)$comisionEmpty ) / 100);
  311.                 if ($costssupplier->getOpIva() == "0"){
  312.                     // Si es menos(-) es Entre(/)
  313.                     $totales_neto $totales_neto  /  ($IvaServicesEmpty 100 1);
  314.                 }
  315.                 $total_neto += $totales_neto;
  316.                 $iva $totales_neto * ($IvaServicesEmpty 100);
  317.                 $totales_iva $totales_neto * ($IvaServicesEmpty 100 1);
  318.                 $total_iva += $totales_iva;
  319.                 $data_costs[] = array(
  320.                     'data' => $costssupplier,
  321.                     'total_neto' => $totales_neto,
  322.                     'iva' => $iva,
  323.                     'total_iva' => $totales_iva
  324.                 );
  325.             }
  326.             $totales_data = array(
  327.                 'total_neto' => $total_neto,
  328.                 'total_iva' => $total_iva,
  329.             );
  330.             $suppliers $em->getRepository(Supplier::class)->findById($supplierexistecontrol);
  331.             foreach ($suppliers as $supplier){
  332.                 $data_supplier[] = array(
  333.                     'master' => 'supplier',
  334.                     'supplier' => $supplier,
  335.                     'data' => $data_costs,
  336.                     'totales' => $totales_data
  337.                 );
  338.             }
  339.         }
  340.         $costs_supplier_cero $em->getRepository(ProposalSupplierServicesCosts::class)->findBy(
  341.             array(
  342.                 'proposalId' => $id,
  343.                 'supplierId' => 0
  344.             )
  345.         );
  346.         if (!is_null($costs_supplier_cero)){
  347.             $total_neto 0;
  348.             $total_iva 0;
  349.             $data_costs_cero = array();
  350.             foreach ($costs_supplier_cero as $costssupplier){
  351.                 if (empty($costssupplier->getCommission()) OR is_null($costssupplier->getCommission()) OR $costssupplier->getCommission() == " "){
  352.                     $comisionEmpty 0;
  353.                 }else{
  354.                     $comisionEmpty $costssupplier->getCommission();
  355.                 }
  356.                 if (empty($costssupplier->getTotalServices()) OR is_null($costssupplier->getTotalServices() OR $costssupplier->getTotalServices() == " ")){
  357.                     $TotalServicesEmpty 0;
  358.                 }else{
  359.                     $TotalServicesEmpty $costssupplier->getTotalServices();
  360.                 }
  361.                 if (empty($costssupplier->getIvaServices()) OR is_null($costssupplier->getIvaServices() OR $costssupplier->getIvaServices() == " ")){
  362.                     $IvaServicesEmpty 0;
  363.                 }else{
  364.                     $IvaServicesEmpty $costssupplier->getIvaServices();
  365.                 }
  366.     //                $totales_neto = $costssupplier->getTotalServices() /  ($costssupplier->getCommission() /100 + 1);
  367.                 $totales_neto = (float)$TotalServicesEmpty *  ( ( 100 - (float)$comisionEmpty ) / 100);
  368.                 if ($costssupplier->getOpIva() == "0"){
  369.                     // Si es menos(-) es Entre(/)
  370.                     $totales_neto $totales_neto  /  ($IvaServicesEmpty 100 1);
  371.                 }
  372.                 $total_neto += $totales_neto;
  373.                 $iva $totales_neto * ($IvaServicesEmpty 100);
  374.                 $totales_iva $totales_neto * ($IvaServicesEmpty 100 1);
  375.                 $total_iva += $totales_iva;
  376.                 /* Obtener y agregar el nombre del proveedor */
  377.                 if (!is_null($costssupplier->getSupplierIdExpenses()) and $costssupplier->getSupplierIdExpenses() != ){
  378.                     $supplierExp $em->getRepository(Supplier::class)->findOneById($costssupplier->getSupplierIdExpenses());
  379.                     if(!empty($supplierExp)){
  380.                         $costssupplier->setSupplierIdExpenses($supplierExp->getCompany());
  381.                     }else{
  382.                         $costssupplier->setSupplierIdExpenses('');
  383.                     }
  384.                 }else{
  385.                     $costssupplier->setSupplierIdExpenses('');
  386.                 }
  387.                 $data_costs_cero[] = array(
  388.                     'data' => $costssupplier,
  389.                     'total_neto' => $totales_neto,
  390.                     'iva' => $iva,
  391.                     'total_iva' => $totales_iva
  392.                 );
  393.             }
  394.             $totales_data = array(
  395.                 'total_neto' => $total_neto,
  396.                 'total_iva' => $total_iva,
  397.             );
  398.             $company $em->getRepository(SettingsCompany::class)->findByPriority('1');
  399.             $data_supplier[] = array(
  400.                 'master' => 'company',
  401.                 'supplier' => $company,
  402.                 'data' => $data_costs_cero,
  403.                 'totales' => $totales_data
  404.             );
  405.         }
  406.         /*Supplier list*/
  407.         $list_Supplier $em->getRepository(Supplier::class)->findAll();
  408.         $arraySupplier =array();
  409.         foreach($list_Supplier as $listSupplier) {
  410.             $arraySupplier[] = array(
  411.                 'id' => $listSupplier->getId(),
  412.                 'company' => $listSupplier->getCompany(),
  413.                 'name' => $listSupplier->getName(),
  414.             );
  415.         }
  416.         /* Actualizar los costos pasando serviciosid a cero(0) */
  417.         $costs_limpiar $em->getRepository(ProposalSupplierServicesCosts::class)->findByProposalId($id);
  418.         foreach($costs_limpiar as $costslimpiarArray){
  419.             if (!in_array($costslimpiarArray->getId(), $idcostsfuera)) {
  420.                 if ($costslimpiarArray->getServicesId() != 0){
  421. //                    d($costslimpiarArray->getId(), "No Cero");
  422.                     $costslimpiarArray->setServicesId('0');
  423.                     $costslimpiarArray->setContcolor('info');
  424.                     if(!($proposal->getStatus()=='Invoiced')) {
  425.                         $em->persist($costslimpiarArray);
  426.                         $em->flush();
  427.                     }
  428.                 } else {
  429. //                    d($costslimpiarArray->getId(), "Si Cero");
  430.                 }
  431.             }
  432.         }
  433.         /* Fin Actualizar los costos pasando serviciosid a cero(0) */
  434.         return $this->render('MDS/EventsBundle/costs-supplier/update-costs-supplier.html.twig',
  435.             array(
  436.                 'id' => $id,
  437.                 'listSupplier' => $arraySupplier,
  438.                 'token' => $proposal->getAccessKey(),
  439.                 'mcp' => $proposal->getMcp(),
  440.                 'costsSupplier' => $data_supplier,
  441.                 'propEditable' => !($proposal->getStatus() == 'Invoiced'),
  442.         ));
  443.     }
  444.     public function CalculoTotalCosts($price$units$pax$days$idcat$opiva$iva)
  445.     {
  446.         //Units
  447.         if(empty($units) or $units =="0"){
  448.             $units "1";
  449.         }
  450.         // Calculo Especial por categoria
  451.         //Alojamientos
  452.         if($idcat =="1"){
  453.             $informativo_days "si";
  454.             $pax "1";
  455.         }
  456.         //Transporte
  457.         elseif($idcat =="13"){
  458.             $informativo_days "no";
  459.             $pax "1";
  460. //            if($days > "1"){
  461. //                $days = "2";
  462. //            }else{
  463. //                $days = "1";
  464. //            }
  465.         }
  466.         //Guia
  467.         elseif($idcat =="8"){
  468.             $informativo_days "no";
  469.             $pax "1";
  470.         }
  471.         //Lounge
  472.         elseif($idcat =="10"){
  473.             $informativo_days "no";
  474.             $pax "1";
  475.         }else{
  476.             $informativo_days "no";
  477.         }
  478.         //Pax
  479.         if(empty($pax) or $pax =="0"){
  480.             $pax "1";
  481.         }
  482.         if($informativo_days =="no"){
  483.             //Days
  484.             if(empty($days) or $days =="0"){
  485.                 $days "1";
  486.             }else{
  487.                 $days $days ;
  488.             }
  489.         }
  490.         /* si viene iva negativo */
  491.         if($opiva =='0'){
  492.             $iva $iva 100;
  493.             $price $price / ($iva 1);
  494.             $price round($price2);
  495.         }
  496.         $total_items $price $units $pax $days;
  497.         return $total_items;
  498.     }
  499.     /**
  500.      * @Route("/proposal/costs/supplier/updated", name="proposal_supplier_services_costs_updates", methods={"POST"})
  501.      */
  502.     public function udatedAction(Request $request)
  503.     {
  504.         $data_costs $request->request->get('costsSupplier');
  505.         $em $this->getDoctrine()->getManager();
  506.         $supplier_costs $em->getRepository(ProposalSupplierServicesCosts::class)->findOneById($data_costs['id']);
  507.         if(!is_null($data_costs))
  508.         {
  509.             /* Obtengo usuario logueado */
  510.             $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  511.             $user_id $user_logueado->getId();
  512.             $supplier_costs->setTotalServices($data_costs['total']);
  513.             $supplier_costs->setCommission($data_costs['commission']);
  514.             $supplier_costs->setOpIva($data_costs['opIva']);
  515.             $supplier_costs->setIvaServices($data_costs['iva']);
  516.             $supplier_costs->setUpdatedId($user_id);
  517.             $supplier_costs->setEdited('0');
  518.             $em->persist($supplier_costs);
  519.             $em->flush();
  520.             $event 'The cost updated in total costs supplier in Proposal.';
  521.             $successMessage $this->translator->trans($event);
  522.             $this->addFlash('mensajeproposalcostsservices'$successMessage);
  523.         }else{
  524.             $errorMessage $this->translator->trans('Error, some fields are empty');
  525.             $this->addFlash('mensajeproposalcostsservicesrror'$errorMessage);
  526.         }
  527.         return $this->redirectToRoute('proposal_supplier_services_costs',
  528.             array(
  529.                 'id' => $supplier_costs->getProposalId(),
  530.                 '_fragment' => $data_costs['id']
  531.             )
  532.         );
  533.     }
  534.     /**
  535.      * @Route("/proposal/costs/supplier/add", name="proposal_supplier_services_costs_add", methods={"POST"})
  536.      */
  537.     public function AddAction(Request $requestEntityManagerInterface $emProposalSupplierServicesService $proposalSupplierServicesService)
  538.     {
  539.         $data_costs $request->request->get('costsSupplier');
  540.         /* Obtengo usuario logueado */
  541.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  542.         $user_id $user_logueado->getId();
  543.         $response $proposalSupplierServicesService->supplierServicesCostAdd($data_costs$user_id$em);
  544.         $message $this->translator->trans($response['msg']);
  545.         $this->addFlash($response['type'], $message);
  546.         return $this->redirectToRoute('proposal_supplier_services_costs',
  547.             array(
  548.                 'id' => $data_costs['proposalId']
  549.             )
  550.         );
  551.     }
  552.     /**
  553.      * @Route("/proposal/costs/supplier/deleted/{id}", name="proposal_supplier_services_costs_deleted")
  554.      *
  555.      */
  556.     public function deleteServicesAction($idRequest $request)
  557.     {
  558.         $em $this->getDoctrine()->getManager();
  559.         $delete $em->getRepository(ProposalSupplierServicesCosts::class)->findOneById($id);
  560.         $em->remove($delete);
  561.         $em->flush();
  562.         $event 'The Costs total Supplier has been Deleted.';
  563.         $successMessage $this->translator->trans($event);
  564.         $this->addFlash('mensajeproposalcostsservices'$successMessage);
  565.         return $this->redirectToRoute('proposal_supplier_services_costs',
  566.             array(
  567.                 'id' => $delete->getProposalId()
  568.             )
  569.         );
  570.     }
  571. }