src/Controller/SpectaclesController.php line 1188

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\ClassTheatre\aside\asidesUrlPagination;
  4. use App\ClassTheatre\asides;
  5. use App\ClassTheatre\TheatreController;
  6. use App\Service\Abonnements\Abonnements;
  7. use App\Service\Functions;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  10. use Symfony\Component\Form\Extension\Core\Type\FormType;
  11. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  12. use Symfony\Component\Form\Extension\Core\Type\TextType;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use Symfony\Component\Routing\Annotation\Route;
  15. use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
  16. use Symfony\Contracts\Translation\TranslatorInterface;
  17. use TheatreCore\Entity\Bigregions;
  18. use TheatreCore\Entity\Classifications;
  19. use TheatreCore\Entity\Contacts;
  20. use TheatreCore\Entity\Files;
  21. use TheatreCore\Entity\Multimedias;
  22. use TheatreCore\Entity\News;
  23. use TheatreCore\Entity\Persons;
  24. use TheatreCore\Entity\Regions;
  25. use TheatreCore\Entity\Spectacles;
  26. use TheatreCore\Entity\Typesstructures;
  27. use TheatreCore\Form\Type\RelationsType;
  28. class SpectaclesController extends TheatreController
  29. {
  30.     // l'objet spectacles
  31.     protected $spectacles;
  32.     // par page
  33.     protected $perPage 20;
  34.     // version de la carte
  35.     protected $carte_version 'svg';
  36.     // {{{ _construct()
  37.     public function __construct(EntityManagerInterface $emTranslatorInterface $translatorTokenStorageInterface $tokenStorageAbonnements $abonnements)
  38.     {
  39.         parent::__construct($translator$tokenStorage);
  40.         $this->context['controller'] = $this->view->controller 'spectacles';
  41.         $this->em $em;
  42.         $this->spectacles $em->getRepository(Spectacles::class);
  43.         $this->getCarteVersion();
  44.         $this->serviceAbonnements $abonnements;
  45.     }
  46.     // {{{ region_common()
  47.     /**
  48.      * @Route("/spectacles/", name="spectacles_index")
  49.      *
  50.      * region_common
  51.      *
  52.      */
  53.     public function action_index()
  54.     {
  55.         $this->context['action'] = 'view';
  56.         // pager & mois pour liste deroulante
  57. //        include PATH_LIBS.'/Functions/Months.php';
  58.         // trucs commun
  59. //        include PATH_APP.$module.'/controllers/Spectacles/commun.inc.php';
  60.         $form $this->setCommonSearch()->getForm();
  61.         $this->context['view']->formAsideSearch $form->createView();
  62.         // page de provenance
  63.         $this->view->from_page '/spectacles/';
  64.         // instancier un objet spectacles
  65.         // nb total de spectacle
  66.         $sql_count 'SELECT COUNT(DISTINCT('.$this->spectacles->__idtable.')) FROM '.$this->spectacles->__table.' WHERE publish=1';
  67.         $this->view->nb_total $this->spectacles->queryOne($sql_count);
  68.         //menu pour l'aside Spéctacles à venir
  69.         $spectacles_a_venir = array(
  70.             array(
  71.                 'name' => 'Dans les 7 prochains jours',
  72.                 'key_day' => '7',
  73.             ),
  74.             array(
  75.                 'name' => 'Dans les 30 prochains jours',
  76.                 'key_day' => '30',
  77.             ),
  78.             array(
  79.                 'name' => 'Dans les 3 prochains mois',
  80.                 'key_day' => '90',
  81.             ),
  82.             array(
  83.                 'name' => 'Dans les 12 prochains mois',
  84.                 'key_day' => '365',
  85.             )
  86.         );
  87.         $day_spectacles 365$day_all false;
  88.         if(!empty($_REQUEST['d'])){
  89.             if(in_array($_REQUEST['d'], array_column($spectacles_a_venir'key_day'))){
  90.                 $day_spectacles $_REQUEST['d'];
  91.                 if(!is_numeric($day_spectacles)){
  92.                     $day_all true;
  93.                 }
  94.             }
  95.         }
  96.         $this->view->jours_affiche_all $day_all;
  97.         $spectacles_voir = array(
  98.             array(
  99.                 'name' => 'Tous les spectacles',
  100.                         'key_filtre' => ''// TODO:  fixe v2
  101.                 'action' => 'view',
  102.             ),
  103.             array(
  104.                 'name' => 'Tous les spectacles avec vidéos',
  105.                 'key_filtre' => 'theatre/affiche-videos/',
  106.                 'action' => 'affiche-videos'
  107.             ),
  108.             array(
  109.                 'name' => 'Tous les spectacles avec audios',
  110.                 'url' => '/audios/spectacles/type/prochains/',
  111.                 'action' => 'affiche-audios'
  112.             ),
  113.             array(
  114.                 'name' => 'Premières',
  115.                 'url' => '/premieres/mondiales',
  116.                 'action' => 'premieres'
  117.             ),
  118.         );
  119.         $filtre_spectacles 'view';
  120.         if(in_array($this->context['action'], array_column($spectacles_voir'action'))){
  121.             $filtre_spectacles $this->context['action'];
  122.         }
  123.         $this->view->spectacle_avenir_jour $day_spectacles;
  124.         $params_days_numeric = array();
  125.         if(is_numeric($day_spectacles)){
  126.             $params_days_numeric = array(
  127.                 'prochains' => $day_spectacles
  128.             );
  129.         }
  130.         $special_params = array(
  131.             'prochains' => $day_spectacles
  132.         );
  133.         //nombre total de spectacle a venir
  134.         $nombreprochainspectacle $this->spectacles->countSpectacles($params_days_numeric);
  135.         //les pages pour les spectacles à l'affiche
  136.         $this->perPage $pagerOptions['perPage'] = 30;
  137.         $pagerOptions['totalItems'] = $nombreprochainspectacle;
  138.         // pagination
  139. //        require PATH_LIBS.'Pager/Pagersimple.php';
  140. //        $this->view->pagination = $paged_data = pagerSimple($pagerOptions);
  141.         $this->view->pagination $this->getPagination($nombreprochainspectacle);
  142.         $this->view->pagination['spectacle'] = true;
  143. //        require_once PATH_ADMIN."app/common/helpers/aside/asidesUrlPagination.php";
  144.         $urlpagination = new asidesUrlPagination(
  145.             '/spectacles/generate_params',
  146.             array(
  147.                 'day' => $day_spectacles,
  148.             ),
  149.             $this->context
  150.         );
  151.         $this->view->pagination['url_custom'] = $urlpagination->url_pagination();
  152.         $paged_data['from'] = 10;
  153.         // les prochains spectacles
  154.         $params_sql_prochains = array(
  155.             'params' => array(
  156.                 'limit' => array($this->getLimitStart(),$this->perPage),
  157.                 'where' => ' AND s.idspectaclegenre=1'
  158.             ),
  159.             'special' => $special_params,
  160.         );
  161.         $prochains_spectacles $this->spectacles->getListSpectacles(
  162.             $params_sql_prochains,
  163.             array('vignette' => array(
  164.                 'width'=>100,'height'=>100,'direction'=>'crop','fleche'=>'moyen'
  165.             )),
  166.             false,
  167.             array(
  168.                 'allauthors' => true,
  169.                 'carrer_couleurs' => true
  170.             )
  171.         );
  172.         // trier les spectacles en france et à l'étranger
  173.         foreach($prochains_spectacles as $key=>$val) {
  174.             $val['footer_contact'] = true;
  175.             $idspectacle $val['idspectacle'];
  176.             if(isset($val['allpersons']) && sizeof($val['allpersons']) >= 2){
  177.                 $allpersons = array();
  178.                 foreach($val['allpersons'] AS $k => $v){
  179.                     unset($v['nopunct']);
  180.                     $allpersons[$k] = $v;
  181.                     if(sizeof($allpersons) == 2) break;
  182.                 }
  183.                 $val['allpersons'] = $this->spectacles->noPunct($allpersons);
  184.             }
  185.             $prochains_spectacles[$key] = $val;
  186.         // France
  187.         //    if($val['country']=='FR') {
  188.         //        $spec[$idspectacle] = $val;
  189.         //    } else {
  190.         //        $spec_etranger[$idspectacle] = $val;
  191.         //    }
  192.         }
  193.         // envoi au template
  194.         if (!empty($prochains_spectacles)){
  195.             $this->view->spectacles $prochains_spectacles;
  196.         }
  197.         if (!empty($spec_etranger)){
  198.             $this->view->spectacles_etranger $spec_etranger;
  199.         }
  200.         $this->view->default true;
  201.         // options générales
  202. //        require_once PATH_LIBS.'Options/Theatre_options.php';
  203. //        $th_options = new Theatre_options($module);
  204.         // Gestion du cache
  205. //        require_once PATH_LIBS.'Cache/Theatre_cache.php';
  206.         // les spectacles les plus consultes généré toutes les nuits
  207.         $statsname 'spectacleslesplusvus';
  208. //        $cf = $th_options->getOptions('stats.'.$statsname);
  209.         $cache = array();
  210.         // les options
  211. //        $cache['options'] = array(
  212. //            'id' => $statsname.'_'.$GLOBALS['lng'],
  213. //            'group' => $this->context['module'],
  214. //            'cacheDir' => $cf['cacheDir'],
  215. //            'lifeTime' => $cf['lifeTime'],
  216. //            'fileNameProtection'=>false
  217. //        );
  218. //        $cache[$statsname] = new Theatre_cache($cache['options']);
  219.         // cache
  220. //        if (USE_CACHE && !$calculwget && $cache['data'] = $cache[$statsname]->get()) {
  221. //            // on récupère les données du cache
  222. //            $plus_vus = unserialize($cache['data']);
  223. //        } else {
  224.             /* todo ne pas push a remettre pour la production */
  225.             // $statscumul = Theatre::factory('statscumul');
  226.             // $plus_vus = $statscumul->spectaclesLesPlusVus($cf['max_items'], $module, $lng, $cf['facteur']);
  227.             // sauvegarde le cache
  228.             //$cache[$statsname]->save(serialize($plus_vus));
  229. //        }
  230.         // envoi les stats à la vue
  231.         // $this->view->plus_vus_count = count($plus_vus);
  232.         // $this->view->plus_vus = $plus_vus;
  233.         //recuperer le contenu multimedia
  234.         $multimedias $this->em->getRepository(Multimedias::class);
  235.         //recuperer la page
  236.         $classification $this->em->getRepository(Classifications::class);
  237.         // classe images
  238. //        require_once PATH_LIBS.'Images/Images.php';
  239. //        $images = new Images();
  240. //        $images->setVignetteFormat(array('width'=>93,'height'=>70,'direction'=>'crop','fleche'=>'moyen'));
  241.         // situation et titre meta
  242.         $this->view->locate = array(=> 'Spectacles');
  243.         $this->view->title_page 'Les spectacles de théâtre contemporain en France et à l\'étranger';
  244.         $this->view->rub_courante 'spectacles';
  245.         // jquery
  246.         $this->view->jquery_cal 'datepicker';
  247.         $this->view->jquery_flash true;
  248.         $this->context['view']->use_addthis true;
  249.         $this->context['view']->is_carte_svg true;
  250.         $this->context['view']->js_more['raphael-min-js'] = 'raphaeljs/raphael-min.js';
  251.         $this->context['view']->js_more['raphael-svg-import'] = 'raphaeljs/raphael-svg-import.js';
  252.         // Placeholder du champ de recherche du nom de spectacles
  253. //        $form->addElement('text', 'title', '', array('id'=>'title','placeholder' => 'Un nom de spectacle'));
  254.         //On affiche la publicité google
  255.         $asides_publicite = new asides();
  256.         asides::setEntityManager($this->em);
  257.         asides::loadaside('Publicite')->addGoogle($asides_publicite$this->serviceAbonnements);
  258.         $this->context['view']->asides_publicite $asides_publicite->view($this->context['view']);
  259.         $asides = new asides();
  260.         $asides->load(['url_lists,a_laffiche' => array(
  261.             'exec' => array(
  262.                 'htmlstart' => true
  263.             ),
  264.             'php' => array(
  265.                 'method' => 'asidesUrlLists',
  266.                 'urls' => $spectacles_voir,
  267.                 'url' => '/spectacles/key_filtre',
  268.                 'params' => array(
  269.                     'activate' => $filtre_spectacles
  270.                 )
  271.             ),
  272.             'title' => html_entity_decode('&Agrave; l\'affiche')
  273.         )]);
  274.         $asides->load(['url_lists' => array(
  275.             'exec' => array(
  276.                 'alone' => false
  277.             ),
  278.             'php' => array(
  279.                 'method' => 'asidesUrlLists',
  280.                 'urls' => $spectacles_a_venir,
  281.                 'url' => '/spectacles/?d=key_day',
  282.                 'params' => array(
  283.                     'activate' => $day_spectacles
  284.                 )
  285.             ),
  286.             'title' => html_entity_decode('Recherche par période')
  287.         )]);
  288.         $asides->load(['recherche_par_periode' => array(
  289.             'exec' => array(
  290.                 'htmlend' => true
  291.             ),
  292.             'action' => '/spectacles/theatre/recherche'
  293.         )]);
  294.         //$asides->load('spectacles_rechercher_nom');
  295.         $asides->load(['url_lists_alone,tn_cdn_sn' => array(
  296.             'php' => [
  297.                 'method' => 'tn_cdn_sn',
  298.                 'url' => '/key_controller/liste/structures/generate_params',
  299.                 'params' => array(
  300.                     'activate' => (isset($this->context['view']->idtypestructure)) ? $this->context['view']->idtypestructure 'ALL',
  301.                     'url_custom' => ['ALL' => '/spectacles/']
  302.                 ),
  303.                 'structure' => array(
  304.                     'area' => $this->context['view']->area ?? null,
  305.                     'type' => $this->context['view']->type_spectacle ?? null,
  306.                     'structure_classic' => array(
  307.                         'd' => 'v_days',
  308.                         'type' => 'v_type',
  309.                         's' => 'v_saison',
  310.                         'y' => 'v_year',
  311.                         'dateend' => 'v_dateend',
  312.                         'datestart' => 'v_datestart',
  313.                         'idtypestructure' => 'key_structure'
  314.                     )
  315.                 )
  316.             ],
  317.             'title' => 'Voir dans'
  318.         )]);
  319.         $asides->load(['common_carte' => array(
  320.             'url' => '/spectacles/theatre/region/area/get_id?carte_version=svg'
  321.         )]);
  322.         $asides->load('common_carrer_informations');
  323.         asides::setEntityManager($this->em);
  324.         asides::loadaside('Publicite')->addWithNational($asides); //$this->area
  325.         $asides->load(['common_participer'=>array(
  326.             'php' => array(
  327.                 'method' => 'asidesUrlLists_Ajoutez'
  328.             )
  329.         )]);
  330.         $this->context['view']->aside $asides->view($this->context['view']);
  331.         return $this->view('spectacles/view.html.twig');
  332.     }
  333.     // }}}
  334.     // {{{ region_common()
  335.     /** region_common
  336.      *
  337.      */
  338.     public function region_common(){
  339.         $nb_day_default 90;
  340.         $this->getCommonSearch(array(
  341.             'nb_days' => $nb_day_default,
  342.         ));
  343.         $choix_type = array('SN','TN','CDN','AP');
  344.         $this->context['idtypestructure'] = null;
  345.         if(!empty($_REQUEST['idtypestructure']) && in_array($_REQUEST['idtypestructure'], $choix_type)) {
  346.             $this->context['idtypestructure'] = filter_var($_REQUEST['idtypestructure'], FILTER_SANITIZE_STRING);
  347.         }
  348.         $this->context['view']->menu_structures = array(
  349.             'region' => array('url'=> '/spectacles/theatre/region/generate_params','name'=> 'Tous les spectacles','id'=>'region'),
  350.             'region-videos' => array('url'=> '/spectacles/theatre/region-videos/generate_params','name'=> 'Spectacles avec vidéos','id'=>'region-videos'),
  351.             'textes-videos' => array('url'=> '/textes/editions/auteurs-spectacles/generate_params','name'=> 'Les textes par leurs auteurs','id'=>'textes-videos'),
  352.             'premieres' => array('url' => '/premieres/regions/area/{p_area}''name' => 'Premières'),
  353.             // 'region-coprod' => array('url'=> '/spectacles/theatre/region-coprod/generate_params','name'=> 'En tournée','id'=>'region-coprod'),
  354.             // 'region-evenements' => array('url'=> '/spectacles/theatre/region-evenements','name'=> 'Évènements','id'=>'region-evenements'),
  355.             // 'region-programmes' => array('url'=> '/contacts/archives/programmes/area/'.$this->context['params']['area'],'name'=> 'Programmes en PDF','id'=>'region-programmes'),
  356.         );
  357.         $this->context['region']['days_array'] = array(
  358.             => array('name' => 'Dans les 7 prochains jours''key_day' => '7'),
  359.             30 => array('name' => 'Dans les 30 prochains jours''key_day' => '30'),
  360.             90 => array('name' => 'Dans les 3 prochains mois''key_day' => '90'),
  361.             365 => array('name' => 'Dans les 12 prochains mois','key_day' => '365')
  362.         );
  363.         if(!in_array($this->context['view']->daysarray_column($this->context['region']['days_array'], 'key_day'))){
  364.             $this->context['view']->days $nb_day_default;
  365.         }
  366.         $this->context['view']->nb_jour $this->context['view']->days;
  367.         if($this->context['params']['area'] == 43){
  368.             $this->context['view']->menu_structures['region-soutien'] = array('url'=> '/spectacles/theatre/region-soutien','name'=> 'Avec le soutien de la région','id'=>'region-soutien');
  369.         }
  370.         $params $this->context['params'];
  371.         $city null;
  372.         if(array_key_exists('city'$params) || (isset($_REQUEST['city']) && !empty($_REQUEST['city']))) {
  373.             $value = (array_key_exists('city'$params)) ? $params['city'] : $_REQUEST['city'];
  374.             $this->context['view']->city $city filter_var($value);
  375.         }
  376.         // regions
  377.         $regions $this->em->getRepository(Bigregions::class);
  378. //        $this->context['form']->addElement('select', 'area', 'Choisissez dans la liste', $regions->getArea('Choisissez dans la liste',false,false,true), array('class' => 'select_language', 'id'=>'area'));
  379.         $area null;
  380.         $params $this->context['params'];
  381.         if(array_key_exists('area',$params) && (is_numeric($params['area']) || strlen($params['area'])<3)) {
  382.             $area $params['area'];
  383.         }
  384.         if($regions->my_is_int($area)) {
  385.             $sql_area $regions->getZipCode($area'contacts');
  386.         } else {
  387.             $country_name $this->spectacles->getNameCountry($area);
  388.             $this->context['view']->other_country true;
  389.             $sql_area ' contacts.country=\''.$this->spectacles->escape($area).'\' ';
  390.         }
  391.         $this->context['sql_area'] = $sql_area;
  392.         // si pas de région ou de ville
  393.         if (empty($area) && empty($city)) {
  394.             return $this->redirect('/spectacles/');
  395.         }
  396.         // nom de la région et code
  397.         if(!empty($area)) {
  398.             if(!empty($country_name)) {
  399.                 $this->context['view']->country_name $country_name;
  400.             } else {
  401.                 $this->context['view']->region_name $regions->getRegionName($area);
  402.             }
  403.             $this->context['view']->area $area;
  404.             //SQL : si region, recherche des spectacles dans la région ou le pays
  405.             $this->context['where_zone'] = $sql_area;
  406.             
  407.             if (!$sql_area) {
  408.                 return $this->redirectToRoute("spectacles_region_videos");
  409.             }
  410.         }
  411.         // si ville, recherche des spectacles dans la ville
  412.         if(!empty($city)) {
  413.             $this->context['where_zone']  = ' contacts.city LIKE \'%'.$this->spectacles->escape($city).'%\' ';
  414.         }
  415.         $this->context['region']['vignette'] = array('width'=>100,'height'=>100,'direction'=>'crop');
  416.         $this->context['view']->insert_block 'spectacles/region.choix.inc.html';
  417.         // trouver le spectacle avec la date la plus éloignée ou les dates
  418.         $sql 'SELECT MAX(sc.date) FROM schedules sc, contacts
  419.                 WHERE sc.idcontact=contacts.idcontact AND '.$sql_area.' AND sc.date>=\''.date('Y-m-d').'\'';
  420.         $this->context['view']->datemax $this->spectacles->queryOne($sql);
  421.         $this->context['sql_date'] = null;
  422.         if(!empty($this->context['view']->datestart) && !empty($this->context['view']->dateend)) {
  423.             // les dates doivent être entre hier et le max
  424.             if($this->context['view']->datestart<date('Y-m-d')) {
  425.                 $this->context['view']->datestart date('Y-m-d');
  426.             }
  427.             if($this->context['view']->dateend>$this->context['view']->datemax) {
  428.                 $this->context['view']->dateend $this->context['view']->datemax;
  429.             }
  430.             $this->context['sql_date'] = ' AND sc.date BETWEEN
  431.                         \''.$this->spectacles->escape($this->spectacles->getFormeDate($this->context['view']->datestart)).'\' AND
  432.                         \''.$this->spectacles->escape($this->spectacles->getFormeDate($this->context['view']->dateend)).'\' ';
  433.             //mises-en-forme des dates au format de Francais
  434.             $this->context['view']->datestart $this->spectacles->getFormeDate($this->context['view']->datestart,$GLOBALS['format_date']['fr']);
  435.             $this->context['view']->dateend $this->spectacles->getFormeDate($this->context['view']->dateend,$GLOBALS['format_date']['fr']);
  436.         }
  437.         $this->spectacles->setZoneRecherche($this->context['where_zone'] ?? null);
  438. //        require_once PATH_ADMIN."app/common/helpers/aside/asidesUrlPagination.php";
  439.         $urlpagination = new asidesUrlPagination(
  440.             $this->context['view']->menu_structures[$this->context['action']]['url'],
  441.             array(
  442.                 'd' => $this->context['view']->days,
  443.                 'structure' => $this->context['idtypestructure'],
  444.                 'area' => $area
  445.             ),
  446.             $this->context
  447.         );
  448.         $this->context['view']->url_custom_pagination $urlpagination->url_pagination();
  449.     }
  450.     // }}}
  451.     // {{{ region_common_asides()
  452.     /** Les asides communs aux spectacles
  453.      *
  454.      */
  455.     public function region_common_asides(){
  456.         $this->context['view']->use_addthis true;
  457.         $asides_top = new asides();
  458.         $asides_top->load(['aside_top' => array(
  459.             'php' => array(
  460.                 'method' => 'asidesUrlRegions',
  461.             )
  462.         )
  463.         ]);
  464.         $this->context['view']->aside_top $asides_top->view($this->context['view']);
  465.         //pour afficher les asides correctements
  466.         //on supprime certains asides pour cette action
  467.         $asides_show_periode true;
  468.         $is_region_videos true// Pour la couleur vidéos
  469.         if(in_array($this->context['action'],['region-videos'])){
  470.             $asides_show_periode false;
  471.             $is_region_videos false;
  472.         }
  473.         if(!$asides_show_periode){
  474.             unset($this->context['view']->menu_structures['region']);
  475.             unset($this->context['view']->menu_structures['region-coprod']);
  476.         }
  477.         else{
  478.             unset($this->context['view']->menu_structures['region-videos']);
  479.             unset($this->context['view']->menu_structures['textes-videos']);
  480.         }
  481.         // aside
  482.         $asides = new asides();
  483.         $asides->load(['url_lists' => array(
  484.             'exec' => ($is_region_videos) ? ['htmlstart' => true'color'=> 'spectacles'] : ['htmlstart' => true'color'=> 'videos'],
  485.             'php' => array(
  486.                 'method' => 'asidesUrlLists',
  487.                 'urls' => $this->context['view']->menu_structures,
  488.                 'params' => array(
  489.                     'activate' => $this->context['view']->action
  490.                 ),
  491.                 'structure' => array(
  492.                     'area' => $this->context['view']->area ?? null,
  493.                     'structure_classic' => [
  494.                         'd' => $this->context['view']->days,
  495.                         'structure' => $this->context['idtypestructure'],
  496.                     ]
  497.                 )
  498.             ),
  499.             'title' => html_entity_decode('&Agrave; l\'affiche')
  500.         )]);
  501.         $asides->load(['url_lists,spectacles_a_venir' => array(
  502.             //Nous fermons ou non l'aside, selon l'état de la variable $asides_show_periode
  503.             'exec' => ($asides_show_periode) ? ['alone' => false] : ['htmlend' => true],
  504.             'php' => array(
  505.                 'method' => 'asidesUrlLists',
  506.                 'urls' => $this->context['region']['days_array'],
  507.                 'url' => '/spectacles/theatre/key_action/area/{v_area}',
  508.                 'params' => array(
  509.                     'key_action' => $this->context['view']->action,
  510.                     'key_structure' => $this->context['idtypestructure'],
  511.                     'activate' => $this->context['view']->days
  512.                 ),
  513.                 'structure' => array(
  514.                     'structure_classic' => array(
  515.                         'idtypestructure' => 'key_structure',
  516.                         'd' => 'key_day'
  517.                     )
  518.                 )
  519.             ),
  520.             'title' => html_entity_decode('Recherche par période')
  521.         )
  522.         ]);
  523.         //nous affichons les asides de période si l'état de la variable le permet ($asides_show_periode)
  524.         if($asides_show_periode){
  525.             $asides->load(['recherche_par_periode' => array(
  526.                 'exec' => ['alone' => false],
  527.                 'action' => $this->context['view']->url_custom_pagination
  528.             )
  529.             ]);
  530.             $asides->load(['spectacles_choisir_ville' => array(
  531.                 'exec' => ['alone' => false],
  532.                 'url' => $this->context['view']->url_custom_pagination,
  533.                 'title' => 'Recherche par ville'
  534.             )]);
  535.             $asides->load(['url_lists,tn_cdn_sn' => array(
  536.                 'exec' => ['htmlend' => true],
  537.                 'php' => [
  538.                     'method' => 'tn_cdn_sn',
  539.                     'url' => '/key_controller/generate_params',
  540.                     'params' => array(
  541.                         'activate' => (!is_null($this->context['idtypestructure'])) ? $this->context['idtypestructure'] : 'ALL',
  542.                         'key_action' => $this->context['view']->action,
  543.                         'key_area' => $this->context['view']->area
  544.                     ),
  545.                     'structure' => array(
  546.                         'theatre' => 'key_action',
  547.                         'area' => 'key_area',
  548.                         'structure_classic' => array(
  549.                             'idtypestructure' => 'key_structure',
  550.                             'd' => $this->context['view']->days
  551.                         )
  552.                     )
  553.                 ],
  554.                 'title' => 'Rechercher par label'
  555.             )]);
  556.         }
  557.         if(in_array($this->context['action'],['region']))
  558.         {   $voir_videos = array(
  559.             array(
  560.                 'name' => 'Spectacles avec vidéos',
  561.             )
  562.         );
  563.             $asides->load(['url_lists_alone,voir_videos'=> array(
  564.                 'php' => array(
  565.                     'method' => 'asidesUrlLists',
  566.                     'urls' => $voir_videos,
  567.                     'url' => '/spectacles/theatre/region-videos/area/key_area',
  568.                     'params' => array(
  569.                         'key_area' => $this->context['view']->area
  570.                     )
  571.                 ),
  572.                 'title' => 'Voir aussi'
  573.             )]);
  574.             $asides->load(['common_carrer_informations'=> array(
  575.                 'color' => 'spectacles'
  576.             )]);
  577.         }
  578.         //Chargement de la pub par région
  579.         asides::setEntityManager($this->em);
  580.         asides::loadaside('Publicite')->addWithRegion($asides, ['region' => $this->context['view']->area ?? null]); //$this->area
  581.         $asides->load(['common_carte' => array(
  582.             'exec' => ($is_region_videos) ? ['color'=> 'spectacles'] : ['color'=> 'videos'],
  583.             'url' => ($is_region_videos) ? "/spectacles/theatre/region/area/get_id" "/spectacles/theatre/region-videos/area/get_id" ,
  584.         )]);
  585.         $this->context['view']->aside $asides->view($this->context['view']);
  586.         //Tous les asides communs
  587.         // $this->region_common_asides();
  588.     }
  589.     // }}}
  590.     // {{{ action_region()
  591.     /** Spectacles à l'affiche dans les regions
  592.      *
  593.      * @Route("/spectacles/theatre/region/area/{p_area}", name="spectacles_region_area")
  594.      * @Route("/spectacles/theatre/region/area/{p_area}/liste", name="spectacles_region_area_liste")
  595.      *
  596.      */
  597.     public function action_region($p_area null)
  598.     {
  599.         $this->context['params']['area'] = $p_area;
  600.         $this->view->action $this->context['action'] = 'region';
  601.         //Les données communes aux pages
  602.         $this->region_common();
  603.         $files $this->em->getRepository(Files::class);
  604.         // formulaire de saisie
  605.         $city_list $this->spectacles->getCityListSpectacle('prochains',180$this->context['sql_area']);
  606.         ksort($city_listSORT_LOCALE_STRING);
  607.         $this->context['formAsideSearch']->add('city'ChoiceType::class, [
  608.             'label' => 'A l\'affiche à',
  609.             'placeholder' => 'Choisissez une ville...',
  610.             'choices' => array_flip($city_list)
  611.         ]);
  612.         $this->context['formAsideSearch']->add('datestart'TextType::class, [
  613.             'label' => 'Entre',
  614.             'attr' => [
  615.                 'size'=>'10',
  616.                 'id'=>'datestart'
  617.             ]
  618.         ]);
  619.         $this->context['formAsideSearch']->add('dateend'TextType::class, [
  620.             'label' => 'et',
  621.             'attr' => [
  622.                 'size'=>'10',
  623.                 'id'=>'dateend'
  624.             ]
  625.         ]);
  626.         $this->getCommonSearchView();
  627.         $limit_spectacles 10;
  628.         $this->context['view']->region true;
  629.         // spectacles dans la region
  630.         $params_sql_regions = array(
  631.             'params' => array(
  632.                 'where' => $this->context['where_zone'].$this->context['sql_date'],
  633.                 'limit' => 'all',
  634.             ),
  635.             'special' => array(
  636.                 'prochains' => true,
  637.                 'publish_valid' => 1,
  638.                 'prochains' => $this->context['view']->days
  639.             ),
  640.             'dbg' => array('affiche_region','A l\'affiche en région')
  641.         );
  642.         if(!is_null($this->context['idtypestructure'])){
  643.             $params_sql_regions['special']['idtypestructure'] = $this->context['idtypestructure'];
  644.             $params_sql_regions['special']['structures_specifiques'] = $this->context['idtypestructure'];
  645.         }
  646.         $this->context['view']->nb_spectacles_total $this->spectacles->countListSpectacles($params_sql_regions);
  647.         //La pagination
  648.         $urlpagination = new asidesUrlPagination(
  649.             $this->context['view']->menu_structures[$this->context['action']]['url'],
  650.             array(
  651.                 'd' => $this->context['view']->days,
  652.                 'structure' => $this->context['idtypestructure'],
  653.                 'area' => $this->context['view']->area,
  654.                 'datestart' => $this->context['view']->datestart,
  655.                 'dateend' => $this->context['view']->dateend
  656.             ),
  657.             $this->context
  658.         );
  659.         $this->perPage $pagerOptions['perPage'] = 500//On supprime la limite de résultats (10/03/2020 #79)
  660.         $pagination_url_custom $urlpagination->url_pagination();
  661.         $this->context['view']->pagination $this->getPagination($this->context['view']->nb_spectacles_total10, array('url_custom' => $pagination_url_custom));
  662.         $this->context['view']->pagination['totalItems'] = $this->context['view']->nb_spectacles_total;
  663.         $this->context['view']->pagination['spectacle'] = true;
  664.         $params_sql_regions['params']['limit'] = array($this->getLimitStart(),$this->perPage);
  665.         // supprimer la limite pour la recherche par date
  666.         if(!empty($sql_date)) {
  667.             $params_sql_regions['params']['limit'] = array(0,500);
  668.             unset($params_sql_regions['special']['prochains']);
  669.             // définir la date de début de recherche
  670.             $params_sql_regions['special']['depuis_le'] = $this->context['view']->datestart;
  671.         }
  672.         //on prépare la requête pour compter le nombre de répsentation
  673.         $params_query_count_schedules $params_sql_regions;
  674.         unset($params_query_count_schedules['params']['limit']); //on supprime la imite pour récupérer le nombre total de représentations
  675.         $params_query_count $this->spectacles->countListSchedules($params_query_count_schedules);
  676.         $this->context['view']->pagination['total_dates'] = number_format($params_query_count0''' '); //on assigne le nombre total à la vue
  677.         $this->context['view']->pagination['representation_spectacle'] = true//on force l'affichage des représentations
  678.         $spectacles_region $this->spectacles->getListSpectacles($params_sql_regions,$this->context['region']['vignette'],false,array('allauthors' => true'carrer_couleurs' => true));
  679.         // suppléments
  680.         foreach($spectacles_region as $k=>$v) {
  681.             //ajout footer_contact pour region spectacles
  682.             $spectacles_region[$k]['footer_contact'] = true;
  683.             // titre du theatre en haut
  684.             $spectacles_region[$k]['bloc'] = true;
  685.             $spectacles_region[$k]['city_top'] = $spectacles_region[$k]['city'];
  686.             // voir si le contact du spectacle est un partenaire et récup son logo
  687.             $bandeau $files->getAssociateFile($v['contact']['idcontact'], 'contacts','class_petit_bandeau');
  688.             if(!empty($bandeau)) {
  689.                 //$spectacles_region[$k]['contact']['bandeau_partenaire'] = $bandeau['filepath']; // sans retaille
  690.                 $spectacles_region[$k]['contact']['bandeau_partenaire'] = $_ENV['URL_DIRECTORYUPLOAD'].$files->getThumbnail($bandeau['file'],285,'thumb');
  691.             }
  692.         }
  693.         
  694.         if (isset($city_list) && isset($this->context['view']->city)) {
  695.             $this->context['view']->city_name $city_list[$this->context['view']->city];
  696.         }
  697.         $this->context['view']->spectacles_region $spectacles_region;
  698.         //Tous les asides communs
  699.         $this->region_common_asides();
  700.         return $this->view('spectacles/region.html.twig');
  701.     }
  702.     // }}}
  703.     // {{{ action_region()
  704.     /** Spectacles à l'affiche dans les regions
  705.      *
  706.      */
  707.     public function action_region_coprod()
  708.     {
  709.         //Les données communes aux pages
  710.         $this->region_common();
  711.         $regions $this->em->getRepository(Bigregions::class);
  712.         $area $this->context['view']->area;
  713.         $this->context['view']->no_city_list true;
  714.         $this->context['view']->regioncoprod true;
  715.         // spectacles en tournée coproduit par des contacts de la région
  716.         // Productteur (17), coprod (18), prod délégué (19). Recherche sur spectacle_contact+idrole
  717.         $where_idcontact ' sct.idcontact IN (SELECT c.idcontact FROM contacts WHERE 1 '.$this->context['sql_area'].')';
  718.         $params_sql_coprod_regions = array(
  719.             'params' => array(
  720.                 'from' => 'spectacle_contact sct',
  721.                 'where' => ' AND sct.idspectacle=s.idspectacle AND sct.idrole IN (17,18,19) AND '.$where_idcontact,
  722.                 'select' => 'contacts.idcontact as datecontact',
  723.                 'limit' => 'all'
  724.             ),
  725.             'special' => array(
  726.                 'prochains' => true
  727.             ),
  728.         );
  729.         if(!is_null($this->context['idtypestructure'])){
  730.             $params_sql_coprod_regions['special']['idtypestructure'] = $this->context['idtypestructure'];
  731.         }
  732.         $this->context['view']->nb_spectacles_total $this->spectacles->countListSpectacles($params_sql_coprod_regions);
  733.         $this->context['view']->pagination $this->getPagination($this->context['view']->nb_spectacles_total10);
  734.         $this->context['view']->pagination['totalItems'] = $this->context['view']->nb_spectacles_total;
  735.         // $params_sql_coprod_regions['params']['limit'] = array($paged_data['from']-1, $pagerOptions['perPage']);
  736.         $params_sql_coprod_regions['params']['limit'] = array($this->getLimitStart(),$this->perPage);
  737.         $spectacles_coprod_region $this->spectacles->getListSpectacles($params_sql_coprod_regions,$this->context['region']['vignette'],true,array('allauthors' => true));
  738.         // parcourir pour trouver les coprod (17,18,19)
  739.         foreach($spectacles_coprod_region as $k=>$v) {
  740.             // trouver la prochaine date dans un lieu qui n'est pas dans la région ou dans le pays
  741.             if(!empty($other_country)) {
  742.                 $sql_proch_city_date '
  743.                     SELECT DISTINCT(contacts.zip), contactsc.city
  744.                     FROM schedules sc, contacts
  745.                     WHERE sc.idcontact=contacts.idcontact AND contacts.country!=\''.$this->spectacles->escape($area).'\'
  746.                     AND sc.idspectacle='.$k.'
  747.                     AND sc.date>=\''.date('Y-m-d').'\' ORDER BY sc.date LIMIT 0,1';
  748.             } else {
  749.                 $sql_proch_city_date '
  750.                     SELECT DISTINCT(contacts.zip), contacts.city
  751.                     FROM schedules sc, contacts contacts
  752.                     WHERE sc.idcontact=contacts.idcontact
  753.                     '.$regions->getZipCode($area,'contacts','zip','NOT').'
  754.                     AND sc.idspectacle='.$k.'
  755.                     AND sc.date>=\''.date('Y-m-d').'\' ORDER BY sc.date LIMIT 0,1';
  756.             }
  757.             $proch_city_date $this->spectacles->queryRow($sql_proch_city_date);
  758.             if(!PEAR::isError($proch_city_date) && !empty($proch_city_date)) {
  759.                 // trouver les autres dates dans ce lieux hors de la région
  760.                 $sql_proch_ext 'SELECT MIN(sc.date) as datestart, MAX(sc.date) as dateend, c.city
  761.                                   FROM schedules sc, contacts
  762.                                   WHERE sc.idcontact=contacts.idcontact
  763.                                   AND sc.idspectacle='.$k.'
  764.                                   AND contacts.zip=\''.$proch_city_date['zip'].'\'
  765.                                   AND sc.date>=\''.date('Y-m-d').'\' ';
  766.                 $prochedate_ext $this->spectacles->queryAll($sql_proch_ext);
  767.                 // les mettre au format français
  768.                 $prochedate_ext[0]['datestart'] = $this->spectacles->getFormeDate($prochedate_ext[0]['datestart'],"%a %d/%m/%Y",true);
  769.                 $prochedate_ext[0]['dateend'] = $this->spectacles->getFormeDate($prochedate_ext[0]['dateend'],"%a %d/%m/%Y",true);
  770.                 // si datestart égal dateend, ne garder que dateend
  771.                 if($prochedate_ext[0]['datestart']==$prochedate_ext[0]['dateend']) {
  772.                     $prochedate_ext[0]['datestart'] = null;
  773.                 }
  774.             } else {
  775.                 $prochedate_ext null;
  776.             }
  777.             // si prochdate_ext
  778.             if(!empty($prochedate_ext)) {
  779.                 // si il n'y a que une date proche
  780.                 if(empty($prochedate_ext[0]['datestart'])) {
  781.                     $spectacles_coprod_region[$k]['prochdate'] = $prochedate_ext[0]['dateend'];
  782.                     $spectacles_coprod_region[$k]['city'] = $prochedate_ext[0]['city'];
  783.                 } else {
  784.                     $spectacles_coprod_region[$k]['periode'] = $prochedate_ext[0];
  785.                     $spectacles_coprod_region[$k]['prochdate'] = null;
  786.                 }
  787.                 $coproducteurs null;
  788.                 $sql_coprod 'SELECT contacts.idcontact,contacts.organisation,contacts.url_clean FROM
  789.                                 contacts, spectacle_contact sct
  790.                                 WHERE
  791.                                 sct.idcontact=contacts.idcontact
  792.                                 '.$this->context['sql_area'].'
  793.                                 AND sct.idspectacle='.$k.'
  794.                                 AND sct.idrole IN (17,18,19) GROUP BY contacts.`idcontact`';
  795.                 $coproducteurs $this->spectacles->queryAll($sql_coprod,array(),null,false);
  796.                 if(!PEAR::isError($coproducteurs) && !empty($coproducteurs)) {
  797.                     $spectacles_coprod_region[$k]['coprod'] = noPunct($coproducteurs);
  798.                 }
  799.             } else {
  800.                 unset($spectacles_coprod_region[$k]);
  801.             }
  802.         }
  803.         $this->context['view']->spectacles_coprod_region $spectacles_coprod_region;
  804.         //Tous les asides communs
  805.         $this->region_common_asides();
  806.     }
  807.     // }}}
  808.     // {{{ action_region_evenements()
  809.     /** Spectacles à l'affiche dans les regions
  810.      *
  811.      */
  812.     public function action_region_evenements()
  813.     {
  814.         //Les données communes aux pages
  815.         $this->region_common();
  816.         $this->context['view']->regionevenements true;
  817.         $area $this->context['view']->area;
  818.         // récupérer les prochains évènements proposés en région qui sont validé et sont des évènements
  819.         $news $this->em->getRepository(News::class);
  820.         $news_params = array(
  821.             'params' => array(
  822.                 'limit' => array(0100),
  823.             ),
  824.             'special' => array(
  825.                 'prochains' => true,
  826.                 'publish_valid' => true,
  827.                 'type_news' => 'news',
  828.             ),
  829.             'dbg' => array('prochains_news','Prochains évènements'),
  830.         );
  831.         if($news_params != "ALL"){
  832.             $params_sql_coprod_regions['special']['idtypestructure'] = $this->context['idtypestructure'];
  833.         }
  834.         if(my_is_int($area)) {
  835.             $news_params['special']['idbigregion'] = array($area);
  836.         } elseif($area=='BE' || $area=='CH') {
  837.             $news_params['special']['country'] = array($area);
  838.         }
  839.         $this->context['view']->news_list $news->getListNews($news_params);
  840.         $news_params['special']['type_news'] = 'spectacles';
  841.         $this->context['view']->spectacles_list $news->getListNews($news_params);
  842.         //Tous les asides communs
  843.         // $this->region_common_asides();
  844.     }
  845.     // }}}
  846.     // {{{ action_region_videos()
  847.     /** Spectacles à l'affiche dans les regions
  848.      *
  849.      * @Route("/spectacles/theatre/region-videos/", name="spectacles_region_videos")
  850.      * @Route("/spectacles/theatre/region-videos/area/{p_area}", name="spectacles_region_videos_area")
  851.      *
  852.      */
  853.     public function action_region_videos($p_area null)
  854.     {
  855.         $this->context['params']['area'] = $p_area;
  856.         $this->view->action $this->context['action'] = 'region-videos';
  857.         //Les données communes aux pages
  858.         $route $this->region_common();
  859.         if ($route != null) {
  860.             return $route;
  861.         }
  862.         $this->context['view']->regionvideos true;
  863.         $sql_where_zone "";
  864.         if (isset($this->context['where_zone'])) {
  865.             $sql_where_zone 'AND '.$this->context['where_zone'];
  866.         }
  867.         // recherche de base
  868.         $params_query_affiches = array(
  869.             'where' => array(
  870.                 //array('spectacles','idspectaclegenre',1), // uniquement les spectacles
  871.                 $sql_where_zone// condition géographique
  872.             ),
  873.             'count' => true,
  874.             'affiche' => array('today' => $this->context['view']->days),
  875.             'limit' => array('all'),
  876.             'dbg' => array('affiche','Vidéos de spectacles à l\'affiche'),
  877.         );
  878.         //si l'utilisateur à sélectionné une région
  879.         if(!is_null($this->context['idtypestructure'])){
  880.             $params_query_affiches['special']['idtypestructure'] = $this->context['idtypestructure'];
  881.         }
  882.         $this->context['view']->nb_spectacles_total $this->em->getRepository(Multimedias::class)->getListMultimedias($params_query_affiches);
  883.         $this->context['view']->nb_spectacles_total count($this->context['view']->nb_spectacles_total);
  884.         // $this->context['view']->pagination = $paged_data = pagerSimple($pagerOptions);
  885.         $this->context['view']->pagination $this->getPagination($this->context['view']->nb_spectacles_total10);
  886.         $this->context['view']->pagination['totalItems'] = $this->context['view']->nb_spectacles_total;
  887.         $this->context['view']->pagination['spectacle'] = true;
  888.         $params_query_affiches['limit'] = array($this->getLimitStart(),$this->perPage);
  889.         // $params_query_affiches['limit'] = array($paged_data['from']-1, $pagerOptions['perPage']);
  890.         $format_vignette = array('width'=>$_ENV['VIGN_VIDEO_WIDTH'],'height'=>$_ENV['VIGN_VIDEO_HEIGHT'],'fleche'=>'none','ratio' => '169');
  891.         $this->context['view']->videos $this->em->getRepository(Multimedias::class)->getListMultimedias($params_query_affiches,$format_vignette,array('get_schedule' => true,'get_schedule_ville' => $this->context['view']->area ?? null,'format_vignette' => true));
  892.         // si vide, mettre plus de vidéos
  893.         if(empty($this->context['view']->videos)) {
  894.             $params_query_affiches['affiche'] = array('today' => 60);
  895.             $this->context['view']->videos $this->em->getRepository(Multimedias::class)->getListMultimedias($params_query_affiches,$format_vignette,array('get_schedule' => true,'format_vignette' => true));
  896.         }
  897.         //Tous les asides communs
  898.         $this->region_common_asides();
  899.         return $this->view('spectacles/region-videos.html.twig');
  900.     }
  901.     // }}}
  902.     // {{{ action_region_soutien()
  903.     /** Spectacles à l'affiche dans les regions
  904.      *
  905.      */
  906.     public function action_region_soutien()
  907.     {
  908.         //Les données communes aux pages
  909.         $this->region_common();
  910.         require_once PATH_LIBS.'Date/Date_time.php';
  911.         $this->context['view']->regionsoutien true;
  912.         // saison courante
  913.         $saison Date_time::getLastSaison(array(),true);
  914.         // spectacles soutenu par la region
  915.         $params_sql_soutien = array(
  916.             'params' => array(
  917.                 //'where' => $where_genre.$where_zone.$sql_date,
  918.                 'where' => $this->context['sql_date'],
  919.                 'limit' => array(0,50),
  920.             ),
  921.             'special' => array(
  922.                 //'prochains' => true,
  923.                 'publish_valid' => 1,
  924.                 'aide' => array(
  925.                     'idcontact' => 15995,
  926.                 ),
  927.                 'spectacle_aide' => true,
  928.                 'period' => array(
  929.                     'start' => $saison['start'],
  930.                     'end' => $saison['end'],
  931.                 ),
  932.             ),
  933.             'dbg' => array('soutien','Spectacles avec le soutien de la région'),
  934.         );
  935.         $this->spectacles->setZoneRecherche(false);
  936.         $this->context['view']->saison Date_time::getLastSaison();
  937.         $this->context['view']->spectacles_soutien $this->spectacles->getListSpectacles($params_sql_soutien,$this->context['region']['vignette'],false);
  938.         //Tous les asides communs
  939.         $this->region_common_asides();
  940.     }
  941.     // }}}
  942.     // {{{ action_structures()
  943.     /** Spectacles à l'affiche dans des types de structures en particulier
  944.      *
  945.      * @Route("/spectacles/liste/structures", name="spectacles_liste_structures")
  946.      *
  947.      */
  948.     public function action_structures()
  949.     {
  950.         $this->view->action $this->context['action'] = 'structures';
  951.         // structures recherchées
  952.         $vignette_image = array();
  953.         $choix_type = array(
  954.             'SN',
  955.             'TN',
  956.             'CDN',
  957.             'SC'
  958.         );
  959.         // les types de structure
  960.         $typesstructure_list $this->em->getRepository(Typesstructures::class)->getTypeStructureList(true,true,$choix_type);
  961.         // type de structure recherchée
  962.         if(!empty($_REQUEST['idtypestructure']) && array_key_exists($_REQUEST['idtypestructure'], $typesstructure_list)) {
  963.             $this->context['view']->idtypestructure filter_var($_REQUEST['idtypestructure'], FILTER_SANITIZE_STRING);
  964.         } else {
  965.             $this->context['view']->idtypestructure 'SN';
  966.         }
  967.         if(!empty($_REQUEST['directeur'])) {
  968.             $this->context['view']->requestDirecteur filter_var($_REQUEST['directeur'], FILTER_SANITIZE_STRING);
  969.         }
  970.         // type courant pour la vue
  971.         foreach(array('typestructure','typestructure_pluriel') as $s) {
  972.             $typesstructure_list_simple[$s] = strtolower($typesstructure_list[$this->context['view']->idtypestructure][$s]);
  973.         }
  974.         $typesstructure_list_simple['idtypestructure'] = $this->context['view']->idtypestructure;
  975.         $this->context['view']->typestructure $typesstructure_list_simple;
  976.         // contact pour ce type de structure
  977.         $contacts $this->getContactsByType($this->context['view']->idtypestructure);
  978.         $this->context['view']->menu_content = array(
  979.             'spectacles' => array(
  980.                 'name' => 'Tous les spectacles',
  981.                 'name_view' => 'spectacles',
  982.                 'key_type' => 'spectacles'
  983.             ),
  984.             'spectacles-videos' => array(
  985.                 'name' => 'Tous les spectacles avec vidéos',
  986.                 'name_view' => 'spectacles avec vidéos',
  987.                 'key_type' => 'spectacles-videos',
  988.                 'activate' => 'spectacles/videos'
  989.             ),
  990.             'coproductions' => array(
  991.                 'name' => 'Coproductions à l\'affiche',
  992.                 'name_view' => 'coproductions à l\'affiche',
  993.                 'key_type' => 'coproductions'
  994.             ),
  995.             'spectacles-directeurs' => array(
  996.                 'name' => 'Tous les directeurs',
  997.                 'name_view' => 'Tous les directeurs',
  998.                 'key_directeur' => '1',
  999.                 'activate' => 'spectacles/directeurs'
  1000.             )
  1001.         );
  1002.         if(empty($_REQUEST['type']) || !array_key_exists($_REQUEST['type'], $this->context['view']->menu_content)) {
  1003.             $this->context['view']->type 'spectacles';
  1004.         } else {
  1005.             $this->context['view']->type $_REQUEST['type'];
  1006.         }
  1007.         $this->context['view']->type_title $this->context['view']->menu_content[$this->context['view']->type];
  1008.         $this->context['view']->menu_jours = array(
  1009.             => array('name' => '3 prochains jours'),
  1010.             => array('name' => '7 prochains jours'),
  1011.             30 => array('name' => '30 prochains jours'),
  1012.             90 => array('name' => '3 prochains mois'),
  1013.             365 => array('name' => '12 prochains mois'),
  1014.         );
  1015.         $nb_day_default 365;
  1016.         $vignette_image = array('vignette' => array(
  1017.             'width'=>$_ENV['VIGN_SPECTACLE_WIDTH'],'height'=>$_ENV['VIGN_SPECTACLE_HEIGHT'],'direction'=>'crop','fleche'=>'moyen'
  1018.         ));
  1019.         $this->getCommonSearch(array(
  1020.             'saisons_annees' => $this->getSaisonsAndAnneesByContacts($contacts['ids']),
  1021.             'nb_days' => $nb_day_default,
  1022.         ));
  1023.         $this->getCommonSearchView();
  1024.         $where_idcontact ' AND contacts.idcontact IN ('.join(','$contacts['ids']).') ';
  1025.         // les spectacles à l'affiche avec des textes nonfictif
  1026.         if($this->context['view']->type=='spectacles') {
  1027.             $params_sql $this->setCommonSearchSpectacles(array(
  1028.                 'params' => array(
  1029.                     'where' => $where_idcontact.' AND s.publish=1 ',
  1030.                 ),
  1031.                 'special' => array(
  1032.                     'idcontact' => $contacts['ids'],
  1033.                     'prochains' => true
  1034.                 ),
  1035.                 'dbg' => array('spectacles''Spectacles à l\'affiche pour ces contacts')
  1036.             ));
  1037.             // directeur à l'affiche
  1038.             if(!empty($this->context['view']->requestDirecteur) && $this->context['view']->requestDirecteur) {
  1039.                 // On récupère la liste des directeurs associé avec la structure recherché par l'utilisateur
  1040.                 $persons $this->em->getRepository(Persons::class);
  1041.                 $sqlPersons $persons->getSQLPersons(
  1042.                     [
  1043.                         'limit' => 'all',
  1044.                     ],
  1045.                     [
  1046.                         'contact_person' => [
  1047.                             'idoffice' => 'directeur',
  1048.                             'idtypestructure' => $this->context['view']->idtypestructure,
  1049.                             'actual' => true,
  1050.                         ],
  1051.                     ]
  1052.                 );
  1053.                 $result $persons->queryAll($sqlPersons, array(),null,true);
  1054.                 // mises-à-jours de nouveaux paramètres à la requête des spectacles
  1055.                 unset($params_sql['special']['idcontact']);
  1056.                 $params_sql['special']['join'] = true;
  1057.                 $params_sql['special']['textfictif'] = 0;
  1058.                 $params_sql['special']['join_person'] = [
  1059.                     'idperson' => !empty($result) ? array_keys($result) : null,
  1060.                 ];
  1061.             }
  1062.             // Pour les autres cas de recherche (en dehors des directeurs)
  1063.             // on recherche les spectacles joués dans les structures associés aux TN/SN/CDN
  1064.             else {
  1065.                 $params_sql['params']['where'] .= $where_idcontact'';
  1066.             }
  1067.         }
  1068.         //les spectacles avec vidéos
  1069.         else if($this->context['view']->type=='spectacles-videos') {
  1070.             $getSpectaclesMultimedias true;
  1071.             $params_sql = array(
  1072.                 'where' => array(
  1073.                     array('spectacles','idspectaclegenre',1), // uniquement les spectacles
  1074.                     array('schedules','idcontact',$contacts['ids']), // uniquement dans ces structures
  1075.                 ),
  1076.                 'affiche' => array('today' => $this->context['view']->days),
  1077.                 'limit' => 'all',
  1078.                 'dbg' => array('affiche','Vidéos de spectacles à l\'affiche'),
  1079.             );
  1080.             if(!empty($this->context['params']['area'])){
  1081.                 $where_zone Theatre::factory('bigregions')->getZipCode(intval($this->context['params']['area']));
  1082.                 $params_sql['where'][] = str_replace('c.''contacts.'$where_zone); // condition géographiqu
  1083.             }
  1084.             //requête pour compter le nombre d'élément multimédias liés aux spectacles
  1085.             $sql_counts_multimedias $this->spectacles->getSQLSpectacles(
  1086.                 array(
  1087.                     'limit' => 'all',
  1088.                     'where' => 'AND s.idspectaclegenre = 1 AND sc.idcontact IN('.implode(','$contacts['ids']).')',
  1089.                 ),
  1090.                 array(
  1091.                     'prochains' => $this->context['view']->days,
  1092.                     'join' => true,
  1093.                     'count_only' => array(
  1094.                         'count_only_distinct' => 's.idSpectacle'
  1095.                     ),
  1096.                     'contenus_associes_multimedias' => true,
  1097.                 )
  1098.             );
  1099.             $params_sql['limit' ] = array(0,10);
  1100.         }
  1101.         //spectacles avec coproduction à l'affiche
  1102.         else {
  1103.             $where_coprod '
  1104.                 AND s.publish=1
  1105.                 AND sct.idspectacle=s.idspectacle
  1106.                 AND sct.idrole IN (17,18,19)
  1107.                 AND (
  1108.                     sct.idcontact IN ('.join(','$contacts['ids']).')
  1109.                     OR s.idcontactProduction IN ('.join(','$contacts['ids']).')
  1110.                 )';
  1111.             // rechercher les coproductions
  1112.             $params_sql $this->setCommonSearchSpectacles(array(
  1113.                 'params' => array(
  1114.                     'from' => 'TheatreCore\Entity\SpectacleContact sct',
  1115.                     'where' => $where_coprod,
  1116.                 ),
  1117.                 'special' => array(
  1118.                     'plus_proche' => true,
  1119.                     // 'idcontact' => $contacts['ids'],
  1120.                 ),
  1121.                 'dbg' => array('spectacles_coprod''Spectacles à l\'affiche pour ces contacts')
  1122.             ));
  1123.         }
  1124.         // recherche par région
  1125.         if(!empty($this->context['params']['area'])) {
  1126.             $where_zone Theatre::factory('bigregions')->getZipCode(intval($this->context['params']['area']));
  1127.             $this->spectacles->setZoneRecherche($where_zone); // définir la zone de recherche
  1128.         }
  1129.         //si nous recherchons du contenu multimedias (spectacles avec vidéos)
  1130.         if(isset($getSpectaclesMultimedias) && $getSpectaclesMultimedias){
  1131.             $this->context['view']->spectacles_videos true;
  1132.             $this->context['view']->nb_spectacles_total $sql_counts_multimedias->getOneOrNullResult();
  1133.             //on lui indique la limite
  1134.             $params_sql['limit'] = array($this->getLimitStart(),$this->perPage);
  1135.             $this->context['view']->spectacles $this->em->getRepository(Multimedias::class)->getListMultimedias($params_sql,array(),array('get_schedule' => $contacts['ids']));
  1136.             //on assigne à la vue la pagination et ces valeurs
  1137.             $this->context['view']->pagination $this->getPagination($this->context['view']->nb_spectacles_total10);
  1138.         }
  1139.         //si nous rechercons des spectacles "classiques" (sans multimedias)
  1140.         else{
  1141.             /* pagiantion */
  1142.             //nombre total de spectacles
  1143.             $this->context['view']->nb_spectacles_total $this->spectacles->countListSpectacles($params_sql);
  1144.             //nombre total de représenations
  1145.             $this->context['view']->nb_dates_total $this->spectacles->countListSchedules($params_sql);
  1146.             //on lui indique la limite
  1147.             $params_sql['params']['limit'] = array($this->getLimitStart(),$this->perPage);
  1148.             $this->context['view']->spectacles $this->setBandeauPartenaire(
  1149.                 $this->spectacles->getListSpectacles(
  1150.                     $params_sql,
  1151.                     $vignette_image,
  1152.                     false,
  1153.                     array('allauthors' => true'carrer_couleurs' => true)
  1154.                 )
  1155.             );
  1156.             //on assigne à la vue la pagination et ces valeurs
  1157.             $this->context['view']->pagination $this->getPagination($this->context['view']->nb_spectacles_total10, array(
  1158.                 'total_dates' => $this->context['view']->nb_dates_total
  1159.             ));
  1160.             $this->context['view']->pagination['spectacle'] = true;
  1161.             // $this->context['view']->pagination['representation_spectacle'] = true;
  1162.         }
  1163.         $this->getAsidesStructures();
  1164.         
  1165.         $this->title_page $title_page $this->context['view']->type_title['name'].' dans les '.$this->context['view']->typestructure['typestructure_pluriel'];
  1166.         // situation et titre meta
  1167.         $this->view->locate = array(
  1168.             '/spectacles/' => 'Spectacles',
  1169.             => $title_page,
  1170.         );
  1171.         return $this->view('spectacles/structures.html.twig');
  1172.     }
  1173.     // }}}
  1174.     // {{{ action_theatre_recherche()
  1175.     /** Recherche des spectacles dans les théâtres.
  1176.      *
  1177.      * @Route("/spectacles/theatre/recherche", name="spectacles_theatre_recherche")
  1178.      *
  1179.      * @return \Symfony\Component\HttpFoundation\Response
  1180.      *
  1181.      */
  1182.     public function action_theatre_recherche(Request $request)
  1183.     {  
  1184.         $this->context['formAsideSearch'] = $this->get('form.factory')->createNamedBuilder(''FormType::class);
  1185.         // formulaire de saisie recherche par titre
  1186.         $this->context['formAsideSearch']->add('title'TextType::class, [
  1187.             'label' => 'Mots du titre',
  1188.             'attr' => [
  1189.                 'size' => '35',
  1190.                 'placeholder' =>'Rechercher un texte'
  1191.             ]
  1192.         ]);
  1193.         $this->context['formAsideSearch']->add('search'SubmitType::class, [
  1194.             'label' => 'OK',
  1195.             'attr' => [
  1196.                 'class'=>'boutform'
  1197.             ]
  1198.         ]);
  1199.         $this->getCommonSearchView($request);
  1200.         $this->view->action $this->context['action'] = 'recherche';
  1201.         // instancier un objet spectacles
  1202.         $spectacle $this->em->getRepository(Spectacles::class);
  1203.         // regions
  1204.         $regions $this->em->getRepository(Regions::class);
  1205.         $form $this->setCommonSearch();
  1206.         // formulaire de saisie
  1207. //        $form->add('director', TextType::class, [
  1208. //            'label' => 'Metteur en sc&egrave;ne',
  1209. //            'attr' => [
  1210. //                'size' => '40'
  1211. //            ]
  1212. //        ]);
  1213.         $form->add('idcontact_publisher'RelationsType::class, [
  1214.             'label' => '&Eacute;diteur',
  1215.             'relat'=>'simple',
  1216.             'type_dbdo' => 'contacts',
  1217.             'required' => false
  1218.         ]);
  1219.         $form->add('idperson_author'RelationsType::class, [
  1220.             'label' => 'Auteur',
  1221.             'relat'=>'simple',
  1222.             'type_dbdo' => 'persons',
  1223.             'required' => false
  1224.         ]);
  1225.         $form->add('idperson_director'RelationsType::class, [
  1226.             'label' => 'Metteur en sc&egrave;ne',
  1227.             'relat'=>'simple',
  1228.             'type_dbdo' => 'persons',
  1229.             'required' => false
  1230.         ]);
  1231.         $form->add('area'ChoiceType::class, [
  1232.             'label' => 'Region',
  1233.             'choices' => array_flip($regions->getArea()),
  1234.             'attr' => [
  1235.                 'class' => 'select_language'
  1236.             ],
  1237.             'required' => false
  1238.         ]);
  1239.         // nombre de resultat pas page
  1240.         $nbpage_array = array('20'=>'20','40'=>'40','60'=>'60','80'=>'80');
  1241.         $form->add('nbpagelimit'ChoiceType::class, [
  1242.             'label' => 'Resultats par page',
  1243.             'choices' => $nbpage_array,
  1244.             'required' => false
  1245.         ]);
  1246.         // crriteres de tri
  1247.         $tri_array = array(
  1248.             'author'=>'Auteur',
  1249.             'titre'=>'Titre',
  1250.             'date'=>'Date'
  1251.         );
  1252.         $form->add('tri'ChoiceType::class, [
  1253.             'label' => 'Trier par',
  1254.             'choices' => array_flip($tri_array),
  1255.             'required' => false
  1256.         ]);
  1257.         // region en GET
  1258.         if(isset($_REQUEST['area'])) {
  1259.             $area $_REQUEST['area'];
  1260.             // prochain 180 jours
  1261.             if(isset($_GET['prochain'])) {
  1262.                 $prochain date('Y-m-d'mktime(000date('m'), date('d')+180,  date('Y')));
  1263.                 $this->view->prochain 180;
  1264.             }
  1265.         }
  1266.         $form $form->getForm();
  1267.         $form->handleRequest($request);
  1268.         // si le formulaire est validé
  1269.         if(($form->isSubmitted() && $form->isValid()) || isset($_GET['page']) || isset($area) || $this->context['formAsideSearch']->isSubmitted() || isset($_GET['start'])) {
  1270.             // recuperation de variable
  1271.             $title $form->get('title')->getData();
  1272.             if(empty($title) && isset($_GET['title'])) {
  1273.                 $title $_GET['title'];
  1274.             }
  1275.             if(!empty($title)) {
  1276.                 $this->view->title $title;
  1277.             }
  1278.             if($this->context['formAsideSearch']->isSubmitted() || isset($_GET['start'])) {
  1279.                 
  1280.                 if ($this->context['formAsideSearch']->get('title')->getData() != null) {
  1281.                     $title $this->context['formAsideSearch']->get('title')->getData();
  1282.                 } else if (empty($title) && isset($_GET['title'])) {
  1283.                     $title $_GET['title'];
  1284.                 } else {
  1285.                     $title "spectacle";
  1286.                 }
  1287.             }
  1288. //            $director = $form->get('director')->getData();
  1289. //            if(empty($director) && isset($_GET['director'])) {
  1290. //                $director = $_GET['director'];
  1291. //            }
  1292. //            if(!empty($director)) {
  1293. //                $this->view->director = $director;
  1294. //            }
  1295.             $datestart $form->get('datestart')->getData();
  1296.             if(empty($datestart) && isset($_GET['datestart'])) {
  1297.                 $datestart $_GET['datestart'];
  1298.             }
  1299.             if(!empty($datestart)) {
  1300.                 $this->view->datestart $spectacle->getFormeDate($datestart,$GLOBALS['format_date']['fr']);
  1301.             }
  1302.             $dateend $form->get('dateend')->getData();
  1303.             if(empty($dateend) && isset($_GET['dateend'])) {
  1304.                 $dateend $_GET['dateend'];
  1305.             }
  1306.             if(!empty($dateend)) {
  1307.                 $this->view->dateend $spectacle->getFormeDate($dateend,$GLOBALS['format_date']['fr']);
  1308.             }
  1309.             if(!isset($area)) {
  1310.                 $area $form->get('area')->getData();
  1311.             }
  1312.             if(empty($area) && isset($_GET['area'])) {
  1313.                 $area $_GET['area'];
  1314.             }
  1315.             if(!empty($area)) {
  1316.                 $this->view->area $regions->getRegionName($area);
  1317.             }
  1318.             $nbpagelimit $form->get('nbpagelimit')->getData();
  1319.             if(empty($nbpagelimit) && isset($_GET['nbpagelimit'])) {
  1320.                 $pagerOptions['perPage'] = $_GET['nbpagelimit'];
  1321.                 $nbpagelimit $_GET['nbpagelimit'];
  1322.             } else {
  1323.                 $pagerOptions['perPage'] = $nbpagelimit;
  1324.             }
  1325.             if(empty($nbpagelimit) || !array_key_exists($nbpagelimit,$nbpage_array)) {
  1326.                 $pagerOptions['perPage'] = 20;
  1327.             }
  1328.             // requete normale
  1329.             $sql_normal 'SELECT DISTINCT(s.idspectacle), s.idtypespectacle, s.url_clean, ty.typespectacle, s.creation_date, s.textfictif,
  1330.                                        s.title as titlespectacle,
  1331.                                        t.title as titletext, t.idtext, t.type as type, ty.typespectacle,
  1332.                                        sc.date as prochdate, c.city';
  1333.             // compter les resultats
  1334.             $sql_count 'SELECT COUNT(DISTINCT(s.idspectacle)';
  1335.             $sql null;
  1336.             // dd($request, $sql, $sql_normal);
  1337.             if(!empty($title)) {
  1338.                 $title htmlspecialchars($titleENT_COMPAT);
  1339.                 $title trim($title);
  1340.                 $sql_normal .= ', MATCH(seat.title) AGAINST (\''.$spectacle->escape($title).'\') AS cpt, MATCH(seas.title) AGAINST (\''.$spectacle->escape($title).'\') as cpts';
  1341.                 $sql_count .= ', MATCH(seat.title) AGAINST (\''.$spectacle->escape($title).'\'), MATCH(seas.title) AGAINST (\''.$spectacle->escape($title).'\')';
  1342.             }
  1343.             // sql count suite
  1344.             $sql_count .= ') as total ';
  1345.             // from
  1346.             $sql .= ' FROM spectacles s, typesspectacles ty, texts t, text_spectacle ts, schedules sc,
  1347.         contacts c, persons pd, spectacle_person sp, searchs_texts seat, searchs_spectacles seas';
  1348.             // conditions
  1349.             //ddAND t.idtext=ta.idtext
  1350.             $sql .= ' WHERE t.idtext=ts.idtext
  1351.         AND s.idspectacle=ts.idspectacle
  1352.         AND s.idspectacle=sc.idspectacle
  1353.         AND s.idtypespectacle=ty.idtypespectacle
  1354.         AND sc.idcontact=c.idcontact
  1355.         AND (sp.idperson=pd.idperson AND s.idspectacle=sp.idspectacle)
  1356.         AND t.idtext=seat.idtext
  1357.         AND s.idspectacle=seas.idspectacle
  1358.         AND s.publish=\'1\' AND (t.publish=\'1\' || t.textfictif=\'1\')';
  1359.             if (!empty($title)) {
  1360.                 // on match directement
  1361.                 $sql .= ' AND ( MATCH(seat.title) AGAINST (\''.$spectacle->escape($title).'\' IN BOOLEAN MODE)
  1362.                         OR MATCH(seas.title) AGAINST (\''.$spectacle->escape($title).'\' IN BOOLEAN MODE)
  1363.                       )';
  1364.             }
  1365.             // recherche par metteur en scene
  1366.             if (!empty($director)) {
  1367.                 $director htmlspecialchars($directorENT_COMPAT);
  1368.                 $director addslashes($director);
  1369.                 // decouper la chaine
  1370.                 $directorarray explode(' 'trim($director));
  1371.                 if (count($directorarray) > 0) {
  1372.                     $kwtemparray = array();
  1373.                     foreach($directorarray as $ck) {
  1374.                         $kwtemparray[] = " pd.lastname LIKE '%$ck%' ";
  1375.                     }
  1376.                     $sql .= 'AND  (' implode(' OR '$kwtemparray) . ') ';
  1377.                 }
  1378.             }
  1379.             // recherche avec la date
  1380.             if(!empty($datestart)) {
  1381.                 $tabdatestart explode('/'$datestart);
  1382.                 $start_year = (int)$tabdatestart[2];
  1383.                 $start_month = (int)$tabdatestart[1];
  1384.                 $start_day = (int)$tabdatestart[0];
  1385.                 if (checkdate((int)$start_month, (int)$start_day, (int)$start_year)) $datestart $start_year '-' $start_month '-' $start_day;
  1386.             }
  1387.             if(!empty($dateend)) {
  1388.                 $tabdateend explode('/'$dateend);
  1389.                 $end_year = (int)$tabdateend[2];
  1390.                 $end_month = (int)$tabdateend[1];
  1391.                 $end_day = (int)$tabdateend[0];
  1392.                 if (checkdate((int)$end_month, (int)$end_day, (int)$end_year)) $dateend $end_year '-' $end_month '-' $end_day;
  1393.             }
  1394.             // recherche par date
  1395.             if (!empty($datestart) && !empty($dateend)) {
  1396.                 $sql .= ' AND (sc.date BETWEEN (\'' $datestart '\') AND (\'' $dateend '\'))';
  1397.             }
  1398.             // si prochain
  1399.             if(isset($prochain)) {
  1400.                 $sql .= ' AND (sc.date BETWEEN (\''.date('Y-m-d').'\') AND (\''.$prochain.'\'))';
  1401.             }
  1402. //            $month = $form->get('month')->getData();
  1403.             if(empty($month) && isset($_GET['month'])) {
  1404.                 $month $_GET['month'];
  1405.             }
  1406.             if(!empty($month)) {
  1407.                 // date (mois + annee)
  1408.                 $tab explode('-',$month);
  1409.                 $month $tab[0];
  1410.                 $year $tab[1];
  1411.                 $datestart date('Y-m-d',mktime(0,0,0,$month,1,$year)); //premier du mois
  1412.                 $dateend date('Y-m-d',mktime(0,0,0,$month+1,0,$year)); //dernier du mois
  1413.                 $this->view->dateend $spectacle->getFormeDate($dateend,$GLOBALS['format_date'][$lng]);
  1414.                 $this->view->datestart $spectacle->getFormeDate($datestart,$GLOBALS['format_date'][$lng]);
  1415.                 //requete
  1416.                 $sql .= ' AND (sc.date BETWEEN (\''.$datestart.'\') AND (\''.$dateend.'\'))';
  1417.             }
  1418.             // recherche par region
  1419.             if (!empty($area)) {
  1420.                 //nom de la region
  1421.                 $lgarea $regions->getRegionName($area);
  1422.                 //liste des departements de la region
  1423.                 $listedept $regions->getZipCode($area"c");
  1424.                 //region
  1425.                 $sql .= ' AND ' $listedept;
  1426.             }
  1427.             //echo $sql_normal.$sql.$limit;//
  1428.             // nombre d'enregistrement
  1429.             $totalItems $spectacle->queryOne($sql_count.$sql);
  1430.             if(!empty($totalItems) && $totalItems>0) {
  1431.                 $pagerOptions['totalItems'] = $totalItems;
  1432.                 // pagination
  1433. //                require PATH_LIBS.'Pager/Pagersimple.php';
  1434.                 //$this->view->pagination = $paged_data = pagerSimple($pagerOptions);
  1435.                 $urlpagination = new asidesUrlPagination(
  1436.                     '/spectacles/theatre/recherche/generate_params',
  1437.                     array(
  1438.                         //'day' => $context['view']->days,
  1439.                         'title' => $title,
  1440.                         'area' => $area,
  1441.                         'nbpagelimit' => $nbpagelimit,
  1442.                         'datestart' => $datestart,
  1443.                         'dateend' => $dateend
  1444.                     ),
  1445.                     $this->context
  1446.                 );
  1447. //                $view->pagination = $paged_data = pagerSimple($pagerOptions);
  1448.                 $this->view->pagination['spectacle'] = true;
  1449.                 $this->view->pagination['url_custom'] = $urlpagination->url_pagination();
  1450.                 // ajout des criteres de tri apres avoir fait le count
  1451.                 $sql .= ' GROUP BY s.idspectacle ';
  1452.                 //$sql .= " ORDER BY cpts,cpt,s.creation_date DESC";
  1453.                 if(!empty($title)) {
  1454.                     $sql .= ' ORDER BY cpts,cpt DESC';
  1455.                 } elseif(isset($prochain)) {
  1456.                     $sql .= ' ORDER BY sc.date ASC';
  1457.                 } else {
  1458.                     $sql .= ' ORDER BY sc.date DESC';
  1459.                 }
  1460.                 //limite
  1461.                 $limit ' LIMIT '.$this->getLimitStart().', '.$this->perPage;
  1462. //                $limit = array($this->getLimitStart(),$this->perPage);
  1463.                 // executer la requete
  1464.                 $datas $spectacle->query($sql_normal.$sql.$limit);
  1465.                 $spec = [];
  1466.                 // mettre en forme chaque reponse
  1467.                 foreach($datas AS $data)
  1468.                 {
  1469.                     $spectacle->loadResult($data);
  1470.                     // infos
  1471.                     $idspectacle $spectacle->idspectacle;
  1472.                     $spec[$idspectacle] = $spectacle->getInfosSpectacleRow();
  1473.                     // trouver la prochaine et/ou la derniere date
  1474.                     //$spec[$idspectacle]['prochdate'] = $spectacle->getFormeDate($spectacle->prochdate,'%a %d/%m/%Y',true);
  1475.                     //$spec[$idspectacle]['city'] = $spectacle->city;
  1476.                     $spec[$idspectacle]['title_cut'] = $spectacle->cutSentence($spec[$idspectacle]['title'], 50);
  1477.                     // vignette
  1478.                     $spec[$idspectacle]['vignette_affiche'] = $spectacle->getVignetteSpectacle($idspectacle);
  1479.                     //carrer de couleurs
  1480.                     $spec[$idspectacle]['carrer'] = $spectacle->getObjectsCarrerDetails($idspectacle);
  1481.                 }
  1482.                 //passer le spectacle au template
  1483.                 $this->view->spec $spec;
  1484.                 // liens du pager
  1485. //                $paged_data['links'] = str_replace('spectacles/recherche/index.php', '', $paged_data['links']);
  1486.                 //setDebug($paged_data);
  1487. //                if($paged_data['to']<$paged_data['totalItems']) {
  1488. //                    $paged_data['page_numbers']['next_page'] = $paged_data['page_numbers']['current']+1;
  1489. //                }
  1490.             }
  1491.         }
  1492.         // situation et titre meta
  1493.         $this->view->locate = [
  1494.             '/spectacles/' => 'Spectacles',
  1495.             => 'Rechercher des spectacles'
  1496.         ];
  1497.         $this->title_page 'Recherche de spectacles de theatre';
  1498.         $this->rub_courante 'spectacles';
  1499.         // jquery
  1500.         $this->view->jquery_cal 'datepicker';
  1501.         $this->view->jquery_flash true;
  1502.         return $this->view('spectacles/recherche.html.twig', [
  1503.             'form' => $form->createView()
  1504.         ]);
  1505.     }
  1506.     /**
  1507.      * @Route("/spectacles/theatre/affiche-videos", name="spectacles_affiche_videos")
  1508.      *
  1509.      * @return \Symfony\Component\HttpFoundation\Response
  1510.      *
  1511.      */
  1512.     public function action_affiche_video()
  1513.     {
  1514.         $this->view->action $this->context['action'] = 'affiche-videos';
  1515.         $multimedias $this->em->getRepository(Multimedias::class);
  1516.         $spectacles $this->em->getRepository(Spectacles::class);
  1517.         //menu pour l'aside Spéctacles à venir
  1518.         $spectacles_a_venir = array(
  1519.             array(
  1520.                 'name' => 'Dans les 7 prochains jours',
  1521.                 'key_day' => '7',
  1522.             ),
  1523.             array(
  1524.                 'name' => 'Dans les 30 prochains jours',
  1525.                 'key_day' => '30',
  1526.             ),
  1527.             array(
  1528.                 'name' => 'Dans les 3 prochains mois',
  1529.                 'key_day' => '90',
  1530.             ),
  1531.             array(
  1532.                 'name' => 'Dans les 12 prochains mois',
  1533.                 'key_day' => '365',
  1534.             ),
  1535.         );
  1536.         $day_spectacles 365$day_all false;
  1537.         if(!empty($_REQUEST['d'])){
  1538.             if(in_array($_REQUEST['d'], array_column($spectacles_a_venir'key_day'))){
  1539.                 $day_spectacles intval($_REQUEST['d']);
  1540.                 if(!is_numeric($day_spectacles)){
  1541.                     $day_all true;
  1542.                 }
  1543.             }
  1544.         }
  1545.         $this->context['view']->jours_affiche $day_spectacles;
  1546.         $this->context['view']->jours_affiche_all $day_all;
  1547.         // recherche de base
  1548.         $params_query_count = array(
  1549.             'prochains' => $day_spectacles
  1550.         );
  1551.         $params_query_affiches = array(
  1552.             'affiche' => array('today' => $day_spectacles),
  1553.             'limit' => array(0,100),
  1554.             'dbg' => array('affiche','Vidéos de spectacles à l\'affiche'),
  1555.         );
  1556.         $this->context['view']->insert_block 'spectacles/affiche-videos.choix.inc.html';
  1557.         // dates de debut et de fin
  1558.         $this->getCommonSearch();
  1559.         $this->getCommonSearchView();
  1560.         // trouver le spectacle avec la date la plus éloignée ou les dates
  1561.         $sql 'SELECT MAX(sc.`date`)
  1562.         FROM schedules sc
  1563.             JOIN object_multimedia om ON om.`idobject`=sc.`idspectacle`
  1564.         WHERE
  1565.         om.`object`=\'spectacles\'
  1566.         AND sc.`date`>=\''.date('Y-m-d').'\'';
  1567.         $datemax $multimedias->queryOne($sql);
  1568.         $this->context['view']->datemax $datemax;
  1569.         // datestart ?
  1570.         if(isset($_REQUEST['datestart']) && !empty($_REQUEST['datestart'])) {
  1571.             $datestart filter_var($_REQUEST['datestart']);
  1572.         } else {
  1573.             $datestart null;
  1574.         }
  1575.         // dateend ?
  1576.         if(isset($_REQUEST['dateend']) && !empty($_REQUEST['dateend'])) {
  1577.             $dateend filter_var($_REQUEST['dateend']);
  1578.         } else {
  1579.             $dateend null;
  1580.         }
  1581.         // si datestart et dateend, on recherche dans la période
  1582.         if(!empty($datestart) && !empty($dateend)) {
  1583.             // paser a la vue
  1584.             $this->context['view']->datestart $datestart;
  1585.             $this->context['view']->dateend $dateend;
  1586.             // convertir en en
  1587.             $datestart $multimedias->getFormeDate($datestart);
  1588.             $dateend $multimedias->getFormeDate($dateend);
  1589.             // les dates doivent être entre hier et le max
  1590.             if($datestart<date('Y-m-d')) {
  1591.                 $datestart date('Y-m-d');
  1592.             }
  1593.             if($dateend>$datemax) {
  1594.                 $dateend $datemax;
  1595.             }
  1596.             $params_query_affiches['affiche'] = array(
  1597.                 'datestart' => $datestart,
  1598.                 'dateend' => $dateend
  1599.             );
  1600.             $params_query_count = array(
  1601.                 'prochains' => array($datestart$dateend)
  1602.             );
  1603.         }
  1604.         $params_query_count_schedules = array(
  1605.             'special' => array(
  1606.                 'prochains' => $params_query_count['prochains']
  1607.             )
  1608.         );
  1609.         $count_videos $spectacles->countSpectaclesWithMultimedias($params_query_count);
  1610.         $totalRepresentations $spectacles->countListSchedules($params_query_count_schedules);
  1611.         if($count_videos 0){
  1612.             $this->perPage 20;
  1613.             // pagination
  1614.             $this->context['view']->pagination $this->getPagination($count_videos);
  1615.             $this->view->pagination['spectacle'] = true;
  1616.             $this->view->pagination['representation_spectacle'] = true;
  1617.             $this->view->pagination['total_dates'] = number_format($totalRepresentations0''' ');
  1618.             $this->view->pagination['url_custom'] = '/spectacles/theatre/affiche-videos/?d='.intval($day_spectacles);
  1619.             // TODO à revoir ici aussi
  1620.             $paged_data['from'] = 10;
  1621.             $params_query_affiches['limit'] = array($this->getLimitStart(), $this->perPage);
  1622.         }
  1623.         $format_vignette = array('width'=>$_ENV['VIGN_VIDEO_WIDTH'],'height'=>$_ENV['VIGN_VIDEO_HEIGHT'],'fleche'=>'none','ratio' => '169');
  1624.         $this->context['view']->videos $multimedias->getListMultimedias($params_query_affiches,$format_vignette,array('get_schedule' => true,'format_vignette' => true));
  1625.         // situation et titre meta
  1626.         $this->view->locate = array(
  1627.             '/spectacles/' => 'Spectacles',
  1628.             => 'À l\'affiche en vidéo'
  1629.         );
  1630.         $this->title_page 'Vidéos de spectacles à l\'affiche';
  1631.         $this->rub_courante 'spectacles';
  1632.         // jquery
  1633.         $this->context['view']->jquery_cal 'datepicker';
  1634.         //Menu
  1635.         $spectacles_voir = array(
  1636.             array(
  1637.                 'name' => 'Tous les spectacles',
  1638.                 'key_filtre' => ''// TODO:  fixe v2
  1639.                 'action' => 'view',
  1640.             ),
  1641.             array(
  1642.                 'name' => 'Tous les spectacles avec vidéos',
  1643.                 'key_filtre' => 'theatre/affiche-videos/',
  1644.                 'action' => 'affiche-videos',
  1645.             )
  1646.         );
  1647.         $filtre_spectacles 'view';
  1648.         if(in_array($this->context['action'], array_column($spectacles_voir'action'))){
  1649.             $filtre_spectacles $this->context['action'];
  1650.         }
  1651.         // aside top
  1652.         $asides_top = new asides();
  1653.         $asides_top->load(['aside_top' => array(
  1654.             'php' => array(
  1655.                 'method' => 'asidesUrlListMenuVideos',
  1656.             )
  1657.         )
  1658.         ]);
  1659.         $this->context['view']->aside_top $asides_top->view($this->context['view']);
  1660.         //aside
  1661.         $asides = new asides();
  1662.         $asides->load(['url_lists,spectacles_voir' => array(
  1663.             'exec' => array(
  1664.                 'htmlstart' => true,
  1665.                 'color' => 'videos'
  1666.             ),
  1667.             'php' => array(
  1668.                 'method' => 'asidesUrlLists',
  1669.                 'urls' => $spectacles_voir,
  1670.                 'url' => '/spectacles/key_filtre',
  1671.                 'params' => array(
  1672.                     'activate' => $filtre_spectacles
  1673.                 )
  1674.             ),
  1675.             'title' => html_entity_decode('&Agrave; l\'affiche'),
  1676.         )]);
  1677.         $asides->load(['url_lists,jours_a_venir' => array(
  1678.             'exec' => array(
  1679.                 'alone' => false,
  1680.                 'color' => 'videos'
  1681.             ),
  1682.             'php' => array(
  1683.                 'method' => 'asidesUrlLists',
  1684.                 'urls' => $spectacles_a_venir,
  1685.                 'url' => '/spectacles/theatre/affiche-videos/?d=key_day',
  1686.                 'params' => array(
  1687.                     'activate' => $day_spectacles
  1688.                 )
  1689.             ),
  1690.             'title' => html_entity_decode('Recherche par période'),
  1691.         )]);
  1692.         $asides->load(['recherche_par_periode' => array(
  1693.             'exec' => array(
  1694.                 'htmlend' => true,
  1695.                 'color' => 'videos'
  1696.             ),
  1697.             'url' => '/spectacles/theatre/affiche-videos/'
  1698.         )]);
  1699.         $asides->load(['url_lists_alone,tn_cdn_sn' => array(
  1700.             'exec' => ['color' => 'videos'],
  1701.             'php' => [
  1702.                 'url' => '/spectacles/liste/structures',
  1703.                 'method' => 'tn_cdn_sn',
  1704.                 'params' => array(
  1705.                     'activate' => (isset($this->context['view']->typestructure['idtypestructure'])) ? $this->context['view']->typestructure['idtypestructure'] : 'ALL'
  1706.                 ),
  1707.                 'structure' => array(
  1708.                     'structure_classic' => array(
  1709.                         'idtypestructure' => 'key_structure'
  1710.                     )
  1711.                 )
  1712.             ],
  1713.             'title' => 'Voir dans'
  1714.         )]);
  1715.         $asides->load(['common_carte' => array(
  1716.             'exec' => ['color' => 'videos'],
  1717.             'url' => '/spectacles/theatre/region-videos/area/get_id?d=365'
  1718.         )]);
  1719.         $menu = array(
  1720.             array(
  1721.                 'name' => 'Mes videos favorites',
  1722.                 'key_sub' => 'videos',
  1723.             ),
  1724.             array(
  1725.                 'name' => 'Mes videos modifiables',
  1726.                 'key_sub' => 'mesvideos',
  1727.             ),
  1728.         );
  1729.         $asides->load(['url_lists_alone' => array(
  1730.             'exec' => ['color' => 'index'],
  1731.             'php' => [
  1732.                 'method' => 'asidesUrlLists',
  1733.                 'urls' => $menu,
  1734.                 'url' => '/montheatre/key_sub'
  1735.             ],
  1736.             'title' => 'Mon théâtre'
  1737.         )]);
  1738.         asides::setEntityManager($this->em);
  1739.         asides::loadaside('Publicite')->addWithNational($asides); //$this->area
  1740.         $asides->load(['common_participer' => array(
  1741.             'exec' => ['color' => 'videos'],
  1742.             'php' => array(
  1743.                 'method' => 'asidesUrlLists_Ajoutez'
  1744.             )
  1745.         )]);
  1746.         $this->context['view']->aside $asides->view($this->context['view']);
  1747.         //On affiche la publicité google
  1748.         $asides_publicite = new asides();
  1749.         asides::setEntityManager($this->em);
  1750.         asides::loadaside('Publicite')->addGoogle($asides_publicite$this->serviceAbonnements);
  1751.         $this->context['view']->asides_publicite $asides_publicite->view($this->context['view']);
  1752.         return $this->view('spectacles/affiche-videos.html.twig');
  1753.     }
  1754.     // {{{
  1755.     public function getAsidesStructures()
  1756.     {
  1757.         $this->title_page $this->context['view']->type_title['name'].' dans les '.$this->context['view']->typestructure['typestructure_pluriel'];
  1758.         // situation et titre meta
  1759.         $this->view->locate = array(
  1760.             '/spectacles/' => 'Spectacles',
  1761.             => $this->title_page,
  1762.         );
  1763.         // ajouter masonery
  1764.         $this->context['view']->js_more[] = 'jquery.masonry.min.js';
  1765.         foreach($this->context['view']->spectacles as $k=>$v) {
  1766.             $this->context['view']->spectacles[$k]['footer_contact'] = true;
  1767.         }
  1768.         // jajascript
  1769.         $this->context['view']->js_more[] = 'jquery.masonry.min.js';
  1770.         $this->context['view']->jquery_cal 'datepicker';
  1771.         $this->context['view']->use_addthis true;
  1772.         $asides_top = new asides();
  1773.         $asides_top->load(['aside_top' => array(
  1774.             'php' => array(
  1775.                 'method' => 'asidesUrlListsMenuCDN',
  1776.                 'activate' => (!empty($this->context['view']->menu_content[$this->context['view']->type]['activate'])) ? $this->context['view']->menu_content[$this->context['view']->type]['activate'] : ''
  1777.             )
  1778.         )
  1779.         ]);
  1780.         $spectacles_videos false;
  1781.         if($this->context['view']->type=='spectacles-videos') {
  1782.             unset($this->context['view']->menu_content['spectacles']);
  1783.             unset($this->context['view']->menu_content['coproductions']);
  1784.             $spectacles_videos true;
  1785.         }
  1786.         else{
  1787.             unset($this->context['view']->menu_content['spectacles-videos']);
  1788.         }
  1789.         //on execute les asides pour le menu top
  1790.         $this->context['view']->aside_top $asides_top->view($this->context['view']);
  1791.         // On ajoute des placeholder au input
  1792. //        $form->addElement('text', 'datestart', 'Entre', array('size'=>'10','id'=>'datestart','placeholder' => 'Début'));
  1793. //        $form->addElement('text', 'dateend', 'et', array('size'=>'10','id'=>'dateend','placeholder' => 'Fin'));
  1794.         $asides = new asides();
  1795.         $asides->load(['url_lists,navigation_spectacles' => array(
  1796.             'exec' => ($spectacles_videos) ? ['htmlstart' => true'color'=> 'videos'] : ['htmlstart' => true'color'=> 'spectacles'],
  1797.             'php' => array(
  1798.                 'method' => 'asidesUrlLists',
  1799.                 'urls' => $this->context['view']->menu_content,
  1800.                 'url' => '/spectacles/liste/structuresgenerate_params',
  1801.                 'params' => array(
  1802.                     'activate' =>
  1803.                         !empty($this->__getView('requestDirecteur'))
  1804.                             ? $this->__getView('requestDirecteur')
  1805.                             : $this->__getView('type')
  1806.                 ),
  1807.                 'structure' => array(
  1808.                     'structure_classic' => array(
  1809.                         'd' => 'v_days',
  1810.                         'type' => 'key_type',
  1811.                         's' => 'v_saison',
  1812.                         'y' => 'v_year',
  1813.                         'dateend' => 'v_dateend',
  1814.                         'datestart' => 'v_datestart',
  1815.                         'idtypestructure' => 'v_idtypestructure',
  1816.                         'directeur' => 'key_directeur',
  1817.                     )
  1818.                 )
  1819.             ),
  1820.             'title' => html_entity_decode('&Agrave; l\'affiche'),
  1821.         )]);
  1822.         $asides->load(['url_lists,spectacles_a_venir' => array(
  1823.             'exec' => ($spectacles_videos) ? ['alone' => false'color'=> 'videos'] : ['alone' => false'color'=> 'spectacles'],
  1824.             'php' => array(
  1825.                 'method' => 'asidesUrlLists',
  1826.                 'urls' => $this->context['view']->menu_jours,
  1827.                 'url' => '/spectacles/liste/structuresgenerate_params'//'/spectacles/liste/structures/?type={v_type}&idtypestructure={v_idtypestructure}&d=key_day&s={v_saison}&y={v_year}&datestart={v_datestart}&dateend={v_dateend}',
  1828.                 'params' => array(
  1829.                     'key_day' => 'auto_key'
  1830.                 ),
  1831.                 'structure' => array(
  1832.                     'structure_classic' => array(
  1833.                         'd' => 'key_day',
  1834.                         'type' => 'v_type',
  1835.                         'y' => 'v_year',
  1836.                         'idtypestructure' => 'v_idtypestructure'
  1837.                     )
  1838.                 )
  1839.             ),
  1840.             'title' => html_entity_decode('Recherche par période'),
  1841.         )]);
  1842.         if(!$spectacles_videos){
  1843.             $asides->load(['recherche_par_periode' => array(
  1844.                 'exec' => ($spectacles_videos) ? ['alone' => false'color'=> 'videos'] : ['alone' => false'color'=> 'spectacles'],
  1845.                 'php' => array(
  1846.                     'method' => 'asidesUrlListsForms',
  1847.                     'url' => '/spectacles/liste/structuresgenerate_params',
  1848.                     'params' => array(
  1849.                         'k_type' => $this->view->type,
  1850.                         'k_typestructure' => $this->view->idtypestructure
  1851.                     ),
  1852.                     'structure' => array(
  1853.                         'structure_classic' => array(
  1854.                             'type' => 'k_type',
  1855.                             'idtypestructure' => 'k_typestructure'
  1856.                         )
  1857.                     )
  1858.                 )
  1859.             )]);
  1860.         }
  1861.         $asides->load(['par_saison_alone' => array(
  1862.             'exec' => array(
  1863.                 'htmlend' => true
  1864.             )
  1865.         )]);
  1866.         $asides->load(['url_lists_alone,tn_cdn_sn' => array(
  1867.             'exec' => ($spectacles_videos) ? ['color'=> 'videos'] : ['color'=> 'spectacles'],
  1868.             'php' => [
  1869.                 'method' => 'tn_cdn_sn',
  1870.                 'url' => '/key_controller/liste/structures/generate_params',
  1871.                 'params' => array(
  1872.                     'activate' => $this->context['view']->typestructure['idtypestructure'],
  1873.                     'url_custom' => ['ALL' => '/spectacles/']
  1874.                 ),
  1875.                 'structure' => array(
  1876.                     'structure_classic' => array(
  1877.                         'd' => 'v_days',
  1878.                         'type' => 'v_type',
  1879.                         's' => 'v_saison',
  1880.                         'y' => 'v_year',
  1881.                         'dateend' => 'v_dateend',
  1882.                         'datestart' => 'v_datestart',
  1883.                         'idtypestructure' => 'key_structure'
  1884.                     )
  1885.                 )
  1886.             ],
  1887.             'title' => 'Voir dans'
  1888.         )]);
  1889.         if(!$spectacles_videos){
  1890.             $asides->load(['common_carrer_informations'=> array(
  1891.                 'color' => 'spectacles'
  1892.             )]);
  1893.         }
  1894.         $asides->load(['common_carte' => array(
  1895.             'exec' => ($spectacles_videos) ? ['color'=> 'videos'] : ['color'=> 'spectacles'],
  1896.             'php' => [
  1897.                 'method' => 'asidesUrlLists',
  1898.                 'url' => ($spectacles_videos) ? '/spectacles/theatre/region-videos/area/get_id/' '/key_controller/theatre/region/area/get_id/liste?idtypestructure={v_idtypestructure}',
  1899.                 'params' => array(
  1900.                     'key_controller' => $this->context['controller']
  1901.                 )
  1902.             ]
  1903.         )]);
  1904.         $asides->load(['spectacles_infos' => array(
  1905.             'exec' => ($spectacles_videos) ? ['color'=> 'videos'] : ['color'=> 'spectacles']
  1906.         )]);
  1907.         $this->context['view']->aside $asides->view($this->context['view']);
  1908.     }
  1909.     // }}}
  1910.     // {{{ action_xml_structures()
  1911.     /** Cartes de France
  1912.      *
  1913.      */
  1914.     public function action_xml_structures()  { $this->getCommonXmlCarte(); }
  1915.     // }}}
  1916.     // {{{ getContactsByType()
  1917.     /** Les contacts par tupe de structure avec bandeau
  1918.      *
  1919.      */
  1920.     public function getContactsByType($idtypestructure) {
  1921.         // rechercher les scènes conventionnées
  1922.         $params_sql_typestructure = array(
  1923.             'where' => array(
  1924.                 array('contacts''idtypestructure'$idtypestructure),
  1925.                 array('contacts''country''FR'),
  1926.                 ' AND contacts.idcontact NOT IN (SELECT idcontact FROM contact_classification WHERE idclassification=99) ',
  1927.             ),
  1928.             'order' => array('contacts' => 'organisation'),
  1929.             'direction' => 'ASC',
  1930.             'idclassification' => array('NOT' => array(99)),
  1931.             'limit' => array(0,500),
  1932.             'dbg' => array('structures','Contacts avec un type précis'),
  1933.         );
  1934.         $structures $this->em->getRepository(Contacts::class)->getListContacts($params_sql_typestructure);
  1935.         // classe fichiers
  1936.         $files $this->em->getRepository(Files::class);
  1937.         foreach($structures as $k=>$s) {
  1938.             $ids_contact[] = $s['idcontact'];
  1939.             // voir si la structure à une petite bannière
  1940.             $structures[$k]['petit_bandeau'] = $files->getObjectFiles($s['idcontact'],'contacts',114);
  1941.         }
  1942.         return array(
  1943.             'contacts' => $structures,
  1944.             'nb_contacts' => count($structures),
  1945.             'ids' => $ids_contact,
  1946.         );
  1947.     }
  1948.     // }}}
  1949.     // {{{
  1950.     /**
  1951.      *
  1952.      * @Route("/spectacles/statut/non-accessible", name="spectacles_non_accessible")
  1953.      *
  1954.      * @return bool|\Symfony\Component\HttpFoundation\Response
  1955.      *
  1956.      */
  1957.     public function action_non_accessible()
  1958.     {
  1959.         return $this->view('spectacles/non-accessible.html.twig');
  1960.     }
  1961.     // }}}
  1962.     // {{{ getSaisonsAndAnneesByContacts()
  1963.     /** Les saisons/années de spectacle pour des contacts
  1964.      *
  1965.      */
  1966.     public function getSaisonsAndAnneesByContacts($ids_contact) {
  1967.         $saisons = array();
  1968.         $saisons_key = array();
  1969.         $annees = array();
  1970.         // grouper les dates par saisons => dans les lieux
  1971.         $sql_annees 'SELECT schedules.`date`, YEAR(schedules.`date`) as annee
  1972.                        FROM schedules, spectacles
  1973.                        WHERE schedules.`idspectacle`=spectacles.`idspectacle`
  1974.                        AND spectacles.`publish`=1
  1975.                        AND schedules.`idcontact` IN ('.join(','$ids_contact).')
  1976.                        AND schedules.`date` > \'1999-12-31\'
  1977.                        ORDER BY schedules.`date` ';
  1978.         $listdates $this->spectacles->queryAll($sql_annees);
  1979.         // debug de la boucle
  1980.         if(!empty($_REQUEST['dbg_sql_object'])) {
  1981.             $this->spectacles->setTraceInfos(array(
  1982.                 'execution_time_boucle' => (microtime(true) - $start_sql),
  1983.                 'nb_occurence' => count($listdates),
  1984.                 'sql_query' => $sql_annees,
  1985.                 'dbg' => array('dates''Liste des dates'),
  1986.             ));
  1987.         }
  1988.         // liste des saisons et des années
  1989.         if(empty($listdates)) {
  1990.             return $listdates->getDebugInfos();
  1991.         } elseif(!empty($listdates)) {
  1992.             foreach($listdates as $a) {
  1993.                 if($a['date']>date('Y-m-d'mktime(0,0,0,8,31,$a['annee'])) ) {
  1994.                     $s $a['annee'].'-'.($a['annee']+1);
  1995.                 } else {
  1996.                     $s = ($a['annee']-1).'-'.$a['annee'];
  1997.                 }
  1998.                 $saisons[$s] = $s;
  1999.                 $saisons_key[] = $s;
  2000.                 $annees[$a['annee']] = $a['annee'];
  2001.             }
  2002.         }
  2003.         return  array(
  2004.             'saisons' => $saisons,
  2005.             'saisons_key' => $saisons_key,
  2006.             'annees' => $annees,
  2007.         );
  2008.     }
  2009.     // }}}
  2010.     // {{{ setBandeauPartenaire()
  2011.     /** Ajout du bandeau partenaire pour des blocs spectacles
  2012.      *
  2013.      */
  2014.     public function setBandeauPartenaire($spectacles) {
  2015.         // bandeau partenaire
  2016.         if(!empty($spectacles)) {
  2017.             $files $this->em->getRepository(Files::class);
  2018.             foreach($spectacles as $k=>$v) {
  2019.                 $spectacles[$k]['bloc'] = true;
  2020.                 if(!empty($spectacles[$k]['city'])) {
  2021.                     $spectacles[$k]['city_barre'] = $spectacles[$k]['city'];
  2022.                 }
  2023.                 if(!empty($v['contact']['idcontact'])) {
  2024.                     $bandeau_partenaire $files->getObjectFiles($v['contact']['idcontact'],'contacts',114);
  2025.                     if(!empty($bandeau_partenaire)) {
  2026.                         $spectacles[$k]['contact']['bandeau_partenaire'] = $bandeau_partenaire[0]['url_file_path'];
  2027.                     }
  2028.                 }
  2029.             }
  2030.         }
  2031.         return $spectacles;
  2032.     }
  2033.     // }}}
  2034.     // {{{ setCommonSearch()
  2035.     /** Fonction pour le block de recherche commun
  2036.      *
  2037.      */
  2038.     public function setCommonSearch()
  2039.     {
  2040.         $form $this->get('form.factory')->createBuilder(FormType::class, null, [
  2041.             'attr' => [
  2042.                 'id' => 'masterform'
  2043.             ]
  2044.         ]);
  2045.         $form->add('title'TextType::class, [
  2046.             'label' => 'Titre de la pièce',
  2047.             'attr' => [
  2048.                 'size' => '35'
  2049.             ],
  2050.             'required' => false
  2051.         ]);
  2052.         $form->add'validation'SubmitType::class, [
  2053.             'label' => 'Lancer la recherche',
  2054.             'attr' => [
  2055.                 'class'=>'boutform'
  2056.             ]
  2057.         ]);
  2058.         $form->add('datestart'TextType::class, [
  2059.             'label' => 'Entre',
  2060.             'attr' => [
  2061.                 'size'=>'7',
  2062.                 'id'=>'datestart',
  2063.                 'placeholder' => 'Début'
  2064.             ],
  2065.             'required' => false
  2066.         ]);
  2067.         $form->add'dateend'TextType::class, [
  2068.             'label' => 'et',
  2069.             'attr' => [
  2070.                 'size'=>'7',
  2071.                 'id'=>'dateend',
  2072.                 'placeholder' => 'Fin'
  2073.             ],
  2074.             'translation_domain' => false,
  2075.             'required' => false
  2076.         ]);
  2077. //        $month_list = month();
  2078. //        $form->add('month', $this->context['tr']->trans('mois'), ChoiceType::class, [
  2079. //            'choices '=> $month_list,
  2080. //            'attr' => [
  2081. //                'class'=>'select_type'
  2082. //            ]
  2083. //        ]);
  2084.         return $form;
  2085.     }
  2086.     // }}}
  2087. }