<?php
/**
* Created by Mediterranean Develup Solutions
* User: jorge.defreitas@develup.solutions
* Date: 13/07/2017
* Time: 16:04
*/
namespace App\Controller;
use App\Entity\Cities;
use App\Entity\Country;
use App\Entity\Provinces;
use App\Entity\Regions;
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\SupplierEntertainment;
use App\Entity\SupplierGifts;
use App\Entity\SupplierGuide;
use App\Entity\SupplierIdeaServicesControl;
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 Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Validator\Constraints as Assert;
class SupplierServicesController extends AbstractController
{
/**
* @Route("/supplier/services/{ids}", name="services_index")
*/
public function indexAction($ids, Request $request) {
$em = $this->getDoctrine()->getManager();
$system = "supplier";
/*CONTROL GENERAL*/
$controlgeneral = $em->getRepository(SupplierIdeaServicesControl::class)->findOneById($ids);
$id = $controlgeneral->getId();
$supplier = $em->getRepository(Supplier::class)->findOneById($controlgeneral->getSupplierId());
$country = $em->getRepository(Country::class)->findOneById($supplier->getCountry());
$supplier->setCountry($country->getCountry());
$regions = $em->getRepository(Regions::class)->findOneById($supplier->getRegion());
$supplier->setRegion($regions->getRegion());
$province = $em->getRepository(Provinces::class)->findOneById($supplier->getProvince());
$supplier->setProvince($province->getName());
$cities = $em->getRepository(Cities::class)->findOneById($supplier->getPopulation());
$supplier->setPopulation($cities->getCity());
/* 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"><img src="/assets/images/icons/mi-20.png"></span>');
}
if ($accommodation->getWifi()){
$accommodation->setWifi('<span class="label"><img src="/assets/images/icons/wi-20.png"></span>');
}
if ($accommodation->getAirconditioner()){
$accommodation->setAirconditioner('<span class="label"><img src="/assets/images/icons/ac-20.png"></span>');
}
if ($accommodation->getCalefaction()){
$accommodation->setCalefaction('<span class="label"><img src="/assets/images/icons/ca-20.png"></span>');
}
if ($accommodation->getPool()){
$accommodation->setPool('<span class="label"><img src="/assets/images/icons/po-20.png"></span>');
}
if ($accommodation->getBath()){
$accommodation->setBath('<span class="label"><img src="/assets/images/icons/ba-20.png"></span>');
}
if ($accommodation->getCoffeemaker()){
$accommodation->setCoffeemaker('<span class="label"><img src="/assets/images/icons/cm-20.png"></span>');
}
if ($accommodation->getKitchen()){
$accommodation->setKitchen('<span class="label"><img src="/assets/images/icons/ki-20.png"></span>');
}
if ($accommodation->getWasher()){
$accommodation->setWasher('<span class="label"><img src="/assets/images/icons/wa-20.png"></span>');
}
if ($accommodation->getFlattv()){
$accommodation->setFlattv('<span class="label"><img src="/assets/images/icons/tv-20.png"></span>');
}
if ($accommodation->getElectrickettle()){
$accommodation->setElectrickettle('<span class="label"><img src="/assets/images/icons/ke-20.png"></span>');
}
if ($accommodation->getViews()){
$accommodation->setViews('<span class="label"><img src="/assets/images/icons/vi-20.png"></span>');
}
if ($accommodation->getPets()){
$accommodation->setPets('<span class="label"><img src="/assets/images/icons/pe-20.png"></span>');
}
$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
// $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(),
'description' => $description //GEAO Gustavo Ayala: agregue la descripcción al listar los servicios
);
}
/* 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(), //GEAO lo comente ya que esta repetido
'currency' => $menu->getCurrency(),
'price' => $menu->getPrice(),
'commission' => $menu->getCommission(),
'iva' => $menu->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description //Gustavo Ayala: agregue la descripcción al listar los servicios
);
}
/* 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(),
'meters' => $lounge->getMeters(),
'length' => $lounge->getLength(),
'width' => $lounge->getWidth(),
'height' => $lounge->getHeight(),
'currency' => $lounge->getCurrency(),
'price' => $lounge->getPrice(),
'commission' => $lounge->getCommission(),
'iva' => $lounge->getIva(),
'controlId' => $controlctrlDes->getId(),
'description' => $description
);
}
/* 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()
));
//Gustavo Ayala: descomente esats lineas para agregar la descripcion
$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
//Gustavo Ayala: descomente esats lineas para agregar la descripcion
$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(),
'description' => $description //Gustavo Ayala: agregue la descripcción al listar los servicios
);
}
/* 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()
));
//Gustavo Ayala: descomente esats lineas para agregar la descripcion
$controlctrlDes->getId();
$description = $em->getRepository(SupplierServicesDescription::class)->findByControlId($controlctrlDes->getId());
//Gustavo Ayala: descomente esats lineas para agregar la descripcion
$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(),
'description' => $description //Gustavo Ayala: agregue la descripcción al listar los servicios
);
}
/* 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 */
$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('supplier/services/list-services.html.twig', array(
'id' => $supplier->getId(),
'ids' => $ids,
'controlGeneral' => $controlgeneral,
'supplier' => $supplier,
'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,
'technologys' => $data_technology,
'assistants' => $data_assistant,
'otherss' => $data_others,
'system' => $system,
));
}
}