<?php
/**
* Created by Mediterranean Develup Solutions
* User: jorge.defreitas@develup.solutions
* Date: 14/08/2017
* Time: 12:15
*/
namespace App\MDS\EventsBundle\Controller;
use App\Entity\Activities;
use App\Entity\Cities;
use App\Entity\Client;
use App\Entity\ClientContact;
use App\Entity\Country;
use App\Entity\Destination;
use App\Entity\DestinationGallery;
use App\Entity\Ideas;
use App\Entity\ProposalsInvoiceSummary;
use App\Entity\Provinces;
use App\Entity\Regions;
use App\Entity\RevisionCarga;
use App\Entity\Supplier;
use App\Entity\SupplierAccommodation;
use App\Entity\SupplierActivities;
use App\Entity\SupplierAv;
use App\Entity\SupplierCreative;
use App\Entity\SupplierCruise;
use App\Entity\SupplierDescription;
use App\Entity\SupplierEntertainment;
use App\Entity\SupplierGallery;
use App\Entity\SupplierGifts;
use App\Entity\SupplierGuide;
use App\Entity\SupplierIdeaServicesControl;
use App\Entity\SupplierIdServices;
use App\Entity\SupplierItineraries;
use App\Entity\SupplierLounge;
use App\Entity\SupplierMenu;
use App\Entity\SupplierOthers;
use App\Entity\SupplierServicesAssistant;
use App\Entity\SupplierServicesControl;
use App\Entity\SupplierServicesDescription;
use App\Entity\SupplierTechnology;
use App\Entity\SupplierTransport;
use App\Entity\User;
use App\MDS\AvexpressBundle\Entity\AveBriefings;
use App\MDS\DevelupBundle\Entity\MdvBriefings;
use App\MDS\EventsBundle\Entity\ProposalDiscount;
use App\MDS\EventsBundle\Entity\ProposalFee;
use App\MDS\EventsBundle\Entity\ProposalSupplierControl;
use App\MDS\EventsBundle\Entity\ProposalSupplierServices;
use App\MDS\EventsBundle\Form\ProposalActivitiesControlType;
use App\MDS\EventsBundle\Form\ProposalDiscountType;
use App\MDS\EventsBundle\Form\ProposalIdeasControlType;
use App\MDS\EventsBundle\Form\ProposalSupplierControlType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use App\MDS\EventsBundle\Entity\ProposalSupplierServicesCostsClient;
use App\MDS\DevelupBundle\Entity\MdvBudgetPending;
use App\MDS\DevelupBundle\Entity\MdvFiles;
use App\MDS\DevelupBundle\Entity\MdvProduct;
use App\MDS\DevelupBundle\Entity\MdvTelegramUser;
use App\MDS\EventsBundle\Entity\Proposal;
use App\MDS\EventsBundle\Entity\ProposalControl;
use App\MDS\EventsBundle\Entity\ProposalsSupplierServicesAssistantName;
use App\MDS\EventsBundle\Entity\ProposalSupplierServicesBudget;
use App\MDS\EventsBundle\Entity\ProposalSupplierServicesCosts;
use Swift_Mailer;
use Swift_Message;
use Swift_SmtpTransport;
use Symfony\Contracts\Translation\TranslatorInterface;
class ProposalSupplierController extends AbstractController
{
private $translator;
public function __construct(TranslatorInterface $translator) {
$this->translator = $translator;
}
// /*
// * ATENCION LAS RAIZ DE @Route POR DEFECTO DEL BUNDLE: EventsBundle ES /events/, NO PONERLO EN LA @Route("")
// *
// * */
/**
* @Route("/proposal/destination/services/add/{id}/{status}", defaults={"status" = "All"}, name="proposal_destination_supplier_view")
*/
public function viewSupplierAction($id, $status, Request $request)
{
$em = $this->getDoctrine()->getManager();
$destinationCrtl = $em->getRepository(ProposalControl::class)->findOneById($id);
$adicionales_destination = $em->getRepository(ProposalControl::class)->findByProposalId($destinationCrtl->getProposalId());
$mostrar_destino_adicionales = array();
foreach($adicionales_destination as $adicionaldestination){
$destination = $em->getRepository(Destination::class)->findOneById($adicionaldestination->getDestinationId());
$mostrar_destino_adicionales = array(
'idcontrol' => $adicionaldestination->getId(),
'title' => $destination->getTitle()
);
}
$destination = $em->getRepository(Destination::class)->findOneById($destinationCrtl->getDestinationId());
/* Formulario Supplier*/
$controlsupplier= new ProposalSupplierControl();
$controlsupplier->setControlDestinationId($id);
$controlsupplier->setProposalId($destinationCrtl->getProposalId());
$controlsupplier->setDestinoId($destinationCrtl->getDestinationId());
// $supplier_data = $em->getRepository(Supplier::class)->findBy(
// array(
// 'country' => $destination->getCountry(),
// 'province' => $destination->getProvince(),
// 'population' => $destination->getPopulation()
// )
// );
//
// foreach($supplier_data as $supplier_pais){
// $choices_data = array(
// 'choices' => array(
// 'id' => $supplier_pais->getId(),
// 'Company' => $supplier_pais->getCompany()
// )
// );
// };
// $controlsupplier->setSupplierId($choices_data);
$form = $this->createDestinationProposalSupplierCreateForm($controlsupplier);
$form2 = $this->createDestinationProposalIdeasCreateForm($controlsupplier);
$form4 = $this->createDestinationProposalActivitiesCreateForm($controlsupplier);
$consultadiscount = $em->getRepository(ProposalDiscount::class)->findByProposalId($destinationCrtl->getProposalId());
if(!empty($consultadiscount)){
foreach($consultadiscount as $consultadiscountfor){
if(is_null($consultadiscountfor->getServiceId())){
$consultadiscountfor->setServiceId('All');
}else{
$servicesName = $em->getRepository(SupplierIdServices::class)->findOneById($consultadiscountfor->getServiceId());
$consultadiscountfor->setServiceId($servicesName->getName());
}
}
}
/* Formulario Discount*/
$discount = new ProposalDiscount();
$discount->setProposalId($destinationCrtl->getProposalId());
$form3 = $this->createDiscountCreateForm($discount);
// }else{
// $consultadiscount ->setProposalId($destinationCrtl->getProposalId());
// $form3 = $this->editDiscountCreateForm($consultadiscount, $consultadiscount->getId());
// }
/* Data Proposal */
$idproposal = $destinationCrtl->getProposalId();
$proposal = $em->getRepository(Proposal::class)->findOneById($idproposal);
//
// $commercial = $em->getRepository(User::class)->findOneById($proposal->getAgencommercialId());
// $proposal->setAgencommercialId($commercial->getName().' '.$commercial->getLastname());
//
// $client = $em->getRepository(Client::class)->findOneById($proposal->getClientId());
// $proposal->setClientId($client->getName());
//
// $contact = $em->getRepository(ClientContact::class)->findOneById($proposal->getContactId());
// $proposal->setContactId($contact->getName().' '.$contact->getLastname());
// $datos_contacto = array(
// 'contacttelefono' => $contact->getPhone(),
// 'contactemail' => $contact->getEmail(),
// );
//
// if (!is_null($proposal->getTeamId())){
// $teams = $em->getRepository(SettingsTeam::class)->findOneById($proposal->getTeamId());
// $proposal->setTeamId($teams->getTeam());
// }
//
// $office = $em->getRepository(SettingsOffice::class)->findOneById($proposal->getOfficeId());
// $proposal->setOfficeId($office->getOffice());
//
// $agent = $em->getRepository(User::class)->findOneById($proposal->getAgentId());
// $proposal->setAgentId($agent->getName().' '.$agent->getLastname());
//
// $iconstatus = "";
// switch ($proposal->getStatus()) {
// case "Pending":
// $iconstatus ='<i class="icon-bell3 text-danger parpadea"></i>';
// break;
// case "Sent":
// $iconstatus ='<i class="icon-paperplane text-orange parpadea"></i>';
// break;
// case "Confirmed":
// $iconstatus ='<i class="icon-unlocked text-success"></i>';
// break;
// case "Invoiced":
// $iconstatus ='<i class="icon-lock2 text-green"></i>';
// break;
// }
//
// $proposal->SetStatus($this->translator->trans($proposal->getStatus()));
/* Data destino */
// $destination = $em->getRepository(Destination::class)->findOneById($destinationCrtl->getDestinationId());
//$destinationGallery = $em->getRepository(DestinationGallery::class)->findOneByDestinationId($destinationCrtl->getDestinationId());
$country = $em->getRepository(Country::class)->findOneById($destination->getCountry());
$destination->setCountry($country->getCountry());
$regions = $em->getRepository(Regions::class)->findOneById($destination->getRegion());
$destination->setRegion($regions->getRegion());
$province = $em->getRepository(Provinces::class)->findOneById($destination->getProvince());
$destination->setProvince($province->getName());
$cities = $em->getRepository(Cities::class)->findOneById($destination->getPopulation());
$destination->setPopulation($cities->getCity());
$mostrar_destino = array(
'idcontrol' => $destinationCrtl->getId(),
'destinoId' => $destination->getId(),
'title' => $destination->getTitle(),
//'image' => $destinationGallery->getImageSmall(),
'country' => $destination->getCountry(),
'region' => $destination->getRegion(),
'province' => $destination->getProvince(),
'population' =>$destination->getPopulation()
);
/* Data Supplier agregados */
// if($status == "All") {
// $array_ProposalSupplierControl =
// array(
// 'proposalId' => $destinationCrtl->getProposalId(),
// 'destinoId' => $destinationCrtl->getDestinationId()
// );
// }else{
// $array_ProposalSupplierControl = array(
// 'proposalId' => $destinationCrtl->getProposalId(),
// 'destinoId' => $destinationCrtl->getDestinationId()
// );
// }
// $service_supplier = $em->getRepository(ProposalSupplierControl::class)->findBy();
$service_supplier = $em->getRepository(ProposalSupplierControl::class)->findBy(
array(
'proposalId' => $destinationCrtl->getProposalId(),
'destinoId' => $destinationCrtl->getDestinationId(),
),
array(
'rank' => 'ASC'
)
);
$totales_global_neto = 0;
$totales_global_direct = 0;
$totales_global_iva = 0;
$totales_global_con_iva = 0;
$totales_global_paying = 0;
$totales_global_pago = 0;
$totales_global_benefit_moneda = 0;
$totales_global_benefit_porsentaje = 0;
$calculos_globales = array();
$data_supplier = array();
$controlgeneral = array();
foreach($service_supplier as $suppliercontrol){
//cambiar el estatus de colores
$colorlabel = "";
switch ($suppliercontrol->getStatus()) {
case 'Pending':
$colorlabel= "bg-danger";
break;
case 'Confirmed':
$colorlabel= "bg-success-300";
break;
}
$suppliercontrol->SetStatus($this->translator->trans($suppliercontrol->getStatus()));
$sqlactivities = "";
if(!is_null($suppliercontrol->getActivityId())){
$master = "activity";
$sqlactivities = $em->getRepository(Activities::class)->findOneById($suppliercontrol->getActivityId());
/*CONTROL GENERAL*/
$controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneByActivityId($suppliercontrol->getActivityId());
}
$sqlideas = "";
if(!is_null($suppliercontrol->getIdeaId())){
$master = "idea";
$sqlideas = $em->getRepository(Ideas::class)->findOneById($suppliercontrol->getIdeaId());
/*CONTROL GENERAL*/
$controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneByIdeaId($suppliercontrol->getIdeaId());
}
$sqlsuppliers ="";
if(!is_null($suppliercontrol->getSupplierId())){
$master = "supplier";
$sqlsuppliers = $em->getRepository(Supplier::class)->findOneById($suppliercontrol->getSupplierId());
if(!is_null($sqlsuppliers)){
switch ($sqlsuppliers->getStar()) {
case 1:
$sqlsuppliers->setStar('<i class="icon-star-full2"></i>');
break;
case 2:
$sqlsuppliers->setStar('<i class="icon-star-full2"></i><i class="icon-star-full2"></i>');
break;
case 3:
$sqlsuppliers->setStar('<i class="icon-star-full2"></i><i class="icon-star-full2"></i><i class="icon-star-full2"></i>');
break;
case 4:
$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>');
break;
case 5:
$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');
break;
case 6:
$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>');
break;
case 7:
$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');
break;
case 8:
$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');
break;
}
}
/*CONTROL GENERAL*/
$controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneBySupplierId($suppliercontrol->getSupplierId());
}
if (empty($controlgeneral)){
$master = "White";
$idsu = '0';
}else{
$idsu = $controlgeneral->getId();
}
$sqlsuppliers_gallery = $em->getRepository(SupplierGallery::class)->findOneBy(
array(
'supplierId' => $idsu,
'servicesCatId' => '0',
'servicesCategory' => 'General',
'servicesId' => '0',
'controlId' => '0'
)
);
if (!is_null($sqlsuppliers_gallery)){
$imagenSmall = $sqlsuppliers_gallery->getimageSmall();
}else{
//Imagen no disponible (poner una generica)
$imagenSmall = null;
}
// SIN ORDEN
// $data_service_supplier = $em->getRepository(ProposalSupplierServices::class)->findByControlId($suppliercontrol->getId());
// CON ORDEN DESCENDENTE
// $data_service_supplier = $em->getRepository(ProposalSupplierServices::class)->findByControlId(
// array( 'controlId' => $suppliercontrol->getId() ),
// array( 'id' => 'DESC' )
// );
// ORDEN DESCENDENTE Y POR SERVICES
if($status == "All"){
$parameters = array(
'controlId' => $suppliercontrol->getId(),
'serviceIdFather' => '0'
);
$dql = 'SELECT p
FROM EventsBundle:ProposalSupplierServices p
WHERE p.controlId = :controlId AND p.serviceIdFather = :serviceIdFather
ORDER BY p.rank, p.serviceCatId ASC ';
// ORDER BY p.serviceCatId, p.rank ASC ';
}else{
$parameters = array(
'controlId' => $suppliercontrol->getId(),
'serviceIdFather' => '0',
'status' => $status
);
$dql = 'SELECT p
FROM EventsBundle:ProposalSupplierServices p
WHERE p.controlId = :controlId AND p.serviceIdFather = :serviceIdFather AND p.status = :status
ORDER BY p.rank, p.serviceCatId ASC ';
// ORDER BY p.serviceCatId, p.rank ASC ';
}
// $dql = 'SELECT p
// FROM EventsBundle:ProposalSupplierServices p
// WHERE p.controlId = :controlId AND p.serviceIdFather = :serviceIdFather AND p.status in (:status)
// ORDER BY p.serviceCatId, p.id ASC ';
$query = $em->createQuery($dql)->setParameters($parameters);
$data_service_supplier = $query->getResult();
$service_supplier_data = array();
$calculos_totatales = array();
$totales_neto ='0';
$total_direct ='0';
$totales_iva ='0';
$totales_con_iva ='0';
$totales_paying ='0';
$totales_pago ='0';
$totales_benefit_moneda ='0';
$totales_benefit_porsentaje ='0';
foreach($data_service_supplier as $data_service){
$service_supplier_data_sub = array();
$zNameSrvOrNameUsrBool = false;
//COLOR POR SERVICIO
$contcolor ="";
switch ($data_service->getServiceCatName()) {
case "Accommodation":
$contcolor = 'teal';
break;
case "Menu" :
$contcolor = 'purple';
break;
case "Lounge":
$contcolor = 'warning';
break;
case "Activities":
$contcolor = 'blue';
break;
case "Itineraries":
$contcolor = 'indigo';
break;
case "Cruise":
$contcolor = 'brown';
break;
case "Transport":
$contcolor = 'grey';
break;
case "Av":
$contcolor = 'slate';
break;
case "Creative":
$contcolor = 'orange';
break;
case "Gifts":
$contcolor = 'pink';
break;
case "Entertainment":
$contcolor = 'green';
break;
case "Guide":
$contcolor = 'orange';
break;
case "Others":
$contcolor = 'danger';
break;
case "Technology":
$contcolor = 'slate-800';
break;
case "Assistant":
$contcolor = 'indigo-800';
$prpSupSrv = $em->getRepository(ProposalsSupplierServicesAssistantName::class)->findOneByPrpSupSrvId($data_service->getId());
$zNameSrvOrNameUsrBool = !empty($prpSupSrv);
break;
case "DDR":
$contcolor = 'green-300';
break;
}
$servicesbudgetconfirm = $em->getRepository(ProposalSupplierServicesBudget::class)->findOneBy(
array(
'itemsServiceId' => $data_service->getId(),
'proposalId' => $data_service->getProposalId(),
'status' => 'Confirmed',
),
array(
'updatedAt' => 'DESC'
)
);
if (is_null($servicesbudgetconfirm)){
$servicesbudgetconfirm = array();
}
$idcat = $data_service->getServiceCatId();
$price = empty($data_service->getPrice())? 0 : $data_service->getPrice();
$precommission = $data_service->getPreCommission();
$preiva = $data_service->getPreIva();
$units = $data_service->getUnits();
$pax = $data_service->getPax();
$opcommission = $data_service->getOpCommission();
$commission = $data_service->getCommission();
$opover = $data_service->getOpOver();
$over = $data_service->getOver();
$opiva = $data_service->getOpIva();
$iva = empty($data_service->getIva())? 0 : $data_service->getIva();
$dateInAt = $data_service->getDateInAt();
$dateOutAt = $data_service->getDateOutAt();
if (!is_null($dateInAt) and !is_null($dateOutAt)){
$days = $dateInAt->diff($dateOutAt);
$day = $days->days;
}else{
$day = "0";
}
$directPayment = $data_service->getDirectPayment();
if(!is_null($data_service->getSupplierId())){
$name_supplier = $em->getRepository(Supplier::class)->findOneById($data_service->getSupplierId());
if (empty($name_supplier)){
$namesupplier = '';
}else{
$namesupplier = $name_supplier->getName();
}
}
if(!is_null($data_service->getActivityId())){
$name_supplier = $em->getRepository(Activities::class)->findOneById($data_service->getActivityId());
if (empty($name_supplier)){
$namesupplier = '';
}else{
$namesupplier = $name_supplier->getName();
}
}
if(!is_null($data_service->getIdeaId())){
$name_supplier = $em->getRepository(Ideas::class)->findOneById($data_service->getIdeaId());
if (empty($name_supplier)){
$namesupplier = '';
}else{
$namesupplier = $name_supplier->getName();
}
}
$calculos = $this->CalculoTotalesservices($price, $precommission, $preiva, $units, $pax, $day, $opcommission, $commission, $opover, $over, $opiva, $iva, $directPayment, $idcat);
// /*CONTROL GENERAL*/
// $controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneBySupplierId($data_service->getSupplierId());
if (empty($controlgeneral)){
$control_general = '0';
}else{
$control_general = $controlgeneral->getId();
}
$service_supplier_data[] = array(
'calculos' => $calculos,
'services_data' => $data_service,
'controlBoolNameSrvOrNameUsrBool' => $zNameSrvOrNameUsrBool,
'controlGeneralId' => $control_general,
'inBudget' => $servicesbudgetconfirm,
'namesupplier' => $namesupplier,
'contcolor' => $contcolor,
'servicesSub' =>$service_supplier_data_sub
);
if($data_service->getBreakdown() == false){
$totales_neto += $calculos['total_neto'];
$total_direct += $calculos['total_direct'];
$totales_iva += $calculos['sub_total_iva'];
$totales_con_iva += $calculos['total'];
$totales_paying += $calculos['total_paying'];
$totales_pago += $calculos['total_pago'];
$totales_benefit_moneda += $calculos['benefit_moneda'];
}else{
// $totales_neto += $totales_neto_sub ;
// $totales_iva += $totales_iva_sub ;
// $totales_con_iva += $totales_con_iva_sub;
// $totales_paying += $totales_paying_sub;
// $totales_pago += $totales_pago_sub;
// $totales_benefit_moneda += $totales_benefit_moneda_sub;
}
$totales_global_neto += $calculos['total_neto'];
$totales_global_direct += $calculos['total_direct'];
$totales_global_iva += $calculos['sub_total_iva'];
$totales_global_con_iva += $calculos['total'];
$totales_global_paying += $calculos['total_paying'];
$totales_global_pago += $calculos['total_pago'];
$totales_global_benefit_moneda += $calculos['benefit_moneda'];
if ($totales_benefit_moneda == '0'){
$totales_benefit_porsentaje = '0';
}else{
$totales_benefit_porsentaje = $totales_benefit_moneda / $total_direct * 100; // arreglado or estevan
}
if ($totales_global_benefit_moneda == '0'){
$totales_global_benefit_porsentaje = '0';
}else{
$totales_global_benefit_porsentaje = $totales_global_benefit_moneda / $totales_global_direct * 100; // arreglado or estevan
}
}
$calculos_totatales = array(
'totales_neto' => $totales_neto,
'totales_iva' => $totales_iva,
'totales_con_iva' => $totales_con_iva,
'totales_paying' => $totales_paying,
'totales_benefit_moneda' => $totales_benefit_moneda,
'totales_benefit_porsentaje' => $totales_benefit_porsentaje
);
if (!empty($sqlsuppliers)){
$briefings = null;
if ($sqlsuppliers->getId() == 2){
// Buscamos los briefings de Develup
$briefings = $em->getRepository(MdvBriefings::class)->findByProposalId($idproposal);
}
if ($sqlsuppliers->getId() == 80){
// Buscamos los briefings de Av Express
$briefings = $em->getRepository(AveBriefings::class)->findByProposalId($idproposal);
}
} else { $briefings = null; }
$data_supplier[] = array(
'colorlabel' => $colorlabel,
'control' => $suppliercontrol,
'master' => $master,
'supplier' => $sqlsuppliers,
'briefings' => $briefings,
'idea' => $sqlideas,
'activity' => $sqlactivities,
'image' => $imagenSmall,
'services' => $service_supplier_data,
'totales_services' => $calculos_totatales
);
}
$calculos_globales = array(
'totales_global_neto' => $totales_global_neto,
'totales_global_iva' => $totales_global_iva,
'totales_global_con_iva' => $totales_global_con_iva,
'totales_global_paying' => $totales_global_paying,
'totales_global_benefit_moneda' => $totales_global_benefit_moneda,
'totales_global_benefit_porsentaje' => $totales_global_benefit_porsentaje,
);
/*Supplier list*/
$list_Supplier = $em->getRepository(Supplier::class)->findAll();
$arraySupplier =array();
foreach($list_Supplier as $listSupplier) {
$arraySupplier[] = array(
'id' => $listSupplier->getId(),
'company' => $listSupplier->getCompany(),
'name' => $listSupplier->getName(),
);
}
/*User list*/
$list_User = $em->getRepository(User::class)->findAll();
$arrayUser =array();
foreach($list_User as $listUser) {
$arrayUser[] = array(
'id' => $listUser->getId(),
'name' => $listUser->getName().' '.$listUser->getLastname()
);
}
$fee = $em->getRepository(ProposalFee::class)->findByProposalId($idproposal);
$summaryInvoice = $em->getRepository(ProposalsInvoiceSummary::class)->findOneByProposalId($idproposal);
return $this->render('MDS/EventsBundle/services/services-destination-proposal.html.twig',
array(
'id' => $idproposal,
'proname' => $proposal->getName(),
'token' => $proposal->getAccessKey(),
'mcp' => $proposal->getMcp(),
'proposal' => $proposal,
// 'proposal_icostatus' => $iconstatus,
// 'datacontact' => $datos_contacto,
'destination' => $mostrar_destino,
'adicionaldestination' => $mostrar_destino_adicionales,
'form' => $form->createView(),
'form2' => $form2->createView(),
'form3' => $form3->createView(),
'form4' => $form4->createView(),
'discounts' => $consultadiscount,
'fees' => $fee,
'summaryInvoice' => $summaryInvoice,
'datasupplier' => $data_supplier,
'listSupplier' => $arraySupplier,
'listUser' => $arrayUser,
'status' => $status,
'global_calculos' => $calculos_globales
)
);
}
public function CalculoTotalesservices($price, $precommission, $preiva, $units, $pax, $days, $opcommission, $commission, $opover, $over, $opiva, $iva, $directPayment, $idcat)
{
$price = trim($price);
$over = trim($over);
$price = str_replace(",", ".", $price);
$over = str_replace(",", ".", $over);
if (empty($iva)){$iva=0;}
$iva = $iva / 100;
if($opiva =='0'){
$price = $price / ($iva + 1);
}
// if($opiva =='1'){
// $price = $price * ($iva + 1);
// }
if(!empty($commission)){
if($opcommission=='1'){
$commission = ($commission / 100) + 1;
}
if($opcommission=='0'){
// $price = $price * 0.9;
$commission = (100 - $commission) / 100;
$price = $price * $commission;
}
}
//Units
if(empty($units) or $units =="0"){
$units = "1";
}
// Calculo Especial por categoria
//Alojamientos
if($idcat =="1"){
$informativo_days = "si";
$pax = "1";
}
//Transporte
elseif($idcat =="13"){
$informativo_days = "no";
$pax = "1";
}
//Guia
elseif($idcat =="8") {
$informativo_days = "no";
$pax = "1";
}
//Lounge
elseif($idcat =="10"){
$informativo_days = "no";
$pax = "1";
}else{
$informativo_days = "no";
}
//Pax
if(empty($pax) or $pax =="0"){
$pax = "1";
}
//Over
if(empty($over)){
$over = "0";
}
if($informativo_days =="no"){
//Days
if(empty($days) or $days =="0"){
$days = "1";
}else{
$days = $days + 1 ;
}
}
$total_items = $price * $units * $pax * $days;
$total_pdirect = $price * $units * $pax * $days;
$total_over = $over * $units * $pax * $days;
// if($opover=='0' and !empty($over)){
//// $total_neto = $total_items * ($commission + 1) - $total_over ;
//// $total_neto = $total_items / 0.9 - $total_over ;
// $total_neto = $total_items / $commission - $total_over ;
// }
// if($opover=='1' or (empty($over) or $over == "0")){
//// $total_neto = $total_items * ($commission + 1) + $total_over;
//// $total_neto = $total_items / 0.9 + $total_over;
// $total_neto = $total_items * $commission + $total_over;
// }
if(!empty($commission)){
if($opcommission=='0'){
$total_neto = $total_items / $commission;
}
if($opcommission=='1'){
$total_neto = $total_items * $commission;
}
}else{
$total_neto = $total_items;
}
if($opover=='0'){
$total_neto = $total_neto - $total_over ;
}
if($opover=='1'){
$total_neto = $total_neto + $total_over;
}
// $total_neto = $total_items * ($commission + 1);
$total_paying = $total_items * ($iva + 1);
$total_comision ="0";
// $total_pago = $total_items + $total_comision;
$total_pago = $total_items;
$total_iva = $total_items * $iva;
$sub_total_iva = $total_neto * $iva;
$total = $total_neto + $sub_total_iva;
$benefit_moneda = $total_neto - $total_items;
// if ($directPayment == true){
// $benefit_moneda = $total_neto;
// $total_paying = "0";
// }else{
// $benefit_moneda = $total_neto - $total_items;
// }
$total_direct = $total_neto;
if ($directPayment == true){
$total_neto = "0";
$total = "0";
$total_paying = "0";
$total_pago = "0";
$sub_total_iva = "0";
}
$data_calculos = array(
'total_days' => $days,
'sub_total' => $total_items,
'sub_total_iva' => $sub_total_iva,
'total_neto' => $total_neto,
'total_direct' => $total_direct,
'total_iva' => $total_iva,
'total_paying' => $total_paying,
'total_pago' => $total_pago,
'total_comision' => $total_comision,
'total' => $total,
'benefit_moneda' => $benefit_moneda
);
// d($data_calculos);
return $data_calculos;
}
/* CREAR DESDE UN SUPPLIER ESPECIAL*/
/**
* @Route("/proposal/destination/servicesesp/create/{cdid}/{pid}/{did}/{sid}", name="proposal_destination_supplier_create_especial")
*/
public function createProposalDestinationEspecialAction($cdid, $pid, $did, $sid, Request $request)
{
$em = $this->getDoctrine()->getManager();
$control_verifico = $em->getRepository(ProposalSupplierControl::class)->findOneBy(
array(
'controlDestinationId' => $cdid,
'proposalId' => $pid,
'destinoId' => $did,
'supplierId' => $sid,
)
);
// $proposal = $em->getRepository(Proposal::class)->findOneById($pid);
if(empty($control_verifico)){
if(!empty($cdid) and !empty($pid) and !empty($did) and !empty($sid))
{
$control = new ProposalSupplierControl();
$control->setControlDestinationId($cdid);
$control->setProposalId($pid);
$control->setDestinoId($did);
$control->setSupplierId($sid);
$control->setStatus('Pending');
$em->persist($control);
$em->flush();
// INICIO: Envio de Correo a AV EXPRESS o DEVELUP SOLUTIONS
if ($sid == 80 or $sid == 2) {
// Es un servicio de proveedor AV EXPRESS o DEVELUP
$proposal = $em->getRepository(Proposal::class)->findOneById($pid);
$zclient = $em->getRepository(Client::class)->findOneById($proposal->getClientId());
$user_logueado = $this->get('security.token_storage')->getToken()->getUser();
$user_id = $user_logueado->getId();
$agentUser = $em->getRepository(User::class)->findOneById($user_id);
$agent = $em->getRepository(User::class)->findOneById('20');
$mailAgent[] = $agent->getEmail();
$agentMail = $agent->getEmail();
$zagentReplyTo = array(
$agent->getEmail() => $agent->getName() . ' ' . $agent->getLastName()
);
$firmGmail = $agent->getFirmGmail();
if ($sid == 80 ) {
// AV Express
$mailAgentSent = array(
// $zclient->getEmail() => $zclient->getName()
// 'gustavo.ayala@develup.solutions' => $zclient->getName()
'salvador@avexpress.tv' => $zclient->getName()
);
$empresa = $em->getRepository(Supplier::class)->findOneById('80');
} else {
// Develup
$mailAgentSent = array(
'jorge.defreitas@develup.solutions' => $zclient->getName()
// 'gustavo.ayala@develup.solutions' => $zclient->getName()
);
$empresa = $em->getRepository(Supplier::class)->findOneById('2');
}
$mailAgentFrom = array(
$agent->getEmail() => $agent->getName() . ' ' . $agent->getLastName()
);
$data = array(
'body' => '' . '<p>Estimado proveedor,</p><p>'. $empresa->getName() .' ha sido dada de alta como uno de los proveedores para la propuesta: </p>
<p><a href="inout.mante.solutions/events/proposal/edit/' . $proposal->getId() .'">' . $proposal->getTitle() . '</a></p>
<p>El usuario que hizo esta incorporación fue: ' . $agentUser->getName() .' '. $agentUser->getLastName() . '</p>'
,
// '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> <br></span><span style="font-size: x-small; color: rgb(0, 121, 186);">Phone : <a href="tel:+34%20911%2087%2083%2093" value="+34911878393" target="_blank" style="color: rgb(17, 85, 204);">+34 91 187 83 93</a> / <a href="tel:+34%20917%2058%2007%2020" value="+34917580720" target="_blank" style="color: rgb(17, 85, 204);">+34 91 758 07 20</a> </span><span style="font-size: x-small; color: rgb(0, 121, 186);">Fax : <a href="tel:+34%20911%2087%2083%2090" value="+34911878390" target="_blank" style="color: rgb(17, 85, 204);">+34 91 187 83 90</a> <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 </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&sn=" target="_blank" data-saferedirecturl="https://www.google.com/url?hl=es&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&source=gmail&ust=1516881697636000&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&q=https://www.facebook.com/InOutTravel/&source=gmail&ust=1516881697636000&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"> </span><a href="https://twitter.com/inout_travel?lang=es" target="_blank" data-saferedirecturl="https://www.google.com/url?hl=es&q=https://twitter.com/inout_travel?lang%3Des&source=gmail&ust=1516881697636000&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"> </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 </span><a href="https://maps.google.com/?q=C/+CRISTOBAL+BORDIU,+53+-+28003+MADRID&entry=gmail&source=g" target="_blank" data-saferedirecturl="https://www.google.com/url?hl=es&q=https://maps.google.com/?q%3DC/%2BCRISTOBAL%2BBORDIU,%2B53%2B-%2B28003%2BMADRID%26entry%3Dgmail%26source%3Dg&source=gmail&ust=1516881697636000&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 </span><a href="https://maps.google.com/?q=C/+CRISTOBAL+BORDIU,+53+-+28003+MADRID&entry=gmail&source=g" target="_blank" data-saferedirecturl="https://www.google.com/url?hl=es&q=https://maps.google.com/?q%3DC/%2BCRISTOBAL%2BBORDIU,%2B53%2B-%2B28003%2BMADRID%26entry%3Dgmail%26source%3Dg&source=gmail&ust=1516881697636000&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;"> 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 </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 </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;"> o al teléfono<b> </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 </span></b></a><b><span style="font-size: 10pt; line-height: 15.3333px; font-family: Arial, sans-serif;"> </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>',
'firm' => '',
);
// EJECUTAR ENVIO DE ALERTA PARA EL AGENTE
$transporter = new Swift_SmtpTransport();
$transporter->setHost('smtp.gmail.com')
->setEncryption('ssl')//ssl / tls
->setPort(465)// 465 / 587
// ->setUsername($agent->getEmail())
// ->setPassword($agent->getPassGmail());
->setUsername('desarrollo@develup.solutions')
->setPassword('MeDITeRRANeAN_Develup30102023#');
$mailer = new Swift_Mailer($transporter);
$message = new Swift_Message();
$message->setSubject('P#' . $proposal->getId() . ', Alta de servicio')
// ->setSender($agentMail)
// ->setFrom($mailAgentFrom)
->setFrom(array("desarrollo@develup.solutions" => "System Mante 3.0"))
->setReplyTo($zagentReplyTo)
->setTo($mailAgentSent)
->setBody(
$this->renderView(
'mail/structure-mail.html.twig',
array('data' => $data)
),
'text/html'
);
$mailer->send($message);
}
// FIN: Envio de Correo a AV EXPRESS o DEVELUP SOLUTIONS
$event = 'The Supplier Destination Proposal has been created.';
$successMessage = $this->translator->trans($event);
$this->addFlash('mensajeproposaldestinationservices', $successMessage);
return $this->redirectToRoute('proposal_destination_supplier_especial_list', array(
'idcontrol' => $control->getId()
));
}else{
$errorMessage = $this->translator->trans('Error, some fields are empty');
$this->addFlash('mensajeproposaldestinationserviceserror', $errorMessage);
}
}else{
// $errorMessage = $this->translator->trans('The proposal already has this provider included');
// $this->addFlash('mensajeproposaldestinationserviceserror', $errorMessage);
return $this->redirectToRoute('proposal_destination_supplier_especial_list', array(
'idcontrol' => $control_verifico->getId()
));
}
return $this->redirectToRoute('proposal_destination_supplier_view', array(
'id' => $cdid,
'_fragment' => 's'.$control_verifico->getId()
));
}
/* CREAR DESDE UN SUPPLIER */
private function createDestinationProposalSupplierCreateForm(ProposalSupplierControl $entity)
{
$form = $this->createForm(ProposalSupplierControlType::class, $entity, array(
'action' => $this->generateUrl('proposal_destination_supplier_create'),
'method' => 'POST'
));
return $form;
}
/* CREAR DESDE UN SUPPLIER */
/**
* @Route("/proposal/destination/services/create", name="proposal_destination_supplier_create")
*/
public function createProposalDestinationAction(Request $request)
{
$control = new ProposalSupplierControl();
$form = $this->createDestinationProposalSupplierCreateForm($control);
$form->handleRequest($request);
$supplier_proposal = $form->get('supplierId')->getData();
if(!is_null($supplier_proposal)){
$control->setSupplierId($supplier_proposal->getId());
}
$em = $this->getDoctrine()->getManager();
$control_verifico = $em->getRepository(ProposalSupplierControl::class)->findOneBy(
array(
'controlDestinationId' => $form->get('controlDestinationId')->getData(),
'proposalId' => $form->get('proposalId')->getData(),
'destinoId' => $form->get('destinoId')->getData(),
'supplierId' => $supplier_proposal->getId(),
)
);
$proposal = $em->getRepository(Proposal::class)->findOneById($form->get('proposalId')->getData());
if(empty($control_verifico)){
if($form->isValid())
{
$control->setStatus('Pending');
$em->persist($control);
$em->flush();
$event = 'The Supplier Destination Proposal has been created.';
$successMessage = $this->translator->trans($event);
$this->addFlash('mensajeproposaldestinationservices', $successMessage);
}else{
$errorMessage = $this->translator->trans('Error, some fields are empty');
$this->addFlash('mensajeproposaldestinationserviceserror', $errorMessage);
}
}else{
$errorMessage = $this->translator->trans('The proposal already has this provider included');
$this->addFlash('mensajeproposaldestinationserviceserror', $errorMessage);
}
return $this->redirectToRoute('proposal_destination_supplier_view', array(
'id' => $control->getControlDestinationId(),
'_fragment' => 's'.$control->getId()
));
}
/* CREAR DESDE UNA Activity */
private function createDestinationProposalActivitiesCreateForm(ProposalSupplierControl $entity)
{
$form = $this->createForm(ProposalActivitiesControlType::class, $entity, array(
'action' => $this->generateUrl('proposal_destination_activities_create'),
'method' => 'POST'
));
return $form;
}
/* CREAR DESDE UNA Activity */
/**
* @Route("/proposal/destination/services/createActivity", name="proposal_destination_activities_create")
*/
public function createProposalActivityDestinationAction(Request $request)
{
$control = new ProposalSupplierControl();
$form = $this->createDestinationProposalActivitiesCreateForm($control);
$form->handleRequest($request);
$supplier_proposal = $form->get('activityId')->getData();
if(!is_null($supplier_proposal)){
$control->setActivityId($supplier_proposal->getId());
}
$em = $this->getDoctrine()->getManager();
$control_verifico = $em->getRepository(ProposalSupplierControl::class)->findOneBy(
array(
'controlDestinationId' => $form->get('controlDestinationId')->getData(),
'proposalId' => $form->get('proposalId')->getData(),
'destinoId' => $form->get('destinoId')->getData(),
'activityId' => $supplier_proposal->getId(),
)
);
// $proposal = $em->getRepository(Proposal::class)->findOneById($form->get('proposalId')->getData());
if(empty($control_verifico)){
if($form->isValid())
{
$control->setStatus('Pending');
$em->persist($control);
$em->flush();
/* METEMOS EL CONTENIDO DE LA IDEA */
$idcontrol = $control->getId();
$idactivity = $control->getActivityId();
/*CONTROL GENERAL*/
$controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneByActivityId($idactivity);
$id = $controlgeneral->getId();
$supplierservices= new ProposalSupplierServices();
$supplierservices->setControlId($idcontrol);
$supplierCrtl = $em->getRepository(ProposalSupplierControl::class)->findOneById($idcontrol);
$supplierservices->setProposalId($supplierCrtl->getProposalId());
$supplierservices->setDestinationId($supplierCrtl->getDestinoId());
$supplierservices->setServiceIdFather('0');
$supplierservices->setSupplierId(null);
$supplierservices->setActivityId($idactivity);
$supplierservices->setIsFather('0');
/* NAMEJO DE ADICIONALES EN EL DIA DEL EVENTO O DESPUES EL DIA DEL EVENTO */
$proposal_data = $em->getRepository(Proposal::class)->findOneById($supplierCrtl->getProposalId());
$dayEvent = $proposal_data->getDateEventStarAt()->format('Y-m-d');
$today = date('Y-m-d');
if( $today >= $dayEvent){
$additional = "Additional";
}else{
$additional = "Normal";
}
/* Obtengo usuario logueado */
$user_logueado = $this->get('security.token_storage')->getToken()->getUser();
$user_id = $user_logueado->getId();
$supplierservices->setCreatedId($user_id);
$supplierservices->setUpdatedId($user_id);
$supplierservices->setDateInAt($proposal_data->getDateEventStarAt());
$supplierservices->setDateOutAt($proposal_data->getDateEventEndAt());
///////colsulta de servicio
/* metemos accommodation *////////////////////////////////////////////////////////////////
$accommodations = $em->getRepository(SupplierAccommodation::class)->findBySupplierId($id);
//la consulta es al SupplierId porque lo estamos usando como id controlador para SupplierIdeaServicesControl
if(!empty($accommodations)){
foreach($accommodations as $accommodation){
$supplierservices->setServiceId($accommodation->getId());
$supplierservices->setServiceCatId('1');
$supplierservices->setServiceCatName('Accommodation');
$supplierservices->setName($accommodation->getName());
$supplierservices->setPrice($accommodation->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission('0');
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva('10');
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos menu *////////////////////////////////////////////////////////////////
$menus = $em->getRepository(SupplierMenu::class)->findBySupplierId($id);
if(!empty($menus)){
foreach($menus as $menu){
$supplierservices->setServiceId($menu->getId());
$supplierservices->setServiceCatId('11');
$supplierservices->setServiceCatName('Menu');
$supplierservices->setName($menu->getTitle());
$supplierservices->setPrice($menu->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($menu->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($menu->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos lounge *////////////////////////////////////////////////////////////////
$lounges = $em->getRepository(SupplierLounge::class)->findBySupplierId($id);
if(!empty($lounges)){
foreach($lounges as $lounge){
$supplierservices->setServiceId($lounge->getId());
$supplierservices->setServiceCatId('10');
$supplierservices->setServiceCatName('Lounge');
$supplierservices->setName($lounge->getName());
$supplierservices->setPrice($lounge->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($lounge->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($lounge->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos activities *////////////////////////////////////////////////////////////////
$activitiess = $em->getRepository(SupplierActivities::class)->findBySupplierId($id);
if(!empty($activitiess)){
foreach($activitiess as $activities){
$supplierservices->setServiceId($activities->getId());
$supplierservices->setServiceCatId('2');
$supplierservices->setServiceCatName('Activities');
$supplierservices->setName($activities->getTitle());
$supplierservices->setPrice($activities->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($activities->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($activities->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos itineraries *////////////////////////////////////////////////////////////////
$itinerariess = $em->getRepository(SupplierItineraries::class)->findBySupplierId($id);
if(!empty($itinerariess)){
foreach($itinerariess as $itineraries){
$supplierservices->setServiceId($itineraries->getId());
$supplierservices->setServiceCatId('9');
$supplierservices->setServiceCatName('Itineraries');
$supplierservices->setName($itineraries->getTitle());
$supplierservices->setPrice('0');
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission('0');
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva('10');
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos cruise *////////////////////////////////////////////////////////////////
$cruises = $em->getRepository(SupplierCruise::class)->findBySupplierId($id);
if(!empty($cruises)){
foreach($cruises as $cruise){
$supplierservices->setServiceId($cruise->getId());
$supplierservices->setServiceCatId('5');
$supplierservices->setServiceCatName('Cruise');
$supplierservices->setName($cruise->getTitle());
$supplierservices->setPrice($cruise->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($cruise->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($cruise->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos transport *////////////////////////////////////////////////////////////////
$transports = $em->getRepository(SupplierTransport::class)->findBySupplierId($id);
if(!empty($transports)){
foreach($transports as $transport){
$supplierservices->setServiceId($transport->getId());
$supplierservices->setServiceCatId('13');
$supplierservices->setServiceCatName('Transport');
$supplierservices->setName($transport->getName());
$supplierservices->setPrice($transport->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($transport->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($transport->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos av *////////////////////////////////////////////////////////////////
$avs = $em->getRepository(SupplierAv::class)->findBySupplierId($id);
if(!empty($avs)){
foreach($avs as $av){
$supplierservices->setServiceId($av->getId());
$supplierservices->setServiceCatId('3');
$supplierservices->setServiceCatName('Av');
$supplierservices->setName($av->getName());
$supplierservices->setPrice($av->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($av->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($av->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos creative *////////////////////////////////////////////////////////////////
$creatives = $em->getRepository(SupplierCreative::class)->findBySupplierId($id);
if(!empty($creatives)){
foreach($creatives as $creative){
$supplierservices->setServiceId($creative->getId());
$supplierservices->setServiceCatId('4');
$supplierservices->setServiceCatName('Creative');
$supplierservices->setName($creative->getTitle());
$supplierservices->setPrice('0');
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission('0');
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva('21');
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos gift *////////////////////////////////////////////////////////////////
$gifts = $em->getRepository(SupplierGifts::class)->findBySupplierId($id);
if(!empty($gifts)){
foreach($gifts as $gift){
$supplierservices->setServiceId($gift->getId());
$supplierservices->setServiceCatId('7');
$supplierservices->setServiceCatName('Gifts');
$supplierservices->setName($gift->getName());
$supplierservices->setPrice($gift->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($gift->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($gift->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos entertainment *////////////////////////////////////////////////////////////////
$entertainments = $em->getRepository(SupplierEntertainment::class)->findBySupplierId($id);
if(!empty($entertainments)){
foreach($entertainments as $entertainment){
$supplierservices->setServiceId($entertainment->getId());
$supplierservices->setServiceCatId('6');
$supplierservices->setServiceCatName('Entertainment');
$supplierservices->setName($entertainment->getName());
$supplierservices->setPrice($entertainment->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($entertainment->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($entertainment->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos guide *////////////////////////////////////////////////////////////////
$guides = $em->getRepository(SupplierGuide::class)->findBySupplierId($id);
if(!empty($guides)){
foreach($guides as $guide){
$supplierservices->setServiceId($guide->getId());
$supplierservices->setServiceCatId('8');
$supplierservices->setServiceCatName('Guide');
$supplierservices->setName($guide->getName());
$supplierservices->setPrice($guide->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($guide->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($guide->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos others *////////////////////////////////////////////////////////////////
$otherss = $em->getRepository(SupplierOthers::class)->findBySupplierId($id);
if(!empty($otherss)){
foreach($otherss as $others){
$supplierservices->setServiceId($others->getId());
$supplierservices->setServiceCatId('12');
$supplierservices->setServiceCatName('Others');
$supplierservices->setName($others->getName());
$supplierservices->setPrice($others->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($others->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($others->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos technology *////////////////////////////////////////////////////////////////
$technologys = $em->getRepository(SupplierTechnology::class)->findBySupplierId($id);
if(!empty($technologys)){
foreach($technologys as $technology){
$supplierservices->setServiceId($technology->getId());
$supplierservices->setServiceCatId('14');
$supplierservices->setServiceCatName('Technology');
$supplierservices->setName($technology->getTitle());
$supplierservices->setPrice($technology->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($technology->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($technology->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos Assistant *////////////////////////////////////////////////////////////////
$assistants = $em->getRepository(SupplierServicesAssistant::class)->findBySupplierId($id);
if(!empty($assistants)){
foreach($assistants as $assistant){
$supplierservices->setServiceId($assistant->getId());
$supplierservices->setServiceCatId('15');
$supplierservices->setServiceCatName('Assistant');
$supplierservices->setName($assistant->getName());
$supplierservices->setPrice($assistant->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($assistant->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($assistant->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* FIN METEMOS EL CONTENIDO DE LA IDEA */
// Control para el sistema de revision
$actId = $request->request->get('proposalsuppliercontrol')['activityId'];
$prpId = $request->request->get('proposalsuppliercontrol')['proposalId'];
$activities = $em->getRepository(Activities::class)->findOneById($actId);
$revision1 = new RevisionCarga();
$revision2 = new RevisionCarga();
$revision3 = new RevisionCarga();
$revision1->setIdType($activities->getId());
$revision2->setIdType($activities->getId());
$revision3->setIdType($activities->getId());
$revision1->setName($activities->getName());
$revision2->setName($activities->getName());
$revision3->setName($activities->getName());
// Titulo, Destino y observacion
$revision1->setType('ACTIVIDAD (TÃtulo) - Agregada al Proposal:'.$prpId);
$revision1->setLink('activities/edit/'.$activities->getId());
$revision1->setStatus(false);
$em->persist($revision1);
$em->flush();
// Descripcion
$revision2->setType('ACTIVIDAD (Descripción) - Agregada al Proposal:'.$prpId);
// Buscamos el ID de la descripcion
$idact = $activities->getId();
$controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneByActivityId($idact);
$idctrl = $controlgeneral->getId();
$supdesc = $em->getRepository(SupplierDescription::class)->findOneBySupplierId($idctrl);
$id = $supdesc->getId();
// FIN Buscamos el ID de la descripcion
$revision2->setLink('activities/description/edit/'.$id);
$revision2->setStatus(false);
$em->persist($revision2);
$em->flush();
// GalerÃa
$revision3->setType('ACTIVIDAD (GalerÃa) - Agregada al Proposal:'.$prpId);
$revision3->setLink('activities/gallery/list/'.$activities->getId());
$revision3->setStatus(false);
$em->persist($revision3);
$em->flush();
// FIN Control para el sistema de revision
$event = 'The Idea Destination Proposal has been created.';
$successMessage = $this->translator->trans($event);
$this->addFlash('mensajeproposaldestinationservices', $successMessage);
}else{
$errorMessage = $this->translator->trans('Error, some fields are empty');
$this->addFlash('mensajeproposaldestinationserviceserror', $errorMessage);
}
}else{
$errorMessage = $this->translator->trans('The proposal already has this Idea included');
$this->addFlash('mensajeproposaldestinationserviceserror', $errorMessage);
}
return $this->redirectToRoute('proposal_destination_supplier_view', array(
'id' => $control->getControlDestinationId(),
'_fragment' => 's'.$control->getId()
));
}
/* CREAR DESDE UNA IDEA */
private function createDestinationProposalIdeasCreateForm(ProposalSupplierControl $entity)
{
$form = $this->createForm(ProposalIdeasControlType::class, $entity, array(
'action' => $this->generateUrl('proposal_destination_ideas_create'),
'method' => 'POST'
));
return $form;
}
/* CREAR DESDE UNA IDEA */
/**
* @Route("/proposal/destination/services/createIdea", name="proposal_destination_ideas_create")
*/
public function createProposalIdeaDestinationAction(Request $request)
{
$control = new ProposalSupplierControl();
$form = $this->createDestinationProposalIdeasCreateForm($control);
$form->handleRequest($request);
$supplier_proposal = $form->get('ideaId')->getData();
if(!is_null($supplier_proposal)){
$control->setIdeaId($supplier_proposal->getId());
}
$em = $this->getDoctrine()->getManager();
$control_verifico = $em->getRepository(ProposalSupplierControl::class)->findOneBy(
array(
'controlDestinationId' => $form->get('controlDestinationId')->getData(),
'proposalId' => $form->get('proposalId')->getData(),
'destinoId' => $form->get('destinoId')->getData(),
'ideaId' => $supplier_proposal->getId(),
)
);
// $proposal = $em->getRepository(Proposal::class)->findOneById($form->get('proposalId')->getData());
if(empty($control_verifico)){
if($form->isValid())
{
$control->setStatus('Pending');
$em->persist($control);
$em->flush();
/* METEMOS EL CONTENIDO DE LA IDEA */
$idcontrol = $control->getId();
$ididea = $control->getIdeaId();
/*CONTROL GENERAL*/
$controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneByIdeaId($ididea);
$id = $controlgeneral->getId();
$supplierservices= new ProposalSupplierServices();
$supplierservices->setControlId($idcontrol);
$supplierCrtl = $em->getRepository(ProposalSupplierControl::class)->findOneById($idcontrol);
$supplierservices->setProposalId($supplierCrtl->getProposalId());
$supplierservices->setDestinationId($supplierCrtl->getDestinoId());
$supplierservices->setServiceIdFather('0');
$supplierservices->setSupplierId(null);
$supplierservices->setIdeaId($ididea);
$supplierservices->setIsFather('0');
/* NAMEJO DE ADICIONALES EN EL DIA DEL EVENTO O DESPUES EL DIA DEL EVENTO */
$proposal_data = $em->getRepository(Proposal::class)->findOneById($supplierCrtl->getProposalId());
$dayEvent = $proposal_data->getDateEventStarAt()->format('Y-m-d');
$today = date('Y-m-d');
if( $today >= $dayEvent){
$additional = "Additional";
}else{
$additional = "Normal";
}
/* Obtengo usuario logueado */
$user_logueado = $this->get('security.token_storage')->getToken()->getUser();
$user_id = $user_logueado->getId();
$supplierservices->setCreatedId($user_id);
$supplierservices->setUpdatedId($user_id);
$supplierservices->setDateInAt($proposal_data->getDateEventStarAt());
$supplierservices->setDateOutAt($proposal_data->getDateEventEndAt());
///////colsulta de servicio
/* metemos accommodation *////////////////////////////////////////////////////////////////
$accommodations = $em->getRepository(SupplierAccommodation::class)->findBySupplierId($id);
//la consulta es al SupplierId porque lo estamos usando como id controlador para SupplierIdeaServicesControl
if(!empty($accommodations)){
foreach($accommodations as $accommodation){
$supplierservices->setServiceId($accommodation->getId());
$supplierservices->setServiceCatId('1');
$supplierservices->setServiceCatName('Accommodation');
$supplierservices->setName($accommodation->getName());
$supplierservices->setPrice($accommodation->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission('0');
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva('10');
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos menu *////////////////////////////////////////////////////////////////
$menus = $em->getRepository(SupplierMenu::class)->findBySupplierId($id);
if(!empty($menus)){
foreach($menus as $menu){
$supplierservices->setServiceId($menu->getId());
$supplierservices->setServiceCatId('11');
$supplierservices->setServiceCatName('Menu');
$supplierservices->setName($menu->getTitle());
$supplierservices->setPrice($menu->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($menu->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($menu->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos lounge *////////////////////////////////////////////////////////////////
$lounges = $em->getRepository(SupplierLounge::class)->findBySupplierId($id);
if(!empty($lounges)){
foreach($lounges as $lounge){
$supplierservices->setServiceId($lounge->getId());
$supplierservices->setServiceCatId('10');
$supplierservices->setServiceCatName('Lounge');
$supplierservices->setName($lounge->getName());
$supplierservices->setPrice($lounge->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($lounge->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($lounge->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos activities *////////////////////////////////////////////////////////////////
$activitiess = $em->getRepository(SupplierActivities::class)->findBySupplierId($id);
if(!empty($activitiess)){
foreach($activitiess as $activities){
$supplierservices->setServiceId($activities->getId());
$supplierservices->setServiceCatId('2');
$supplierservices->setServiceCatName('Activities');
$supplierservices->setName($activities->getTitle());
$supplierservices->setPrice($activities->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($activities->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($activities->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos itineraries *////////////////////////////////////////////////////////////////
$itinerariess = $em->getRepository(SupplierItineraries::class)->findBySupplierId($id);
if(!empty($itinerariess)){
foreach($itinerariess as $itineraries){
$supplierservices->setServiceId($itineraries->getId());
$supplierservices->setServiceCatId('9');
$supplierservices->setServiceCatName('Itineraries');
$supplierservices->setName($itineraries->getTitle());
$supplierservices->setPrice('0');
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission('0');
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva('10');
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos cruise *////////////////////////////////////////////////////////////////
$cruises = $em->getRepository(SupplierCruise::class)->findBySupplierId($id);
if(!empty($cruises)){
foreach($cruises as $cruise){
$supplierservices->setServiceId($cruise->getId());
$supplierservices->setServiceCatId('5');
$supplierservices->setServiceCatName('Cruise');
$supplierservices->setName($cruise->getTitle());
$supplierservices->setPrice($cruise->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($cruise->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($cruise->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos transport *////////////////////////////////////////////////////////////////
$transports = $em->getRepository(SupplierTransport::class)->findBySupplierId($id);
if(!empty($transports)){
foreach($transports as $transport){
$supplierservices->setServiceId($transport->getId());
$supplierservices->setServiceCatId('13');
$supplierservices->setServiceCatName('Transport');
$supplierservices->setName($transport->getName());
$supplierservices->setPrice($transport->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($transport->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($transport->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos av *////////////////////////////////////////////////////////////////
$avs = $em->getRepository(SupplierAv::class)->findBySupplierId($id);
if(!empty($avs)){
foreach($avs as $av){
$supplierservices->setServiceId($av->getId());
$supplierservices->setServiceCatId('3');
$supplierservices->setServiceCatName('Av');
$supplierservices->setName($av->getName());
$supplierservices->setPrice($av->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($av->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($av->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos creative *////////////////////////////////////////////////////////////////
$creatives = $em->getRepository(SupplierCreative::class)->findBySupplierId($id);
if(!empty($creatives)){
foreach($creatives as $creative){
$supplierservices->setServiceId($creative->getId());
$supplierservices->setServiceCatId('4');
$supplierservices->setServiceCatName('Creative');
$supplierservices->setName($creative->getTitle());
$supplierservices->setPrice('0');
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission('0');
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva('21');
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos gift *////////////////////////////////////////////////////////////////
$gifts = $em->getRepository(SupplierGifts::class)->findBySupplierId($id);
if(!empty($gifts)){
foreach($gifts as $gift){
$supplierservices->setServiceId($gift->getId());
$supplierservices->setServiceCatId('7');
$supplierservices->setServiceCatName('Gifts');
$supplierservices->setName($gift->getName());
$supplierservices->setPrice($gift->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($gift->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($gift->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos entertainment *////////////////////////////////////////////////////////////////
$entertainments = $em->getRepository(SupplierEntertainment::class)->findBySupplierId($id);
if(!empty($entertainments)){
foreach($entertainments as $entertainment){
$supplierservices->setServiceId($entertainment->getId());
$supplierservices->setServiceCatId('6');
$supplierservices->setServiceCatName('Entertainment');
$supplierservices->setName($entertainment->getName());
$supplierservices->setPrice($entertainment->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($entertainment->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($entertainment->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos guide *////////////////////////////////////////////////////////////////
$guides = $em->getRepository(SupplierGuide::class)->findBySupplierId($id);
if(!empty($guides)){
foreach($guides as $guide){
$supplierservices->setServiceId($guide->getId());
$supplierservices->setServiceCatId('8');
$supplierservices->setServiceCatName('Guide');
$supplierservices->setName($guide->getName());
$supplierservices->setPrice($guide->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($guide->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($guide->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos others *////////////////////////////////////////////////////////////////
$otherss = $em->getRepository(SupplierOthers::class)->findBySupplierId($id);
if(!empty($otherss)){
foreach($otherss as $others){
$supplierservices->setServiceId($others->getId());
$supplierservices->setServiceCatId('12');
$supplierservices->setServiceCatName('Others');
$supplierservices->setName($others->getName());
$supplierservices->setPrice($others->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($others->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($others->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos technology *////////////////////////////////////////////////////////////////
$technologys = $em->getRepository(SupplierTechnology::class)->findBySupplierId($id);
if(!empty($technologys)){
foreach($technologys as $technology){
$supplierservices->setServiceId($technology->getId());
$supplierservices->setServiceCatId('14');
$supplierservices->setServiceCatName('Technology');
$supplierservices->setName($technology->getTitle());
$supplierservices->setPrice($technology->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($technology->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($technology->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* metemos Assistant *////////////////////////////////////////////////////////////////
$assistants = $em->getRepository(SupplierServicesAssistant::class)->findBySupplierId($id);
if(!empty($assistants)){
foreach($assistants as $assistant){
$supplierservices->setServiceId($assistant->getId());
$supplierservices->setServiceCatId('15');
$supplierservices->setServiceCatName('Assistant');
$supplierservices->setName($assistant->getName());
$supplierservices->setPrice($assistant->getPrice());
//$supplierservices->setCurrency('Euro');
$supplierservices->setUnits('1');
$supplierservices->setCommission($assistant->getCommission());
//$supplierservices->setOver('Accommodation');
$supplierservices->setIva($assistant->getIva());
$supplierservices->setPax('0');
//$supplierservices->setHour('');//null
//$supplierservices->setDateInAt('');
//$supplierservices->setDateOutAt('');
$supplierservices->setDirectPayment('0');
$supplierservices->setStatus('Pending');
$supplierservices->setStatusinternal($additional);
$em->persist($supplierservices);
$em->flush();
$em->clear();
//para pruebas
//$data_prueba[] = array(
// 'data' => $supplierservices
//);
}
//para pruebas
//d($data_prueba);
//exit();
}
/* FIN METEMOS EL CONTENIDO DE LA IDEA */
// Control para el sistema de revision
$ideas = $em->getRepository(Ideas::class)->findOneById($supplier_proposal->getId());
$prpId = $request->request->get('proposalsuppliercontrol')['proposalId'];
$revision1 = new RevisionCarga();
$revision2 = new RevisionCarga();
$revision3 = new RevisionCarga();
$revision1->setIdType($ideas->getId());
$revision2->setIdType($ideas->getId());
$revision3->setIdType($ideas->getId());
$revision1->setName($ideas->getName());
$revision2->setName($ideas->getName());
$revision3->setName($ideas->getName());
// Titulo, Destino y observacion
$revision1->setType('IDEA (TÃtulo) - Agregada al Proposal: '.$prpId);
$revision1->setLink('ideas/edit/'.$ideas->getId());
$revision1->setStatus(false);
$em->persist($revision1);
$em->flush();
// Descripcion
$revision2->setType('IDEA (Descripción) - Agregada al Proposal: '.$prpId);
// Buscamos el ID de la descripcion
$idact = $ideas->getId();
$controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneByIdeaId($idact);
$idctrl = $controlgeneral->getId();
$supdesc = $em->getRepository(SupplierDescription::class)->findOneBySupplierId($idctrl);
$id = $supdesc->getId();
// FIN Buscamos el ID de la descripcion
$revision2->setLink('ideas/description/edit/'.$id);
$revision2->setStatus(false);
$em->persist($revision2);
$em->flush();
// GalerÃa
$revision3->setType('IDEA (GalerÃa) - Agregada al Proposal: '.$prpId);
$revision3->setLink('ideas/gallery/list/'.$ideas->getId());
$revision3->setStatus(false);
$em->persist($revision3);
$em->flush();
// FIN Control para el sistema de revision
$event = 'The Idea Destination Proposal has been created.';
$successMessage = $this->translator->trans($event);
$this->addFlash('mensajeproposaldestinationservices', $successMessage);
}else{
$errorMessage = $this->translator->trans('Error, some fields are empty');
$this->addFlash('mensajeproposaldestinationserviceserror', $errorMessage);
}
}else{
$errorMessage = $this->translator->trans('The proposal already has this Idea included');
$this->addFlash('mensajeproposaldestinationserviceserror', $errorMessage);
}
return $this->redirectToRoute('proposal_destination_supplier_view', array(
'id' => $control->getControlDestinationId(),
'_fragment' => 's'.$control->getId()
));
}
/**
* @Route("proposal/destination/services/disabled/{id}", name="proposal_destination_supplier_disabled")
*
*/
public function disabledAction($id, Request $request)
{
$em = $this->getDoctrine()->getManager();
$disabled = $em->getRepository(ProposalSupplierControl::class)->findOneById($id);
$proposal= $em->getRepository(Proposal::class)->findOneById($disabled->getProposalId());
$actual = $disabled->getDisabled();
$var_mensaje="";
if($actual == "0"){
$disabled->setDisabled('1');
$var_mensaje = "Disabled";
}
if($actual == "1"){
$disabled->setDisabled('0');
$var_mensaje = "Activated";
}
$em->persist($disabled);
$em->flush();
$event = 'The supplier has been. '.$var_mensaje;
$successMessage = $this->translator->trans($event);
$this->addFlash('mensajeproposaldestinationservices', $successMessage);
return $this->redirectToRoute('proposal_destination_supplier_view',
array(
'id' => $disabled->getControlDestinationId(),
'_fragment' => 's'.$disabled->getId()
)
);
}
/**
* @Route("proposal/destination/services/deleted/{id}", name="proposal_destination_supplier_deleted")
*
*/
// public function deleteAction($id, Request $request, LoggerInterface $logger)
public function deleteAction($id, Request $request)
{
$em = $this->getDoctrine()->getManager();
$delete = $em->getRepository(ProposalSupplierControl::class)->findOneById($id);
$proposal = $em->getRepository(Proposal::class)->findOneById($delete->getProposalId());
$delete_services = $em->getRepository(ProposalSupplierServices::class)->findByControlId($id);
foreach ($delete_services as $delete_service) {
$em->remove($delete_service);
}
$em->remove($delete);
$em->flush();
$event = 'The supplier has been Deleted.';
$successMessage = $this->translator->trans($event);
$this->addFlash('mensajeproposaldestinationservices', $successMessage);
return $this->redirectToRoute('proposal_destination_supplier_view',
array(
'id' => $delete->getControlDestinationId()
)
);
}
/**
* @Route("proposal/destination/services/list/{idcontrol}", name="proposal_destination_supplier_list")
*/
public function listAction($idcontrol, Request $request) {
$em = $this->getDoctrine()->getManager();
$control = $em->getRepository(ProposalSupplierControl::class)->findOneById($idcontrol);
$idsupplier = $control->getSupplierId();
$ididea = $control->getIdeaId();
$idactivity = $control->getActivityId();
if($idsupplier == '0'){
$id = '0';
}else{
if(!is_null($idsupplier)){
/*CONTROL GENERAL*/
$controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneBySupplierId($idsupplier);
$id = $controlgeneral->getId();
}
if(!is_null($idactivity)){
/*CONTROL GENERAL*/
$controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneByActivityId($idactivity);
$id = $controlgeneral->getId();
}
if(!is_null($ididea)){
/*CONTROL GENERAL*/
$controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneByIdeaId($ididea);
$id = $controlgeneral->getId();
}
}
/* accommodations */
$accommodations = $em->getRepository(SupplierAccommodation::class)->findBySupplierId($id);
$data_accommodation = array();
foreach ($accommodations as $accommodation) {
/* Consulta en Control Services */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $accommodation->getId(),
'servicesCat' => $accommodation->getControlCat()
));
//class="label label-flat label-rounded label-icon border-grey text-grey"
if ($accommodation->getMinibar()){
$accommodation->setMinibar('<span class="label quitar-margin-15"><img src="/assets/images/icons/mi-20.png"></span>');
}
if ($accommodation->getWifi()){
$accommodation->setWifi('<span class="label quitar-margin-15"><img src="/assets/images/icons/wi-20.png"></span>');
}
if ($accommodation->getAirconditioner()){
$accommodation->setAirconditioner('<span class="label quitar-margin-15"><img src="/assets/images/icons/ac-20.png"></span>');
}
if ($accommodation->getCalefaction()){
$accommodation->setCalefaction('<span class="label quitar-margin-15"><img src="/assets/images/icons/ca-20.png"></span>');
}
if ($accommodation->getPool()){
$accommodation->setPool('<span class="label quitar-margin-15"><img src="/assets/images/icons/po-20.png"></span>');
}
if ($accommodation->getBath()){
$accommodation->setBath('<span class="label quitar-margin-15"><img src="/assets/images/icons/ba-20.png"></span>');
}
if ($accommodation->getCoffeemaker()){
$accommodation->setCoffeemaker('<span class="label quitar-margin-15"><img src="/assets/images/icons/cm-20.png"></span>');
}
if ($accommodation->getKitchen()){
$accommodation->setKitchen('<span class="label quitar-margin-15"><img src="/assets/images/icons/ki-20.png"></span>');
}
if ($accommodation->getWasher()){
$accommodation->setWasher('<span class="label quitar-margin-15"><img src="/assets/images/icons/wa-20.png"></span>');
}
if ($accommodation->getFlattv()){
$accommodation->setFlattv('<span class="label quitar-margin-15"><img src="/assets/images/icons/tv-20.png"></span>');
}
if ($accommodation->getElectrickettle()){
$accommodation->setElectrickettle('<span class="label quitar-margin-15"><img src="/assets/images/icons/ke-20.png"></span>');
}
if ($accommodation->getViews()){
$accommodation->setViews('<span class="label quitar-margin-15"><img src="/assets/images/icons/vi-20.png"></span>');
}
if ($accommodation->getPets()){
$accommodation->setPets('<span class="label quitar-margin-15"><img src="/assets/images/icons/pe-20.png"></span>');
}
// $data_accommodation[]=$accommodation;
$data_accommodation[] = array(
'id' => $accommodation->getId(),
'name' => $accommodation->getName(),
'size' => $accommodation->getSize(),
'quantity' => $accommodation->getQuantity(),
'price' => $accommodation->getPrice(),
'controlId' => $controlctrlDes->getId(),
'minibar' => $accommodation->getMinibar(),
'wifi' => $accommodation->getWifi(),
'airconditioner' => $accommodation->getAirconditioner(),
'calefaction' => $accommodation->getCalefaction(),
'pool' => $accommodation->getPool(),
'bath' => $accommodation->getBath(),
'coffeemaker' => $accommodation->getCoffeemaker(),
'kitchen' => $accommodation->getKitchen(),
'washer' => $accommodation->getWasher(),
'flattv' => $accommodation->getFlattv(),
'electrickettle' => $accommodation->getElectrickettle(),
'views' => $accommodation->getViews(),
'pets' => $accommodation->getPets()
);
}
/* accommodations */
/* menu */
$menus = $em->getRepository(SupplierMenu::class)->findBySupplierId($id);
/* menu Description*/
$data_menu = array();
foreach($menus as $menu){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $menu->getId(),
'servicesCat' => $menu->getControlCat()
));
// $controlctrlDes->getId();
// $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_menu[] = array(
'id' => $menu->getId(),
'title' => $menu->getTitle(),
'description' => $menu->getDescription(),
'currency' => $menu->getCurrency(),
'price' => $menu->getPrice(),
'commission' => $menu->getCommission(),
'iva' => $menu->getIva(),
'controlId' => $controlctrlDes->getId()
);
}
/* lounge */
$lounges = $em->getRepository(SupplierLounge::class)->findBySupplierId($id);
/* lounge Description*/
$data_lounge = array();
foreach($lounges as $lounge){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $lounge->getId(),
'servicesCat' => $lounge->getControlCat()
));
// $controlctrlDes->getId();
// $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_lounge[] = array(
'id' => $lounge->getId(),
'name' => $lounge->getName(),
'currency' => $lounge->getCurrency(),
'price' => $lounge->getPrice(),
'commission' => $lounge->getCommission(),
'iva' => $lounge->getIva(),
'controlId' => $controlctrlDes->getId()
);
}
/* Transport */
$transports = $em->getRepository(SupplierTransport::class)->findBySupplierId($id);
/* Transport Description*/
$data_transport = array();
foreach($transports as $transport){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $transport->getId(),
'servicesCat' => $transport->getControlCat()
));
// $controlctrlDes->getId();
// $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_transport[] = array(
'id' => $transport->getId(),
'name' => $transport->getName(),
'driver' => $transport->getDriver(),
'currency' => $transport->getCurrency(),
'price' => $transport->getPrice(),
'commission' => $transport->getCommission(),
'iva' => $transport->getIva(),
'controlId' => $controlctrlDes->getId()
);
}
/* Guide */
$guides = $em->getRepository(SupplierGuide::class)->findBySupplierId($id);
/* Guide Description*/
$data_guide = array();
foreach($guides as $guide){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $guide->getId(),
'servicesCat' => $guide->getControlCat()
));
// $controlctrlDes->getId();
// $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_guide[] = array(
'id' => $guide->getId(),
'name' => $guide->getName(),
'guide' => $guide->getGuide(),
'currency' => $guide->getCurrency(),
'price' => $guide->getPrice(),
'commission' => $guide->getCommission(),
'iva' => $guide->getIva(),
'controlId' => $controlctrlDes->getId()
);
}
/* Itineraries */
$itinerariess = $em->getRepository(SupplierItineraries::class)->findBySupplierId($id);
/* Itineraries Description*/
$data_itineraries = array();
foreach($itinerariess as $itineraries){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $itineraries->getId(),
'servicesCat' => $itineraries->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_itineraries[] = array(
'id' => $itineraries->getId(),
'title' => $itineraries->getTitle(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* activities */
$activitiess = $em->getRepository(SupplierActivities::class)->findBySupplierId($id);
/* activities Description*/
$data_activities = array();
foreach($activitiess as $activities){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $activities->getId(),
'servicesCat' => $activities->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_activities[] = array(
'id' => $activities->getId(),
'title' => $activities->getTitle(),
'capacity' => $activities->getCapacity(),
'currency' => $activities->getCurrency(),
'price' => $activities->getPrice(),
'commission' => $activities->getCommission(),
'iva' => $activities->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* cruise */
$cruises = $em->getRepository(SupplierCruise::class)->findBySupplierId($id);
/* cruise Description*/
$data_cruise = array();
foreach($cruises as $cruise){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $cruise->getId(),
'servicesCat' => $cruise->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_cruise[] = array(
'id' => $cruise->getId(),
'title' => $cruise->getTitle(),
'currency' => $cruise->getCurrency(),
'price' => $cruise->getPrice(),
'commission' => $cruise->getCommission(),
'iva' => $cruise->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* Av */
$avs = $em->getRepository(SupplierAv::class)->findBySupplierId($id);
/* Av Description*/
$data_av = array();
foreach($avs as $av){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $av->getId(),
'servicesCat' => $av->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_av[] = array(
'id' => $av->getId(),
'name' => $av->getName(),
'responsible' => $av->getResponsible(),
'currency' => $av->getCurrency(),
'price' => $av->getPrice(),
'commission' => $av->getCommission(),
'iva' => $av->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* Creative */
$creatives = $em->getRepository(SupplierCreative::class)->findBySupplierId($id);
/* Creative Description*/
$data_creative = array();
foreach($creatives as $creative){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $creative->getId(),
'servicesCat' => $creative->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_creative[] = array(
'id' => $creative->getId(),
'title' => $creative->getTitle(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* Gifts */
$gifts = $em->getRepository(SupplierGifts::class)->findBySupplierId($id);
/* Gifts Description*/
$data_gifts = array();
foreach($gifts as $gift){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $gift->getId(),
'servicesCat' => $gift->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_gifts[] = array(
'id' => $gift->getId(),
'name' => $gift->getName(),
'responsible' => $gift->getResponsible(),
'currency' => $gift->getCurrency(),
'price' => $gift->getPrice(),
'commission' => $gift->getCommission(),
'iva' => $gift->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* Entertainment */
$entertainments = $em->getRepository(SupplierEntertainment::class)->findBySupplierId($id);
/* Entertainment Description*/
$data_entertainment = array();
foreach($entertainments as $entertainment){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $entertainment->getId(),
'servicesCat' => $entertainment->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_entertainment[] = array(
'id' => $entertainment->getId(),
'name' => $entertainment->getName(),
'responsible' => $entertainment->getResponsible(),
'currency' => $entertainment->getCurrency(),
'price' => $entertainment->getPrice(),
'commission' => $entertainment->getCommission(),
'iva' => $entertainment->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* Others */
$otherss = $em->getRepository(SupplierOthers::class)->findBySupplierId($id);
/* Others Description*/
$data_others = array();
foreach($otherss as $others){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $others->getId(),
'servicesCat' => $others->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_others[] = array(
'id' => $others->getId(),
'name' => $others->getName(),
'responsible' => $others->getResponsible(),
'currency' => $others->getCurrency(),
'price' => $others->getPrice(),
'commission' => $others->getCommission(),
'iva' => $others->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* technology */
if ($idsupplier == 2){ // Es una tecnologia de Develup
$technologys = $em->getRepository(MdvProduct::class)->findAll();
$data_technology = array();
foreach($technologys as $technology){
$data_technology[] = array(
'id' => $technology->getId(),
'title' => $technology->getName(),
'modules' => null,
'type' => $technology->getType(),
'currency' => 'Euro',
'price' => $technology->getPrice(),
'commission' => $technology->getCommission(),
'iva' => $technology->getIva(),
'controlId' => null,
'description' => $technology->getDescription(),
'supplier' => 'Develup',
);
}
} else {
$technologys = $em->getRepository(SupplierTechnology::class)->findBySupplierId($id);
/* technology Description*/
$data_technology = array();
foreach($technologys as $technology){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $technology->getId(),
'servicesCat' => $technology->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_technology[] = array(
'id' => $technology->getId(),
'title' => $technology->getTitle(),
'modules' => $technology->getModules(),
'type' => $technology->getType(),
'currency' => $technology->getCurrency(),
'price' => $technology->getPrice(),
'commission' => $technology->getCommission(),
'iva' => $technology->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/////////////////////////////////////////////////////////////////////
$technologys = $em->getRepository(SupplierTechnology::class)->findBySupplierId($id);
/* technology Description*/
$data_technology = array();
foreach($technologys as $technology){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $technology->getId(),
'servicesCat' => $technology->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_technology[] = array(
'id' => $technology->getId(),
'title' => $technology->getTitle(),
'modules' => $technology->getModules(),
'type' => $technology->getType(),
'currency' => $technology->getCurrency(),
'price' => $technology->getPrice(),
'commission' => $technology->getCommission(),
'iva' => $technology->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
}
/* Assistant */
$assistants = $em->getRepository(SupplierServicesAssistant::class)->findBySupplierId($id);
/* Assistant Description*/
$data_assistant = array();
foreach($assistants as $assistant){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $assistant->getId(),
'servicesCat' => $assistant->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_assistant[] = array(
'id' => $assistant->getId(),
'name' => $assistant->getName(),
'quantity' => $assistant->getQuantity(),
'currency' => $assistant->getCurrency(),
'price' => $assistant->getPrice(),
'commission' => $assistant->getCommission(),
'iva' => $assistant->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* salida de data */
return $this->render('MDS/EventsBundle/services/services-modal-proposal.html.twig', array(
'idcontrol' => $idcontrol,
'accommodations' => $data_accommodation,
'menus' => $data_menu,
'lounges' => $data_lounge,
'transports' => $data_transport,
'guides' => $data_guide,
'itineraries' => $data_itineraries,
'activities' => $data_activities,
'cruises' => $data_cruise,
'avs' => $data_av,
'creatives' => $data_creative,
'gifts' => $data_gifts,
'entertainments' => $data_entertainment,
'technology' => $data_technology,
'assistants' => $data_assistant,
'otherss' => $data_others
));
}
/**
* @Route("proposal/destination/servicesesp/list/{idcontrol}", name="proposal_destination_supplier_especial_list")
*/
public function listEspecialSupplierAction($idcontrol, Request $request) {
$em = $this->getDoctrine()->getManager();
$control = $em->getRepository(ProposalSupplierControl::class)->findOneById($idcontrol);
$idsupplier = $control->getSupplierId();
$cdid = $control->getControlDestinationId();
$ididea = $control->getIdeaId();
$idactivity = $control->getActivityId();
$proposal = $em->getRepository(Proposal::class)->findOneById($control->getProposalId());
if($idsupplier == '0'){
$id = '0';
}else{
if(!is_null($idsupplier)){
/*CONTROL GENERAL*/
$controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneBySupplierId($idsupplier);
$id = $controlgeneral->getId();
}
if(!is_null($idactivity)){
/*CONTROL GENERAL*/
$controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneByActivityId($idactivity);
$id = $controlgeneral->getId();
}
if(!is_null($ididea)){
/*CONTROL GENERAL*/
$controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneByIdeaId($ididea);
$id = $controlgeneral->getId();
}
}
/* accommodations */
$accommodations = $em->getRepository(SupplierAccommodation::class)->findBySupplierId($id);
$data_accommodation = array();
foreach ($accommodations as $accommodation) {
/* Consulta en Control Services */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $accommodation->getId(),
'servicesCat' => $accommodation->getControlCat()
));
//class="label label-flat label-rounded label-icon border-grey text-grey"
if ($accommodation->getMinibar()){
$accommodation->setMinibar('<span class="label quitar-margin-15"><img src="/assets/images/icons/mi-20.png"></span>');
}
if ($accommodation->getWifi()){
$accommodation->setWifi('<span class="label quitar-margin-15"><img src="/assets/images/icons/wi-20.png"></span>');
}
if ($accommodation->getAirconditioner()){
$accommodation->setAirconditioner('<span class="label quitar-margin-15"><img src="/assets/images/icons/ac-20.png"></span>');
}
if ($accommodation->getCalefaction()){
$accommodation->setCalefaction('<span class="label quitar-margin-15"><img src="/assets/images/icons/ca-20.png"></span>');
}
if ($accommodation->getPool()){
$accommodation->setPool('<span class="label quitar-margin-15"><img src="/assets/images/icons/po-20.png"></span>');
}
if ($accommodation->getBath()){
$accommodation->setBath('<span class="label quitar-margin-15"><img src="/assets/images/icons/ba-20.png"></span>');
}
if ($accommodation->getCoffeemaker()){
$accommodation->setCoffeemaker('<span class="label quitar-margin-15"><img src="/assets/images/icons/cm-20.png"></span>');
}
if ($accommodation->getKitchen()){
$accommodation->setKitchen('<span class="label quitar-margin-15"><img src="/assets/images/icons/ki-20.png"></span>');
}
if ($accommodation->getWasher()){
$accommodation->setWasher('<span class="label quitar-margin-15"><img src="/assets/images/icons/wa-20.png"></span>');
}
if ($accommodation->getFlattv()){
$accommodation->setFlattv('<span class="label quitar-margin-15"><img src="/assets/images/icons/tv-20.png"></span>');
}
if ($accommodation->getElectrickettle()){
$accommodation->setElectrickettle('<span class="label quitar-margin-15"><img src="/assets/images/icons/ke-20.png"></span>');
}
if ($accommodation->getViews()){
$accommodation->setViews('<span class="label quitar-margin-15"><img src="/assets/images/icons/vi-20.png"></span>');
}
if ($accommodation->getPets()){
$accommodation->setPets('<span class="label quitar-margin-15"><img src="/assets/images/icons/pe-20.png"></span>');
}
// $data_accommodation[]=$accommodation;
$data_accommodation[] = array(
'id' => $accommodation->getId(),
'name' => $accommodation->getName(),
'size' => $accommodation->getSize(),
'quantity' => $accommodation->getQuantity(),
'price' => $accommodation->getPrice(),
'controlId' => $controlctrlDes->getId(),
'minibar' => $accommodation->getMinibar(),
'wifi' => $accommodation->getWifi(),
'airconditioner' => $accommodation->getAirconditioner(),
'calefaction' => $accommodation->getCalefaction(),
'pool' => $accommodation->getPool(),
'bath' => $accommodation->getBath(),
'coffeemaker' => $accommodation->getCoffeemaker(),
'kitchen' => $accommodation->getKitchen(),
'washer' => $accommodation->getWasher(),
'flattv' => $accommodation->getFlattv(),
'electrickettle' => $accommodation->getElectrickettle(),
'views' => $accommodation->getViews(),
'pets' => $accommodation->getPets()
);
}
/* accommodations */
/* menu */
$menus = $em->getRepository(SupplierMenu::class)->findBySupplierId($id);
/* menu Description*/
$data_menu = array();
foreach($menus as $menu){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $menu->getId(),
'servicesCat' => $menu->getControlCat()
));
// $controlctrlDes->getId();
// $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_menu[] = array(
'id' => $menu->getId(),
'title' => $menu->getTitle(),
'description' => $menu->getDescription(),
'currency' => $menu->getCurrency(),
'price' => $menu->getPrice(),
'commission' => $menu->getCommission(),
'iva' => $menu->getIva(),
'controlId' => $controlctrlDes->getId()
);
}
/* lounge */
$lounges = $em->getRepository(SupplierLounge::class)->findBySupplierId($id);
/* lounge Description*/
$data_lounge = array();
foreach($lounges as $lounge){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $lounge->getId(),
'servicesCat' => $lounge->getControlCat()
));
// $controlctrlDes->getId();
// $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_lounge[] = array(
'id' => $lounge->getId(),
'name' => $lounge->getName(),
'currency' => $lounge->getCurrency(),
'price' => $lounge->getPrice(),
'commission' => $lounge->getCommission(),
'iva' => $lounge->getIva(),
'controlId' => $controlctrlDes->getId()
);
}
/* Transport */
$transports = $em->getRepository(SupplierTransport::class)->findBySupplierId($id);
/* Transport Description*/
$data_transport = array();
foreach($transports as $transport){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $transport->getId(),
'servicesCat' => $transport->getControlCat()
));
// $controlctrlDes->getId();
// $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_transport[] = array(
'id' => $transport->getId(),
'name' => $transport->getName(),
'driver' => $transport->getDriver(),
'currency' => $transport->getCurrency(),
'price' => $transport->getPrice(),
'commission' => $transport->getCommission(),
'iva' => $transport->getIva(),
'controlId' => $controlctrlDes->getId()
);
}
/* Guide */
$guides = $em->getRepository(SupplierGuide::class)->findBySupplierId($id);
/* Guide Description*/
$data_guide = array();
foreach($guides as $guide){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $guide->getId(),
'servicesCat' => $guide->getControlCat()
));
// $controlctrlDes->getId();
// $description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_guide[] = array(
'id' => $guide->getId(),
'name' => $guide->getName(),
'guide' => $guide->getGuide(),
'currency' => $guide->getCurrency(),
'price' => $guide->getPrice(),
'commission' => $guide->getCommission(),
'iva' => $guide->getIva(),
'controlId' => $controlctrlDes->getId()
);
}
/* Itineraries */
$itinerariess = $em->getRepository(SupplierItineraries::class)->findBySupplierId($id);
/* Itineraries Description*/
$data_itineraries = array();
foreach($itinerariess as $itineraries){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $itineraries->getId(),
'servicesCat' => $itineraries->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_itineraries[] = array(
'id' => $itineraries->getId(),
'title' => $itineraries->getTitle(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* activities */
$activitiess = $em->getRepository(SupplierActivities::class)->findBySupplierId($id);
/* activities Description*/
$data_activities = array();
foreach($activitiess as $activities){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $activities->getId(),
'servicesCat' => $activities->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_activities[] = array(
'id' => $activities->getId(),
'title' => $activities->getTitle(),
'capacity' => $activities->getCapacity(),
'currency' => $activities->getCurrency(),
'price' => $activities->getPrice(),
'commission' => $activities->getCommission(),
'iva' => $activities->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* cruise */
$cruises = $em->getRepository(SupplierCruise::class)->findBySupplierId($id);
/* cruise Description*/
$data_cruise = array();
foreach($cruises as $cruise){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $cruise->getId(),
'servicesCat' => $cruise->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_cruise[] = array(
'id' => $cruise->getId(),
'title' => $cruise->getTitle(),
'currency' => $cruise->getCurrency(),
'price' => $cruise->getPrice(),
'commission' => $cruise->getCommission(),
'iva' => $cruise->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* Av */
if ($idsupplier == 80){
// El proveedor del AV es AvExpress
// Listamos por orden alfabetico y se deja de primero a "Otro servicio"
$parameters = array();
$dql = 'SELECT i
FROM AvexpressBundle:AveProduct i
ORDER BY i.name ASC';
$query = $em->createQuery($dql)->setParameters($parameters);
$avs = $query->getResult();
$newAvs = array();
foreach ($avs as $key => $item) {
if ($item->getName() == 'Otro servicio'){
$item->setName('0 - Otro servicio');
$newAvs = array($item);
unset($avs[$key]);
foreach ($avs as $keyTwo => $elem){
$ind = $keyTwo + 1;
$elem->setName($ind.' - '.$elem->getName());
array_push($newAvs,$elem);
}
}
}
$avs = $newAvs;
/* av Description*/
$data_av = array();
foreach($avs as $av){
$data_av[] = array(
'id' => $av->getId(),
'name' => $av->getName(),
// 'modules' => $technology->getModules(),
'modules' => null,
'type' => $av->getType(),
'currency' => 'Euro',
'price' => $av->getPrice(),
'commission' => 0,
'iva' => 21,
'controlId' => null,
'description' => $av->getDescription(),
'supplier' => 'AvExpress',
);
}
// ***************************************** METEMOS AV TEMPLATES (Tipo: AVExpress Template)
$parameters = array();
$dql = 'SELECT i
FROM AvexpressBundle:AveTemplate i
ORDER BY i.name ASC';
$query = $em->createQuery($dql)->setParameters($parameters);
$avsTemplate = $query->getResult();
foreach($avsTemplate as $av){
$data_av[] = array(
'id' => $av->getId(),
'name' => $av->getName(),
'modules' => null,
'type' => 'AVExpress Template',
'currency' => null,
'price' => null,
'commission' => null,
'iva' => null,
'controlId' => null,
'description' => null,
'supplier' => 'AvExpress',
);
}
} else {
$newAvs = array();
$avs = $em->getRepository(SupplierAv::class)->findBySupplierId($id);
/* Av Description*/
$data_av = array();
foreach($avs as $av){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $av->getId(),
'servicesCat' => $av->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_av[] = array(
'id' => $av->getId(),
'name' => $av->getName(),
'responsible' => $av->getResponsible(),
'currency' => $av->getCurrency(),
'price' => $av->getPrice(),
'commission' => $av->getCommission(),
'iva' => $av->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
}
/* Creative */
$creatives = $em->getRepository(SupplierCreative::class)->findBySupplierId($id);
/* Creative Description*/
$data_creative = array();
foreach($creatives as $creative){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $creative->getId(),
'servicesCat' => $creative->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_creative[] = array(
'id' => $creative->getId(),
'title' => $creative->getTitle(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* Gifts */
$gifts = $em->getRepository(SupplierGifts::class)->findBySupplierId($id);
/* Gifts Description*/
$data_gifts = array();
foreach($gifts as $gift){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $gift->getId(),
'servicesCat' => $gift->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_gifts[] = array(
'id' => $gift->getId(),
'name' => $gift->getName(),
'responsible' => $gift->getResponsible(),
'currency' => $gift->getCurrency(),
'price' => $gift->getPrice(),
'commission' => $gift->getCommission(),
'iva' => $gift->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* Entertainment */
$entertainments = $em->getRepository(SupplierEntertainment::class)->findBySupplierId($id);
/* Entertainment Description*/
$data_entertainment = array();
foreach($entertainments as $entertainment){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $entertainment->getId(),
'servicesCat' => $entertainment->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_entertainment[] = array(
'id' => $entertainment->getId(),
'name' => $entertainment->getName(),
'responsible' => $entertainment->getResponsible(),
'currency' => $entertainment->getCurrency(),
'price' => $entertainment->getPrice(),
'commission' => $entertainment->getCommission(),
'iva' => $entertainment->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* Others */
$otherss = $em->getRepository(SupplierOthers::class)->findBySupplierId($id);
/* Others Description*/
$data_others = array();
foreach($otherss as $others){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $others->getId(),
'servicesCat' => $others->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_others[] = array(
'id' => $others->getId(),
'name' => $others->getName(),
'responsible' => $others->getResponsible(),
'currency' => $others->getCurrency(),
'price' => $others->getPrice(),
'commission' => $others->getCommission(),
'iva' => $others->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* technology */
if ($idsupplier == 2){ // Es una tecnologia de Develup
// $technologys = $em->getRepository(MdvProduct::class)->findAll();
// Listamos por orden alfabetico y se deja de primero a "Otro servicio"
$parameters = array();
$dql = 'SELECT i
FROM DevelupBundle:MdvProduct i
ORDER BY i.name ASC';
$query = $em->createQuery($dql)->setParameters($parameters);
$technologys = $query->getResult();
$newTechnologys = array();
foreach ($technologys as $key => $item) {
if ($item->getName() == 'Otro servicio'){
$item->setName('0 - Otro servicio');
$newTechnologys = array($item);
unset($technologys[$key]);
foreach ($technologys as $keyTwo => $elem){
$ind = $keyTwo + 1;
$elem->setName($ind.' - '.$elem->getName());
array_push($newTechnologys,$elem);
}
}
}
$technologys = $newTechnologys;
/* technology Description*/
$data_technology = array();
foreach($technologys as $technology){
$data_technology[] = array(
'id' => $technology->getId(),
'title' => $technology->getName(),
// 'modules' => $technology->getModules(),
'modules' => null,
'type' => $technology->getType(),
'currency' => 'Euro',
'price' => $technology->getPrice(),
'commission' => 0,
'iva' => 21,
'controlId' => null,
'description' => $technology->getDescription(),
'supplier' => 'Develup',
);
}
} else {
$technologys = $em->getRepository(SupplierTechnology::class)->findBySupplierId($id);
$newTechnologys = array();
/* technology Description*/
$data_technology = array();
foreach($technologys as $technology){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $technology->getId(),
'servicesCat' => $technology->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_technology[] = array(
'id' => $technology->getId(),
'title' => $technology->getTitle(),
'modules' => $technology->getModules(),
'type' => $technology->getType(),
'currency' => $technology->getCurrency(),
'price' => $technology->getPrice(),
'commission' => $technology->getCommission(),
'iva' => $technology->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
}
/* Assistant */
$assistants = $em->getRepository(SupplierServicesAssistant::class)->findBySupplierId($id);
/* Assistant Description*/
$data_assistant = array();
foreach($assistants as $assistant){
/* Consulta en Control Description */
$controlctrlDes = $em->getRepository(SupplierServicesControl::class)->findOneBy( array(
'servicesId' => $assistant->getId(),
'servicesCat' => $assistant->getControlCat()
));
//$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
$data_assistant[] = array(
'id' => $assistant->getId(),
'name' => $assistant->getName(),
'quantity' => $assistant->getQuantity(),
'currency' => $assistant->getCurrency(),
'price' => $assistant->getPrice(),
'commission' => $assistant->getCommission(),
'iva' => $assistant->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* salida de data */
return $this->render('MDS/EventsBundle/services/services-supplier-esp-proposal.html.twig', array(
'cdid' => $cdid,
'id' => $proposal->getId(),
'proname' => $proposal->getName(),
'token' => $proposal->getAccessKey(),
'mcp' => $proposal->getMcp(),
'proposal' => $proposal,
'idcontrol' => $idcontrol,
'accommodations' => $data_accommodation,
'menus' => $data_menu,
'lounges' => $data_lounge,
'transports' => $data_transport,
'guides' => $data_guide,
'itineraries' => $data_itineraries,
'activities' => $data_activities,
'cruises' => $data_cruise,
'avs' => $data_av,
'creatives' => $data_creative,
'gifts' => $data_gifts,
'entertainments' => $data_entertainment,
'technology' => $data_technology,
'newTechnologys' => $newTechnologys,
'newAvs' => $newAvs,
'assistants' => $data_assistant,
'otherss' => $data_others
));
}
/* CREAR DESDE Discount */
private function createDiscountCreateForm(ProposalDiscount $entity)
{
$form = $this->createForm(ProposalDiscountType::class, $entity, array(
'action' => $this->generateUrl('proposal_discount_create'),
'method' => 'POST'
));
return $form;
}
/**
* @Route("/proposal/discount/create", name="proposal_discount_create")
*/
public function createDiscountAction(Request $request)
{
$controlid = $request->request->get('control')['id'];
$em = $this->getDoctrine()->getManager();
$discount = new ProposalDiscount();
$form = $this->createDiscountCreateForm($discount);
$form->handleRequest($request);
$serviceId = $form->get('serviceId')->getData();
if(!is_null($serviceId)){
$discount->setServiceId($serviceId->getId());
}else{
$discount->setServiceId(null);
}
if($form->isValid())
{
/* Obtengo usuario logueado */
$user_logueado = $this->get('security.token_storage')->getToken()->getUser();
$user_id = $user_logueado->getId();
$discount->setCreatedId($user_id);
$discount->setUpdatedId($user_id);
$em->persist($discount);
$em->flush();
}
return $this->redirectToRoute('proposal_destination_supplier_view',
array(
'id' => $controlid,
'_fragment' => 'd1'
)
);
}
/**
* @Route("/proposal/discount/delete/{controlid}/{id}", name="proposal_discount_delete")
*/
public function deleteDiscountAction($controlid, $id, Request $request)
{
$em = $this->getDoctrine()->getManager();
$delete= $em->getRepository(ProposalDiscount::class)->findOneById($id);
$em->remove($delete);
$em->flush();
return $this->redirectToRoute('proposal_destination_supplier_view',
array(
'id' => $controlid
)
);
}
/**
* @Route("/proposal/fee/create", name="proposal_fee_create")
*/
public function createFeeAction(Request $request){
$controlid = $request->request->get('control')['id'];
/* Obtengo usuario logueado */
$user_logueado = $this->get('security.token_storage')->getToken()->getUser();
$user_id = $user_logueado->getId();
$em = $this->getDoctrine()->getManager();
$proposalId = $request->request->get('proposal_id');
$proposal = $em->getRepository(Proposal::class)->findOneById($proposalId);
$oldFee = $em->getRepository(ProposalFee::class)->findOneByProposalId($proposalId);
if (!empty($oldFee)){
if ($oldFee->getToInvoice() == 0){
// Habia un Fee que se cargo en los servicios
$this->eliminarFeeOculto($oldFee->getId());
}
$oldFee->setName($request->request->get('nameFee'));
$oldFee->setType($request->request->get('typeFee'));
$oldFee->setAmount($request->request->get('amountFee'));
$oldFee->setToInvoice($request->request->get('toInvoiceFee'));
$oldFee->setUpdatedId($user_id);
$oldFee->setUpdatedAt(new \DateTime("now"));
if ($proposal->getStatus() != 'Invoiced') {
$em->persist($oldFee);
$em->flush();
if(!$oldFee->getToInvoice()){
// Es un Fee oculto se deben modificar los servicios
$this->agregarFeeOculto($oldFee->getId());
}
}
} else {
$newFee = new ProposalFee();
$newFee->setProposalId($proposalId);
$newFee->setName($request->request->get('nameFee'));
$newFee->setType($request->request->get('typeFee'));
$newFee->setAmount($request->request->get('amountFee'));
$newFee->setToInvoice($request->request->get('toInvoiceFee'));
$newFee->setOpIva('1');
$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
if ($request->request->get('typeFee') == 0){ $newFee->setFeeTotal(0); } else { $newFee->setFeeTotal($request->request->get('amountFee') * 1.21); }
$newFee->setCreatedId($user_id);
$newFee->setUpdatedId($user_id);
$newFee->setCreatedAt(new \DateTime("now"));
$newFee->setUpdatedAt(new \DateTime("now"));
// Solo se creará el Fee si no se ha facturado
if ($proposal->getStatus() != 'Invoiced') {
$em->persist($newFee);
$em->flush();
if(!$newFee->getToInvoice()){
// Es un Fee oculto se deben modificar los servicios
$this->agregarFeeOculto($newFee->getId());
}
}
}
return $this->redirectToRoute('proposal_destination_supplier_view',
array(
'id' => $controlid,
'_fragment' => 'f1'
)
);
}
/**
* @Route("/proposal/fee/delete/{controlid}/{id}", name="proposal_fee_delete")
*/
public function deleteFeeAction($controlid, $id, Request $request)
{
$em = $this->getDoctrine()->getManager();
$fee = $em->getRepository(ProposalFee::class)->findOneById($id);
if (!empty($fee)){
$proposal = $em->getRepository(Proposal::class)->findOneById($fee->getProposalId());
if ($fee->getToInvoice() == 0){
// Habia un Fee que se cargo en los servicios
$this->eliminarFeeOculto($fee->getId());
}
if ($proposal->getStatus() != 'Invoiced') {
$em->remove($fee);
$em->flush();
}
}
return $this->redirectToRoute('proposal_destination_supplier_view',
array(
'id' => $controlid,
'_fragment' => 'f1'
)
);
}
private function agregarFeeOculto( $idFee )
{
// Se agregara un fee en los servicios
$em = $this->getDoctrine()->getManager();
$fee = $em->getRepository(ProposalFee::class)->findOneById($idFee);
$prpSupServices = $em->getRepository(ProposalSupplierServices::class)->findByProposalId($fee->getProposalId());
foreach ($prpSupServices as $service){
if ($fee->getType() == 0){
// Fee de %
if ($service->getOpCommission() == 1){
// La Comision es positiva
$comision = $fee->getAmount() + $service->getCommission();
$service->setCommission($comision);
} else {
// La Comision es negativa, no se puede alterar la comision por ende el porcentaje se calculará y añadirá en el over
$comision = $service->getPrice() * ( $fee->getAmount() / 100 );
$comision = $comision + $service->getOver();
$service->setOver($comision);
}
$em->persist($service);
$em->flush();
// Si es un servicio ya confirmado debemos modificar tambien ProposalSupplierServicesCost y en ProposalSupplierServicesCostClient
$prpSupSrvCosts = $em->getRepository(ProposalSupplierServicesCosts::class)->findOneByServicesId($service->getId());
if (!empty($prpSupSrvCosts)){
$prpSupSrvCosts->setCommission($service->getCommission());
$em->persist($prpSupSrvCosts);
$em->flush();
}
$prpSupSrvCostsClient = $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($service->getId());
if (!empty($prpSupSrvCostsClient)){
$prpSupSrvCostsClient->setCommission($service->getCommission());
$prpSupSrvCostsClient->setOver($service->getOver());
$em->persist($prpSupSrvCostsClient);
$em->flush();
}
} else {
// Fee de €
if ($service->getOpOver() == 1){
// El Over es positivo
$over = $fee->getAmount() + $service->getOver();
$service->setOver($over);
} else {
// El Over es negativo,
if ($service->getOver() > $fee->getAmount()){
// Se mantendra el signo negativo del over. La cantidad de over negativo es superior al fee que agregamos
$service->setOver($service->getOver() - $fee->getAmount());
} else {
// Se cambiara el signo del over. La cantidad de over negativo es inferior o igual all fee que agregamos
$service->setOver($fee->getAmount() - $service->getOver());
$service->setOpOver(1);
}
}
$em->persist($service);
$em->flush();
// Si es un servicio ya confirmado debemos modificar tambien ProposalSupplierServicesCostClient (NO APLICA EN ProposalSupplierServicesCost)
$prpSupSrvCostsClient = $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($service->getId());
if (!empty($prpSupSrvCostsClient)){
$prpSupSrvCostsClient->setOver($service->getOver());
$em->persist($prpSupSrvCostsClient);
$em->flush();
}
}
}
return true;
}
private function eliminarFeeOculto( $idFee )
{
// No se eliminara el Fee, solo se quitara el monto de los servicios
$em = $this->getDoctrine()->getManager();
$fee = $em->getRepository(ProposalFee::class)->findOneById($idFee);
$prpSupServices = $em->getRepository(ProposalSupplierServices::class)->findByProposalId($fee->getProposalId());
foreach ($prpSupServices as $service){
if ($fee->getType() == 0){
// Fee de %
if ($service->getOpCommission() == 1){
// La Comision es positiva
$comision = abs($service->getCommission() - $fee->getAmount());
$service->setCommission($comision);
} else {
// La Comision es negativa, no se puede alterar la comision
}
$em->persist($service);
$em->flush();
// Si es un servicio ya confirmado debemos modificar tambien ProposalSupplierServicesCost y en ProposalSupplierServicesCostClient
$prpSupSrvCosts = $em->getRepository(ProposalSupplierServicesCosts::class)->findOneByServicesId($service->getId());
if (!empty($prpSupSrvCosts)){
$prpSupSrvCosts->setCommission($service->getCommission());
$em->persist($prpSupSrvCosts);
$em->flush();
}
$prpSupSrvCostsClient = $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($service->getId());
if (!empty($prpSupSrvCostsClient)){
$prpSupSrvCostsClient->setCommission($service->getCommission());
$prpSupSrvCostsClient->setOver($service->getOver());
$em->persist($prpSupSrvCostsClient);
$em->flush();
}
} else {
// Fee de €
if ($service->getOpOver() == 1){
// El Over es positivo
$over = abs($service->getOver() - $fee->getAmount());
$service->setOver($over);
} else {
// El Over es negativo,
if ($service->getOver() > $fee->getAmount()){
} else {
}
}
$em->persist($service);
$em->flush();
// Si es un servicio ya confirmado debemos modificar tambien ProposalSupplierServicesCostClient (NO APLICA EN ProposalSupplierServicesCost)
$prpSupSrvCostsClient = $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($service->getId());
if (!empty($prpSupSrvCostsClient)){
$prpSupSrvCostsClient->setOver($service->getOver());
$em->persist($prpSupSrvCostsClient);
$em->flush();
}
}
}
return true;
}
/**
* @Route("/proposal/summary/create", name="proposal_summary_create")
*/
public function createSummaryAction(Request $request){
$controlid = $request->request->get('control')['id'];
$em = $this->getDoctrine()->getManager();
$proposalId = $request->request->get('proposal_id');
$proposal = $em->getRepository(Proposal::class)->findOneById($proposalId);
$oldSummary = $em->getRepository(ProposalsInvoiceSummary::class)->findOneByProposalId($proposalId);
$newSummary = $request->request->get('descriptionSummary');
if (!empty($oldSummary)){
if (!empty($newSummary) and ($proposal->getStatus() != 'Invoiced')){
$oldSummary->setDescription($newSummary);
$em->persist($oldSummary);
$em->flush();
} else {
if (empty($newSummary) and ($proposal->getStatus() != 'Invoiced')){
// Si viene vacÃo se elimina el resumen para obetener una factura completa
$em->remove($oldSummary);
$em->flush();
}
}
} else {
$newSumm = new ProposalsInvoiceSummary();
$newSumm->setDescription($newSummary);
$newSumm->setProposalId($proposalId);
$newSumm->setNet(null);
$newSumm->setCurrency(null);
$newSumm->setVatTen(null);
$newSumm->setVatTwentyOne(null);
$newSumm->setPayments(null);
// Solo se creará el Summary si no se ha facturado
if (($proposal->getStatus() != 'Invoiced') and !empty($newSummary)) {
$em->persist($newSumm);
$em->flush();
}
}
return $this->redirectToRoute('proposal_destination_supplier_view',
array(
'id' => $controlid,
'_fragment' => 'summary1'
)
);
}
/**
* @Route("proposal/destination/services/block/{id}", name="proposal_destination_supplier_services_block")
*/
public function udatedBlockAction($id, Request $request)
{
$block = $request->request->get('block');
$em = $this->getDoctrine()->getManager();
$services_control = $em->getRepository(ProposalSupplierControl::class)->findOneById($id);
if (!empty($block['dateBlockLimit']) and !empty($block['timeBlockLimit'])){
$services_control->setDateBlockLimit(new \DateTime($block['dateBlockLimit'].' '.$block['timeBlockLimit'] ));
$services_supplier_proposal = $em->getRepository(ProposalSupplierServices::class)->findByControlId($services_control->getId());
foreach($services_supplier_proposal as $servicessupplierproposal) {
$servicessupplierproposal->setDateBlockLimit(new \DateTime($block['dateBlockLimit'] . ' ' . $block['timeBlockLimit']));
$servicessupplierproposal->setStatus('Block');
$em->persist($servicessupplierproposal);
$em->flush();
}
$em->persist($services_control);
$em->flush();
$event = 'The Block supplier updated in Destination Proposal.';
$successMessage = $this->translator->trans($event);
$this->addFlash('mensajeproposaldestinationservices', $successMessage);
}else{
$errorMessage = $this->translator->trans('Error');
$this->addFlash('mensajeproposaldestinationservicesrror', $errorMessage);
}
return $this->redirectToRoute('proposal_destination_supplier_view',
array(
'id' => $services_control->getControlDestinationId(),
'_fragment' => 's'.$id
)
);
}
/**
* @Route("/multichckservices", name="multichckservices")
*/
public function multiChckServicesAction(Request $request) {
$idSupplier = $_POST['idSupplier'];
$idService = $_POST['idService'];
/* Obtengo usuario logueado */
$user_logueado = $this->get('security.token_storage')->getToken()->getUser();
$user_id = $user_logueado->getId();
$user_role = $user_logueado->getRole();
$em = $this->getDoctrine()->getManager();
$services = $em->getRepository(ProposalSupplierServices::class)->findOneById($idService);
// INICIO: Buscamos el proposal para verificar que no este bloqueado o facturado
$propId = $services->getProposalId();
$proposal = $em->getRepository(Proposal::class)->findOneById($propId);
// FIN :Buscamos el proposal para verificar que no este bloqueado o facturado
if (!empty($services)){
if ($services->getStatus()== 'Pending') {
$services->setStatus('Confirmed');
$services->setUpdatedId($user_id);
} else {
$services->setStatus('Pending');
$services->setUpdatedId($user_id);
}
try{
if (!empty($proposal)){
if (($proposal->getStatus() == 'Invoiced') or ($proposal->getStatus() == 'Blocked')) {
// De ser un expediente Facturado o bloqueado no se hace modificacion
} else {
if (empty($services->getSupplierId())){
$services->setSupplierId(4);
}
$em->persist($services);
$em->flush();
/* Para dentro de ProposalSupplierControl */
if (!empty($services->getSupplierId())){
$controlctrlDes = $em->getRepository(ProposalSupplierControl::class)->findOneBy( array(
'supplierId' => $services->getSupplierId(),
'proposalId' => $services->getProposalId()
));
} else {
$controlctrlDes = $em->getRepository(ProposalSupplierControl::class)->findOneBy( array(
'supplierId' => 4,
'proposalId' => $services->getProposalId()
));
}
// Si el control se encuentra vacio, se debe crear uno nuevo
if (empty($controlctrlDes)){
$controlctrlDes = new ProposalSupplierControl();
$controlctrlDes->setControlDestinationId($services->getDestinationId()); // Falta corregir el ControlDestinationId ahora tiene el Id del destino
$controlctrlDes->setProposalId($services->getProposalId());
$controlctrlDes->setDestinoId($services->getDestinationId());
$controlctrlDes->setSupplierId(4);
$controlctrlDes->setStatus('Pending');
$em->persist($controlctrlDes);
$em->flush();
}
//COLOR POR SERVICIO
$contcolor ="";
switch ($services->getServiceCatName()) {
case "Accommodation":
$contcolor = 'teal';
break;
case "Menu" :
$contcolor = 'purple';
break;
case "Lounge":
$contcolor = 'warning';
break;
case "Activities":
$contcolor = 'blue';
break;
case "Itineraries":
$contcolor = 'indigo';
break;
case "Cruise":
$contcolor = 'brown';
break;
case "Transport":
$contcolor = 'grey';
break;
case "Av":
$contcolor = 'slate';
break;
case "Creative":
$contcolor = 'orange';
break;
case "Gifts":
$contcolor = 'pink';
break;
case "Entertainment":
$contcolor = 'green';
break;
case "Guide":
$contcolor = 'orange';
break;
case "Others":
$contcolor = 'danger';
break;
case "Technology":
$contcolor = 'slate-800';
break;
case "Assistant":
$contcolor = 'indigo-800';
break;
case "DDR":
$contcolor = 'green-300';
break;
}
/* Para dentro de ProposalSupplierServicesCostsClient */
$costsClient = new ProposalSupplierServicesCostsClient();
$costsClient->setServiceIdProposal($services->getId());
$costsClient->setServiceIdFather($services->getServiceIdFather());
$costsClient->setControlId($controlctrlDes->getId());
// if (empty($services->getSupplierId())){$costsClient->setControlId(14244);} else {$costsClient->setControlId($services->getControlId());}
$costsClient->setProposalId($services->getProposalId());
$costsClient->setDestinationId($services->getDestinationId());
if (empty($services->getSupplierId())){$costsClient->setSupplierId('4');} else {$costsClient->setSupplierId($services->getSupplierId());}
$costsClient->setAssistantId($services->getAssistantId());
$costsClient->setIdeaId($services->getIdeaId());
$costsClient->setActivityId($services->getActivityId());
$costsClient->setServiceId($services->getServiceId());
$costsClient->setServiceCatId($services->getServiceCatId());
$costsClient->setServiceCatName($services->getServiceCatName());
$costsClient->setName($services->getName());
$costsClient->setPrice($services->getPrice());
$costsClient->setCurrency($services->getCurrency());
$costsClient->setUnits($services->getUnits());
$costsClient->setOpCommission($services->getOpCommission());
$costsClient->setCommission($services->getCommission());
$costsClient->setOpOver($services->getOpOver());
$costsClient->setOver($services->getOver());
$costsClient->setOpIva($services->getOpIva());
$costsClient->setIva($services->getIva());
$costsClient->setPax($services->getPax());
$costsClient->setHour($services->getHour());
$costsClient->setDateInAt($services->getDateInAt());
$costsClient->setDateOutAt($services->getDateOutAt());
$costsClient->setRank($services->getRank());
$costsClient->setCreatedId($user_id);
$costsClient->setUpdatedId($user_id);
$costsClient->setContcolor($contcolor);
$costsClient->setRenovate('0');
$em->persist($costsClient);
$em->flush();
}
}
} catch (\Exception $e){
}
}
$return = array(
'services' => $services,
);
$response = new JsonResponse($return);
return $response;
}
/**
* @Route("proposal/destination/services/listmultiple/{idcontrol}", name="proposal_destination_supplier_list_multiple")
*/
public function listMultipleAction($idcontrol, Request $request) {
$em = $this->getDoctrine()->getManager();
$control = $em->getRepository(ProposalSupplierControl::class)->findOneById($idcontrol);
$idsupplier = $control->getSupplierId();
$idMemorySupplier = $idsupplier;
$ididea = $control->getIdeaId();
$idactivity = $control->getActivityId();
if($idsupplier == '0'){
$id = '0';
}else{
if(!empty($idsupplier)){
/*CONTROL GENERAL*/
$controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneBySupplierId($idsupplier);
$id = $controlgeneral->getId();
}
if(!empty($idactivity)){
/*CONTROL GENERAL*/
$controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneByActivityId($idactivity);
$id = $controlgeneral->getId();
}
if(!empty($ididea)){
/*CONTROL GENERAL*/
$controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneByIdeaId($ididea);
$id = $controlgeneral->getId();
}
}
if (!empty($control)){
$idProposal = $control->getProposalId();
$proposal = $em->getRepository(Proposal::class)->findOneById($idProposal);
// Buscamos a partir del IDCONTROL los elementos principales (Proveedores, Actividades, Ideas) agregados al destino para la carga multiple
$destinoId = $control->getDestinoId();
$servicesControllers = $em->getRepository(ProposalSupplierControl::class)->findBy(
array(
'proposalId' => $proposal,
'destinoId' => $destinoId
)
);
//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
$tempKey = null;
$logicKey = false;
foreach ($servicesControllers as $key => $item) {
if(($item->getSupplierId() == 0) and (empty($item->getActivityId())) and (empty($item->getIdeaId()))){
// Es un white service, se guarda el indice para luego procesar
$tempKey = $key;
$logicKey = true;
}
if(!empty($item->getSupplierId()) and ($item->getSupplierId() != 0)){
// Es un proveedor ordinario
$tempSup = $em->getRepository(Supplier::class)->findOneById($item->getSupplierId());
$servicesControllers[$key]->setStatus($tempSup->getName());
}
if (!empty($item->getActivityId())){
// Es Actividad
$tempAct = $em->getRepository(Activities::class)->findOneById($item->getActivityId());
$servicesControllers[$key]->setStatus($tempAct->getName());
}
if (!empty($item->getIdeaId())) {
// Es Idea
$tempIdea = $em->getRepository(Ideas::class)->findOneById($item->getIdeaId());
$servicesControllers[$key]->setStatus($tempIdea->getName());
}
}
if($logicKey){
$servicesControllers[$tempKey]->setStatus('SERVICIO SIN PROVEEDOR');
array_push($servicesControllers,$servicesControllers[$tempKey]);
unset($servicesControllers[$tempKey]);
}
//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
}
// LIMPIEZA DE DATOS PARA LA VISTA
if (!($idMemorySupplier === 0)){// el === evalua correctamente el caso de nulo
$newServicesControllers = array();
foreach ($servicesControllers as $item){
if (intval($idcontrol) === $item->getId()){
$newServicesControllers[] = $item;
}
}
$servicesControllers = $newServicesControllers;
}
if (sizeof($servicesControllers) == 1){
$numElementos = 10;
} else {
$numElementos = 5;
}
/* salida de data */
return $this->render('MDS/EventsBundle/services/services-multiple-modal-proposal.html.twig', array(
// return $this->render('MDS/EventsBundle/services/services-multiple-add-destination-proposal.html.twig', array(
'idcontrol' => $idcontrol,
'servicesControllers' => $servicesControllers,
'id' => $idProposal,
'proposal' => $proposal,
'numElementos' => $numElementos,
'token' => $proposal->getAccessKey(),
'mcp' => null,
'datasupplier' => null,
'discounts' => null,
'status' => null,
'global_calculos' => null,
'accommodations' => '',
'menus' => '',
'lounges' => '',
'transports' => '',
'guides' => '',
'itineraries' => '',
'activities' => '',
'cruises' => '',
'avs' => '',
'creatives' => '',
'gifts' => '',
'entertainments' => '',
'technology' => '',
'assistants' => '',
'otherss' => ''
));
}
/**
* @Route("proposal/destination/services/createmultiple", name="proposal_destination_supplier_create_multiple")
*/
public function createMultipleAction(Request $request) {
$add_services_multiple_type = $request->request->get('add_services_multiple_type');
$add_services_multiple_name = $request->request->get('add_services_multiple_name');
$add_services_multiple_price = $request->request->get('add_services_multiple_price');
$add_services_multiple_commission = $request->request->get('add_services_multiple_commission');
$add_services_multiple_over = $request->request->get('add_services_multiple_over');
$add_services_multiple_iva = $request->request->get('add_services_multiple_iva');
$em = $this->getDoctrine()->getManager();
/* Obtengo usuario logueado */
$user_logueado = $this->get('security.token_storage')->getToken()->getUser();
$user_id = $user_logueado->getId();
// INICIO: Generamos un arreglo con todos los servicios a agregar
$newServices = array();
foreach ($add_services_multiple_type as $key1 => $item) {
foreach ($item as $key2 => $elem){
$newServ = new ProposalSupplierServices();
$newServ->setControlId($key1);
$controlTemp = $em->getRepository(ProposalSupplierControl::class)->findOneById($key1);
$proposal_data = $em->getRepository(Proposal::class)->findOneById($controlTemp->getProposalId());
switch ($elem['type']) {
case 1:
$newServ->setServiceCatId('1');
$newServ->setServiceCatName('Accommodation');
break;
case 2:
$newServ->setServiceCatId('2');
$newServ->setServiceCatName('Activities');
break;
case 3:
$newServ->setServiceCatId('3');
$newServ->setServiceCatName('Av');
break;
case 4:
$newServ->setServiceCatId('4');
$newServ->setServiceCatName('Creative');
break;
case 5:
$newServ->setServiceCatId('5');
$newServ->setServiceCatName('Cruise');
break;
case 6:
$newServ->setServiceCatId('6');
$newServ->setServiceCatName('Entertainment');
break;
case 7:
$newServ->setServiceCatId('7');
$newServ->setServiceCatName('Gifts');
break;
case 8:
$newServ->setServiceCatId('8');
$newServ->setServiceCatName('Guide');
break;
case 9:
$newServ->setServiceCatId('9');
$newServ->setServiceCatName('Itineraries');
break;
case 10:
$newServ->setServiceCatId('10');
$newServ->setServiceCatName('Lounge');
break;
case 11:
$newServ->setServiceCatId('11');
$newServ->setServiceCatName('Menu');
break;
case 12:
$newServ->setServiceCatId('12');
$newServ->setServiceCatName('Others');
break;
case 13:
$newServ->setServiceCatId('13');
$newServ->setServiceCatName('Transport');
break;
case 14:
$newServ->setServiceCatId('14');
$newServ->setServiceCatName('Technology');
break;
case 15:
$newServ->setServiceCatId('15');
$newServ->setServiceCatName('Assistant');
break;
case 16:
$newServ->setServiceCatId('16');
$newServ->setServiceCatName('DDR');
break;
case 17:
// $newServ->setServiceCatId('17');
// $newServ->setServiceCatName('AV - EXPRESS');
// $newServ->setSupplierId('80');
//
// $control = new ProposalSupplierControl();
// $control->setSupplierId('80');
// $control->setStatus('Pending');
// $control->setControlDestinationId($cid);
// $control->setProposalId($pid);
// $control->setDestinoId($did);
// $em->persist($control);
// $em->flush();
// $event = 'The Supplier Destination Proposal has been created.';
// $successMessage = $this->translator->trans($event);
// $this->addFlash('mensajeproposaldestinationservices', $successMessage);
//
// return $this->redirectToRoute('proposal_destination_supplier_list', array(
// 'idcontrol' => $cid
// ));
$newServ->setServiceCatId('');
$newServ->setServiceCatName('');
break;
default:
$newServ->setServiceCatId('');
$newServ->setServiceCatName('');
break;
}
$newServ->setName($add_services_multiple_name[$key1][$key2]['name']);
// $newServ->setPrice($add_services_multiple_price[$key1][$key2]['price']);
if (empty($add_services_multiple_price[$key1][$key2]['price'])){
// Se pone el precio a 0 si viene vacio
$newServ->setPrice('0');
} else {
$newServ->setPrice($add_services_multiple_price[$key1][$key2]['price']);
}
if (empty($add_services_multiple_commission[$key1][$key2]['commission'])){
// Se pone la commission en 0 si viene vacio
$newServ->setCommission('0');
} else {
$newServ->setCommission($add_services_multiple_commission[$key1][$key2]['commission']);
}
if (empty($add_services_multiple_over[$key1][$key2]['over'])){
// Se pone el over en 0 si viene vacio
$newServ->setOver('0');
} else {
$newServ->setOver($add_services_multiple_over[$key1][$key2]['over']);
}
if (empty($add_services_multiple_iva[$key1][$key2]['iva'])){
// Se pone el iva a 21% si viene vacio
$newServ->setIva('21');
} else {
$newServ->setIva($add_services_multiple_iva[$key1][$key2]['iva']);
}
$newServ->setProposalId($controlTemp->getProposalId());
$newServ->setDestinationId($controlTemp->getDestinoId());
$newServ->setSupplierId($controlTemp->getSupplierId());
$newServ->setIdeaId($controlTemp->getIdeaId());
$newServ->setActivityId($controlTemp->getActivityId());
/* NAMEJO DE ADICIONALES EN EL DIA DEL EVENTO O DESPUES EL DIA DEL EVENTO */
$dayEvent = $proposal_data->getDateEventStarAt()->format('Y-m-d');
$today = date('Y-m-d');
if( $today >= $dayEvent){
$additional = "Additional";
}else{
$additional = "Normal";
}
$newServ->setCurrency('Euro');
$newServ->setUnits('1');
$newServ->setPax('0');
$newServ->setServiceId(0);
//$newServ->setHour('');//null
//$newServ->setDateInAt('');
//$newServ->setDateOutAt('');
$newServ->setDirectPayment('0');
$newServ->setStatus('Pending');
$newServ->setStatusinternal($additional);
$newServ->setDateInAt($proposal_data->getDateEventStarAt());
$newServ->setDateOutAt($proposal_data->getDateEventEndAt());
$newServ->setCreatedId($user_id);
$newServ->setUpdatedId($user_id);
$newServices[] = $newServ;
}
}
// Eliminamos servicios sin tipo
$arrayNewServ = array();
foreach ($newServices as $item) {
if (!empty($item->getServiceCatName())){ //setServiceCatName
$arrayNewServ[] = $item;
}
}
// FIN: Generamos un arreglo con todos los servicios a agregar
foreach ($arrayNewServ as $item){
$em->persist($item);
$em->flush();
//INICIO: Replicacion en Develup
if ($item->getSupplierId()==2){
// Nombre del agente
$agenteFullName = $em->getRepository(User::class)->findOneById($user_id);
$agenteFullName = $agenteFullName->getName() . ' ' . $agenteFullName->getLastName();
$proposalTitle = $em->getRepository(Proposal::class)->findOneById($item->getProposalId());
if ($item->getSupplierId()==2){
$originalServiceName = $em->getRepository(MdvProduct::class)->findOneById(1); // Id de "Otro Servicio"
$budget = new MdvBudgetPending();
$budget->setActivityId($item->getActivityId());
$budget->setAssistantId($item->getAssistantId());
$budget->setBreakdown($item->getBreakdown());
$budget->setCommission($item->getCommission());
$budget->setControlId($item->getControlId());
$budget->setOriginId($item->getId());
$budget->setCurrency($item->getCurrency());
$budget->setDateBlockLimit($item->getDateBlockLimit());
$budget->setDateInAt($item->getDateInAt());
$budget->setDateOutAt($item->getDateOutAt());
$budget->setDestinationId($item->getDestinationId());
$budget->setDirectPayment($item->getDirectPayment());
$budget->setHour($item->getHour());
$budget->setIdeaId($item->getIdeaId());
$budget->setIsFather($item->getIsFather());
$budget->setIva($item->getIva());
if(!($originalServiceName->getName() == $item->getName())){
$budget->setName($originalServiceName->getName().' (:'. $item->getName().':)');
} else {
$budget->setName($originalServiceName->getName());
}
$budget->setOpCommission($item->getOpCommission());
$budget->setOpIva($item->getOpIva());
$budget->setOpOver($item->getOpOver());
$budget->setOriginalIva($item->getOriginalIva());
$budget->setOriginalopIva($item->getOriginalopIva());
$budget->setOriginalPrice($item->getOriginalPrice());
$budget->setOver($item->getOver());
$budget->setPax($item->getPax());
$budget->setPreCommission($item->getPreCommission());
$budget->setPreIva($item->getPreIva());
$budget->setPrice($item->getPrice());
$budget->setProposalId($item->getProposalId());
$budget->setRank($item->getRank());
$budget->setServiceCatId($item->getServiceCatId());
$budget->setServiceCatName($item->getServiceCatName());
// $budget->setServiceId($item->getServiceId());
$budget->setServiceId(1); // ID de "Otro Servicio"
$budget->setServiceIdFather($item->getServiceIdFather());
$budget->setStatus($item->getStatus());
$budget->setStatusinternal($item->getStatusinternal());
$budget->setStatusRec($item->getStatusRec());
$budget->setSupplierId($item->getSupplierId());
$budget->setUnits($item->getUnits());
$budget->setUserConfirmedFullName($agenteFullName);
$budget->setUserConfirmedId($user_id);
$budget->setProposalTitle($proposalTitle->getTitle());
$budget->setCreatedAt(new \DateTime("now"));
$budget->setCreatedId($user_id);
$budget->setUpdatedId($user_id);
$budget->setUpdatedAt(new \DateTime("now"));
// INIICO: Llenamos el tooltip con la info del proposal
$texto = null;
if (!empty($budget->getProposalId())){
$prop = $em->getRepository(Proposal::class)->findOneById($budget->getProposalId());
if (!empty($prop)){
$client = $em->getRepository(Client::class)->findOneById($prop->getClientId());
$clientContact = $em->getRepository(ClientContact::class)->findOneById($prop->getContactId());
$contacto = null;
if (!empty($clientContact->getName())){$contacto = $contacto. $clientContact->getName(). ' ';}
if (!empty($clientContact->getLastName())){$contacto = $contacto. $clientContact->getLastName(). ' ';}
if (!empty($clientContact->getEmail())){$contacto = $contacto. '('.$clientContact->getEmail().')'. ' ';}
if (!empty($clientContact->getPhone())){$contacto = $contacto. ' - '.$clientContact->getPhone(). ' ';}
if (!empty($clientContact->getMobile())){$contacto = $contacto. ' - '.$clientContact->getMobile();}
$city = $em->getRepository(Destination::class)->findOneById($budget->getDestinationId());
$texto = $texto .'Petición: '.$budget->getCreatedAt()->format('d/m/Y'). ' -- ';
if (!empty($client)){$texto = $texto .'Cliente: '.$client->getName(). ' -- ';}
if (!empty($prop->getPax())){$texto = $texto .'Personas: '.$prop->getPax(). ' -- ';}
$texto = $texto .'Desde: '.$prop->getDateEventStarAt()->format('d/m/Y').' Hasta: '.$prop->getDateEventEndAt()->format('d/m/Y'). ' -- ';
$texto = $texto .'Horario: '.$item->getDateInAt()->format('H:i'). ' a '.$item->getDateOutAt()->format('H:i'). ' -- ';
$texto = $texto .'Ciudad: '.$city->getTitle(). ' -- ';
$texto = $texto .'Contacto: '. $contacto;
$budget->setTextTooltip($texto);
}
}
// FIN: Llenamos el tooltip con la info del proposal
$em->persist($budget);
$em->flush();
//INICIO: Enviamos Telegram
//INICIO: Buscamos el creador del expediente asociado al proposal, si no hay se le envia al jefe de grupo (Jorge)
$file = $em->getRepository(MdvFiles::class)->findOneByIdProposal($prop->getId());
if(!empty($file)){
//Se envia el mensaje al creador del expediente
$userTelegramId = $file->getCreatedId();
} else {
// Solicitud sin expediente, se le notificara la jefe de departamento
$userTelegramId = 5; // Id de Jorge
}
//FIN: Buscamos el creador del expediente asociado al proposal, si no hay se le envia al jefe de grupo (Jorge)
//Buscamos el nombre del destino
$nombreDestino = $em->getRepository(Destination::class)->findOneById($budget->getDestinationId());
$nombreDestino = $nombreDestino->getTitle();
//Mensaje:
//SOLICITUD DE PRESUPUESTO __ ID: '.$budget->getProposalId().' __ DESTINO: '.$nombreDestino.' __ PROVEEDOR: In Out Travel __ CONTACTO: '.$budget->getUserConfirmedFullName()
$this->sendTelegram($userTelegramId,'SOLICITUD DE PRESUPUESTO (MultiService) __ ID: '.$budget->getProposalId().' __ DESTINO: '.$nombreDestino.' __ PROVEEDOR: In Out Travel __ CONTACTO: '.$budget->getUserConfirmedFullName());
// d($userTelegramId,'SOLICITUD DE PRESUPUESTO __ ID: '.$budget->getProposalId().' __ DESTINO: '.$nombreDestino.' __ PROVEEDOR: In Out Travel __ CONTACTO: '.$budget->getUserConfirmedFullName());exit();
//FIN: Enviamos Telegram
}
}
//FIN: Replicacion en Develup
}
return $this->redirectToRoute('proposal_destination_supplier_view', array(
'id' => $controlTemp->getControlDestinationId(),
));
}
/**
* @Route("proposal/destination/services/saveallservices/{id}", name="proposal_destination_supplier_saveallservices")
*/
public function saveAllServicesAction($id, Request $request) {
$save_services_multiple_name = $request->request->get('services_hidden_name');
$save_services_multiple_rank = $request->request->get('services_hidden_rank');
$save_services_multiple_price = $request->request->get('services_hidden_price');
$save_services_multiple_units = $request->request->get('services_hidden_units');
$save_services_multiple_pax = $request->request->get('services_hidden_pax');
$save_services_multiple_commission = $request->request->get('services_hidden_commission');
$save_services_multiple_over = $request->request->get('services_hidden_over');
$save_services_multiple_iva = $request->request->get('services_hidden_iva');
$save_services_multiple_originalPrice = $request->request->get('services_hidden_originalPrice');
$save_services_multiple_originalIva = $request->request->get('services_hidden_originalIva');
$save_services_multiple_supplier = $request->request->get('services_hidden_supplier');
$save_services_multiple_opcommission = $request->request->get('services_hidden_opcommission');
$save_services_multiple_opover = $request->request->get('services_hidden_opover');
$save_services_multiple_opiva = $request->request->get('services_hidden_opiva');
$save_services_multiple_dateBlockLimit = $request->request->get('services_hidden_dateBlockLimit');
$save_services_multiple_timeBlockLimit = $request->request->get('services_hidden_timeBlockLimit');
$save_services_multiple_dateInAt = $request->request->get('services_hidden_dateInAt');
$save_services_multiple_dateOutAt = $request->request->get('services_hidden_dateOutAt');
$save_services_multiple_hour_start = $request->request->get('services_hidden_hour_start_');
$save_services_multiple_hour_end = $request->request->get('services_hidden_hour_end_');
$save_services_multiple_currency = $request->request->get('services_hidden_currency_');
$save_services_multiple_originalopIva = $request->request->get('services_hidden_originalopIva_');
$save_multiple_supplier_activity_idea_rank = $request->request->get('supplier_activity_idea_hidden_rank');
$arrayServices = array();
foreach ($save_services_multiple_name as $key => $name){
$service = new ProposalSupplierServices();
$service->setName($name);
$service->setRank($save_services_multiple_rank[$key]);
$service->setPrice($save_services_multiple_price[$key]);
$service->setUnits($save_services_multiple_units[$key]);
$service->setPax($save_services_multiple_pax[$key]);
$service->setCommission($save_services_multiple_commission[$key]);
$service->setOver($save_services_multiple_over[$key]);
$service->setIva($save_services_multiple_iva[$key]);
$service->setOriginalPrice($save_services_multiple_originalPrice[$key]);
$service->setOriginalIva($save_services_multiple_originalIva[$key]);
$service->setSupplierId($save_services_multiple_supplier[$key]);
$service->setOpCommission($save_services_multiple_opcommission[$key]);
$service->setOpOver($save_services_multiple_opover[$key]);
$service->setOpIva($save_services_multiple_opiva[$key]);
if (!empty($save_services_multiple_dateBlockLimit[$key]) or !empty($save_services_multiple_timeBlockLimit[$key])){
$service->setDateBlockLimit(new \DateTime($save_services_multiple_dateBlockLimit[$key].' '.$save_services_multiple_timeBlockLimit[$key]));
}
//$service->set ($save_services_multiple_timeBlockLimit[$key]);
if (!empty($save_services_multiple_dateInAt[$key]) or !empty($save_services_multiple_hour_start[$key])) {
$service->setDateInAt(new \DateTime($save_services_multiple_dateInAt[$key] . ' ' . $save_services_multiple_hour_start[$key]));
}
if (!empty($save_services_multiple_dateOutAt[$key]) or !empty($save_services_multiple_hour_end[$key]) ) {
$service->setDateOutAt(new \DateTime($save_services_multiple_dateOutAt[$key] . ' ' . $save_services_multiple_hour_end[$key]));
}
$service->setHour($save_services_multiple_hour_start[$key]);
//$service->set ($save_services_multiple_hour_end[$key]);
$service->setCurrency($save_services_multiple_currency[$key]);
$service->setOriginalopIva($save_services_multiple_originalopIva[$key]);
$arrayServices[] = array($key, $service);
}
$em = $this->getDoctrine()->getManager();
foreach ($save_multiple_supplier_activity_idea_rank as $key => $item){
if(!empty($item)){
$prpSupActIdeaControl = $em->getRepository(ProposalSupplierControl::class)->findOneById($key);
if (!empty($prpSupActIdeaControl)){
$prpSupActIdeaControl->setRank($item);
$em->persist($prpSupActIdeaControl);
$em->flush();
}
}
}
/* Obtengo usuario logueado */
$user_logueado = $this->get('security.token_storage')->getToken()->getUser();
$user_id = $user_logueado->getId();
foreach ($arrayServices as $item){
$prpSupService = $em->getRepository(ProposalSupplierServices::class)->findOneById($item[0]);
$srvToSave = false; //Indicador para determinar si se debe guardar el servicio
// INICIO: Analizamos si se debe modificar el servicio, el $item[1] se encuentra el servicio
if (!empty($item[1]->getName())){ // Hay nombre
$srvToSave = true;
$prpSupService->setName($item[1]->getName());
}
if (!empty($item[1]->getRank())){ // Hay ranking
$srvToSave = true;
$prpSupService->setRank($item[1]->getRank());
}
if (!empty($item[1]->getPrice())){ // Hay Precio
$srvToSave = true;
$prpSupService->setPrice($item[1]->getPrice());
}
if (!empty($item[1]->getUnits())){ // Hay Unidades
$srvToSave = true;
$prpSupService->setUnits($item[1]->getUnits());
}
if (!empty($item[1]->getPax())){ // Hay Personas
$srvToSave = true;
$prpSupService->setPax($item[1]->getPax());
}
if (!empty($item[1]->getCommission())){ // Hay Comision
$srvToSave = true;
$prpSupService->setCommission($item[1]->getCommission());
}
if (!empty($item[1]->getOver())){ // Hay Over
$srvToSave = true;
$prpSupService->setOver($item[1]->getOver());
}
if (!empty($item[1]->getIva()) or ($item[1]->getIva() == '0')){ // Hay Iva
$srvToSave = true;
$prpSupService->setIva($item[1]->getIva());
}
if (!empty($item[1]->getOriginalPrice())){ // Hay Original Price
$srvToSave = true;
$prpSupService->setOriginalPrice($item[1]->getOriginalPrice());
}
if (!empty($item[1]->getOriginalIva())){ // Hay Original Iva
$srvToSave = true;
$prpSupService->setOriginalIva($item[1]->getOriginalIva());
}
if (!empty($item[1]->getSupplierId())){ // Hay Supplier
$srvToSave = true;
$prpSupService->setSupplierId($item[1]->getSupplierId());
}
if (($item[1]->getOpCommission() === '0') or ($item[1]->getOpCommission() === '1')){ // Hay OpCommission
$srvToSave = true;
$prpSupService->setOpCommission($item[1]->getOpCommission());
}
if (($item[1]->getOpOver() === '0') or ($item[1]->getOpOver() === '1')){ // Hay OpOver
$srvToSave = true;
$prpSupService->setOpOver($item[1]->getOpOver());
}
if (($item[1]->getOpIva() === '0') or ($item[1]->getOpIva() === '1')){ // Hay OpIva
$srvToSave = true;
$prpSupService->setOpIva($item[1]->getOpIva());
}
if (!empty($item[1]->getHour())){ // Hay Hora de inicio
$srvToSave = true;
$prpSupService->setHour($item[1]->getHour());
}
if (!empty($item[1]->getCurrency())){ // Hay Moneda
$srvToSave = true;
$prpSupService->setCurrency($item[1]->getCurrency());
}
if (($item[1]->getOriginalopIva() === '0') or ($item[1]->getOriginalopIva() === '1')){ // Hay Original OP Iva
$srvToSave = true;
$prpSupService->setOriginalopIva($item[1]->getOriginalopIva());
}
if (!empty($item[1]->getDateBlockLimit())){ // Hay Fecha de Block Limit
$srvToSave = true;
$prpSupService->setDateBlockLimit($item[1]->getDateBlockLimit());
}
if (!empty($item[1]->getDateInAt())){ // Hay DateInAt
$srvToSave = true;
$prpSupService->setDateInAt($item[1]->getDateInAt());
}
if (!empty($item[1]->getDateOutAt())){ // Hay DateInAt
$srvToSave = true;
$prpSupService->setDateOutAt($item[1]->getDateOutAt());
}
// FIN: Analizamos si se debe modificar el servicio, el $item[1] se encuentra el servicio
if ($srvToSave){
$em->persist($prpSupService);
$em->flush();
}
//Actualizar confirmado
if ($prpSupService->getStatus() =='Confirmed'){
$costsClient = $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($prpSupService->getId());
if (!empty($costsClient)){
// $costsClient->setSupplierId($services_supplier_proposal->getSupplierId());
$costsClient->setAssistantId($prpSupService->getAssistantId());
$costsClient->setName($prpSupService->getName());
$costsClient->setPrice($prpSupService->getPrice());
$costsClient->setCurrency($prpSupService->getCurrency());
$costsClient->setUnits($prpSupService->getUnits());
$costsClient->setOpCommission($prpSupService->getOpCommission());
$costsClient->setCommission($prpSupService->getCommission());
$costsClient->setOpOver($prpSupService->getOpOver());
$costsClient->setOver($prpSupService->getOver());
$costsClient->setOpIva($prpSupService->getOpIva());
$costsClient->setIva($prpSupService->getIva());
$costsClient->setPax($prpSupService->getPax());
$costsClient->setHour($prpSupService->getHour());
$costsClient->setDateInAt($prpSupService->getDateInAt());
$costsClient->setDateOutAt($prpSupService->getDateOutAt());
$costsClient->setRank($prpSupService->getRank());
$costsClient->setCreatedId($user_id);
$costsClient->setUpdatedId($user_id);
$em->persist($costsClient);
$em->flush();
}
}
}
return $this->redirectToRoute('proposal_destination_supplier_view', array(
'id' => $id,
));
}
/**
* @Route("proposal/destination/services/duplicateservice/{id}", name="proposal_destination_duplicate_service")
*/
public function duplicateServiceAction($id, Request $request) {
$em = $this->getDoctrine()->getManager();
$prpSupService = $em->getRepository(ProposalSupplierServices::class)->findOneById($id);
/* Obtengo usuario logueado */
$user_logueado = $this->get('security.token_storage')->getToken()->getUser();
$user_id = $user_logueado->getId();
$service = new ProposalSupplierServices();
$service->setName('DUPLICADO - '.$prpSupService->getName());
$service->setRank($prpSupService->getRank());
$service->setPrice($prpSupService->getPrice());
$service->setUnits($prpSupService->getUnits());
$service->setPax($prpSupService->getPax());
$service->setCommission($prpSupService->getCommission());
$service->setOver($prpSupService->getOver());
$service->setIva($prpSupService->getIva());
$service->setOriginalPrice($prpSupService->getOriginalPrice());
$service->setOriginalIva($prpSupService->getOriginalIva());
$service->setSupplierId($prpSupService->getSupplierId());
$service->setOpCommission($prpSupService->getOpCommission());
$service->setOpOver($prpSupService->getOpOver());
$service->setOpIva($prpSupService->getOpIva());
$service->setDateBlockLimit($prpSupService->getDateBlockLimit());
$service->setDateInAt($prpSupService->getDateInAt());
$service->setDateOutAt($prpSupService->getDateOutAt());
$service->setHour($prpSupService->getHour());
$service->setCurrency($prpSupService->getCurrency());
$service->setOriginalopIva($prpSupService->getOriginalopIva());
$service->setCreatedId($user_id);
$service->setCreatedAt(new \DateTime());
$service->setUpdatedId($user_id);
$service->setUpdatedAt(new \DateTime());
$service->setControlId($prpSupService->getControlId());
$service->setActivityId($prpSupService->getActivityId());
$service->setAssistantId($prpSupService->getAssistantId());
$service->setBreakdown($prpSupService->getBreakdown());
$service->setDestinationId($prpSupService->getDestinationId());
$service->setDirectPayment($prpSupService->getDirectPayment());
$service->setIdeaId($prpSupService->getIdeaId());
$service->setPreCommission($prpSupService->getPreCommission());
$service->setPreIva($prpSupService->getPreIva());
$service->setProposalId($prpSupService->getProposalId());
$service->setServiceCatId($prpSupService->getServiceCatId());
$service->setServiceCatName($prpSupService->getServiceCatName());
$service->setServiceId($prpSupService->getServiceId());
$service->setServiceIdFather($prpSupService->getServiceIdFather());
$service->setStatus('Pending');
$service->setStatusinternal($prpSupService->getStatusinternal());
$em->persist($service);
$em->flush();
$prpSupCtrl = $em->getRepository(ProposalSupplierControl::class)->findOneById($prpSupService->getControlId());
return $this->redirectToRoute('proposal_destination_supplier_view', array(
'id' => $prpSupCtrl->getControlDestinationId(),
'_fragment' => $id
));
}
/**
* @Route("proposal/destination/services/duplicatesupplier/{id}", name="proposal_destination_duplicate_supplier")
*/
public function duplicateSupplierAction($id, Request $request) {
$newSup = $request->request->get('dupliSupplierId');
$em = $this->getDoctrine()->getManager();
/* Obtengo usuario logueado */
$user_logueado = $this->get('security.token_storage')->getToken()->getUser();
$user_id = $user_logueado->getId();
$prpSupServices = $em->getRepository(ProposalSupplierServices::class)->findByControlId($id);
$prpSupControl = $em->getRepository(ProposalSupplierControl::class)->findOneById($id);
$origenSup = $prpSupControl->getSupplierId();
//Verificamos si Proveedor origen y destino son el mismo
if ($newSup != $origenSup){
//Verificamos si ya existe el control del Proveedor destino
$prevPrpSupControl = $em->getRepository(ProposalSupplierControl::class)->findBy(
array('proposalId'=>$prpSupControl->getProposalId(),
'destinoId'=>$prpSupControl->getDestinoId(),
'supplierId'=>$newSup));
if (empty($prevPrpSupControl)){
// Proveedor origen y destino son distintos, se crea una nueva entidad de control
$newSupControl = new ProposalSupplierControl();
} else {
// El Proveedor destino ya tiene un controlador
$newSupControl = $prevPrpSupControl[0];
}
$newSupControl->setActivityId($prpSupControl->getActivityId());
$newSupControl->setControlDestinationId($prpSupControl->getControlDestinationId());
$newSupControl->setDateBlockLimit($prpSupControl->getDateBlockLimit());
$newSupControl->setDestinoId($prpSupControl->getDestinoId());
$newSupControl->setDisabled($prpSupControl->getDisabled());
$newSupControl->setIdeaId($prpSupControl->getIdeaId());
$newSupControl->setProposalId($prpSupControl->getProposalId());
$newSupControl->setRank($prpSupControl->getRank());
$newSupControl->setStatus($prpSupControl->getStatus());
$newSupControl->setSupplierId($newSup);
$em->persist($newSupControl);
$em->flush();
} else {
$newSupControl = $prpSupControl;
}
// Duplicamos los servicios
foreach ($prpSupServices as $item){
$service = new ProposalSupplierServices();
$service->setName($item->getName());
$service->setRank($item->getRank());
$service->setPrice($item->getPrice());
$service->setUnits($item->getUnits());
$service->setPax($item->getPax());
$service->setCommission($item->getCommission());
$service->setOver($item->getOver());
$service->setIva($item->getIva());
$service->setOriginalPrice($item->getOriginalPrice());
$service->setOriginalIva($item->getOriginalIva());
$service->setSupplierId($newSup);
$service->setOpCommission($item->getOpCommission());
$service->setOpOver($item->getOpOver());
$service->setOpIva($item->getOpIva());
$service->setDateBlockLimit($item->getDateBlockLimit());
$service->setDateInAt($item->getDateInAt());
$service->setDateOutAt($item->getDateOutAt());
$service->setHour($item->getHour());
$service->setCurrency($item->getCurrency());
$service->setOriginalopIva($item->getOriginalopIva());
$service->setCreatedId($user_id);
$service->setCreatedAt(new \DateTime());
$service->setUpdatedId($user_id);
$service->setUpdatedAt(new \DateTime());
$service->setControlId($newSupControl->getId());
$service->setActivityId($item->getActivityId());
$service->setAssistantId($item->getAssistantId());
$service->setBreakdown($item->getBreakdown());
$service->setDestinationId($item->getDestinationId());
$service->setDirectPayment($item->getDirectPayment());
$service->setIdeaId($item->getIdeaId());
$service->setPreCommission($item->getPreCommission());
$service->setPreIva($item->getPreIva());
$service->setProposalId($item->getProposalId());
$service->setServiceCatId($item->getServiceCatId());
$service->setServiceCatName($item->getServiceCatName());
$service->setServiceId($item->getServiceId());
$service->setServiceIdFather($item->getServiceIdFather());
$service->setStatus('Pending');
$service->setStatusinternal($item->getStatusinternal());
$em->persist($service);
$em->flush();
}
$prpSupCtrl = $em->getRepository(ProposalSupplierControl::class)->findOneById($id);
return $this->redirectToRoute('proposal_destination_supplier_view', array(
'id' => $prpSupCtrl->getControlDestinationId(),
));
}
/**
* @Route("proposal/destination/services/comissionall", name="proposal_destination_comission_all")
*/
public function comissionAllAction(Request $request){
$proposalSupplierControlId = $request->request->get('proposalSupplierControlId');
$opCommissionAll = $request->request->get('opCommissionAll');
$commissionAll = $request->request->get('commissionAll');
$em = $this->getDoctrine()->getManager();
$prpSupControl = $em->getRepository(ProposalSupplierControl::class)->findOneById($proposalSupplierControlId);
$prpSupServices = $em->getRepository(ProposalSupplierServices::class)->findByControlId($proposalSupplierControlId);
$idPrpSupServices = null;
foreach ($prpSupServices as $item){
$item->setOpCommission($opCommissionAll);
$item->setCommission($commissionAll);
$idPrpSupServices = $item->getId();
$em->persist($item);
$em->flush();
$prpSupServicesCosts = $em->getRepository(ProposalSupplierServicesCostsClient::class)->findOneByServiceIdProposal($item->getId());
if (!empty($prpSupServicesCosts)){
$em->remove($prpSupServicesCosts);
$em->flush();
}
if (!empty($idPrpSupServices)){
$parameters = array(
'idPrpSupServices' => '%'.$idPrpSupServices.'%',
);
$dql = 'SELECT i
FROM EventsBundle:ProposalSupplierServicesCosts i
WHERE i.servicesId LIKE :idPrpSupServices
ORDER BY i.id ASC';
$query = $em->createQuery($dql)->setParameters($parameters);
$proposalSupplierServicesCosts = $query->getResult();
// Si el servicio se encontraba dentro de $proposalSupplierServicesCosts es porque el servicio se encontraba
// confirmado y dentro de una proforma, se deben sacar para evitar error en el apartado de proveedores
foreach($proposalSupplierServicesCosts as $prpSupSrvCst){
$prpSupSrvCst->setServicesId('0');
$em->persist($prpSupSrvCst);
$em->flush();
}
}
}
$fragmento = empty($prpSupServices) ? null : $prpSupServices[0]->getId();
return $this->redirectToRoute('proposal_destination_supplier_view',
array(
'id' => $prpSupControl->getControlDestinationId(),
'_fragment' => $fragmento
));
}
private function sendTelegram ( $id, $text )
{
$em = $this->getDoctrine()->getManager();
$telegUser = $em->getRepository(MdvTelegramUser::class)->findOneByUserId($id);
if (empty($telegUser)){return true;}
$parameters = array(
'chat_id' => $telegUser->getChatId(),
'text' => $text,
);
$bot_token = $telegUser->getBotToken();
$url = "https://api.telegram.org/bot$bot_token/sendMessage";
if (!$curl = curl_init()){
exit();
}
curl_setopt($curl,CURLOPT_POST,true);
curl_setopt($curl,CURLOPT_POSTFIELDS,$parameters);
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
$output = curl_exec($curl);
curl_close($curl);
return true;
}
}