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($agent->getEmail())
  836. //                        ->setPassword($agent->getPassGmail());
  837.                         ->setUsername('desarrollo@develup.solutions')
  838.                         ->setPassword('MeDITeRRANeAN_Develup30102023#');
  839.                     $mailer = new Swift_Mailer($transporter);
  840.                     $message = new Swift_Message();
  841.                     $message->setSubject('P#' $proposal->getId() . ', Alta de servicio')
  842. //                        ->setSender($agentMail)
  843. //                        ->setFrom($mailAgentFrom)
  844.                         ->setFrom(array("desarrollo@develup.solutions" => "System Mante 3.0"))
  845.                         ->setReplyTo($zagentReplyTo)
  846.                         ->setTo($mailAgentSent)
  847.                         ->setBody(
  848.                             $this->renderView(
  849.                                 'mail/structure-mail.html.twig',
  850.                                 array('data' => $data)
  851.                             ),
  852.                             'text/html'
  853.                         );
  854.                     $mailer->send($message);
  855.                 }
  856.                 // FIN: Envio de Correo a AV EXPRESS o DEVELUP SOLUTIONS
  857.                 $event 'The Supplier Destination Proposal has been created.';
  858.                 $successMessage $this->translator->trans($event);
  859.                 $this->addFlash('mensajeproposaldestinationservices'$successMessage);
  860.                 return $this->redirectToRoute('proposal_destination_supplier_especial_list', array(
  861.                     'idcontrol' => $control->getId()
  862.                 ));
  863.             }else{
  864.                 $errorMessage $this->translator->trans('Error, some fields are empty');
  865.                 $this->addFlash('mensajeproposaldestinationserviceserror'$errorMessage);
  866.             }
  867.         }else{
  868. //            $errorMessage = $this->translator->trans('The proposal already has this provider included');
  869. //            $this->addFlash('mensajeproposaldestinationserviceserror', $errorMessage);
  870.             return $this->redirectToRoute('proposal_destination_supplier_especial_list', array(
  871.                 'idcontrol' => $control_verifico->getId()
  872.             ));
  873.         }
  874.         return $this->redirectToRoute('proposal_destination_supplier_view', array(
  875.             'id' => $cdid,
  876.             '_fragment' => 's'.$control_verifico->getId()
  877.         ));
  878.     }
  879.     /* CREAR DESDE UN SUPPLIER */
  880.     private function createDestinationProposalSupplierCreateForm(ProposalSupplierControl $entity)
  881.     {
  882.         $form $this->createForm(ProposalSupplierControlType::class, $entity, array(
  883.             'action' => $this->generateUrl('proposal_destination_supplier_create'),
  884.             'method' => 'POST'
  885.         ));
  886.         return $form;
  887.     }
  888.     /* CREAR DESDE UN SUPPLIER */
  889.     /**
  890.      * @Route("/proposal/destination/services/create", name="proposal_destination_supplier_create")
  891.      */
  892.     public function createProposalDestinationAction(Request $request)
  893.     {
  894.         $control = new ProposalSupplierControl();
  895.         $form $this->createDestinationProposalSupplierCreateForm($control);
  896.         $form->handleRequest($request);
  897.         $supplier_proposal $form->get('supplierId')->getData();
  898.         if(!is_null($supplier_proposal)){
  899.             $control->setSupplierId($supplier_proposal->getId());
  900.         }
  901.         $em $this->getDoctrine()->getManager();
  902.         $control_verifico $em->getRepository(ProposalSupplierControl::class)->findOneBy(
  903.             array(
  904.                 'controlDestinationId' => $form->get('controlDestinationId')->getData(),
  905.                 'proposalId' => $form->get('proposalId')->getData(),
  906.                 'destinoId' => $form->get('destinoId')->getData(),
  907.                 'supplierId' => $supplier_proposal->getId(),
  908.             )
  909.         );
  910.         $proposal $em->getRepository(Proposal::class)->findOneById($form->get('proposalId')->getData());
  911.         if(empty($control_verifico)){
  912.             if($form->isValid())
  913.             {
  914.                 $control->setStatus('Pending');
  915.                 $em->persist($control);
  916.                 $em->flush();
  917.                 $event 'The Supplier Destination Proposal has been created.';
  918.                 $successMessage $this->translator->trans($event);
  919.                 $this->addFlash('mensajeproposaldestinationservices'$successMessage);
  920.             }else{
  921.                 $errorMessage $this->translator->trans('Error, some fields are empty');
  922.                 $this->addFlash('mensajeproposaldestinationserviceserror'$errorMessage);
  923.             }
  924.         }else{
  925.             $errorMessage $this->translator->trans('The proposal already has this provider included');
  926.             $this->addFlash('mensajeproposaldestinationserviceserror'$errorMessage);
  927.         }
  928.         return $this->redirectToRoute('proposal_destination_supplier_view', array(
  929.             'id' => $control->getControlDestinationId(),
  930.             '_fragment' => 's'.$control->getId()
  931.         ));
  932.     }
  933.     /* CREAR DESDE UNA Activity */
  934.     private function createDestinationProposalActivitiesCreateForm(ProposalSupplierControl $entity)
  935.     {
  936.         $form $this->createForm(ProposalActivitiesControlType::class, $entity, array(
  937.             'action' => $this->generateUrl('proposal_destination_activities_create'),
  938.             'method' => 'POST'
  939.         ));
  940.         return $form;
  941.     }
  942.     /* CREAR DESDE UNA Activity  */
  943.     /**
  944.      * @Route("/proposal/destination/services/createActivity", name="proposal_destination_activities_create")
  945.      */
  946.     public function createProposalActivityDestinationAction(Request $request)
  947.     {
  948.         $control = new ProposalSupplierControl();
  949.         $form $this->createDestinationProposalActivitiesCreateForm($control);
  950.         $form->handleRequest($request);
  951.         $supplier_proposal $form->get('activityId')->getData();
  952.         if(!is_null($supplier_proposal)){
  953.             $control->setActivityId($supplier_proposal->getId());
  954.         }
  955.         $em $this->getDoctrine()->getManager();
  956.         $control_verifico $em->getRepository(ProposalSupplierControl::class)->findOneBy(
  957.             array(
  958.                 'controlDestinationId' => $form->get('controlDestinationId')->getData(),
  959.                 'proposalId' => $form->get('proposalId')->getData(),
  960.                 'destinoId' => $form->get('destinoId')->getData(),
  961.                 'activityId' => $supplier_proposal->getId(),
  962.             )
  963.         );
  964. //        $proposal = $em->getRepository(Proposal::class)->findOneById($form->get('proposalId')->getData());
  965.         if(empty($control_verifico)){
  966.             if($form->isValid())
  967.             {
  968.                 $control->setStatus('Pending');
  969.                 $em->persist($control);
  970.                 $em->flush();
  971.                 /* METEMOS EL CONTENIDO DE LA IDEA */
  972.                 $idcontrol $control->getId();
  973.                 $idactivity $control->getActivityId();
  974.                 /*CONTROL GENERAL*/
  975.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByActivityId($idactivity);
  976.                 $id $controlgeneral->getId();
  977.                 $supplierservices= new ProposalSupplierServices();
  978.                 $supplierservices->setControlId($idcontrol);
  979.                 $supplierCrtl $em->getRepository(ProposalSupplierControl::class)->findOneById($idcontrol);
  980.                 $supplierservices->setProposalId($supplierCrtl->getProposalId());
  981.                 $supplierservices->setDestinationId($supplierCrtl->getDestinoId());
  982.                 $supplierservices->setServiceIdFather('0');
  983.                 $supplierservices->setSupplierId(null);
  984.                 $supplierservices->setActivityId($idactivity);
  985.                 $supplierservices->setIsFather('0');
  986.                 /* NAMEJO DE ADICIONALES EN EL DIA DEL EVENTO O DESPUES EL DIA DEL EVENTO */
  987.                 $proposal_data $em->getRepository(Proposal::class)->findOneById($supplierCrtl->getProposalId());
  988.                 $dayEvent $proposal_data->getDateEventStarAt()->format('Y-m-d');
  989.                 $today date('Y-m-d');
  990.                 if( $today >= $dayEvent){
  991.                     $additional "Additional";
  992.                 }else{
  993.                     $additional "Normal";
  994.                 }
  995.                 /* Obtengo usuario logueado */
  996.                 $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  997.                 $user_id $user_logueado->getId();
  998.                 $supplierservices->setCreatedId($user_id);
  999.                 $supplierservices->setUpdatedId($user_id);
  1000.                 $supplierservices->setDateInAt($proposal_data->getDateEventStarAt());
  1001.                 $supplierservices->setDateOutAt($proposal_data->getDateEventEndAt());
  1002.                 ///////colsulta de servicio
  1003.                 /* metemos accommodation *////////////////////////////////////////////////////////////////
  1004.                 $accommodations $em->getRepository(SupplierAccommodation::class)->findBySupplierId($id);
  1005.                 //la consulta es al SupplierId porque lo estamos usando como id controlador para SupplierIdeaServicesControl
  1006.                 if(!empty($accommodations)){
  1007.                     foreach($accommodations as $accommodation){
  1008.                         $supplierservices->setServiceId($accommodation->getId());
  1009.                         $supplierservices->setServiceCatId('1');
  1010.                         $supplierservices->setServiceCatName('Accommodation');
  1011.                         $supplierservices->setName($accommodation->getName());
  1012.                         $supplierservices->setPrice($accommodation->getPrice());
  1013.                         //$supplierservices->setCurrency('Euro');
  1014.                         $supplierservices->setUnits('1');
  1015.                         $supplierservices->setCommission('0');
  1016.                         //$supplierservices->setOver('Accommodation');
  1017.                         $supplierservices->setIva('10');
  1018.                         $supplierservices->setPax('0');
  1019.                         //$supplierservices->setHour('');//null
  1020.                         //$supplierservices->setDateInAt('');
  1021.                         //$supplierservices->setDateOutAt('');
  1022.                         $supplierservices->setDirectPayment('0');
  1023.                         $supplierservices->setStatus('Pending');
  1024.                         $supplierservices->setStatusinternal($additional);
  1025.                         $em->persist($supplierservices);
  1026.                         $em->flush();
  1027.                         $em->clear();
  1028.                         //para pruebas
  1029.                         //$data_prueba[] = array(
  1030.                         //    'data' => $supplierservices
  1031.                         //);
  1032.                     }
  1033.                     //para pruebas
  1034.                     //d($data_prueba);
  1035.                     //exit();
  1036.                 }
  1037.                 /* metemos menu *////////////////////////////////////////////////////////////////
  1038.                 $menus $em->getRepository(SupplierMenu::class)->findBySupplierId($id);
  1039.                 if(!empty($menus)){
  1040.                     foreach($menus as $menu){
  1041.                         $supplierservices->setServiceId($menu->getId());
  1042.                         $supplierservices->setServiceCatId('11');
  1043.                         $supplierservices->setServiceCatName('Menu');
  1044.                         $supplierservices->setName($menu->getTitle());
  1045.                         $supplierservices->setPrice($menu->getPrice());
  1046.                         //$supplierservices->setCurrency('Euro');
  1047.                         $supplierservices->setUnits('1');
  1048.                         $supplierservices->setCommission($menu->getCommission());
  1049.                         //$supplierservices->setOver('Accommodation');
  1050.                         $supplierservices->setIva($menu->getIva());
  1051.                         $supplierservices->setPax('0');
  1052.                         //$supplierservices->setHour('');//null
  1053.                         //$supplierservices->setDateInAt('');
  1054.                         //$supplierservices->setDateOutAt('');
  1055.                         $supplierservices->setDirectPayment('0');
  1056.                         $supplierservices->setStatus('Pending');
  1057.                         $supplierservices->setStatusinternal($additional);
  1058.                         $em->persist($supplierservices);
  1059.                         $em->flush();
  1060.                         $em->clear();
  1061.                         //para pruebas
  1062.                         //$data_prueba[] = array(
  1063.                         //    'data' => $supplierservices
  1064.                         //);
  1065.                     }
  1066.                     //para pruebas
  1067.                     //d($data_prueba);
  1068.                     //exit();
  1069.                 }
  1070.                 /* metemos lounge *////////////////////////////////////////////////////////////////
  1071.                 $lounges $em->getRepository(SupplierLounge::class)->findBySupplierId($id);
  1072.                 if(!empty($lounges)){
  1073.                     foreach($lounges as $lounge){
  1074.                         $supplierservices->setServiceId($lounge->getId());
  1075.                         $supplierservices->setServiceCatId('10');
  1076.                         $supplierservices->setServiceCatName('Lounge');
  1077.                         $supplierservices->setName($lounge->getName());
  1078.                         $supplierservices->setPrice($lounge->getPrice());
  1079.                         //$supplierservices->setCurrency('Euro');
  1080.                         $supplierservices->setUnits('1');
  1081.                         $supplierservices->setCommission($lounge->getCommission());
  1082.                         //$supplierservices->setOver('Accommodation');
  1083.                         $supplierservices->setIva($lounge->getIva());
  1084.                         $supplierservices->setPax('0');
  1085.                         //$supplierservices->setHour('');//null
  1086.                         //$supplierservices->setDateInAt('');
  1087.                         //$supplierservices->setDateOutAt('');
  1088.                         $supplierservices->setDirectPayment('0');
  1089.                         $supplierservices->setStatus('Pending');
  1090.                         $supplierservices->setStatusinternal($additional);
  1091.                         $em->persist($supplierservices);
  1092.                         $em->flush();
  1093.                         $em->clear();
  1094.                         //para pruebas
  1095.                         //$data_prueba[] = array(
  1096.                         //    'data' => $supplierservices
  1097.                         //);
  1098.                     }
  1099.                     //para pruebas
  1100.                     //d($data_prueba);
  1101.                     //exit();
  1102.                 }
  1103.                 /* metemos activities *////////////////////////////////////////////////////////////////
  1104.                 $activitiess $em->getRepository(SupplierActivities::class)->findBySupplierId($id);
  1105.                 if(!empty($activitiess)){
  1106.                     foreach($activitiess as $activities){
  1107.                         $supplierservices->setServiceId($activities->getId());
  1108.                         $supplierservices->setServiceCatId('2');
  1109.                         $supplierservices->setServiceCatName('Activities');
  1110.                         $supplierservices->setName($activities->getTitle());
  1111.                         $supplierservices->setPrice($activities->getPrice());
  1112.                         //$supplierservices->setCurrency('Euro');
  1113.                         $supplierservices->setUnits('1');
  1114.                         $supplierservices->setCommission($activities->getCommission());
  1115.                         //$supplierservices->setOver('Accommodation');
  1116.                         $supplierservices->setIva($activities->getIva());
  1117.                         $supplierservices->setPax('0');
  1118.                         //$supplierservices->setHour('');//null
  1119.                         //$supplierservices->setDateInAt('');
  1120.                         //$supplierservices->setDateOutAt('');
  1121.                         $supplierservices->setDirectPayment('0');
  1122.                         $supplierservices->setStatus('Pending');
  1123.                         $supplierservices->setStatusinternal($additional);
  1124.                         $em->persist($supplierservices);
  1125.                         $em->flush();
  1126.                         $em->clear();
  1127.                         //para pruebas
  1128.                         //$data_prueba[] = array(
  1129.                         //    'data' => $supplierservices
  1130.                         //);
  1131.                     }
  1132.                     //para pruebas
  1133.                     //d($data_prueba);
  1134.                     //exit();
  1135.                 }
  1136.                 /* metemos itineraries *////////////////////////////////////////////////////////////////
  1137.                 $itinerariess $em->getRepository(SupplierItineraries::class)->findBySupplierId($id);
  1138.                 if(!empty($itinerariess)){
  1139.                     foreach($itinerariess as $itineraries){
  1140.                         $supplierservices->setServiceId($itineraries->getId());
  1141.                         $supplierservices->setServiceCatId('9');
  1142.                         $supplierservices->setServiceCatName('Itineraries');
  1143.                         $supplierservices->setName($itineraries->getTitle());
  1144.                         $supplierservices->setPrice('0');
  1145.                         //$supplierservices->setCurrency('Euro');
  1146.                         $supplierservices->setUnits('1');
  1147.                         $supplierservices->setCommission('0');
  1148.                         //$supplierservices->setOver('Accommodation');
  1149.                         $supplierservices->setIva('10');
  1150.                         $supplierservices->setPax('0');
  1151.                         //$supplierservices->setHour('');//null
  1152.                         //$supplierservices->setDateInAt('');
  1153.                         //$supplierservices->setDateOutAt('');
  1154.                         $supplierservices->setDirectPayment('0');
  1155.                         $supplierservices->setStatus('Pending');
  1156.                         $supplierservices->setStatusinternal($additional);
  1157.                         $em->persist($supplierservices);
  1158.                         $em->flush();
  1159.                         $em->clear();
  1160.                         //para pruebas
  1161.                         //$data_prueba[] = array(
  1162.                         //    'data' => $supplierservices
  1163.                         //);
  1164.                     }
  1165.                     //para pruebas
  1166.                     //d($data_prueba);
  1167.                     //exit();
  1168.                 }
  1169.                 /* metemos cruise *////////////////////////////////////////////////////////////////
  1170.                 $cruises $em->getRepository(SupplierCruise::class)->findBySupplierId($id);
  1171.                 if(!empty($cruises)){
  1172.                     foreach($cruises as $cruise){
  1173.                         $supplierservices->setServiceId($cruise->getId());
  1174.                         $supplierservices->setServiceCatId('5');
  1175.                         $supplierservices->setServiceCatName('Cruise');
  1176.                         $supplierservices->setName($cruise->getTitle());
  1177.                         $supplierservices->setPrice($cruise->getPrice());
  1178.                         //$supplierservices->setCurrency('Euro');
  1179.                         $supplierservices->setUnits('1');
  1180.                         $supplierservices->setCommission($cruise->getCommission());
  1181.                         //$supplierservices->setOver('Accommodation');
  1182.                         $supplierservices->setIva($cruise->getIva());
  1183.                         $supplierservices->setPax('0');
  1184.                         //$supplierservices->setHour('');//null
  1185.                         //$supplierservices->setDateInAt('');
  1186.                         //$supplierservices->setDateOutAt('');
  1187.                         $supplierservices->setDirectPayment('0');
  1188.                         $supplierservices->setStatus('Pending');
  1189.                         $supplierservices->setStatusinternal($additional);
  1190.                         $em->persist($supplierservices);
  1191.                         $em->flush();
  1192.                         $em->clear();
  1193.                         //para pruebas
  1194.                         //$data_prueba[] = array(
  1195.                         //    'data' => $supplierservices
  1196.                         //);
  1197.                     }
  1198.                     //para pruebas
  1199.                     //d($data_prueba);
  1200.                     //exit();
  1201.                 }
  1202.                 /* metemos transport *////////////////////////////////////////////////////////////////
  1203.                 $transports $em->getRepository(SupplierTransport::class)->findBySupplierId($id);
  1204.                 if(!empty($transports)){
  1205.                     foreach($transports as $transport){
  1206.                         $supplierservices->setServiceId($transport->getId());
  1207.                         $supplierservices->setServiceCatId('13');
  1208.                         $supplierservices->setServiceCatName('Transport');
  1209.                         $supplierservices->setName($transport->getName());
  1210.                         $supplierservices->setPrice($transport->getPrice());
  1211.                         //$supplierservices->setCurrency('Euro');
  1212.                         $supplierservices->setUnits('1');
  1213.                         $supplierservices->setCommission($transport->getCommission());
  1214.                         //$supplierservices->setOver('Accommodation');
  1215.                         $supplierservices->setIva($transport->getIva());
  1216.                         $supplierservices->setPax('0');
  1217.                         //$supplierservices->setHour('');//null
  1218.                         //$supplierservices->setDateInAt('');
  1219.                         //$supplierservices->setDateOutAt('');
  1220.                         $supplierservices->setDirectPayment('0');
  1221.                         $supplierservices->setStatus('Pending');
  1222.                         $supplierservices->setStatusinternal($additional);
  1223.                         $em->persist($supplierservices);
  1224.                         $em->flush();
  1225.                         $em->clear();
  1226.                         //para pruebas
  1227.                         //$data_prueba[] = array(
  1228.                         //    'data' => $supplierservices
  1229.                         //);
  1230.                     }
  1231.                     //para pruebas
  1232.                     //d($data_prueba);
  1233.                     //exit();
  1234.                 }
  1235.                 /* metemos av *////////////////////////////////////////////////////////////////
  1236.                 $avs $em->getRepository(SupplierAv::class)->findBySupplierId($id);
  1237.                 if(!empty($avs)){
  1238.                     foreach($avs as $av){
  1239.                         $supplierservices->setServiceId($av->getId());
  1240.                         $supplierservices->setServiceCatId('3');
  1241.                         $supplierservices->setServiceCatName('Av');
  1242.                         $supplierservices->setName($av->getName());
  1243.                         $supplierservices->setPrice($av->getPrice());
  1244.                         //$supplierservices->setCurrency('Euro');
  1245.                         $supplierservices->setUnits('1');
  1246.                         $supplierservices->setCommission($av->getCommission());
  1247.                         //$supplierservices->setOver('Accommodation');
  1248.                         $supplierservices->setIva($av->getIva());
  1249.                         $supplierservices->setPax('0');
  1250.                         //$supplierservices->setHour('');//null
  1251.                         //$supplierservices->setDateInAt('');
  1252.                         //$supplierservices->setDateOutAt('');
  1253.                         $supplierservices->setDirectPayment('0');
  1254.                         $supplierservices->setStatus('Pending');
  1255.                         $supplierservices->setStatusinternal($additional);
  1256.                         $em->persist($supplierservices);
  1257.                         $em->flush();
  1258.                         $em->clear();
  1259.                         //para pruebas
  1260.                         //$data_prueba[] = array(
  1261.                         //    'data' => $supplierservices
  1262.                         //);
  1263.                     }
  1264.                     //para pruebas
  1265.                     //d($data_prueba);
  1266.                     //exit();
  1267.                 }
  1268.                 /* metemos creative *////////////////////////////////////////////////////////////////
  1269.                 $creatives $em->getRepository(SupplierCreative::class)->findBySupplierId($id);
  1270.                 if(!empty($creatives)){
  1271.                     foreach($creatives as $creative){
  1272.                         $supplierservices->setServiceId($creative->getId());
  1273.                         $supplierservices->setServiceCatId('4');
  1274.                         $supplierservices->setServiceCatName('Creative');
  1275.                         $supplierservices->setName($creative->getTitle());
  1276.                         $supplierservices->setPrice('0');
  1277.                         //$supplierservices->setCurrency('Euro');
  1278.                         $supplierservices->setUnits('1');
  1279.                         $supplierservices->setCommission('0');
  1280.                         //$supplierservices->setOver('Accommodation');
  1281.                         $supplierservices->setIva('21');
  1282.                         $supplierservices->setPax('0');
  1283.                         //$supplierservices->setHour('');//null
  1284.                         //$supplierservices->setDateInAt('');
  1285.                         //$supplierservices->setDateOutAt('');
  1286.                         $supplierservices->setDirectPayment('0');
  1287.                         $supplierservices->setStatus('Pending');
  1288.                         $supplierservices->setStatusinternal($additional);
  1289.                         $em->persist($supplierservices);
  1290.                         $em->flush();
  1291.                         $em->clear();
  1292.                         //para pruebas
  1293.                         //$data_prueba[] = array(
  1294.                         //    'data' => $supplierservices
  1295.                         //);
  1296.                     }
  1297.                     //para pruebas
  1298.                     //d($data_prueba);
  1299.                     //exit();
  1300.                 }
  1301.                 /* metemos gift *////////////////////////////////////////////////////////////////
  1302.                 $gifts $em->getRepository(SupplierGifts::class)->findBySupplierId($id);
  1303.                 if(!empty($gifts)){
  1304.                     foreach($gifts as $gift){
  1305.                         $supplierservices->setServiceId($gift->getId());
  1306.                         $supplierservices->setServiceCatId('7');
  1307.                         $supplierservices->setServiceCatName('Gifts');
  1308.                         $supplierservices->setName($gift->getName());
  1309.                         $supplierservices->setPrice($gift->getPrice());
  1310.                         //$supplierservices->setCurrency('Euro');
  1311.                         $supplierservices->setUnits('1');
  1312.                         $supplierservices->setCommission($gift->getCommission());
  1313.                         //$supplierservices->setOver('Accommodation');
  1314.                         $supplierservices->setIva($gift->getIva());
  1315.                         $supplierservices->setPax('0');
  1316.                         //$supplierservices->setHour('');//null
  1317.                         //$supplierservices->setDateInAt('');
  1318.                         //$supplierservices->setDateOutAt('');
  1319.                         $supplierservices->setDirectPayment('0');
  1320.                         $supplierservices->setStatus('Pending');
  1321.                         $supplierservices->setStatusinternal($additional);
  1322.                         $em->persist($supplierservices);
  1323.                         $em->flush();
  1324.                         $em->clear();
  1325.                         //para pruebas
  1326.                         //$data_prueba[] = array(
  1327.                         //    'data' => $supplierservices
  1328.                         //);
  1329.                     }
  1330.                     //para pruebas
  1331.                     //d($data_prueba);
  1332.                     //exit();
  1333.                 }
  1334.                 /* metemos entertainment *////////////////////////////////////////////////////////////////
  1335.                 $entertainments $em->getRepository(SupplierEntertainment::class)->findBySupplierId($id);
  1336.                 if(!empty($entertainments)){
  1337.                     foreach($entertainments as $entertainment){
  1338.                         $supplierservices->setServiceId($entertainment->getId());
  1339.                         $supplierservices->setServiceCatId('6');
  1340.                         $supplierservices->setServiceCatName('Entertainment');
  1341.                         $supplierservices->setName($entertainment->getName());
  1342.                         $supplierservices->setPrice($entertainment->getPrice());
  1343.                         //$supplierservices->setCurrency('Euro');
  1344.                         $supplierservices->setUnits('1');
  1345.                         $supplierservices->setCommission($entertainment->getCommission());
  1346.                         //$supplierservices->setOver('Accommodation');
  1347.                         $supplierservices->setIva($entertainment->getIva());
  1348.                         $supplierservices->setPax('0');
  1349.                         //$supplierservices->setHour('');//null
  1350.                         //$supplierservices->setDateInAt('');
  1351.                         //$supplierservices->setDateOutAt('');
  1352.                         $supplierservices->setDirectPayment('0');
  1353.                         $supplierservices->setStatus('Pending');
  1354.                         $supplierservices->setStatusinternal($additional);
  1355.                         $em->persist($supplierservices);
  1356.                         $em->flush();
  1357.                         $em->clear();
  1358.                         //para pruebas
  1359.                         //$data_prueba[] = array(
  1360.                         //    'data' => $supplierservices
  1361.                         //);
  1362.                     }
  1363.                     //para pruebas
  1364.                     //d($data_prueba);
  1365.                     //exit();
  1366.                 }
  1367.                 /* metemos guide *////////////////////////////////////////////////////////////////
  1368.                 $guides $em->getRepository(SupplierGuide::class)->findBySupplierId($id);
  1369.                 if(!empty($guides)){
  1370.                     foreach($guides as $guide){
  1371.                         $supplierservices->setServiceId($guide->getId());
  1372.                         $supplierservices->setServiceCatId('8');
  1373.                         $supplierservices->setServiceCatName('Guide');
  1374.                         $supplierservices->setName($guide->getName());
  1375.                         $supplierservices->setPrice($guide->getPrice());
  1376.                         //$supplierservices->setCurrency('Euro');
  1377.                         $supplierservices->setUnits('1');
  1378.                         $supplierservices->setCommission($guide->getCommission());
  1379.                         //$supplierservices->setOver('Accommodation');
  1380.                         $supplierservices->setIva($guide->getIva());
  1381.                         $supplierservices->setPax('0');
  1382.                         //$supplierservices->setHour('');//null
  1383.                         //$supplierservices->setDateInAt('');
  1384.                         //$supplierservices->setDateOutAt('');
  1385.                         $supplierservices->setDirectPayment('0');
  1386.                         $supplierservices->setStatus('Pending');
  1387.                         $supplierservices->setStatusinternal($additional);
  1388.                         $em->persist($supplierservices);
  1389.                         $em->flush();
  1390.                         $em->clear();
  1391.                         //para pruebas
  1392.                         //$data_prueba[] = array(
  1393.                         //    'data' => $supplierservices
  1394.                         //);
  1395.                     }
  1396.                     //para pruebas
  1397.                     //d($data_prueba);
  1398.                     //exit();
  1399.                 }
  1400.                 /* metemos others *////////////////////////////////////////////////////////////////
  1401.                 $otherss $em->getRepository(SupplierOthers::class)->findBySupplierId($id);
  1402.                 if(!empty($otherss)){
  1403.                     foreach($otherss as $others){
  1404.                         $supplierservices->setServiceId($others->getId());
  1405.                         $supplierservices->setServiceCatId('12');
  1406.                         $supplierservices->setServiceCatName('Others');
  1407.                         $supplierservices->setName($others->getName());
  1408.                         $supplierservices->setPrice($others->getPrice());
  1409.                         //$supplierservices->setCurrency('Euro');
  1410.                         $supplierservices->setUnits('1');
  1411.                         $supplierservices->setCommission($others->getCommission());
  1412.                         //$supplierservices->setOver('Accommodation');
  1413.                         $supplierservices->setIva($others->getIva());
  1414.                         $supplierservices->setPax('0');
  1415.                         //$supplierservices->setHour('');//null
  1416.                         //$supplierservices->setDateInAt('');
  1417.                         //$supplierservices->setDateOutAt('');
  1418.                         $supplierservices->setDirectPayment('0');
  1419.                         $supplierservices->setStatus('Pending');
  1420.                         $supplierservices->setStatusinternal($additional);
  1421.                         $em->persist($supplierservices);
  1422.                         $em->flush();
  1423.                         $em->clear();
  1424.                         //para pruebas
  1425.                         //$data_prueba[] = array(
  1426.                         //    'data' => $supplierservices
  1427.                         //);
  1428.                     }
  1429.                     //para pruebas
  1430.                     //d($data_prueba);
  1431.                     //exit();
  1432.                 }
  1433.                 /* metemos technology *////////////////////////////////////////////////////////////////
  1434.                 $technologys $em->getRepository(SupplierTechnology::class)->findBySupplierId($id);
  1435.                 if(!empty($technologys)){
  1436.                     foreach($technologys as $technology){
  1437.                         $supplierservices->setServiceId($technology->getId());
  1438.                         $supplierservices->setServiceCatId('14');
  1439.                         $supplierservices->setServiceCatName('Technology');
  1440.                         $supplierservices->setName($technology->getTitle());
  1441.                         $supplierservices->setPrice($technology->getPrice());
  1442.                         //$supplierservices->setCurrency('Euro');
  1443.                         $supplierservices->setUnits('1');
  1444.                         $supplierservices->setCommission($technology->getCommission());
  1445.                         //$supplierservices->setOver('Accommodation');
  1446.                         $supplierservices->setIva($technology->getIva());
  1447.                         $supplierservices->setPax('0');
  1448.                         //$supplierservices->setHour('');//null
  1449.                         //$supplierservices->setDateInAt('');
  1450.                         //$supplierservices->setDateOutAt('');
  1451.                         $supplierservices->setDirectPayment('0');
  1452.                         $supplierservices->setStatus('Pending');
  1453.                         $supplierservices->setStatusinternal($additional);
  1454.                         $em->persist($supplierservices);
  1455.                         $em->flush();
  1456.                         $em->clear();
  1457.                         //para pruebas
  1458.                         //$data_prueba[] = array(
  1459.                         //    'data' => $supplierservices
  1460.                         //);
  1461.                     }
  1462.                     //para pruebas
  1463.                     //d($data_prueba);
  1464.                     //exit();
  1465.                 }
  1466.                 /* metemos Assistant *////////////////////////////////////////////////////////////////
  1467.                 $assistants $em->getRepository(SupplierServicesAssistant::class)->findBySupplierId($id);
  1468.                 if(!empty($assistants)){
  1469.                     foreach($assistants as $assistant){
  1470.                         $supplierservices->setServiceId($assistant->getId());
  1471.                         $supplierservices->setServiceCatId('15');
  1472.                         $supplierservices->setServiceCatName('Assistant');
  1473.                         $supplierservices->setName($assistant->getName());
  1474.                         $supplierservices->setPrice($assistant->getPrice());
  1475.                         //$supplierservices->setCurrency('Euro');
  1476.                         $supplierservices->setUnits('1');
  1477.                         $supplierservices->setCommission($assistant->getCommission());
  1478.                         //$supplierservices->setOver('Accommodation');
  1479.                         $supplierservices->setIva($assistant->getIva());
  1480.                         $supplierservices->setPax('0');
  1481.                         //$supplierservices->setHour('');//null
  1482.                         //$supplierservices->setDateInAt('');
  1483.                         //$supplierservices->setDateOutAt('');
  1484.                         $supplierservices->setDirectPayment('0');
  1485.                         $supplierservices->setStatus('Pending');
  1486.                         $supplierservices->setStatusinternal($additional);
  1487.                         $em->persist($supplierservices);
  1488.                         $em->flush();
  1489.                         $em->clear();
  1490.                         //para pruebas
  1491.                         //$data_prueba[] = array(
  1492.                         //    'data' => $supplierservices
  1493.                         //);
  1494.                     }
  1495.                     //para pruebas
  1496.                     //d($data_prueba);
  1497.                     //exit();
  1498.                 }
  1499.                 /* FIN METEMOS EL CONTENIDO DE LA IDEA */
  1500.                 // Control para el sistema de revision
  1501.                 $actId $request->request->get('proposalsuppliercontrol')['activityId'];
  1502.                 $prpId $request->request->get('proposalsuppliercontrol')['proposalId'];
  1503.                 $activities $em->getRepository(Activities::class)->findOneById($actId);
  1504.                 $revision1 = new RevisionCarga();
  1505.                 $revision2 = new RevisionCarga();
  1506.                 $revision3 = new RevisionCarga();
  1507.                 $revision1->setIdType($activities->getId());
  1508.                 $revision2->setIdType($activities->getId());
  1509.                 $revision3->setIdType($activities->getId());
  1510.                 $revision1->setName($activities->getName());
  1511.                 $revision2->setName($activities->getName());
  1512.                 $revision3->setName($activities->getName());
  1513.                 // Titulo, Destino y observacion
  1514.                 $revision1->setType('ACTIVIDAD (Título) - Agregada al Proposal:'.$prpId);
  1515.                 $revision1->setLink('activities/edit/'.$activities->getId());
  1516.                 $revision1->setStatus(false);
  1517.                 $em->persist($revision1);
  1518.                 $em->flush();
  1519.                 // Descripcion
  1520.                 $revision2->setType('ACTIVIDAD (Descripción) - Agregada al Proposal:'.$prpId);
  1521.                 // Buscamos el ID de la descripcion
  1522.                 $idact $activities->getId();
  1523.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByActivityId($idact);
  1524.                 $idctrl $controlgeneral->getId();
  1525.                 $supdesc $em->getRepository(SupplierDescription::class)->findOneBySupplierId($idctrl);
  1526.                 $id $supdesc->getId();
  1527.                 // FIN Buscamos el ID de la descripcion
  1528.                 $revision2->setLink('activities/description/edit/'.$id);
  1529.                 $revision2->setStatus(false);
  1530.                 $em->persist($revision2);
  1531.                 $em->flush();
  1532.                 // Galería
  1533.                 $revision3->setType('ACTIVIDAD (Galería) - Agregada al Proposal:'.$prpId);
  1534.                 $revision3->setLink('activities/gallery/list/'.$activities->getId());
  1535.                 $revision3->setStatus(false);
  1536.                 $em->persist($revision3);
  1537.                 $em->flush();
  1538.                 // FIN Control para el sistema de revision
  1539.                 $event 'The Idea Destination Proposal has been created.';
  1540.                 $successMessage $this->translator->trans($event);
  1541.                 $this->addFlash('mensajeproposaldestinationservices'$successMessage);
  1542.             }else{
  1543.                 $errorMessage $this->translator->trans('Error, some fields are empty');
  1544.                 $this->addFlash('mensajeproposaldestinationserviceserror'$errorMessage);
  1545.             }
  1546.         }else{
  1547.             $errorMessage $this->translator->trans('The proposal already has this Idea included');
  1548.             $this->addFlash('mensajeproposaldestinationserviceserror'$errorMessage);
  1549.         }
  1550.         return $this->redirectToRoute('proposal_destination_supplier_view', array(
  1551.             'id' => $control->getControlDestinationId(),
  1552.             '_fragment' => 's'.$control->getId()
  1553.         ));
  1554.     }
  1555.     /* CREAR DESDE UNA IDEA */
  1556.     private function createDestinationProposalIdeasCreateForm(ProposalSupplierControl $entity)
  1557.     {
  1558.         $form $this->createForm(ProposalIdeasControlType::class, $entity, array(
  1559.             'action' => $this->generateUrl('proposal_destination_ideas_create'),
  1560.             'method' => 'POST'
  1561.         ));
  1562.         return $form;
  1563.     }
  1564.     /* CREAR DESDE UNA IDEA */
  1565.     /**
  1566.      * @Route("/proposal/destination/services/createIdea", name="proposal_destination_ideas_create")
  1567.      */
  1568.     public function createProposalIdeaDestinationAction(Request $request)
  1569.     {
  1570.         $control = new ProposalSupplierControl();
  1571.         $form $this->createDestinationProposalIdeasCreateForm($control);
  1572.         $form->handleRequest($request);
  1573.         $supplier_proposal $form->get('ideaId')->getData();
  1574.         if(!is_null($supplier_proposal)){
  1575.             $control->setIdeaId($supplier_proposal->getId());
  1576.         }
  1577.         $em $this->getDoctrine()->getManager();
  1578.         $control_verifico $em->getRepository(ProposalSupplierControl::class)->findOneBy(
  1579.             array(
  1580.                 'controlDestinationId' => $form->get('controlDestinationId')->getData(),
  1581.                 'proposalId' => $form->get('proposalId')->getData(),
  1582.                 'destinoId' => $form->get('destinoId')->getData(),
  1583.                 'ideaId' => $supplier_proposal->getId(),
  1584.             )
  1585.         );
  1586. //        $proposal = $em->getRepository(Proposal::class)->findOneById($form->get('proposalId')->getData());
  1587.         if(empty($control_verifico)){
  1588.             if($form->isValid())
  1589.             {
  1590.                 $control->setStatus('Pending');
  1591.                 $em->persist($control);
  1592.                 $em->flush();
  1593.                 /* METEMOS EL CONTENIDO DE LA IDEA */
  1594.                 $idcontrol $control->getId();
  1595.                 $ididea $control->getIdeaId();
  1596.                 /*CONTROL GENERAL*/
  1597.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByIdeaId($ididea);
  1598.                 $id $controlgeneral->getId();
  1599.                 $supplierservices= new ProposalSupplierServices();
  1600.                 $supplierservices->setControlId($idcontrol);
  1601.                 $supplierCrtl $em->getRepository(ProposalSupplierControl::class)->findOneById($idcontrol);
  1602.                 $supplierservices->setProposalId($supplierCrtl->getProposalId());
  1603.                 $supplierservices->setDestinationId($supplierCrtl->getDestinoId());
  1604.                 $supplierservices->setServiceIdFather('0');
  1605.                 $supplierservices->setSupplierId(null);
  1606.                 $supplierservices->setIdeaId($ididea);
  1607.                 $supplierservices->setIsFather('0');
  1608.                 /* NAMEJO DE ADICIONALES EN EL DIA DEL EVENTO O DESPUES EL DIA DEL EVENTO */
  1609.                 $proposal_data $em->getRepository(Proposal::class)->findOneById($supplierCrtl->getProposalId());
  1610.                 $dayEvent $proposal_data->getDateEventStarAt()->format('Y-m-d');
  1611.                 $today date('Y-m-d');
  1612.                 if( $today >= $dayEvent){
  1613.                     $additional "Additional";
  1614.                 }else{
  1615.                     $additional "Normal";
  1616.                 }
  1617.                 /* Obtengo usuario logueado */
  1618.                 $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  1619.                 $user_id $user_logueado->getId();
  1620.                 $supplierservices->setCreatedId($user_id);
  1621.                 $supplierservices->setUpdatedId($user_id);
  1622.                 $supplierservices->setDateInAt($proposal_data->getDateEventStarAt());
  1623.                 $supplierservices->setDateOutAt($proposal_data->getDateEventEndAt());
  1624.                 ///////colsulta de servicio
  1625.                 /* metemos accommodation *////////////////////////////////////////////////////////////////
  1626.                 $accommodations $em->getRepository(SupplierAccommodation::class)->findBySupplierId($id);
  1627.                 //la consulta es al SupplierId porque lo estamos usando como id controlador para SupplierIdeaServicesControl
  1628.                 if(!empty($accommodations)){
  1629.                     foreach($accommodations as $accommodation){
  1630.                         $supplierservices->setServiceId($accommodation->getId());
  1631.                         $supplierservices->setServiceCatId('1');
  1632.                         $supplierservices->setServiceCatName('Accommodation');
  1633.                         $supplierservices->setName($accommodation->getName());
  1634.                         $supplierservices->setPrice($accommodation->getPrice());
  1635.                         //$supplierservices->setCurrency('Euro');
  1636.                         $supplierservices->setUnits('1');
  1637.                         $supplierservices->setCommission('0');
  1638.                         //$supplierservices->setOver('Accommodation');
  1639.                         $supplierservices->setIva('10');
  1640.                         $supplierservices->setPax('0');
  1641.                         //$supplierservices->setHour('');//null
  1642.                         //$supplierservices->setDateInAt('');
  1643.                         //$supplierservices->setDateOutAt('');
  1644.                         $supplierservices->setDirectPayment('0');
  1645.                         $supplierservices->setStatus('Pending');
  1646.                         $supplierservices->setStatusinternal($additional);
  1647.                         $em->persist($supplierservices);
  1648.                         $em->flush();
  1649.                         $em->clear();
  1650.                         //para pruebas
  1651.                         //$data_prueba[] = array(
  1652.                         //    'data' => $supplierservices
  1653.                         //);
  1654.                     }
  1655.                     //para pruebas
  1656.                     //d($data_prueba);
  1657.                     //exit();
  1658.                 }
  1659.                 /* metemos menu *////////////////////////////////////////////////////////////////
  1660.                 $menus $em->getRepository(SupplierMenu::class)->findBySupplierId($id);
  1661.                 if(!empty($menus)){
  1662.                     foreach($menus as $menu){
  1663.                         $supplierservices->setServiceId($menu->getId());
  1664.                         $supplierservices->setServiceCatId('11');
  1665.                         $supplierservices->setServiceCatName('Menu');
  1666.                         $supplierservices->setName($menu->getTitle());
  1667.                         $supplierservices->setPrice($menu->getPrice());
  1668.                         //$supplierservices->setCurrency('Euro');
  1669.                         $supplierservices->setUnits('1');
  1670.                         $supplierservices->setCommission($menu->getCommission());
  1671.                         //$supplierservices->setOver('Accommodation');
  1672.                         $supplierservices->setIva($menu->getIva());
  1673.                         $supplierservices->setPax('0');
  1674.                         //$supplierservices->setHour('');//null
  1675.                         //$supplierservices->setDateInAt('');
  1676.                         //$supplierservices->setDateOutAt('');
  1677.                         $supplierservices->setDirectPayment('0');
  1678.                         $supplierservices->setStatus('Pending');
  1679.                         $supplierservices->setStatusinternal($additional);
  1680.                         $em->persist($supplierservices);
  1681.                         $em->flush();
  1682.                         $em->clear();
  1683.                         //para pruebas
  1684.                         //$data_prueba[] = array(
  1685.                         //    'data' => $supplierservices
  1686.                         //);
  1687.                     }
  1688.                     //para pruebas
  1689.                     //d($data_prueba);
  1690.                     //exit();
  1691.                 }
  1692.                 /* metemos lounge *////////////////////////////////////////////////////////////////
  1693.                 $lounges $em->getRepository(SupplierLounge::class)->findBySupplierId($id);
  1694.                 if(!empty($lounges)){
  1695.                     foreach($lounges as $lounge){
  1696.                         $supplierservices->setServiceId($lounge->getId());
  1697.                         $supplierservices->setServiceCatId('10');
  1698.                         $supplierservices->setServiceCatName('Lounge');
  1699.                         $supplierservices->setName($lounge->getName());
  1700.                         $supplierservices->setPrice($lounge->getPrice());
  1701.                         //$supplierservices->setCurrency('Euro');
  1702.                         $supplierservices->setUnits('1');
  1703.                         $supplierservices->setCommission($lounge->getCommission());
  1704.                         //$supplierservices->setOver('Accommodation');
  1705.                         $supplierservices->setIva($lounge->getIva());
  1706.                         $supplierservices->setPax('0');
  1707.                         //$supplierservices->setHour('');//null
  1708.                         //$supplierservices->setDateInAt('');
  1709.                         //$supplierservices->setDateOutAt('');
  1710.                         $supplierservices->setDirectPayment('0');
  1711.                         $supplierservices->setStatus('Pending');
  1712.                         $supplierservices->setStatusinternal($additional);
  1713.                         $em->persist($supplierservices);
  1714.                         $em->flush();
  1715.                         $em->clear();
  1716.                         //para pruebas
  1717.                         //$data_prueba[] = array(
  1718.                         //    'data' => $supplierservices
  1719.                         //);
  1720.                     }
  1721.                     //para pruebas
  1722.                     //d($data_prueba);
  1723.                     //exit();
  1724.                 }
  1725.                 /* metemos activities *////////////////////////////////////////////////////////////////
  1726.                 $activitiess $em->getRepository(SupplierActivities::class)->findBySupplierId($id);
  1727.                 if(!empty($activitiess)){
  1728.                     foreach($activitiess as $activities){
  1729.                         $supplierservices->setServiceId($activities->getId());
  1730.                         $supplierservices->setServiceCatId('2');
  1731.                         $supplierservices->setServiceCatName('Activities');
  1732.                         $supplierservices->setName($activities->getTitle());
  1733.                         $supplierservices->setPrice($activities->getPrice());
  1734.                         //$supplierservices->setCurrency('Euro');
  1735.                         $supplierservices->setUnits('1');
  1736.                         $supplierservices->setCommission($activities->getCommission());
  1737.                         //$supplierservices->setOver('Accommodation');
  1738.                         $supplierservices->setIva($activities->getIva());
  1739.                         $supplierservices->setPax('0');
  1740.                         //$supplierservices->setHour('');//null
  1741.                         //$supplierservices->setDateInAt('');
  1742.                         //$supplierservices->setDateOutAt('');
  1743.                         $supplierservices->setDirectPayment('0');
  1744.                         $supplierservices->setStatus('Pending');
  1745.                         $supplierservices->setStatusinternal($additional);
  1746.                         $em->persist($supplierservices);
  1747.                         $em->flush();
  1748.                         $em->clear();
  1749.                         //para pruebas
  1750.                         //$data_prueba[] = array(
  1751.                         //    'data' => $supplierservices
  1752.                         //);
  1753.                     }
  1754.                     //para pruebas
  1755.                     //d($data_prueba);
  1756.                     //exit();
  1757.                 }
  1758.                 /* metemos itineraries *////////////////////////////////////////////////////////////////
  1759.                 $itinerariess $em->getRepository(SupplierItineraries::class)->findBySupplierId($id);
  1760.                 if(!empty($itinerariess)){
  1761.                     foreach($itinerariess as $itineraries){
  1762.                         $supplierservices->setServiceId($itineraries->getId());
  1763.                         $supplierservices->setServiceCatId('9');
  1764.                         $supplierservices->setServiceCatName('Itineraries');
  1765.                         $supplierservices->setName($itineraries->getTitle());
  1766.                         $supplierservices->setPrice('0');
  1767.                         //$supplierservices->setCurrency('Euro');
  1768.                         $supplierservices->setUnits('1');
  1769.                         $supplierservices->setCommission('0');
  1770.                         //$supplierservices->setOver('Accommodation');
  1771.                         $supplierservices->setIva('10');
  1772.                         $supplierservices->setPax('0');
  1773.                         //$supplierservices->setHour('');//null
  1774.                         //$supplierservices->setDateInAt('');
  1775.                         //$supplierservices->setDateOutAt('');
  1776.                         $supplierservices->setDirectPayment('0');
  1777.                         $supplierservices->setStatus('Pending');
  1778.                         $supplierservices->setStatusinternal($additional);
  1779.                         $em->persist($supplierservices);
  1780.                         $em->flush();
  1781.                         $em->clear();
  1782.                         //para pruebas
  1783.                         //$data_prueba[] = array(
  1784.                         //    'data' => $supplierservices
  1785.                         //);
  1786.                     }
  1787.                     //para pruebas
  1788.                     //d($data_prueba);
  1789.                     //exit();
  1790.                 }
  1791.                 /* metemos cruise *////////////////////////////////////////////////////////////////
  1792.                 $cruises $em->getRepository(SupplierCruise::class)->findBySupplierId($id);
  1793.                 if(!empty($cruises)){
  1794.                     foreach($cruises as $cruise){
  1795.                         $supplierservices->setServiceId($cruise->getId());
  1796.                         $supplierservices->setServiceCatId('5');
  1797.                         $supplierservices->setServiceCatName('Cruise');
  1798.                         $supplierservices->setName($cruise->getTitle());
  1799.                         $supplierservices->setPrice($cruise->getPrice());
  1800.                         //$supplierservices->setCurrency('Euro');
  1801.                         $supplierservices->setUnits('1');
  1802.                         $supplierservices->setCommission($cruise->getCommission());
  1803.                         //$supplierservices->setOver('Accommodation');
  1804.                         $supplierservices->setIva($cruise->getIva());
  1805.                         $supplierservices->setPax('0');
  1806.                         //$supplierservices->setHour('');//null
  1807.                         //$supplierservices->setDateInAt('');
  1808.                         //$supplierservices->setDateOutAt('');
  1809.                         $supplierservices->setDirectPayment('0');
  1810.                         $supplierservices->setStatus('Pending');
  1811.                         $supplierservices->setStatusinternal($additional);
  1812.                         $em->persist($supplierservices);
  1813.                         $em->flush();
  1814.                         $em->clear();
  1815.                         //para pruebas
  1816.                         //$data_prueba[] = array(
  1817.                         //    'data' => $supplierservices
  1818.                         //);
  1819.                     }
  1820.                     //para pruebas
  1821.                     //d($data_prueba);
  1822.                     //exit();
  1823.                 }
  1824.                 /* metemos transport *////////////////////////////////////////////////////////////////
  1825.                 $transports $em->getRepository(SupplierTransport::class)->findBySupplierId($id);
  1826.                 if(!empty($transports)){
  1827.                     foreach($transports as $transport){
  1828.                         $supplierservices->setServiceId($transport->getId());
  1829.                         $supplierservices->setServiceCatId('13');
  1830.                         $supplierservices->setServiceCatName('Transport');
  1831.                         $supplierservices->setName($transport->getName());
  1832.                         $supplierservices->setPrice($transport->getPrice());
  1833.                         //$supplierservices->setCurrency('Euro');
  1834.                         $supplierservices->setUnits('1');
  1835.                         $supplierservices->setCommission($transport->getCommission());
  1836.                         //$supplierservices->setOver('Accommodation');
  1837.                         $supplierservices->setIva($transport->getIva());
  1838.                         $supplierservices->setPax('0');
  1839.                         //$supplierservices->setHour('');//null
  1840.                         //$supplierservices->setDateInAt('');
  1841.                         //$supplierservices->setDateOutAt('');
  1842.                         $supplierservices->setDirectPayment('0');
  1843.                         $supplierservices->setStatus('Pending');
  1844.                         $supplierservices->setStatusinternal($additional);
  1845.                         $em->persist($supplierservices);
  1846.                         $em->flush();
  1847.                         $em->clear();
  1848.                         //para pruebas
  1849.                         //$data_prueba[] = array(
  1850.                         //    'data' => $supplierservices
  1851.                         //);
  1852.                     }
  1853.                     //para pruebas
  1854.                     //d($data_prueba);
  1855.                     //exit();
  1856.                 }
  1857.                 /* metemos av *////////////////////////////////////////////////////////////////
  1858.                 $avs $em->getRepository(SupplierAv::class)->findBySupplierId($id);
  1859.                 if(!empty($avs)){
  1860.                     foreach($avs as $av){
  1861.                         $supplierservices->setServiceId($av->getId());
  1862.                         $supplierservices->setServiceCatId('3');
  1863.                         $supplierservices->setServiceCatName('Av');
  1864.                         $supplierservices->setName($av->getName());
  1865.                         $supplierservices->setPrice($av->getPrice());
  1866.                         //$supplierservices->setCurrency('Euro');
  1867.                         $supplierservices->setUnits('1');
  1868.                         $supplierservices->setCommission($av->getCommission());
  1869.                         //$supplierservices->setOver('Accommodation');
  1870.                         $supplierservices->setIva($av->getIva());
  1871.                         $supplierservices->setPax('0');
  1872.                         //$supplierservices->setHour('');//null
  1873.                         //$supplierservices->setDateInAt('');
  1874.                         //$supplierservices->setDateOutAt('');
  1875.                         $supplierservices->setDirectPayment('0');
  1876.                         $supplierservices->setStatus('Pending');
  1877.                         $supplierservices->setStatusinternal($additional);
  1878.                         $em->persist($supplierservices);
  1879.                         $em->flush();
  1880.                         $em->clear();
  1881.                         //para pruebas
  1882.                         //$data_prueba[] = array(
  1883.                         //    'data' => $supplierservices
  1884.                         //);
  1885.                     }
  1886.                     //para pruebas
  1887.                     //d($data_prueba);
  1888.                     //exit();
  1889.                 }
  1890.                 /* metemos creative *////////////////////////////////////////////////////////////////
  1891.                 $creatives $em->getRepository(SupplierCreative::class)->findBySupplierId($id);
  1892.                 if(!empty($creatives)){
  1893.                     foreach($creatives as $creative){
  1894.                         $supplierservices->setServiceId($creative->getId());
  1895.                         $supplierservices->setServiceCatId('4');
  1896.                         $supplierservices->setServiceCatName('Creative');
  1897.                         $supplierservices->setName($creative->getTitle());
  1898.                         $supplierservices->setPrice('0');
  1899.                         //$supplierservices->setCurrency('Euro');
  1900.                         $supplierservices->setUnits('1');
  1901.                         $supplierservices->setCommission('0');
  1902.                         //$supplierservices->setOver('Accommodation');
  1903.                         $supplierservices->setIva('21');
  1904.                         $supplierservices->setPax('0');
  1905.                         //$supplierservices->setHour('');//null
  1906.                         //$supplierservices->setDateInAt('');
  1907.                         //$supplierservices->setDateOutAt('');
  1908.                         $supplierservices->setDirectPayment('0');
  1909.                         $supplierservices->setStatus('Pending');
  1910.                         $supplierservices->setStatusinternal($additional);
  1911.                         $em->persist($supplierservices);
  1912.                         $em->flush();
  1913.                         $em->clear();
  1914.                         //para pruebas
  1915.                         //$data_prueba[] = array(
  1916.                         //    'data' => $supplierservices
  1917.                         //);
  1918.                     }
  1919.                     //para pruebas
  1920.                     //d($data_prueba);
  1921.                     //exit();
  1922.                 }
  1923.                 /* metemos gift *////////////////////////////////////////////////////////////////
  1924.                 $gifts $em->getRepository(SupplierGifts::class)->findBySupplierId($id);
  1925.                 if(!empty($gifts)){
  1926.                     foreach($gifts as $gift){
  1927.                         $supplierservices->setServiceId($gift->getId());
  1928.                         $supplierservices->setServiceCatId('7');
  1929.                         $supplierservices->setServiceCatName('Gifts');
  1930.                         $supplierservices->setName($gift->getName());
  1931.                         $supplierservices->setPrice($gift->getPrice());
  1932.                         //$supplierservices->setCurrency('Euro');
  1933.                         $supplierservices->setUnits('1');
  1934.                         $supplierservices->setCommission($gift->getCommission());
  1935.                         //$supplierservices->setOver('Accommodation');
  1936.                         $supplierservices->setIva($gift->getIva());
  1937.                         $supplierservices->setPax('0');
  1938.                         //$supplierservices->setHour('');//null
  1939.                         //$supplierservices->setDateInAt('');
  1940.                         //$supplierservices->setDateOutAt('');
  1941.                         $supplierservices->setDirectPayment('0');
  1942.                         $supplierservices->setStatus('Pending');
  1943.                         $supplierservices->setStatusinternal($additional);
  1944.                         $em->persist($supplierservices);
  1945.                         $em->flush();
  1946.                         $em->clear();
  1947.                         //para pruebas
  1948.                         //$data_prueba[] = array(
  1949.                         //    'data' => $supplierservices
  1950.                         //);
  1951.                     }
  1952.                     //para pruebas
  1953.                     //d($data_prueba);
  1954.                     //exit();
  1955.                 }
  1956.                 /* metemos entertainment *////////////////////////////////////////////////////////////////
  1957.                 $entertainments $em->getRepository(SupplierEntertainment::class)->findBySupplierId($id);
  1958.                 if(!empty($entertainments)){
  1959.                     foreach($entertainments as $entertainment){
  1960.                         $supplierservices->setServiceId($entertainment->getId());
  1961.                         $supplierservices->setServiceCatId('6');
  1962.                         $supplierservices->setServiceCatName('Entertainment');
  1963.                         $supplierservices->setName($entertainment->getName());
  1964.                         $supplierservices->setPrice($entertainment->getPrice());
  1965.                         //$supplierservices->setCurrency('Euro');
  1966.                         $supplierservices->setUnits('1');
  1967.                         $supplierservices->setCommission($entertainment->getCommission());
  1968.                         //$supplierservices->setOver('Accommodation');
  1969.                         $supplierservices->setIva($entertainment->getIva());
  1970.                         $supplierservices->setPax('0');
  1971.                         //$supplierservices->setHour('');//null
  1972.                         //$supplierservices->setDateInAt('');
  1973.                         //$supplierservices->setDateOutAt('');
  1974.                         $supplierservices->setDirectPayment('0');
  1975.                         $supplierservices->setStatus('Pending');
  1976.                         $supplierservices->setStatusinternal($additional);
  1977.                         $em->persist($supplierservices);
  1978.                         $em->flush();
  1979.                         $em->clear();
  1980.                         //para pruebas
  1981.                         //$data_prueba[] = array(
  1982.                         //    'data' => $supplierservices
  1983.                         //);
  1984.                     }
  1985.                     //para pruebas
  1986.                     //d($data_prueba);
  1987.                     //exit();
  1988.                 }
  1989.                 /* metemos guide *////////////////////////////////////////////////////////////////
  1990.                 $guides $em->getRepository(SupplierGuide::class)->findBySupplierId($id);
  1991.                 if(!empty($guides)){
  1992.                     foreach($guides as $guide){
  1993.                         $supplierservices->setServiceId($guide->getId());
  1994.                         $supplierservices->setServiceCatId('8');
  1995.                         $supplierservices->setServiceCatName('Guide');
  1996.                         $supplierservices->setName($guide->getName());
  1997.                         $supplierservices->setPrice($guide->getPrice());
  1998.                         //$supplierservices->setCurrency('Euro');
  1999.                         $supplierservices->setUnits('1');
  2000.                         $supplierservices->setCommission($guide->getCommission());
  2001.                         //$supplierservices->setOver('Accommodation');
  2002.                         $supplierservices->setIva($guide->getIva());
  2003.                         $supplierservices->setPax('0');
  2004.                         //$supplierservices->setHour('');//null
  2005.                         //$supplierservices->setDateInAt('');
  2006.                         //$supplierservices->setDateOutAt('');
  2007.                         $supplierservices->setDirectPayment('0');
  2008.                         $supplierservices->setStatus('Pending');
  2009.                         $supplierservices->setStatusinternal($additional);
  2010.                         $em->persist($supplierservices);
  2011.                         $em->flush();
  2012.                         $em->clear();
  2013.                         //para pruebas
  2014.                         //$data_prueba[] = array(
  2015.                         //    'data' => $supplierservices
  2016.                         //);
  2017.                     }
  2018.                     //para pruebas
  2019.                     //d($data_prueba);
  2020.                     //exit();
  2021.                 }
  2022.                 /* metemos others *////////////////////////////////////////////////////////////////
  2023.                 $otherss $em->getRepository(SupplierOthers::class)->findBySupplierId($id);
  2024.                 if(!empty($otherss)){
  2025.                     foreach($otherss as $others){
  2026.                         $supplierservices->setServiceId($others->getId());
  2027.                         $supplierservices->setServiceCatId('12');
  2028.                         $supplierservices->setServiceCatName('Others');
  2029.                         $supplierservices->setName($others->getName());
  2030.                         $supplierservices->setPrice($others->getPrice());
  2031.                         //$supplierservices->setCurrency('Euro');
  2032.                         $supplierservices->setUnits('1');
  2033.                         $supplierservices->setCommission($others->getCommission());
  2034.                         //$supplierservices->setOver('Accommodation');
  2035.                         $supplierservices->setIva($others->getIva());
  2036.                         $supplierservices->setPax('0');
  2037.                         //$supplierservices->setHour('');//null
  2038.                         //$supplierservices->setDateInAt('');
  2039.                         //$supplierservices->setDateOutAt('');
  2040.                         $supplierservices->setDirectPayment('0');
  2041.                         $supplierservices->setStatus('Pending');
  2042.                         $supplierservices->setStatusinternal($additional);
  2043.                         $em->persist($supplierservices);
  2044.                         $em->flush();
  2045.                         $em->clear();
  2046.                         //para pruebas
  2047.                         //$data_prueba[] = array(
  2048.                         //    'data' => $supplierservices
  2049.                         //);
  2050.                     }
  2051.                     //para pruebas
  2052.                     //d($data_prueba);
  2053.                     //exit();
  2054.                 }
  2055.                 /* metemos technology *////////////////////////////////////////////////////////////////
  2056.                 $technologys $em->getRepository(SupplierTechnology::class)->findBySupplierId($id);
  2057.                 if(!empty($technologys)){
  2058.                     foreach($technologys as $technology){
  2059.                         $supplierservices->setServiceId($technology->getId());
  2060.                         $supplierservices->setServiceCatId('14');
  2061.                         $supplierservices->setServiceCatName('Technology');
  2062.                         $supplierservices->setName($technology->getTitle());
  2063.                         $supplierservices->setPrice($technology->getPrice());
  2064.                         //$supplierservices->setCurrency('Euro');
  2065.                         $supplierservices->setUnits('1');
  2066.                         $supplierservices->setCommission($technology->getCommission());
  2067.                         //$supplierservices->setOver('Accommodation');
  2068.                         $supplierservices->setIva($technology->getIva());
  2069.                         $supplierservices->setPax('0');
  2070.                         //$supplierservices->setHour('');//null
  2071.                         //$supplierservices->setDateInAt('');
  2072.                         //$supplierservices->setDateOutAt('');
  2073.                         $supplierservices->setDirectPayment('0');
  2074.                         $supplierservices->setStatus('Pending');
  2075.                         $supplierservices->setStatusinternal($additional);
  2076.                         $em->persist($supplierservices);
  2077.                         $em->flush();
  2078.                         $em->clear();
  2079.                         //para pruebas
  2080.                         //$data_prueba[] = array(
  2081.                         //    'data' => $supplierservices
  2082.                         //);
  2083.                     }
  2084.                     //para pruebas
  2085.                     //d($data_prueba);
  2086.                     //exit();
  2087.                 }
  2088.                 /* metemos Assistant *////////////////////////////////////////////////////////////////
  2089.                 $assistants $em->getRepository(SupplierServicesAssistant::class)->findBySupplierId($id);
  2090.                 if(!empty($assistants)){
  2091.                     foreach($assistants as $assistant){
  2092.                         $supplierservices->setServiceId($assistant->getId());
  2093.                         $supplierservices->setServiceCatId('15');
  2094.                         $supplierservices->setServiceCatName('Assistant');
  2095.                         $supplierservices->setName($assistant->getName());
  2096.                         $supplierservices->setPrice($assistant->getPrice());
  2097.                         //$supplierservices->setCurrency('Euro');
  2098.                         $supplierservices->setUnits('1');
  2099.                         $supplierservices->setCommission($assistant->getCommission());
  2100.                         //$supplierservices->setOver('Accommodation');
  2101.                         $supplierservices->setIva($assistant->getIva());
  2102.                         $supplierservices->setPax('0');
  2103.                         //$supplierservices->setHour('');//null
  2104.                         //$supplierservices->setDateInAt('');
  2105.                         //$supplierservices->setDateOutAt('');
  2106.                         $supplierservices->setDirectPayment('0');
  2107.                         $supplierservices->setStatus('Pending');
  2108.                         $supplierservices->setStatusinternal($additional);
  2109.                         $em->persist($supplierservices);
  2110.                         $em->flush();
  2111.                         $em->clear();
  2112.                         //para pruebas
  2113.                         //$data_prueba[] = array(
  2114.                         //    'data' => $supplierservices
  2115.                         //);
  2116.                     }
  2117.                     //para pruebas
  2118.                     //d($data_prueba);
  2119.                     //exit();
  2120.                 }
  2121.                 /* FIN METEMOS EL CONTENIDO DE LA IDEA */
  2122.                 // Control para el sistema de revision
  2123.                 $ideas $em->getRepository(Ideas::class)->findOneById($supplier_proposal->getId());
  2124.                 $prpId $request->request->get('proposalsuppliercontrol')['proposalId'];
  2125.                 $revision1 = new RevisionCarga();
  2126.                 $revision2 = new RevisionCarga();
  2127.                 $revision3 = new RevisionCarga();
  2128.                 $revision1->setIdType($ideas->getId());
  2129.                 $revision2->setIdType($ideas->getId());
  2130.                 $revision3->setIdType($ideas->getId());
  2131.                 $revision1->setName($ideas->getName());
  2132.                 $revision2->setName($ideas->getName());
  2133.                 $revision3->setName($ideas->getName());
  2134.                 // Titulo, Destino y observacion
  2135.                 $revision1->setType('IDEA (Título) - Agregada al Proposal: '.$prpId);
  2136.                 $revision1->setLink('ideas/edit/'.$ideas->getId());
  2137.                 $revision1->setStatus(false);
  2138.                 $em->persist($revision1);
  2139.                 $em->flush();
  2140.                 // Descripcion
  2141.                 $revision2->setType('IDEA (Descripción) - Agregada al Proposal: '.$prpId);
  2142.                 // Buscamos el ID de la descripcion
  2143.                 $idact $ideas->getId();
  2144.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByIdeaId($idact);
  2145.                 $idctrl $controlgeneral->getId();
  2146.                 $supdesc $em->getRepository(SupplierDescription::class)->findOneBySupplierId($idctrl);
  2147.                 $id $supdesc->getId();
  2148.                 // FIN Buscamos el ID de la descripcion
  2149.                 $revision2->setLink('ideas/description/edit/'.$id);
  2150.                 $revision2->setStatus(false);
  2151.                 $em->persist($revision2);
  2152.                 $em->flush();
  2153.                 // Galería
  2154.                 $revision3->setType('IDEA (Galería) - Agregada al Proposal: '.$prpId);
  2155.                 $revision3->setLink('ideas/gallery/list/'.$ideas->getId());
  2156.                 $revision3->setStatus(false);
  2157.                 $em->persist($revision3);
  2158.                 $em->flush();
  2159.                 // FIN Control para el sistema de revision
  2160.                 $event 'The Idea Destination Proposal has been created.';
  2161.                 $successMessage $this->translator->trans($event);
  2162.                 $this->addFlash('mensajeproposaldestinationservices'$successMessage);
  2163.             }else{
  2164.                 $errorMessage $this->translator->trans('Error, some fields are empty');
  2165.                 $this->addFlash('mensajeproposaldestinationserviceserror'$errorMessage);
  2166.             }
  2167.         }else{
  2168.             $errorMessage $this->translator->trans('The proposal already has this Idea included');
  2169.             $this->addFlash('mensajeproposaldestinationserviceserror'$errorMessage);
  2170.         }
  2171.         return $this->redirectToRoute('proposal_destination_supplier_view', array(
  2172.             'id' => $control->getControlDestinationId(),
  2173.             '_fragment' => 's'.$control->getId()
  2174.         ));
  2175.     }
  2176.     /**
  2177.      * @Route("proposal/destination/services/disabled/{id}", name="proposal_destination_supplier_disabled")
  2178.      *
  2179.      */
  2180.     public function disabledAction($idRequest $request)
  2181.     {
  2182.         $em $this->getDoctrine()->getManager();
  2183.         $disabled $em->getRepository(ProposalSupplierControl::class)->findOneById($id);
  2184.         $proposal$em->getRepository(Proposal::class)->findOneById($disabled->getProposalId());
  2185.         $actual $disabled->getDisabled();
  2186.         $var_mensaje="";
  2187.         if($actual == "0"){
  2188.             $disabled->setDisabled('1');
  2189.             $var_mensaje "Disabled";
  2190.         }
  2191.         if($actual == "1"){
  2192.             $disabled->setDisabled('0');
  2193.             $var_mensaje "Activated";
  2194.         }
  2195.         $em->persist($disabled);
  2196.         $em->flush();
  2197.         $event 'The supplier has been. '.$var_mensaje;
  2198.         $successMessage $this->translator->trans($event);
  2199.         $this->addFlash('mensajeproposaldestinationservices'$successMessage);
  2200.         return $this->redirectToRoute('proposal_destination_supplier_view',
  2201.             array(
  2202.                 'id' => $disabled->getControlDestinationId(),
  2203.                 '_fragment' => 's'.$disabled->getId()
  2204.             )
  2205.         );
  2206.     }
  2207.     /**
  2208.      * @Route("proposal/destination/services/deleted/{id}", name="proposal_destination_supplier_deleted")
  2209.      *
  2210.      */
  2211. //    public function deleteAction($id, Request $request, LoggerInterface $logger)
  2212.     public function deleteAction($idRequest $request)
  2213.     {
  2214.         $em $this->getDoctrine()->getManager();
  2215.         $delete $em->getRepository(ProposalSupplierControl::class)->findOneById($id);
  2216.         $proposal $em->getRepository(Proposal::class)->findOneById($delete->getProposalId());
  2217.         $delete_services $em->getRepository(ProposalSupplierServices::class)->findByControlId($id);
  2218.         foreach ($delete_services as $delete_service) {
  2219.             $em->remove($delete_service);
  2220.         }
  2221.         $em->remove($delete);
  2222.         $em->flush();
  2223.         $event 'The supplier has been Deleted.';
  2224.         $successMessage $this->translator->trans($event);
  2225.         $this->addFlash('mensajeproposaldestinationservices'$successMessage);
  2226.         return $this->redirectToRoute('proposal_destination_supplier_view',
  2227.             array(
  2228.                 'id' => $delete->getControlDestinationId()
  2229.             )
  2230.         );
  2231.     }
  2232.     /**
  2233.      * @Route("proposal/destination/services/list/{idcontrol}", name="proposal_destination_supplier_list")
  2234.      */
  2235.     public function listAction($idcontrolRequest $request) {
  2236.         $em $this->getDoctrine()->getManager();
  2237.         $control $em->getRepository(ProposalSupplierControl::class)->findOneById($idcontrol);
  2238.         $idsupplier $control->getSupplierId();
  2239.         $ididea $control->getIdeaId();
  2240.         $idactivity $control->getActivityId();
  2241.         if($idsupplier == '0'){
  2242.             $id '0';
  2243.         }else{
  2244.             if(!is_null($idsupplier)){
  2245.                 /*CONTROL GENERAL*/
  2246.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneBySupplierId($idsupplier);
  2247.                 $id $controlgeneral->getId();
  2248.             }
  2249.             if(!is_null($idactivity)){
  2250.                 /*CONTROL GENERAL*/
  2251.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByActivityId($idactivity);
  2252.                 $id $controlgeneral->getId();
  2253.             }
  2254.             if(!is_null($ididea)){
  2255.                 /*CONTROL GENERAL*/
  2256.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByIdeaId($ididea);
  2257.                 $id $controlgeneral->getId();
  2258.             }
  2259.         }
  2260.         /* accommodations */
  2261.         $accommodations $em->getRepository(SupplierAccommodation::class)->findBySupplierId($id);
  2262.         $data_accommodation = array();
  2263.         foreach ($accommodations as $accommodation) {
  2264.             /* Consulta en Control Services */
  2265.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2266.                 'servicesId' => $accommodation->getId(),
  2267.                 'servicesCat' => $accommodation->getControlCat()
  2268.             ));
  2269.             //class="label label-flat label-rounded label-icon border-grey text-grey"
  2270.             if ($accommodation->getMinibar()){
  2271.                 $accommodation->setMinibar('<span class="label quitar-margin-15"><img src="/assets/images/icons/mi-20.png"></span>');
  2272.             }
  2273.             if ($accommodation->getWifi()){
  2274.                 $accommodation->setWifi('<span class="label quitar-margin-15"><img src="/assets/images/icons/wi-20.png"></span>');
  2275.             }
  2276.             if ($accommodation->getAirconditioner()){
  2277.                 $accommodation->setAirconditioner('<span class="label quitar-margin-15"><img src="/assets/images/icons/ac-20.png"></span>');
  2278.             }
  2279.             if ($accommodation->getCalefaction()){
  2280.                 $accommodation->setCalefaction('<span class="label quitar-margin-15"><img src="/assets/images/icons/ca-20.png"></span>');
  2281.             }
  2282.             if ($accommodation->getPool()){
  2283.                 $accommodation->setPool('<span class="label quitar-margin-15"><img src="/assets/images/icons/po-20.png"></span>');
  2284.             }
  2285.             if ($accommodation->getBath()){
  2286.                 $accommodation->setBath('<span class="label quitar-margin-15"><img src="/assets/images/icons/ba-20.png"></span>');
  2287.             }
  2288.             if ($accommodation->getCoffeemaker()){
  2289.                 $accommodation->setCoffeemaker('<span class="label quitar-margin-15"><img src="/assets/images/icons/cm-20.png"></span>');
  2290.             }
  2291.             if ($accommodation->getKitchen()){
  2292.                 $accommodation->setKitchen('<span class="label quitar-margin-15"><img src="/assets/images/icons/ki-20.png"></span>');
  2293.             }
  2294.             if ($accommodation->getWasher()){
  2295.                 $accommodation->setWasher('<span class="label quitar-margin-15"><img src="/assets/images/icons/wa-20.png"></span>');
  2296.             }
  2297.             if ($accommodation->getFlattv()){
  2298.                 $accommodation->setFlattv('<span class="label quitar-margin-15"><img src="/assets/images/icons/tv-20.png"></span>');
  2299.             }
  2300.             if ($accommodation->getElectrickettle()){
  2301.                 $accommodation->setElectrickettle('<span class="label quitar-margin-15"><img src="/assets/images/icons/ke-20.png"></span>');
  2302.             }
  2303.             if ($accommodation->getViews()){
  2304.                 $accommodation->setViews('<span class="label quitar-margin-15"><img src="/assets/images/icons/vi-20.png"></span>');
  2305.             }
  2306.             if ($accommodation->getPets()){
  2307.                 $accommodation->setPets('<span class="label quitar-margin-15"><img src="/assets/images/icons/pe-20.png"></span>');
  2308.             }
  2309. //                $data_accommodation[]=$accommodation;
  2310.             $data_accommodation[] = array(
  2311.                 'id' => $accommodation->getId(),
  2312.                 'name' => $accommodation->getName(),
  2313.                 'size' => $accommodation->getSize(),
  2314.                 'quantity' => $accommodation->getQuantity(),
  2315.                 'price' => $accommodation->getPrice(),
  2316.                 'controlId' => $controlctrlDes->getId(),
  2317.                 'minibar' => $accommodation->getMinibar(),
  2318.                 'wifi' => $accommodation->getWifi(),
  2319.                 'airconditioner' => $accommodation->getAirconditioner(),
  2320.                 'calefaction' => $accommodation->getCalefaction(),
  2321.                 'pool' => $accommodation->getPool(),
  2322.                 'bath' => $accommodation->getBath(),
  2323.                 'coffeemaker' => $accommodation->getCoffeemaker(),
  2324.                 'kitchen' => $accommodation->getKitchen(),
  2325.                 'washer' => $accommodation->getWasher(),
  2326.                 'flattv' => $accommodation->getFlattv(),
  2327.                 'electrickettle' => $accommodation->getElectrickettle(),
  2328.                 'views' => $accommodation->getViews(),
  2329.                 'pets' => $accommodation->getPets()
  2330.             );
  2331.         }
  2332.         /* accommodations */
  2333.         /* menu */
  2334.         $menus $em->getRepository(SupplierMenu::class)->findBySupplierId($id);
  2335.         /* menu Description*/
  2336.         $data_menu = array();
  2337.         foreach($menus as $menu){
  2338.             /* Consulta en Control Description */
  2339.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2340.                 'servicesId' => $menu->getId(),
  2341.                 'servicesCat' => $menu->getControlCat()
  2342.             ));
  2343. //            $controlctrlDes->getId();
  2344. //            $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2345.             $data_menu[] = array(
  2346.                 'id' => $menu->getId(),
  2347.                 'title' => $menu->getTitle(),
  2348.                 'description' => $menu->getDescription(),
  2349.                 'currency' => $menu->getCurrency(),
  2350.                 'price' => $menu->getPrice(),
  2351.                 'commission' => $menu->getCommission(),
  2352.                 'iva' => $menu->getIva(),
  2353.                 'controlId' => $controlctrlDes->getId()
  2354.             );
  2355.         }
  2356.         /* lounge */
  2357.         $lounges $em->getRepository(SupplierLounge::class)->findBySupplierId($id);
  2358.         /* lounge Description*/
  2359.         $data_lounge = array();
  2360.         foreach($lounges as $lounge){
  2361.             /* Consulta en Control Description */
  2362.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2363.                 'servicesId' => $lounge->getId(),
  2364.                 'servicesCat' => $lounge->getControlCat()
  2365.             ));
  2366. //            $controlctrlDes->getId();
  2367. //            $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2368.             $data_lounge[] = array(
  2369.                 'id' => $lounge->getId(),
  2370.                 'name' => $lounge->getName(),
  2371.                 'currency' => $lounge->getCurrency(),
  2372.                 'price' => $lounge->getPrice(),
  2373.                 'commission' => $lounge->getCommission(),
  2374.                 'iva' => $lounge->getIva(),
  2375.                 'controlId' => $controlctrlDes->getId()
  2376.             );
  2377.         }
  2378.         /* Transport */
  2379.         $transports $em->getRepository(SupplierTransport::class)->findBySupplierId($id);
  2380.         /* Transport Description*/
  2381.         $data_transport = array();
  2382.         foreach($transports as $transport){
  2383.             /* Consulta en Control Description */
  2384.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2385.                 'servicesId' => $transport->getId(),
  2386.                 'servicesCat' => $transport->getControlCat()
  2387.             ));
  2388. //            $controlctrlDes->getId();
  2389. //            $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2390.             $data_transport[] = array(
  2391.                 'id' => $transport->getId(),
  2392.                 'name' => $transport->getName(),
  2393.                 'driver' => $transport->getDriver(),
  2394.                 'currency' => $transport->getCurrency(),
  2395.                 'price' => $transport->getPrice(),
  2396.                 'commission' => $transport->getCommission(),
  2397.                 'iva' => $transport->getIva(),
  2398.                 'controlId' => $controlctrlDes->getId()
  2399.             );
  2400.         }
  2401.         /* Guide */
  2402.         $guides $em->getRepository(SupplierGuide::class)->findBySupplierId($id);
  2403.         /* Guide Description*/
  2404.         $data_guide = array();
  2405.         foreach($guides as $guide){
  2406.             /* Consulta en Control Description */
  2407.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2408.                 'servicesId' => $guide->getId(),
  2409.                 'servicesCat' => $guide->getControlCat()
  2410.             ));
  2411. //            $controlctrlDes->getId();
  2412. //            $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2413.             $data_guide[] = array(
  2414.                 'id' => $guide->getId(),
  2415.                 'name' => $guide->getName(),
  2416.                 'guide' => $guide->getGuide(),
  2417.                 'currency' => $guide->getCurrency(),
  2418.                 'price' => $guide->getPrice(),
  2419.                 'commission' => $guide->getCommission(),
  2420.                 'iva' => $guide->getIva(),
  2421.                 'controlId' => $controlctrlDes->getId()
  2422.             );
  2423.         }
  2424.         /* Itineraries */
  2425.         $itinerariess $em->getRepository(SupplierItineraries::class)->findBySupplierId($id);
  2426.         /* Itineraries Description*/
  2427.         $data_itineraries = array();
  2428.         foreach($itinerariess as $itineraries){
  2429.             /* Consulta en Control Description */
  2430.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2431.                 'servicesId' => $itineraries->getId(),
  2432.                 'servicesCat' => $itineraries->getControlCat()
  2433.             ));
  2434.             //$controlctrlDes->getId();
  2435.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2436.             $data_itineraries[] = array(
  2437.                 'id' => $itineraries->getId(),
  2438.                 'title' => $itineraries->getTitle(),
  2439.                 'controlId' => $controlctrlDes->getId(),
  2440.                 'description' => $description
  2441.             );
  2442.         }
  2443.         /* activities */
  2444.         $activitiess $em->getRepository(SupplierActivities::class)->findBySupplierId($id);
  2445.         /* activities Description*/
  2446.         $data_activities = array();
  2447.         foreach($activitiess as $activities){
  2448.             /* Consulta en Control Description */
  2449.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2450.                 'servicesId' => $activities->getId(),
  2451.                 'servicesCat' => $activities->getControlCat()
  2452.             ));
  2453.             //$controlctrlDes->getId();
  2454.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2455.             $data_activities[] = array(
  2456.                 'id' => $activities->getId(),
  2457.                 'title' => $activities->getTitle(),
  2458.                 'capacity' => $activities->getCapacity(),
  2459.                 'currency' => $activities->getCurrency(),
  2460.                 'price' => $activities->getPrice(),
  2461.                 'commission' => $activities->getCommission(),
  2462.                 'iva' => $activities->getIva(),
  2463.                 'controlId' => $controlctrlDes->getId(),
  2464.                 'description' => $description
  2465.             );
  2466.         }
  2467.         /* cruise */
  2468.         $cruises $em->getRepository(SupplierCruise::class)->findBySupplierId($id);
  2469.         /* cruise Description*/
  2470.         $data_cruise = array();
  2471.         foreach($cruises as $cruise){
  2472.             /* Consulta en Control Description */
  2473.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2474.                 'servicesId' => $cruise->getId(),
  2475.                 'servicesCat' => $cruise->getControlCat()
  2476.             ));
  2477.             //$controlctrlDes->getId();
  2478.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2479.             $data_cruise[] = array(
  2480.                 'id' => $cruise->getId(),
  2481.                 'title' => $cruise->getTitle(),
  2482.                 'currency' => $cruise->getCurrency(),
  2483.                 'price' => $cruise->getPrice(),
  2484.                 'commission' => $cruise->getCommission(),
  2485.                 'iva' => $cruise->getIva(),
  2486.                 'controlId' => $controlctrlDes->getId(),
  2487.                 'description' => $description
  2488.             );
  2489.         }
  2490.         /* Av */
  2491.         $avs $em->getRepository(SupplierAv::class)->findBySupplierId($id);
  2492.         /* Av Description*/
  2493.         $data_av = array();
  2494.         foreach($avs as $av){
  2495.             /* Consulta en Control Description */
  2496.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2497.                 'servicesId' => $av->getId(),
  2498.                 'servicesCat' => $av->getControlCat()
  2499.             ));
  2500.             //$controlctrlDes->getId();
  2501.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2502.             $data_av[] = array(
  2503.                 'id' => $av->getId(),
  2504.                 'name' => $av->getName(),
  2505.                 'responsible' => $av->getResponsible(),
  2506.                 'currency' => $av->getCurrency(),
  2507.                 'price' => $av->getPrice(),
  2508.                 'commission' => $av->getCommission(),
  2509.                 'iva' => $av->getIva(),
  2510.                 'controlId' => $controlctrlDes->getId(),
  2511.                 'description' => $description
  2512.             );
  2513.         }
  2514.         /* Creative */
  2515.         $creatives $em->getRepository(SupplierCreative::class)->findBySupplierId($id);
  2516.         /* Creative Description*/
  2517.         $data_creative = array();
  2518.         foreach($creatives as $creative){
  2519.             /* Consulta en Control Description */
  2520.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2521.                 'servicesId' => $creative->getId(),
  2522.                 'servicesCat' => $creative->getControlCat()
  2523.             ));
  2524.             //$controlctrlDes->getId();
  2525.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2526.             $data_creative[] = array(
  2527.                 'id' => $creative->getId(),
  2528.                 'title' => $creative->getTitle(),
  2529.                 'controlId' => $controlctrlDes->getId(),
  2530.                 'description' => $description
  2531.             );
  2532.         }
  2533.         /* Gifts */
  2534.         $gifts $em->getRepository(SupplierGifts::class)->findBySupplierId($id);
  2535.         /* Gifts Description*/
  2536.         $data_gifts = array();
  2537.         foreach($gifts as $gift){
  2538.             /* Consulta en Control Description */
  2539.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2540.                 'servicesId' => $gift->getId(),
  2541.                 'servicesCat' => $gift->getControlCat()
  2542.             ));
  2543.             //$controlctrlDes->getId();
  2544.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2545.             $data_gifts[] = array(
  2546.                 'id' => $gift->getId(),
  2547.                 'name' => $gift->getName(),
  2548.                 'responsible' => $gift->getResponsible(),
  2549.                 'currency' => $gift->getCurrency(),
  2550.                 'price' => $gift->getPrice(),
  2551.                 'commission' => $gift->getCommission(),
  2552.                 'iva' => $gift->getIva(),
  2553.                 'controlId' => $controlctrlDes->getId(),
  2554.                 'description' => $description
  2555.             );
  2556.         }
  2557.         /* Entertainment */
  2558.         $entertainments $em->getRepository(SupplierEntertainment::class)->findBySupplierId($id);
  2559.         /* Entertainment Description*/
  2560.         $data_entertainment = array();
  2561.         foreach($entertainments as $entertainment){
  2562.             /* Consulta en Control Description */
  2563.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2564.                 'servicesId' => $entertainment->getId(),
  2565.                 'servicesCat' => $entertainment->getControlCat()
  2566.             ));
  2567.             //$controlctrlDes->getId();
  2568.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2569.             $data_entertainment[] = array(
  2570.                 'id' => $entertainment->getId(),
  2571.                 'name' => $entertainment->getName(),
  2572.                 'responsible' => $entertainment->getResponsible(),
  2573.                 'currency' => $entertainment->getCurrency(),
  2574.                 'price' => $entertainment->getPrice(),
  2575.                 'commission' => $entertainment->getCommission(),
  2576.                 'iva' => $entertainment->getIva(),
  2577.                 'controlId' => $controlctrlDes->getId(),
  2578.                 'description' => $description
  2579.             );
  2580.         }
  2581.         /* Others */
  2582.         $otherss $em->getRepository(SupplierOthers::class)->findBySupplierId($id);
  2583.         /* Others Description*/
  2584.         $data_others = array();
  2585.         foreach($otherss as $others){
  2586.             /* Consulta en Control Description */
  2587.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2588.                 'servicesId' => $others->getId(),
  2589.                 'servicesCat' => $others->getControlCat()
  2590.             ));
  2591.             //$controlctrlDes->getId();
  2592.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2593.             $data_others[] = array(
  2594.                 'id' => $others->getId(),
  2595.                 'name' => $others->getName(),
  2596.                 'responsible' => $others->getResponsible(),
  2597.                 'currency' => $others->getCurrency(),
  2598.                 'price' => $others->getPrice(),
  2599.                 'commission' => $others->getCommission(),
  2600.                 'iva' => $others->getIva(),
  2601.                 'controlId' => $controlctrlDes->getId(),
  2602.                 'description' => $description
  2603.             );
  2604.         }
  2605.         /* technology */
  2606.         if ($idsupplier == 2){          // Es una tecnologia de Develup
  2607.             $technologys $em->getRepository(MdvProduct::class)->findAll();
  2608.             $data_technology = array();
  2609.             foreach($technologys as $technology){
  2610.                 $data_technology[] = array(
  2611.                     'id' => $technology->getId(),
  2612.                     'title' => $technology->getName(),
  2613.                     'modules' => null,
  2614.                     'type' => $technology->getType(),
  2615.                     'currency' => 'Euro',
  2616.                     'price' => $technology->getPrice(),
  2617.                     'commission' => $technology->getCommission(),
  2618.                     'iva' => $technology->getIva(),
  2619.                     'controlId' => null,
  2620.                     'description' => $technology->getDescription(),
  2621.                     'supplier' => 'Develup',
  2622.                 );
  2623.             }
  2624.         } else {
  2625.             $technologys $em->getRepository(SupplierTechnology::class)->findBySupplierId($id);
  2626.             /* technology Description*/
  2627.             $data_technology = array();
  2628.             foreach($technologys as $technology){
  2629.                 /* Consulta en Control Description */
  2630.                 $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2631.                     'servicesId' => $technology->getId(),
  2632.                     'servicesCat' => $technology->getControlCat()
  2633.                 ));
  2634.                 //$controlctrlDes->getId();
  2635.                 $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2636.                 $data_technology[] = array(
  2637.                     'id' => $technology->getId(),
  2638.                     'title' => $technology->getTitle(),
  2639.                     'modules' => $technology->getModules(),
  2640.                     'type' => $technology->getType(),
  2641.                     'currency' => $technology->getCurrency(),
  2642.                     'price' => $technology->getPrice(),
  2643.                     'commission' => $technology->getCommission(),
  2644.                     'iva' => $technology->getIva(),
  2645.                     'controlId' => $controlctrlDes->getId(),
  2646.                     'description' => $description
  2647.                 );
  2648.             }
  2649.             /////////////////////////////////////////////////////////////////////
  2650.             $technologys $em->getRepository(SupplierTechnology::class)->findBySupplierId($id);
  2651.             /* technology Description*/
  2652.             $data_technology = array();
  2653.             foreach($technologys as $technology){
  2654.                 /* Consulta en Control Description */
  2655.                 $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2656.                     'servicesId' => $technology->getId(),
  2657.                     'servicesCat' => $technology->getControlCat()
  2658.                 ));
  2659.                 //$controlctrlDes->getId();
  2660.                 $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2661.                 $data_technology[] = array(
  2662.                     'id' => $technology->getId(),
  2663.                     'title' => $technology->getTitle(),
  2664.                     'modules' => $technology->getModules(),
  2665.                     'type' => $technology->getType(),
  2666.                     'currency' => $technology->getCurrency(),
  2667.                     'price' => $technology->getPrice(),
  2668.                     'commission' => $technology->getCommission(),
  2669.                     'iva' => $technology->getIva(),
  2670.                     'controlId' => $controlctrlDes->getId(),
  2671.                     'description' => $description
  2672.                 );
  2673.             }
  2674.         }
  2675.         /* Assistant  */
  2676.         $assistants $em->getRepository(SupplierServicesAssistant::class)->findBySupplierId($id);
  2677.         /* Assistant  Description*/
  2678.         $data_assistant = array();
  2679.         foreach($assistants as $assistant){
  2680.             /* Consulta en Control Description */
  2681.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2682.                 'servicesId' => $assistant->getId(),
  2683.                 'servicesCat' => $assistant->getControlCat()
  2684.             ));
  2685.             //$controlctrlDes->getId();
  2686.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2687.             $data_assistant[] = array(
  2688.                 'id' => $assistant->getId(),
  2689.                 'name' => $assistant->getName(),
  2690.                 'quantity' => $assistant->getQuantity(),
  2691.                 'currency' => $assistant->getCurrency(),
  2692.                 'price' => $assistant->getPrice(),
  2693.                 'commission' => $assistant->getCommission(),
  2694.                 'iva' => $assistant->getIva(),
  2695.                 'controlId' => $controlctrlDes->getId(),
  2696.                 'description' => $description
  2697.             );
  2698.         }
  2699.         /* salida de data */
  2700.         return $this->render('MDS/EventsBundle/services/services-modal-proposal.html.twig', array(
  2701.             'idcontrol' => $idcontrol,
  2702.             'accommodations' => $data_accommodation,
  2703.             'menus' => $data_menu,
  2704.             'lounges' => $data_lounge,
  2705.             'transports' => $data_transport,
  2706.             'guides' => $data_guide,
  2707.             'itineraries' => $data_itineraries,
  2708.             'activities' => $data_activities,
  2709.             'cruises' => $data_cruise,
  2710.             'avs' => $data_av,
  2711.             'creatives' => $data_creative,
  2712.             'gifts' => $data_gifts,
  2713.             'entertainments' => $data_entertainment,
  2714.             'technology' => $data_technology,
  2715.             'assistants' => $data_assistant,
  2716.             'otherss' => $data_others
  2717.         ));
  2718.     }
  2719.     /**
  2720.      * @Route("proposal/destination/servicesesp/list/{idcontrol}", name="proposal_destination_supplier_especial_list")
  2721.      */
  2722.     public function listEspecialSupplierAction($idcontrolRequest $request) {
  2723.         $em $this->getDoctrine()->getManager();
  2724.         $control $em->getRepository(ProposalSupplierControl::class)->findOneById($idcontrol);
  2725.         $idsupplier $control->getSupplierId();
  2726.         $cdid $control->getControlDestinationId();
  2727.         $ididea $control->getIdeaId();
  2728.         $idactivity $control->getActivityId();
  2729.         $proposal $em->getRepository(Proposal::class)->findOneById($control->getProposalId());
  2730.         if($idsupplier == '0'){
  2731.             $id '0';
  2732.         }else{
  2733.             if(!is_null($idsupplier)){
  2734.                 /*CONTROL GENERAL*/
  2735.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneBySupplierId($idsupplier);
  2736.                 $id $controlgeneral->getId();
  2737.             }
  2738.             if(!is_null($idactivity)){
  2739.                 /*CONTROL GENERAL*/
  2740.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByActivityId($idactivity);
  2741.                 $id $controlgeneral->getId();
  2742.             }
  2743.             if(!is_null($ididea)){
  2744.                 /*CONTROL GENERAL*/
  2745.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByIdeaId($ididea);
  2746.                 $id $controlgeneral->getId();
  2747.             }
  2748.         }
  2749.         /* accommodations */
  2750.         $accommodations $em->getRepository(SupplierAccommodation::class)->findBySupplierId($id);
  2751.         $data_accommodation = array();
  2752.         foreach ($accommodations as $accommodation) {
  2753.             /* Consulta en Control Services */
  2754.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2755.                 'servicesId' => $accommodation->getId(),
  2756.                 'servicesCat' => $accommodation->getControlCat()
  2757.             ));
  2758.             //class="label label-flat label-rounded label-icon border-grey text-grey"
  2759.             if ($accommodation->getMinibar()){
  2760.                 $accommodation->setMinibar('<span class="label quitar-margin-15"><img src="/assets/images/icons/mi-20.png"></span>');
  2761.             }
  2762.             if ($accommodation->getWifi()){
  2763.                 $accommodation->setWifi('<span class="label quitar-margin-15"><img src="/assets/images/icons/wi-20.png"></span>');
  2764.             }
  2765.             if ($accommodation->getAirconditioner()){
  2766.                 $accommodation->setAirconditioner('<span class="label quitar-margin-15"><img src="/assets/images/icons/ac-20.png"></span>');
  2767.             }
  2768.             if ($accommodation->getCalefaction()){
  2769.                 $accommodation->setCalefaction('<span class="label quitar-margin-15"><img src="/assets/images/icons/ca-20.png"></span>');
  2770.             }
  2771.             if ($accommodation->getPool()){
  2772.                 $accommodation->setPool('<span class="label quitar-margin-15"><img src="/assets/images/icons/po-20.png"></span>');
  2773.             }
  2774.             if ($accommodation->getBath()){
  2775.                 $accommodation->setBath('<span class="label quitar-margin-15"><img src="/assets/images/icons/ba-20.png"></span>');
  2776.             }
  2777.             if ($accommodation->getCoffeemaker()){
  2778.                 $accommodation->setCoffeemaker('<span class="label quitar-margin-15"><img src="/assets/images/icons/cm-20.png"></span>');
  2779.             }
  2780.             if ($accommodation->getKitchen()){
  2781.                 $accommodation->setKitchen('<span class="label quitar-margin-15"><img src="/assets/images/icons/ki-20.png"></span>');
  2782.             }
  2783.             if ($accommodation->getWasher()){
  2784.                 $accommodation->setWasher('<span class="label quitar-margin-15"><img src="/assets/images/icons/wa-20.png"></span>');
  2785.             }
  2786.             if ($accommodation->getFlattv()){
  2787.                 $accommodation->setFlattv('<span class="label quitar-margin-15"><img src="/assets/images/icons/tv-20.png"></span>');
  2788.             }
  2789.             if ($accommodation->getElectrickettle()){
  2790.                 $accommodation->setElectrickettle('<span class="label quitar-margin-15"><img src="/assets/images/icons/ke-20.png"></span>');
  2791.             }
  2792.             if ($accommodation->getViews()){
  2793.                 $accommodation->setViews('<span class="label quitar-margin-15"><img src="/assets/images/icons/vi-20.png"></span>');
  2794.             }
  2795.             if ($accommodation->getPets()){
  2796.                 $accommodation->setPets('<span class="label quitar-margin-15"><img src="/assets/images/icons/pe-20.png"></span>');
  2797.             }
  2798. //                $data_accommodation[]=$accommodation;
  2799.             $data_accommodation[] = array(
  2800.                 'id' => $accommodation->getId(),
  2801.                 'name' => $accommodation->getName(),
  2802.                 'size' => $accommodation->getSize(),
  2803.                 'quantity' => $accommodation->getQuantity(),
  2804.                 'price' => $accommodation->getPrice(),
  2805.                 'controlId' => $controlctrlDes->getId(),
  2806.                 'minibar' => $accommodation->getMinibar(),
  2807.                 'wifi' => $accommodation->getWifi(),
  2808.                 'airconditioner' => $accommodation->getAirconditioner(),
  2809.                 'calefaction' => $accommodation->getCalefaction(),
  2810.                 'pool' => $accommodation->getPool(),
  2811.                 'bath' => $accommodation->getBath(),
  2812.                 'coffeemaker' => $accommodation->getCoffeemaker(),
  2813.                 'kitchen' => $accommodation->getKitchen(),
  2814.                 'washer' => $accommodation->getWasher(),
  2815.                 'flattv' => $accommodation->getFlattv(),
  2816.                 'electrickettle' => $accommodation->getElectrickettle(),
  2817.                 'views' => $accommodation->getViews(),
  2818.                 'pets' => $accommodation->getPets()
  2819.             );
  2820.         }
  2821.         /* accommodations */
  2822.         /* menu */
  2823.         $menus $em->getRepository(SupplierMenu::class)->findBySupplierId($id);
  2824.         /* menu Description*/
  2825.         $data_menu = array();
  2826.         foreach($menus as $menu){
  2827.             /* Consulta en Control Description */
  2828.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2829.                 'servicesId' => $menu->getId(),
  2830.                 'servicesCat' => $menu->getControlCat()
  2831.             ));
  2832. //            $controlctrlDes->getId();
  2833. //            $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2834.             $data_menu[] = array(
  2835.                 'id' => $menu->getId(),
  2836.                 'title' => $menu->getTitle(),
  2837.                 'description' => $menu->getDescription(),
  2838.                 'currency' => $menu->getCurrency(),
  2839.                 'price' => $menu->getPrice(),
  2840.                 'commission' => $menu->getCommission(),
  2841.                 'iva' => $menu->getIva(),
  2842.                 'controlId' => $controlctrlDes->getId()
  2843.             );
  2844.         }
  2845.         /* lounge */
  2846.         $lounges $em->getRepository(SupplierLounge::class)->findBySupplierId($id);
  2847.         /* lounge Description*/
  2848.         $data_lounge = array();
  2849.         foreach($lounges as $lounge){
  2850.             /* Consulta en Control Description */
  2851.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2852.                 'servicesId' => $lounge->getId(),
  2853.                 'servicesCat' => $lounge->getControlCat()
  2854.             ));
  2855. //            $controlctrlDes->getId();
  2856. //            $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2857.             $data_lounge[] = array(
  2858.                 'id' => $lounge->getId(),
  2859.                 'name' => $lounge->getName(),
  2860.                 'currency' => $lounge->getCurrency(),
  2861.                 'price' => $lounge->getPrice(),
  2862.                 'commission' => $lounge->getCommission(),
  2863.                 'iva' => $lounge->getIva(),
  2864.                 'controlId' => $controlctrlDes->getId()
  2865.             );
  2866.         }
  2867.         /* Transport */
  2868.         $transports $em->getRepository(SupplierTransport::class)->findBySupplierId($id);
  2869.         /* Transport Description*/
  2870.         $data_transport = array();
  2871.         foreach($transports as $transport){
  2872.             /* Consulta en Control Description */
  2873.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2874.                 'servicesId' => $transport->getId(),
  2875.                 'servicesCat' => $transport->getControlCat()
  2876.             ));
  2877. //            $controlctrlDes->getId();
  2878. //            $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2879.             $data_transport[] = array(
  2880.                 'id' => $transport->getId(),
  2881.                 'name' => $transport->getName(),
  2882.                 'driver' => $transport->getDriver(),
  2883.                 'currency' => $transport->getCurrency(),
  2884.                 'price' => $transport->getPrice(),
  2885.                 'commission' => $transport->getCommission(),
  2886.                 'iva' => $transport->getIva(),
  2887.                 'controlId' => $controlctrlDes->getId()
  2888.             );
  2889.         }
  2890.         /* Guide */
  2891.         $guides $em->getRepository(SupplierGuide::class)->findBySupplierId($id);
  2892.         /* Guide Description*/
  2893.         $data_guide = array();
  2894.         foreach($guides as $guide){
  2895.             /* Consulta en Control Description */
  2896.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2897.                 'servicesId' => $guide->getId(),
  2898.                 'servicesCat' => $guide->getControlCat()
  2899.             ));
  2900. //            $controlctrlDes->getId();
  2901. //            $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2902.             $data_guide[] = array(
  2903.                 'id' => $guide->getId(),
  2904.                 'name' => $guide->getName(),
  2905.                 'guide' => $guide->getGuide(),
  2906.                 'currency' => $guide->getCurrency(),
  2907.                 'price' => $guide->getPrice(),
  2908.                 'commission' => $guide->getCommission(),
  2909.                 'iva' => $guide->getIva(),
  2910.                 'controlId' => $controlctrlDes->getId()
  2911.             );
  2912.         }
  2913.         /* Itineraries */
  2914.         $itinerariess $em->getRepository(SupplierItineraries::class)->findBySupplierId($id);
  2915.         /* Itineraries Description*/
  2916.         $data_itineraries = array();
  2917.         foreach($itinerariess as $itineraries){
  2918.             /* Consulta en Control Description */
  2919.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2920.                 'servicesId' => $itineraries->getId(),
  2921.                 'servicesCat' => $itineraries->getControlCat()
  2922.             ));
  2923.             //$controlctrlDes->getId();
  2924.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2925.             $data_itineraries[] = array(
  2926.                 'id' => $itineraries->getId(),
  2927.                 'title' => $itineraries->getTitle(),
  2928.                 'controlId' => $controlctrlDes->getId(),
  2929.                 'description' => $description
  2930.             );
  2931.         }
  2932.         /* activities */
  2933.         $activitiess $em->getRepository(SupplierActivities::class)->findBySupplierId($id);
  2934.         /* activities Description*/
  2935.         $data_activities = array();
  2936.         foreach($activitiess as $activities){
  2937.             /* Consulta en Control Description */
  2938.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2939.                 'servicesId' => $activities->getId(),
  2940.                 'servicesCat' => $activities->getControlCat()
  2941.             ));
  2942.             //$controlctrlDes->getId();
  2943.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2944.             $data_activities[] = array(
  2945.                 'id' => $activities->getId(),
  2946.                 'title' => $activities->getTitle(),
  2947.                 'capacity' => $activities->getCapacity(),
  2948.                 'currency' => $activities->getCurrency(),
  2949.                 'price' => $activities->getPrice(),
  2950.                 'commission' => $activities->getCommission(),
  2951.                 'iva' => $activities->getIva(),
  2952.                 'controlId' => $controlctrlDes->getId(),
  2953.                 'description' => $description
  2954.             );
  2955.         }
  2956.         /* cruise */
  2957.         $cruises $em->getRepository(SupplierCruise::class)->findBySupplierId($id);
  2958.         /* cruise Description*/
  2959.         $data_cruise = array();
  2960.         foreach($cruises as $cruise){
  2961.             /* Consulta en Control Description */
  2962.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  2963.                 'servicesId' => $cruise->getId(),
  2964.                 'servicesCat' => $cruise->getControlCat()
  2965.             ));
  2966.             //$controlctrlDes->getId();
  2967.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  2968.             $data_cruise[] = array(
  2969.                 'id' => $cruise->getId(),
  2970.                 'title' => $cruise->getTitle(),
  2971.                 'currency' => $cruise->getCurrency(),
  2972.                 'price' => $cruise->getPrice(),
  2973.                 'commission' => $cruise->getCommission(),
  2974.                 'iva' => $cruise->getIva(),
  2975.                 'controlId' => $controlctrlDes->getId(),
  2976.                 'description' => $description
  2977.             );
  2978.         }
  2979.         /* Av */
  2980.         if ($idsupplier == 80){
  2981.             // El proveedor del AV es AvExpress
  2982.             // Listamos por orden alfabetico y se deja de primero a "Otro servicio"
  2983.             $parameters = array();
  2984.             $dql 'SELECT i
  2985.                         FROM AvexpressBundle:AveProduct i
  2986.                         ORDER BY i.name ASC';
  2987.             $query $em->createQuery($dql)->setParameters($parameters);
  2988.             $avs $query->getResult();
  2989.             $newAvs = array();
  2990.             foreach ($avs as $key => $item) {
  2991.                 if ($item->getName() == 'Otro servicio'){
  2992.                     $item->setName('0 - Otro servicio');
  2993.                     $newAvs = array($item);
  2994.                     unset($avs[$key]);
  2995.                     foreach ($avs as $keyTwo => $elem){
  2996.                         $ind $keyTwo 1;
  2997.                         $elem->setName($ind.' - '.$elem->getName());
  2998.                         array_push($newAvs,$elem);
  2999.                     }
  3000.                 }
  3001.             }
  3002.             $avs $newAvs;
  3003.             /* av Description*/
  3004.             $data_av = array();
  3005.             foreach($avs as $av){
  3006.                 $data_av[] = array(
  3007.                     'id' => $av->getId(),
  3008.                     'name' => $av->getName(),
  3009. //                    'modules' => $technology->getModules(),
  3010.                     'modules' => null,
  3011.                     'type' => $av->getType(),
  3012.                     'currency' => 'Euro',
  3013.                     'price' => $av->getPrice(),
  3014.                     'commission' => 0,
  3015.                     'iva' => 21,
  3016.                     'controlId' => null,
  3017.                     'description' => $av->getDescription(),
  3018.                     'supplier' => 'AvExpress',
  3019.                 );
  3020.             }
  3021.             //   ***************************************** METEMOS AV TEMPLATES (Tipo: AVExpress Template)
  3022.             $parameters = array();
  3023.             $dql 'SELECT i
  3024.                         FROM AvexpressBundle:AveTemplate i
  3025.                         ORDER BY i.name ASC';
  3026.             $query $em->createQuery($dql)->setParameters($parameters);
  3027.             $avsTemplate $query->getResult();
  3028.             foreach($avsTemplate as $av){
  3029.                 $data_av[] = array(
  3030.                     'id' => $av->getId(),
  3031.                     'name' => $av->getName(),
  3032.                     'modules' => null,
  3033.                     'type' => 'AVExpress Template',
  3034.                     'currency' => null,
  3035.                     'price' => null,
  3036.                     'commission' => null,
  3037.                     'iva' => null,
  3038.                     'controlId' => null,
  3039.                     'description' => null,
  3040.                     'supplier' => 'AvExpress',
  3041.                 );
  3042.             }
  3043.         } else {
  3044.             $newAvs = array();
  3045.             $avs $em->getRepository(SupplierAv::class)->findBySupplierId($id);
  3046.             /* Av Description*/
  3047.             $data_av = array();
  3048.             foreach($avs as $av){
  3049.                 /* Consulta en Control Description */
  3050.                 $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  3051.                     'servicesId' => $av->getId(),
  3052.                     'servicesCat' => $av->getControlCat()
  3053.                 ));
  3054.                 //$controlctrlDes->getId();
  3055.                 $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  3056.                 $data_av[] = array(
  3057.                     'id' => $av->getId(),
  3058.                     'name' => $av->getName(),
  3059.                     'responsible' => $av->getResponsible(),
  3060.                     'currency' => $av->getCurrency(),
  3061.                     'price' => $av->getPrice(),
  3062.                     'commission' => $av->getCommission(),
  3063.                     'iva' => $av->getIva(),
  3064.                     'controlId' => $controlctrlDes->getId(),
  3065.                     'description' => $description
  3066.                 );
  3067.             }
  3068.         }
  3069.         /* Creative */
  3070.         $creatives $em->getRepository(SupplierCreative::class)->findBySupplierId($id);
  3071.         /* Creative Description*/
  3072.         $data_creative = array();
  3073.         foreach($creatives as $creative){
  3074.             /* Consulta en Control Description */
  3075.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  3076.                 'servicesId' => $creative->getId(),
  3077.                 'servicesCat' => $creative->getControlCat()
  3078.             ));
  3079.             //$controlctrlDes->getId();
  3080.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  3081.             $data_creative[] = array(
  3082.                 'id' => $creative->getId(),
  3083.                 'title' => $creative->getTitle(),
  3084.                 'controlId' => $controlctrlDes->getId(),
  3085.                 'description' => $description
  3086.             );
  3087.         }
  3088.         /* Gifts */
  3089.         $gifts $em->getRepository(SupplierGifts::class)->findBySupplierId($id);
  3090.         /* Gifts Description*/
  3091.         $data_gifts = array();
  3092.         foreach($gifts as $gift){
  3093.             /* Consulta en Control Description */
  3094.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  3095.                 'servicesId' => $gift->getId(),
  3096.                 'servicesCat' => $gift->getControlCat()
  3097.             ));
  3098.             //$controlctrlDes->getId();
  3099.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  3100.             $data_gifts[] = array(
  3101.                 'id' => $gift->getId(),
  3102.                 'name' => $gift->getName(),
  3103.                 'responsible' => $gift->getResponsible(),
  3104.                 'currency' => $gift->getCurrency(),
  3105.                 'price' => $gift->getPrice(),
  3106.                 'commission' => $gift->getCommission(),
  3107.                 'iva' => $gift->getIva(),
  3108.                 'controlId' => $controlctrlDes->getId(),
  3109.                 'description' => $description
  3110.             );
  3111.         }
  3112.         /* Entertainment */
  3113.         $entertainments $em->getRepository(SupplierEntertainment::class)->findBySupplierId($id);
  3114.         /* Entertainment Description*/
  3115.         $data_entertainment = array();
  3116.         foreach($entertainments as $entertainment){
  3117.             /* Consulta en Control Description */
  3118.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  3119.                 'servicesId' => $entertainment->getId(),
  3120.                 'servicesCat' => $entertainment->getControlCat()
  3121.             ));
  3122.             //$controlctrlDes->getId();
  3123.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  3124.             $data_entertainment[] = array(
  3125.                 'id' => $entertainment->getId(),
  3126.                 'name' => $entertainment->getName(),
  3127.                 'responsible' => $entertainment->getResponsible(),
  3128.                 'currency' => $entertainment->getCurrency(),
  3129.                 'price' => $entertainment->getPrice(),
  3130.                 'commission' => $entertainment->getCommission(),
  3131.                 'iva' => $entertainment->getIva(),
  3132.                 'controlId' => $controlctrlDes->getId(),
  3133.                 'description' => $description
  3134.             );
  3135.         }
  3136.         /* Others */
  3137.         $otherss $em->getRepository(SupplierOthers::class)->findBySupplierId($id);
  3138.         /* Others Description*/
  3139.         $data_others = array();
  3140.         foreach($otherss as $others){
  3141.             /* Consulta en Control Description */
  3142.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  3143.                 'servicesId' => $others->getId(),
  3144.                 'servicesCat' => $others->getControlCat()
  3145.             ));
  3146.             //$controlctrlDes->getId();
  3147.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  3148.             $data_others[] = array(
  3149.                 'id' => $others->getId(),
  3150.                 'name' => $others->getName(),
  3151.                 'responsible' => $others->getResponsible(),
  3152.                 'currency' => $others->getCurrency(),
  3153.                 'price' => $others->getPrice(),
  3154.                 'commission' => $others->getCommission(),
  3155.                 'iva' => $others->getIva(),
  3156.                 'controlId' => $controlctrlDes->getId(),
  3157.                 'description' => $description
  3158.             );
  3159.         }
  3160.         /* technology */
  3161.         if ($idsupplier == 2){          // Es una tecnologia de Develup
  3162. //            $technologys = $em->getRepository(MdvProduct::class)->findAll();
  3163.             // Listamos por orden alfabetico y se deja de primero a "Otro servicio"
  3164.             $parameters = array();
  3165.             $dql 'SELECT i
  3166.                         FROM DevelupBundle:MdvProduct i
  3167.                         ORDER BY i.name ASC';
  3168.             $query $em->createQuery($dql)->setParameters($parameters);
  3169.             $technologys $query->getResult();
  3170.             $newTechnologys = array();
  3171.             foreach ($technologys as $key => $item) {
  3172.                 if ($item->getName() == 'Otro servicio'){
  3173.                     $item->setName('0 - Otro servicio');
  3174.                     $newTechnologys = array($item);
  3175.                     unset($technologys[$key]);
  3176.                     foreach ($technologys as $keyTwo => $elem){
  3177.                         $ind $keyTwo 1;
  3178.                         $elem->setName($ind.' - '.$elem->getName());
  3179.                         array_push($newTechnologys,$elem);
  3180.                     }
  3181.                 }
  3182.             }
  3183.             $technologys $newTechnologys;
  3184.             /* technology Description*/
  3185.             $data_technology = array();
  3186.             foreach($technologys as $technology){
  3187.                 $data_technology[] = array(
  3188.                     'id' => $technology->getId(),
  3189.                     'title' => $technology->getName(),
  3190. //                    'modules' => $technology->getModules(),
  3191.                     'modules' => null,
  3192.                     'type' => $technology->getType(),
  3193.                     'currency' => 'Euro',
  3194.                     'price' => $technology->getPrice(),
  3195.                     'commission' => 0,
  3196.                     'iva' => 21,
  3197.                     'controlId' => null,
  3198.                     'description' => $technology->getDescription(),
  3199.                     'supplier' => 'Develup',
  3200.                 );
  3201.             }
  3202.         } else {
  3203.             $technologys $em->getRepository(SupplierTechnology::class)->findBySupplierId($id);
  3204.             $newTechnologys = array();
  3205.             /* technology Description*/
  3206.             $data_technology = array();
  3207.             foreach($technologys as $technology){
  3208.                 /* Consulta en Control Description */
  3209.                 $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  3210.                     'servicesId' => $technology->getId(),
  3211.                     'servicesCat' => $technology->getControlCat()
  3212.                 ));
  3213.                 //$controlctrlDes->getId();
  3214.                 $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  3215.                 $data_technology[] = array(
  3216.                     'id' => $technology->getId(),
  3217.                     'title' => $technology->getTitle(),
  3218.                     'modules' => $technology->getModules(),
  3219.                     'type' => $technology->getType(),
  3220.                     'currency' => $technology->getCurrency(),
  3221.                     'price' => $technology->getPrice(),
  3222.                     'commission' => $technology->getCommission(),
  3223.                     'iva' => $technology->getIva(),
  3224.                     'controlId' => $controlctrlDes->getId(),
  3225.                     'description' => $description
  3226.                 );
  3227.             }
  3228.         }
  3229.         /* Assistant  */
  3230.         $assistants $em->getRepository(SupplierServicesAssistant::class)->findBySupplierId($id);
  3231.         /* Assistant  Description*/
  3232.         $data_assistant = array();
  3233.         foreach($assistants as $assistant){
  3234.             /* Consulta en Control Description */
  3235.             $controlctrlDes $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
  3236.                 'servicesId' => $assistant->getId(),
  3237.                 'servicesCat' => $assistant->getControlCat()
  3238.             ));
  3239.             //$controlctrlDes->getId();
  3240.             $description $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
  3241.             $data_assistant[] = array(
  3242.                 'id' => $assistant->getId(),
  3243.                 'name' => $assistant->getName(),
  3244.                 'quantity' => $assistant->getQuantity(),
  3245.                 'currency' => $assistant->getCurrency(),
  3246.                 'price' => $assistant->getPrice(),
  3247.                 'commission' => $assistant->getCommission(),
  3248.                 'iva' => $assistant->getIva(),
  3249.                 'controlId' => $controlctrlDes->getId(),
  3250.                 'description' => $description
  3251.             );
  3252.         }
  3253.         /* salida de data */
  3254.         return $this->render('MDS/EventsBundle/services/services-supplier-esp-proposal.html.twig', array(
  3255.             'cdid' => $cdid,
  3256.             'id' => $proposal->getId(),
  3257.             'proname' => $proposal->getName(),
  3258.             'token' => $proposal->getAccessKey(),
  3259.             'mcp' => $proposal->getMcp(),
  3260.             'proposal' => $proposal,
  3261.             'idcontrol' => $idcontrol,
  3262.             'accommodations' => $data_accommodation,
  3263.             'menus' => $data_menu,
  3264.             'lounges' => $data_lounge,
  3265.             'transports' => $data_transport,
  3266.             'guides' => $data_guide,
  3267.             'itineraries' => $data_itineraries,
  3268.             'activities' => $data_activities,
  3269.             'cruises' => $data_cruise,
  3270.             'avs' => $data_av,
  3271.             'creatives' => $data_creative,
  3272.             'gifts' => $data_gifts,
  3273.             'entertainments' => $data_entertainment,
  3274.             'technology' => $data_technology,
  3275.             'newTechnologys' => $newTechnologys,
  3276.             'newAvs' => $newAvs,
  3277.             'assistants' => $data_assistant,
  3278.             'otherss' => $data_others
  3279.         ));
  3280.     }
  3281.     /* CREAR DESDE Discount */
  3282.     private function createDiscountCreateForm(ProposalDiscount $entity)
  3283.     {
  3284.         $form $this->createForm(ProposalDiscountType::class, $entity, array(
  3285.             'action' => $this->generateUrl('proposal_discount_create'),
  3286.             'method' => 'POST'
  3287.         ));
  3288.         return $form;
  3289.     }
  3290.     /**
  3291.      * @Route("/proposal/discount/create",  name="proposal_discount_create")
  3292.      */
  3293.     public function createDiscountAction(Request $request)
  3294.     {
  3295.         $controlid $request->request->get('control')['id'];
  3296.         $em $this->getDoctrine()->getManager();
  3297.         $discount = new ProposalDiscount();
  3298.         $form $this->createDiscountCreateForm($discount);
  3299.         $form->handleRequest($request);
  3300.         $serviceId $form->get('serviceId')->getData();
  3301.         if(!is_null($serviceId)){
  3302.             $discount->setServiceId($serviceId->getId());
  3303.         }else{
  3304.             $discount->setServiceId(null);
  3305.         }
  3306.         if($form->isValid())
  3307.         {
  3308.             /* Obtengo usuario logueado */
  3309.             $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  3310.             $user_id $user_logueado->getId();
  3311.             $discount->setCreatedId($user_id);
  3312.             $discount->setUpdatedId($user_id);
  3313.             $em->persist($discount);
  3314.             $em->flush();
  3315.         }
  3316.         return $this->redirectToRoute('proposal_destination_supplier_view',
  3317.             array(
  3318.                 'id' => $controlid,
  3319.                 '_fragment' => 'd1'
  3320.             )
  3321.         );
  3322.     }
  3323.     /**
  3324.      * @Route("/proposal/discount/delete/{controlid}/{id}",  name="proposal_discount_delete")
  3325.      */
  3326.     public function deleteDiscountAction($controlid$idRequest $request)
  3327.     {
  3328.         $em $this->getDoctrine()->getManager();
  3329.         $delete$em->getRepository(ProposalDiscount::class)->findOneById($id);
  3330.         $em->remove($delete);
  3331.         $em->flush();
  3332.         return $this->redirectToRoute('proposal_destination_supplier_view',
  3333.             array(
  3334.                 'id' => $controlid
  3335.             )
  3336.         );
  3337.     }
  3338.     /**
  3339.      * @Route("/proposal/fee/create",  name="proposal_fee_create")
  3340.      */
  3341.     public function createFeeAction(Request $request){
  3342.         $controlid $request->request->get('control')['id'];
  3343.         /* Obtengo usuario logueado */
  3344.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  3345.         $user_id $user_logueado->getId();
  3346.         $em $this->getDoctrine()->getManager();
  3347.         $proposalId $request->request->get('proposal_id');
  3348.         $proposal $em->getRepository(Proposal::class)->findOneById($proposalId);
  3349.         $oldFee $em->getRepository(ProposalFee::class)->findOneByProposalId($proposalId);
  3350.         if (!empty($oldFee)){
  3351.             if ($oldFee->getToInvoice() == 0){
  3352.                 // Habia un Fee que se cargo en los servicios
  3353.                 $this->eliminarFeeOculto($oldFee->getId());
  3354.             }
  3355.             $oldFee->setName($request->request->get('nameFee'));
  3356.             $oldFee->setType($request->request->get('typeFee'));
  3357.             $oldFee->setAmount($request->request->get('amountFee'));
  3358.             $oldFee->setToInvoice($request->request->get('toInvoiceFee'));
  3359.             $oldFee->setUpdatedId($user_id);
  3360.             $oldFee->setUpdatedAt(new \DateTime("now"));
  3361.             if ($proposal->getStatus() != 'Invoiced') {
  3362.                 $em->persist($oldFee);
  3363.                 $em->flush();
  3364.                 if(!$oldFee->getToInvoice()){
  3365.                     // Es un Fee oculto se deben modificar los servicios
  3366.                     $this->agregarFeeOculto($oldFee->getId());
  3367.                 }
  3368.             }
  3369.         } else {
  3370.             $newFee = new ProposalFee();
  3371.             $newFee->setProposalId($proposalId);
  3372.             $newFee->setName($request->request->get('nameFee'));
  3373.             $newFee->setType($request->request->get('typeFee'));
  3374.             $newFee->setAmount($request->request->get('amountFee'));
  3375.             $newFee->setToInvoice($request->request->get('toInvoiceFee'));
  3376.             $newFee->setOpIva('1');
  3377.             $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
  3378.             if ($request->request->get('typeFee') == 0){ $newFee->setFeeTotal(0); } else { $newFee->setFeeTotal($request->request->get('amountFee') * 1.21); }
  3379.             $newFee->setCreatedId($user_id);
  3380.             $newFee->setUpdatedId($user_id);
  3381.             $newFee->setCreatedAt(new \DateTime("now"));
  3382.             $newFee->setUpdatedAt(new \DateTime("now"));
  3383.             // Solo se creará el Fee si no se ha facturado
  3384.             if ($proposal->getStatus() != 'Invoiced') {
  3385.                 $em->persist($newFee);
  3386.                 $em->flush();
  3387.                 if(!$newFee->getToInvoice()){
  3388.                     // Es un Fee oculto se deben modificar los servicios
  3389.                     $this->agregarFeeOculto($newFee->getId());
  3390.                 }
  3391.             }
  3392.         }
  3393.         return $this->redirectToRoute('proposal_destination_supplier_view',
  3394.             array(
  3395.                 'id' => $controlid,
  3396.                 '_fragment' => 'f1'
  3397.             )
  3398.         );
  3399.     }
  3400.     /**
  3401.      * @Route("/proposal/fee/delete/{controlid}/{id}",  name="proposal_fee_delete")
  3402.      */
  3403.     public function deleteFeeAction($controlid$idRequest $request)
  3404.     {
  3405.         $em $this->getDoctrine()->getManager();
  3406.         $fee $em->getRepository(ProposalFee::class)->findOneById($id);
  3407.         if (!empty($fee)){
  3408.             $proposal $em->getRepository(Proposal::class)->findOneById($fee->getProposalId());
  3409.             if ($fee->getToInvoice() == 0){
  3410.                 // Habia un Fee que se cargo en los servicios
  3411.                 $this->eliminarFeeOculto($fee->getId());
  3412.             }
  3413.             if ($proposal->getStatus() != 'Invoiced') {
  3414.                 $em->remove($fee);
  3415.                 $em->flush();
  3416.             }
  3417.         }
  3418.         return $this->redirectToRoute('proposal_destination_supplier_view',
  3419.             array(
  3420.                 'id' => $controlid,
  3421.                 '_fragment' => 'f1'
  3422.             )
  3423.         );
  3424.     }
  3425.     private function agregarFeeOculto$idFee )
  3426.     {
  3427.         // Se agregara un fee en los servicios
  3428.         $em $this->getDoctrine()->getManager();
  3429.         $fee $em->getRepository(ProposalFee::class)->findOneById($idFee);
  3430.         $prpSupServices $em->getRepository(ProposalSupplierServices::class)->findByProposalId($fee->getProposalId());
  3431.         foreach ($prpSupServices as $service){
  3432.             if ($fee->getType() == 0){
  3433.                 // Fee de %
  3434.                 if ($service->getOpCommission() == 1){
  3435.                     // La Comision es positiva
  3436.                     $comision $fee->getAmount() + $service->getCommission();
  3437.                     $service->setCommission($comision);
  3438.                 } else {
  3439.                     // La Comision es negativa, no se puede alterar la comision por ende el porcentaje se calculará y añadirá en el over
  3440.                     $comision $service->getPrice() * ( $fee->getAmount() / 100 );
  3441.                     $comision $comision $service->getOver();
  3442.                     $service->setOver($comision);
  3443.                 }
  3444.                 $em->persist($service);
  3445.                 $em->flush();
  3446.                 // Si es un servicio ya confirmado debemos modificar tambien ProposalSupplierServicesCost y en ProposalSupplierServicesCostClient
  3447.                 $prpSupSrvCosts $em->getRepository(ProposalSupplierServicesCosts::class)->findOneByServicesId($service->getId());
  3448.                 if (!empty($prpSupSrvCosts)){
  3449.                     $prpSupSrvCosts->setCommission($service->getCommission());
  3450.                     $em->persist($prpSupSrvCosts);
  3451.                     $em->flush();
  3452.                 }
  3453.                 $prpSupSrvCostsClient $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($service->getId());
  3454.                 if (!empty($prpSupSrvCostsClient)){
  3455.                     $prpSupSrvCostsClient->setCommission($service->getCommission());
  3456.                     $prpSupSrvCostsClient->setOver($service->getOver());
  3457.                     $em->persist($prpSupSrvCostsClient);
  3458.                     $em->flush();
  3459.                 }
  3460.             } else {
  3461.                 // Fee de â‚¬
  3462.                 if ($service->getOpOver() == 1){
  3463.                     // El Over es positivo
  3464.                     $over $fee->getAmount() + $service->getOver();
  3465.                     $service->setOver($over);
  3466.                 } else {
  3467.                     // El Over es negativo,
  3468.                     if ($service->getOver() > $fee->getAmount()){
  3469.                         // Se mantendra el signo negativo del over. La cantidad de over negativo es superior al fee que agregamos
  3470.                         $service->setOver($service->getOver() - $fee->getAmount());
  3471.                     } else {
  3472.                         // Se cambiara el signo del over. La cantidad de over negativo es inferior o igual all fee que agregamos
  3473.                         $service->setOver($fee->getAmount() - $service->getOver());
  3474.                         $service->setOpOver(1);
  3475.                     }
  3476.                 }
  3477.                 $em->persist($service);
  3478.                 $em->flush();
  3479.                 // Si es un servicio ya confirmado debemos modificar tambien ProposalSupplierServicesCostClient (NO APLICA EN ProposalSupplierServicesCost)
  3480.                 $prpSupSrvCostsClient $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($service->getId());
  3481.                 if (!empty($prpSupSrvCostsClient)){
  3482.                     $prpSupSrvCostsClient->setOver($service->getOver());
  3483.                     $em->persist($prpSupSrvCostsClient);
  3484.                     $em->flush();
  3485.                 }
  3486.             }
  3487.         }
  3488.         return true;
  3489.     }
  3490.     private function eliminarFeeOculto$idFee )
  3491.     {
  3492.         // No se eliminara el Fee, solo se quitara el monto de los servicios
  3493.         $em $this->getDoctrine()->getManager();
  3494.         $fee $em->getRepository(ProposalFee::class)->findOneById($idFee);
  3495.         $prpSupServices $em->getRepository(ProposalSupplierServices::class)->findByProposalId($fee->getProposalId());
  3496.         foreach ($prpSupServices as $service){
  3497.             if ($fee->getType() == 0){
  3498.                 // Fee de %
  3499.                 if ($service->getOpCommission() == 1){
  3500.                     // La Comision es positiva
  3501.                     $comision abs($service->getCommission() - $fee->getAmount());
  3502.                     $service->setCommission($comision);
  3503.                 } else {
  3504.                     // La Comision es negativa, no se puede alterar la comision
  3505.                 }
  3506.                 $em->persist($service);
  3507.                 $em->flush();
  3508.                 // Si es un servicio ya confirmado debemos modificar tambien ProposalSupplierServicesCost y en ProposalSupplierServicesCostClient
  3509.                 $prpSupSrvCosts $em->getRepository(ProposalSupplierServicesCosts::class)->findOneByServicesId($service->getId());
  3510.                 if (!empty($prpSupSrvCosts)){
  3511.                     $prpSupSrvCosts->setCommission($service->getCommission());
  3512.                     $em->persist($prpSupSrvCosts);
  3513.                     $em->flush();
  3514.                 }
  3515.                 $prpSupSrvCostsClient $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($service->getId());
  3516.                 if (!empty($prpSupSrvCostsClient)){
  3517.                     $prpSupSrvCostsClient->setCommission($service->getCommission());
  3518.                     $prpSupSrvCostsClient->setOver($service->getOver());
  3519.                     $em->persist($prpSupSrvCostsClient);
  3520.                     $em->flush();
  3521.                 }
  3522.             } else {
  3523.                 // Fee de â‚¬
  3524.                 if ($service->getOpOver() == 1){
  3525.                     // El Over es positivo
  3526.                     $over abs($service->getOver() - $fee->getAmount());
  3527.                     $service->setOver($over);
  3528.                 } else {
  3529.                     // El Over es negativo,
  3530.                     if ($service->getOver() > $fee->getAmount()){
  3531.                     } else {
  3532.                     }
  3533.                 }
  3534.                 $em->persist($service);
  3535.                 $em->flush();
  3536.                 // Si es un servicio ya confirmado debemos modificar tambien ProposalSupplierServicesCostClient (NO APLICA EN ProposalSupplierServicesCost)
  3537.                 $prpSupSrvCostsClient $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($service->getId());
  3538.                 if (!empty($prpSupSrvCostsClient)){
  3539.                     $prpSupSrvCostsClient->setOver($service->getOver());
  3540.                     $em->persist($prpSupSrvCostsClient);
  3541.                     $em->flush();
  3542.                 }
  3543.             }
  3544.         }
  3545.         return true;
  3546.     }
  3547.     /**
  3548.      * @Route("/proposal/summary/create",  name="proposal_summary_create")
  3549.      */
  3550.     public function createSummaryAction(Request $request){
  3551.         $controlid $request->request->get('control')['id'];
  3552.         $em $this->getDoctrine()->getManager();
  3553.         $proposalId $request->request->get('proposal_id');
  3554.         $proposal $em->getRepository(Proposal::class)->findOneById($proposalId);
  3555.         $oldSummary $em->getRepository(ProposalsInvoiceSummary::class)->findOneByProposalId($proposalId);
  3556.         $newSummary $request->request->get('descriptionSummary');
  3557.         if (!empty($oldSummary)){
  3558.             if (!empty($newSummary) and ($proposal->getStatus() != 'Invoiced')){
  3559.                 $oldSummary->setDescription($newSummary);
  3560.                 $em->persist($oldSummary);
  3561.                 $em->flush();
  3562.             } else {
  3563.                 if (empty($newSummary) and ($proposal->getStatus() != 'Invoiced')){
  3564.                     // Si viene vacío se elimina el resumen para obetener una factura completa
  3565.                     $em->remove($oldSummary);
  3566.                     $em->flush();
  3567.                 }
  3568.             }
  3569.         } else {
  3570.             $newSumm = new ProposalsInvoiceSummary();
  3571.             $newSumm->setDescription($newSummary);
  3572.             $newSumm->setProposalId($proposalId);
  3573.             $newSumm->setNet(null);
  3574.             $newSumm->setCurrency(null);
  3575.             $newSumm->setVatTen(null);
  3576.             $newSumm->setVatTwentyOne(null);
  3577.             $newSumm->setPayments(null);
  3578.             // Solo se creará el Summary si no se ha facturado
  3579.             if (($proposal->getStatus() != 'Invoiced') and !empty($newSummary)) {
  3580.                 $em->persist($newSumm);
  3581.                 $em->flush();
  3582.             }
  3583.         }
  3584.         return $this->redirectToRoute('proposal_destination_supplier_view',
  3585.             array(
  3586.                 'id' => $controlid,
  3587.                 '_fragment' => 'summary1'
  3588.             )
  3589.         );
  3590.     }
  3591.     /**
  3592.      * @Route("proposal/destination/services/block/{id}", name="proposal_destination_supplier_services_block")
  3593.      */
  3594.     public function udatedBlockAction($idRequest $request)
  3595.     {
  3596.         $block $request->request->get('block');
  3597.         $em $this->getDoctrine()->getManager();
  3598.         $services_control $em->getRepository(ProposalSupplierControl::class)->findOneById($id);
  3599.         if (!empty($block['dateBlockLimit']) and !empty($block['timeBlockLimit'])){
  3600.             $services_control->setDateBlockLimit(new \DateTime($block['dateBlockLimit'].' '.$block['timeBlockLimit'] ));
  3601.             $services_supplier_proposal $em->getRepository(ProposalSupplierServices::class)->findByControlId($services_control->getId());
  3602.             foreach($services_supplier_proposal as $servicessupplierproposal) {
  3603.                 $servicessupplierproposal->setDateBlockLimit(new \DateTime($block['dateBlockLimit'] . ' ' $block['timeBlockLimit']));
  3604.                 $servicessupplierproposal->setStatus('Block');
  3605.                 $em->persist($servicessupplierproposal);
  3606.                 $em->flush();
  3607.             }
  3608.             $em->persist($services_control);
  3609.             $em->flush();
  3610.             $event 'The Block supplier updated in Destination Proposal.';
  3611.             $successMessage $this->translator->trans($event);
  3612.             $this->addFlash('mensajeproposaldestinationservices'$successMessage);
  3613.         }else{
  3614.             $errorMessage $this->translator->trans('Error');
  3615.             $this->addFlash('mensajeproposaldestinationservicesrror'$errorMessage);
  3616.         }
  3617.         return $this->redirectToRoute('proposal_destination_supplier_view',
  3618.             array(
  3619.                 'id' => $services_control->getControlDestinationId(),
  3620.                 '_fragment' => 's'.$id
  3621.             )
  3622.         );
  3623.     }
  3624.     /**
  3625.      * @Route("/multichckservices", name="multichckservices")
  3626.      */
  3627.     public function multiChckServicesAction(Request $request) {
  3628.         $idSupplier $_POST['idSupplier'];
  3629.         $idService $_POST['idService'];
  3630.         /* Obtengo usuario logueado */
  3631.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  3632.         $user_id $user_logueado->getId();
  3633.         $user_role $user_logueado->getRole();
  3634.         $em $this->getDoctrine()->getManager();
  3635.         $services $em->getRepository(ProposalSupplierServices::class)->findOneById($idService);
  3636.         // INICIO: Buscamos el proposal para verificar que no este bloqueado o facturado
  3637.         $propId $services->getProposalId();
  3638.         $proposal $em->getRepository(Proposal::class)->findOneById($propId);
  3639.         // FIN :Buscamos el proposal para verificar que no este bloqueado o facturado
  3640.         if (!empty($services)){
  3641.             if ($services->getStatus()== 'Pending') {
  3642.                 $services->setStatus('Confirmed');
  3643.                 $services->setUpdatedId($user_id);
  3644.             } else {
  3645.                 $services->setStatus('Pending');
  3646.                 $services->setUpdatedId($user_id);
  3647.             }
  3648.             try{
  3649.                 if (!empty($proposal)){
  3650.                     if (($proposal->getStatus() == 'Invoiced') or ($proposal->getStatus() == 'Blocked')) {
  3651.                         // De ser un expediente Facturado o bloqueado no se hace modificacion
  3652.                     } else {
  3653.                         if (empty($services->getSupplierId())){
  3654.                             $services->setSupplierId(4);
  3655.                         }
  3656.                         $em->persist($services);
  3657.                         $em->flush();
  3658.                         /* Para dentro de ProposalSupplierControl */
  3659.                         if (!empty($services->getSupplierId())){
  3660.                             $controlctrlDes $em->getRepository(ProposalSupplierControl::class)->findOneBy( array(
  3661.                                 'supplierId' => $services->getSupplierId(),
  3662.                                 'proposalId' => $services->getProposalId()
  3663.                             ));
  3664.                         } else {
  3665.                             $controlctrlDes $em->getRepository(ProposalSupplierControl::class)->findOneBy( array(
  3666.                                 'supplierId' => 4,
  3667.                                 'proposalId' => $services->getProposalId()
  3668.                             ));
  3669.                         }
  3670. //                         Si el control se encuentra vacio, se debe crear uno nuevo
  3671.                         if (empty($controlctrlDes)){
  3672.                             $controlctrlDes = new ProposalSupplierControl();
  3673.                             $controlctrlDes->setControlDestinationId($services->getDestinationId());  // Falta corregir el ControlDestinationId ahora tiene el Id del destino
  3674.                             $controlctrlDes->setProposalId($services->getProposalId());
  3675.                             $controlctrlDes->setDestinoId($services->getDestinationId());
  3676.                             $controlctrlDes->setSupplierId(4);
  3677.                             $controlctrlDes->setStatus('Pending');
  3678.                             $em->persist($controlctrlDes);
  3679.                             $em->flush();
  3680.                         }
  3681.                         //COLOR POR SERVICIO
  3682.                         $contcolor ="";
  3683.                         switch ($services->getServiceCatName()) {
  3684.                             case "Accommodation":
  3685.                                 $contcolor 'teal';
  3686.                                 break;
  3687.                             case "Menu" :
  3688.                                 $contcolor 'purple';
  3689.                                 break;
  3690.                             case "Lounge":
  3691.                                 $contcolor 'warning';
  3692.                                 break;
  3693.                             case "Activities":
  3694.                                 $contcolor 'blue';
  3695.                                 break;
  3696.                             case "Itineraries":
  3697.                                 $contcolor 'indigo';
  3698.                                 break;
  3699.                             case "Cruise":
  3700.                                 $contcolor 'brown';
  3701.                                 break;
  3702.                             case "Transport":
  3703.                                 $contcolor 'grey';
  3704.                                 break;
  3705.                             case "Av":
  3706.                                 $contcolor 'slate';
  3707.                                 break;
  3708.                             case "Creative":
  3709.                                 $contcolor 'orange';
  3710.                                 break;
  3711.                             case "Gifts":
  3712.                                 $contcolor 'pink';
  3713.                                 break;
  3714.                             case "Entertainment":
  3715.                                 $contcolor 'green';
  3716.                                 break;
  3717.                             case "Guide":
  3718.                                 $contcolor 'orange';
  3719.                                 break;
  3720.                             case "Others":
  3721.                                 $contcolor 'danger';
  3722.                                 break;
  3723.                             case "Technology":
  3724.                                 $contcolor 'slate-800';
  3725.                                 break;
  3726.                             case "Assistant":
  3727.                                 $contcolor 'indigo-800';
  3728.                                 break;
  3729.                             case "DDR":
  3730.                                 $contcolor 'green-300';
  3731.                                 break;
  3732.                         }
  3733.                         /* Para dentro de ProposalSupplierServicesCostsClient */
  3734.                         $costsClient = new ProposalSupplierServicesCostsClient();
  3735.                         $costsClient->setServiceIdProposal($services->getId());
  3736.                         $costsClient->setServiceIdFather($services->getServiceIdFather());
  3737.                         $costsClient->setControlId($controlctrlDes->getId());
  3738. //                        if (empty($services->getSupplierId())){$costsClient->setControlId(14244);} else {$costsClient->setControlId($services->getControlId());}
  3739.                         $costsClient->setProposalId($services->getProposalId());
  3740.                         $costsClient->setDestinationId($services->getDestinationId());
  3741.                         if (empty($services->getSupplierId())){$costsClient->setSupplierId('4');} else {$costsClient->setSupplierId($services->getSupplierId());}
  3742.                         $costsClient->setAssistantId($services->getAssistantId());
  3743.                         $costsClient->setIdeaId($services->getIdeaId());
  3744.                         $costsClient->setActivityId($services->getActivityId());
  3745.                         $costsClient->setServiceId($services->getServiceId());
  3746.                         $costsClient->setServiceCatId($services->getServiceCatId());
  3747.                         $costsClient->setServiceCatName($services->getServiceCatName());
  3748.                         $costsClient->setName($services->getName());
  3749.                         $costsClient->setPrice($services->getPrice());
  3750.                         $costsClient->setCurrency($services->getCurrency());
  3751.                         $costsClient->setUnits($services->getUnits());
  3752.                         $costsClient->setOpCommission($services->getOpCommission());
  3753.                         $costsClient->setCommission($services->getCommission());
  3754.                         $costsClient->setOpOver($services->getOpOver());
  3755.                         $costsClient->setOver($services->getOver());
  3756.                         $costsClient->setOpIva($services->getOpIva());
  3757.                         $costsClient->setIva($services->getIva());
  3758.                         $costsClient->setPax($services->getPax());
  3759.                         $costsClient->setHour($services->getHour());
  3760.                         $costsClient->setDateInAt($services->getDateInAt());
  3761.                         $costsClient->setDateOutAt($services->getDateOutAt());
  3762.                         $costsClient->setRank($services->getRank());
  3763.                         $costsClient->setCreatedId($user_id);
  3764.                         $costsClient->setUpdatedId($user_id);
  3765.                         $costsClient->setContcolor($contcolor);
  3766.                         $costsClient->setRenovate('0');
  3767.                         $em->persist($costsClient);
  3768.                         $em->flush();
  3769.                     }
  3770.                 }
  3771.             } catch (\Exception $e){
  3772.             }
  3773.         }
  3774.         $return = array(
  3775.             'services' => $services,
  3776.         );
  3777.         $response = new JsonResponse($return);
  3778.         return $response;
  3779.     }
  3780.     /**
  3781.      * @Route("proposal/destination/services/listmultiple/{idcontrol}", name="proposal_destination_supplier_list_multiple")
  3782.      */
  3783.     public function listMultipleAction($idcontrolRequest $request) {
  3784.         $em $this->getDoctrine()->getManager();
  3785.         $control $em->getRepository(ProposalSupplierControl::class)->findOneById($idcontrol);
  3786.         $idsupplier $control->getSupplierId();
  3787.         $idMemorySupplier $idsupplier;
  3788.         $ididea $control->getIdeaId();
  3789.         $idactivity $control->getActivityId();
  3790.         if($idsupplier == '0'){
  3791.             $id '0';
  3792.         }else{
  3793.             if(!empty($idsupplier)){
  3794.                 /*CONTROL GENERAL*/
  3795.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneBySupplierId($idsupplier);
  3796.                 $id $controlgeneral->getId();
  3797.             }
  3798.             if(!empty($idactivity)){
  3799.                 /*CONTROL GENERAL*/
  3800.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByActivityId($idactivity);
  3801.                 $id $controlgeneral->getId();
  3802.             }
  3803.             if(!empty($ididea)){
  3804.                 /*CONTROL GENERAL*/
  3805.                 $controlgeneral $em->getRepository(SupplierIdeaServicesControl::class)->findOneByIdeaId($ididea);
  3806.                 $id $controlgeneral->getId();
  3807.             }
  3808.         }
  3809.         if (!empty($control)){
  3810.             $idProposal $control->getProposalId();
  3811.             $proposal $em->getRepository(Proposal::class)->findOneById($idProposal);
  3812.             // Buscamos a partir del IDCONTROL los elementos principales (Proveedores, Actividades, Ideas) agregados al destino para la carga multiple
  3813.             $destinoId $control->getDestinoId();
  3814.             $servicesControllers $em->getRepository(ProposalSupplierControl::class)->findBy(
  3815.                 array(
  3816.                     'proposalId' => $proposal,
  3817.                     'destinoId' => $destinoId
  3818.                 )
  3819.             );
  3820.             //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
  3821.             $tempKey null;
  3822.             $logicKey false;
  3823.             foreach ($servicesControllers as $key => $item) {
  3824.                 if(($item->getSupplierId() == 0) and (empty($item->getActivityId())) and (empty($item->getIdeaId()))){
  3825.                     // Es un white service, se guarda el indice para luego procesar
  3826.                     $tempKey $key;
  3827.                     $logicKey true;
  3828.                 }
  3829.                 if(!empty($item->getSupplierId()) and ($item->getSupplierId() != 0)){
  3830.                     // Es un proveedor ordinario
  3831.                     $tempSup $em->getRepository(Supplier::class)->findOneById($item->getSupplierId());
  3832.                     $servicesControllers[$key]->setStatus($tempSup->getName());
  3833.                 }
  3834.                 if (!empty($item->getActivityId())){
  3835.                     // Es Actividad
  3836.                     $tempAct $em->getRepository(Activities::class)->findOneById($item->getActivityId());
  3837.                     $servicesControllers[$key]->setStatus($tempAct->getName());
  3838.                 }
  3839.                 if (!empty($item->getIdeaId())) {
  3840.                     // Es Idea
  3841.                     $tempIdea $em->getRepository(Ideas::class)->findOneById($item->getIdeaId());
  3842.                     $servicesControllers[$key]->setStatus($tempIdea->getName());
  3843.                 }
  3844.             }
  3845.             if($logicKey){
  3846.                 $servicesControllers[$tempKey]->setStatus('SERVICIO SIN PROVEEDOR');
  3847.                 array_push($servicesControllers,$servicesControllers[$tempKey]);
  3848.                 unset($servicesControllers[$tempKey]);
  3849.             }
  3850.             //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
  3851.         }
  3852. //        LIMPIEZA DE DATOS PARA LA VISTA
  3853.         if (!($idMemorySupplier === 0)){// el === evalua correctamente el caso de nulo
  3854.             $newServicesControllers = array();
  3855.             foreach ($servicesControllers as $item){
  3856.                 if (intval($idcontrol) === $item->getId()){
  3857.                     $newServicesControllers[] = $item;
  3858.                 }
  3859.             }
  3860.             $servicesControllers $newServicesControllers;
  3861.         }
  3862.         if (sizeof($servicesControllers) == 1){
  3863.             $numElementos 10;
  3864.         } else {
  3865.             $numElementos 5;
  3866.         }
  3867.         /* salida de data */
  3868.         return $this->render('MDS/EventsBundle/services/services-multiple-modal-proposal.html.twig', array(
  3869. //        return $this->render('MDS/EventsBundle/services/services-multiple-add-destination-proposal.html.twig', array(
  3870.             'idcontrol' => $idcontrol,
  3871.             'servicesControllers' => $servicesControllers,
  3872.             'id' => $idProposal,
  3873.             'proposal' => $proposal,
  3874.             'numElementos' => $numElementos,
  3875.             'token' => $proposal->getAccessKey(),
  3876.             'mcp' => null,
  3877.             'datasupplier' => null,
  3878.             'discounts' => null,
  3879.             'status' => null,
  3880.             'global_calculos' => null,
  3881.             'accommodations' => '',
  3882.             'menus' => '',
  3883.             'lounges' => '',
  3884.             'transports' => '',
  3885.             'guides' => '',
  3886.             'itineraries' => '',
  3887.             'activities' => '',
  3888.             'cruises' => '',
  3889.             'avs' => '',
  3890.             'creatives' => '',
  3891.             'gifts' => '',
  3892.             'entertainments' => '',
  3893.             'technology' => '',
  3894.             'assistants' => '',
  3895.             'otherss' => ''
  3896.         ));
  3897.     }
  3898.     /**
  3899.      * @Route("proposal/destination/services/createmultiple", name="proposal_destination_supplier_create_multiple")
  3900.      */
  3901.     public function createMultipleAction(Request $request) {
  3902.         $add_services_multiple_type $request->request->get('add_services_multiple_type');
  3903.         $add_services_multiple_name $request->request->get('add_services_multiple_name');
  3904.         $add_services_multiple_price $request->request->get('add_services_multiple_price');
  3905.         $add_services_multiple_commission $request->request->get('add_services_multiple_commission');
  3906.         $add_services_multiple_over $request->request->get('add_services_multiple_over');
  3907.         $add_services_multiple_iva $request->request->get('add_services_multiple_iva');
  3908.         $em $this->getDoctrine()->getManager();
  3909.         /* Obtengo usuario logueado */
  3910.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  3911.         $user_id $user_logueado->getId();
  3912.         // INICIO: Generamos un arreglo con todos los servicios a agregar
  3913.         $newServices = array();
  3914.         foreach ($add_services_multiple_type as $key1 => $item) {
  3915.             foreach ($item as $key2 => $elem){
  3916.                 $newServ = new ProposalSupplierServices();
  3917.                 $newServ->setControlId($key1);
  3918.                 $controlTemp $em->getRepository(ProposalSupplierControl::class)->findOneById($key1);
  3919.                 $proposal_data $em->getRepository(Proposal::class)->findOneById($controlTemp->getProposalId());
  3920.                 switch ($elem['type']) {
  3921.                     case 1:
  3922.                         $newServ->setServiceCatId('1');
  3923.                         $newServ->setServiceCatName('Accommodation');
  3924.                         break;
  3925.                     case 2:
  3926.                         $newServ->setServiceCatId('2');
  3927.                         $newServ->setServiceCatName('Activities');
  3928.                         break;
  3929.                     case 3:
  3930.                         $newServ->setServiceCatId('3');
  3931.                         $newServ->setServiceCatName('Av');
  3932.                         break;
  3933.                     case 4:
  3934.                         $newServ->setServiceCatId('4');
  3935.                         $newServ->setServiceCatName('Creative');
  3936.                         break;
  3937.                     case 5:
  3938.                         $newServ->setServiceCatId('5');
  3939.                         $newServ->setServiceCatName('Cruise');
  3940.                         break;
  3941.                     case 6:
  3942.                         $newServ->setServiceCatId('6');
  3943.                         $newServ->setServiceCatName('Entertainment');
  3944.                         break;
  3945.                     case 7:
  3946.                         $newServ->setServiceCatId('7');
  3947.                         $newServ->setServiceCatName('Gifts');
  3948.                         break;
  3949.                     case 8:
  3950.                         $newServ->setServiceCatId('8');
  3951.                         $newServ->setServiceCatName('Guide');
  3952.                         break;
  3953.                     case 9:
  3954.                         $newServ->setServiceCatId('9');
  3955.                         $newServ->setServiceCatName('Itineraries');
  3956.                         break;
  3957.                     case 10:
  3958.                         $newServ->setServiceCatId('10');
  3959.                         $newServ->setServiceCatName('Lounge');
  3960.                         break;
  3961.                     case 11:
  3962.                         $newServ->setServiceCatId('11');
  3963.                         $newServ->setServiceCatName('Menu');
  3964.                         break;
  3965.                     case 12:
  3966.                         $newServ->setServiceCatId('12');
  3967.                         $newServ->setServiceCatName('Others');
  3968.                         break;
  3969.                     case 13:
  3970.                         $newServ->setServiceCatId('13');
  3971.                         $newServ->setServiceCatName('Transport');
  3972.                         break;
  3973.                     case 14:
  3974.                         $newServ->setServiceCatId('14');
  3975.                         $newServ->setServiceCatName('Technology');
  3976.                         break;
  3977.                     case 15:
  3978.                         $newServ->setServiceCatId('15');
  3979.                         $newServ->setServiceCatName('Assistant');
  3980.                         break;
  3981.                     case 16:
  3982.                         $newServ->setServiceCatId('16');
  3983.                         $newServ->setServiceCatName('DDR');
  3984.                         break;
  3985.                     case 17:
  3986. //                        $newServ->setServiceCatId('17');
  3987. //                        $newServ->setServiceCatName('AV - EXPRESS');
  3988. //                        $newServ->setSupplierId('80');
  3989. //
  3990. //                        $control = new ProposalSupplierControl();
  3991. //                        $control->setSupplierId('80');
  3992. //                        $control->setStatus('Pending');
  3993. //                        $control->setControlDestinationId($cid);
  3994. //                        $control->setProposalId($pid);
  3995. //                        $control->setDestinoId($did);
  3996. //                        $em->persist($control);
  3997. //                        $em->flush();
  3998. //                        $event = 'The Supplier Destination Proposal has been created.';
  3999. //                        $successMessage = $this->translator->trans($event);
  4000. //                        $this->addFlash('mensajeproposaldestinationservices', $successMessage);
  4001. //
  4002. //                        return $this->redirectToRoute('proposal_destination_supplier_list', array(
  4003. //                            'idcontrol' => $cid
  4004. //                        ));
  4005.                         $newServ->setServiceCatId('');
  4006.                         $newServ->setServiceCatName('');
  4007.                         break;
  4008.                     default:
  4009.                         $newServ->setServiceCatId('');
  4010.                         $newServ->setServiceCatName('');
  4011.                         break;
  4012.                 }
  4013.                 $newServ->setName($add_services_multiple_name[$key1][$key2]['name']);
  4014. //                $newServ->setPrice($add_services_multiple_price[$key1][$key2]['price']);
  4015.                 if (empty($add_services_multiple_price[$key1][$key2]['price'])){
  4016.                     // Se pone el precio a 0 si viene vacio
  4017.                     $newServ->setPrice('0');
  4018.                 } else {
  4019.                     $newServ->setPrice($add_services_multiple_price[$key1][$key2]['price']);
  4020.                 }
  4021.                 if (empty($add_services_multiple_commission[$key1][$key2]['commission'])){
  4022.                     // Se pone la commission en 0 si viene vacio
  4023.                     $newServ->setCommission('0');
  4024.                 } else {
  4025.                     $newServ->setCommission($add_services_multiple_commission[$key1][$key2]['commission']);
  4026.                 }
  4027.                 if (empty($add_services_multiple_over[$key1][$key2]['over'])){
  4028.                     // Se pone el over en 0 si viene vacio
  4029.                     $newServ->setOver('0');
  4030.                 } else {
  4031.                     $newServ->setOver($add_services_multiple_over[$key1][$key2]['over']);
  4032.                 }
  4033.                 if (empty($add_services_multiple_iva[$key1][$key2]['iva'])){
  4034.                     // Se pone el iva a 21% si viene vacio
  4035.                     $newServ->setIva('21');
  4036.                 } else {
  4037.                     $newServ->setIva($add_services_multiple_iva[$key1][$key2]['iva']);
  4038.                 }
  4039.                 $newServ->setProposalId($controlTemp->getProposalId());
  4040.                 $newServ->setDestinationId($controlTemp->getDestinoId());
  4041.                 $newServ->setSupplierId($controlTemp->getSupplierId());
  4042.                 $newServ->setIdeaId($controlTemp->getIdeaId());
  4043.                 $newServ->setActivityId($controlTemp->getActivityId());
  4044.                 /* NAMEJO DE ADICIONALES EN EL DIA DEL EVENTO O DESPUES EL DIA DEL EVENTO */
  4045.                 $dayEvent $proposal_data->getDateEventStarAt()->format('Y-m-d');
  4046.                 $today date('Y-m-d');
  4047.                 if( $today >= $dayEvent){
  4048.                     $additional "Additional";
  4049.                 }else{
  4050.                     $additional "Normal";
  4051.                 }
  4052.                 $newServ->setCurrency('Euro');
  4053.                 $newServ->setUnits('1');
  4054.                 $newServ->setPax('0');
  4055.                 $newServ->setServiceId(0);
  4056.                 //$newServ->setHour('');//null
  4057.                 //$newServ->setDateInAt('');
  4058.                 //$newServ->setDateOutAt('');
  4059.                 $newServ->setDirectPayment('0');
  4060.                 $newServ->setStatus('Pending');
  4061.                 $newServ->setStatusinternal($additional);
  4062.                 $newServ->setDateInAt($proposal_data->getDateEventStarAt());
  4063.                 $newServ->setDateOutAt($proposal_data->getDateEventEndAt());
  4064.                 $newServ->setCreatedId($user_id);
  4065.                 $newServ->setUpdatedId($user_id);
  4066.                 $newServices[] = $newServ;
  4067.             }
  4068.         }
  4069.         // Eliminamos servicios sin tipo
  4070.         $arrayNewServ = array();
  4071.         foreach ($newServices as $item) {
  4072.             if (!empty($item->getServiceCatName())){   //setServiceCatName
  4073.                 $arrayNewServ[] = $item;
  4074.             }
  4075.         }
  4076.         // FIN: Generamos un arreglo con todos los servicios a agregar
  4077.         foreach ($arrayNewServ as $item){
  4078.             $em->persist($item);
  4079.             $em->flush();
  4080.             //INICIO: Replicacion en Develup
  4081.             if ($item->getSupplierId()==2){
  4082.                 // Nombre del agente
  4083.                 $agenteFullName $em->getRepository(User::class)->findOneById($user_id);
  4084.                 $agenteFullName $agenteFullName->getName() . ' ' $agenteFullName->getLastName();
  4085.                 $proposalTitle $em->getRepository(Proposal::class)->findOneById($item->getProposalId());
  4086.                 if ($item->getSupplierId()==2){
  4087.                     $originalServiceName $em->getRepository(MdvProduct::class)->findOneById(1); // Id de "Otro Servicio"
  4088.                     $budget = new MdvBudgetPending();
  4089.                     $budget->setActivityId($item->getActivityId());
  4090.                     $budget->setAssistantId($item->getAssistantId());
  4091.                     $budget->setBreakdown($item->getBreakdown());
  4092.                     $budget->setCommission($item->getCommission());
  4093.                     $budget->setControlId($item->getControlId());
  4094.                     $budget->setOriginId($item->getId());
  4095.                     $budget->setCurrency($item->getCurrency());
  4096.                     $budget->setDateBlockLimit($item->getDateBlockLimit());
  4097.                     $budget->setDateInAt($item->getDateInAt());
  4098.                     $budget->setDateOutAt($item->getDateOutAt());
  4099.                     $budget->setDestinationId($item->getDestinationId());
  4100.                     $budget->setDirectPayment($item->getDirectPayment());
  4101.                     $budget->setHour($item->getHour());
  4102.                     $budget->setIdeaId($item->getIdeaId());
  4103.                     $budget->setIsFather($item->getIsFather());
  4104.                     $budget->setIva($item->getIva());
  4105.                     if(!($originalServiceName->getName() == $item->getName())){
  4106.                         $budget->setName($originalServiceName->getName().' (:'$item->getName().':)');
  4107.                     } else {
  4108.                         $budget->setName($originalServiceName->getName());
  4109.                     }
  4110.                     $budget->setOpCommission($item->getOpCommission());
  4111.                     $budget->setOpIva($item->getOpIva());
  4112.                     $budget->setOpOver($item->getOpOver());
  4113.                     $budget->setOriginalIva($item->getOriginalIva());
  4114.                     $budget->setOriginalopIva($item->getOriginalopIva());
  4115.                     $budget->setOriginalPrice($item->getOriginalPrice());
  4116.                     $budget->setOver($item->getOver());
  4117.                     $budget->setPax($item->getPax());
  4118.                     $budget->setPreCommission($item->getPreCommission());
  4119.                     $budget->setPreIva($item->getPreIva());
  4120.                     $budget->setPrice($item->getPrice());
  4121.                     $budget->setProposalId($item->getProposalId());
  4122.                     $budget->setRank($item->getRank());
  4123.                     $budget->setServiceCatId($item->getServiceCatId());
  4124.                     $budget->setServiceCatName($item->getServiceCatName());
  4125. //                    $budget->setServiceId($item->getServiceId());
  4126.                     $budget->setServiceId(1);       // ID de "Otro Servicio"
  4127.                     $budget->setServiceIdFather($item->getServiceIdFather());
  4128.                     $budget->setStatus($item->getStatus());
  4129.                     $budget->setStatusinternal($item->getStatusinternal());
  4130.                     $budget->setStatusRec($item->getStatusRec());
  4131.                     $budget->setSupplierId($item->getSupplierId());
  4132.                     $budget->setUnits($item->getUnits());
  4133.                     $budget->setUserConfirmedFullName($agenteFullName);
  4134.                     $budget->setUserConfirmedId($user_id);
  4135.                     $budget->setProposalTitle($proposalTitle->getTitle());
  4136.                     $budget->setCreatedAt(new \DateTime("now"));
  4137.                     $budget->setCreatedId($user_id);
  4138.                     $budget->setUpdatedId($user_id);
  4139.                     $budget->setUpdatedAt(new \DateTime("now"));
  4140.                     // INIICO: Llenamos el tooltip con la info del proposal
  4141.                     $texto null;
  4142.                     if (!empty($budget->getProposalId())){
  4143.                         $prop $em->getRepository(Proposal::class)->findOneById($budget->getProposalId());
  4144.                         if (!empty($prop)){
  4145.                             $client $em->getRepository(Client::class)->findOneById($prop->getClientId());
  4146.                             $clientContact $em->getRepository(ClientContact::class)->findOneById($prop->getContactId());
  4147.                             $contacto null;
  4148.                             if (!empty($clientContact->getName())){$contacto $contacto$clientContact->getName(). ' ';}
  4149.                             if (!empty($clientContact->getLastName())){$contacto $contacto$clientContact->getLastName(). ' ';}
  4150.                             if (!empty($clientContact->getEmail())){$contacto $contacto'('.$clientContact->getEmail().')'' ';}
  4151.                             if (!empty($clientContact->getPhone())){$contacto $contacto' - '.$clientContact->getPhone(). ' ';}
  4152.                             if (!empty($clientContact->getMobile())){$contacto $contacto' - '.$clientContact->getMobile();}
  4153.                             $city $em->getRepository(Destination::class)->findOneById($budget->getDestinationId());
  4154.                             $texto $texto .'Petición: '.$budget->getCreatedAt()->format('d/m/Y'). ' -- ';
  4155.                             if (!empty($client)){$texto $texto .'Cliente: '.$client->getName(). ' -- ';}
  4156.                             if (!empty($prop->getPax())){$texto $texto .'Personas: '.$prop->getPax(). ' -- ';}
  4157.                             $texto $texto .'Desde: '.$prop->getDateEventStarAt()->format('d/m/Y').' Hasta: '.$prop->getDateEventEndAt()->format('d/m/Y'). ' -- ';
  4158.                             $texto $texto .'Horario: '.$item->getDateInAt()->format('H:i'). ' a '.$item->getDateOutAt()->format('H:i'). ' -- ';
  4159.                             $texto $texto .'Ciudad: '.$city->getTitle(). ' -- ';
  4160.                             $texto $texto .'Contacto: '$contacto;
  4161.                             $budget->setTextTooltip($texto);
  4162.                         }
  4163.                     }
  4164.                     // FIN: Llenamos el tooltip con la info del proposal
  4165.                     $em->persist($budget);
  4166.                     $em->flush();
  4167.                     //INICIO: Enviamos Telegram
  4168.                     //INICIO: Buscamos el creador del expediente asociado al proposal, si no hay se le envia al jefe de grupo (Jorge)
  4169.                     $file $em->getRepository(MdvFiles::class)->findOneByIdProposal($prop->getId());
  4170.                     if(!empty($file)){
  4171.                         //Se envia el mensaje al creador del expediente
  4172.                         $userTelegramId $file->getCreatedId();
  4173.                     } else {
  4174.                         // Solicitud sin expediente, se le notificara la jefe de departamento
  4175.                         $userTelegramId 5// Id de Jorge
  4176.                     }
  4177.                     //FIN: Buscamos el creador del expediente asociado al proposal, si no hay se le envia al jefe de grupo (Jorge)
  4178.                     //Buscamos el nombre del destino
  4179.                     $nombreDestino $em->getRepository(Destination::class)->findOneById($budget->getDestinationId());
  4180.                     $nombreDestino $nombreDestino->getTitle();
  4181.                     //Mensaje:
  4182.                     //SOLICITUD DE PRESUPUESTO __ ID: '.$budget->getProposalId().' __ DESTINO: '.$nombreDestino.' __ PROVEEDOR: In Out Travel __ CONTACTO: '.$budget->getUserConfirmedFullName()
  4183.                     $this->sendTelegram($userTelegramId,'SOLICITUD DE PRESUPUESTO (MultiService) __ ID: '.$budget->getProposalId().' __ DESTINO: '.$nombreDestino.' __ PROVEEDOR: In Out Travel __ CONTACTO: '.$budget->getUserConfirmedFullName());
  4184. //                            d($userTelegramId,'SOLICITUD DE PRESUPUESTO __ ID: '.$budget->getProposalId().' __ DESTINO: '.$nombreDestino.' __ PROVEEDOR: In Out Travel __ CONTACTO: '.$budget->getUserConfirmedFullName());exit();
  4185.                     //FIN: Enviamos Telegram
  4186.                 }
  4187.             }
  4188.             //FIN: Replicacion en Develup
  4189.         }
  4190.         return $this->redirectToRoute('proposal_destination_supplier_view', array(
  4191.             'id' => $controlTemp->getControlDestinationId(),
  4192.         ));
  4193.     }
  4194.     /**
  4195.      * @Route("proposal/destination/services/saveallservices/{id}", name="proposal_destination_supplier_saveallservices")
  4196.      */
  4197.     public function saveAllServicesAction($idRequest $request) {
  4198.         $save_services_multiple_name $request->request->get('services_hidden_name');
  4199.         $save_services_multiple_rank $request->request->get('services_hidden_rank');
  4200.         $save_services_multiple_price $request->request->get('services_hidden_price');
  4201.         $save_services_multiple_units $request->request->get('services_hidden_units');
  4202.         $save_services_multiple_pax $request->request->get('services_hidden_pax');
  4203.         $save_services_multiple_commission $request->request->get('services_hidden_commission');
  4204.         $save_services_multiple_over $request->request->get('services_hidden_over');
  4205.         $save_services_multiple_iva $request->request->get('services_hidden_iva');
  4206.         $save_services_multiple_originalPrice $request->request->get('services_hidden_originalPrice');
  4207.         $save_services_multiple_originalIva $request->request->get('services_hidden_originalIva');
  4208.         $save_services_multiple_supplier $request->request->get('services_hidden_supplier');
  4209.         $save_services_multiple_opcommission $request->request->get('services_hidden_opcommission');
  4210.         $save_services_multiple_opover $request->request->get('services_hidden_opover');
  4211.         $save_services_multiple_opiva $request->request->get('services_hidden_opiva');
  4212.         $save_services_multiple_dateBlockLimit $request->request->get('services_hidden_dateBlockLimit');
  4213.         $save_services_multiple_timeBlockLimit $request->request->get('services_hidden_timeBlockLimit');
  4214.         $save_services_multiple_dateInAt $request->request->get('services_hidden_dateInAt');
  4215.         $save_services_multiple_dateOutAt $request->request->get('services_hidden_dateOutAt');
  4216.         $save_services_multiple_hour_start $request->request->get('services_hidden_hour_start_');
  4217.         $save_services_multiple_hour_end $request->request->get('services_hidden_hour_end_');
  4218.         $save_services_multiple_currency $request->request->get('services_hidden_currency_');
  4219.         $save_services_multiple_originalopIva $request->request->get('services_hidden_originalopIva_');
  4220.         $save_multiple_supplier_activity_idea_rank $request->request->get('supplier_activity_idea_hidden_rank');
  4221.         $arrayServices = array();
  4222.         foreach ($save_services_multiple_name as $key => $name){
  4223.             $service = new ProposalSupplierServices();
  4224.             $service->setName($name);
  4225.             $service->setRank($save_services_multiple_rank[$key]);
  4226.             $service->setPrice($save_services_multiple_price[$key]);
  4227.             $service->setUnits($save_services_multiple_units[$key]);
  4228.             $service->setPax($save_services_multiple_pax[$key]);
  4229.             $service->setCommission($save_services_multiple_commission[$key]);
  4230.             $service->setOver($save_services_multiple_over[$key]);
  4231.             $service->setIva($save_services_multiple_iva[$key]);
  4232.             $service->setOriginalPrice($save_services_multiple_originalPrice[$key]);
  4233.             $service->setOriginalIva($save_services_multiple_originalIva[$key]);
  4234.             $service->setSupplierId($save_services_multiple_supplier[$key]);
  4235.             $service->setOpCommission($save_services_multiple_opcommission[$key]);
  4236.             $service->setOpOver($save_services_multiple_opover[$key]);
  4237.             $service->setOpIva($save_services_multiple_opiva[$key]);
  4238.             if (!empty($save_services_multiple_dateBlockLimit[$key]) or !empty($save_services_multiple_timeBlockLimit[$key])){
  4239.                 $service->setDateBlockLimit(new \DateTime($save_services_multiple_dateBlockLimit[$key].' '.$save_services_multiple_timeBlockLimit[$key]));
  4240.             }
  4241.             //$service->set ($save_services_multiple_timeBlockLimit[$key]);
  4242.             if (!empty($save_services_multiple_dateInAt[$key]) or !empty($save_services_multiple_hour_start[$key])) {
  4243.                 $service->setDateInAt(new \DateTime($save_services_multiple_dateInAt[$key] . ' ' $save_services_multiple_hour_start[$key]));
  4244.             }
  4245.             if (!empty($save_services_multiple_dateOutAt[$key]) or !empty($save_services_multiple_hour_end[$key]) ) {
  4246.                 $service->setDateOutAt(new \DateTime($save_services_multiple_dateOutAt[$key] . ' ' $save_services_multiple_hour_end[$key]));
  4247.             }
  4248.             $service->setHour($save_services_multiple_hour_start[$key]);
  4249.             //$service->set ($save_services_multiple_hour_end[$key]);
  4250.             $service->setCurrency($save_services_multiple_currency[$key]);
  4251.             $service->setOriginalopIva($save_services_multiple_originalopIva[$key]);
  4252.             $arrayServices[] = array($key$service);
  4253.         }
  4254.         $em $this->getDoctrine()->getManager();
  4255.         foreach ($save_multiple_supplier_activity_idea_rank as $key => $item){
  4256.             if(!empty($item)){
  4257.                 $prpSupActIdeaControl $em->getRepository(ProposalSupplierControl::class)->findOneById($key);
  4258.                 if (!empty($prpSupActIdeaControl)){
  4259.                     $prpSupActIdeaControl->setRank($item);
  4260.                     $em->persist($prpSupActIdeaControl);
  4261.                     $em->flush();
  4262.                 }
  4263.             }
  4264.         }
  4265.         /* Obtengo usuario logueado */
  4266.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  4267.         $user_id $user_logueado->getId();
  4268.         foreach ($arrayServices as $item){
  4269.             $prpSupService $em->getRepository(ProposalSupplierServices::class)->findOneById($item[0]);
  4270.             $srvToSave false;  //Indicador para determinar si se debe guardar el servicio
  4271.             // INICIO: Analizamos si se debe modificar el servicio, el $item[1] se encuentra el servicio
  4272.             if (!empty($item[1]->getName())){ // Hay nombre
  4273.                 $srvToSave true;
  4274.                 $prpSupService->setName($item[1]->getName());
  4275.             }
  4276.             if (!empty($item[1]->getRank())){ // Hay ranking
  4277.                 $srvToSave true;
  4278.                 $prpSupService->setRank($item[1]->getRank());
  4279.             }
  4280.             if (!empty($item[1]->getPrice())){ // Hay Precio
  4281.                 $srvToSave true;
  4282.                 $prpSupService->setPrice($item[1]->getPrice());
  4283.             }
  4284.             if (!empty($item[1]->getUnits())){ // Hay Unidades
  4285.                 $srvToSave true;
  4286.                 $prpSupService->setUnits($item[1]->getUnits());
  4287.             }
  4288.             if (!empty($item[1]->getPax())){ // Hay Personas
  4289.                 $srvToSave true;
  4290.                 $prpSupService->setPax($item[1]->getPax());
  4291.             }
  4292.             if (!empty($item[1]->getCommission())){ // Hay Comision
  4293.                 $srvToSave true;
  4294.                 $prpSupService->setCommission($item[1]->getCommission());
  4295.             }
  4296.             if (!empty($item[1]->getOver())){ // Hay Over
  4297.                 $srvToSave true;
  4298.                 $prpSupService->setOver($item[1]->getOver());
  4299.             }
  4300.             if (!empty($item[1]->getIva()) or ($item[1]->getIva() == '0')){ // Hay Iva
  4301.                 $srvToSave true;
  4302.                 $prpSupService->setIva($item[1]->getIva());
  4303.             }
  4304.             if (!empty($item[1]->getOriginalPrice())){ // Hay Original Price
  4305.                 $srvToSave true;
  4306.                 $prpSupService->setOriginalPrice($item[1]->getOriginalPrice());
  4307.             }
  4308.             if (!empty($item[1]->getOriginalIva())){ // Hay Original Iva
  4309.                 $srvToSave true;
  4310.                 $prpSupService->setOriginalIva($item[1]->getOriginalIva());
  4311.             }
  4312.             if (!empty($item[1]->getSupplierId())){ // Hay Supplier
  4313.                 $srvToSave true;
  4314.                 $prpSupService->setSupplierId($item[1]->getSupplierId());
  4315.             }
  4316.             if (($item[1]->getOpCommission() === '0') or ($item[1]->getOpCommission() === '1')){ // Hay OpCommission
  4317.                 $srvToSave true;
  4318.                 $prpSupService->setOpCommission($item[1]->getOpCommission());
  4319.             }
  4320.             if (($item[1]->getOpOver() === '0') or ($item[1]->getOpOver() === '1')){ // Hay OpOver
  4321.                 $srvToSave true;
  4322.                 $prpSupService->setOpOver($item[1]->getOpOver());
  4323.             }
  4324.             if (($item[1]->getOpIva() === '0') or ($item[1]->getOpIva() === '1')){ // Hay OpIva
  4325.                 $srvToSave true;
  4326.                 $prpSupService->setOpIva($item[1]->getOpIva());
  4327.             }
  4328.             if (!empty($item[1]->getHour())){ // Hay Hora de inicio
  4329.                 $srvToSave true;
  4330.                 $prpSupService->setHour($item[1]->getHour());
  4331.             }
  4332.             if (!empty($item[1]->getCurrency())){ // Hay Moneda
  4333.                 $srvToSave true;
  4334.                 $prpSupService->setCurrency($item[1]->getCurrency());
  4335.             }
  4336.             if (($item[1]->getOriginalopIva() === '0') or ($item[1]->getOriginalopIva() === '1')){ // Hay Original OP Iva
  4337.                 $srvToSave true;
  4338.                 $prpSupService->setOriginalopIva($item[1]->getOriginalopIva());
  4339.             }
  4340.             if (!empty($item[1]->getDateBlockLimit())){ // Hay Fecha de Block Limit
  4341.                 $srvToSave true;
  4342.                 $prpSupService->setDateBlockLimit($item[1]->getDateBlockLimit());
  4343.             }
  4344.             if (!empty($item[1]->getDateInAt())){ // Hay DateInAt
  4345.                 $srvToSave true;
  4346.                 $prpSupService->setDateInAt($item[1]->getDateInAt());
  4347.             }
  4348.             if (!empty($item[1]->getDateOutAt())){ // Hay DateInAt
  4349.                 $srvToSave true;
  4350.                 $prpSupService->setDateOutAt($item[1]->getDateOutAt());
  4351.             }
  4352.             // FIN: Analizamos si se debe modificar el servicio, el $item[1] se encuentra el servicio
  4353.             if ($srvToSave){
  4354.                 $em->persist($prpSupService);
  4355.                 $em->flush();
  4356.             }
  4357.             //Actualizar confirmado
  4358.             if ($prpSupService->getStatus() =='Confirmed'){
  4359.                 $costsClient $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($prpSupService->getId());
  4360.                 if (!empty($costsClient)){
  4361. //                $costsClient->setSupplierId($services_supplier_proposal->getSupplierId());
  4362.                     $costsClient->setAssistantId($prpSupService->getAssistantId());
  4363.                     $costsClient->setName($prpSupService->getName());
  4364.                     $costsClient->setPrice($prpSupService->getPrice());
  4365.                     $costsClient->setCurrency($prpSupService->getCurrency());
  4366.                     $costsClient->setUnits($prpSupService->getUnits());
  4367.                     $costsClient->setOpCommission($prpSupService->getOpCommission());
  4368.                     $costsClient->setCommission($prpSupService->getCommission());
  4369.                     $costsClient->setOpOver($prpSupService->getOpOver());
  4370.                     $costsClient->setOver($prpSupService->getOver());
  4371.                     $costsClient->setOpIva($prpSupService->getOpIva());
  4372.                     $costsClient->setIva($prpSupService->getIva());
  4373.                     $costsClient->setPax($prpSupService->getPax());
  4374.                     $costsClient->setHour($prpSupService->getHour());
  4375.                     $costsClient->setDateInAt($prpSupService->getDateInAt());
  4376.                     $costsClient->setDateOutAt($prpSupService->getDateOutAt());
  4377.                     $costsClient->setRank($prpSupService->getRank());
  4378.                     $costsClient->setCreatedId($user_id);
  4379.                     $costsClient->setUpdatedId($user_id);
  4380.                     $em->persist($costsClient);
  4381.                     $em->flush();
  4382.                 }
  4383.             }
  4384.         }
  4385.         return $this->redirectToRoute('proposal_destination_supplier_view', array(
  4386.             'id' => $id,
  4387.         ));
  4388.     }
  4389.     /**
  4390.      * @Route("proposal/destination/services/duplicateservice/{id}", name="proposal_destination_duplicate_service")
  4391.      */
  4392.     public function duplicateServiceAction($idRequest $request) {
  4393.         $em $this->getDoctrine()->getManager();
  4394.         $prpSupService $em->getRepository(ProposalSupplierServices::class)->findOneById($id);
  4395.         /* Obtengo usuario logueado */
  4396.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  4397.         $user_id $user_logueado->getId();
  4398.         $service = new ProposalSupplierServices();
  4399.         $service->setName('DUPLICADO - '.$prpSupService->getName());
  4400.         $service->setRank($prpSupService->getRank());
  4401.         $service->setPrice($prpSupService->getPrice());
  4402.         $service->setUnits($prpSupService->getUnits());
  4403.         $service->setPax($prpSupService->getPax());
  4404.         $service->setCommission($prpSupService->getCommission());
  4405.         $service->setOver($prpSupService->getOver());
  4406.         $service->setIva($prpSupService->getIva());
  4407.         $service->setOriginalPrice($prpSupService->getOriginalPrice());
  4408.         $service->setOriginalIva($prpSupService->getOriginalIva());
  4409.         $service->setSupplierId($prpSupService->getSupplierId());
  4410.         $service->setOpCommission($prpSupService->getOpCommission());
  4411.         $service->setOpOver($prpSupService->getOpOver());
  4412.         $service->setOpIva($prpSupService->getOpIva());
  4413.         $service->setDateBlockLimit($prpSupService->getDateBlockLimit());
  4414.         $service->setDateInAt($prpSupService->getDateInAt());
  4415.         $service->setDateOutAt($prpSupService->getDateOutAt());
  4416.         $service->setHour($prpSupService->getHour());
  4417.         $service->setCurrency($prpSupService->getCurrency());
  4418.         $service->setOriginalopIva($prpSupService->getOriginalopIva());
  4419.         $service->setCreatedId($user_id);
  4420.         $service->setCreatedAt(new \DateTime());
  4421.         $service->setUpdatedId($user_id);
  4422.         $service->setUpdatedAt(new \DateTime());
  4423.         $service->setControlId($prpSupService->getControlId());
  4424.         $service->setActivityId($prpSupService->getActivityId());
  4425.         $service->setAssistantId($prpSupService->getAssistantId());
  4426.         $service->setBreakdown($prpSupService->getBreakdown());
  4427.         $service->setDestinationId($prpSupService->getDestinationId());
  4428.         $service->setDirectPayment($prpSupService->getDirectPayment());
  4429.         $service->setIdeaId($prpSupService->getIdeaId());
  4430.         $service->setPreCommission($prpSupService->getPreCommission());
  4431.         $service->setPreIva($prpSupService->getPreIva());
  4432.         $service->setProposalId($prpSupService->getProposalId());
  4433.         $service->setServiceCatId($prpSupService->getServiceCatId());
  4434.         $service->setServiceCatName($prpSupService->getServiceCatName());
  4435.         $service->setServiceId($prpSupService->getServiceId());
  4436.         $service->setServiceIdFather($prpSupService->getServiceIdFather());
  4437.         $service->setStatus('Pending');
  4438.         $service->setStatusinternal($prpSupService->getStatusinternal());
  4439.         $em->persist($service);
  4440.         $em->flush();
  4441.         $prpSupCtrl $em->getRepository(ProposalSupplierControl::class)->findOneById($prpSupService->getControlId());
  4442.         return $this->redirectToRoute('proposal_destination_supplier_view', array(
  4443.             'id' => $prpSupCtrl->getControlDestinationId(),
  4444.             '_fragment' => $id
  4445.         ));
  4446.     }
  4447.     /**
  4448.      * @Route("proposal/destination/services/duplicatesupplier/{id}", name="proposal_destination_duplicate_supplier")
  4449.      */
  4450.     public function duplicateSupplierAction($idRequest $request) {
  4451.         $newSup $request->request->get('dupliSupplierId');
  4452.         $em $this->getDoctrine()->getManager();
  4453.         /* Obtengo usuario logueado */
  4454.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  4455.         $user_id $user_logueado->getId();
  4456.         $prpSupServices $em->getRepository(ProposalSupplierServices::class)->findByControlId($id);
  4457.         $prpSupControl $em->getRepository(ProposalSupplierControl::class)->findOneById($id);
  4458.         $origenSup $prpSupControl->getSupplierId();
  4459.         //Verificamos si Proveedor origen y destino son el mismo
  4460.         if ($newSup != $origenSup){
  4461.             //Verificamos si ya existe el control del Proveedor destino
  4462.             $prevPrpSupControl $em->getRepository(ProposalSupplierControl::class)->findBy(
  4463.                 array('proposalId'=>$prpSupControl->getProposalId(),
  4464.                       'destinoId'=>$prpSupControl->getDestinoId(),
  4465.                       'supplierId'=>$newSup));
  4466.             if (empty($prevPrpSupControl)){
  4467.                 // Proveedor origen y destino son distintos, se crea una nueva entidad de control
  4468.                 $newSupControl = new ProposalSupplierControl();
  4469.             } else {
  4470.                 // El Proveedor destino ya tiene un controlador
  4471.                 $newSupControl $prevPrpSupControl[0];
  4472.             }
  4473.             $newSupControl->setActivityId($prpSupControl->getActivityId());
  4474.             $newSupControl->setControlDestinationId($prpSupControl->getControlDestinationId());
  4475.             $newSupControl->setDateBlockLimit($prpSupControl->getDateBlockLimit());
  4476.             $newSupControl->setDestinoId($prpSupControl->getDestinoId());
  4477.             $newSupControl->setDisabled($prpSupControl->getDisabled());
  4478.             $newSupControl->setIdeaId($prpSupControl->getIdeaId());
  4479.             $newSupControl->setProposalId($prpSupControl->getProposalId());
  4480.             $newSupControl->setRank($prpSupControl->getRank());
  4481.             $newSupControl->setStatus($prpSupControl->getStatus());
  4482.             $newSupControl->setSupplierId($newSup);
  4483.             $em->persist($newSupControl);
  4484.             $em->flush();
  4485.         } else {
  4486.             $newSupControl $prpSupControl;
  4487.         }
  4488.         // Duplicamos los servicios
  4489.         foreach ($prpSupServices as $item){
  4490.             $service = new ProposalSupplierServices();
  4491.             $service->setName($item->getName());
  4492.             $service->setRank($item->getRank());
  4493.             $service->setPrice($item->getPrice());
  4494.             $service->setUnits($item->getUnits());
  4495.             $service->setPax($item->getPax());
  4496.             $service->setCommission($item->getCommission());
  4497.             $service->setOver($item->getOver());
  4498.             $service->setIva($item->getIva());
  4499.             $service->setOriginalPrice($item->getOriginalPrice());
  4500.             $service->setOriginalIva($item->getOriginalIva());
  4501.             $service->setSupplierId($newSup);
  4502.             $service->setOpCommission($item->getOpCommission());
  4503.             $service->setOpOver($item->getOpOver());
  4504.             $service->setOpIva($item->getOpIva());
  4505.             $service->setDateBlockLimit($item->getDateBlockLimit());
  4506.             $service->setDateInAt($item->getDateInAt());
  4507.             $service->setDateOutAt($item->getDateOutAt());
  4508.             $service->setHour($item->getHour());
  4509.             $service->setCurrency($item->getCurrency());
  4510.             $service->setOriginalopIva($item->getOriginalopIva());
  4511.             $service->setCreatedId($user_id);
  4512.             $service->setCreatedAt(new \DateTime());
  4513.             $service->setUpdatedId($user_id);
  4514.             $service->setUpdatedAt(new \DateTime());
  4515.             $service->setControlId($newSupControl->getId());
  4516.             $service->setActivityId($item->getActivityId());
  4517.             $service->setAssistantId($item->getAssistantId());
  4518.             $service->setBreakdown($item->getBreakdown());
  4519.             $service->setDestinationId($item->getDestinationId());
  4520.             $service->setDirectPayment($item->getDirectPayment());
  4521.             $service->setIdeaId($item->getIdeaId());
  4522.             $service->setPreCommission($item->getPreCommission());
  4523.             $service->setPreIva($item->getPreIva());
  4524.             $service->setProposalId($item->getProposalId());
  4525.             $service->setServiceCatId($item->getServiceCatId());
  4526.             $service->setServiceCatName($item->getServiceCatName());
  4527.             $service->setServiceId($item->getServiceId());
  4528.             $service->setServiceIdFather($item->getServiceIdFather());
  4529.             $service->setStatus('Pending');
  4530.             $service->setStatusinternal($item->getStatusinternal());
  4531.             $em->persist($service);
  4532.             $em->flush();
  4533.         }
  4534.         $prpSupCtrl $em->getRepository(ProposalSupplierControl::class)->findOneById($id);
  4535.         return $this->redirectToRoute('proposal_destination_supplier_view', array(
  4536.             'id' => $prpSupCtrl->getControlDestinationId(),
  4537.         ));
  4538.     }
  4539.     /**
  4540.      * @Route("proposal/destination/services/comissionall", name="proposal_destination_comission_all")
  4541.      */
  4542.     public function comissionAllAction(Request $request){
  4543.         $proposalSupplierControlId $request->request->get('proposalSupplierControlId');
  4544.         $opCommissionAll $request->request->get('opCommissionAll');
  4545.         $commissionAll $request->request->get('commissionAll');
  4546.         $em $this->getDoctrine()->getManager();
  4547.         $prpSupControl $em->getRepository(ProposalSupplierControl::class)->findOneById($proposalSupplierControlId);
  4548.         $prpSupServices $em->getRepository(ProposalSupplierServices::class)->findByControlId($proposalSupplierControlId);
  4549.         $idPrpSupServices null;
  4550.         foreach ($prpSupServices as $item){
  4551.             $item->setOpCommission($opCommissionAll);
  4552.             $item->setCommission($commissionAll);
  4553.             $idPrpSupServices $item->getId();
  4554.             $em->persist($item);
  4555.             $em->flush();
  4556.             $prpSupServicesCosts $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($item->getId());
  4557.             if (!empty($prpSupServicesCosts)){
  4558.                 $em->remove($prpSupServicesCosts);
  4559.                 $em->flush();
  4560.             }
  4561.             if (!empty($idPrpSupServices)){
  4562.                 $parameters = array(
  4563.                     'idPrpSupServices' => '%'.$idPrpSupServices.'%',
  4564.                 );
  4565.                 $dql 'SELECT i
  4566.                     FROM EventsBundle:ProposalSupplierServicesCosts i
  4567.                     WHERE i.servicesId LIKE :idPrpSupServices
  4568.                     ORDER BY i.id ASC';
  4569.                 $query $em->createQuery($dql)->setParameters($parameters);
  4570.                 $proposalSupplierServicesCosts $query->getResult();
  4571.                 // Si el servicio se encontraba dentro de $proposalSupplierServicesCosts es porque el servicio se encontraba
  4572.                 // confirmado y dentro de una proforma, se deben sacar para evitar error en el apartado de proveedores
  4573.                 foreach($proposalSupplierServicesCosts as $prpSupSrvCst){
  4574.                     $prpSupSrvCst->setServicesId('0');
  4575.                     $em->persist($prpSupSrvCst);
  4576.                     $em->flush();
  4577.                 }
  4578.             }
  4579.         }
  4580.         $fragmento = empty($prpSupServices) ? null $prpSupServices[0]->getId();
  4581.         return $this->redirectToRoute('proposal_destination_supplier_view',
  4582.             array(
  4583.                 'id' => $prpSupControl->getControlDestinationId(),
  4584.                 '_fragment' => $fragmento
  4585.             ));
  4586.     }
  4587.     private function sendTelegram $id$text )
  4588.     {
  4589.         $em $this->getDoctrine()->getManager();
  4590.         $telegUser $em->getRepository(MdvTelegramUser::class)->findOneByUserId($id);
  4591.         if (empty($telegUser)){return true;}
  4592.         $parameters = array(
  4593.             'chat_id' => $telegUser->getChatId(),
  4594.             'text' => $text,
  4595.         );
  4596.         $bot_token $telegUser->getBotToken();
  4597.         $url "https://api.telegram.org/bot$bot_token/sendMessage";
  4598.         if (!$curl curl_init()){
  4599.             exit();
  4600.         }
  4601.         curl_setopt($curl,CURLOPT_POST,true);
  4602.         curl_setopt($curl,CURLOPT_POSTFIELDS,$parameters);
  4603.         curl_setopt($curl,CURLOPT_URL,$url);
  4604.         curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
  4605.         $output curl_exec($curl);
  4606.         curl_close($curl);
  4607.         return true;
  4608.     }
  4609. }