src/MDS/EventsBundle/Controller/ProposalSupplierController.php line 91

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\Activities;
  10. use App\Entity\Cities;
  11. use App\Entity\Client;
  12. use App\Entity\ClientContact;
  13. use App\Entity\Country;
  14. use App\Entity\Destination;
  15. use App\Entity\DestinationGallery;
  16. use App\Entity\Ideas;
  17. use App\Entity\ProposalsInvoiceSummary;
  18. use App\Entity\Provinces;
  19. use App\Entity\Regions;
  20. use App\Entity\RevisionCarga;
  21. use App\Entity\Supplier;
  22. use App\Entity\SupplierAccommodation;
  23. use App\Entity\SupplierActivities;
  24. use App\Entity\SupplierAv;
  25. use App\Entity\SupplierCreative;
  26. use App\Entity\SupplierCruise;
  27. use App\Entity\SupplierDescription;
  28. use App\Entity\SupplierEntertainment;
  29. use App\Entity\SupplierGallery;
  30. use App\Entity\SupplierGifts;
  31. use App\Entity\SupplierGuide;
  32. use App\Entity\SupplierIdeaServicesControl;
  33. use App\Entity\SupplierIdServices;
  34. use App\Entity\SupplierItineraries;
  35. use App\Entity\SupplierLounge;
  36. use App\Entity\SupplierMenu;
  37. use App\Entity\SupplierOthers;
  38. use App\Entity\SupplierServicesAssistant;
  39. use App\Entity\SupplierServicesControl;
  40. use App\Entity\SupplierServicesDescription;
  41. use App\Entity\SupplierTechnology;
  42. use App\Entity\SupplierTransport;
  43. use App\Entity\User;
  44. use App\MDS\AvexpressBundle\Entity\AveBriefings;
  45. use App\MDS\DevelupBundle\Entity\MdvBriefings;
  46. use App\MDS\EventsBundle\Entity\ProposalDiscount;
  47. use App\MDS\EventsBundle\Entity\ProposalFee;
  48. use App\MDS\EventsBundle\Entity\ProposalSupplierControl;
  49. use App\MDS\EventsBundle\Entity\ProposalSupplierServices;
  50. use App\MDS\EventsBundle\Form\ProposalActivitiesControlType;
  51. use App\MDS\EventsBundle\Form\ProposalDiscountType;
  52. use App\MDS\EventsBundle\Form\ProposalIdeasControlType;
  53. use App\MDS\EventsBundle\Form\ProposalSupplierControlType;
  54. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  55. use Symfony\Component\Routing\Annotation\Route;
  56. use Symfony\Component\HttpFoundation\JsonResponse;
  57. use Symfony\Component\HttpFoundation\Request;
  58. use App\MDS\EventsBundle\Entity\ProposalSupplierServicesCostsClient;
  59. use App\MDS\DevelupBundle\Entity\MdvBudgetPending;
  60. use App\MDS\DevelupBundle\Entity\MdvFiles;
  61. use App\MDS\DevelupBundle\Entity\MdvProduct;
  62. use App\MDS\DevelupBundle\Entity\MdvTelegramUser;
  63. use App\MDS\EventsBundle\Entity\Proposal;
  64. use App\MDS\EventsBundle\Entity\ProposalControl;
  65. use App\MDS\EventsBundle\Entity\ProposalsSupplierServicesAssistantName;
  66. use App\MDS\EventsBundle\Entity\ProposalSupplierServicesBudget;
  67. use App\MDS\EventsBundle\Entity\ProposalSupplierServicesCosts;
  68. use Swift_Mailer;
  69. use Swift_Message;
  70. use Swift_SmtpTransport;
  71. use Symfony\Contracts\Translation\TranslatorInterface;
  72. class ProposalSupplierController extends AbstractController
  73. {
  74.     private $translator;
  75.     public function __construct(TranslatorInterface $translator) {
  76.         $this->translator $translator;
  77.     }
  78. //    /*
  79. //    * ATENCION LAS RAIZ DE @Route POR DEFECTO DEL BUNDLE: EventsBundle ES  /events/, NO PONERLO EN LA @Route("")
  80. //    *
  81. //    * */
  82.     /**
  83.      * @Route("/proposal/destination/services/add/{id}/{status}", defaults={"status" = "All"},  name="proposal_destination_supplier_view")
  84.      */
  85.     public function viewSupplierAction($id$statusRequest $request)
  86.     {
  87.         $em $this->getDoctrine()->getManager();
  88.         $destinationCrtl $em->getRepository(ProposalControl::class)->findOneById($id);
  89.         $adicionales_destination $em->getRepository(ProposalControl::class)->findByProposalId($destinationCrtl->getProposalId());
  90.         $mostrar_destino_adicionales = array();
  91.         foreach($adicionales_destination as $adicionaldestination){
  92.             $destination $em->getRepository(Destination::class)->findOneById($adicionaldestination->getDestinationId());
  93.             $mostrar_destino_adicionales = array(
  94.                 'idcontrol' => $adicionaldestination->getId(),
  95.                 'title' => $destination->getTitle()
  96.             );
  97.         }
  98.         $destination $em->getRepository(Destination::class)->findOneById($destinationCrtl->getDestinationId());
  99.         /* Formulario Supplier*/
  100.         $controlsupplier= new ProposalSupplierControl();
  101.         $controlsupplier->setControlDestinationId($id);
  102.         $controlsupplier->setProposalId($destinationCrtl->getProposalId());
  103.         $controlsupplier->setDestinoId($destinationCrtl->getDestinationId());
  104. //        $supplier_data = $em->getRepository(Supplier::class)->findBy(
  105. //            array(
  106. //                'country' => $destination->getCountry(),
  107. //                'province' => $destination->getProvince(),
  108. //                'population' => $destination->getPopulation()
  109. //            )
  110. //        );
  111. //
  112. //        foreach($supplier_data as $supplier_pais){
  113. //            $choices_data = array(
  114. //                'choices' => array(
  115. //                    'id' => $supplier_pais->getId(),
  116. //                    'Company' => $supplier_pais->getCompany()
  117. //                )
  118. //            );
  119. //        };
  120. //        $controlsupplier->setSupplierId($choices_data);
  121.         $form $this->createDestinationProposalSupplierCreateForm($controlsupplier);
  122.         $form2 $this->createDestinationProposalIdeasCreateForm($controlsupplier);
  123.         $form4 $this->createDestinationProposalActivitiesCreateForm($controlsupplier);
  124.         $consultadiscount $em->getRepository(ProposalDiscount::class)->findByProposalId($destinationCrtl->getProposalId());
  125.         if(!empty($consultadiscount)){
  126.             foreach($consultadiscount as $consultadiscountfor){
  127.                 if(is_null($consultadiscountfor->getServiceId())){
  128.                     $consultadiscountfor->setServiceId('All');
  129.                 }else{
  130.                     $servicesName $em->getRepository(SupplierIdServices::class)->findOneById($consultadiscountfor->getServiceId());
  131.                     $consultadiscountfor->setServiceId($servicesName->getName());
  132.                 }
  133.             }
  134.         }
  135.         /* Formulario Discount*/
  136.         $discount = new ProposalDiscount();
  137.         $discount->setProposalId($destinationCrtl->getProposalId());
  138.         $form3 $this->createDiscountCreateForm($discount);
  139. //        }else{
  140. //            $consultadiscount ->setProposalId($destinationCrtl->getProposalId());
  141. //            $form3 = $this->editDiscountCreateForm($consultadiscount, $consultadiscount->getId());
  142. //        }
  143.         /* Data Proposal */
  144.         $idproposal $destinationCrtl->getProposalId();
  145.         $proposal $em->getRepository(Proposal::class)->findOneById($idproposal);
  146. //
  147. //            $commercial = $em->getRepository(User::class)->findOneById($proposal->getAgencommercialId());
  148. //            $proposal->setAgencommercialId($commercial->getName().' '.$commercial->getLastname());
  149. //
  150. //            $client = $em->getRepository(Client::class)->findOneById($proposal->getClientId());
  151. //            $proposal->setClientId($client->getName());
  152. //
  153. //            $contact = $em->getRepository(ClientContact::class)->findOneById($proposal->getContactId());
  154. //            $proposal->setContactId($contact->getName().' '.$contact->getLastname());
  155. //            $datos_contacto = array(
  156. //                'contacttelefono' => $contact->getPhone(),
  157. //                'contactemail' => $contact->getEmail(),
  158. //            );
  159. //
  160. //            if (!is_null($proposal->getTeamId())){
  161. //            $teams = $em->getRepository(SettingsTeam::class)->findOneById($proposal->getTeamId());
  162. //            $proposal->setTeamId($teams->getTeam());
  163. //            }
  164. //
  165. //            $office = $em->getRepository(SettingsOffice::class)->findOneById($proposal->getOfficeId());
  166. //            $proposal->setOfficeId($office->getOffice());
  167. //
  168. //            $agent = $em->getRepository(User::class)->findOneById($proposal->getAgentId());
  169. //            $proposal->setAgentId($agent->getName().' '.$agent->getLastname());
  170. //
  171. //                $iconstatus = "";
  172. //                switch ($proposal->getStatus()) {
  173. //                    case "Pending":
  174. //                        $iconstatus ='<i class="icon-bell3 text-danger parpadea"></i>';
  175. //                        break;
  176. //                    case "Sent":
  177. //                        $iconstatus ='<i class="icon-paperplane text-orange parpadea"></i>';
  178. //                        break;
  179. //                    case "Confirmed":
  180. //                        $iconstatus ='<i class="icon-unlocked text-success"></i>';
  181. //                        break;
  182. //                    case "Invoiced":
  183. //                        $iconstatus ='<i class="icon-lock2 text-green"></i>';
  184. //                        break;
  185. //                }
  186. //
  187. //            $proposal->SetStatus($this->translator->trans($proposal->getStatus()));
  188.         /* Data destino */
  189. //        $destination = $em->getRepository(Destination::class)->findOneById($destinationCrtl->getDestinationId());
  190.         //$destinationGallery = $em->getRepository(DestinationGallery::class)->findOneByDestinationId($destinationCrtl->getDestinationId());
  191.         $country $em->getRepository(Country::class)->findOneById($destination->getCountry());
  192.         $destination->setCountry($country->getCountry());
  193.         $regions $em->getRepository(Regions::class)->findOneById($destination->getRegion());
  194.         $destination->setRegion($regions->getRegion());
  195.         $province $em->getRepository(Provinces::class)->findOneById($destination->getProvince());
  196.         $destination->setProvince($province->getName());
  197.         $cities $em->getRepository(Cities::class)->findOneById($destination->getPopulation());
  198.         $destination->setPopulation($cities->getCity());
  199.         $mostrar_destino = array(
  200.             'idcontrol' => $destinationCrtl->getId(),
  201.             'destinoId' => $destination->getId(),
  202.             'title' => $destination->getTitle(),
  203.             //'image' => $destinationGallery->getImageSmall(),
  204.             'country' => $destination->getCountry(),
  205.             'region' => $destination->getRegion(),
  206.             'province' => $destination->getProvince(),
  207.             'population' =>$destination->getPopulation()
  208.         );
  209.         /* Data Supplier agregados */
  210. //        if($status == "All") {
  211. //            $array_ProposalSupplierControl =
  212. //                array(
  213. //                'proposalId' => $destinationCrtl->getProposalId(),
  214. //                'destinoId' => $destinationCrtl->getDestinationId()
  215. //                );
  216. //        }else{
  217. //                $array_ProposalSupplierControl = array(
  218. //                    'proposalId' => $destinationCrtl->getProposalId(),
  219. //                    'destinoId' => $destinationCrtl->getDestinationId()
  220. //                );
  221. //        }
  222. //        $service_supplier = $em->getRepository(ProposalSupplierControl::class)->findBy();
  223.         $service_supplier $em->getRepository(ProposalSupplierControl::class)->findBy(
  224.             array(
  225.                 'proposalId' => $destinationCrtl->getProposalId(),
  226.                 'destinoId' => $destinationCrtl->getDestinationId(),
  227.             ),
  228.             array(
  229.                 'rank' => 'ASC'
  230.             )
  231.         );
  232.         $totales_global_neto 0;
  233.         $totales_global_direct 0;
  234.         $totales_global_iva 0;
  235.         $totales_global_con_iva 0;
  236.         $totales_global_paying 0;
  237.         $totales_global_pago 0;
  238.         $totales_global_benefit_moneda 0;
  239.         $totales_global_benefit_porsentaje 0;
  240.         $calculos_globales = array();
  241.         $data_supplier = array();
  242.         $controlgeneral = array();
  243.         foreach($service_supplier as $suppliercontrol){
  244.             //cambiar el estatus de colores
  245.             $colorlabel "";
  246.             switch ($suppliercontrol->getStatus()) {
  247.                 case 'Pending':
  248.                     $colorlabel"bg-danger";
  249.                     break;
  250.                 case 'Confirmed':
  251.                     $colorlabel"bg-success-300";
  252.                     break;
  253.             }
  254.             $suppliercontrol->SetStatus($this->translator->trans($suppliercontrol->getStatus()));
  255.             $sqlactivities "";
  256.             if(!is_null($suppliercontrol->getActivityId())){
  257.                 $master "activity";
  258.                 $sqlactivities $em->getRepository(Activities::class)->findOneById($suppliercontrol->getActivityId());
  259.                 /*CONTROL GENERAL*/
  260.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByActivityId($suppliercontrol->getActivityId());
  261.             }
  262.             $sqlideas "";
  263.             if(!is_null($suppliercontrol->getIdeaId())){
  264.                 $master "idea";
  265.                 $sqlideas $em->getRepository(Ideas::class)->findOneById($suppliercontrol->getIdeaId());
  266.                 /*CONTROL GENERAL*/
  267.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByIdeaId($suppliercontrol->getIdeaId());
  268.             }
  269.             $sqlsuppliers ="";
  270.             if(!is_null($suppliercontrol->getSupplierId())){
  271.                 $master "supplier";
  272.                 $sqlsuppliers $em->getRepository(Supplier::class)->findOneById($suppliercontrol->getSupplierId());
  273.                 if(!is_null($sqlsuppliers)){
  274.                     switch ($sqlsuppliers->getStar()) {
  275.                         case 1:
  276.                             $sqlsuppliers->setStar('<i class="icon-star-full2"></i>');
  277.                             break;
  278.                         case 2:
  279.                             $sqlsuppliers->setStar('<i class="icon-star-full2"></i><i class="icon-star-full2"></i>');
  280.                             break;
  281.                         case 3:
  282.                             $sqlsuppliers->setStar('<i class="icon-star-full2"></i><i class="icon-star-full2"></i><i class="icon-star-full2"></i>');
  283.                             break;
  284.                         case 4:
  285.                             $sqlsuppliers->setStar('<i class="icon-star-full2"></i><i class="icon-star-full2"></i><i class="icon-star-full2"></i><i class="icon-star-full2"></i>');
  286.                             break;
  287.                         case 5:
  288.                             $sqlsuppliers->setStar('<i class="icon-star-full2"></i><i class="icon-star-full2"></i><i class="icon-star-full2"></i><i class="icon-star-full2"></i> SUP');
  289.                             break;
  290.                         case 6:
  291.                             $sqlsuppliers->setStar('<i class="icon-star-full2"></i><i class="icon-star-full2"></i><i class="icon-star-full2"></i><i class="icon-star-full2"></i><i class="icon-star-full2"></i>');
  292.                             break;
  293.                         case 7:
  294.                             $sqlsuppliers->setStar('<i class="icon-star-full2"></i><i class="icon-star-full2"></i><i class="icon-star-full2"></i><i class="icon-star-full2"></i><i class="icon-star-full2"></i> GL');
  295.                             break;
  296.                         case 8:
  297.                             $sqlsuppliers->setStar('<i class="icon-star-full2"></i><i class="icon-star-full2"></i><i class="icon-star-full2"></i><i class="icon-star-full2"></i><i class="icon-star-full2"></i> GL');
  298.                             break;
  299.                     }
  300.                 }
  301.                 /*CONTROL GENERAL*/
  302.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneBySupplierId($suppliercontrol->getSupplierId());
  303.             }
  304.             if (empty($controlgeneral)){
  305.                 $master "White";
  306.                 $idsu '0';
  307.             }else{
  308.                 $idsu $controlgeneral->getId();
  309.             }
  310.             $sqlsuppliers_gallery $em->getRepository(SupplierGallery::class)->findOneBy(
  311.                 array(
  312.                     'supplierId' => $idsu,
  313.                     'servicesCatId' => '0',
  314.                     'servicesCategory' => 'General',
  315.                     'servicesId' => '0',
  316.                     'controlId' => '0'
  317.                 )
  318.             );
  319.             if (!is_null($sqlsuppliers_gallery)){
  320.                 $imagenSmall $sqlsuppliers_gallery->getimageSmall();
  321.             }else{
  322.                 //Imagen no disponible (poner una generica)
  323.                 $imagenSmall null;
  324.             }
  325.             // SIN ORDEN
  326.             // $data_service_supplier = $em->getRepository(ProposalSupplierServices::class)->findByControlId($suppliercontrol->getId());
  327.             // CON ORDEN DESCENDENTE
  328. //                $data_service_supplier = $em->getRepository(ProposalSupplierServices::class)->findByControlId(
  329. //                    array( 'controlId' => $suppliercontrol->getId() ),
  330. //                    array( 'id' => 'DESC' )
  331. //                    );
  332.             // ORDEN DESCENDENTE Y POR SERVICES
  333.             if($status == "All"){
  334.                 $parameters = array(
  335.                     'controlId' => $suppliercontrol->getId(),
  336.                     'serviceIdFather' => '0'
  337.                 );
  338.                 $dql 'SELECT p
  339.                         FROM EventsBundle:ProposalSupplierServices p
  340.                         WHERE p.controlId = :controlId AND p.serviceIdFather = :serviceIdFather 
  341.                         ORDER BY p.rank, p.serviceCatId ASC ';
  342. //                        ORDER BY p.serviceCatId, p.rank ASC ';
  343.             }else{
  344.                 $parameters = array(
  345.                     'controlId' => $suppliercontrol->getId(),
  346.                     'serviceIdFather' => '0',
  347.                     'status' => $status
  348.                 );
  349.                 $dql 'SELECT p
  350.                         FROM EventsBundle:ProposalSupplierServices p
  351.                         WHERE p.controlId = :controlId AND p.serviceIdFather = :serviceIdFather AND p.status = :status
  352.                         ORDER BY p.rank, p.serviceCatId ASC ';
  353. //                        ORDER BY p.serviceCatId, p.rank ASC ';
  354.             }
  355. //                $dql = 'SELECT p
  356. //                        FROM EventsBundle:ProposalSupplierServices p
  357. //                        WHERE p.controlId = :controlId AND p.serviceIdFather = :serviceIdFather AND p.status in (:status)
  358. //                        ORDER BY p.serviceCatId, p.id ASC ';
  359.             $query $em->createQuery($dql)->setParameters($parameters);
  360.             $data_service_supplier $query->getResult();
  361.             $service_supplier_data = array();
  362.             $calculos_totatales = array();
  363.             $totales_neto ='0';
  364.             $total_direct ='0';
  365.             $totales_iva ='0';
  366.             $totales_con_iva ='0';
  367.             $totales_paying ='0';
  368.             $totales_pago ='0';
  369.             $totales_benefit_moneda ='0';
  370.             $totales_benefit_porsentaje ='0';
  371.             foreach($data_service_supplier as $data_service){
  372.                 $service_supplier_data_sub = array();
  373.                 $zNameSrvOrNameUsrBool false;
  374.                 //COLOR POR SERVICIO
  375.                 $contcolor ="";
  376.                 switch ($data_service->getServiceCatName()) {
  377.                     case "Accommodation":
  378.                         $contcolor 'teal';
  379.                         break;
  380.                     case "Menu" :
  381.                         $contcolor 'purple';
  382.                         break;
  383.                     case "Lounge":
  384.                         $contcolor 'warning';
  385.                         break;
  386.                     case "Activities":
  387.                         $contcolor 'blue';
  388.                         break;
  389.                     case "Itineraries":
  390.                         $contcolor 'indigo';
  391.                         break;
  392.                     case "Cruise":
  393.                         $contcolor 'brown';
  394.                         break;
  395.                     case "Transport":
  396.                         $contcolor 'grey';
  397.                         break;
  398.                     case "Av":
  399.                         $contcolor 'slate';
  400.                         break;
  401.                     case "Creative":
  402.                         $contcolor 'orange';
  403.                         break;
  404.                     case "Gifts":
  405.                         $contcolor 'pink';
  406.                         break;
  407.                     case "Entertainment":
  408.                         $contcolor 'green';
  409.                         break;
  410.                     case "Guide":
  411.                         $contcolor 'orange';
  412.                         break;
  413.                     case "Others":
  414.                         $contcolor 'danger';
  415.                         break;
  416.                     case "Technology":
  417.                         $contcolor 'slate-800';
  418.                         break;
  419.                     case "Assistant":
  420.                         $contcolor 'indigo-800';
  421.                         $prpSupSrv $em->getRepository(ProposalsSupplierServicesAssistantName::class)->findOneByPrpSupSrvId($data_service->getId());
  422.                         $zNameSrvOrNameUsrBool = !empty($prpSupSrv);
  423.                         break;
  424.                     case "DDR":
  425.                         $contcolor 'green-300';
  426.                         break;
  427.                 }
  428.                 $servicesbudgetconfirm $em->getRepository(ProposalSupplierServicesBudget::class)->findOneBy(
  429.                     array(
  430.                         'itemsServiceId' => $data_service->getId(),
  431.                         'proposalId' => $data_service->getProposalId(),
  432.                         'status' => 'Confirmed',
  433.                     ),
  434.                     array(
  435.                         'updatedAt' => 'DESC'
  436.                     )
  437.                 );
  438.                 if (is_null($servicesbudgetconfirm)){
  439.                     $servicesbudgetconfirm = array();
  440.                 }
  441.                 $idcat $data_service->getServiceCatId();
  442.                 $price = empty($data_service->getPrice())? $data_service->getPrice();
  443.                 $precommission $data_service->getPreCommission();
  444.                 $preiva $data_service->getPreIva();
  445.                 $units $data_service->getUnits();
  446.                 $pax $data_service->getPax();
  447.                 $opcommission $data_service->getOpCommission();
  448.                 $commission $data_service->getCommission();
  449.                 $opover $data_service->getOpOver();
  450.                 $over $data_service->getOver();
  451.                 $opiva $data_service->getOpIva();
  452.                 $iva = empty($data_service->getIva())? $data_service->getIva();
  453.                 $dateInAt $data_service->getDateInAt();
  454.                 $dateOutAt $data_service->getDateOutAt();
  455.                 if (!is_null($dateInAt) and !is_null($dateOutAt)){
  456.                     $days $dateInAt->diff($dateOutAt);
  457.                     $day $days->days;
  458.                 }else{
  459.                     $day "0";
  460.                 }
  461.                 $directPayment $data_service->getDirectPayment();
  462.                 if(!is_null($data_service->getSupplierId())){
  463.                     $name_supplier $em->getRepository(Supplier::class)->findOneById($data_service->getSupplierId());
  464.                     if (empty($name_supplier)){
  465.                         $namesupplier '';
  466.                     }else{
  467.                         $namesupplier $name_supplier->getName();
  468.                     }
  469.                 }
  470.                 if(!is_null($data_service->getActivityId())){
  471.                     $name_supplier $em->getRepository(Activities::class)->findOneById($data_service->getActivityId());
  472.                     if (empty($name_supplier)){
  473.                         $namesupplier '';
  474.                     }else{
  475.                         $namesupplier $name_supplier->getName();
  476.                     }
  477.                 }
  478.                 if(!is_null($data_service->getIdeaId())){
  479.                     $name_supplier $em->getRepository(Ideas::class)->findOneById($data_service->getIdeaId());
  480.                     if (empty($name_supplier)){
  481.                         $namesupplier '';
  482.                     }else{
  483.                         $namesupplier $name_supplier->getName();
  484.                     }
  485.                 }
  486.                 $calculos $this->CalculoTotalesservices($price$precommission$preiva$units$pax$day$opcommission$commission$opover$over$opiva$iva$directPayment$idcat);
  487. //                /*CONTROL GENERAL*/
  488. //                $controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneBySupplierId($data_service->getSupplierId());
  489.                 if (empty($controlgeneral)){
  490.                     $control_general '0';
  491.                 }else{
  492.                     $control_general $controlgeneral->getId();
  493.                 }
  494.                 $service_supplier_data[] = array(
  495.                     'calculos' => $calculos,
  496.                     'services_data' => $data_service,
  497.                     'controlBoolNameSrvOrNameUsrBool' => $zNameSrvOrNameUsrBool,
  498.                     'controlGeneralId' => $control_general,
  499.                     'inBudget' => $servicesbudgetconfirm,
  500.                     'namesupplier' => $namesupplier,
  501.                     'contcolor' => $contcolor,
  502.                     'servicesSub' =>$service_supplier_data_sub
  503.                 );
  504.                 if($data_service->getBreakdown() == false){
  505.                     $totales_neto += $calculos['total_neto'];
  506.                     $total_direct += $calculos['total_direct'];
  507.                     $totales_iva += $calculos['sub_total_iva'];
  508.                     $totales_con_iva += $calculos['total'];
  509.                     $totales_paying += $calculos['total_paying'];
  510.                     $totales_pago += $calculos['total_pago'];
  511.                     $totales_benefit_moneda += $calculos['benefit_moneda'];
  512.                 }else{
  513. //                    $totales_neto += $totales_neto_sub ;
  514. //                    $totales_iva += $totales_iva_sub ;
  515. //                    $totales_con_iva += $totales_con_iva_sub;
  516. //                    $totales_paying += $totales_paying_sub;
  517. //                    $totales_pago += $totales_pago_sub;
  518. //                    $totales_benefit_moneda += $totales_benefit_moneda_sub;
  519.                 }
  520.                 $totales_global_neto += $calculos['total_neto'];
  521.                 $totales_global_direct += $calculos['total_direct'];
  522.                 $totales_global_iva += $calculos['sub_total_iva'];
  523.                 $totales_global_con_iva += $calculos['total'];
  524.                 $totales_global_paying += $calculos['total_paying'];
  525.                 $totales_global_pago += $calculos['total_pago'];
  526.                 $totales_global_benefit_moneda += $calculos['benefit_moneda'];
  527.                 if ($totales_benefit_moneda == '0'){
  528.                     $totales_benefit_porsentaje =  '0';
  529.                 }else{
  530.                     $totales_benefit_porsentaje =  $totales_benefit_moneda $total_direct 100// arreglado or estevan
  531.                 }
  532.                 if ($totales_global_benefit_moneda == '0'){
  533.                     $totales_global_benefit_porsentaje =  '0';
  534.                 }else{
  535.                     $totales_global_benefit_porsentaje =  $totales_global_benefit_moneda $totales_global_direct 100// arreglado or estevan
  536.                 }
  537.             }
  538.             $calculos_totatales = array(
  539.                 'totales_neto' => $totales_neto,
  540.                 'totales_iva' => $totales_iva,
  541.                 'totales_con_iva' => $totales_con_iva,
  542.                 'totales_paying' => $totales_paying,
  543.                 'totales_benefit_moneda' => $totales_benefit_moneda,
  544.                 'totales_benefit_porsentaje' => $totales_benefit_porsentaje
  545.             );
  546.             if (!empty($sqlsuppliers)){
  547.                 $briefings null;
  548.                 if ($sqlsuppliers->getId() == 2){
  549.                     // Buscamos los briefings de Develup
  550.                     $briefings $em->getRepository(MdvBriefings::class)->findByProposalId($idproposal);
  551.                 }
  552.                 if ($sqlsuppliers->getId() == 80){
  553.                     // Buscamos los briefings de Av Express
  554.                     $briefings $em->getRepository(AveBriefings::class)->findByProposalId($idproposal);
  555.                 }
  556.             } else { $briefings null; }
  557.             $data_supplier[] = array(
  558.                 'colorlabel' => $colorlabel,
  559.                 'control' => $suppliercontrol,
  560.                 'master' => $master,
  561.                 'supplier' => $sqlsuppliers,
  562.                 'briefings' => $briefings,
  563.                 'idea' => $sqlideas,
  564.                 'activity' => $sqlactivities,
  565.                 'image' => $imagenSmall,
  566.                 'services' => $service_supplier_data,
  567.                 'totales_services' => $calculos_totatales
  568.             );
  569.         }
  570.         $calculos_globales = array(
  571.             'totales_global_neto' => $totales_global_neto,
  572.             'totales_global_iva' => $totales_global_iva,
  573.             'totales_global_con_iva' => $totales_global_con_iva,
  574.             'totales_global_paying' => $totales_global_paying,
  575.             'totales_global_benefit_moneda' => $totales_global_benefit_moneda,
  576.             'totales_global_benefit_porsentaje' => $totales_global_benefit_porsentaje,
  577.         );
  578.         /*Supplier list*/
  579.         $list_Supplier $em->getRepository(Supplier::class)->findAll();
  580.         $arraySupplier =array();
  581.         foreach($list_Supplier as $listSupplier) {
  582.             $arraySupplier[] = array(
  583.                 'id' => $listSupplier->getId(),
  584.                 'company' => $listSupplier->getCompany(),
  585.                 'name' => $listSupplier->getName(),
  586.             );
  587.         }
  588.         /*User list*/
  589.         $list_User $em->getRepository(User::class)->findAll();
  590.         $arrayUser =array();
  591.         foreach($list_User as $listUser) {
  592.             $arrayUser[] = array(
  593.                 'id' => $listUser->getId(),
  594.                 'name' => $listUser->getName().' '.$listUser->getLastname()
  595.             );
  596.         }
  597.         $fee $em->getRepository(ProposalFee::class)->findByProposalId($idproposal);
  598.         $summaryInvoice $em->getRepository(ProposalsInvoiceSummary::class)->findOneByProposalId($idproposal);
  599.         return $this->render('MDS/EventsBundle/services/services-destination-proposal.html.twig',
  600.             array(
  601.                 'id' => $idproposal,
  602.                 'proname' => $proposal->getName(),
  603.                 'token' => $proposal->getAccessKey(),
  604.                 'mcp' => $proposal->getMcp(),
  605.                 'proposal' => $proposal,
  606. //                'proposal_icostatus' => $iconstatus,
  607. //                'datacontact' => $datos_contacto,
  608.                 'destination' => $mostrar_destino,
  609.                 'adicionaldestination' => $mostrar_destino_adicionales,
  610.                 'form' => $form->createView(),
  611.                 'form2' => $form2->createView(),
  612.                 'form3' => $form3->createView(),
  613.                 'form4' => $form4->createView(),
  614.                 'discounts' => $consultadiscount,
  615.                 'fees' => $fee,
  616.                 'summaryInvoice' => $summaryInvoice,
  617.                 'datasupplier' => $data_supplier,
  618.                 'listSupplier' => $arraySupplier,
  619.                 'listUser' => $arrayUser,
  620.                 'status' => $status,
  621.                 'global_calculos' => $calculos_globales
  622.             )
  623.         );
  624.     }
  625.     public function CalculoTotalesservices($price$precommission$preiva$units$pax$days$opcommission$commission$opover$over$opiva$iva$directPayment$idcat)
  626.     {
  627.         $price trim($price);
  628.         $over trim($over);
  629.         $price str_replace(",""."$price);
  630.         $over str_replace(",""."$over);
  631.         
  632.         if (empty($iva)){$iva=0;}
  633.         $iva $iva 100;
  634.         if($opiva =='0'){
  635.             $price $price / ($iva 1);
  636.         }
  637. //        if($opiva =='1'){
  638. //            $price = $price * ($iva + 1);
  639. //        }
  640.         if(!empty($commission)){
  641.             if($opcommission=='1'){
  642.                 $commission = ($commission 100) + 1;
  643.             }
  644.             if($opcommission=='0'){
  645.     //            $price = $price * 0.9;
  646.                 $commission = (100 $commission) / 100;
  647.                 $price $price $commission;
  648.             }
  649.         }
  650.         //Units
  651.         if(empty($units) or $units =="0"){
  652.             $units "1";
  653.         }
  654.         // Calculo Especial por categoria
  655.         //Alojamientos
  656.         if($idcat =="1"){
  657.             $informativo_days "si";
  658.             $pax "1";
  659.         }
  660.         //Transporte
  661.         elseif($idcat =="13"){
  662.             $informativo_days "no";
  663.             $pax "1";
  664.         }
  665.         //Guia
  666.         elseif($idcat =="8") {
  667.             $informativo_days "no";
  668.             $pax "1";
  669.         }
  670.         //Lounge
  671.         elseif($idcat =="10"){
  672.             $informativo_days "no";
  673.             $pax "1";
  674.         }else{
  675.             $informativo_days "no";
  676.         }
  677.         //Pax
  678.         if(empty($pax) or $pax =="0"){
  679.             $pax "1";
  680.         }
  681.         //Over
  682.         if(empty($over)){
  683.             $over "0";
  684.         }
  685.         if($informativo_days =="no"){
  686.             //Days
  687.             if(empty($days) or $days =="0"){
  688.                 $days "1";
  689.             }else{
  690.                 $days $days ;
  691.             }
  692.         }
  693.         $total_items $price $units $pax $days;
  694.         $total_pdirect $price $units $pax $days;
  695.         $total_over $over $units $pax $days;
  696. //        if($opover=='0' and !empty($over)){
  697. ////            $total_neto = $total_items * ($commission + 1) - $total_over ;
  698. ////            $total_neto = $total_items / 0.9 - $total_over ;
  699. //            $total_neto = $total_items / $commission - $total_over ;
  700. //        }
  701. //        if($opover=='1' or (empty($over) or $over == "0")){
  702. ////            $total_neto = $total_items * ($commission + 1) + $total_over;
  703. ////            $total_neto = $total_items / 0.9 + $total_over;
  704. //            $total_neto = $total_items * $commission + $total_over;
  705. //        }
  706.         if(!empty($commission)){
  707.             if($opcommission=='0'){
  708.                 $total_neto $total_items $commission;
  709.             }
  710.             if($opcommission=='1'){
  711.                 $total_neto $total_items $commission;
  712.             }
  713.         }else{
  714.             $total_neto $total_items;
  715.         }
  716.         if($opover=='0'){
  717.             $total_neto $total_neto $total_over ;
  718.         }
  719.         if($opover=='1'){
  720.             $total_neto $total_neto +  $total_over;
  721.         }
  722. //        $total_neto = $total_items * ($commission + 1);
  723.         $total_paying $total_items * ($iva 1);
  724.         $total_comision ="0";
  725. //        $total_pago = $total_items + $total_comision;
  726.         $total_pago $total_items;
  727.         $total_iva $total_items $iva;
  728.         $sub_total_iva $total_neto $iva;
  729.         $total $total_neto $sub_total_iva;
  730.         $benefit_moneda $total_neto $total_items;
  731. //        if ($directPayment == true){
  732. //            $benefit_moneda = $total_neto;
  733. //            $total_paying = "0";
  734. //        }else{
  735. //            $benefit_moneda = $total_neto - $total_items;
  736. //        }
  737.         $total_direct $total_neto;
  738.         if ($directPayment == true){
  739.             $total_neto "0";
  740.             $total "0";
  741.             $total_paying "0";
  742.             $total_pago "0";
  743.             $sub_total_iva "0";
  744.         }
  745.         $data_calculos = array(
  746.             'total_days' => $days,
  747.             'sub_total' => $total_items,
  748.             'sub_total_iva' => $sub_total_iva,
  749.             'total_neto' => $total_neto,
  750.             'total_direct' => $total_direct,
  751.             'total_iva' => $total_iva,
  752.             'total_paying' => $total_paying,
  753.             'total_pago' => $total_pago,
  754.             'total_comision' => $total_comision,
  755.             'total' => $total,
  756.             'benefit_moneda' => $benefit_moneda
  757.         );
  758. //        d($data_calculos);
  759.         return $data_calculos;
  760.     }
  761.     /* CREAR DESDE UN SUPPLIER ESPECIAL*/
  762.     /**
  763.      * @Route("/proposal/destination/servicesesp/create/{cdid}/{pid}/{did}/{sid}", name="proposal_destination_supplier_create_especial")
  764.      */
  765.     public function createProposalDestinationEspecialAction($cdid$pid$did$sidRequest $request)
  766.     {
  767.         $em $this->getDoctrine()->getManager();
  768.         $control_verifico $em->getRepository(ProposalSupplierControl::class)->findOneBy(
  769.             array(
  770.                 'controlDestinationId' => $cdid,
  771.                 'proposalId' => $pid,
  772.                 'destinoId' => $did,
  773.                 'supplierId' => $sid,
  774.             )
  775.         );
  776. //        $proposal = $em->getRepository(Proposal::class)->findOneById($pid);
  777.         if(empty($control_verifico)){
  778.             if(!empty($cdid) and !empty($pid) and !empty($did) and !empty($sid))
  779.             {
  780.                 $control = new ProposalSupplierControl();
  781.                 $control->setControlDestinationId($cdid);
  782.                 $control->setProposalId($pid);
  783.                 $control->setDestinoId($did);
  784.                 $control->setSupplierId($sid);
  785.                 $control->setStatus('Pending');
  786.                 $em->persist($control);
  787.                 $em->flush();
  788.                 // INICIO: Envio de Correo a AV EXPRESS o DEVELUP SOLUTIONS
  789.                 if ($sid == 80 or $sid == 2) {
  790.                     // Es un servicio de proveedor AV EXPRESS o DEVELUP
  791.                     $proposal $em->getRepository(Proposal::class)->findOneById($pid);
  792.                     $zclient $em->getRepository(Client::class)->findOneById($proposal->getClientId());
  793.                     $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  794.                     $user_id $user_logueado->getId();
  795.                     $agentUser $em->getRepository(User::class)->findOneById($user_id);
  796.                     $agent $em->getRepository(User::class)->findOneById('20');
  797.                     $mailAgent[] = $agent->getEmail();
  798.                     $agentMail $agent->getEmail();
  799.                     $zagentReplyTo = array(
  800.                         $agent->getEmail() => $agent->getName() . ' ' $agent->getLastName()
  801.                     );
  802.                     $firmGmail $agent->getFirmGmail();
  803.                     if ($sid == 80 ) {
  804.                         // AV Express
  805.                         $mailAgentSent = array(
  806. //                            $zclient->getEmail() => $zclient->getName()
  807. //                            'gustavo.ayala@develup.solutions' => $zclient->getName()
  808.                               'salvador@avexpress.tv' => $zclient->getName()
  809.                         );
  810.                         $empresa $em->getRepository(Supplier::class)->findOneById('80');
  811.                     } else {
  812.                         // Develup
  813.                         $mailAgentSent = array(
  814.                             'jorge.defreitas@develup.solutions' => $zclient->getName()
  815. //                            'gustavo.ayala@develup.solutions' => $zclient->getName()
  816.                         );
  817.                         $empresa $em->getRepository(Supplier::class)->findOneById('2');
  818.                     }
  819.                     $mailAgentFrom = array(
  820.                         $agent->getEmail() => $agent->getName() . ' ' $agent->getLastName()
  821.                     );
  822.                     $data = array(
  823.                         'body' => '' '<p>Estimado proveedor,</p><p>'$empresa->getName() .' ha sido dada de alta como uno de los proveedores para la propuesta: &nbsp;</p>                        
  824.                         <p><a href="inout.mante.solutions/events/proposal/edit/' $proposal->getId() .'">' $proposal->getTitle() . '</a></p>
  825.                         <p>El usuario que hizo esta incorporación fue: ' $agentUser->getName() .' '$agentUser->getLastName() . '</p>'
  826.                     ,
  827. //                        'firm' => '' . '<div dir="ltr" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8px;"><table border="0" cellpadding="0" style="font-size: 13.3333px; font-family: Verdana, Arial, Helvetica, sans-serif;"><tbody><tr><td width="35%" style="font-family: arial, sans-serif; margin: 0px;"><img src="https://ci4.googleusercontent.com/proxy/xTPcHPPSpFqSf8EjRTvJIv21y6LHuzwbsDqBA4oxRzrrUZQWNYERW7oMbgXjw6CzSDsE9QqPHEk9PiNylx5UaAuSJykk6eA3WiyMGmZmQYc=s0-d-e1-ft#http://www.inout-travel.com/inout-travel/img/logo/logo.jpg" alt="Logo InOut Travel" class="CToWUd"></td><td width="65%" style="font-family: arial, sans-serif; margin: 0px;"><p style="margin-bottom: 0px;"></p><span style="font-size: small; color: rgb(0, 121, 186);"><b>M.I.C.E Dept.</b>&nbsp;<br></span><span style="font-size: x-small; color: rgb(0, 121, 186);">Phone :&nbsp;<a href="tel:+34%20911%2087%2083%2093" value="+34911878393" target="_blank" style="color: rgb(17, 85, 204);">+34 91 187 83 93</a>&nbsp;/&nbsp;<a href="tel:+34%20917%2058%2007%2020" value="+34917580720" target="_blank" style="color: rgb(17, 85, 204);">+34 91 758 07 20</a>&nbsp;</span><span style="font-size: x-small; color: rgb(0, 121, 186);">Fax :&nbsp;<a href="tel:+34%20911%2087%2083%2090" value="+34911878390" target="_blank" style="color: rgb(17, 85, 204);">+34 91 187 83&nbsp;90</a>&nbsp;<br></span><span style="font-size: x-small; color: rgb(0, 121, 186);"><u></u><a href="mailto:eventos@inout-travel.com" target="_blank" style="color: rgb(17, 85, 204);">eventos@inout-travel.com&nbsp;</a><br></span><span style="font-size: small; color: rgb(0, 128, 128);"><a href="http://s.wisestamp.com/links?url=http%3A%2F%2Fs.wisestamp.com%2Flinks%3Furl%3Dhttps%253A%252F%252Furldefense.proofpoint.com%252Fv1%252Furl%253Fu%253Dhttp%253A%252F%252Fs.wisestamp.com%252Flinks%253Furl%25253Dhttp%2525253A%2525252F%2525252Fs.wisestamp.com%2525252Flinks%2525253Furl%2525253Dhttp%252525253A%252525252F%252525252Fwww.inout-travel.com%25252526amp%2525253Bsn%2525253D%252526sn%25253D%2526amp%253Bk%253D2BjihEEf49EEnl2c9cXhDQ%25253D%25253D%25250A%2526amp%253Br%253DoVBgYJTSgqKobIhrxHXwWFa1hslDOFZMhTZjQm3slhE%25253D%25250A%2526amp%253Bm%253DiRaDYfk0sXIZzunVdLJPLTs52u8wk7HMfjdCh290Q5I%25253D%25250A%2526amp%253Bs%253D1a9ff7d8f4f1fb953d74200f6537f77ca64418a966d39f4786e9aed71833d44c%26amp%3Bsn%3D&amp;sn=" target="_blank" data-saferedirecturl="https://www.google.com/url?hl=es&amp;q=http://s.wisestamp.com/links?url%3Dhttp%253A%252F%252Fs.wisestamp.com%252Flinks%253Furl%253Dhttps%25253A%25252F%25252Furldefense.proofpoint.com%25252Fv1%25252Furl%25253Fu%25253Dhttp%25253A%25252F%25252Fs.wisestamp.com%25252Flinks%25253Furl%2525253Dhttp%252525253A%252525252F%252525252Fs.wisestamp.com%252525252Flinks%252525253Furl%252525253Dhttp%25252525253A%25252525252F%25252525252Fwww.inout-travel.com%2525252526amp%252525253Bsn%252525253D%25252526sn%2525253D%252526amp%25253Bk%25253D2BjihEEf49EEnl2c9cXhDQ%2525253D%2525253D%2525250A%252526amp%25253Br%25253DoVBgYJTSgqKobIhrxHXwWFa1hslDOFZMhTZjQm3slhE%2525253D%2525250A%252526amp%25253Bm%25253DiRaDYfk0sXIZzunVdLJPLTs52u8wk7HMfjdCh290Q5I%2525253D%2525250A%252526amp%25253Bs%25253D1a9ff7d8f4f1fb953d74200f6537f77ca64418a966d39f4786e9aed71833d44c%2526amp%253Bsn%253D%26sn%3D&amp;source=gmail&amp;ust=1516881697636000&amp;usg=AFQjCNGFDs4JRUVibUfVQaFSuQ0u9PVwzQ" style="color: rgb(17, 85, 204); font-size: x-small;">http://www.inout-travel.com</a></span><p></p><span style="font-size: small; color: rgb(51, 102, 255);"><a href="https://www.facebook.com/InOutTravel/" target="_blank" data-saferedirecturl="https://www.google.com/url?hl=es&amp;q=https://www.facebook.com/InOutTravel/&amp;source=gmail&amp;ust=1516881697636000&amp;usg=AFQjCNH3zSTpYN6Jn0ibd4io116DlxPPNg" style="color: rgb(17, 85, 204);"><span style="color: rgb(51, 102, 255);"><img src="https://ci5.googleusercontent.com/proxy/8luozs3Ef6tofaP9YvpFMJfUFEqz1QLUJ4pmjmbiZBmIbtfxbFDGS7mVrEd2y32b_P4vDTb14QmA1gowrSAKvtWxet9R3_02VVFOV4S3mKU=s0-d-e1-ft#https://s3.amazonaws.com/images.wisestamp.com/facebook.png" alt="Facebook" width="16" height="16" border="0" class="CToWUd"></span></a><span lang="ES">&nbsp;</span><a href="https://twitter.com/inout_travel?lang=es" target="_blank" data-saferedirecturl="https://www.google.com/url?hl=es&amp;q=https://twitter.com/inout_travel?lang%3Des&amp;source=gmail&amp;ust=1516881697636000&amp;usg=AFQjCNEe-ltzYrhEmNPcORkqhPnlInLutw" style="color: rgb(17, 85, 204);"><span style="color: rgb(51, 102, 255);"><img src="https://ci5.googleusercontent.com/proxy/6sqL0BxRRr4QwfAOhK_hNNAXIpUHZNg-gl3CPQKITbX2dpT2jMTzf3zlwMmhB9BgxZehJzFQT_AJzsskN1uQR-SqppTRLIbJIILDeDNjlA=s0-d-e1-ft#https://s3.amazonaws.com/images.wisestamp.com/twitter.png" alt="Twitter" width="16" height="16" border="0" class="CToWUd"></span></a><span lang="ES">&nbsp; &nbsp;</span><span style="color: rgb(255, 102, 0);"><strong><span lang="ES">Visítanos en las redes sociales!!</span></strong></span></span></td></tr></tbody></table><img src="https://ci4.googleusercontent.com/proxy/rDdypMfZKWPkRRuCB3bp8PSQXo0k5aswGQRjFzy71EB2XEQkr4_rbaroShG2FEJbnrmwoEfE3-Z6r_hNFlfRMNPC1X8yjwJ2eOmZ1DagWHkl8sh7Y60=s0-d-e1-ft#http://www.inout-travel.com/inout-travel/img/logo/firma_MICE.png" class="CToWUd"><br><div></div></div><div dir="ltr" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8px;"><p style="text-align: justify; text-indent: 7.1pt; line-height: 14.72px;"><span style="font-size: 10pt; line-height: 15.3333px; font-family: Arial, sans-serif;">De conformidad con lo dispuesto en la Ley Orgánica 15/1999 de Protección de Datos de carácter Personal VIAJES IN OUT TRAVEL, S.L., domiciliado en&nbsp;</span><a href="https://maps.google.com/?q=C/+CRISTOBAL+BORDIU,+53+-+28003+MADRID&amp;entry=gmail&amp;source=g" target="_blank" data-saferedirecturl="https://www.google.com/url?hl=es&amp;q=https://maps.google.com/?q%3DC/%2BCRISTOBAL%2BBORDIU,%2B53%2B-%2B28003%2BMADRID%26entry%3Dgmail%26source%3Dg&amp;source=gmail&amp;ust=1516881697636000&amp;usg=AFQjCNFHPMBadB0TD0U63EsqPiOZ7TPldg" style="color: rgb(17, 85, 204);"><span style="font-size: 10pt; line-height: 15.3333px; font-family: Arial, sans-serif;">C/ CRISTOBAL BORDIU, 53 - 28003 MADRID</span></a><span style="font-size: 10pt; line-height: 15.3333px; font-family: Arial, sans-serif;">, le informa que los datos que nos ha proporcionado formarán parte de un fichero de datos de carácter personal, responsabilidad de dicha entidad, con la finalidad de gestionar las comunicaciones que pudiera mantener con el personal de la misma.</span></p><p style="text-align: justify; text-indent: 7.1pt; line-height: 14.72px;"><span style="font-size: 10pt; line-height: 15.3333px; font-family: Arial, sans-serif;">En el supuesto de que desee ejercitar los derechos que le asisten de acceso, rectificación, cancelación y oposición dirija una comunicación por escrito a VIAJES IN OUT TRAVEL, S.L. a la dirección&nbsp;</span><a href="https://maps.google.com/?q=C/+CRISTOBAL+BORDIU,+53+-+28003+MADRID&amp;entry=gmail&amp;source=g" target="_blank" data-saferedirecturl="https://www.google.com/url?hl=es&amp;q=https://maps.google.com/?q%3DC/%2BCRISTOBAL%2BBORDIU,%2B53%2B-%2B28003%2BMADRID%26entry%3Dgmail%26source%3Dg&amp;source=gmail&amp;ust=1516881697636000&amp;usg=AFQjCNFHPMBadB0TD0U63EsqPiOZ7TPldg" style="color: rgb(17, 85, 204);"><span style="font-size: 10pt; line-height: 15.3333px; font-family: Arial, sans-serif;">C/ CRISTOBAL BORDIU, 53 - 28003 MADRID</span></a><span style="font-size: 10pt; line-height: 15.3333px; font-family: Arial, sans-serif;">&nbsp;&nbsp;incluyendo copia de su Documento Nacional de Identidad o documento identificativo equivalente, Ã³ a través de un mensaje de correo electrónico a la dirección&nbsp;</span><a href="mailto:info@inout-travel.com" target="_blank" style="color: rgb(17, 85, 204);"><b><span style="font-size: 10pt; line-height: 15.3333px; font-family: Arial, sans-serif;">info@inout-travel.com</span></b></a><b><span style="font-size: 10pt; line-height: 15.3333px; font-family: Arial, sans-serif;">.</span></b></p><p style="text-align: justify; text-indent: 7.1pt; line-height: 14.72px;"><span style="font-size: 10pt; line-height: 15.3333px; font-family: Arial, sans-serif;">La información contenida en el presente mensaje de correo electrónico es confidencial y su acceso Ãºnicamente está autorizado al destinatario original del mismo, quedando prohibida cualquier comunicación, divulgación, o reenvío, tanto del mensaje como de su contenido. En el supuesto de que usted no sea el destinatario autorizado, le rogamos borre el contenido del mensaje y nos comunique dicha circunstancia a través de un mensaje de correo electrónico a la dirección&nbsp;</span><a href="mailto:info@inout-travel.com" target="_blank" style="color: rgb(17, 85, 204);"><b><span style="font-size: 10pt; line-height: 15.3333px; font-family: Arial, sans-serif;">info@inout-travel.com</span></b></a><span style="font-size: 10pt; line-height: 15.3333px; font-family: Arial, sans-serif;">&nbsp;o al teléfono<b>&nbsp;</b></span><a href="tel:911%2087%2083%2091" target="_blank" style="color: rgb(17, 85, 204);"><b><span style="font-size: 10pt; line-height: 15.3333px; font-family: Arial, sans-serif;">+34&nbsp;</span></b></a><b><span style="font-size: 10pt; line-height: 15.3333px; font-family: Arial, sans-serif;">&nbsp;</span></b><a href="tel:917%2058%2007%2085" target="_blank" style="color: rgb(17, 85, 204);"><b><span style="font-size: 10pt; line-height: 15.3333px; font-family: Arial, sans-serif;">917580785</span></b></a><span style="font-size: 10pt; line-height: 15.3333px; font-family: Arial, sans-serif;">.</span></p></div>',
  828.                         'firm' => '',
  829.                     );
  830.                     // EJECUTAR ENVIO DE ALERTA PARA EL AGENTE
  831.                     $transporter = new Swift_SmtpTransport();
  832.                     $transporter->setHost('smtp.gmail.com')
  833.                         ->setEncryption('ssl')//ssl / tls
  834.                         ->setPort(465)// 465 / 587
  835.                         ->setUsername('desarrollo@develup.solutions')
  836.                         ->setPassword('utvh hzoi wfdo ztjs');
  837.                     $mailer = new Swift_Mailer($transporter);
  838.                     $message = new Swift_Message();
  839.                     $message->setSubject('P#' $proposal->getId() . ', Alta de servicio')
  840.                         ->setFrom(array("desarrollo@develup.solutions" => "System Mante 3.0"))
  841.                         ->setReplyTo($zagentReplyTo)
  842.                         ->setTo($mailAgentSent)
  843.                         ->setBody(
  844.                             $this->renderView(
  845.                                 'mail/structure-mail.html.twig',
  846.                                 array('data' => $data)
  847.                             ),
  848.                             'text/html'
  849.                         );
  850.                     $mailer->send($message);
  851.                 }
  852.                 // FIN: Envio de Correo a AV EXPRESS o DEVELUP SOLUTIONS
  853.                 $event 'The Supplier Destination Proposal has been created.';
  854.                 $successMessage $this->translator->trans($event);
  855.                 $this->addFlash('mensajeproposaldestinationservices'$successMessage);
  856.                 return $this->redirectToRoute('proposal_destination_supplier_especial_list', array(
  857.                     'idcontrol' => $control->getId()
  858.                 ));
  859.             }else{
  860.                 $errorMessage $this->translator->trans('Error, some fields are empty');
  861.                 $this->addFlash('mensajeproposaldestinationserviceserror'$errorMessage);
  862.             }
  863.         }else{
  864. //            $errorMessage = $this->translator->trans('The proposal already has this provider included');
  865. //            $this->addFlash('mensajeproposaldestinationserviceserror', $errorMessage);
  866.             return $this->redirectToRoute('proposal_destination_supplier_especial_list', array(
  867.                 'idcontrol' => $control_verifico->getId()
  868.             ));
  869.         }
  870.         return $this->redirectToRoute('proposal_destination_supplier_view', array(
  871.             'id' => $cdid,
  872.             '_fragment' => 's'.$control_verifico->getId()
  873.         ));
  874.     }
  875.     /* CREAR DESDE UN SUPPLIER */
  876.     private function createDestinationProposalSupplierCreateForm(ProposalSupplierControl $entity)
  877.     {
  878.         $form $this->createForm(ProposalSupplierControlType::class, $entity, array(
  879.             'action' => $this->generateUrl('proposal_destination_supplier_create'),
  880.             'method' => 'POST'
  881.         ));
  882.         return $form;
  883.     }
  884.     /* CREAR DESDE UN SUPPLIER */
  885.     /**
  886.      * @Route("/proposal/destination/services/create", name="proposal_destination_supplier_create")
  887.      */
  888.     public function createProposalDestinationAction(Request $request)
  889.     {
  890.         $control = new ProposalSupplierControl();
  891.         $form $this->createDestinationProposalSupplierCreateForm($control);
  892.         $form->handleRequest($request);
  893.         $supplier_proposal $form->get('supplierId')->getData();
  894.         if(!is_null($supplier_proposal)){
  895.             $control->setSupplierId($supplier_proposal->getId());
  896.         }
  897.         $em $this->getDoctrine()->getManager();
  898.         $control_verifico $em->getRepository(ProposalSupplierControl::class)->findOneBy(
  899.             array(
  900.                 'controlDestinationId' => $form->get('controlDestinationId')->getData(),
  901.                 'proposalId' => $form->get('proposalId')->getData(),
  902.                 'destinoId' => $form->get('destinoId')->getData(),
  903.                 'supplierId' => $supplier_proposal->getId(),
  904.             )
  905.         );
  906.         $proposal $em->getRepository(Proposal::class)->findOneById($form->get('proposalId')->getData());
  907.         if(empty($control_verifico)){
  908.             if($form->isValid())
  909.             {
  910.                 $control->setStatus('Pending');
  911.                 $em->persist($control);
  912.                 $em->flush();
  913.                 $event 'The Supplier Destination Proposal has been created.';
  914.                 $successMessage $this->translator->trans($event);
  915.                 $this->addFlash('mensajeproposaldestinationservices'$successMessage);
  916.             }else{
  917.                 $errorMessage $this->translator->trans('Error, some fields are empty');
  918.                 $this->addFlash('mensajeproposaldestinationserviceserror'$errorMessage);
  919.             }
  920.         }else{
  921.             $errorMessage $this->translator->trans('The proposal already has this provider included');
  922.             $this->addFlash('mensajeproposaldestinationserviceserror'$errorMessage);
  923.         }
  924.         return $this->redirectToRoute('proposal_destination_supplier_view', array(
  925.             'id' => $control->getControlDestinationId(),
  926.             '_fragment' => 's'.$control->getId()
  927.         ));
  928.     }
  929.     /* CREAR DESDE UNA Activity */
  930.     private function createDestinationProposalActivitiesCreateForm(ProposalSupplierControl $entity)
  931.     {
  932.         $form $this->createForm(ProposalActivitiesControlType::class, $entity, array(
  933.             'action' => $this->generateUrl('proposal_destination_activities_create'),
  934.             'method' => 'POST'
  935.         ));
  936.         return $form;
  937.     }
  938.     /* CREAR DESDE UNA Activity  */
  939.     /**
  940.      * @Route("/proposal/destination/services/createActivity", name="proposal_destination_activities_create")
  941.      */
  942.     public function createProposalActivityDestinationAction(Request $request)
  943.     {
  944.         $control = new ProposalSupplierControl();
  945.         $form $this->createDestinationProposalActivitiesCreateForm($control);
  946.         $form->handleRequest($request);
  947.         $supplier_proposal $form->get('activityId')->getData();
  948.         if(!is_null($supplier_proposal)){
  949.             $control->setActivityId($supplier_proposal->getId());
  950.         }
  951.         $em $this->getDoctrine()->getManager();
  952.         $control_verifico $em->getRepository(ProposalSupplierControl::class)->findOneBy(
  953.             array(
  954.                 'controlDestinationId' => $form->get('controlDestinationId')->getData(),
  955.                 'proposalId' => $form->get('proposalId')->getData(),
  956.                 'destinoId' => $form->get('destinoId')->getData(),
  957.                 'activityId' => $supplier_proposal->getId(),
  958.             )
  959.         );
  960. //        $proposal = $em->getRepository(Proposal::class)->findOneById($form->get('proposalId')->getData());
  961.         if(empty($control_verifico)){
  962.             if($form->isValid())
  963.             {
  964.                 $control->setStatus('Pending');
  965.                 $em->persist($control);
  966.                 $em->flush();
  967.                 /* METEMOS EL CONTENIDO DE LA IDEA */
  968.                 $idcontrol $control->getId();
  969.                 $idactivity $control->getActivityId();
  970.                 /*CONTROL GENERAL*/
  971.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByActivityId($idactivity);
  972.                 $id $controlgeneral->getId();
  973.                 $supplierservices= new ProposalSupplierServices();
  974.                 $supplierservices->setControlId($idcontrol);
  975.                 $supplierCrtl $em->getRepository(ProposalSupplierControl::class)->findOneById($idcontrol);
  976.                 $supplierservices->setProposalId($supplierCrtl->getProposalId());
  977.                 $supplierservices->setDestinationId($supplierCrtl->getDestinoId());
  978.                 $supplierservices->setServiceIdFather('0');
  979.                 $supplierservices->setSupplierId(null);
  980.                 $supplierservices->setActivityId($idactivity);
  981.                 $supplierservices->setIsFather('0');
  982.                 /* NAMEJO DE ADICIONALES EN EL DIA DEL EVENTO O DESPUES EL DIA DEL EVENTO */
  983.                 $proposal_data $em->getRepository(Proposal::class)->findOneById($supplierCrtl->getProposalId());
  984.                 $dayEvent $proposal_data->getDateEventStarAt()->format('Y-m-d');
  985.                 $today date('Y-m-d');
  986.                 if( $today >= $dayEvent){
  987.                     $additional "Additional";
  988.                 }else{
  989.                     $additional "Normal";
  990.                 }
  991.                 /* Obtengo usuario logueado */
  992.                 $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  993.                 $user_id $user_logueado->getId();
  994.                 $supplierservices->setCreatedId($user_id);
  995.                 $supplierservices->setUpdatedId($user_id);
  996.                 $supplierservices->setDateInAt($proposal_data->getDateEventStarAt());
  997.                 $supplierservices->setDateOutAt($proposal_data->getDateEventEndAt());
  998.                 ///////colsulta de servicio
  999.                 /* metemos accommodation *////////////////////////////////////////////////////////////////
  1000.                 $accommodations $em->getRepository(SupplierAccommodation::class)->findBySupplierId($id);
  1001.                 //la consulta es al SupplierId porque lo estamos usando como id controlador para SupplierIdeaServicesControl
  1002.                 if(!empty($accommodations)){
  1003.                     foreach($accommodations as $accommodation){
  1004.                         $supplierservices->setServiceId($accommodation->getId());
  1005.                         $supplierservices->setServiceCatId('1');
  1006.                         $supplierservices->setServiceCatName('Accommodation');
  1007.                         $supplierservices->setName($accommodation->getName());
  1008.                         $supplierservices->setPrice($accommodation->getPrice());
  1009.                         //$supplierservices->setCurrency('Euro');
  1010.                         $supplierservices->setUnits('1');
  1011.                         $supplierservices->setCommission('0');
  1012.                         //$supplierservices->setOver('Accommodation');
  1013.                         $supplierservices->setIva('10');
  1014.                         $supplierservices->setPax('0');
  1015.                         //$supplierservices->setHour('');//null
  1016.                         //$supplierservices->setDateInAt('');
  1017.                         //$supplierservices->setDateOutAt('');
  1018.                         $supplierservices->setDirectPayment('0');
  1019.                         $supplierservices->setStatus('Pending');
  1020.                         $supplierservices->setStatusinternal($additional);
  1021.                         $em->persist($supplierservices);
  1022.                         $em->flush();
  1023.                         $em->clear();
  1024.                         //para pruebas
  1025.                         //$data_prueba[] = array(
  1026.                         //    'data' => $supplierservices
  1027.                         //);
  1028.                     }
  1029.                     //para pruebas
  1030.                     //d($data_prueba);
  1031.                     //exit();
  1032.                 }
  1033.                 /* metemos menu *////////////////////////////////////////////////////////////////
  1034.                 $menus $em->getRepository(SupplierMenu::class)->findBySupplierId($id);
  1035.                 if(!empty($menus)){
  1036.                     foreach($menus as $menu){
  1037.                         $supplierservices->setServiceId($menu->getId());
  1038.                         $supplierservices->setServiceCatId('11');
  1039.                         $supplierservices->setServiceCatName('Menu');
  1040.                         $supplierservices->setName($menu->getTitle());
  1041.                         $supplierservices->setPrice($menu->getPrice());
  1042.                         //$supplierservices->setCurrency('Euro');
  1043.                         $supplierservices->setUnits('1');
  1044.                         $supplierservices->setCommission($menu->getCommission());
  1045.                         //$supplierservices->setOver('Accommodation');
  1046.                         $supplierservices->setIva($menu->getIva());
  1047.                         $supplierservices->setPax('0');
  1048.                         //$supplierservices->setHour('');//null
  1049.                         //$supplierservices->setDateInAt('');
  1050.                         //$supplierservices->setDateOutAt('');
  1051.                         $supplierservices->setDirectPayment('0');
  1052.                         $supplierservices->setStatus('Pending');
  1053.                         $supplierservices->setStatusinternal($additional);
  1054.                         $em->persist($supplierservices);
  1055.                         $em->flush();
  1056.                         $em->clear();
  1057.                         //para pruebas
  1058.                         //$data_prueba[] = array(
  1059.                         //    'data' => $supplierservices
  1060.                         //);
  1061.                     }
  1062.                     //para pruebas
  1063.                     //d($data_prueba);
  1064.                     //exit();
  1065.                 }
  1066.                 /* metemos lounge *////////////////////////////////////////////////////////////////
  1067.                 $lounges $em->getRepository(SupplierLounge::class)->findBySupplierId($id);
  1068.                 if(!empty($lounges)){
  1069.                     foreach($lounges as $lounge){
  1070.                         $supplierservices->setServiceId($lounge->getId());
  1071.                         $supplierservices->setServiceCatId('10');
  1072.                         $supplierservices->setServiceCatName('Lounge');
  1073.                         $supplierservices->setName($lounge->getName());
  1074.                         $supplierservices->setPrice($lounge->getPrice());
  1075.                         //$supplierservices->setCurrency('Euro');
  1076.                         $supplierservices->setUnits('1');
  1077.                         $supplierservices->setCommission($lounge->getCommission());
  1078.                         //$supplierservices->setOver('Accommodation');
  1079.                         $supplierservices->setIva($lounge->getIva());
  1080.                         $supplierservices->setPax('0');
  1081.                         //$supplierservices->setHour('');//null
  1082.                         //$supplierservices->setDateInAt('');
  1083.                         //$supplierservices->setDateOutAt('');
  1084.                         $supplierservices->setDirectPayment('0');
  1085.                         $supplierservices->setStatus('Pending');
  1086.                         $supplierservices->setStatusinternal($additional);
  1087.                         $em->persist($supplierservices);
  1088.                         $em->flush();
  1089.                         $em->clear();
  1090.                         //para pruebas
  1091.                         //$data_prueba[] = array(
  1092.                         //    'data' => $supplierservices
  1093.                         //);
  1094.                     }
  1095.                     //para pruebas
  1096.                     //d($data_prueba);
  1097.                     //exit();
  1098.                 }
  1099.                 /* metemos activities *////////////////////////////////////////////////////////////////
  1100.                 $activitiess $em->getRepository(SupplierActivities::class)->findBySupplierId($id);
  1101.                 if(!empty($activitiess)){
  1102.                     foreach($activitiess as $activities){
  1103.                         $supplierservices->setServiceId($activities->getId());
  1104.                         $supplierservices->setServiceCatId('2');
  1105.                         $supplierservices->setServiceCatName('Activities');
  1106.                         $supplierservices->setName($activities->getTitle());
  1107.                         $supplierservices->setPrice($activities->getPrice());
  1108.                         //$supplierservices->setCurrency('Euro');
  1109.                         $supplierservices->setUnits('1');
  1110.                         $supplierservices->setCommission($activities->getCommission());
  1111.                         //$supplierservices->setOver('Accommodation');
  1112.                         $supplierservices->setIva($activities->getIva());
  1113.                         $supplierservices->setPax('0');
  1114.                         //$supplierservices->setHour('');//null
  1115.                         //$supplierservices->setDateInAt('');
  1116.                         //$supplierservices->setDateOutAt('');
  1117.                         $supplierservices->setDirectPayment('0');
  1118.                         $supplierservices->setStatus('Pending');
  1119.                         $supplierservices->setStatusinternal($additional);
  1120.                         $em->persist($supplierservices);
  1121.                         $em->flush();
  1122.                         $em->clear();
  1123.                         //para pruebas
  1124.                         //$data_prueba[] = array(
  1125.                         //    'data' => $supplierservices
  1126.                         //);
  1127.                     }
  1128.                     //para pruebas
  1129.                     //d($data_prueba);
  1130.                     //exit();
  1131.                 }
  1132.                 /* metemos itineraries *////////////////////////////////////////////////////////////////
  1133.                 $itinerariess $em->getRepository(SupplierItineraries::class)->findBySupplierId($id);
  1134.                 if(!empty($itinerariess)){
  1135.                     foreach($itinerariess as $itineraries){
  1136.                         $supplierservices->setServiceId($itineraries->getId());
  1137.                         $supplierservices->setServiceCatId('9');
  1138.                         $supplierservices->setServiceCatName('Itineraries');
  1139.                         $supplierservices->setName($itineraries->getTitle());
  1140.                         $supplierservices->setPrice('0');
  1141.                         //$supplierservices->setCurrency('Euro');
  1142.                         $supplierservices->setUnits('1');
  1143.                         $supplierservices->setCommission('0');
  1144.                         //$supplierservices->setOver('Accommodation');
  1145.                         $supplierservices->setIva('10');
  1146.                         $supplierservices->setPax('0');
  1147.                         //$supplierservices->setHour('');//null
  1148.                         //$supplierservices->setDateInAt('');
  1149.                         //$supplierservices->setDateOutAt('');
  1150.                         $supplierservices->setDirectPayment('0');
  1151.                         $supplierservices->setStatus('Pending');
  1152.                         $supplierservices->setStatusinternal($additional);
  1153.                         $em->persist($supplierservices);
  1154.                         $em->flush();
  1155.                         $em->clear();
  1156.                         //para pruebas
  1157.                         //$data_prueba[] = array(
  1158.                         //    'data' => $supplierservices
  1159.                         //);
  1160.                     }
  1161.                     //para pruebas
  1162.                     //d($data_prueba);
  1163.                     //exit();
  1164.                 }
  1165.                 /* metemos cruise *////////////////////////////////////////////////////////////////
  1166.                 $cruises $em->getRepository(SupplierCruise::class)->findBySupplierId($id);
  1167.                 if(!empty($cruises)){
  1168.                     foreach($cruises as $cruise){
  1169.                         $supplierservices->setServiceId($cruise->getId());
  1170.                         $supplierservices->setServiceCatId('5');
  1171.                         $supplierservices->setServiceCatName('Cruise');
  1172.                         $supplierservices->setName($cruise->getTitle());
  1173.                         $supplierservices->setPrice($cruise->getPrice());
  1174.                         //$supplierservices->setCurrency('Euro');
  1175.                         $supplierservices->setUnits('1');
  1176.                         $supplierservices->setCommission($cruise->getCommission());
  1177.                         //$supplierservices->setOver('Accommodation');
  1178.                         $supplierservices->setIva($cruise->getIva());
  1179.                         $supplierservices->setPax('0');
  1180.                         //$supplierservices->setHour('');//null
  1181.                         //$supplierservices->setDateInAt('');
  1182.                         //$supplierservices->setDateOutAt('');
  1183.                         $supplierservices->setDirectPayment('0');
  1184.                         $supplierservices->setStatus('Pending');
  1185.                         $supplierservices->setStatusinternal($additional);
  1186.                         $em->persist($supplierservices);
  1187.                         $em->flush();
  1188.                         $em->clear();
  1189.                         //para pruebas
  1190.                         //$data_prueba[] = array(
  1191.                         //    'data' => $supplierservices
  1192.                         //);
  1193.                     }
  1194.                     //para pruebas
  1195.                     //d($data_prueba);
  1196.                     //exit();
  1197.                 }
  1198.                 /* metemos transport *////////////////////////////////////////////////////////////////
  1199.                 $transports $em->getRepository(SupplierTransport::class)->findBySupplierId($id);
  1200.                 if(!empty($transports)){
  1201.                     foreach($transports as $transport){
  1202.                         $supplierservices->setServiceId($transport->getId());
  1203.                         $supplierservices->setServiceCatId('13');
  1204.                         $supplierservices->setServiceCatName('Transport');
  1205.                         $supplierservices->setName($transport->getName());
  1206.                         $supplierservices->setPrice($transport->getPrice());
  1207.                         //$supplierservices->setCurrency('Euro');
  1208.                         $supplierservices->setUnits('1');
  1209.                         $supplierservices->setCommission($transport->getCommission());
  1210.                         //$supplierservices->setOver('Accommodation');
  1211.                         $supplierservices->setIva($transport->getIva());
  1212.                         $supplierservices->setPax('0');
  1213.                         //$supplierservices->setHour('');//null
  1214.                         //$supplierservices->setDateInAt('');
  1215.                         //$supplierservices->setDateOutAt('');
  1216.                         $supplierservices->setDirectPayment('0');
  1217.                         $supplierservices->setStatus('Pending');
  1218.                         $supplierservices->setStatusinternal($additional);
  1219.                         $em->persist($supplierservices);
  1220.                         $em->flush();
  1221.                         $em->clear();
  1222.                         //para pruebas
  1223.                         //$data_prueba[] = array(
  1224.                         //    'data' => $supplierservices
  1225.                         //);
  1226.                     }
  1227.                     //para pruebas
  1228.                     //d($data_prueba);
  1229.                     //exit();
  1230.                 }
  1231.                 /* metemos av *////////////////////////////////////////////////////////////////
  1232.                 $avs $em->getRepository(SupplierAv::class)->findBySupplierId($id);
  1233.                 if(!empty($avs)){
  1234.                     foreach($avs as $av){
  1235.                         $supplierservices->setServiceId($av->getId());
  1236.                         $supplierservices->setServiceCatId('3');
  1237.                         $supplierservices->setServiceCatName('Av');
  1238.                         $supplierservices->setName($av->getName());
  1239.                         $supplierservices->setPrice($av->getPrice());
  1240.                         //$supplierservices->setCurrency('Euro');
  1241.                         $supplierservices->setUnits('1');
  1242.                         $supplierservices->setCommission($av->getCommission());
  1243.                         //$supplierservices->setOver('Accommodation');
  1244.                         $supplierservices->setIva($av->getIva());
  1245.                         $supplierservices->setPax('0');
  1246.                         //$supplierservices->setHour('');//null
  1247.                         //$supplierservices->setDateInAt('');
  1248.                         //$supplierservices->setDateOutAt('');
  1249.                         $supplierservices->setDirectPayment('0');
  1250.                         $supplierservices->setStatus('Pending');
  1251.                         $supplierservices->setStatusinternal($additional);
  1252.                         $em->persist($supplierservices);
  1253.                         $em->flush();
  1254.                         $em->clear();
  1255.                         //para pruebas
  1256.                         //$data_prueba[] = array(
  1257.                         //    'data' => $supplierservices
  1258.                         //);
  1259.                     }
  1260.                     //para pruebas
  1261.                     //d($data_prueba);
  1262.                     //exit();
  1263.                 }
  1264.                 /* metemos creative *////////////////////////////////////////////////////////////////
  1265.                 $creatives $em->getRepository(SupplierCreative::class)->findBySupplierId($id);
  1266.                 if(!empty($creatives)){
  1267.                     foreach($creatives as $creative){
  1268.                         $supplierservices->setServiceId($creative->getId());
  1269.                         $supplierservices->setServiceCatId('4');
  1270.                         $supplierservices->setServiceCatName('Creative');
  1271.                         $supplierservices->setName($creative->getTitle());
  1272.                         $supplierservices->setPrice('0');
  1273.                         //$supplierservices->setCurrency('Euro');
  1274.                         $supplierservices->setUnits('1');
  1275.                         $supplierservices->setCommission('0');
  1276.                         //$supplierservices->setOver('Accommodation');
  1277.                         $supplierservices->setIva('21');
  1278.                         $supplierservices->setPax('0');
  1279.                         //$supplierservices->setHour('');//null
  1280.                         //$supplierservices->setDateInAt('');
  1281.                         //$supplierservices->setDateOutAt('');
  1282.                         $supplierservices->setDirectPayment('0');
  1283.                         $supplierservices->setStatus('Pending');
  1284.                         $supplierservices->setStatusinternal($additional);
  1285.                         $em->persist($supplierservices);
  1286.                         $em->flush();
  1287.                         $em->clear();
  1288.                         //para pruebas
  1289.                         //$data_prueba[] = array(
  1290.                         //    'data' => $supplierservices
  1291.                         //);
  1292.                     }
  1293.                     //para pruebas
  1294.                     //d($data_prueba);
  1295.                     //exit();
  1296.                 }
  1297.                 /* metemos gift *////////////////////////////////////////////////////////////////
  1298.                 $gifts $em->getRepository(SupplierGifts::class)->findBySupplierId($id);
  1299.                 if(!empty($gifts)){
  1300.                     foreach($gifts as $gift){
  1301.                         $supplierservices->setServiceId($gift->getId());
  1302.                         $supplierservices->setServiceCatId('7');
  1303.                         $supplierservices->setServiceCatName('Gifts');
  1304.                         $supplierservices->setName($gift->getName());
  1305.                         $supplierservices->setPrice($gift->getPrice());
  1306.                         //$supplierservices->setCurrency('Euro');
  1307.                         $supplierservices->setUnits('1');
  1308.                         $supplierservices->setCommission($gift->getCommission());
  1309.                         //$supplierservices->setOver('Accommodation');
  1310.                         $supplierservices->setIva($gift->getIva());
  1311.                         $supplierservices->setPax('0');
  1312.                         //$supplierservices->setHour('');//null
  1313.                         //$supplierservices->setDateInAt('');
  1314.                         //$supplierservices->setDateOutAt('');
  1315.                         $supplierservices->setDirectPayment('0');
  1316.                         $supplierservices->setStatus('Pending');
  1317.                         $supplierservices->setStatusinternal($additional);
  1318.                         $em->persist($supplierservices);
  1319.                         $em->flush();
  1320.                         $em->clear();
  1321.                         //para pruebas
  1322.                         //$data_prueba[] = array(
  1323.                         //    'data' => $supplierservices
  1324.                         //);
  1325.                     }
  1326.                     //para pruebas
  1327.                     //d($data_prueba);
  1328.                     //exit();
  1329.                 }
  1330.                 /* metemos entertainment *////////////////////////////////////////////////////////////////
  1331.                 $entertainments $em->getRepository(SupplierEntertainment::class)->findBySupplierId($id);
  1332.                 if(!empty($entertainments)){
  1333.                     foreach($entertainments as $entertainment){
  1334.                         $supplierservices->setServiceId($entertainment->getId());
  1335.                         $supplierservices->setServiceCatId('6');
  1336.                         $supplierservices->setServiceCatName('Entertainment');
  1337.                         $supplierservices->setName($entertainment->getName());
  1338.                         $supplierservices->setPrice($entertainment->getPrice());
  1339.                         //$supplierservices->setCurrency('Euro');
  1340.                         $supplierservices->setUnits('1');
  1341.                         $supplierservices->setCommission($entertainment->getCommission());
  1342.                         //$supplierservices->setOver('Accommodation');
  1343.                         $supplierservices->setIva($entertainment->getIva());
  1344.                         $supplierservices->setPax('0');
  1345.                         //$supplierservices->setHour('');//null
  1346.                         //$supplierservices->setDateInAt('');
  1347.                         //$supplierservices->setDateOutAt('');
  1348.                         $supplierservices->setDirectPayment('0');
  1349.                         $supplierservices->setStatus('Pending');
  1350.                         $supplierservices->setStatusinternal($additional);
  1351.                         $em->persist($supplierservices);
  1352.                         $em->flush();
  1353.                         $em->clear();
  1354.                         //para pruebas
  1355.                         //$data_prueba[] = array(
  1356.                         //    'data' => $supplierservices
  1357.                         //);
  1358.                     }
  1359.                     //para pruebas
  1360.                     //d($data_prueba);
  1361.                     //exit();
  1362.                 }
  1363.                 /* metemos guide *////////////////////////////////////////////////////////////////
  1364.                 $guides $em->getRepository(SupplierGuide::class)->findBySupplierId($id);
  1365.                 if(!empty($guides)){
  1366.                     foreach($guides as $guide){
  1367.                         $supplierservices->setServiceId($guide->getId());
  1368.                         $supplierservices->setServiceCatId('8');
  1369.                         $supplierservices->setServiceCatName('Guide');
  1370.                         $supplierservices->setName($guide->getName());
  1371.                         $supplierservices->setPrice($guide->getPrice());
  1372.                         //$supplierservices->setCurrency('Euro');
  1373.                         $supplierservices->setUnits('1');
  1374.                         $supplierservices->setCommission($guide->getCommission());
  1375.                         //$supplierservices->setOver('Accommodation');
  1376.                         $supplierservices->setIva($guide->getIva());
  1377.                         $supplierservices->setPax('0');
  1378.                         //$supplierservices->setHour('');//null
  1379.                         //$supplierservices->setDateInAt('');
  1380.                         //$supplierservices->setDateOutAt('');
  1381.                         $supplierservices->setDirectPayment('0');
  1382.                         $supplierservices->setStatus('Pending');
  1383.                         $supplierservices->setStatusinternal($additional);
  1384.                         $em->persist($supplierservices);
  1385.                         $em->flush();
  1386.                         $em->clear();
  1387.                         //para pruebas
  1388.                         //$data_prueba[] = array(
  1389.                         //    'data' => $supplierservices
  1390.                         //);
  1391.                     }
  1392.                     //para pruebas
  1393.                     //d($data_prueba);
  1394.                     //exit();
  1395.                 }
  1396.                 /* metemos others *////////////////////////////////////////////////////////////////
  1397.                 $otherss $em->getRepository(SupplierOthers::class)->findBySupplierId($id);
  1398.                 if(!empty($otherss)){
  1399.                     foreach($otherss as $others){
  1400.                         $supplierservices->setServiceId($others->getId());
  1401.                         $supplierservices->setServiceCatId('12');
  1402.                         $supplierservices->setServiceCatName('Others');
  1403.                         $supplierservices->setName($others->getName());
  1404.                         $supplierservices->setPrice($others->getPrice());
  1405.                         //$supplierservices->setCurrency('Euro');
  1406.                         $supplierservices->setUnits('1');
  1407.                         $supplierservices->setCommission($others->getCommission());
  1408.                         //$supplierservices->setOver('Accommodation');
  1409.                         $supplierservices->setIva($others->getIva());
  1410.                         $supplierservices->setPax('0');
  1411.                         //$supplierservices->setHour('');//null
  1412.                         //$supplierservices->setDateInAt('');
  1413.                         //$supplierservices->setDateOutAt('');
  1414.                         $supplierservices->setDirectPayment('0');
  1415.                         $supplierservices->setStatus('Pending');
  1416.                         $supplierservices->setStatusinternal($additional);
  1417.                         $em->persist($supplierservices);
  1418.                         $em->flush();
  1419.                         $em->clear();
  1420.                         //para pruebas
  1421.                         //$data_prueba[] = array(
  1422.                         //    'data' => $supplierservices
  1423.                         //);
  1424.                     }
  1425.                     //para pruebas
  1426.                     //d($data_prueba);
  1427.                     //exit();
  1428.                 }
  1429.                 /* metemos technology *////////////////////////////////////////////////////////////////
  1430.                 $technologys $em->getRepository(SupplierTechnology::class)->findBySupplierId($id);
  1431.                 if(!empty($technologys)){
  1432.                     foreach($technologys as $technology){
  1433.                         $supplierservices->setServiceId($technology->getId());
  1434.                         $supplierservices->setServiceCatId('14');
  1435.                         $supplierservices->setServiceCatName('Technology');
  1436.                         $supplierservices->setName($technology->getTitle());
  1437.                         $supplierservices->setPrice($technology->getPrice());
  1438.                         //$supplierservices->setCurrency('Euro');
  1439.                         $supplierservices->setUnits('1');
  1440.                         $supplierservices->setCommission($technology->getCommission());
  1441.                         //$supplierservices->setOver('Accommodation');
  1442.                         $supplierservices->setIva($technology->getIva());
  1443.                         $supplierservices->setPax('0');
  1444.                         //$supplierservices->setHour('');//null
  1445.                         //$supplierservices->setDateInAt('');
  1446.                         //$supplierservices->setDateOutAt('');
  1447.                         $supplierservices->setDirectPayment('0');
  1448.                         $supplierservices->setStatus('Pending');
  1449.                         $supplierservices->setStatusinternal($additional);
  1450.                         $em->persist($supplierservices);
  1451.                         $em->flush();
  1452.                         $em->clear();
  1453.                         //para pruebas
  1454.                         //$data_prueba[] = array(
  1455.                         //    'data' => $supplierservices
  1456.                         //);
  1457.                     }
  1458.                     //para pruebas
  1459.                     //d($data_prueba);
  1460.                     //exit();
  1461.                 }
  1462.                 /* metemos Assistant *////////////////////////////////////////////////////////////////
  1463.                 $assistants $em->getRepository(SupplierServicesAssistant::class)->findBySupplierId($id);
  1464.                 if(!empty($assistants)){
  1465.                     foreach($assistants as $assistant){
  1466.                         $supplierservices->setServiceId($assistant->getId());
  1467.                         $supplierservices->setServiceCatId('15');
  1468.                         $supplierservices->setServiceCatName('Assistant');
  1469.                         $supplierservices->setName($assistant->getName());
  1470.                         $supplierservices->setPrice($assistant->getPrice());
  1471.                         //$supplierservices->setCurrency('Euro');
  1472.                         $supplierservices->setUnits('1');
  1473.                         $supplierservices->setCommission($assistant->getCommission());
  1474.                         //$supplierservices->setOver('Accommodation');
  1475.                         $supplierservices->setIva($assistant->getIva());
  1476.                         $supplierservices->setPax('0');
  1477.                         //$supplierservices->setHour('');//null
  1478.                         //$supplierservices->setDateInAt('');
  1479.                         //$supplierservices->setDateOutAt('');
  1480.                         $supplierservices->setDirectPayment('0');
  1481.                         $supplierservices->setStatus('Pending');
  1482.                         $supplierservices->setStatusinternal($additional);
  1483.                         $em->persist($supplierservices);
  1484.                         $em->flush();
  1485.                         $em->clear();
  1486.                         //para pruebas
  1487.                         //$data_prueba[] = array(
  1488.                         //    'data' => $supplierservices
  1489.                         //);
  1490.                     }
  1491.                     //para pruebas
  1492.                     //d($data_prueba);
  1493.                     //exit();
  1494.                 }
  1495.                 /* FIN METEMOS EL CONTENIDO DE LA IDEA */
  1496.                 // Control para el sistema de revision
  1497.                 $actId $request->request->get('proposalsuppliercontrol')['activityId'];
  1498.                 $prpId $request->request->get('proposalsuppliercontrol')['proposalId'];
  1499.                 $activities $em->getRepository(Activities::class)->findOneById($actId);
  1500.                 $revision1 = new RevisionCarga();
  1501.                 $revision2 = new RevisionCarga();
  1502.                 $revision3 = new RevisionCarga();
  1503.                 $revision1->setIdType($activities->getId());
  1504.                 $revision2->setIdType($activities->getId());
  1505.                 $revision3->setIdType($activities->getId());
  1506.                 $revision1->setName($activities->getName());
  1507.                 $revision2->setName($activities->getName());
  1508.                 $revision3->setName($activities->getName());
  1509.                 // Titulo, Destino y observacion
  1510.                 $revision1->setType('ACTIVIDAD (Título) - Agregada al Proposal:'.$prpId);
  1511.                 $revision1->setLink('activities/edit/'.$activities->getId());
  1512.                 $revision1->setStatus(false);
  1513.                 $em->persist($revision1);
  1514.                 $em->flush();
  1515.                 // Descripcion
  1516.                 $revision2->setType('ACTIVIDAD (Descripción) - Agregada al Proposal:'.$prpId);
  1517.                 // Buscamos el ID de la descripcion
  1518.                 $idact $activities->getId();
  1519.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByActivityId($idact);
  1520.                 $idctrl $controlgeneral->getId();
  1521.                 $supdesc $em->getRepository(SupplierDescription::class)->findOneBySupplierId($idctrl);
  1522.                 $id $supdesc->getId();
  1523.                 // FIN Buscamos el ID de la descripcion
  1524.                 $revision2->setLink('activities/description/edit/'.$id);
  1525.                 $revision2->setStatus(false);
  1526.                 $em->persist($revision2);
  1527.                 $em->flush();
  1528.                 // Galería
  1529.                 $revision3->setType('ACTIVIDAD (Galería) - Agregada al Proposal:'.$prpId);
  1530.                 $revision3->setLink('activities/gallery/list/'.$activities->getId());
  1531.                 $revision3->setStatus(false);
  1532.                 $em->persist($revision3);
  1533.                 $em->flush();
  1534.                 // FIN Control para el sistema de revision
  1535.                 $event 'The Idea Destination Proposal has been created.';
  1536.                 $successMessage $this->translator->trans($event);
  1537.                 $this->addFlash('mensajeproposaldestinationservices'$successMessage);
  1538.             }else{
  1539.                 $errorMessage $this->translator->trans('Error, some fields are empty');
  1540.                 $this->addFlash('mensajeproposaldestinationserviceserror'$errorMessage);
  1541.             }
  1542.         }else{
  1543.             $errorMessage $this->translator->trans('The proposal already has this Idea included');
  1544.             $this->addFlash('mensajeproposaldestinationserviceserror'$errorMessage);
  1545.         }
  1546.         return $this->redirectToRoute('proposal_destination_supplier_view', array(
  1547.             'id' => $control->getControlDestinationId(),
  1548.             '_fragment' => 's'.$control->getId()
  1549.         ));
  1550.     }
  1551.     /* CREAR DESDE UNA IDEA */
  1552.     private function createDestinationProposalIdeasCreateForm(ProposalSupplierControl $entity)
  1553.     {
  1554.         $form $this->createForm(ProposalIdeasControlType::class, $entity, array(
  1555.             'action' => $this->generateUrl('proposal_destination_ideas_create'),
  1556.             'method' => 'POST'
  1557.         ));
  1558.         return $form;
  1559.     }
  1560.     /* CREAR DESDE UNA IDEA */
  1561.     /**
  1562.      * @Route("/proposal/destination/services/createIdea", name="proposal_destination_ideas_create")
  1563.      */
  1564.     public function createProposalIdeaDestinationAction(Request $request)
  1565.     {
  1566.         $control = new ProposalSupplierControl();
  1567.         $form $this->createDestinationProposalIdeasCreateForm($control);
  1568.         $form->handleRequest($request);
  1569.         $supplier_proposal $form->get('ideaId')->getData();
  1570.         if(!is_null($supplier_proposal)){
  1571.             $control->setIdeaId($supplier_proposal->getId());
  1572.         }
  1573.         $em $this->getDoctrine()->getManager();
  1574.         $control_verifico $em->getRepository(ProposalSupplierControl::class)->findOneBy(
  1575.             array(
  1576.                 'controlDestinationId' => $form->get('controlDestinationId')->getData(),
  1577.                 'proposalId' => $form->get('proposalId')->getData(),
  1578.                 'destinoId' => $form->get('destinoId')->getData(),
  1579.                 'ideaId' => $supplier_proposal->getId(),
  1580.             )
  1581.         );
  1582. //        $proposal = $em->getRepository(Proposal::class)->findOneById($form->get('proposalId')->getData());
  1583.         if(empty($control_verifico)){
  1584.             if($form->isValid())
  1585.             {
  1586.                 $control->setStatus('Pending');
  1587.                 $em->persist($control);
  1588.                 $em->flush();
  1589.                 /* METEMOS EL CONTENIDO DE LA IDEA */
  1590.                 $idcontrol $control->getId();
  1591.                 $ididea $control->getIdeaId();
  1592.                 /*CONTROL GENERAL*/
  1593.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByIdeaId($ididea);
  1594.                 $id $controlgeneral->getId();
  1595.                 $supplierservices= new ProposalSupplierServices();
  1596.                 $supplierservices->setControlId($idcontrol);
  1597.                 $supplierCrtl $em->getRepository(ProposalSupplierControl::class)->findOneById($idcontrol);
  1598.                 $supplierservices->setProposalId($supplierCrtl->getProposalId());
  1599.                 $supplierservices->setDestinationId($supplierCrtl->getDestinoId());
  1600.                 $supplierservices->setServiceIdFather('0');
  1601.                 $supplierservices->setSupplierId(null);
  1602.                 $supplierservices->setIdeaId($ididea);
  1603.                 $supplierservices->setIsFather('0');
  1604.                 /* NAMEJO DE ADICIONALES EN EL DIA DEL EVENTO O DESPUES EL DIA DEL EVENTO */
  1605.                 $proposal_data $em->getRepository(Proposal::class)->findOneById($supplierCrtl->getProposalId());
  1606.                 $dayEvent $proposal_data->getDateEventStarAt()->format('Y-m-d');
  1607.                 $today date('Y-m-d');
  1608.                 if( $today >= $dayEvent){
  1609.                     $additional "Additional";
  1610.                 }else{
  1611.                     $additional "Normal";
  1612.                 }
  1613.                 /* Obtengo usuario logueado */
  1614.                 $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  1615.                 $user_id $user_logueado->getId();
  1616.                 $supplierservices->setCreatedId($user_id);
  1617.                 $supplierservices->setUpdatedId($user_id);
  1618.                 $supplierservices->setDateInAt($proposal_data->getDateEventStarAt());
  1619.                 $supplierservices->setDateOutAt($proposal_data->getDateEventEndAt());
  1620.                 ///////colsulta de servicio
  1621.                 /* metemos accommodation *////////////////////////////////////////////////////////////////
  1622.                 $accommodations $em->getRepository(SupplierAccommodation::class)->findBySupplierId($id);
  1623.                 //la consulta es al SupplierId porque lo estamos usando como id controlador para SupplierIdeaServicesControl
  1624.                 if(!empty($accommodations)){
  1625.                     foreach($accommodations as $accommodation){
  1626.                         $supplierservices->setServiceId($accommodation->getId());
  1627.                         $supplierservices->setServiceCatId('1');
  1628.                         $supplierservices->setServiceCatName('Accommodation');
  1629.                         $supplierservices->setName($accommodation->getName());
  1630.                         $supplierservices->setPrice($accommodation->getPrice());
  1631.                         //$supplierservices->setCurrency('Euro');
  1632.                         $supplierservices->setUnits('1');
  1633.                         $supplierservices->setCommission('0');
  1634.                         //$supplierservices->setOver('Accommodation');
  1635.                         $supplierservices->setIva('10');
  1636.                         $supplierservices->setPax('0');
  1637.                         //$supplierservices->setHour('');//null
  1638.                         //$supplierservices->setDateInAt('');
  1639.                         //$supplierservices->setDateOutAt('');
  1640.                         $supplierservices->setDirectPayment('0');
  1641.                         $supplierservices->setStatus('Pending');
  1642.                         $supplierservices->setStatusinternal($additional);
  1643.                         $em->persist($supplierservices);
  1644.                         $em->flush();
  1645.                         $em->clear();
  1646.                         //para pruebas
  1647.                         //$data_prueba[] = array(
  1648.                         //    'data' => $supplierservices
  1649.                         //);
  1650.                     }
  1651.                     //para pruebas
  1652.                     //d($data_prueba);
  1653.                     //exit();
  1654.                 }
  1655.                 /* metemos menu *////////////////////////////////////////////////////////////////
  1656.                 $menus $em->getRepository(SupplierMenu::class)->findBySupplierId($id);
  1657.                 if(!empty($menus)){
  1658.                     foreach($menus as $menu){
  1659.                         $supplierservices->setServiceId($menu->getId());
  1660.                         $supplierservices->setServiceCatId('11');
  1661.                         $supplierservices->setServiceCatName('Menu');
  1662.                         $supplierservices->setName($menu->getTitle());
  1663.                         $supplierservices->setPrice($menu->getPrice());
  1664.                         //$supplierservices->setCurrency('Euro');
  1665.                         $supplierservices->setUnits('1');
  1666.                         $supplierservices->setCommission($menu->getCommission());
  1667.                         //$supplierservices->setOver('Accommodation');
  1668.                         $supplierservices->setIva($menu->getIva());
  1669.                         $supplierservices->setPax('0');
  1670.                         //$supplierservices->setHour('');//null
  1671.                         //$supplierservices->setDateInAt('');
  1672.                         //$supplierservices->setDateOutAt('');
  1673.                         $supplierservices->setDirectPayment('0');
  1674.                         $supplierservices->setStatus('Pending');
  1675.                         $supplierservices->setStatusinternal($additional);
  1676.                         $em->persist($supplierservices);
  1677.                         $em->flush();
  1678.                         $em->clear();
  1679.                         //para pruebas
  1680.                         //$data_prueba[] = array(
  1681.                         //    'data' => $supplierservices
  1682.                         //);
  1683.                     }
  1684.                     //para pruebas
  1685.                     //d($data_prueba);
  1686.                     //exit();
  1687.                 }
  1688.                 /* metemos lounge *////////////////////////////////////////////////////////////////
  1689.                 $lounges $em->getRepository(SupplierLounge::class)->findBySupplierId($id);
  1690.                 if(!empty($lounges)){
  1691.                     foreach($lounges as $lounge){
  1692.                         $supplierservices->setServiceId($lounge->getId());
  1693.                         $supplierservices->setServiceCatId('10');
  1694.                         $supplierservices->setServiceCatName('Lounge');
  1695.                         $supplierservices->setName($lounge->getName());
  1696.                         $supplierservices->setPrice($lounge->getPrice());
  1697.                         //$supplierservices->setCurrency('Euro');
  1698.                         $supplierservices->setUnits('1');
  1699.                         $supplierservices->setCommission($lounge->getCommission());
  1700.                         //$supplierservices->setOver('Accommodation');
  1701.                         $supplierservices->setIva($lounge->getIva());
  1702.                         $supplierservices->setPax('0');
  1703.                         //$supplierservices->setHour('');//null
  1704.                         //$supplierservices->setDateInAt('');
  1705.                         //$supplierservices->setDateOutAt('');
  1706.                         $supplierservices->setDirectPayment('0');
  1707.                         $supplierservices->setStatus('Pending');
  1708.                         $supplierservices->setStatusinternal($additional);
  1709.                         $em->persist($supplierservices);
  1710.                         $em->flush();
  1711.                         $em->clear();
  1712.                         //para pruebas
  1713.                         //$data_prueba[] = array(
  1714.                         //    'data' => $supplierservices
  1715.                         //);
  1716.                     }
  1717.                     //para pruebas
  1718.                     //d($data_prueba);
  1719.                     //exit();
  1720.                 }
  1721.                 /* metemos activities *////////////////////////////////////////////////////////////////
  1722.                 $activitiess $em->getRepository(SupplierActivities::class)->findBySupplierId($id);
  1723.                 if(!empty($activitiess)){
  1724.                     foreach($activitiess as $activities){
  1725.                         $supplierservices->setServiceId($activities->getId());
  1726.                         $supplierservices->setServiceCatId('2');
  1727.                         $supplierservices->setServiceCatName('Activities');
  1728.                         $supplierservices->setName($activities->getTitle());
  1729.                         $supplierservices->setPrice($activities->getPrice());
  1730.                         //$supplierservices->setCurrency('Euro');
  1731.                         $supplierservices->setUnits('1');
  1732.                         $supplierservices->setCommission($activities->getCommission());
  1733.                         //$supplierservices->setOver('Accommodation');
  1734.                         $supplierservices->setIva($activities->getIva());
  1735.                         $supplierservices->setPax('0');
  1736.                         //$supplierservices->setHour('');//null
  1737.                         //$supplierservices->setDateInAt('');
  1738.                         //$supplierservices->setDateOutAt('');
  1739.                         $supplierservices->setDirectPayment('0');
  1740.                         $supplierservices->setStatus('Pending');
  1741.                         $supplierservices->setStatusinternal($additional);
  1742.                         $em->persist($supplierservices);
  1743.                         $em->flush();
  1744.                         $em->clear();
  1745.                         //para pruebas
  1746.                         //$data_prueba[] = array(
  1747.                         //    'data' => $supplierservices
  1748.                         //);
  1749.                     }
  1750.                     //para pruebas
  1751.                     //d($data_prueba);
  1752.                     //exit();
  1753.                 }
  1754.                 /* metemos itineraries *////////////////////////////////////////////////////////////////
  1755.                 $itinerariess $em->getRepository(SupplierItineraries::class)->findBySupplierId($id);
  1756.                 if(!empty($itinerariess)){
  1757.                     foreach($itinerariess as $itineraries){
  1758.                         $supplierservices->setServiceId($itineraries->getId());
  1759.                         $supplierservices->setServiceCatId('9');
  1760.                         $supplierservices->setServiceCatName('Itineraries');
  1761.                         $supplierservices->setName($itineraries->getTitle());
  1762.                         $supplierservices->setPrice('0');
  1763.                         //$supplierservices->setCurrency('Euro');
  1764.                         $supplierservices->setUnits('1');
  1765.                         $supplierservices->setCommission('0');
  1766.                         //$supplierservices->setOver('Accommodation');
  1767.                         $supplierservices->setIva('10');
  1768.                         $supplierservices->setPax('0');
  1769.                         //$supplierservices->setHour('');//null
  1770.                         //$supplierservices->setDateInAt('');
  1771.                         //$supplierservices->setDateOutAt('');
  1772.                         $supplierservices->setDirectPayment('0');
  1773.                         $supplierservices->setStatus('Pending');
  1774.                         $supplierservices->setStatusinternal($additional);
  1775.                         $em->persist($supplierservices);
  1776.                         $em->flush();
  1777.                         $em->clear();
  1778.                         //para pruebas
  1779.                         //$data_prueba[] = array(
  1780.                         //    'data' => $supplierservices
  1781.                         //);
  1782.                     }
  1783.                     //para pruebas
  1784.                     //d($data_prueba);
  1785.                     //exit();
  1786.                 }
  1787.                 /* metemos cruise *////////////////////////////////////////////////////////////////
  1788.                 $cruises $em->getRepository(SupplierCruise::class)->findBySupplierId($id);
  1789.                 if(!empty($cruises)){
  1790.                     foreach($cruises as $cruise){
  1791.                         $supplierservices->setServiceId($cruise->getId());
  1792.                         $supplierservices->setServiceCatId('5');
  1793.                         $supplierservices->setServiceCatName('Cruise');
  1794.                         $supplierservices->setName($cruise->getTitle());
  1795.                         $supplierservices->setPrice($cruise->getPrice());
  1796.                         //$supplierservices->setCurrency('Euro');
  1797.                         $supplierservices->setUnits('1');
  1798.                         $supplierservices->setCommission($cruise->getCommission());
  1799.                         //$supplierservices->setOver('Accommodation');
  1800.                         $supplierservices->setIva($cruise->getIva());
  1801.                         $supplierservices->setPax('0');
  1802.                         //$supplierservices->setHour('');//null
  1803.                         //$supplierservices->setDateInAt('');
  1804.                         //$supplierservices->setDateOutAt('');
  1805.                         $supplierservices->setDirectPayment('0');
  1806.                         $supplierservices->setStatus('Pending');
  1807.                         $supplierservices->setStatusinternal($additional);
  1808.                         $em->persist($supplierservices);
  1809.                         $em->flush();
  1810.                         $em->clear();
  1811.                         //para pruebas
  1812.                         //$data_prueba[] = array(
  1813.                         //    'data' => $supplierservices
  1814.                         //);
  1815.                     }
  1816.                     //para pruebas
  1817.                     //d($data_prueba);
  1818.                     //exit();
  1819.                 }
  1820.                 /* metemos transport *////////////////////////////////////////////////////////////////
  1821.                 $transports $em->getRepository(SupplierTransport::class)->findBySupplierId($id);
  1822.                 if(!empty($transports)){
  1823.                     foreach($transports as $transport){
  1824.                         $supplierservices->setServiceId($transport->getId());
  1825.                         $supplierservices->setServiceCatId('13');
  1826.                         $supplierservices->setServiceCatName('Transport');
  1827.                         $supplierservices->setName($transport->getName());
  1828.                         $supplierservices->setPrice($transport->getPrice());
  1829.                         //$supplierservices->setCurrency('Euro');
  1830.                         $supplierservices->setUnits('1');
  1831.                         $supplierservices->setCommission($transport->getCommission());
  1832.                         //$supplierservices->setOver('Accommodation');
  1833.                         $supplierservices->setIva($transport->getIva());
  1834.                         $supplierservices->setPax('0');
  1835.                         //$supplierservices->setHour('');//null
  1836.                         //$supplierservices->setDateInAt('');
  1837.                         //$supplierservices->setDateOutAt('');
  1838.                         $supplierservices->setDirectPayment('0');
  1839.                         $supplierservices->setStatus('Pending');
  1840.                         $supplierservices->setStatusinternal($additional);
  1841.                         $em->persist($supplierservices);
  1842.                         $em->flush();
  1843.                         $em->clear();
  1844.                         //para pruebas
  1845.                         //$data_prueba[] = array(
  1846.                         //    'data' => $supplierservices
  1847.                         //);
  1848.                     }
  1849.                     //para pruebas
  1850.                     //d($data_prueba);
  1851.                     //exit();
  1852.                 }
  1853.                 /* metemos av *////////////////////////////////////////////////////////////////
  1854.                 $avs $em->getRepository(SupplierAv::class)->findBySupplierId($id);
  1855.                 if(!empty($avs)){
  1856.                     foreach($avs as $av){
  1857.                         $supplierservices->setServiceId($av->getId());
  1858.                         $supplierservices->setServiceCatId('3');
  1859.                         $supplierservices->setServiceCatName('Av');
  1860.                         $supplierservices->setName($av->getName());
  1861.                         $supplierservices->setPrice($av->getPrice());
  1862.                         //$supplierservices->setCurrency('Euro');
  1863.                         $supplierservices->setUnits('1');
  1864.                         $supplierservices->setCommission($av->getCommission());
  1865.                         //$supplierservices->setOver('Accommodation');
  1866.                         $supplierservices->setIva($av->getIva());
  1867.                         $supplierservices->setPax('0');
  1868.                         //$supplierservices->setHour('');//null
  1869.                         //$supplierservices->setDateInAt('');
  1870.                         //$supplierservices->setDateOutAt('');
  1871.                         $supplierservices->setDirectPayment('0');
  1872.                         $supplierservices->setStatus('Pending');
  1873.                         $supplierservices->setStatusinternal($additional);
  1874.                         $em->persist($supplierservices);
  1875.                         $em->flush();
  1876.                         $em->clear();
  1877.                         //para pruebas
  1878.                         //$data_prueba[] = array(
  1879.                         //    'data' => $supplierservices
  1880.                         //);
  1881.                     }
  1882.                     //para pruebas
  1883.                     //d($data_prueba);
  1884.                     //exit();
  1885.                 }
  1886.                 /* metemos creative *////////////////////////////////////////////////////////////////
  1887.                 $creatives $em->getRepository(SupplierCreative::class)->findBySupplierId($id);
  1888.                 if(!empty($creatives)){
  1889.                     foreach($creatives as $creative){
  1890.                         $supplierservices->setServiceId($creative->getId());
  1891.                         $supplierservices->setServiceCatId('4');
  1892.                         $supplierservices->setServiceCatName('Creative');
  1893.                         $supplierservices->setName($creative->getTitle());
  1894.                         $supplierservices->setPrice('0');
  1895.                         //$supplierservices->setCurrency('Euro');
  1896.                         $supplierservices->setUnits('1');
  1897.                         $supplierservices->setCommission('0');
  1898.                         //$supplierservices->setOver('Accommodation');
  1899.                         $supplierservices->setIva('21');
  1900.                         $supplierservices->setPax('0');
  1901.                         //$supplierservices->setHour('');//null
  1902.                         //$supplierservices->setDateInAt('');
  1903.                         //$supplierservices->setDateOutAt('');
  1904.                         $supplierservices->setDirectPayment('0');
  1905.                         $supplierservices->setStatus('Pending');
  1906.                         $supplierservices->setStatusinternal($additional);
  1907.                         $em->persist($supplierservices);
  1908.                         $em->flush();
  1909.                         $em->clear();
  1910.                         //para pruebas
  1911.                         //$data_prueba[] = array(
  1912.                         //    'data' => $supplierservices
  1913.                         //);
  1914.                     }
  1915.                     //para pruebas
  1916.                     //d($data_prueba);
  1917.                     //exit();
  1918.                 }
  1919.                 /* metemos gift *////////////////////////////////////////////////////////////////
  1920.                 $gifts $em->getRepository(SupplierGifts::class)->findBySupplierId($id);
  1921.                 if(!empty($gifts)){
  1922.                     foreach($gifts as $gift){
  1923.                         $supplierservices->setServiceId($gift->getId());
  1924.                         $supplierservices->setServiceCatId('7');
  1925.                         $supplierservices->setServiceCatName('Gifts');
  1926.                         $supplierservices->setName($gift->getName());
  1927.                         $supplierservices->setPrice($gift->getPrice());
  1928.                         //$supplierservices->setCurrency('Euro');
  1929.                         $supplierservices->setUnits('1');
  1930.                         $supplierservices->setCommission($gift->getCommission());
  1931.                         //$supplierservices->setOver('Accommodation');
  1932.                         $supplierservices->setIva($gift->getIva());
  1933.                         $supplierservices->setPax('0');
  1934.                         //$supplierservices->setHour('');//null
  1935.                         //$supplierservices->setDateInAt('');
  1936.                         //$supplierservices->setDateOutAt('');
  1937.                         $supplierservices->setDirectPayment('0');
  1938.                         $supplierservices->setStatus('Pending');
  1939.                         $supplierservices->setStatusinternal($additional);
  1940.                         $em->persist($supplierservices);
  1941.                         $em->flush();
  1942.                         $em->clear();
  1943.                         //para pruebas
  1944.                         //$data_prueba[] = array(
  1945.                         //    'data' => $supplierservices
  1946.                         //);
  1947.                     }
  1948.                     //para pruebas
  1949.                     //d($data_prueba);
  1950.                     //exit();
  1951.                 }
  1952.                 /* metemos entertainment *////////////////////////////////////////////////////////////////
  1953.                 $entertainments $em->getRepository(SupplierEntertainment::class)->findBySupplierId($id);
  1954.                 if(!empty($entertainments)){
  1955.                     foreach($entertainments as $entertainment){
  1956.                         $supplierservices->setServiceId($entertainment->getId());
  1957.                         $supplierservices->setServiceCatId('6');
  1958.                         $supplierservices->setServiceCatName('Entertainment');
  1959.                         $supplierservices->setName($entertainment->getName());
  1960.                         $supplierservices->setPrice($entertainment->getPrice());
  1961.                         //$supplierservices->setCurrency('Euro');
  1962.                         $supplierservices->setUnits('1');
  1963.                         $supplierservices->setCommission($entertainment->getCommission());
  1964.                         //$supplierservices->setOver('Accommodation');
  1965.                         $supplierservices->setIva($entertainment->getIva());
  1966.                         $supplierservices->setPax('0');
  1967.                         //$supplierservices->setHour('');//null
  1968.                         //$supplierservices->setDateInAt('');
  1969.                         //$supplierservices->setDateOutAt('');
  1970.                         $supplierservices->setDirectPayment('0');
  1971.                         $supplierservices->setStatus('Pending');
  1972.                         $supplierservices->setStatusinternal($additional);
  1973.                         $em->persist($supplierservices);
  1974.                         $em->flush();
  1975.                         $em->clear();
  1976.                         //para pruebas
  1977.                         //$data_prueba[] = array(
  1978.                         //    'data' => $supplierservices
  1979.                         //);
  1980.                     }
  1981.                     //para pruebas
  1982.                     //d($data_prueba);
  1983.                     //exit();
  1984.                 }
  1985.                 /* metemos guide *////////////////////////////////////////////////////////////////
  1986.                 $guides $em->getRepository(SupplierGuide::class)->findBySupplierId($id);
  1987.                 if(!empty($guides)){
  1988.                     foreach($guides as $guide){
  1989.                         $supplierservices->setServiceId($guide->getId());
  1990.                         $supplierservices->setServiceCatId('8');
  1991.                         $supplierservices->setServiceCatName('Guide');
  1992.                         $supplierservices->setName($guide->getName());
  1993.                         $supplierservices->setPrice($guide->getPrice());
  1994.                         //$supplierservices->setCurrency('Euro');
  1995.                         $supplierservices->setUnits('1');
  1996.                         $supplierservices->setCommission($guide->getCommission());
  1997.                         //$supplierservices->setOver('Accommodation');
  1998.                         $supplierservices->setIva($guide->getIva());
  1999.                         $supplierservices->setPax('0');
  2000.                         //$supplierservices->setHour('');//null
  2001.                         //$supplierservices->setDateInAt('');
  2002.                         //$supplierservices->setDateOutAt('');
  2003.                         $supplierservices->setDirectPayment('0');
  2004.                         $supplierservices->setStatus('Pending');
  2005.                         $supplierservices->setStatusinternal($additional);
  2006.                         $em->persist($supplierservices);
  2007.                         $em->flush();
  2008.                         $em->clear();
  2009.                         //para pruebas
  2010.                         //$data_prueba[] = array(
  2011.                         //    'data' => $supplierservices
  2012.                         //);
  2013.                     }
  2014.                     //para pruebas
  2015.                     //d($data_prueba);
  2016.                     //exit();
  2017.                 }
  2018.                 /* metemos others *////////////////////////////////////////////////////////////////
  2019.                 $otherss $em->getRepository(SupplierOthers::class)->findBySupplierId($id);
  2020.                 if(!empty($otherss)){
  2021.                     foreach($otherss as $others){
  2022.                         $supplierservices->setServiceId($others->getId());
  2023.                         $supplierservices->setServiceCatId('12');
  2024.                         $supplierservices->setServiceCatName('Others');
  2025.                         $supplierservices->setName($others->getName());
  2026.                         $supplierservices->setPrice($others->getPrice());
  2027.                         //$supplierservices->setCurrency('Euro');
  2028.                         $supplierservices->setUnits('1');
  2029.                         $supplierservices->setCommission($others->getCommission());
  2030.                         //$supplierservices->setOver('Accommodation');
  2031.                         $supplierservices->setIva($others->getIva());
  2032.                         $supplierservices->setPax('0');
  2033.                         //$supplierservices->setHour('');//null
  2034.                         //$supplierservices->setDateInAt('');
  2035.                         //$supplierservices->setDateOutAt('');
  2036.                         $supplierservices->setDirectPayment('0');
  2037.                         $supplierservices->setStatus('Pending');
  2038.                         $supplierservices->setStatusinternal($additional);
  2039.                         $em->persist($supplierservices);
  2040.                         $em->flush();
  2041.                         $em->clear();
  2042.                         //para pruebas
  2043.                         //$data_prueba[] = array(
  2044.                         //    'data' => $supplierservices
  2045.                         //);
  2046.                     }
  2047.                     //para pruebas
  2048.                     //d($data_prueba);
  2049.                     //exit();
  2050.                 }
  2051.                 /* metemos technology *////////////////////////////////////////////////////////////////
  2052.                 $technologys $em->getRepository(SupplierTechnology::class)->findBySupplierId($id);
  2053.                 if(!empty($technologys)){
  2054.                     foreach($technologys as $technology){
  2055.                         $supplierservices->setServiceId($technology->getId());
  2056.                         $supplierservices->setServiceCatId('14');
  2057.                         $supplierservices->setServiceCatName('Technology');
  2058.                         $supplierservices->setName($technology->getTitle());
  2059.                         $supplierservices->setPrice($technology->getPrice());
  2060.                         //$supplierservices->setCurrency('Euro');
  2061.                         $supplierservices->setUnits('1');
  2062.                         $supplierservices->setCommission($technology->getCommission());
  2063.                         //$supplierservices->setOver('Accommodation');
  2064.                         $supplierservices->setIva($technology->getIva());
  2065.                         $supplierservices->setPax('0');
  2066.                         //$supplierservices->setHour('');//null
  2067.                         //$supplierservices->setDateInAt('');
  2068.                         //$supplierservices->setDateOutAt('');
  2069.                         $supplierservices->setDirectPayment('0');
  2070.                         $supplierservices->setStatus('Pending');
  2071.                         $supplierservices->setStatusinternal($additional);
  2072.                         $em->persist($supplierservices);
  2073.                         $em->flush();
  2074.                         $em->clear();
  2075.                         //para pruebas
  2076.                         //$data_prueba[] = array(
  2077.                         //    'data' => $supplierservices
  2078.                         //);
  2079.                     }
  2080.                     //para pruebas
  2081.                     //d($data_prueba);
  2082.                     //exit();
  2083.                 }
  2084.                 /* metemos Assistant *////////////////////////////////////////////////////////////////
  2085.                 $assistants $em->getRepository(SupplierServicesAssistant::class)->findBySupplierId($id);
  2086.                 if(!empty($assistants)){
  2087.                     foreach($assistants as $assistant){
  2088.                         $supplierservices->setServiceId($assistant->getId());
  2089.                         $supplierservices->setServiceCatId('15');
  2090.                         $supplierservices->setServiceCatName('Assistant');
  2091.                         $supplierservices->setName($assistant->getName());
  2092.                         $supplierservices->setPrice($assistant->getPrice());
  2093.                         //$supplierservices->setCurrency('Euro');
  2094.                         $supplierservices->setUnits('1');
  2095.                         $supplierservices->setCommission($assistant->getCommission());
  2096.                         //$supplierservices->setOver('Accommodation');
  2097.                         $supplierservices->setIva($assistant->getIva());
  2098.                         $supplierservices->setPax('0');
  2099.                         //$supplierservices->setHour('');//null
  2100.                         //$supplierservices->setDateInAt('');
  2101.                         //$supplierservices->setDateOutAt('');
  2102.                         $supplierservices->setDirectPayment('0');
  2103.                         $supplierservices->setStatus('Pending');
  2104.                         $supplierservices->setStatusinternal($additional);
  2105.                         $em->persist($supplierservices);
  2106.                         $em->flush();
  2107.                         $em->clear();
  2108.                         //para pruebas
  2109.                         //$data_prueba[] = array(
  2110.                         //    'data' => $supplierservices
  2111.                         //);
  2112.                     }
  2113.                     //para pruebas
  2114.                     //d($data_prueba);
  2115.                     //exit();
  2116.                 }
  2117.                 /* FIN METEMOS EL CONTENIDO DE LA IDEA */
  2118.                 // Control para el sistema de revision
  2119.                 $ideas $em->getRepository(Ideas::class)->findOneById($supplier_proposal->getId());
  2120.                 $prpId $request->request->get('proposalsuppliercontrol')['proposalId'];
  2121.                 $revision1 = new RevisionCarga();
  2122.                 $revision2 = new RevisionCarga();
  2123.                 $revision3 = new RevisionCarga();
  2124.                 $revision1->setIdType($ideas->getId());
  2125.                 $revision2->setIdType($ideas->getId());
  2126.                 $revision3->setIdType($ideas->getId());
  2127.                 $revision1->setName($ideas->getName());
  2128.                 $revision2->setName($ideas->getName());
  2129.                 $revision3->setName($ideas->getName());
  2130.                 // Titulo, Destino y observacion
  2131.                 $revision1->setType('IDEA (Título) - Agregada al Proposal: '.$prpId);
  2132.                 $revision1->setLink('ideas/edit/'.$ideas->getId());
  2133.                 $revision1->setStatus(false);
  2134.                 $em->persist($revision1);
  2135.                 $em->flush();
  2136.                 // Descripcion
  2137.                 $revision2->setType('IDEA (Descripción) - Agregada al Proposal: '.$prpId);
  2138.                 // Buscamos el ID de la descripcion
  2139.                 $idact $ideas->getId();
  2140.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByIdeaId($idact);
  2141.                 $idctrl $controlgeneral->getId();
  2142.                 $supdesc $em->getRepository(SupplierDescription::class)->findOneBySupplierId($idctrl);
  2143.                 $id $supdesc->getId();
  2144.                 // FIN Buscamos el ID de la descripcion
  2145.                 $revision2->setLink('ideas/description/edit/'.$id);
  2146.                 $revision2->setStatus(false);
  2147.                 $em->persist($revision2);
  2148.                 $em->flush();
  2149.                 // Galería
  2150.                 $revision3->setType('IDEA (Galería) - Agregada al Proposal: '.$prpId);
  2151.                 $revision3->setLink('ideas/gallery/list/'.$ideas->getId());
  2152.                 $revision3->setStatus(false);
  2153.                 $em->persist($revision3);
  2154.                 $em->flush();
  2155.                 // FIN Control para el sistema de revision
  2156.                 $event 'The Idea Destination Proposal has been created.';
  2157.                 $successMessage $this->translator->trans($event);
  2158.                 $this->addFlash('mensajeproposaldestinationservices'$successMessage);
  2159.             }else{
  2160.                 $errorMessage $this->translator->trans('Error, some fields are empty');
  2161.                 $this->addFlash('mensajeproposaldestinationserviceserror'$errorMessage);
  2162.             }
  2163.         }else{
  2164.             $errorMessage $this->translator->trans('The proposal already has this Idea included');
  2165.             $this->addFlash('mensajeproposaldestinationserviceserror'$errorMessage);
  2166.         }
  2167.         return $this->redirectToRoute('proposal_destination_supplier_view', array(
  2168.             'id' => $control->getControlDestinationId(),
  2169.             '_fragment' => 's'.$control->getId()
  2170.         ));
  2171.     }
  2172.     /**
  2173.      * @Route("proposal/destination/services/disabled/{id}", name="proposal_destination_supplier_disabled")
  2174.      *
  2175.      */
  2176.     public function disabledAction($idRequest $request)
  2177.     {
  2178.         $em $this->getDoctrine()->getManager();
  2179.         $disabled $em->getRepository(ProposalSupplierControl::class)->findOneById($id);
  2180.         $proposal$em->getRepository(Proposal::class)->findOneById($disabled->getProposalId());
  2181.         $actual $disabled->getDisabled();
  2182.         $var_mensaje="";
  2183.         if($actual == "0"){
  2184.             $disabled->setDisabled('1');
  2185.             $var_mensaje "Disabled";
  2186.         }
  2187.         if($actual == "1"){
  2188.             $disabled->setDisabled('0');
  2189.             $var_mensaje "Activated";
  2190.         }
  2191.         $em->persist($disabled);
  2192.         $em->flush();
  2193.         $event 'The supplier has been. '.$var_mensaje;
  2194.         $successMessage $this->translator->trans($event);
  2195.         $this->addFlash('mensajeproposaldestinationservices'$successMessage);
  2196.         return $this->redirectToRoute('proposal_destination_supplier_view',
  2197.             array(
  2198.                 'id' => $disabled->getControlDestinationId(),
  2199.                 '_fragment' => 's'.$disabled->getId()
  2200.             )
  2201.         );
  2202.     }
  2203.     /**
  2204.      * @Route("proposal/destination/services/deleted/{id}", name="proposal_destination_supplier_deleted")
  2205.      *
  2206.      */
  2207. //    public function deleteAction($id, Request $request, LoggerInterface $logger)
  2208.     public function deleteAction($idRequest $request)
  2209.     {
  2210.         $em $this->getDoctrine()->getManager();
  2211.         $delete $em->getRepository(ProposalSupplierControl::class)->findOneById($id);
  2212.         $proposal $em->getRepository(Proposal::class)->findOneById($delete->getProposalId());
  2213.         $delete_services $em->getRepository(ProposalSupplierServices::class)->findByControlId($id);
  2214.         foreach ($delete_services as $delete_service) {
  2215.             $em->remove($delete_service);
  2216.         }
  2217.         $em->remove($delete);
  2218.         $em->flush();
  2219.         $event 'The supplier has been Deleted.';
  2220.         $successMessage $this->translator->trans($event);
  2221.         $this->addFlash('mensajeproposaldestinationservices'$successMessage);
  2222.         return $this->redirectToRoute('proposal_destination_supplier_view',
  2223.             array(
  2224.                 'id' => $delete->getControlDestinationId()
  2225.             )
  2226.         );
  2227.     }
  2228.     /**
  2229.      * @Route("proposal/destination/services/list/{idcontrol}", name="proposal_destination_supplier_list")
  2230.      */
  2231.     public function listAction($idcontrolRequest $request) {
  2232.         $em $this->getDoctrine()->getManager();
  2233.         $control $em->getRepository(ProposalSupplierControl::class)->findOneById($idcontrol);
  2234.         $idsupplier $control->getSupplierId();
  2235.         $ididea $control->getIdeaId();
  2236.         $idactivity $control->getActivityId();
  2237.         if($idsupplier == '0'){
  2238.             $id '0';
  2239.         }else{
  2240.             if(!is_null($idsupplier)){
  2241.                 /*CONTROL GENERAL*/
  2242.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneBySupplierId($idsupplier);
  2243.                 $id $controlgeneral->getId();
  2244.             }
  2245.             if(!is_null($idactivity)){
  2246.                 /*CONTROL GENERAL*/
  2247.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByActivityId($idactivity);
  2248.                 $id $controlgeneral->getId();
  2249.             }
  2250.             if(!is_null($ididea)){
  2251.                 /*CONTROL GENERAL*/
  2252.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByIdeaId($ididea);
  2253.                 $id $controlgeneral->getId();
  2254.             }
  2255.         }
  2256.         /* accommodations */
  2257.         $accommodations $em->getRepository(SupplierAccommodation::class)->findBySupplierId($id);
  2258.         $data_accommodation = array();
  2259.         foreach ($accommodations as $accommodation) {
  2260.             /* Consulta en Control Services */
  2261.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2262.                 'servicesId' => $accommodation->getId(),
  2263.                 'servicesCat' => $accommodation->getControlCat()
  2264.             ));
  2265.             //class="label label-flat label-rounded label-icon border-grey text-grey"
  2266.             if ($accommodation->getMinibar()){
  2267.                 $accommodation->setMinibar('<span class="label quitar-margin-15"><img src="/assets/images/icons/mi-20.png"></span>');
  2268.             }
  2269.             if ($accommodation->getWifi()){
  2270.                 $accommodation->setWifi('<span class="label quitar-margin-15"><img src="/assets/images/icons/wi-20.png"></span>');
  2271.             }
  2272.             if ($accommodation->getAirconditioner()){
  2273.                 $accommodation->setAirconditioner('<span class="label quitar-margin-15"><img src="/assets/images/icons/ac-20.png"></span>');
  2274.             }
  2275.             if ($accommodation->getCalefaction()){
  2276.                 $accommodation->setCalefaction('<span class="label quitar-margin-15"><img src="/assets/images/icons/ca-20.png"></span>');
  2277.             }
  2278.             if ($accommodation->getPool()){
  2279.                 $accommodation->setPool('<span class="label quitar-margin-15"><img src="/assets/images/icons/po-20.png"></span>');
  2280.             }
  2281.             if ($accommodation->getBath()){
  2282.                 $accommodation->setBath('<span class="label quitar-margin-15"><img src="/assets/images/icons/ba-20.png"></span>');
  2283.             }
  2284.             if ($accommodation->getCoffeemaker()){
  2285.                 $accommodation->setCoffeemaker('<span class="label quitar-margin-15"><img src="/assets/images/icons/cm-20.png"></span>');
  2286.             }
  2287.             if ($accommodation->getKitchen()){
  2288.                 $accommodation->setKitchen('<span class="label quitar-margin-15"><img src="/assets/images/icons/ki-20.png"></span>');
  2289.             }
  2290.             if ($accommodation->getWasher()){
  2291.                 $accommodation->setWasher('<span class="label quitar-margin-15"><img src="/assets/images/icons/wa-20.png"></span>');
  2292.             }
  2293.             if ($accommodation->getFlattv()){
  2294.                 $accommodation->setFlattv('<span class="label quitar-margin-15"><img src="/assets/images/icons/tv-20.png"></span>');
  2295.             }
  2296.             if ($accommodation->getElectrickettle()){
  2297.                 $accommodation->setElectrickettle('<span class="label quitar-margin-15"><img src="/assets/images/icons/ke-20.png"></span>');
  2298.             }
  2299.             if ($accommodation->getViews()){
  2300.                 $accommodation->setViews('<span class="label quitar-margin-15"><img src="/assets/images/icons/vi-20.png"></span>');
  2301.             }
  2302.             if ($accommodation->getPets()){
  2303.                 $accommodation->setPets('<span class="label quitar-margin-15"><img src="/assets/images/icons/pe-20.png"></span>');
  2304.             }
  2305. //                $data_accommodation[]=$accommodation;
  2306.             $data_accommodation[] = array(
  2307.                 'id' => $accommodation->getId(),
  2308.                 'name' => $accommodation->getName(),
  2309.                 'size' => $accommodation->getSize(),
  2310.                 'quantity' => $accommodation->getQuantity(),
  2311.                 'price' => $accommodation->getPrice(),
  2312.                 'controlId' => $controlctrlDes->getId(),
  2313.                 'minibar' => $accommodation->getMinibar(),
  2314.                 'wifi' => $accommodation->getWifi(),
  2315.                 'airconditioner' => $accommodation->getAirconditioner(),
  2316.                 'calefaction' => $accommodation->getCalefaction(),
  2317.                 'pool' => $accommodation->getPool(),
  2318.                 'bath' => $accommodation->getBath(),
  2319.                 'coffeemaker' => $accommodation->getCoffeemaker(),
  2320.                 'kitchen' => $accommodation->getKitchen(),
  2321.                 'washer' => $accommodation->getWasher(),
  2322.                 'flattv' => $accommodation->getFlattv(),
  2323.                 'electrickettle' => $accommodation->getElectrickettle(),
  2324.                 'views' => $accommodation->getViews(),
  2325.                 'pets' => $accommodation->getPets()
  2326.             );
  2327.         }
  2328.         /* accommodations */
  2329.         /* menu */
  2330.         $menus $em->getRepository(SupplierMenu::class)->findBySupplierId($id);
  2331.         /* menu Description*/
  2332.         $data_menu = array();
  2333.         foreach($menus as $menu){
  2334.             /* Consulta en Control Description */
  2335.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2336.                 'servicesId' => $menu->getId(),
  2337.                 'servicesCat' => $menu->getControlCat()
  2338.             ));
  2339. //            $controlctrlDes->getId();
  2340. //            $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2341.             $data_menu[] = array(
  2342.                 'id' => $menu->getId(),
  2343.                 'title' => $menu->getTitle(),
  2344.                 'description' => $menu->getDescription(),
  2345.                 'currency' => $menu->getCurrency(),
  2346.                 'price' => $menu->getPrice(),
  2347.                 'commission' => $menu->getCommission(),
  2348.                 'iva' => $menu->getIva(),
  2349.                 'controlId' => $controlctrlDes->getId()
  2350.             );
  2351.         }
  2352.         /* lounge */
  2353.         $lounges $em->getRepository(SupplierLounge::class)->findBySupplierId($id);
  2354.         /* lounge Description*/
  2355.         $data_lounge = array();
  2356.         foreach($lounges as $lounge){
  2357.             /* Consulta en Control Description */
  2358.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2359.                 'servicesId' => $lounge->getId(),
  2360.                 'servicesCat' => $lounge->getControlCat()
  2361.             ));
  2362. //            $controlctrlDes->getId();
  2363. //            $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2364.             $data_lounge[] = array(
  2365.                 'id' => $lounge->getId(),
  2366.                 'name' => $lounge->getName(),
  2367.                 'currency' => $lounge->getCurrency(),
  2368.                 'price' => $lounge->getPrice(),
  2369.                 'commission' => $lounge->getCommission(),
  2370.                 'iva' => $lounge->getIva(),
  2371.                 'controlId' => $controlctrlDes->getId()
  2372.             );
  2373.         }
  2374.         /* Transport */
  2375.         $transports $em->getRepository(SupplierTransport::class)->findBySupplierId($id);
  2376.         /* Transport Description*/
  2377.         $data_transport = array();
  2378.         foreach($transports as $transport){
  2379.             /* Consulta en Control Description */
  2380.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2381.                 'servicesId' => $transport->getId(),
  2382.                 'servicesCat' => $transport->getControlCat()
  2383.             ));
  2384. //            $controlctrlDes->getId();
  2385. //            $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2386.             $data_transport[] = array(
  2387.                 'id' => $transport->getId(),
  2388.                 'name' => $transport->getName(),
  2389.                 'driver' => $transport->getDriver(),
  2390.                 'currency' => $transport->getCurrency(),
  2391.                 'price' => $transport->getPrice(),
  2392.                 'commission' => $transport->getCommission(),
  2393.                 'iva' => $transport->getIva(),
  2394.                 'controlId' => $controlctrlDes->getId()
  2395.             );
  2396.         }
  2397.         /* Guide */
  2398.         $guides $em->getRepository(SupplierGuide::class)->findBySupplierId($id);
  2399.         /* Guide Description*/
  2400.         $data_guide = array();
  2401.         foreach($guides as $guide){
  2402.             /* Consulta en Control Description */
  2403.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2404.                 'servicesId' => $guide->getId(),
  2405.                 'servicesCat' => $guide->getControlCat()
  2406.             ));
  2407. //            $controlctrlDes->getId();
  2408. //            $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2409.             $data_guide[] = array(
  2410.                 'id' => $guide->getId(),
  2411.                 'name' => $guide->getName(),
  2412.                 'guide' => $guide->getGuide(),
  2413.                 'currency' => $guide->getCurrency(),
  2414.                 'price' => $guide->getPrice(),
  2415.                 'commission' => $guide->getCommission(),
  2416.                 'iva' => $guide->getIva(),
  2417.                 'controlId' => $controlctrlDes->getId()
  2418.             );
  2419.         }
  2420.         /* Itineraries */
  2421.         $itinerariess $em->getRepository(SupplierItineraries::class)->findBySupplierId($id);
  2422.         /* Itineraries Description*/
  2423.         $data_itineraries = array();
  2424.         foreach($itinerariess as $itineraries){
  2425.             /* Consulta en Control Description */
  2426.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2427.                 'servicesId' => $itineraries->getId(),
  2428.                 'servicesCat' => $itineraries->getControlCat()
  2429.             ));
  2430.             //$controlctrlDes->getId();
  2431.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2432.             $data_itineraries[] = array(
  2433.                 'id' => $itineraries->getId(),
  2434.                 'title' => $itineraries->getTitle(),
  2435.                 'controlId' => $controlctrlDes->getId(),
  2436.                 'description' => $description
  2437.             );
  2438.         }
  2439.         /* activities */
  2440.         $activitiess $em->getRepository(SupplierActivities::class)->findBySupplierId($id);
  2441.         /* activities Description*/
  2442.         $data_activities = array();
  2443.         foreach($activitiess as $activities){
  2444.             /* Consulta en Control Description */
  2445.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2446.                 'servicesId' => $activities->getId(),
  2447.                 'servicesCat' => $activities->getControlCat()
  2448.             ));
  2449.             //$controlctrlDes->getId();
  2450.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2451.             $data_activities[] = array(
  2452.                 'id' => $activities->getId(),
  2453.                 'title' => $activities->getTitle(),
  2454.                 'capacity' => $activities->getCapacity(),
  2455.                 'currency' => $activities->getCurrency(),
  2456.                 'price' => $activities->getPrice(),
  2457.                 'commission' => $activities->getCommission(),
  2458.                 'iva' => $activities->getIva(),
  2459.                 'controlId' => $controlctrlDes->getId(),
  2460.                 'description' => $description
  2461.             );
  2462.         }
  2463.         /* cruise */
  2464.         $cruises $em->getRepository(SupplierCruise::class)->findBySupplierId($id);
  2465.         /* cruise Description*/
  2466.         $data_cruise = array();
  2467.         foreach($cruises as $cruise){
  2468.             /* Consulta en Control Description */
  2469.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2470.                 'servicesId' => $cruise->getId(),
  2471.                 'servicesCat' => $cruise->getControlCat()
  2472.             ));
  2473.             //$controlctrlDes->getId();
  2474.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2475.             $data_cruise[] = array(
  2476.                 'id' => $cruise->getId(),
  2477.                 'title' => $cruise->getTitle(),
  2478.                 'currency' => $cruise->getCurrency(),
  2479.                 'price' => $cruise->getPrice(),
  2480.                 'commission' => $cruise->getCommission(),
  2481.                 'iva' => $cruise->getIva(),
  2482.                 'controlId' => $controlctrlDes->getId(),
  2483.                 'description' => $description
  2484.             );
  2485.         }
  2486.         /* Av */
  2487.         $avs $em->getRepository(SupplierAv::class)->findBySupplierId($id);
  2488.         /* Av Description*/
  2489.         $data_av = array();
  2490.         foreach($avs as $av){
  2491.             /* Consulta en Control Description */
  2492.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2493.                 'servicesId' => $av->getId(),
  2494.                 'servicesCat' => $av->getControlCat()
  2495.             ));
  2496.             //$controlctrlDes->getId();
  2497.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2498.             $data_av[] = array(
  2499.                 'id' => $av->getId(),
  2500.                 'name' => $av->getName(),
  2501.                 'responsible' => $av->getResponsible(),
  2502.                 'currency' => $av->getCurrency(),
  2503.                 'price' => $av->getPrice(),
  2504.                 'commission' => $av->getCommission(),
  2505.                 'iva' => $av->getIva(),
  2506.                 'controlId' => $controlctrlDes->getId(),
  2507.                 'description' => $description
  2508.             );
  2509.         }
  2510.         /* Creative */
  2511.         $creatives $em->getRepository(SupplierCreative::class)->findBySupplierId($id);
  2512.         /* Creative Description*/
  2513.         $data_creative = array();
  2514.         foreach($creatives as $creative){
  2515.             /* Consulta en Control Description */
  2516.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2517.                 'servicesId' => $creative->getId(),
  2518.                 'servicesCat' => $creative->getControlCat()
  2519.             ));
  2520.             //$controlctrlDes->getId();
  2521.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2522.             $data_creative[] = array(
  2523.                 'id' => $creative->getId(),
  2524.                 'title' => $creative->getTitle(),
  2525.                 'controlId' => $controlctrlDes->getId(),
  2526.                 'description' => $description
  2527.             );
  2528.         }
  2529.         /* Gifts */
  2530.         $gifts $em->getRepository(SupplierGifts::class)->findBySupplierId($id);
  2531.         /* Gifts Description*/
  2532.         $data_gifts = array();
  2533.         foreach($gifts as $gift){
  2534.             /* Consulta en Control Description */
  2535.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2536.                 'servicesId' => $gift->getId(),
  2537.                 'servicesCat' => $gift->getControlCat()
  2538.             ));
  2539.             //$controlctrlDes->getId();
  2540.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2541.             $data_gifts[] = array(
  2542.                 'id' => $gift->getId(),
  2543.                 'name' => $gift->getName(),
  2544.                 'responsible' => $gift->getResponsible(),
  2545.                 'currency' => $gift->getCurrency(),
  2546.                 'price' => $gift->getPrice(),
  2547.                 'commission' => $gift->getCommission(),
  2548.                 'iva' => $gift->getIva(),
  2549.                 'controlId' => $controlctrlDes->getId(),
  2550.                 'description' => $description
  2551.             );
  2552.         }
  2553.         /* Entertainment */
  2554.         $entertainments $em->getRepository(SupplierEntertainment::class)->findBySupplierId($id);
  2555.         /* Entertainment Description*/
  2556.         $data_entertainment = array();
  2557.         foreach($entertainments as $entertainment){
  2558.             /* Consulta en Control Description */
  2559.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2560.                 'servicesId' => $entertainment->getId(),
  2561.                 'servicesCat' => $entertainment->getControlCat()
  2562.             ));
  2563.             //$controlctrlDes->getId();
  2564.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2565.             $data_entertainment[] = array(
  2566.                 'id' => $entertainment->getId(),
  2567.                 'name' => $entertainment->getName(),
  2568.                 'responsible' => $entertainment->getResponsible(),
  2569.                 'currency' => $entertainment->getCurrency(),
  2570.                 'price' => $entertainment->getPrice(),
  2571.                 'commission' => $entertainment->getCommission(),
  2572.                 'iva' => $entertainment->getIva(),
  2573.                 'controlId' => $controlctrlDes->getId(),
  2574.                 'description' => $description
  2575.             );
  2576.         }
  2577.         /* Others */
  2578.         $otherss $em->getRepository(SupplierOthers::class)->findBySupplierId($id);
  2579.         /* Others Description*/
  2580.         $data_others = array();
  2581.         foreach($otherss as $others){
  2582.             /* Consulta en Control Description */
  2583.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2584.                 'servicesId' => $others->getId(),
  2585.                 'servicesCat' => $others->getControlCat()
  2586.             ));
  2587.             //$controlctrlDes->getId();
  2588.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2589.             $data_others[] = array(
  2590.                 'id' => $others->getId(),
  2591.                 'name' => $others->getName(),
  2592.                 'responsible' => $others->getResponsible(),
  2593.                 'currency' => $others->getCurrency(),
  2594.                 'price' => $others->getPrice(),
  2595.                 'commission' => $others->getCommission(),
  2596.                 'iva' => $others->getIva(),
  2597.                 'controlId' => $controlctrlDes->getId(),
  2598.                 'description' => $description
  2599.             );
  2600.         }
  2601.         /* technology */
  2602.         if ($idsupplier == 2){          // Es una tecnologia de Develup
  2603.             $technologys $em->getRepository(MdvProduct::class)->findAll();
  2604.             $data_technology = array();
  2605.             foreach($technologys as $technology){
  2606.                 $data_technology[] = array(
  2607.                     'id' => $technology->getId(),
  2608.                     'title' => $technology->getName(),
  2609.                     'modules' => null,
  2610.                     'type' => $technology->getType(),
  2611.                     'currency' => 'Euro',
  2612.                     'price' => $technology->getPrice(),
  2613.                     'commission' => $technology->getCommission(),
  2614.                     'iva' => $technology->getIva(),
  2615.                     'controlId' => null,
  2616.                     'description' => $technology->getDescription(),
  2617.                     'supplier' => 'Develup',
  2618.                 );
  2619.             }
  2620.         } else {
  2621.             $technologys $em->getRepository(SupplierTechnology::class)->findBySupplierId($id);
  2622.             /* technology Description*/
  2623.             $data_technology = array();
  2624.             foreach($technologys as $technology){
  2625.                 /* Consulta en Control Description */
  2626.                 $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2627.                     'servicesId' => $technology->getId(),
  2628.                     'servicesCat' => $technology->getControlCat()
  2629.                 ));
  2630.                 //$controlctrlDes->getId();
  2631.                 $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2632.                 $data_technology[] = array(
  2633.                     'id' => $technology->getId(),
  2634.                     'title' => $technology->getTitle(),
  2635.                     'modules' => $technology->getModules(),
  2636.                     'type' => $technology->getType(),
  2637.                     'currency' => $technology->getCurrency(),
  2638.                     'price' => $technology->getPrice(),
  2639.                     'commission' => $technology->getCommission(),
  2640.                     'iva' => $technology->getIva(),
  2641.                     'controlId' => $controlctrlDes->getId(),
  2642.                     'description' => $description
  2643.                 );
  2644.             }
  2645.             /////////////////////////////////////////////////////////////////////
  2646.             $technologys $em->getRepository(SupplierTechnology::class)->findBySupplierId($id);
  2647.             /* technology Description*/
  2648.             $data_technology = array();
  2649.             foreach($technologys as $technology){
  2650.                 /* Consulta en Control Description */
  2651.                 $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2652.                     'servicesId' => $technology->getId(),
  2653.                     'servicesCat' => $technology->getControlCat()
  2654.                 ));
  2655.                 //$controlctrlDes->getId();
  2656.                 $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2657.                 $data_technology[] = array(
  2658.                     'id' => $technology->getId(),
  2659.                     'title' => $technology->getTitle(),
  2660.                     'modules' => $technology->getModules(),
  2661.                     'type' => $technology->getType(),
  2662.                     'currency' => $technology->getCurrency(),
  2663.                     'price' => $technology->getPrice(),
  2664.                     'commission' => $technology->getCommission(),
  2665.                     'iva' => $technology->getIva(),
  2666.                     'controlId' => $controlctrlDes->getId(),
  2667.                     'description' => $description
  2668.                 );
  2669.             }
  2670.         }
  2671.         /* Assistant  */
  2672.         $assistants $em->getRepository(SupplierServicesAssistant::class)->findBySupplierId($id);
  2673.         /* Assistant  Description*/
  2674.         $data_assistant = array();
  2675.         foreach($assistants as $assistant){
  2676.             /* Consulta en Control Description */
  2677.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2678.                 'servicesId' => $assistant->getId(),
  2679.                 'servicesCat' => $assistant->getControlCat()
  2680.             ));
  2681.             //$controlctrlDes->getId();
  2682.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2683.             $data_assistant[] = array(
  2684.                 'id' => $assistant->getId(),
  2685.                 'name' => $assistant->getName(),
  2686.                 'quantity' => $assistant->getQuantity(),
  2687.                 'currency' => $assistant->getCurrency(),
  2688.                 'price' => $assistant->getPrice(),
  2689.                 'commission' => $assistant->getCommission(),
  2690.                 'iva' => $assistant->getIva(),
  2691.                 'controlId' => $controlctrlDes->getId(),
  2692.                 'description' => $description
  2693.             );
  2694.         }
  2695.         /* salida de data */
  2696.         return $this->render('MDS/EventsBundle/services/services-modal-proposal.html.twig', array(
  2697.             'idcontrol' => $idcontrol,
  2698.             'accommodations' => $data_accommodation,
  2699.             'menus' => $data_menu,
  2700.             'lounges' => $data_lounge,
  2701.             'transports' => $data_transport,
  2702.             'guides' => $data_guide,
  2703.             'itineraries' => $data_itineraries,
  2704.             'activities' => $data_activities,
  2705.             'cruises' => $data_cruise,
  2706.             'avs' => $data_av,
  2707.             'creatives' => $data_creative,
  2708.             'gifts' => $data_gifts,
  2709.             'entertainments' => $data_entertainment,
  2710.             'technology' => $data_technology,
  2711.             'assistants' => $data_assistant,
  2712.             'otherss' => $data_others
  2713.         ));
  2714.     }
  2715.     /**
  2716.      * @Route("proposal/destination/servicesesp/list/{idcontrol}", name="proposal_destination_supplier_especial_list")
  2717.      */
  2718.     public function listEspecialSupplierAction($idcontrolRequest $request) {
  2719.         $em $this->getDoctrine()->getManager();
  2720.         $control $em->getRepository(ProposalSupplierControl::class)->findOneById($idcontrol);
  2721.         $idsupplier $control->getSupplierId();
  2722.         $cdid $control->getControlDestinationId();
  2723.         $ididea $control->getIdeaId();
  2724.         $idactivity $control->getActivityId();
  2725.         $proposal $em->getRepository(Proposal::class)->findOneById($control->getProposalId());
  2726.         if($idsupplier == '0'){
  2727.             $id '0';
  2728.         }else{
  2729.             if(!is_null($idsupplier)){
  2730.                 /*CONTROL GENERAL*/
  2731.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneBySupplierId($idsupplier);
  2732.                 $id $controlgeneral->getId();
  2733.             }
  2734.             if(!is_null($idactivity)){
  2735.                 /*CONTROL GENERAL*/
  2736.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByActivityId($idactivity);
  2737.                 $id $controlgeneral->getId();
  2738.             }
  2739.             if(!is_null($ididea)){
  2740.                 /*CONTROL GENERAL*/
  2741.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByIdeaId($ididea);
  2742.                 $id $controlgeneral->getId();
  2743.             }
  2744.         }
  2745.         /* accommodations */
  2746.         $accommodations $em->getRepository(SupplierAccommodation::class)->findBySupplierId($id);
  2747.         $data_accommodation = array();
  2748.         foreach ($accommodations as $accommodation) {
  2749.             /* Consulta en Control Services */
  2750.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2751.                 'servicesId' => $accommodation->getId(),
  2752.                 'servicesCat' => $accommodation->getControlCat()
  2753.             ));
  2754.             //class="label label-flat label-rounded label-icon border-grey text-grey"
  2755.             if ($accommodation->getMinibar()){
  2756.                 $accommodation->setMinibar('<span class="label quitar-margin-15"><img src="/assets/images/icons/mi-20.png"></span>');
  2757.             }
  2758.             if ($accommodation->getWifi()){
  2759.                 $accommodation->setWifi('<span class="label quitar-margin-15"><img src="/assets/images/icons/wi-20.png"></span>');
  2760.             }
  2761.             if ($accommodation->getAirconditioner()){
  2762.                 $accommodation->setAirconditioner('<span class="label quitar-margin-15"><img src="/assets/images/icons/ac-20.png"></span>');
  2763.             }
  2764.             if ($accommodation->getCalefaction()){
  2765.                 $accommodation->setCalefaction('<span class="label quitar-margin-15"><img src="/assets/images/icons/ca-20.png"></span>');
  2766.             }
  2767.             if ($accommodation->getPool()){
  2768.                 $accommodation->setPool('<span class="label quitar-margin-15"><img src="/assets/images/icons/po-20.png"></span>');
  2769.             }
  2770.             if ($accommodation->getBath()){
  2771.                 $accommodation->setBath('<span class="label quitar-margin-15"><img src="/assets/images/icons/ba-20.png"></span>');
  2772.             }
  2773.             if ($accommodation->getCoffeemaker()){
  2774.                 $accommodation->setCoffeemaker('<span class="label quitar-margin-15"><img src="/assets/images/icons/cm-20.png"></span>');
  2775.             }
  2776.             if ($accommodation->getKitchen()){
  2777.                 $accommodation->setKitchen('<span class="label quitar-margin-15"><img src="/assets/images/icons/ki-20.png"></span>');
  2778.             }
  2779.             if ($accommodation->getWasher()){
  2780.                 $accommodation->setWasher('<span class="label quitar-margin-15"><img src="/assets/images/icons/wa-20.png"></span>');
  2781.             }
  2782.             if ($accommodation->getFlattv()){
  2783.                 $accommodation->setFlattv('<span class="label quitar-margin-15"><img src="/assets/images/icons/tv-20.png"></span>');
  2784.             }
  2785.             if ($accommodation->getElectrickettle()){
  2786.                 $accommodation->setElectrickettle('<span class="label quitar-margin-15"><img src="/assets/images/icons/ke-20.png"></span>');
  2787.             }
  2788.             if ($accommodation->getViews()){
  2789.                 $accommodation->setViews('<span class="label quitar-margin-15"><img src="/assets/images/icons/vi-20.png"></span>');
  2790.             }
  2791.             if ($accommodation->getPets()){
  2792.                 $accommodation->setPets('<span class="label quitar-margin-15"><img src="/assets/images/icons/pe-20.png"></span>');
  2793.             }
  2794. //                $data_accommodation[]=$accommodation;
  2795.             $data_accommodation[] = array(
  2796.                 'id' => $accommodation->getId(),
  2797.                 'name' => $accommodation->getName(),
  2798.                 'size' => $accommodation->getSize(),
  2799.                 'quantity' => $accommodation->getQuantity(),
  2800.                 'price' => $accommodation->getPrice(),
  2801.                 'controlId' => $controlctrlDes->getId(),
  2802.                 'minibar' => $accommodation->getMinibar(),
  2803.                 'wifi' => $accommodation->getWifi(),
  2804.                 'airconditioner' => $accommodation->getAirconditioner(),
  2805.                 'calefaction' => $accommodation->getCalefaction(),
  2806.                 'pool' => $accommodation->getPool(),
  2807.                 'bath' => $accommodation->getBath(),
  2808.                 'coffeemaker' => $accommodation->getCoffeemaker(),
  2809.                 'kitchen' => $accommodation->getKitchen(),
  2810.                 'washer' => $accommodation->getWasher(),
  2811.                 'flattv' => $accommodation->getFlattv(),
  2812.                 'electrickettle' => $accommodation->getElectrickettle(),
  2813.                 'views' => $accommodation->getViews(),
  2814.                 'pets' => $accommodation->getPets()
  2815.             );
  2816.         }
  2817.         /* accommodations */
  2818.         /* menu */
  2819.         $menus $em->getRepository(SupplierMenu::class)->findBySupplierId($id);
  2820.         /* menu Description*/
  2821.         $data_menu = array();
  2822.         foreach($menus as $menu){
  2823.             /* Consulta en Control Description */
  2824.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2825.                 'servicesId' => $menu->getId(),
  2826.                 'servicesCat' => $menu->getControlCat()
  2827.             ));
  2828. //            $controlctrlDes->getId();
  2829. //            $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2830.             $data_menu[] = array(
  2831.                 'id' => $menu->getId(),
  2832.                 'title' => $menu->getTitle(),
  2833.                 'description' => $menu->getDescription(),
  2834.                 'currency' => $menu->getCurrency(),
  2835.                 'price' => $menu->getPrice(),
  2836.                 'commission' => $menu->getCommission(),
  2837.                 'iva' => $menu->getIva(),
  2838.                 'controlId' => $controlctrlDes->getId()
  2839.             );
  2840.         }
  2841.         /* lounge */
  2842.         $lounges $em->getRepository(SupplierLounge::class)->findBySupplierId($id);
  2843.         /* lounge Description*/
  2844.         $data_lounge = array();
  2845.         foreach($lounges as $lounge){
  2846.             /* Consulta en Control Description */
  2847.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2848.                 'servicesId' => $lounge->getId(),
  2849.                 'servicesCat' => $lounge->getControlCat()
  2850.             ));
  2851. //            $controlctrlDes->getId();
  2852. //            $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2853.             $data_lounge[] = array(
  2854.                 'id' => $lounge->getId(),
  2855.                 'name' => $lounge->getName(),
  2856.                 'currency' => $lounge->getCurrency(),
  2857.                 'price' => $lounge->getPrice(),
  2858.                 'commission' => $lounge->getCommission(),
  2859.                 'iva' => $lounge->getIva(),
  2860.                 'controlId' => $controlctrlDes->getId()
  2861.             );
  2862.         }
  2863.         /* Transport */
  2864.         $transports $em->getRepository(SupplierTransport::class)->findBySupplierId($id);
  2865.         /* Transport Description*/
  2866.         $data_transport = array();
  2867.         foreach($transports as $transport){
  2868.             /* Consulta en Control Description */
  2869.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2870.                 'servicesId' => $transport->getId(),
  2871.                 'servicesCat' => $transport->getControlCat()
  2872.             ));
  2873. //            $controlctrlDes->getId();
  2874. //            $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2875.             $data_transport[] = array(
  2876.                 'id' => $transport->getId(),
  2877.                 'name' => $transport->getName(),
  2878.                 'driver' => $transport->getDriver(),
  2879.                 'currency' => $transport->getCurrency(),
  2880.                 'price' => $transport->getPrice(),
  2881.                 'commission' => $transport->getCommission(),
  2882.                 'iva' => $transport->getIva(),
  2883.                 'controlId' => $controlctrlDes->getId()
  2884.             );
  2885.         }
  2886.         /* Guide */
  2887.         $guides $em->getRepository(SupplierGuide::class)->findBySupplierId($id);
  2888.         /* Guide Description*/
  2889.         $data_guide = array();
  2890.         foreach($guides as $guide){
  2891.             /* Consulta en Control Description */
  2892.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2893.                 'servicesId' => $guide->getId(),
  2894.                 'servicesCat' => $guide->getControlCat()
  2895.             ));
  2896. //            $controlctrlDes->getId();
  2897. //            $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2898.             $data_guide[] = array(
  2899.                 'id' => $guide->getId(),
  2900.                 'name' => $guide->getName(),
  2901.                 'guide' => $guide->getGuide(),
  2902.                 'currency' => $guide->getCurrency(),
  2903.                 'price' => $guide->getPrice(),
  2904.                 'commission' => $guide->getCommission(),
  2905.                 'iva' => $guide->getIva(),
  2906.                 'controlId' => $controlctrlDes->getId()
  2907.             );
  2908.         }
  2909.         /* Itineraries */
  2910.         $itinerariess $em->getRepository(SupplierItineraries::class)->findBySupplierId($id);
  2911.         /* Itineraries Description*/
  2912.         $data_itineraries = array();
  2913.         foreach($itinerariess as $itineraries){
  2914.             /* Consulta en Control Description */
  2915.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2916.                 'servicesId' => $itineraries->getId(),
  2917.                 'servicesCat' => $itineraries->getControlCat()
  2918.             ));
  2919.             //$controlctrlDes->getId();
  2920.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2921.             $data_itineraries[] = array(
  2922.                 'id' => $itineraries->getId(),
  2923.                 'title' => $itineraries->getTitle(),
  2924.                 'controlId' => $controlctrlDes->getId(),
  2925.                 'description' => $description
  2926.             );
  2927.         }
  2928.         /* activities */
  2929.         $activitiess $em->getRepository(SupplierActivities::class)->findBySupplierId($id);
  2930.         /* activities Description*/
  2931.         $data_activities = array();
  2932.         foreach($activitiess as $activities){
  2933.             /* Consulta en Control Description */
  2934.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2935.                 'servicesId' => $activities->getId(),
  2936.                 'servicesCat' => $activities->getControlCat()
  2937.             ));
  2938.             //$controlctrlDes->getId();
  2939.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2940.             $data_activities[] = array(
  2941.                 'id' => $activities->getId(),
  2942.                 'title' => $activities->getTitle(),
  2943.                 'capacity' => $activities->getCapacity(),
  2944.                 'currency' => $activities->getCurrency(),
  2945.                 'price' => $activities->getPrice(),
  2946.                 'commission' => $activities->getCommission(),
  2947.                 'iva' => $activities->getIva(),
  2948.                 'controlId' => $controlctrlDes->getId(),
  2949.                 'description' => $description
  2950.             );
  2951.         }
  2952.         /* cruise */
  2953.         $cruises $em->getRepository(SupplierCruise::class)->findBySupplierId($id);
  2954.         /* cruise Description*/
  2955.         $data_cruise = array();
  2956.         foreach($cruises as $cruise){
  2957.             /* Consulta en Control Description */
  2958.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2959.                 'servicesId' => $cruise->getId(),
  2960.                 'servicesCat' => $cruise->getControlCat()
  2961.             ));
  2962.             //$controlctrlDes->getId();
  2963.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2964.             $data_cruise[] = array(
  2965.                 'id' => $cruise->getId(),
  2966.                 'title' => $cruise->getTitle(),
  2967.                 'currency' => $cruise->getCurrency(),
  2968.                 'price' => $cruise->getPrice(),
  2969.                 'commission' => $cruise->getCommission(),
  2970.                 'iva' => $cruise->getIva(),
  2971.                 'controlId' => $controlctrlDes->getId(),
  2972.                 'description' => $description
  2973.             );
  2974.         }
  2975.         /* Av */
  2976.         if ($idsupplier == 80){
  2977.             // El proveedor del AV es AvExpress
  2978.             // Listamos por orden alfabetico y se deja de primero a "Otro servicio"
  2979.             $parameters = array();
  2980.             $dql 'SELECT i
  2981.                         FROM AvexpressBundle:AveProduct i
  2982.                         ORDER BY i.name ASC';
  2983.             $query $em->createQuery($dql)->setParameters($parameters);
  2984.             $avs $query->getResult();
  2985.             $newAvs = array();
  2986.             foreach ($avs as $key => $item) {
  2987.                 if ($item->getName() == 'Otro servicio'){
  2988.                     $item->setName('0 - Otro servicio');
  2989.                     $newAvs = array($item);
  2990.                     unset($avs[$key]);
  2991.                     foreach ($avs as $keyTwo => $elem){
  2992.                         $ind $keyTwo 1;
  2993.                         $elem->setName($ind.' - '.$elem->getName());
  2994.                         array_push($newAvs,$elem);
  2995.                     }
  2996.                 }
  2997.             }
  2998.             $avs $newAvs;
  2999.             /* av Description*/
  3000.             $data_av = array();
  3001.             foreach($avs as $av){
  3002.                 $data_av[] = array(
  3003.                     'id' => $av->getId(),
  3004.                     'name' => $av->getName(),
  3005. //                    'modules' => $technology->getModules(),
  3006.                     'modules' => null,
  3007.                     'type' => $av->getType(),
  3008.                     'currency' => 'Euro',
  3009.                     'price' => $av->getPrice(),
  3010.                     'commission' => 0,
  3011.                     'iva' => 21,
  3012.                     'controlId' => null,
  3013.                     'description' => $av->getDescription(),
  3014.                     'supplier' => 'AvExpress',
  3015.                 );
  3016.             }
  3017.             //   ***************************************** METEMOS AV TEMPLATES (Tipo: AVExpress Template)
  3018.             $parameters = array();
  3019.             $dql 'SELECT i
  3020.                         FROM AvexpressBundle:AveTemplate i
  3021.                         ORDER BY i.name ASC';
  3022.             $query $em->createQuery($dql)->setParameters($parameters);
  3023.             $avsTemplate $query->getResult();
  3024.             foreach($avsTemplate as $av){
  3025.                 $data_av[] = array(
  3026.                     'id' => $av->getId(),
  3027.                     'name' => $av->getName(),
  3028.                     'modules' => null,
  3029.                     'type' => 'AVExpress Template',
  3030.                     'currency' => null,
  3031.                     'price' => null,
  3032.                     'commission' => null,
  3033.                     'iva' => null,
  3034.                     'controlId' => null,
  3035.                     'description' => null,
  3036.                     'supplier' => 'AvExpress',
  3037.                 );
  3038.             }
  3039.         } else {
  3040.             $newAvs = array();
  3041.             $avs $em->getRepository(SupplierAv::class)->findBySupplierId($id);
  3042.             /* Av Description*/
  3043.             $data_av = array();
  3044.             foreach($avs as $av){
  3045.                 /* Consulta en Control Description */
  3046.                 $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  3047.                     'servicesId' => $av->getId(),
  3048.                     'servicesCat' => $av->getControlCat()
  3049.                 ));
  3050.                 //$controlctrlDes->getId();
  3051.                 $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  3052.                 $data_av[] = array(
  3053.                     'id' => $av->getId(),
  3054.                     'name' => $av->getName(),
  3055.                     'responsible' => $av->getResponsible(),
  3056.                     'currency' => $av->getCurrency(),
  3057.                     'price' => $av->getPrice(),
  3058.                     'commission' => $av->getCommission(),
  3059.                     'iva' => $av->getIva(),
  3060.                     'controlId' => $controlctrlDes->getId(),
  3061.                     'description' => $description
  3062.                 );
  3063.             }
  3064.         }
  3065.         /* Creative */
  3066.         $creatives $em->getRepository(SupplierCreative::class)->findBySupplierId($id);
  3067.         /* Creative Description*/
  3068.         $data_creative = array();
  3069.         foreach($creatives as $creative){
  3070.             /* Consulta en Control Description */
  3071.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  3072.                 'servicesId' => $creative->getId(),
  3073.                 'servicesCat' => $creative->getControlCat()
  3074.             ));
  3075.             //$controlctrlDes->getId();
  3076.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  3077.             $data_creative[] = array(
  3078.                 'id' => $creative->getId(),
  3079.                 'title' => $creative->getTitle(),
  3080.                 'controlId' => $controlctrlDes->getId(),
  3081.                 'description' => $description
  3082.             );
  3083.         }
  3084.         /* Gifts */
  3085.         $gifts $em->getRepository(SupplierGifts::class)->findBySupplierId($id);
  3086.         /* Gifts Description*/
  3087.         $data_gifts = array();
  3088.         foreach($gifts as $gift){
  3089.             /* Consulta en Control Description */
  3090.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  3091.                 'servicesId' => $gift->getId(),
  3092.                 'servicesCat' => $gift->getControlCat()
  3093.             ));
  3094.             //$controlctrlDes->getId();
  3095.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  3096.             $data_gifts[] = array(
  3097.                 'id' => $gift->getId(),
  3098.                 'name' => $gift->getName(),
  3099.                 'responsible' => $gift->getResponsible(),
  3100.                 'currency' => $gift->getCurrency(),
  3101.                 'price' => $gift->getPrice(),
  3102.                 'commission' => $gift->getCommission(),
  3103.                 'iva' => $gift->getIva(),
  3104.                 'controlId' => $controlctrlDes->getId(),
  3105.                 'description' => $description
  3106.             );
  3107.         }
  3108.         /* Entertainment */
  3109.         $entertainments $em->getRepository(SupplierEntertainment::class)->findBySupplierId($id);
  3110.         /* Entertainment Description*/
  3111.         $data_entertainment = array();
  3112.         foreach($entertainments as $entertainment){
  3113.             /* Consulta en Control Description */
  3114.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  3115.                 'servicesId' => $entertainment->getId(),
  3116.                 'servicesCat' => $entertainment->getControlCat()
  3117.             ));
  3118.             //$controlctrlDes->getId();
  3119.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  3120.             $data_entertainment[] = array(
  3121.                 'id' => $entertainment->getId(),
  3122.                 'name' => $entertainment->getName(),
  3123.                 'responsible' => $entertainment->getResponsible(),
  3124.                 'currency' => $entertainment->getCurrency(),
  3125.                 'price' => $entertainment->getPrice(),
  3126.                 'commission' => $entertainment->getCommission(),
  3127.                 'iva' => $entertainment->getIva(),
  3128.                 'controlId' => $controlctrlDes->getId(),
  3129.                 'description' => $description
  3130.             );
  3131.         }
  3132.         /* Others */
  3133.         $otherss $em->getRepository(SupplierOthers::class)->findBySupplierId($id);
  3134.         /* Others Description*/
  3135.         $data_others = array();
  3136.         foreach($otherss as $others){
  3137.             /* Consulta en Control Description */
  3138.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  3139.                 'servicesId' => $others->getId(),
  3140.                 'servicesCat' => $others->getControlCat()
  3141.             ));
  3142.             //$controlctrlDes->getId();
  3143.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  3144.             $data_others[] = array(
  3145.                 'id' => $others->getId(),
  3146.                 'name' => $others->getName(),
  3147.                 'responsible' => $others->getResponsible(),
  3148.                 'currency' => $others->getCurrency(),
  3149.                 'price' => $others->getPrice(),
  3150.                 'commission' => $others->getCommission(),
  3151.                 'iva' => $others->getIva(),
  3152.                 'controlId' => $controlctrlDes->getId(),
  3153.                 'description' => $description
  3154.             );
  3155.         }
  3156.         /* technology */
  3157.         if ($idsupplier == 2){          // Es una tecnologia de Develup
  3158. //            $technologys = $em->getRepository(MdvProduct::class)->findAll();
  3159.             // Listamos por orden alfabetico y se deja de primero a "Otro servicio"
  3160.             $parameters = array();
  3161.             $dql 'SELECT i
  3162.                         FROM DevelupBundle:MdvProduct i
  3163.                         ORDER BY i.name ASC';
  3164.             $query $em->createQuery($dql)->setParameters($parameters);
  3165.             $technologys $query->getResult();
  3166.             $newTechnologys = array();
  3167.             foreach ($technologys as $key => $item) {
  3168.                 if ($item->getName() == 'Otro servicio'){
  3169.                     $item->setName('0 - Otro servicio');
  3170.                     $newTechnologys = array($item);
  3171.                     unset($technologys[$key]);
  3172.                     foreach ($technologys as $keyTwo => $elem){
  3173.                         $ind $keyTwo 1;
  3174.                         $elem->setName($ind.' - '.$elem->getName());
  3175.                         array_push($newTechnologys,$elem);
  3176.                     }
  3177.                 }
  3178.             }
  3179.             $technologys $newTechnologys;
  3180.             /* technology Description*/
  3181.             $data_technology = array();
  3182.             foreach($technologys as $technology){
  3183.                 $data_technology[] = array(
  3184.                     'id' => $technology->getId(),
  3185.                     'title' => $technology->getName(),
  3186. //                    'modules' => $technology->getModules(),
  3187.                     'modules' => null,
  3188.                     'type' => $technology->getType(),
  3189.                     'currency' => 'Euro',
  3190.                     'price' => $technology->getPrice(),
  3191.                     'commission' => 0,
  3192.                     'iva' => 21,
  3193.                     'controlId' => null,
  3194.                     'description' => $technology->getDescription(),
  3195.                     'supplier' => 'Develup',
  3196.                 );
  3197.             }
  3198.         } else {
  3199.             $technologys $em->getRepository(SupplierTechnology::class)->findBySupplierId($id);
  3200.             $newTechnologys = array();
  3201.             /* technology Description*/
  3202.             $data_technology = array();
  3203.             foreach($technologys as $technology){
  3204.                 /* Consulta en Control Description */
  3205.                 $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  3206.                     'servicesId' => $technology->getId(),
  3207.                     'servicesCat' => $technology->getControlCat()
  3208.                 ));
  3209.                 //$controlctrlDes->getId();
  3210.                 $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  3211.                 $data_technology[] = array(
  3212.                     'id' => $technology->getId(),
  3213.                     'title' => $technology->getTitle(),
  3214.                     'modules' => $technology->getModules(),
  3215.                     'type' => $technology->getType(),
  3216.                     'currency' => $technology->getCurrency(),
  3217.                     'price' => $technology->getPrice(),
  3218.                     'commission' => $technology->getCommission(),
  3219.                     'iva' => $technology->getIva(),
  3220.                     'controlId' => $controlctrlDes->getId(),
  3221.                     'description' => $description
  3222.                 );
  3223.             }
  3224.         }
  3225.         /* Assistant  */
  3226.         $assistants $em->getRepository(SupplierServicesAssistant::class)->findBySupplierId($id);
  3227.         /* Assistant  Description*/
  3228.         $data_assistant = array();
  3229.         foreach($assistants as $assistant){
  3230.             /* Consulta en Control Description */
  3231.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  3232.                 'servicesId' => $assistant->getId(),
  3233.                 'servicesCat' => $assistant->getControlCat()
  3234.             ));
  3235.             //$controlctrlDes->getId();
  3236.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  3237.             $data_assistant[] = array(
  3238.                 'id' => $assistant->getId(),
  3239.                 'name' => $assistant->getName(),
  3240.                 'quantity' => $assistant->getQuantity(),
  3241.                 'currency' => $assistant->getCurrency(),
  3242.                 'price' => $assistant->getPrice(),
  3243.                 'commission' => $assistant->getCommission(),
  3244.                 'iva' => $assistant->getIva(),
  3245.                 'controlId' => $controlctrlDes->getId(),
  3246.                 'description' => $description
  3247.             );
  3248.         }
  3249.         /* salida de data */
  3250.         return $this->render('MDS/EventsBundle/services/services-supplier-esp-proposal.html.twig', array(
  3251.             'cdid' => $cdid,
  3252.             'id' => $proposal->getId(),
  3253.             'proname' => $proposal->getName(),
  3254.             'token' => $proposal->getAccessKey(),
  3255.             'mcp' => $proposal->getMcp(),
  3256.             'proposal' => $proposal,
  3257.             'idcontrol' => $idcontrol,
  3258.             'accommodations' => $data_accommodation,
  3259.             'menus' => $data_menu,
  3260.             'lounges' => $data_lounge,
  3261.             'transports' => $data_transport,
  3262.             'guides' => $data_guide,
  3263.             'itineraries' => $data_itineraries,
  3264.             'activities' => $data_activities,
  3265.             'cruises' => $data_cruise,
  3266.             'avs' => $data_av,
  3267.             'creatives' => $data_creative,
  3268.             'gifts' => $data_gifts,
  3269.             'entertainments' => $data_entertainment,
  3270.             'technology' => $data_technology,
  3271.             'newTechnologys' => $newTechnologys,
  3272.             'newAvs' => $newAvs,
  3273.             'assistants' => $data_assistant,
  3274.             'otherss' => $data_others
  3275.         ));
  3276.     }
  3277.     /* CREAR DESDE Discount */
  3278.     private function createDiscountCreateForm(ProposalDiscount $entity)
  3279.     {
  3280.         $form $this->createForm(ProposalDiscountType::class, $entity, array(
  3281.             'action' => $this->generateUrl('proposal_discount_create'),
  3282.             'method' => 'POST'
  3283.         ));
  3284.         return $form;
  3285.     }
  3286.     /**
  3287.      * @Route("/proposal/discount/create",  name="proposal_discount_create")
  3288.      */
  3289.     public function createDiscountAction(Request $request)
  3290.     {
  3291.         $controlid $request->request->get('control')['id'];
  3292.         $em $this->getDoctrine()->getManager();
  3293.         $discount = new ProposalDiscount();
  3294.         $form $this->createDiscountCreateForm($discount);
  3295.         $form->handleRequest($request);
  3296.         $serviceId $form->get('serviceId')->getData();
  3297.         if(!is_null($serviceId)){
  3298.             $discount->setServiceId($serviceId->getId());
  3299.         }else{
  3300.             $discount->setServiceId(null);
  3301.         }
  3302.         if($form->isValid())
  3303.         {
  3304.             /* Obtengo usuario logueado */
  3305.             $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  3306.             $user_id $user_logueado->getId();
  3307.             $discount->setCreatedId($user_id);
  3308.             $discount->setUpdatedId($user_id);
  3309.             $em->persist($discount);
  3310.             $em->flush();
  3311.         }
  3312.         return $this->redirectToRoute('proposal_destination_supplier_view',
  3313.             array(
  3314.                 'id' => $controlid,
  3315.                 '_fragment' => 'd1'
  3316.             )
  3317.         );
  3318.     }
  3319.     /**
  3320.      * @Route("/proposal/discount/delete/{controlid}/{id}",  name="proposal_discount_delete")
  3321.      */
  3322.     public function deleteDiscountAction($controlid$idRequest $request)
  3323.     {
  3324.         $em $this->getDoctrine()->getManager();
  3325.         $delete$em->getRepository(ProposalDiscount::class)->findOneById($id);
  3326.         $em->remove($delete);
  3327.         $em->flush();
  3328.         return $this->redirectToRoute('proposal_destination_supplier_view',
  3329.             array(
  3330.                 'id' => $controlid
  3331.             )
  3332.         );
  3333.     }
  3334.     /**
  3335.      * @Route("/proposal/fee/create",  name="proposal_fee_create")
  3336.      */
  3337.     public function createFeeAction(Request $request){
  3338.         $controlid $request->request->get('control')['id'];
  3339.         /* Obtengo usuario logueado */
  3340.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  3341.         $user_id $user_logueado->getId();
  3342.         $em $this->getDoctrine()->getManager();
  3343.         $proposalId $request->request->get('proposal_id');
  3344.         $proposal $em->getRepository(Proposal::class)->findOneById($proposalId);
  3345.         $oldFee $em->getRepository(ProposalFee::class)->findOneByProposalId($proposalId);
  3346.         if (!empty($oldFee)){
  3347.             if ($oldFee->getToInvoice() == 0){
  3348.                 // Habia un Fee que se cargo en los servicios
  3349.                 $this->eliminarFeeOculto($oldFee->getId());
  3350.             }
  3351.             $oldFee->setName($request->request->get('nameFee'));
  3352.             $oldFee->setType($request->request->get('typeFee'));
  3353.             $oldFee->setAmount($request->request->get('amountFee'));
  3354.             $oldFee->setToInvoice($request->request->get('toInvoiceFee'));
  3355.             $oldFee->setUpdatedId($user_id);
  3356.             $oldFee->setUpdatedAt(new \DateTime("now"));
  3357.             if ($proposal->getStatus() != 'Invoiced') {
  3358.                 $em->persist($oldFee);
  3359.                 $em->flush();
  3360.                 if(!$oldFee->getToInvoice()){
  3361.                     // Es un Fee oculto se deben modificar los servicios
  3362.                     $this->agregarFeeOculto($oldFee->getId());
  3363.                 }
  3364.             }
  3365.         } else {
  3366.             $newFee = new ProposalFee();
  3367.             $newFee->setProposalId($proposalId);
  3368.             $newFee->setName($request->request->get('nameFee'));
  3369.             $newFee->setType($request->request->get('typeFee'));
  3370.             $newFee->setAmount($request->request->get('amountFee'));
  3371.             $newFee->setToInvoice($request->request->get('toInvoiceFee'));
  3372.             $newFee->setOpIva('1');
  3373.             $newFee->setIva('21');      // Por indicaciones de Esteban siempre sera al 21% el iva del Fee, si se da una excepcion (por ejemplo SUCOE) se modificacara manualmente
  3374.             if ($request->request->get('typeFee') == 0){ $newFee->setFeeTotal(0); } else { $newFee->setFeeTotal($request->request->get('amountFee') * 1.21); }
  3375.             $newFee->setCreatedId($user_id);
  3376.             $newFee->setUpdatedId($user_id);
  3377.             $newFee->setCreatedAt(new \DateTime("now"));
  3378.             $newFee->setUpdatedAt(new \DateTime("now"));
  3379.             // Solo se creará el Fee si no se ha facturado
  3380.             if ($proposal->getStatus() != 'Invoiced') {
  3381.                 $em->persist($newFee);
  3382.                 $em->flush();
  3383.                 if(!$newFee->getToInvoice()){
  3384.                     // Es un Fee oculto se deben modificar los servicios
  3385.                     $this->agregarFeeOculto($newFee->getId());
  3386.                 }
  3387.             }
  3388.         }
  3389.         return $this->redirectToRoute('proposal_destination_supplier_view',
  3390.             array(
  3391.                 'id' => $controlid,
  3392.                 '_fragment' => 'f1'
  3393.             )
  3394.         );
  3395.     }
  3396.     /**
  3397.      * @Route("/proposal/fee/delete/{controlid}/{id}",  name="proposal_fee_delete")
  3398.      */
  3399.     public function deleteFeeAction($controlid$idRequest $request)
  3400.     {
  3401.         $em $this->getDoctrine()->getManager();
  3402.         $fee $em->getRepository(ProposalFee::class)->findOneById($id);
  3403.         if (!empty($fee)){
  3404.             $proposal $em->getRepository(Proposal::class)->findOneById($fee->getProposalId());
  3405.             if ($fee->getToInvoice() == 0){
  3406.                 // Habia un Fee que se cargo en los servicios
  3407.                 $this->eliminarFeeOculto($fee->getId());
  3408.             }
  3409.             if ($proposal->getStatus() != 'Invoiced') {
  3410.                 $em->remove($fee);
  3411.                 $em->flush();
  3412.             }
  3413.         }
  3414.         return $this->redirectToRoute('proposal_destination_supplier_view',
  3415.             array(
  3416.                 'id' => $controlid,
  3417.                 '_fragment' => 'f1'
  3418.             )
  3419.         );
  3420.     }
  3421.     private function agregarFeeOculto$idFee )
  3422.     {
  3423.         // Se agregara un fee en los servicios
  3424.         $em $this->getDoctrine()->getManager();
  3425.         $fee $em->getRepository(ProposalFee::class)->findOneById($idFee);
  3426.         $prpSupServices $em->getRepository(ProposalSupplierServices::class)->findByProposalId($fee->getProposalId());
  3427.         foreach ($prpSupServices as $service){
  3428.             if ($fee->getType() == 0){
  3429.                 // Fee de %
  3430.                 if ($service->getOpCommission() == 1){
  3431.                     // La Comision es positiva
  3432.                     $comision $fee->getAmount() + $service->getCommission();
  3433.                     $service->setCommission($comision);
  3434.                 } else {
  3435.                     // La Comision es negativa, no se puede alterar la comision por ende el porcentaje se calculará y añadirá en el over
  3436.                     $comision $service->getPrice() * ( $fee->getAmount() / 100 );
  3437.                     $comision $comision $service->getOver();
  3438.                     $service->setOver($comision);
  3439.                 }
  3440.                 $em->persist($service);
  3441.                 $em->flush();
  3442.                 // Si es un servicio ya confirmado debemos modificar tambien ProposalSupplierServicesCost y en ProposalSupplierServicesCostClient
  3443.                 $prpSupSrvCosts $em->getRepository(ProposalSupplierServicesCosts::class)->findOneByServicesId($service->getId());
  3444.                 if (!empty($prpSupSrvCosts)){
  3445.                     $prpSupSrvCosts->setCommission($service->getCommission());
  3446.                     $em->persist($prpSupSrvCosts);
  3447.                     $em->flush();
  3448.                 }
  3449.                 $prpSupSrvCostsClient $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($service->getId());
  3450.                 if (!empty($prpSupSrvCostsClient)){
  3451.                     $prpSupSrvCostsClient->setCommission($service->getCommission());
  3452.                     $prpSupSrvCostsClient->setOver($service->getOver());
  3453.                     $em->persist($prpSupSrvCostsClient);
  3454.                     $em->flush();
  3455.                 }
  3456.             } else {
  3457.                 // Fee de â‚¬
  3458.                 if ($service->getOpOver() == 1){
  3459.                     // El Over es positivo
  3460.                     $over $fee->getAmount() + $service->getOver();
  3461.                     $service->setOver($over);
  3462.                 } else {
  3463.                     // El Over es negativo,
  3464.                     if ($service->getOver() > $fee->getAmount()){
  3465.                         // Se mantendra el signo negativo del over. La cantidad de over negativo es superior al fee que agregamos
  3466.                         $service->setOver($service->getOver() - $fee->getAmount());
  3467.                     } else {
  3468.                         // Se cambiara el signo del over. La cantidad de over negativo es inferior o igual all fee que agregamos
  3469.                         $service->setOver($fee->getAmount() - $service->getOver());
  3470.                         $service->setOpOver(1);
  3471.                     }
  3472.                 }
  3473.                 $em->persist($service);
  3474.                 $em->flush();
  3475.                 // Si es un servicio ya confirmado debemos modificar tambien ProposalSupplierServicesCostClient (NO APLICA EN ProposalSupplierServicesCost)
  3476.                 $prpSupSrvCostsClient $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($service->getId());
  3477.                 if (!empty($prpSupSrvCostsClient)){
  3478.                     $prpSupSrvCostsClient->setOver($service->getOver());
  3479.                     $em->persist($prpSupSrvCostsClient);
  3480.                     $em->flush();
  3481.                 }
  3482.             }
  3483.         }
  3484.         return true;
  3485.     }
  3486.     private function eliminarFeeOculto$idFee )
  3487.     {
  3488.         // No se eliminara el Fee, solo se quitara el monto de los servicios
  3489.         $em $this->getDoctrine()->getManager();
  3490.         $fee $em->getRepository(ProposalFee::class)->findOneById($idFee);
  3491.         $prpSupServices $em->getRepository(ProposalSupplierServices::class)->findByProposalId($fee->getProposalId());
  3492.         foreach ($prpSupServices as $service){
  3493.             if ($fee->getType() == 0){
  3494.                 // Fee de %
  3495.                 if ($service->getOpCommission() == 1){
  3496.                     // La Comision es positiva
  3497.                     $comision abs($service->getCommission() - $fee->getAmount());
  3498.                     $service->setCommission($comision);
  3499.                 } else {
  3500.                     // La Comision es negativa, no se puede alterar la comision
  3501.                 }
  3502.                 $em->persist($service);
  3503.                 $em->flush();
  3504.                 // Si es un servicio ya confirmado debemos modificar tambien ProposalSupplierServicesCost y en ProposalSupplierServicesCostClient
  3505.                 $prpSupSrvCosts $em->getRepository(ProposalSupplierServicesCosts::class)->findOneByServicesId($service->getId());
  3506.                 if (!empty($prpSupSrvCosts)){
  3507.                     $prpSupSrvCosts->setCommission($service->getCommission());
  3508.                     $em->persist($prpSupSrvCosts);
  3509.                     $em->flush();
  3510.                 }
  3511.                 $prpSupSrvCostsClient $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($service->getId());
  3512.                 if (!empty($prpSupSrvCostsClient)){
  3513.                     $prpSupSrvCostsClient->setCommission($service->getCommission());
  3514.                     $prpSupSrvCostsClient->setOver($service->getOver());
  3515.                     $em->persist($prpSupSrvCostsClient);
  3516.                     $em->flush();
  3517.                 }
  3518.             } else {
  3519.                 // Fee de â‚¬
  3520.                 if ($service->getOpOver() == 1){
  3521.                     // El Over es positivo
  3522.                     $over abs($service->getOver() - $fee->getAmount());
  3523.                     $service->setOver($over);
  3524.                 } else {
  3525.                     // El Over es negativo,
  3526.                     if ($service->getOver() > $fee->getAmount()){
  3527.                     } else {
  3528.                     }
  3529.                 }
  3530.                 $em->persist($service);
  3531.                 $em->flush();
  3532.                 // Si es un servicio ya confirmado debemos modificar tambien ProposalSupplierServicesCostClient (NO APLICA EN ProposalSupplierServicesCost)
  3533.                 $prpSupSrvCostsClient $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($service->getId());
  3534.                 if (!empty($prpSupSrvCostsClient)){
  3535.                     $prpSupSrvCostsClient->setOver($service->getOver());
  3536.                     $em->persist($prpSupSrvCostsClient);
  3537.                     $em->flush();
  3538.                 }
  3539.             }
  3540.         }
  3541.         return true;
  3542.     }
  3543.     /**
  3544.      * @Route("/proposal/summary/create",  name="proposal_summary_create")
  3545.      */
  3546.     public function createSummaryAction(Request $request){
  3547.         $controlid $request->request->get('control')['id'];
  3548.         $em $this->getDoctrine()->getManager();
  3549.         $proposalId $request->request->get('proposal_id');
  3550.         $proposal $em->getRepository(Proposal::class)->findOneById($proposalId);
  3551.         $oldSummary $em->getRepository(ProposalsInvoiceSummary::class)->findOneByProposalId($proposalId);
  3552.         $newSummary $request->request->get('descriptionSummary');
  3553.         if (!empty($oldSummary)){
  3554.             if (!empty($newSummary) and ($proposal->getStatus() != 'Invoiced')){
  3555.                 $oldSummary->setDescription($newSummary);
  3556.                 $em->persist($oldSummary);
  3557.                 $em->flush();
  3558.             } else {
  3559.                 if (empty($newSummary) and ($proposal->getStatus() != 'Invoiced')){
  3560.                     // Si viene vacío se elimina el resumen para obetener una factura completa
  3561.                     $em->remove($oldSummary);
  3562.                     $em->flush();
  3563.                 }
  3564.             }
  3565.         } else {
  3566.             $newSumm = new ProposalsInvoiceSummary();
  3567.             $newSumm->setDescription($newSummary);
  3568.             $newSumm->setProposalId($proposalId);
  3569.             $newSumm->setNet(null);
  3570.             $newSumm->setCurrency(null);
  3571.             $newSumm->setVatTen(null);
  3572.             $newSumm->setVatTwentyOne(null);
  3573.             $newSumm->setPayments(null);
  3574.             // Solo se creará el Summary si no se ha facturado
  3575.             if (($proposal->getStatus() != 'Invoiced') and !empty($newSummary)) {
  3576.                 $em->persist($newSumm);
  3577.                 $em->flush();
  3578.             }
  3579.         }
  3580.         return $this->redirectToRoute('proposal_destination_supplier_view',
  3581.             array(
  3582.                 'id' => $controlid,
  3583.                 '_fragment' => 'summary1'
  3584.             )
  3585.         );
  3586.     }
  3587.     /**
  3588.      * @Route("proposal/destination/services/block/{id}", name="proposal_destination_supplier_services_block")
  3589.      */
  3590.     public function udatedBlockAction($idRequest $request)
  3591.     {
  3592.         $block $request->request->get('block');
  3593.         $em $this->getDoctrine()->getManager();
  3594.         $services_control $em->getRepository(ProposalSupplierControl::class)->findOneById($id);
  3595.         if (!empty($block['dateBlockLimit']) and !empty($block['timeBlockLimit'])){
  3596.             $services_control->setDateBlockLimit(new \DateTime($block['dateBlockLimit'].' '.$block['timeBlockLimit'] ));
  3597.             $services_supplier_proposal $em->getRepository(ProposalSupplierServices::class)->findByControlId($services_control->getId());
  3598.             foreach($services_supplier_proposal as $servicessupplierproposal) {
  3599.                 $servicessupplierproposal->setDateBlockLimit(new \DateTime($block['dateBlockLimit'] . ' ' $block['timeBlockLimit']));
  3600.                 $servicessupplierproposal->setStatus('Block');
  3601.                 $em->persist($servicessupplierproposal);
  3602.                 $em->flush();
  3603.             }
  3604.             $em->persist($services_control);
  3605.             $em->flush();
  3606.             $event 'The Block supplier updated in Destination Proposal.';
  3607.             $successMessage $this->translator->trans($event);
  3608.             $this->addFlash('mensajeproposaldestinationservices'$successMessage);
  3609.         }else{
  3610.             $errorMessage $this->translator->trans('Error');
  3611.             $this->addFlash('mensajeproposaldestinationservicesrror'$errorMessage);
  3612.         }
  3613.         return $this->redirectToRoute('proposal_destination_supplier_view',
  3614.             array(
  3615.                 'id' => $services_control->getControlDestinationId(),
  3616.                 '_fragment' => 's'.$id
  3617.             )
  3618.         );
  3619.     }
  3620.     /**
  3621.      * @Route("/multichckservices", name="multichckservices")
  3622.      */
  3623.     public function multiChckServicesAction(Request $request) {
  3624.         $idSupplier $_POST['idSupplier'];
  3625.         $idService $_POST['idService'];
  3626.         /* Obtengo usuario logueado */
  3627.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  3628.         $user_id $user_logueado->getId();
  3629.         $user_role $user_logueado->getRole();
  3630.         $em $this->getDoctrine()->getManager();
  3631.         $services $em->getRepository(ProposalSupplierServices::class)->findOneById($idService);
  3632.         // INICIO: Buscamos el proposal para verificar que no este bloqueado o facturado
  3633.         $propId $services->getProposalId();
  3634.         $proposal $em->getRepository(Proposal::class)->findOneById($propId);
  3635.         // FIN :Buscamos el proposal para verificar que no este bloqueado o facturado
  3636.         if (!empty($services)){
  3637.             if ($services->getStatus()== 'Pending') {
  3638.                 $services->setStatus('Confirmed');
  3639.                 $services->setUpdatedId($user_id);
  3640.             } else {
  3641.                 $services->setStatus('Pending');
  3642.                 $services->setUpdatedId($user_id);
  3643.             }
  3644.             try{
  3645.                 if (!empty($proposal)){
  3646.                     if (($proposal->getStatus() == 'Invoiced') or ($proposal->getStatus() == 'Blocked')) {
  3647.                         // De ser un expediente Facturado o bloqueado no se hace modificacion
  3648.                     } else {
  3649.                         if (empty($services->getSupplierId())){
  3650.                             $services->setSupplierId(4);
  3651.                         }
  3652.                         $em->persist($services);
  3653.                         $em->flush();
  3654.                         /* Para dentro de ProposalSupplierControl */
  3655.                         if (!empty($services->getSupplierId())){
  3656.                             $controlctrlDes $em->getRepository(ProposalSupplierControl::class)->findOneBy( array(
  3657.                                 'supplierId' => $services->getSupplierId(),
  3658.                                 'proposalId' => $services->getProposalId()
  3659.                             ));
  3660.                         } else {
  3661.                             $controlctrlDes $em->getRepository(ProposalSupplierControl::class)->findOneBy( array(
  3662.                                 'supplierId' => 4,
  3663.                                 'proposalId' => $services->getProposalId()
  3664.                             ));
  3665.                         }
  3666. //                         Si el control se encuentra vacio, se debe crear uno nuevo
  3667.                         if (empty($controlctrlDes)){
  3668.                             $controlctrlDes = new ProposalSupplierControl();
  3669.                             $controlctrlDes->setControlDestinationId($services->getDestinationId());  // Falta corregir el ControlDestinationId ahora tiene el Id del destino
  3670.                             $controlctrlDes->setProposalId($services->getProposalId());
  3671.                             $controlctrlDes->setDestinoId($services->getDestinationId());
  3672.                             $controlctrlDes->setSupplierId(4);
  3673.                             $controlctrlDes->setStatus('Pending');
  3674.                             $em->persist($controlctrlDes);
  3675.                             $em->flush();
  3676.                         }
  3677.                         //COLOR POR SERVICIO
  3678.                         $contcolor ="";
  3679.                         switch ($services->getServiceCatName()) {
  3680.                             case "Accommodation":
  3681.                                 $contcolor 'teal';
  3682.                                 break;
  3683.                             case "Menu" :
  3684.                                 $contcolor 'purple';
  3685.                                 break;
  3686.                             case "Lounge":
  3687.                                 $contcolor 'warning';
  3688.                                 break;
  3689.                             case "Activities":
  3690.                                 $contcolor 'blue';
  3691.                                 break;
  3692.                             case "Itineraries":
  3693.                                 $contcolor 'indigo';
  3694.                                 break;
  3695.                             case "Cruise":
  3696.                                 $contcolor 'brown';
  3697.                                 break;
  3698.                             case "Transport":
  3699.                                 $contcolor 'grey';
  3700.                                 break;
  3701.                             case "Av":
  3702.                                 $contcolor 'slate';
  3703.                                 break;
  3704.                             case "Creative":
  3705.                                 $contcolor 'orange';
  3706.                                 break;
  3707.                             case "Gifts":
  3708.                                 $contcolor 'pink';
  3709.                                 break;
  3710.                             case "Entertainment":
  3711.                                 $contcolor 'green';
  3712.                                 break;
  3713.                             case "Guide":
  3714.                                 $contcolor 'orange';
  3715.                                 break;
  3716.                             case "Others":
  3717.                                 $contcolor 'danger';
  3718.                                 break;
  3719.                             case "Technology":
  3720.                                 $contcolor 'slate-800';
  3721.                                 break;
  3722.                             case "Assistant":
  3723.                                 $contcolor 'indigo-800';
  3724.                                 break;
  3725.                             case "DDR":
  3726.                                 $contcolor 'green-300';
  3727.                                 break;
  3728.                         }
  3729.                         /* Para dentro de ProposalSupplierServicesCostsClient */
  3730.                         $costsClient = new ProposalSupplierServicesCostsClient();
  3731.                         $costsClient->setServiceIdProposal($services->getId());
  3732.                         $costsClient->setServiceIdFather($services->getServiceIdFather());
  3733.                         $costsClient->setControlId($controlctrlDes->getId());
  3734. //                        if (empty($services->getSupplierId())){$costsClient->setControlId(14244);} else {$costsClient->setControlId($services->getControlId());}
  3735.                         $costsClient->setProposalId($services->getProposalId());
  3736.                         $costsClient->setDestinationId($services->getDestinationId());
  3737.                         if (empty($services->getSupplierId())){$costsClient->setSupplierId('4');} else {$costsClient->setSupplierId($services->getSupplierId());}
  3738.                         $costsClient->setAssistantId($services->getAssistantId());
  3739.                         $costsClient->setIdeaId($services->getIdeaId());
  3740.                         $costsClient->setActivityId($services->getActivityId());
  3741.                         $costsClient->setServiceId($services->getServiceId());
  3742.                         $costsClient->setServiceCatId($services->getServiceCatId());
  3743.                         $costsClient->setServiceCatName($services->getServiceCatName());
  3744.                         $costsClient->setName($services->getName());
  3745.                         $costsClient->setPrice($services->getPrice());
  3746.                         $costsClient->setCurrency($services->getCurrency());
  3747.                         $costsClient->setUnits($services->getUnits());
  3748.                         $costsClient->setOpCommission($services->getOpCommission());
  3749.                         $costsClient->setCommission($services->getCommission());
  3750.                         $costsClient->setOpOver($services->getOpOver());
  3751.                         $costsClient->setOver($services->getOver());
  3752.                         $costsClient->setOpIva($services->getOpIva());
  3753.                         $costsClient->setIva($services->getIva());
  3754.                         $costsClient->setPax($services->getPax());
  3755.                         $costsClient->setHour($services->getHour());
  3756.                         $costsClient->setDateInAt($services->getDateInAt());
  3757.                         $costsClient->setDateOutAt($services->getDateOutAt());
  3758.                         $costsClient->setRank($services->getRank());
  3759.                         $costsClient->setCreatedId($user_id);
  3760.                         $costsClient->setUpdatedId($user_id);
  3761.                         $costsClient->setContcolor($contcolor);
  3762.                         $costsClient->setRenovate('0');
  3763.                         $em->persist($costsClient);
  3764.                         $em->flush();
  3765.                     }
  3766.                 }
  3767.             } catch (\Exception $e){
  3768.             }
  3769.         }
  3770.         $return = array(
  3771.             'services' => $services,
  3772.         );
  3773.         $response = new JsonResponse($return);
  3774.         return $response;
  3775.     }
  3776.     /**
  3777.      * @Route("proposal/destination/services/listmultiple/{idcontrol}", name="proposal_destination_supplier_list_multiple")
  3778.      */
  3779.     public function listMultipleAction($idcontrolRequest $request) {
  3780.         $em $this->getDoctrine()->getManager();
  3781.         $control $em->getRepository(ProposalSupplierControl::class)->findOneById($idcontrol);
  3782.         $idsupplier $control->getSupplierId();
  3783.         $idMemorySupplier $idsupplier;
  3784.         $ididea $control->getIdeaId();
  3785.         $idactivity $control->getActivityId();
  3786.         if($idsupplier == '0'){
  3787.             $id '0';
  3788.         }else{
  3789.             if(!empty($idsupplier)){
  3790.                 /*CONTROL GENERAL*/
  3791.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneBySupplierId($idsupplier);
  3792.                 $id $controlgeneral->getId();
  3793.             }
  3794.             if(!empty($idactivity)){
  3795.                 /*CONTROL GENERAL*/
  3796.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByActivityId($idactivity);
  3797.                 $id $controlgeneral->getId();
  3798.             }
  3799.             if(!empty($ididea)){
  3800.                 /*CONTROL GENERAL*/
  3801.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByIdeaId($ididea);
  3802.                 $id $controlgeneral->getId();
  3803.             }
  3804.         }
  3805.         if (!empty($control)){
  3806.             $idProposal $control->getProposalId();
  3807.             $proposal $em->getRepository(Proposal::class)->findOneById($idProposal);
  3808.             // Buscamos a partir del IDCONTROL los elementos principales (Proveedores, Actividades, Ideas) agregados al destino para la carga multiple
  3809.             $destinoId $control->getDestinoId();
  3810.             $servicesControllers $em->getRepository(ProposalSupplierControl::class)->findBy(
  3811.                 array(
  3812.                     'proposalId' => $proposal,
  3813.                     'destinoId' => $destinoId
  3814.                 )
  3815.             );
  3816.             //INICIO: Asignamos al campo Status (ya que no se usa) el Nombre del proveedor, tambien buscamos el control que apunta a los white services para ponerlo de ultimo
  3817.             $tempKey null;
  3818.             $logicKey false;
  3819.             foreach ($servicesControllers as $key => $item) {
  3820.                 if(($item->getSupplierId() == 0) and (empty($item->getActivityId())) and (empty($item->getIdeaId()))){
  3821.                     // Es un white service, se guarda el indice para luego procesar
  3822.                     $tempKey $key;
  3823.                     $logicKey true;
  3824.                 }
  3825.                 if(!empty($item->getSupplierId()) and ($item->getSupplierId() != 0)){
  3826.                     // Es un proveedor ordinario
  3827.                     $tempSup $em->getRepository(Supplier::class)->findOneById($item->getSupplierId());
  3828.                     $servicesControllers[$key]->setStatus($tempSup->getName());
  3829.                 }
  3830.                 if (!empty($item->getActivityId())){
  3831.                     // Es Actividad
  3832.                     $tempAct $em->getRepository(Activities::class)->findOneById($item->getActivityId());
  3833.                     $servicesControllers[$key]->setStatus($tempAct->getName());
  3834.                 }
  3835.                 if (!empty($item->getIdeaId())) {
  3836.                     // Es Idea
  3837.                     $tempIdea $em->getRepository(Ideas::class)->findOneById($item->getIdeaId());
  3838.                     $servicesControllers[$key]->setStatus($tempIdea->getName());
  3839.                 }
  3840.             }
  3841.             if($logicKey){
  3842.                 $servicesControllers[$tempKey]->setStatus('SERVICIO SIN PROVEEDOR');
  3843.                 array_push($servicesControllers,$servicesControllers[$tempKey]);
  3844.                 unset($servicesControllers[$tempKey]);
  3845.             }
  3846.             //FIN: Asignamos al campo Status (ya que no se usa) el Nombre dle proveedor, tambien buscamos el control que apunta a los white services para ponerlo de ultimo
  3847.         }
  3848. //        LIMPIEZA DE DATOS PARA LA VISTA
  3849.         if (!($idMemorySupplier === 0)){// el === evalua correctamente el caso de nulo
  3850.             $newServicesControllers = array();
  3851.             foreach ($servicesControllers as $item){
  3852.                 if (intval($idcontrol) === $item->getId()){
  3853.                     $newServicesControllers[] = $item;
  3854.                 }
  3855.             }
  3856.             $servicesControllers $newServicesControllers;
  3857.         }
  3858.         if (sizeof($servicesControllers) == 1){
  3859.             $numElementos 10;
  3860.         } else {
  3861.             $numElementos 5;
  3862.         }
  3863.         /* salida de data */
  3864.         return $this->render('MDS/EventsBundle/services/services-multiple-modal-proposal.html.twig', array(
  3865. //        return $this->render('MDS/EventsBundle/services/services-multiple-add-destination-proposal.html.twig', array(
  3866.             'idcontrol' => $idcontrol,
  3867.             'servicesControllers' => $servicesControllers,
  3868.             'id' => $idProposal,
  3869.             'proposal' => $proposal,
  3870.             'numElementos' => $numElementos,
  3871.             'token' => $proposal->getAccessKey(),
  3872.             'mcp' => null,
  3873.             'datasupplier' => null,
  3874.             'discounts' => null,
  3875.             'status' => null,
  3876.             'global_calculos' => null,
  3877.             'accommodations' => '',
  3878.             'menus' => '',
  3879.             'lounges' => '',
  3880.             'transports' => '',
  3881.             'guides' => '',
  3882.             'itineraries' => '',
  3883.             'activities' => '',
  3884.             'cruises' => '',
  3885.             'avs' => '',
  3886.             'creatives' => '',
  3887.             'gifts' => '',
  3888.             'entertainments' => '',
  3889.             'technology' => '',
  3890.             'assistants' => '',
  3891.             'otherss' => ''
  3892.         ));
  3893.     }
  3894.     /**
  3895.      * @Route("proposal/destination/services/createmultiple", name="proposal_destination_supplier_create_multiple")
  3896.      */
  3897.     public function createMultipleAction(Request $request) {
  3898.         $add_services_multiple_type $request->request->get('add_services_multiple_type');
  3899.         $add_services_multiple_name $request->request->get('add_services_multiple_name');
  3900.         $add_services_multiple_price $request->request->get('add_services_multiple_price');
  3901.         $add_services_multiple_commission $request->request->get('add_services_multiple_commission');
  3902.         $add_services_multiple_over $request->request->get('add_services_multiple_over');
  3903.         $add_services_multiple_iva $request->request->get('add_services_multiple_iva');
  3904.         $em $this->getDoctrine()->getManager();
  3905.         /* Obtengo usuario logueado */
  3906.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  3907.         $user_id $user_logueado->getId();
  3908.         // INICIO: Generamos un arreglo con todos los servicios a agregar
  3909.         $newServices = array();
  3910.         foreach ($add_services_multiple_type as $key1 => $item) {
  3911.             foreach ($item as $key2 => $elem){
  3912.                 $newServ = new ProposalSupplierServices();
  3913.                 $newServ->setControlId($key1);
  3914.                 $controlTemp $em->getRepository(ProposalSupplierControl::class)->findOneById($key1);
  3915.                 $proposal_data $em->getRepository(Proposal::class)->findOneById($controlTemp->getProposalId());
  3916.                 switch ($elem['type']) {
  3917.                     case 1:
  3918.                         $newServ->setServiceCatId('1');
  3919.                         $newServ->setServiceCatName('Accommodation');
  3920.                         break;
  3921.                     case 2:
  3922.                         $newServ->setServiceCatId('2');
  3923.                         $newServ->setServiceCatName('Activities');
  3924.                         break;
  3925.                     case 3:
  3926.                         $newServ->setServiceCatId('3');
  3927.                         $newServ->setServiceCatName('Av');
  3928.                         break;
  3929.                     case 4:
  3930.                         $newServ->setServiceCatId('4');
  3931.                         $newServ->setServiceCatName('Creative');
  3932.                         break;
  3933.                     case 5:
  3934.                         $newServ->setServiceCatId('5');
  3935.                         $newServ->setServiceCatName('Cruise');
  3936.                         break;
  3937.                     case 6:
  3938.                         $newServ->setServiceCatId('6');
  3939.                         $newServ->setServiceCatName('Entertainment');
  3940.                         break;
  3941.                     case 7:
  3942.                         $newServ->setServiceCatId('7');
  3943.                         $newServ->setServiceCatName('Gifts');
  3944.                         break;
  3945.                     case 8:
  3946.                         $newServ->setServiceCatId('8');
  3947.                         $newServ->setServiceCatName('Guide');
  3948.                         break;
  3949.                     case 9:
  3950.                         $newServ->setServiceCatId('9');
  3951.                         $newServ->setServiceCatName('Itineraries');
  3952.                         break;
  3953.                     case 10:
  3954.                         $newServ->setServiceCatId('10');
  3955.                         $newServ->setServiceCatName('Lounge');
  3956.                         break;
  3957.                     case 11:
  3958.                         $newServ->setServiceCatId('11');
  3959.                         $newServ->setServiceCatName('Menu');
  3960.                         break;
  3961.                     case 12:
  3962.                         $newServ->setServiceCatId('12');
  3963.                         $newServ->setServiceCatName('Others');
  3964.                         break;
  3965.                     case 13:
  3966.                         $newServ->setServiceCatId('13');
  3967.                         $newServ->setServiceCatName('Transport');
  3968.                         break;
  3969.                     case 14:
  3970.                         $newServ->setServiceCatId('14');
  3971.                         $newServ->setServiceCatName('Technology');
  3972.                         break;
  3973.                     case 15:
  3974.                         $newServ->setServiceCatId('15');
  3975.                         $newServ->setServiceCatName('Assistant');
  3976.                         break;
  3977.                     case 16:
  3978.                         $newServ->setServiceCatId('16');
  3979.                         $newServ->setServiceCatName('DDR');
  3980.                         break;
  3981.                     case 17:
  3982. //                        $newServ->setServiceCatId('17');
  3983. //                        $newServ->setServiceCatName('AV - EXPRESS');
  3984. //                        $newServ->setSupplierId('80');
  3985. //
  3986. //                        $control = new ProposalSupplierControl();
  3987. //                        $control->setSupplierId('80');
  3988. //                        $control->setStatus('Pending');
  3989. //                        $control->setControlDestinationId($cid);
  3990. //                        $control->setProposalId($pid);
  3991. //                        $control->setDestinoId($did);
  3992. //                        $em->persist($control);
  3993. //                        $em->flush();
  3994. //                        $event = 'The Supplier Destination Proposal has been created.';
  3995. //                        $successMessage = $this->translator->trans($event);
  3996. //                        $this->addFlash('mensajeproposaldestinationservices', $successMessage);
  3997. //
  3998. //                        return $this->redirectToRoute('proposal_destination_supplier_list', array(
  3999. //                            'idcontrol' => $cid
  4000. //                        ));
  4001.                         $newServ->setServiceCatId('');
  4002.                         $newServ->setServiceCatName('');
  4003.                         break;
  4004.                     default:
  4005.                         $newServ->setServiceCatId('');
  4006.                         $newServ->setServiceCatName('');
  4007.                         break;
  4008.                 }
  4009.                 $newServ->setName($add_services_multiple_name[$key1][$key2]['name']);
  4010. //                $newServ->setPrice($add_services_multiple_price[$key1][$key2]['price']);
  4011.                 if (empty($add_services_multiple_price[$key1][$key2]['price'])){
  4012.                     // Se pone el precio a 0 si viene vacio
  4013.                     $newServ->setPrice('0');
  4014.                 } else {
  4015.                     $newServ->setPrice($add_services_multiple_price[$key1][$key2]['price']);
  4016.                 }
  4017.                 if (empty($add_services_multiple_commission[$key1][$key2]['commission'])){
  4018.                     // Se pone la commission en 0 si viene vacio
  4019.                     $newServ->setCommission('0');
  4020.                 } else {
  4021.                     $newServ->setCommission($add_services_multiple_commission[$key1][$key2]['commission']);
  4022.                 }
  4023.                 if (empty($add_services_multiple_over[$key1][$key2]['over'])){
  4024.                     // Se pone el over en 0 si viene vacio
  4025.                     $newServ->setOver('0');
  4026.                 } else {
  4027.                     $newServ->setOver($add_services_multiple_over[$key1][$key2]['over']);
  4028.                 }
  4029.                 if (empty($add_services_multiple_iva[$key1][$key2]['iva'])){
  4030.                     // Se pone el iva a 21% si viene vacio
  4031.                     $newServ->setIva('21');
  4032.                 } else {
  4033.                     $newServ->setIva($add_services_multiple_iva[$key1][$key2]['iva']);
  4034.                 }
  4035.                 $newServ->setProposalId($controlTemp->getProposalId());
  4036.                 $newServ->setDestinationId($controlTemp->getDestinoId());
  4037.                 $newServ->setSupplierId($controlTemp->getSupplierId());
  4038.                 $newServ->setIdeaId($controlTemp->getIdeaId());
  4039.                 $newServ->setActivityId($controlTemp->getActivityId());
  4040.                 /* NAMEJO DE ADICIONALES EN EL DIA DEL EVENTO O DESPUES EL DIA DEL EVENTO */
  4041.                 $dayEvent $proposal_data->getDateEventStarAt()->format('Y-m-d');
  4042.                 $today date('Y-m-d');
  4043.                 if( $today >= $dayEvent){
  4044.                     $additional "Additional";
  4045.                 }else{
  4046.                     $additional "Normal";
  4047.                 }
  4048.                 $newServ->setCurrency('Euro');
  4049.                 $newServ->setUnits('1');
  4050.                 $newServ->setPax('0');
  4051.                 $newServ->setServiceId(0);
  4052.                 //$newServ->setHour('');//null
  4053.                 //$newServ->setDateInAt('');
  4054.                 //$newServ->setDateOutAt('');
  4055.                 $newServ->setDirectPayment('0');
  4056.                 $newServ->setStatus('Pending');
  4057.                 $newServ->setStatusinternal($additional);
  4058.                 $newServ->setDateInAt($proposal_data->getDateEventStarAt());
  4059.                 $newServ->setDateOutAt($proposal_data->getDateEventEndAt());
  4060.                 $newServ->setCreatedId($user_id);
  4061.                 $newServ->setUpdatedId($user_id);
  4062.                 $newServices[] = $newServ;
  4063.             }
  4064.         }
  4065.         // Eliminamos servicios sin tipo
  4066.         $arrayNewServ = array();
  4067.         foreach ($newServices as $item) {
  4068.             if (!empty($item->getServiceCatName())){   //setServiceCatName
  4069.                 $arrayNewServ[] = $item;
  4070.             }
  4071.         }
  4072.         // FIN: Generamos un arreglo con todos los servicios a agregar
  4073.         foreach ($arrayNewServ as $item){
  4074.             $em->persist($item);
  4075.             $em->flush();
  4076.             //INICIO: Replicacion en Develup
  4077.             if ($item->getSupplierId()==2){
  4078.                 // Nombre del agente
  4079.                 $agenteFullName $em->getRepository(User::class)->findOneById($user_id);
  4080.                 $agenteFullName $agenteFullName->getName() . ' ' $agenteFullName->getLastName();
  4081.                 $proposalTitle $em->getRepository(Proposal::class)->findOneById($item->getProposalId());
  4082.                 if ($item->getSupplierId()==2){
  4083.                     $originalServiceName $em->getRepository(MdvProduct::class)->findOneById(1); // Id de "Otro Servicio"
  4084.                     $budget = new MdvBudgetPending();
  4085.                     $budget->setActivityId($item->getActivityId());
  4086.                     $budget->setAssistantId($item->getAssistantId());
  4087.                     $budget->setBreakdown($item->getBreakdown());
  4088.                     $budget->setCommission($item->getCommission());
  4089.                     $budget->setControlId($item->getControlId());
  4090.                     $budget->setOriginId($item->getId());
  4091.                     $budget->setCurrency($item->getCurrency());
  4092.                     $budget->setDateBlockLimit($item->getDateBlockLimit());
  4093.                     $budget->setDateInAt($item->getDateInAt());
  4094.                     $budget->setDateOutAt($item->getDateOutAt());
  4095.                     $budget->setDestinationId($item->getDestinationId());
  4096.                     $budget->setDirectPayment($item->getDirectPayment());
  4097.                     $budget->setHour($item->getHour());
  4098.                     $budget->setIdeaId($item->getIdeaId());
  4099.                     $budget->setIsFather($item->getIsFather());
  4100.                     $budget->setIva($item->getIva());
  4101.                     if(!($originalServiceName->getName() == $item->getName())){
  4102.                         $budget->setName($originalServiceName->getName().' (:'$item->getName().':)');
  4103.                     } else {
  4104.                         $budget->setName($originalServiceName->getName());
  4105.                     }
  4106.                     $budget->setOpCommission($item->getOpCommission());
  4107.                     $budget->setOpIva($item->getOpIva());
  4108.                     $budget->setOpOver($item->getOpOver());
  4109.                     $budget->setOriginalIva($item->getOriginalIva());
  4110.                     $budget->setOriginalopIva($item->getOriginalopIva());
  4111.                     $budget->setOriginalPrice($item->getOriginalPrice());
  4112.                     $budget->setOver($item->getOver());
  4113.                     $budget->setPax($item->getPax());
  4114.                     $budget->setPreCommission($item->getPreCommission());
  4115.                     $budget->setPreIva($item->getPreIva());
  4116.                     $budget->setPrice($item->getPrice());
  4117.                     $budget->setProposalId($item->getProposalId());
  4118.                     $budget->setRank($item->getRank());
  4119.                     $budget->setServiceCatId($item->getServiceCatId());
  4120.                     $budget->setServiceCatName($item->getServiceCatName());
  4121. //                    $budget->setServiceId($item->getServiceId());
  4122.                     $budget->setServiceId(1);       // ID de "Otro Servicio"
  4123.                     $budget->setServiceIdFather($item->getServiceIdFather());
  4124.                     $budget->setStatus($item->getStatus());
  4125.                     $budget->setStatusinternal($item->getStatusinternal());
  4126.                     $budget->setStatusRec($item->getStatusRec());
  4127.                     $budget->setSupplierId($item->getSupplierId());
  4128.                     $budget->setUnits($item->getUnits());
  4129.                     $budget->setUserConfirmedFullName($agenteFullName);
  4130.                     $budget->setUserConfirmedId($user_id);
  4131.                     $budget->setProposalTitle($proposalTitle->getTitle());
  4132.                     $budget->setCreatedAt(new \DateTime("now"));
  4133.                     $budget->setCreatedId($user_id);
  4134.                     $budget->setUpdatedId($user_id);
  4135.                     $budget->setUpdatedAt(new \DateTime("now"));
  4136.                     // INIICO: Llenamos el tooltip con la info del proposal
  4137.                     $texto null;
  4138.                     if (!empty($budget->getProposalId())){
  4139.                         $prop $em->getRepository(Proposal::class)->findOneById($budget->getProposalId());
  4140.                         if (!empty($prop)){
  4141.                             $client $em->getRepository(Client::class)->findOneById($prop->getClientId());
  4142.                             $clientContact $em->getRepository(ClientContact::class)->findOneById($prop->getContactId());
  4143.                             $contacto null;
  4144.                             if (!empty($clientContact->getName())){$contacto $contacto$clientContact->getName(). ' ';}
  4145.                             if (!empty($clientContact->getLastName())){$contacto $contacto$clientContact->getLastName(). ' ';}
  4146.                             if (!empty($clientContact->getEmail())){$contacto $contacto'('.$clientContact->getEmail().')'' ';}
  4147.                             if (!empty($clientContact->getPhone())){$contacto $contacto' - '.$clientContact->getPhone(). ' ';}
  4148.                             if (!empty($clientContact->getMobile())){$contacto $contacto' - '.$clientContact->getMobile();}
  4149.                             $city $em->getRepository(Destination::class)->findOneById($budget->getDestinationId());
  4150.                             $texto $texto .'Petición: '.$budget->getCreatedAt()->format('d/m/Y'). ' -- ';
  4151.                             if (!empty($client)){$texto $texto .'Cliente: '.$client->getName(). ' -- ';}
  4152.                             if (!empty($prop->getPax())){$texto $texto .'Personas: '.$prop->getPax(). ' -- ';}
  4153.                             $texto $texto .'Desde: '.$prop->getDateEventStarAt()->format('d/m/Y').' Hasta: '.$prop->getDateEventEndAt()->format('d/m/Y'). ' -- ';
  4154.                             $texto $texto .'Horario: '.$item->getDateInAt()->format('H:i'). ' a '.$item->getDateOutAt()->format('H:i'). ' -- ';
  4155.                             $texto $texto .'Ciudad: '.$city->getTitle(). ' -- ';
  4156.                             $texto $texto .'Contacto: '$contacto;
  4157.                             $budget->setTextTooltip($texto);
  4158.                         }
  4159.                     }
  4160.                     // FIN: Llenamos el tooltip con la info del proposal
  4161.                     $em->persist($budget);
  4162.                     $em->flush();
  4163.                     //INICIO: Enviamos Telegram
  4164.                     //INICIO: Buscamos el creador del expediente asociado al proposal, si no hay se le envia al jefe de grupo (Jorge)
  4165.                     $file $em->getRepository(MdvFiles::class)->findOneByIdProposal($prop->getId());
  4166.                     if(!empty($file)){
  4167.                         //Se envia el mensaje al creador del expediente
  4168.                         $userTelegramId $file->getCreatedId();
  4169.                     } else {
  4170.                         // Solicitud sin expediente, se le notificara la jefe de departamento
  4171.                         $userTelegramId 5// Id de Jorge
  4172.                     }
  4173.                     //FIN: Buscamos el creador del expediente asociado al proposal, si no hay se le envia al jefe de grupo (Jorge)
  4174.                     //Buscamos el nombre del destino
  4175.                     $nombreDestino $em->getRepository(Destination::class)->findOneById($budget->getDestinationId());
  4176.                     $nombreDestino $nombreDestino->getTitle();
  4177.                     //Mensaje:
  4178.                     //SOLICITUD DE PRESUPUESTO __ ID: '.$budget->getProposalId().' __ DESTINO: '.$nombreDestino.' __ PROVEEDOR: In Out Travel __ CONTACTO: '.$budget->getUserConfirmedFullName()
  4179.                     $this->sendTelegram($userTelegramId,'SOLICITUD DE PRESUPUESTO (MultiService) __ ID: '.$budget->getProposalId().' __ DESTINO: '.$nombreDestino.' __ PROVEEDOR: In Out Travel __ CONTACTO: '.$budget->getUserConfirmedFullName());
  4180. //                            d($userTelegramId,'SOLICITUD DE PRESUPUESTO __ ID: '.$budget->getProposalId().' __ DESTINO: '.$nombreDestino.' __ PROVEEDOR: In Out Travel __ CONTACTO: '.$budget->getUserConfirmedFullName());exit();
  4181.                     //FIN: Enviamos Telegram
  4182.                 }
  4183.             }
  4184.             //FIN: Replicacion en Develup
  4185.         }
  4186.         return $this->redirectToRoute('proposal_destination_supplier_view', array(
  4187.             'id' => $controlTemp->getControlDestinationId(),
  4188.         ));
  4189.     }
  4190.     /**
  4191.      * @Route("proposal/destination/services/saveallservices/{id}", name="proposal_destination_supplier_saveallservices")
  4192.      */
  4193.     public function saveAllServicesAction($idRequest $request) {
  4194.         $save_services_multiple_name $request->request->get('services_hidden_name');
  4195.         $save_services_multiple_rank $request->request->get('services_hidden_rank');
  4196.         $save_services_multiple_price $request->request->get('services_hidden_price');
  4197.         $save_services_multiple_units $request->request->get('services_hidden_units');
  4198.         $save_services_multiple_pax $request->request->get('services_hidden_pax');
  4199.         $save_services_multiple_commission $request->request->get('services_hidden_commission');
  4200.         $save_services_multiple_over $request->request->get('services_hidden_over');
  4201.         $save_services_multiple_iva $request->request->get('services_hidden_iva');
  4202.         $save_services_multiple_originalPrice $request->request->get('services_hidden_originalPrice');
  4203.         $save_services_multiple_originalIva $request->request->get('services_hidden_originalIva');
  4204.         $save_services_multiple_supplier $request->request->get('services_hidden_supplier');
  4205.         $save_services_multiple_opcommission $request->request->get('services_hidden_opcommission');
  4206.         $save_services_multiple_opover $request->request->get('services_hidden_opover');
  4207.         $save_services_multiple_opiva $request->request->get('services_hidden_opiva');
  4208.         $save_services_multiple_dateBlockLimit $request->request->get('services_hidden_dateBlockLimit');
  4209.         $save_services_multiple_timeBlockLimit $request->request->get('services_hidden_timeBlockLimit');
  4210.         $save_services_multiple_dateInAt $request->request->get('services_hidden_dateInAt');
  4211.         $save_services_multiple_dateOutAt $request->request->get('services_hidden_dateOutAt');
  4212.         $save_services_multiple_hour_start $request->request->get('services_hidden_hour_start_');
  4213.         $save_services_multiple_hour_end $request->request->get('services_hidden_hour_end_');
  4214.         $save_services_multiple_currency $request->request->get('services_hidden_currency_');
  4215.         $save_services_multiple_originalopIva $request->request->get('services_hidden_originalopIva_');
  4216.         $save_multiple_supplier_activity_idea_rank $request->request->get('supplier_activity_idea_hidden_rank');
  4217.         $arrayServices = array();
  4218.         foreach ($save_services_multiple_name as $key => $name){
  4219.             $service = new ProposalSupplierServices();
  4220.             $service->setName($name);
  4221.             $service->setRank($save_services_multiple_rank[$key]);
  4222.             $service->setPrice($save_services_multiple_price[$key]);
  4223.             $service->setUnits($save_services_multiple_units[$key]);
  4224.             $service->setPax($save_services_multiple_pax[$key]);
  4225.             $service->setCommission($save_services_multiple_commission[$key]);
  4226.             $service->setOver($save_services_multiple_over[$key]);
  4227.             $service->setIva($save_services_multiple_iva[$key]);
  4228.             $service->setOriginalPrice($save_services_multiple_originalPrice[$key]);
  4229.             $service->setOriginalIva($save_services_multiple_originalIva[$key]);
  4230.             $service->setSupplierId($save_services_multiple_supplier[$key]);
  4231.             $service->setOpCommission($save_services_multiple_opcommission[$key]);
  4232.             $service->setOpOver($save_services_multiple_opover[$key]);
  4233.             $service->setOpIva($save_services_multiple_opiva[$key]);
  4234.             if (!empty($save_services_multiple_dateBlockLimit[$key]) or !empty($save_services_multiple_timeBlockLimit[$key])){
  4235.                 $service->setDateBlockLimit(new \DateTime($save_services_multiple_dateBlockLimit[$key].' '.$save_services_multiple_timeBlockLimit[$key]));
  4236.             }
  4237.             //$service->set ($save_services_multiple_timeBlockLimit[$key]);
  4238.             if (!empty($save_services_multiple_dateInAt[$key]) or !empty($save_services_multiple_hour_start[$key])) {
  4239.                 $service->setDateInAt(new \DateTime($save_services_multiple_dateInAt[$key] . ' ' $save_services_multiple_hour_start[$key]));
  4240.             }
  4241.             if (!empty($save_services_multiple_dateOutAt[$key]) or !empty($save_services_multiple_hour_end[$key]) ) {
  4242.                 $service->setDateOutAt(new \DateTime($save_services_multiple_dateOutAt[$key] . ' ' $save_services_multiple_hour_end[$key]));
  4243.             }
  4244.             $service->setHour($save_services_multiple_hour_start[$key]);
  4245.             //$service->set ($save_services_multiple_hour_end[$key]);
  4246.             $service->setCurrency($save_services_multiple_currency[$key]);
  4247.             $service->setOriginalopIva($save_services_multiple_originalopIva[$key]);
  4248.             $arrayServices[] = array($key$service);
  4249.         }
  4250.         $em $this->getDoctrine()->getManager();
  4251.         foreach ($save_multiple_supplier_activity_idea_rank as $key => $item){
  4252.             if(!empty($item)){
  4253.                 $prpSupActIdeaControl $em->getRepository(ProposalSupplierControl::class)->findOneById($key);
  4254.                 if (!empty($prpSupActIdeaControl)){
  4255.                     $prpSupActIdeaControl->setRank($item);
  4256.                     $em->persist($prpSupActIdeaControl);
  4257.                     $em->flush();
  4258.                 }
  4259.             }
  4260.         }
  4261.         /* Obtengo usuario logueado */
  4262.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  4263.         $user_id $user_logueado->getId();
  4264.         foreach ($arrayServices as $item){
  4265.             $prpSupService $em->getRepository(ProposalSupplierServices::class)->findOneById($item[0]);
  4266.             $srvToSave false;  //Indicador para determinar si se debe guardar el servicio
  4267.             // INICIO: Analizamos si se debe modificar el servicio, el $item[1] se encuentra el servicio
  4268.             if (!empty($item[1]->getName())){ // Hay nombre
  4269.                 $srvToSave true;
  4270.                 $prpSupService->setName($item[1]->getName());
  4271.             }
  4272.             if (!empty($item[1]->getRank())){ // Hay ranking
  4273.                 $srvToSave true;
  4274.                 $prpSupService->setRank($item[1]->getRank());
  4275.             }
  4276.             if (!empty($item[1]->getPrice())){ // Hay Precio
  4277.                 $srvToSave true;
  4278.                 $prpSupService->setPrice($item[1]->getPrice());
  4279.             }
  4280.             if (!empty($item[1]->getUnits())){ // Hay Unidades
  4281.                 $srvToSave true;
  4282.                 $prpSupService->setUnits($item[1]->getUnits());
  4283.             }
  4284.             if (!empty($item[1]->getPax())){ // Hay Personas
  4285.                 $srvToSave true;
  4286.                 $prpSupService->setPax($item[1]->getPax());
  4287.             }
  4288.             if (!empty($item[1]->getCommission())){ // Hay Comision
  4289.                 $srvToSave true;
  4290.                 $prpSupService->setCommission($item[1]->getCommission());
  4291.             }
  4292.             if (!empty($item[1]->getOver())){ // Hay Over
  4293.                 $srvToSave true;
  4294.                 $prpSupService->setOver($item[1]->getOver());
  4295.             }
  4296.             if (!empty($item[1]->getIva()) or ($item[1]->getIva() == '0')){ // Hay Iva
  4297.                 $srvToSave true;
  4298.                 $prpSupService->setIva($item[1]->getIva());
  4299.             }
  4300.             if (!empty($item[1]->getOriginalPrice())){ // Hay Original Price
  4301.                 $srvToSave true;
  4302.                 $prpSupService->setOriginalPrice($item[1]->getOriginalPrice());
  4303.             }
  4304.             if (!empty($item[1]->getOriginalIva())){ // Hay Original Iva
  4305.                 $srvToSave true;
  4306.                 $prpSupService->setOriginalIva($item[1]->getOriginalIva());
  4307.             }
  4308.             if (!empty($item[1]->getSupplierId())){ // Hay Supplier
  4309.                 $srvToSave true;
  4310.                 $prpSupService->setSupplierId($item[1]->getSupplierId());
  4311.             }
  4312.             if (($item[1]->getOpCommission() === '0') or ($item[1]->getOpCommission() === '1')){ // Hay OpCommission
  4313.                 $srvToSave true;
  4314.                 $prpSupService->setOpCommission($item[1]->getOpCommission());
  4315.             }
  4316.             if (($item[1]->getOpOver() === '0') or ($item[1]->getOpOver() === '1')){ // Hay OpOver
  4317.                 $srvToSave true;
  4318.                 $prpSupService->setOpOver($item[1]->getOpOver());
  4319.             }
  4320.             if (($item[1]->getOpIva() === '0') or ($item[1]->getOpIva() === '1')){ // Hay OpIva
  4321.                 $srvToSave true;
  4322.                 $prpSupService->setOpIva($item[1]->getOpIva());
  4323.             }
  4324.             if (!empty($item[1]->getHour())){ // Hay Hora de inicio
  4325.                 $srvToSave true;
  4326.                 $prpSupService->setHour($item[1]->getHour());
  4327.             }
  4328.             if (!empty($item[1]->getCurrency())){ // Hay Moneda
  4329.                 $srvToSave true;
  4330.                 $prpSupService->setCurrency($item[1]->getCurrency());
  4331.             }
  4332.             if (($item[1]->getOriginalopIva() === '0') or ($item[1]->getOriginalopIva() === '1')){ // Hay Original OP Iva
  4333.                 $srvToSave true;
  4334.                 $prpSupService->setOriginalopIva($item[1]->getOriginalopIva());
  4335.             }
  4336.             if (!empty($item[1]->getDateBlockLimit())){ // Hay Fecha de Block Limit
  4337.                 $srvToSave true;
  4338.                 $prpSupService->setDateBlockLimit($item[1]->getDateBlockLimit());
  4339.             }
  4340.             if (!empty($item[1]->getDateInAt())){ // Hay DateInAt
  4341.                 $srvToSave true;
  4342.                 $prpSupService->setDateInAt($item[1]->getDateInAt());
  4343.             }
  4344.             if (!empty($item[1]->getDateOutAt())){ // Hay DateInAt
  4345.                 $srvToSave true;
  4346.                 $prpSupService->setDateOutAt($item[1]->getDateOutAt());
  4347.             }
  4348.             // FIN: Analizamos si se debe modificar el servicio, el $item[1] se encuentra el servicio
  4349.             if ($srvToSave){
  4350.                 $em->persist($prpSupService);
  4351.                 $em->flush();
  4352.             }
  4353.             //Actualizar confirmado
  4354.             if ($prpSupService->getStatus() =='Confirmed'){
  4355.                 $costsClient $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($prpSupService->getId());
  4356.                 if (!empty($costsClient)){
  4357. //                $costsClient->setSupplierId($services_supplier_proposal->getSupplierId());
  4358.                     $costsClient->setAssistantId($prpSupService->getAssistantId());
  4359.                     $costsClient->setName($prpSupService->getName());
  4360.                     $costsClient->setPrice($prpSupService->getPrice());
  4361.                     $costsClient->setCurrency($prpSupService->getCurrency());
  4362.                     $costsClient->setUnits($prpSupService->getUnits());
  4363.                     $costsClient->setOpCommission($prpSupService->getOpCommission());
  4364.                     $costsClient->setCommission($prpSupService->getCommission());
  4365.                     $costsClient->setOpOver($prpSupService->getOpOver());
  4366.                     $costsClient->setOver($prpSupService->getOver());
  4367.                     $costsClient->setOpIva($prpSupService->getOpIva());
  4368.                     $costsClient->setIva($prpSupService->getIva());
  4369.                     $costsClient->setPax($prpSupService->getPax());
  4370.                     $costsClient->setHour($prpSupService->getHour());
  4371.                     $costsClient->setDateInAt($prpSupService->getDateInAt());
  4372.                     $costsClient->setDateOutAt($prpSupService->getDateOutAt());
  4373.                     $costsClient->setRank($prpSupService->getRank());
  4374.                     $costsClient->setCreatedId($user_id);
  4375.                     $costsClient->setUpdatedId($user_id);
  4376.                     $em->persist($costsClient);
  4377.                     $em->flush();
  4378.                 }
  4379.             }
  4380.         }
  4381.         return $this->redirectToRoute('proposal_destination_supplier_view', array(
  4382.             'id' => $id,
  4383.         ));
  4384.     }
  4385.     /**
  4386.      * @Route("proposal/destination/services/duplicateservice/{id}", name="proposal_destination_duplicate_service")
  4387.      */
  4388.     public function duplicateServiceAction($idRequest $request) {
  4389.         $em $this->getDoctrine()->getManager();
  4390.         $prpSupService $em->getRepository(ProposalSupplierServices::class)->findOneById($id);
  4391.         /* Obtengo usuario logueado */
  4392.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  4393.         $user_id $user_logueado->getId();
  4394.         $service = new ProposalSupplierServices();
  4395.         $service->setName('DUPLICADO - '.$prpSupService->getName());
  4396.         $service->setRank($prpSupService->getRank());
  4397.         $service->setPrice($prpSupService->getPrice());
  4398.         $service->setUnits($prpSupService->getUnits());
  4399.         $service->setPax($prpSupService->getPax());
  4400.         $service->setCommission($prpSupService->getCommission());
  4401.         $service->setOver($prpSupService->getOver());
  4402.         $service->setIva($prpSupService->getIva());
  4403.         $service->setOriginalPrice($prpSupService->getOriginalPrice());
  4404.         $service->setOriginalIva($prpSupService->getOriginalIva());
  4405.         $service->setSupplierId($prpSupService->getSupplierId());
  4406.         $service->setOpCommission($prpSupService->getOpCommission());
  4407.         $service->setOpOver($prpSupService->getOpOver());
  4408.         $service->setOpIva($prpSupService->getOpIva());
  4409.         $service->setDateBlockLimit($prpSupService->getDateBlockLimit());
  4410.         $service->setDateInAt($prpSupService->getDateInAt());
  4411.         $service->setDateOutAt($prpSupService->getDateOutAt());
  4412.         $service->setHour($prpSupService->getHour());
  4413.         $service->setCurrency($prpSupService->getCurrency());
  4414.         $service->setOriginalopIva($prpSupService->getOriginalopIva());
  4415.         $service->setCreatedId($user_id);
  4416.         $service->setCreatedAt(new \DateTime());
  4417.         $service->setUpdatedId($user_id);
  4418.         $service->setUpdatedAt(new \DateTime());
  4419.         $service->setControlId($prpSupService->getControlId());
  4420.         $service->setActivityId($prpSupService->getActivityId());
  4421.         $service->setAssistantId($prpSupService->getAssistantId());
  4422.         $service->setBreakdown($prpSupService->getBreakdown());
  4423.         $service->setDestinationId($prpSupService->getDestinationId());
  4424.         $service->setDirectPayment($prpSupService->getDirectPayment());
  4425.         $service->setIdeaId($prpSupService->getIdeaId());
  4426.         $service->setPreCommission($prpSupService->getPreCommission());
  4427.         $service->setPreIva($prpSupService->getPreIva());
  4428.         $service->setProposalId($prpSupService->getProposalId());
  4429.         $service->setServiceCatId($prpSupService->getServiceCatId());
  4430.         $service->setServiceCatName($prpSupService->getServiceCatName());
  4431.         $service->setServiceId($prpSupService->getServiceId());
  4432.         $service->setServiceIdFather($prpSupService->getServiceIdFather());
  4433.         $service->setStatus('Pending');
  4434.         $service->setStatusinternal($prpSupService->getStatusinternal());
  4435.         $em->persist($service);
  4436.         $em->flush();
  4437.         $prpSupCtrl $em->getRepository(ProposalSupplierControl::class)->findOneById($prpSupService->getControlId());
  4438.         return $this->redirectToRoute('proposal_destination_supplier_view', array(
  4439.             'id' => $prpSupCtrl->getControlDestinationId(),
  4440.             '_fragment' => $id
  4441.         ));
  4442.     }
  4443.     /**
  4444.      * @Route("proposal/destination/services/duplicatesupplier/{id}", name="proposal_destination_duplicate_supplier")
  4445.      */
  4446.     public function duplicateSupplierAction($idRequest $request) {
  4447.         $newSup $request->request->get('dupliSupplierId');
  4448.         $em $this->getDoctrine()->getManager();
  4449.         /* Obtengo usuario logueado */
  4450.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  4451.         $user_id $user_logueado->getId();
  4452.         $prpSupServices $em->getRepository(ProposalSupplierServices::class)->findByControlId($id);
  4453.         $prpSupControl $em->getRepository(ProposalSupplierControl::class)->findOneById($id);
  4454.         $origenSup $prpSupControl->getSupplierId();
  4455.         //Verificamos si Proveedor origen y destino son el mismo
  4456.         if ($newSup != $origenSup){
  4457.             //Verificamos si ya existe el control del Proveedor destino
  4458.             $prevPrpSupControl $em->getRepository(ProposalSupplierControl::class)->findBy(
  4459.                 array('proposalId'=>$prpSupControl->getProposalId(),
  4460.                       'destinoId'=>$prpSupControl->getDestinoId(),
  4461.                       'supplierId'=>$newSup));
  4462.             if (empty($prevPrpSupControl)){
  4463.                 // Proveedor origen y destino son distintos, se crea una nueva entidad de control
  4464.                 $newSupControl = new ProposalSupplierControl();
  4465.             } else {
  4466.                 // El Proveedor destino ya tiene un controlador
  4467.                 $newSupControl $prevPrpSupControl[0];
  4468.             }
  4469.             $newSupControl->setActivityId($prpSupControl->getActivityId());
  4470.             $newSupControl->setControlDestinationId($prpSupControl->getControlDestinationId());
  4471.             $newSupControl->setDateBlockLimit($prpSupControl->getDateBlockLimit());
  4472.             $newSupControl->setDestinoId($prpSupControl->getDestinoId());
  4473.             $newSupControl->setDisabled($prpSupControl->getDisabled());
  4474.             $newSupControl->setIdeaId($prpSupControl->getIdeaId());
  4475.             $newSupControl->setProposalId($prpSupControl->getProposalId());
  4476.             $newSupControl->setRank($prpSupControl->getRank());
  4477.             $newSupControl->setStatus($prpSupControl->getStatus());
  4478.             $newSupControl->setSupplierId($newSup);
  4479.             $em->persist($newSupControl);
  4480.             $em->flush();
  4481.         } else {
  4482.             $newSupControl $prpSupControl;
  4483.         }
  4484.         // Duplicamos los servicios
  4485.         foreach ($prpSupServices as $item){
  4486.             $service = new ProposalSupplierServices();
  4487.             $service->setName($item->getName());
  4488.             $service->setRank($item->getRank());
  4489.             $service->setPrice($item->getPrice());
  4490.             $service->setUnits($item->getUnits());
  4491.             $service->setPax($item->getPax());
  4492.             $service->setCommission($item->getCommission());
  4493.             $service->setOver($item->getOver());
  4494.             $service->setIva($item->getIva());
  4495.             $service->setOriginalPrice($item->getOriginalPrice());
  4496.             $service->setOriginalIva($item->getOriginalIva());
  4497.             $service->setSupplierId($newSup);
  4498.             $service->setOpCommission($item->getOpCommission());
  4499.             $service->setOpOver($item->getOpOver());
  4500.             $service->setOpIva($item->getOpIva());
  4501.             $service->setDateBlockLimit($item->getDateBlockLimit());
  4502.             $service->setDateInAt($item->getDateInAt());
  4503.             $service->setDateOutAt($item->getDateOutAt());
  4504.             $service->setHour($item->getHour());
  4505.             $service->setCurrency($item->getCurrency());
  4506.             $service->setOriginalopIva($item->getOriginalopIva());
  4507.             $service->setCreatedId($user_id);
  4508.             $service->setCreatedAt(new \DateTime());
  4509.             $service->setUpdatedId($user_id);
  4510.             $service->setUpdatedAt(new \DateTime());
  4511.             $service->setControlId($newSupControl->getId());
  4512.             $service->setActivityId($item->getActivityId());
  4513.             $service->setAssistantId($item->getAssistantId());
  4514.             $service->setBreakdown($item->getBreakdown());
  4515.             $service->setDestinationId($item->getDestinationId());
  4516.             $service->setDirectPayment($item->getDirectPayment());
  4517.             $service->setIdeaId($item->getIdeaId());
  4518.             $service->setPreCommission($item->getPreCommission());
  4519.             $service->setPreIva($item->getPreIva());
  4520.             $service->setProposalId($item->getProposalId());
  4521.             $service->setServiceCatId($item->getServiceCatId());
  4522.             $service->setServiceCatName($item->getServiceCatName());
  4523.             $service->setServiceId($item->getServiceId());
  4524.             $service->setServiceIdFather($item->getServiceIdFather());
  4525.             $service->setStatus('Pending');
  4526.             $service->setStatusinternal($item->getStatusinternal());
  4527.             $em->persist($service);
  4528.             $em->flush();
  4529.         }
  4530.         $prpSupCtrl $em->getRepository(ProposalSupplierControl::class)->findOneById($id);
  4531.         return $this->redirectToRoute('proposal_destination_supplier_view', array(
  4532.             'id' => $prpSupCtrl->getControlDestinationId(),
  4533.         ));
  4534.     }
  4535.     /**
  4536.      * @Route("proposal/destination/services/comissionall", name="proposal_destination_comission_all")
  4537.      */
  4538.     public function comissionAllAction(Request $request){
  4539.         $proposalSupplierControlId $request->request->get('proposalSupplierControlId');
  4540.         $opCommissionAll $request->request->get('opCommissionAll');
  4541.         $commissionAll $request->request->get('commissionAll');
  4542.         $em $this->getDoctrine()->getManager();
  4543.         $prpSupControl $em->getRepository(ProposalSupplierControl::class)->findOneById($proposalSupplierControlId);
  4544.         $prpSupServices $em->getRepository(ProposalSupplierServices::class)->findByControlId($proposalSupplierControlId);
  4545.         $idPrpSupServices null;
  4546.         foreach ($prpSupServices as $item){
  4547.             $item->setOpCommission($opCommissionAll);
  4548.             $item->setCommission($commissionAll);
  4549.             $idPrpSupServices $item->getId();
  4550.             $em->persist($item);
  4551.             $em->flush();
  4552.             $prpSupServicesCosts $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($item->getId());
  4553.             if (!empty($prpSupServicesCosts)){
  4554.                 $em->remove($prpSupServicesCosts);
  4555.                 $em->flush();
  4556.             }
  4557.             if (!empty($idPrpSupServices)){
  4558.                 $parameters = array(
  4559.                     'idPrpSupServices' => '%'.$idPrpSupServices.'%',
  4560.                 );
  4561.                 $dql 'SELECT i
  4562.                     FROM EventsBundle:ProposalSupplierServicesCosts i
  4563.                     WHERE i.servicesId LIKE :idPrpSupServices
  4564.                     ORDER BY i.id ASC';
  4565.                 $query $em->createQuery($dql)->setParameters($parameters);
  4566.                 $proposalSupplierServicesCosts $query->getResult();
  4567.                 // Si el servicio se encontraba dentro de $proposalSupplierServicesCosts es porque el servicio se encontraba
  4568.                 // confirmado y dentro de una proforma, se deben sacar para evitar error en el apartado de proveedores
  4569.                 foreach($proposalSupplierServicesCosts as $prpSupSrvCst){
  4570.                     $prpSupSrvCst->setServicesId('0');
  4571.                     $em->persist($prpSupSrvCst);
  4572.                     $em->flush();
  4573.                 }
  4574.             }
  4575.         }
  4576.         $fragmento = empty($prpSupServices) ? null $prpSupServices[0]->getId();
  4577.         return $this->redirectToRoute('proposal_destination_supplier_view',
  4578.             array(
  4579.                 'id' => $prpSupControl->getControlDestinationId(),
  4580.                 '_fragment' => $fragmento
  4581.             ));
  4582.     }
  4583.     private function sendTelegram $id$text )
  4584.     {
  4585.         $em $this->getDoctrine()->getManager();
  4586.         $telegUser $em->getRepository(MdvTelegramUser::class)->findOneByUserId($id);
  4587.         if (empty($telegUser)){return true;}
  4588.         $parameters = array(
  4589.             'chat_id' => $telegUser->getChatId(),
  4590.             'text' => $text,
  4591.         );
  4592.         $bot_token $telegUser->getBotToken();
  4593.         $url "https://api.telegram.org/bot$bot_token/sendMessage";
  4594.         if (!$curl curl_init()){
  4595.             exit();
  4596.         }
  4597.         curl_setopt($curl,CURLOPT_POST,true);
  4598.         curl_setopt($curl,CURLOPT_POSTFIELDS,$parameters);
  4599.         curl_setopt($curl,CURLOPT_URL,$url);
  4600.         curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
  4601.         $output curl_exec($curl);
  4602.         curl_close($curl);
  4603.         return true;
  4604.     }
  4605. }